MCPcopy Create free account
hub / github.com/microsoft/SandDance / ToggleBase1

Function ToggleBase1

docs/app/js/sanddance-app.js:50987–51018  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

50985var ToggleBase = /** @class */ function(_super) {
50986 (0, _tslib.__extends)(ToggleBase1, _super);
50987 function ToggleBase1(props) {
50988 var _this = _super.call(this, props) || this;
50989 _this._toggleButton = _react.createRef();
50990 _this._onClick = function(ev) {
50991 // eslint-disable-next-line deprecation/deprecation
50992 var _a = _this.props, disabled = _a.disabled, checkedProp = _a.checked, onChange = _a.onChange, onChanged = _a.onChanged, onClick = _a.onClick;
50993 var checked = _this.state.checked;
50994 if (!disabled) {
50995 // Only update the state if the user hasn't provided it.
50996 if (checkedProp === undefined) _this.setState({
50997 checked: !checked
50998 });
50999 if (onChange) onChange(ev, !checked);
51000 if (onChanged) onChanged(!checked);
51001 if (onClick) onClick(ev);
51002 }
51003 };
51004 (0, _utilities.initializeComponentRef)(_this);
51005 (0, _utilities.warnMutuallyExclusive)(COMPONENT_NAME, props, {
51006 checked: "defaultChecked"
51007 });
51008 (0, _utilities.warnDeprecations)(COMPONENT_NAME, props, {
51009 onAriaLabel: "ariaLabel",
51010 offAriaLabel: undefined,
51011 onChanged: "onChange"
51012 });
51013 _this.state = {
51014 checked: !!(props.checked || props.defaultChecked)
51015 };
51016 _this._id = (0, _utilities.getId)("Toggle");
51017 return _this;
51018 }
51019 ToggleBase1.getDerivedStateFromProps = function(nextProps, prevState) {
51020 if (nextProps.checked === undefined) return null;
51021 return {

Callers

nothing calls this directly

Calls 1

onClickFunction · 0.70

Tested by

no test coverage detected