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

Function CheckboxBase1

docs/app/js/sanddance-app.js:39742–39825  ·  view source on GitHub ↗

* Initialize a new instance of the Checkbox * @param props - Props for the component * @param context - Context or initial state for the base component.

(props1, context)

Source from the content-addressed store, hash-verified

39740 * @param props - Props for the component
39741 * @param context - Context or initial state for the base component.
39742 */ function CheckboxBase1(props1, context) {
39743 var _this = _super.call(this, props1, context) || this;
39744 _this._checkBox = _react.createRef();
39745 _this._renderContent = function(checked, indeterminate, keytipAttributes) {
39746 if (keytipAttributes === void 0) keytipAttributes = {};
39747 var _a = _this.props, disabled = _a.disabled, inputProps = _a.inputProps, name = _a.name, ariaLabel = _a.ariaLabel, ariaLabelledBy = _a.ariaLabelledBy, ariaDescribedBy = _a.ariaDescribedBy, _b = _a.onRenderLabel, onRenderLabel = _b === void 0 ? _this._onRenderLabel : _b, checkmarkIconProps = _a.checkmarkIconProps, ariaPositionInSet = _a.ariaPositionInSet, ariaSetSize = _a.ariaSetSize, title = _a.title, label = _a.label;
39748 return _react.createElement("div", {
39749 className: _this._classNames.root,
39750 title: title
39751 }, _react.createElement((0, _utilities.FocusRects), null), _react.createElement("input", (0, _tslib.__assign)({
39752 type: "checkbox"
39753 }, inputProps, {
39754 "data-ktp-execute-target": keytipAttributes["data-ktp-execute-target"],
39755 checked: checked,
39756 disabled: disabled,
39757 className: _this._classNames.input,
39758 ref: _this._checkBox,
39759 name: name,
39760 id: _this._id,
39761 title: title,
39762 onChange: _this._onChange,
39763 onFocus: _this._onFocus,
39764 onBlur: _this._onBlur,
39765 "aria-disabled": disabled,
39766 "aria-label": ariaLabel || label,
39767 "aria-labelledby": ariaLabelledBy,
39768 "aria-describedby": (0, _utilities.mergeAriaAttributeValues)(ariaDescribedBy, keytipAttributes["aria-describedby"]),
39769 "aria-posinset": ariaPositionInSet,
39770 "aria-setsize": ariaSetSize,
39771 "aria-checked": indeterminate ? "mixed" : checked ? "true" : "false"
39772 })), _react.createElement("label", {
39773 className: _this._classNames.label,
39774 htmlFor: _this._id
39775 }, _react.createElement("div", {
39776 className: _this._classNames.checkbox,
39777 "data-ktp-target": keytipAttributes["data-ktp-target"]
39778 }, _react.createElement((0, _icon.Icon), (0, _tslib.__assign)({
39779 iconName: "CheckMark"
39780 }, checkmarkIconProps, {
39781 className: _this._classNames.checkmark
39782 }))), onRenderLabel(_this.props, _this._onRenderLabel)));
39783 };
39784 _this._onFocus = function(ev) {
39785 var inputProps = _this.props.inputProps;
39786 if (inputProps && inputProps.onFocus) inputProps.onFocus(ev);
39787 };
39788 _this._onBlur = function(ev) {
39789 var inputProps = _this.props.inputProps;
39790 if (inputProps && inputProps.onBlur) inputProps.onBlur(ev);
39791 };
39792 _this._onChange = function(ev) {
39793 var onChange = _this.props.onChange;
39794 var _a = _this.state, isChecked = _a.isChecked, isIndeterminate = _a.isIndeterminate;
39795 if (!isIndeterminate) {
39796 if (onChange) onChange(ev, !isChecked);
39797 if (_this.props.checked === undefined) _this.setState({
39798 isChecked: !isChecked
39799 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected