@muraldevkit/ui-toolkit 4.84.1 → 4.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
35
35
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
36
36
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
37
37
 
38
- var _excluded = ["attrs", "className", "description", "hasMultilineLabel", "state", "selected", "icon", "label", "eventId"];
38
+ var _excluded = ["attrs", "className", "description", "hasMultilineLabel", "state", "selected", "icon", "label", "eventId", "onChange"];
39
39
  /**
40
40
  * Form element with an associated text label that allows the user to select one or more options
41
41
  * from a provided list
@@ -56,6 +56,8 @@ function MrlCheckbox(_ref) {
56
56
  icon = _ref.icon,
57
57
  label = _ref.label,
58
58
  eventId = _ref.eventId,
59
+ _ref$onChange = _ref.onChange,
60
+ onChange = _ref$onChange === void 0 ? attrs.onChange : _ref$onChange,
59
61
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
60
62
  var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlCheckbox', eventId);
61
63
  var checkboxIdRef = React__namespace.useRef(setAttributes.getUniqueId('mrl-checkbox'));
@@ -76,24 +78,27 @@ function MrlCheckbox(_ref) {
76
78
  // setAttributes always sets className="" which always triggers the warning message in the MrlCheckboxStandalone component
77
79
  delete attributes.className;
78
80
 
79
- // the consumer's handler arrives through `attrs`, so wrap it before handing the
80
- // attributes down to the standalone input.
81
- var consumerOnChange = attributes.onChange;
82
- attributes.onChange = e => {
81
+ /**
82
+ * Handle change events
83
+ *
84
+ * @param {React.ChangeEvent<HTMLInputElement>} e - change event
85
+ */
86
+ var handleChange = e => {
83
87
  trackInteraction({
84
88
  action: 'checked',
85
89
  metadata: {
86
90
  selected: e.target.checked
87
91
  }
88
92
  });
89
- consumerOnChange === null || consumerOnChange === void 0 ? void 0 : consumerOnChange(e);
93
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
90
94
  };
91
95
  return /*#__PURE__*/React__namespace.createElement("div", {
92
96
  className: allClasses
93
97
  }, /*#__PURE__*/React__namespace.createElement(MrlCheckboxStandalone.MrlCheckboxStandalone, _rollupPluginBabelHelpers.extends({}, rest, {
98
+ attrs: attributes,
99
+ onChange: handleChange,
94
100
  selected: selected,
95
- state: state,
96
- attrs: attributes
101
+ state: state
97
102
  })), /*#__PURE__*/React__namespace.createElement(MrlLabelWithDescription.MrlLabelWithDescription, {
98
103
  isDisabled: state === 'disabled',
99
104
  isSelected: selected === 'checked',
@@ -1 +1 @@
1
- {"version":3,"file":"MrlCheckbox.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckbox/MrlCheckbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport {\n\tcheckboxDefaults,\n\tCheckboxSelected,\n\tCheckboxStates,\n\tStaticIconConfig\n} from '../../constants';\nimport { MrlCheckboxStandalone } from '../MrlCheckboxStandalone/MrlCheckboxStandalone';\nimport { checkInvalidAttributes } from '../../../../utils/checkInvalidAttributes';\n\nimport './MrlCheckbox.global.scss';\nimport styles from './MrlCheckbox.module.scss';\nimport { MrlLabelWithDescription } from '../../label/MrlLabelWithDescription';\nimport { getDescribedby } from '../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlCheckboxProps {\n\t/** Applies additional HTML attributes to the checkbox element */\n\tattrs?: AttrsObject;\n\t/** Additional class to add to the container of the checkbox and label */\n\tclassName?: string;\n\t/** Adjusts the styles of the label, icon and description when the label is multiline */\n\thasMultilineLabel?: boolean;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/** Sets what selection state the checkbox is in. */\n\tselected?: CheckboxSelected;\n\t/** The text to display as the checkbox's label */\n\tlabel: string;\n\t/** Leading label icon */\n\ticon?: StaticIconConfig;\n\t/**\n\t * Description, additional context text for the user.\n\t * It can be a string or a React component for custom render.\n\t * When using a React component it's necessary to add an id to the custom element and\n\t * pass it to the MrlCheckbox through 'attrs[\"aria-describedby\"]' to make it accessible\n\t * to screen readers.\n\t * Custom description should also implement the disabled state styles\n\t * for text when the input is disabled or set color: inherit.\n\t * @example\n\t * <MrlCheckbox attrs={{ 'aria-describedby': customId }} description={\n\t * <p id={customId}>description</p>\n\t * }>\n\t */\n\tdescription?: string | React.ReactNode;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Form element with an associated text label that allows the user to select one or more options\n * from a provided list\n * @param {MrlCheckboxProps} props - the component props\n * @returns a checkbox element with an associated label\n */\nexport function MrlCheckbox({\n\tattrs = {},\n\tclassName,\n\tdescription,\n\thasMultilineLabel = false,\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\ticon,\n\tlabel,\n\teventId,\n\t...rest\n}: MrlCheckboxProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckbox', eventId);\n\tconst checkboxIdRef = React.useRef<string>(getUniqueId('mrl-checkbox'));\n\tconst descriptionId = `${checkboxIdRef.current}-description`;\n\n\tconst allClasses = classnames(\n\t\tattrs.class || attrs.className,\n\t\tclassName,\n\t\t'MrlCheckbox',\n\t\tstyles['MrlCheckbox'],\n\t\t{\n\t\t\t[styles['mrl-is--disabled']]: state === 'disabled',\n\t\t\t[styles['mrl-is--invalid']]: state === 'error',\n\t\t\t[styles['mrl-is--selected']]: selected === 'checked',\n\t\t\t[styles['mrl-is--indeterminate']]: selected === 'indeterminate'\n\t\t}\n\t);\n\n\tcheckInvalidAttributes(attrs);\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs, {\n\t\t...getDescribedby(\n\t\t\tattrs['aria-describedby'],\n\t\t\ttypeof description === 'string' ? descriptionId : undefined\n\t\t),\n\t\tid: checkboxIdRef.current\n\t});\n\n\t// setAttributes always sets className=\"\" which always triggers the warning message in the MrlCheckboxStandalone component\n\tdelete attributes.className;\n\n\t// the consumer's handler arrives through `attrs`, so wrap it before handing the\n\t// attributes down to the standalone input.\n\tconst consumerOnChange = attributes.onChange as\n\t\t| ((e: React.ChangeEvent<HTMLInputElement>) => void)\n\t\t| undefined;\n\n\tattributes.onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'checked', metadata: { selected: e.target.checked } });\n\n\t\tconsumerOnChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={allClasses}>\n\t\t\t<MrlCheckboxStandalone {...rest} selected={selected} state={state} attrs={attributes} />\n\t\t\t<MrlLabelWithDescription\n\t\t\t\tisDisabled={state === 'disabled'}\n\t\t\t\tisSelected={selected === 'checked'}\n\t\t\t\tisIndeterminate={selected === 'indeterminate'}\n\t\t\t\thasMultilineLabel={hasMultilineLabel}\n\t\t\t\thtmlFor={checkboxIdRef.current}\n\t\t\t\ticon={icon}\n\t\t\t\tlabel={label}\n\t\t\t\tdescription={description}\n\t\t\t\tdescriptionId={descriptionId}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckbox","_ref","_ref$attrs","attrs","className","description","_ref$hasMultilineLabe","hasMultilineLabel","_ref$state","state","checkboxDefaults","_ref$selected","selected","icon","label","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","descriptionId","concat","current","allClasses","classnames","class","styles","checkInvalidAttributes","attributes","setAttributes","_objectSpread","getDescribedby","undefined","id","consumerOnChange","onChange","e","action","metadata","target","checked","createElement","MrlCheckboxStandalone","_extends","MrlLabelWithDescription","isDisabled","isSelected","isIndeterminate","htmlFor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CA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AC,iCAAA,KAAKhC,IAAI,EAAA;AAAEJ,IAAAA,QAAQ,EAAEA,QAAS;AAACH,IAAAA,KAAK,EAAEA,KAAM;AAACN,IAAAA,KAAK,EAAE8B;AAAW,GAAA,CAAE,CAAC,eACxFX,gBAAA,CAAAwB,aAAA,CAACG,+CAAuB,EAAA;IACvBC,UAAU,EAAEzC,KAAK,KAAK,UAAW;IACjC0C,UAAU,EAAEvC,QAAQ,KAAK,SAAU;IACnCwC,eAAe,EAAExC,QAAQ,KAAK,eAAgB;AAC9CL,IAAAA,iBAAiB,EAAEA,iBAAkB;IACrC8C,OAAO,EAAEhC,aAAa,CAACM,OAAQ;AAC/Bd,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,KAAK,EAAEA,KAAM;AACbT,IAAAA,WAAW,EAAEA,WAAY;AACzBoB,IAAAA,aAAa,EAAEA;AAAc,GAC7B,CACG,CAAC;AAER;;;;"}
1
+ {"version":3,"file":"MrlCheckbox.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckbox/MrlCheckbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport {\n\tcheckboxDefaults,\n\tCheckboxInputProps,\n\tCheckboxSelected,\n\tCheckboxStates,\n\tStaticIconConfig\n} from '../../constants';\nimport { MrlCheckboxStandalone } from '../MrlCheckboxStandalone/MrlCheckboxStandalone';\nimport { checkInvalidAttributes } from '../../../../utils/checkInvalidAttributes';\n\nimport './MrlCheckbox.global.scss';\nimport styles from './MrlCheckbox.module.scss';\nimport { MrlLabelWithDescription } from '../../label/MrlLabelWithDescription';\nimport { getDescribedby } from '../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlCheckboxProps extends CheckboxInputProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element\n\t *\n\t * @deprecated - use the regular HTML attributes instead. When an attribute is passed both\n\t * ways, the regular HTML attribute wins.\n\t */\n\tattrs?: AttrsObject;\n\t/** Additional class to add to the container of the checkbox and label */\n\tclassName?: string;\n\t/** Adjusts the styles of the label, icon and description when the label is multiline */\n\thasMultilineLabel?: boolean;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/** Sets what selection state the checkbox is in. */\n\tselected?: CheckboxSelected;\n\t/** The text to display as the checkbox's label */\n\tlabel: string;\n\t/** Leading label icon */\n\ticon?: StaticIconConfig;\n\t/**\n\t * Description, additional context text for the user.\n\t * It can be a string or a React component for custom render.\n\t * When using a React component it's necessary to add an id to the custom element and\n\t * pass it to the MrlCheckbox through \"aria-describedby\" to make it accessible\n\t * to screen readers.\n\t * Custom description should also implement the disabled state styles\n\t * for text when the input is disabled or set color: inherit.\n\t * @example\n\t * <MrlCheckbox aria-describedby={customId} description={\n\t * <p id={customId}>description</p>\n\t * }>\n\t */\n\tdescription?: string | React.ReactNode;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Form element with an associated text label that allows the user to select one or more options\n * from a provided list\n * @param {MrlCheckboxProps} props - the component props\n * @returns a checkbox element with an associated label\n */\nexport function MrlCheckbox({\n\tattrs = {},\n\tclassName,\n\tdescription,\n\thasMultilineLabel = false,\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\ticon,\n\tlabel,\n\teventId,\n\t// the regular HTML attribute wins over the deprecated `attrs` object\n\tonChange = attrs.onChange,\n\t...rest\n}: MrlCheckboxProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckbox', eventId);\n\tconst checkboxIdRef = React.useRef<string>(getUniqueId('mrl-checkbox'));\n\tconst descriptionId = `${checkboxIdRef.current}-description`;\n\n\tconst allClasses = classnames(\n\t\tattrs.class || attrs.className,\n\t\tclassName,\n\t\t'MrlCheckbox',\n\t\tstyles['MrlCheckbox'],\n\t\t{\n\t\t\t[styles['mrl-is--disabled']]: state === 'disabled',\n\t\t\t[styles['mrl-is--invalid']]: state === 'error',\n\t\t\t[styles['mrl-is--selected']]: selected === 'checked',\n\t\t\t[styles['mrl-is--indeterminate']]: selected === 'indeterminate'\n\t\t}\n\t);\n\n\tcheckInvalidAttributes(attrs);\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs, {\n\t\t...getDescribedby(\n\t\t\tattrs['aria-describedby'],\n\t\t\ttypeof description === 'string' ? descriptionId : undefined\n\t\t),\n\t\tid: checkboxIdRef.current\n\t});\n\n\t// setAttributes always sets className=\"\" which always triggers the warning message in the MrlCheckboxStandalone component\n\tdelete attributes.className;\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'checked', metadata: { selected: e.target.checked } });\n\n\t\tonChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={allClasses}>\n\t\t\t<MrlCheckboxStandalone\n\t\t\t\t{...rest}\n\t\t\t\tattrs={attributes}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tselected={selected}\n\t\t\t\tstate={state}\n\t\t\t/>\n\t\t\t<MrlLabelWithDescription\n\t\t\t\tisDisabled={state === 'disabled'}\n\t\t\t\tisSelected={selected === 'checked'}\n\t\t\t\tisIndeterminate={selected === 'indeterminate'}\n\t\t\t\thasMultilineLabel={hasMultilineLabel}\n\t\t\t\thtmlFor={checkboxIdRef.current}\n\t\t\t\ticon={icon}\n\t\t\t\tlabel={label}\n\t\t\t\tdescription={description}\n\t\t\t\tdescriptionId={descriptionId}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckbox","_ref","_ref$attrs","attrs","className","description","_ref$hasMultilineLabe","hasMultilineLabel","_ref$state","state","checkboxDefaults","_ref$selected","selected","icon","label","eventId","_ref$onChange","onChange","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","descriptionId","concat","current","allClasses","classnames","class","styles","checkInvalidAttributes","attributes","setAttributes","_objectSpread","getDescribedby","undefined","id","handleChange","e","action","metadata","target","checked","createElement","MrlCheckboxStandalone","_extends","MrlLabelWithDescription","isDisabled","isSelected","isIndeterminate","htmlFor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAAC,IAAA,EAaO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAZjCE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;IAAAC,qBAAA,GAAAL,IAAA,CACXM,iBAAiB;AAAjBA,IAAAA,iBAAiB,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;IAAAE,UAAA,GAAAP,IAAA,CACzBQ,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAGE,0BAAgB,CAACD,KAAK,GAAAD,UAAA;IAAAG,aAAA,GAAAV,IAAA,CAC9BW,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGD,0BAAgB,CAACE,QAAQ,GAAAD,aAAA;IACpCE,IAAI,GAAAZ,IAAA,CAAJY,IAAI;IACJC,KAAK,GAAAb,IAAA,CAALa,KAAK;IACLC,OAAO,GAAAd,IAAA,CAAPc,OAAO;IAAAC,aAAA,GAAAf,IAAA,CAEPgB,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGb,KAAK,CAACc,QAAQ,GAAAD,aAAA;AACtBE,IAAAA,IAAI,GAAAC,iDAAA,CAA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AsC,IAAK;AAChErB,IAAAA,gBAAgB,CAAC;AAAEsB,MAAAA,MAAM,EAAE,SAAS;AAAEC,MAAAA,QAAQ,EAAE;AAAEhC,QAAAA,QAAQ,EAAE8B,CAAC,CAACG,MAAM,CAACC;AAAQ;AAAE,KAAC,CAAC;AAEjF7B,IAAAA,QAAQ,aAARA,QAAQ,KAAA,MAAA,GAAA,MAAA,GAARA,QAAQ,CAAGyB,CAAC,CAAC;EACd,CAAC;EAED,oBACClB,gBAAA,CAAAuB,aAAA,CAAA,KAAA,EAAA;AAAK3C,IAAAA,SAAS,EAAE0B;GAAW,eAC1BN,gBAAA,CAAAuB,aAAA,CAACC,2CAAqB,EAAAC,iCAAA,KACjB/B,IAAI,EAAA;AACRf,IAAAA,KAAK,EAAEgC,UAAW;AAClBlB,IAAAA,QAAQ,EAAEwB,YAAa;AACvB7B,IAAAA,QAAQ,EAAEA,QAAS;AACnBH,IAAAA,KAAK,EAAEA;AAAM,GAAA,CACb,CAAC,eACFe,gBAAA,CAAAuB,aAAA,CAACG,+CAAuB,EAAA;IACvBC,UAAU,EAAE1C,KAAK,KAAK,UAAW;IACjC2C,UAAU,EAAExC,QAAQ,KAAK,SAAU;IACnCyC,eAAe,EAAEzC,QAAQ,KAAK,eAAgB;AAC9CL,IAAAA,iBAAiB,EAAEA,iBAAkB;IACrC+C,OAAO,EAAE/B,aAAa,CAACM,OAAQ;AAC/BhB,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,KAAK,EAAEA,KAAM;AACbT,IAAAA,WAAW,EAAEA,WAAY;AACzBsB,IAAAA,aAAa,EAAEA;AAAc,GAC7B,CACG,CAAC;AAER;;;;"}
@@ -33,11 +33,13 @@ function _interopNamespace(e) {
33
33
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
34
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
35
35
 
36
- var _excluded = ["attrs", "state", "selected", "eventId"];
36
+ var _excluded = ["attrs", "state", "selected", "eventId", "id", "onChange", "aria-labelledby"];
37
37
  /**
38
38
  * Input that allows the user to select one or more options from a provided list.
39
39
  * Note, this component does not provide out of the box accessibility for ensuring
40
- * an associated label and must be manually setup during adoption.
40
+ * an associated label and must be manually setup during adoption: pass an `id` referenced
41
+ * by a `<label htmlFor>`, or `aria-labelledby` pointing to visible text (a console warning
42
+ * is logged when both are missing).
41
43
  * @param {MrlCheckboxStandaloneProps} props - the component props
42
44
  * @returns a checkbox element
43
45
  */
@@ -49,13 +51,19 @@ function MrlCheckboxStandalone(_ref) {
49
51
  _ref$selected = _ref.selected,
50
52
  selected = _ref$selected === void 0 ? constants.checkboxDefaults.selected : _ref$selected,
51
53
  eventId = _ref.eventId,
54
+ _ref$id = _ref.id,
55
+ id = _ref$id === void 0 ? attrs.id : _ref$id,
56
+ _ref$onChange = _ref.onChange,
57
+ onChange = _ref$onChange === void 0 ? attrs.onChange : _ref$onChange,
58
+ _ref$ariaLabelledby = _ref['aria-labelledby'],
59
+ ariaLabelledby = _ref$ariaLabelledby === void 0 ? attrs['aria-labelledby'] : _ref$ariaLabelledby,
52
60
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
53
61
  var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlCheckboxStandalone', eventId);
54
- // Use attrs.id if the developer passes in a custom id
62
+ // Use the id if the developer passes in a custom one
55
63
  // but we need to ensure one exists for accessibility
56
- var checkboxIdRef = React__namespace.useRef(attrs.id || setAttributes.getUniqueId('mrl-checkbox'));
64
+ var checkboxIdRef = React__namespace.useRef(id || setAttributes.getUniqueId('mrl-checkbox'));
57
65
  var inputRef = React__namespace.useRef(null);
58
- if (!(attrs.id || attrs['aria-labelledby'])) {
66
+ if (!(id || ariaLabelledby)) {
59
67
  console.warn('Warning: Mural Standalone Checkboxes must have either an id or' + ' aria-labelledby attribute for proper accessibility.');
60
68
  }
61
69
 
@@ -71,10 +79,6 @@ function MrlCheckboxStandalone(_ref) {
71
79
  delete attrs.className;
72
80
  var attributes = setAttributes.setAttributes(attrs);
73
81
 
74
- // the consumer's handler arrives through `attrs`, so wrap it here rather than
75
- // relying on a top-level onChange prop.
76
- var consumerOnChange = attributes.onChange;
77
-
78
82
  /**
79
83
  * Handle change events
80
84
  *
@@ -87,14 +91,15 @@ function MrlCheckboxStandalone(_ref) {
87
91
  selected: e.target.checked
88
92
  }
89
93
  });
90
- consumerOnChange === null || consumerOnChange === void 0 ? void 0 : consumerOnChange(e);
94
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
91
95
  };
92
96
  return /*#__PURE__*/React__namespace.createElement("div", {
93
97
  className: classnames__default.default(MrlCheckboxStandalone_module.default['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')
94
98
  }, /*#__PURE__*/React__namespace.createElement("span", {
95
99
  className: "mrl-u-focus-wrapper"
96
- }, /*#__PURE__*/React__namespace.createElement("input", _rollupPluginBabelHelpers.extends({}, rest, attributes, {
100
+ }, /*#__PURE__*/React__namespace.createElement("input", _rollupPluginBabelHelpers.extends({}, attributes, rest, {
97
101
  "aria-invalid": state === 'error',
102
+ "aria-labelledby": ariaLabelledby,
98
103
  checked: selected === 'checked',
99
104
  disabled: state === 'disabled',
100
105
  id: checkboxIdRef.current,
@@ -1 +1 @@
1
- {"version":3,"file":"MrlCheckboxStandalone.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport { check, minus } from '@muraldevkit/ds-icons';\nimport { checkboxDefaults, CheckboxSelected, CheckboxStates } from '../../constants';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlCheckboxStandalone.module.scss';\nimport './MrlCheckboxStandalone.global.scss';\n\ninterface MrlCheckboxStandaloneProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element. The component renders no label,\n\t * so label it here: an `id` referenced by a `<label htmlFor>`, or `aria-labelledby` pointing\n\t * to visible text (a console warning is logged when both are missing). Pass the `onChange`\n\t * handler here as well.\n\t */\n\tattrs?: AttrsObject;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/**\n\t * Sets what selection state the checkbox is in. The component is controlled: update it from\n\t * the `onChange` handler passed in `attrs`.\n\t */\n\tselected?: CheckboxSelected;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Input that allows the user to select one or more options from a provided list.\n * Note, this component does not provide out of the box accessibility for ensuring\n * an associated label and must be manually setup during adoption.\n * @param {MrlCheckboxStandaloneProps} props - the component props\n * @returns a checkbox element\n */\nexport function MrlCheckboxStandalone({\n\tattrs = {},\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\teventId,\n\t...rest\n}: MrlCheckboxStandaloneProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckboxStandalone', eventId);\n\t// Use attrs.id if the developer passes in a custom id\n\t// but we need to ensure one exists for accessibility\n\tconst checkboxIdRef = React.useRef<string>(attrs.id || getUniqueId('mrl-checkbox'));\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\n\tif (!(attrs.id || attrs['aria-labelledby'])) {\n\t\tconsole.warn(\n\t\t\t'Warning: Mural Standalone Checkboxes must have either an id or' +\n\t\t\t\t' aria-labelledby attribute for proper accessibility.'\n\t\t);\n\t}\n\n\t// We need to use the ref to set indetermiant attr\n\t// due to not being an intrinsic HTML attr\n\tReact.useEffect(() => {\n\t\tconst indeterminate = selected === 'indeterminate';\n\n\t\tif (inputRef.current) {\n\t\t\tinputRef.current.indeterminate = indeterminate;\n\t\t}\n\t}, [selected]);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t// the consumer's handler arrives through `attrs`, so wrap it here rather than\n\t// relying on a top-level onChange prop.\n\tconst consumerOnChange = attributes.onChange as\n\t\t| ((e: React.ChangeEvent<HTMLInputElement>) => void)\n\t\t| undefined;\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'change', metadata: { selected: e.target.checked } });\n\n\t\tconsumerOnChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={classnames(styles['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')}>\n\t\t\t<span className=\"mrl-u-focus-wrapper\">\n\t\t\t\t<input\n\t\t\t\t\t{...rest}\n\t\t\t\t\t{...attributes}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\tchecked={selected === 'checked'}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\tid={checkboxIdRef.current}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-input'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-input'\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<span className=\"mrl-u-focus-indicator\"></span>\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-inputDisplay'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-inputDisplay'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tsvg={selected !== 'indeterminate' ? check : minus}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tclassName={styles['MrlCheckboxStandalone-inputDisplay-icon']}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckboxStandalone","_ref","_ref$attrs","attrs","_ref$state","state","checkboxDefaults","_ref$selected","selected","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","id","getUniqueId","inputRef","console","warn","useEffect","indeterminate","current","class","className","attributes","setAttributes","consumerOnChange","onChange","handleChange","e","action","metadata","target","checked","createElement","classnames","styles","_extends","disabled","ref","type","MrlSvg","svg","check","minus","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqBA,CAAAC,IAAA,EAMO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAL3CE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IAAAE,UAAA,GAAAH,IAAA,CACVI,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAGE,0BAAgB,CAACD,KAAK,GAAAD,UAAA;IAAAG,aAAA,GAAAN,IAAA,CAC9BO,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGD,0BAAgB,CAACE,QAAQ,GAAAD,aAAA;IACpCE,OAAO,GAAAR,IAAA,CAAPQ,OAAO;AACJC,IAAAA,IAAI,GAAAC,iDAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA;AAEP,EAAA,IAAMC,gBAAgB,GAAGC,sCAAsB,CAAC,uBAAuB,EAAEL,OAAO,CAAC;AACjF;AACA;AACA,EAAA,IAAMM,aAAa,GAAGC,gBAAK,CAACC,MAAM,CAASd,KAAK,CAACe,EAAE,IAAIC,yBAAW,CAAC,cAAc,CAAC,CAAC;AACnF,EAAA,IAAMC,QAAQ,GAAGJ,gBAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAErD,IAAI,EAAEd,KAAK,CAACe,EAAE,IAAIf,KAAK,CA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;IACd,cAAA,EAAcvB,KAAK,KAAK,OAAQ;IAChCgC,OAAO,EAAE7B,QAAQ,KAAK,SAAU;IAChCkC,QAAQ,EAAErC,KAAK,KAAK,UAAW;IAC/Ba,EAAE,EAAEH,aAAa,CAACU,OAAQ;AAC1BM,IAAAA,QAAQ,EAAEC,YAAa;AACvBW,IAAAA,GAAG,EAAEvB,QAAS;AACdwB,IAAAA,IAAI,EAAC,UAAU;IACfjB,SAAS,EAAEY,2BAAU,CACpBC,oCAAM,CAAC,6BAA6B,CAAC,EACrC,6BACD;AAAE,GAAA,CACF,CAAC,eACFxB,gBAAA,CAAAsB,aAAA,CAAA,MAAA,EAAA;AAAMX,IAAAA,SAAS,EAAC;AAAuB,GAAO,CAAC,eAC/CX,gBAAA,CAAAsB,aAAA,CAAA,MAAA,EAAA;IACCX,SAAS,EAAEY,2BAAU,CACpBC,oCAAM,CAAC,oCAAoC,CAAC,EAC5C,oCACD;AAAE,GAAA,eAEFxB,gBAAA,CAAAsB,aAAA,CAACO,aAAM,EAAA;AACNC,IAAAA,GAAG,EAAEtC,QAAQ,KAAK,eAAe,GAAGuC,aAAK,GAAGC,aAAM;AAClDC,IAAAA,IAAI,EAAC,MAAM;IACXtB,SAAS,EAAEa,oCAAM,CAAC,yCAAyC;GAC3D,CACI,CACD,CACF,CAAC;AAER;;;;"}
1
+ {"version":3,"file":"MrlCheckboxStandalone.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport { check, minus } from '@muraldevkit/ds-icons';\nimport {\n\tcheckboxDefaults,\n\tCheckboxInputProps,\n\tCheckboxSelected,\n\tCheckboxStates\n} from '../../constants';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlCheckboxStandalone.module.scss';\nimport './MrlCheckboxStandalone.global.scss';\n\ninterface MrlCheckboxStandaloneProps extends CheckboxInputProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element\n\t *\n\t * @deprecated - use the regular HTML attributes instead. When an attribute is passed both\n\t * ways, the regular HTML attribute wins.\n\t */\n\tattrs?: AttrsObject;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/**\n\t * Sets what selection state the checkbox is in. The component is controlled: update it from\n\t * the `onChange` handler.\n\t */\n\tselected?: CheckboxSelected;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Input that allows the user to select one or more options from a provided list.\n * Note, this component does not provide out of the box accessibility for ensuring\n * an associated label and must be manually setup during adoption: pass an `id` referenced\n * by a `<label htmlFor>`, or `aria-labelledby` pointing to visible text (a console warning\n * is logged when both are missing).\n * @param {MrlCheckboxStandaloneProps} props - the component props\n * @returns a checkbox element\n */\nexport function MrlCheckboxStandalone({\n\tattrs = {},\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\teventId,\n\t// the regular HTML attributes win over the deprecated `attrs` object\n\tid = attrs.id,\n\tonChange = attrs.onChange,\n\t'aria-labelledby': ariaLabelledby = attrs['aria-labelledby'],\n\t...rest\n}: MrlCheckboxStandaloneProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckboxStandalone', eventId);\n\t// Use the id if the developer passes in a custom one\n\t// but we need to ensure one exists for accessibility\n\tconst checkboxIdRef = React.useRef<string>(id || getUniqueId('mrl-checkbox'));\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\n\tif (!(id || ariaLabelledby)) {\n\t\tconsole.warn(\n\t\t\t'Warning: Mural Standalone Checkboxes must have either an id or' +\n\t\t\t\t' aria-labelledby attribute for proper accessibility.'\n\t\t);\n\t}\n\n\t// We need to use the ref to set indetermiant attr\n\t// due to not being an intrinsic HTML attr\n\tReact.useEffect(() => {\n\t\tconst indeterminate = selected === 'indeterminate';\n\n\t\tif (inputRef.current) {\n\t\t\tinputRef.current.indeterminate = indeterminate;\n\t\t}\n\t}, [selected]);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'change', metadata: { selected: e.target.checked } });\n\n\t\tonChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={classnames(styles['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')}>\n\t\t\t<span className=\"mrl-u-focus-wrapper\">\n\t\t\t\t<input\n\t\t\t\t\t{...attributes}\n\t\t\t\t\t{...rest}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\taria-labelledby={ariaLabelledby}\n\t\t\t\t\tchecked={selected === 'checked'}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\tid={checkboxIdRef.current}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-input'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-input'\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<span className=\"mrl-u-focus-indicator\"></span>\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-inputDisplay'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-inputDisplay'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tsvg={selected !== 'indeterminate' ? check : minus}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tclassName={styles['MrlCheckboxStandalone-inputDisplay-icon']}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckboxStandalone","_ref","_ref$attrs","attrs","_ref$state","state","checkboxDefaults","_ref$selected","selected","eventId","_ref$id","id","_ref$onChange","onChange","_ref$ariaLabelledby","ariaLabelledby","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","inputRef","console","warn","useEffect","indeterminate","current","class","className","attributes","setAttributes","handleChange","e","action","metadata","target","checked","createElement","classnames","styles","_extends","disabled","ref","type","MrlSvg","svg","check","minus","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqBA,CAAAC,IAAA,EAUO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAT3CE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IAAAE,UAAA,GAAAH,IAAA,CACVI,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAGE,0BAAgB,CAACD,KAAK,GAAAD,UAAA;IAAAG,aAAA,GAAAN,IAAA,CAC9BO,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGD,0BAAgB,CAACE,QAAQ,GAAAD,aAAA;IACpCE,OAAO,GAAAR,IAAA,CAAPQ,OAAO;IAAAC,OAAA,GAAAT,IAAA,CAEPU,EAAE;AAAFA,IAAAA,EAAE,GAAAD,OAAA,KAAA,MAAA,GAAGP,KAAK,CAACQ,EAAE,GAAAD,OAAA;IAAAE,aAAA,GAAAX,IAAA,CACbY,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGT,KAAK,CAACU,QAAQ,GAAAD,a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M,CAAC,yCAAyC;GAC3D,CACI,CACD,CACF,CAAC;AAER;;;;"}
@@ -21,6 +21,12 @@ var allowedCheckboxValues = {
21
21
  selected: ['default', 'checked', 'indeterminate'],
22
22
  states: ['default', 'disabled', 'error', 'read-only']
23
23
  };
24
+
25
+ /**
26
+ * Native attributes accepted by the checkbox `input`. The omitted ones are driven by the
27
+ * component's own props (`selected`, `state`) or do not apply to the element.
28
+ */
29
+
24
30
  var checkboxDefaults = {
25
31
  selected: 'default',
26
32
  state: 'default'
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../src/components/form/constants.ts"],"sourcesContent":["import * as React from 'react';\nimport { DSIconType } from '../svg';\n\n/*\n * Shared error object for inputs\n * ------------------------------------------------------------------\n */\n/**\n * This should be used to communciate error information for a specific input\n */\nexport interface MrlFormInputError {\n\tmessage: string;\n}\n\n/*\n * Shared input values\n * ------------------------------------------------------------------\n */\nexport type InputStates = 'disabled' | 'error' | 'read-only';\nexport type InputKinds = 'default' | 'inline' | 'inline-label';\nexport type InputSizes = 'default' | 'large';\n\n/*\n * Checkbox component\n * ------------------------------------------------------------------\n */\nexport const allowedCheckboxValues = {\n\tselected: ['default', 'checked', 'indeterminate'] as const,\n\tstates: [\n\t\t'default',\n\t\t'disabled',\n\t\t'error',\n\t\t'read-only'\n\t] as const\n};\n\nexport type CheckboxStates = (typeof allowedCheckboxValues.states)[number];\nexport type CheckboxSelected = (typeof allowedCheckboxValues.selected)[number];\n\ninterface CheckboxDefaults {\n\tselected: CheckboxSelected;\n\tstate: CheckboxStates;\n}\n\nexport const checkboxDefaults: CheckboxDefaults = {\n\tselected: 'default',\n\tstate: 'default'\n};\n\n/*\n * Select component\n * ------------------------------------------------------------------\n */\n\nexport const allowedSelectItemValues = {\n\tstates: ['default', 'disabled', 'selected'] as const\n};\n\nexport type SelectItemStates = (typeof allowedSelectItemValues.states)[number];\n\ninterface SelectItemDefaults {\n\tstate: SelectItemStates;\n}\n\nexport const selectItemDefaults: SelectItemDefaults = {\n\tstate: 'default'\n};\n\nexport const allowedSelectMenuValues = {\n\tpositions: ['bottom', 'top'] as const\n};\n\nexport type SelectMenuPositions = (typeof allowedSelectMenuValues.positions)[number];\n\ninterface SelectMenuDefaults {\n\tposition: SelectMenuPositions;\n}\n\nexport const selectMenuDefaults: SelectMenuDefaults = {\n\tposition: 'bottom'\n};\n\n// Selects are an extension of the shared \"allowedValues\" object but\n// TypeScript won't let me combine the two objects.\nexport const allowedSelectValues = {\n\tstates: [\n\t\t'default',\n\t\t'disabled',\n\t\t'open',\n\t\t'read-only'\n\t] as const\n};\n\nexport type SelectStates = (typeof allowedSelectValues.states)[number];\n\ninterface SelectDefaults {\n\tsize: InputSizes;\n\tkind: InputKinds;\n\tstate: SelectStates;\n}\n\nexport const selectDefaults: SelectDefaults = {\n\tkind: 'default',\n\tsize: 'default',\n\tstate: 'default'\n};\n\n/*\n * Text Input component\n * ------------------------------------------------------------------\n */\nexport interface StaticIconConfig {\n\ticon: DSIconType;\n\ttheme?: string;\n}\n\nexport interface RightActionConfig extends StaticIconConfig {\n\taction: (event: React.MouseEvent | React.KeyboardEvent) => void;\n\tlabel: string;\n}\n\n/*\n * Label component\n * ------------------------------------------------------------------\n */\nexport const allowedLabelValues = {\n\tkinds: ['block', 'inline'] as const,\n\tstates: ['default', 'disabled'] as const\n};\n\nexport type LabelStates = (typeof allowedLabelValues.states)[number];\nexport type LabelKind = (typeof allowedLabelValues.kinds)[number];\n\ninterface LabelDefaults {\n\tkind: LabelKind;\n\tstate: LabelStates;\n}\n\nexport const labelDefaults: LabelDefaults = {\n\tkind: 'block',\n\tstate: 'default'\n};\n\nexport interface FormControlDefaults {\n\tdisabled: boolean;\n\tlabel: string;\n}\n\nexport interface FieldsetDefault {\n\tlabel: string;\n}\n\n/**\n * Default values for props on the Fieldset component;\n * Shared between the component and Storybook\n */\nexport const fieldsetDefault: FieldsetDefault = {\n\tlabel: \"fieldset's legend label\"\n};\n\n/**\n * Default values for props on the Fieldset component which is used to group Textarea components;\n * Shared between the component and Storybook\n */\nexport const textareaDefaults: FormControlDefaults = {\n\tdisabled: false,\n\tlabel: 'Legend'\n};\n"],"names":["allowedCheckboxValues","selected","states","checkboxDefaults","state","allowedSelectItemValues","selectItemDefaults","allowedSelectMenuValues","positions","selectMenuDefaults","position","allowedSelectValues","selectDefaults","kind","size","allowedLabelValues","kinds","labelDefaults","fieldsetDefault","label","textareaDefaults","disabled"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,IAAMA,qBAAqB,GAAG;AACpCC,EAAAA,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,CAAU;EAC1DC,MAAM,EAAE,CACP,SAAS,EACT,UAAU,EACV,OAAO,EACP,WAAW;AAEb;AAUO,IAAMC,gBAAkC,GAAG;AACjDF,EAAAA,QAAQ,EAAE,SAAS;AACnBG,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;;AAEO,IAAMC,uBAAuB,GAAG;AACtCH,EAAAA,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU;AAC3C;AAQO,IAAMI,kBAAsC,GAAG;AACrDF,EAAAA,KAAK,EAAE;AACR;AAEO,IAAMG,uBAAuB,GAAG;AACtCC,EAAAA,SAAS,EAAE,CAAC,QAAQ,EAAE,KAAK;AAC5B;AAQO,IAAMC,kBAAsC,GAAG;AACrDC,EAAAA,QAAQ,EAAE;AACX;;AAEA;AACA;AACO,IAAMC,mBAAmB,GAAG;EAClCT,MAAM,EAAE,CACP,SAAS,EACT,UAAU,EACV,MAAM,EACN,WAAW;AAEb;AAUO,IAAMU,cAA8B,GAAG;AAC7CC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,IAAI,EAAE,SAAS;AACfV,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACO,IAAMW,kBAAkB,GAAG;AACjCC,EAAAA,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAU;AACnCd,EAAAA,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU;AAC/B;AAUO,IAAMe,aAA4B,GAAG;AAC3CJ,EAAAA,IAAI,EAAE,OAAO;AACbT,EAAAA,KAAK,EAAE;AACR;AAWA;AACA;AACA;AACA;AACO,IAAMc,eAAgC,GAAG;AAC/CC,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;AACO,IAAMC,gBAAqC,GAAG;AACpDC,EAAAA,QAAQ,EAAE,KAAK;AACfF,EAAAA,KAAK,EAAE;AACR;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/components/form/constants.ts"],"sourcesContent":["import * as React from 'react';\nimport { DSIconType } from '../svg';\nimport { DataQa } from '../../utils/dataQa';\n\n/*\n * Shared error object for inputs\n * ------------------------------------------------------------------\n */\n/**\n * This should be used to communciate error information for a specific input\n */\nexport interface MrlFormInputError {\n\tmessage: string;\n}\n\n/*\n * Shared input values\n * ------------------------------------------------------------------\n */\nexport type InputStates = 'disabled' | 'error' | 'read-only';\nexport type InputKinds = 'default' | 'inline' | 'inline-label';\nexport type InputSizes = 'default' | 'large';\n\n/*\n * Checkbox component\n * ------------------------------------------------------------------\n */\nexport const allowedCheckboxValues = {\n\tselected: ['default', 'checked', 'indeterminate'] as const,\n\tstates: ['default', 'disabled', 'error', 'read-only'] as const\n};\n\nexport type CheckboxStates = (typeof allowedCheckboxValues.states)[number];\nexport type CheckboxSelected = (typeof allowedCheckboxValues.selected)[number];\n\n/**\n * Native attributes accepted by the checkbox `input`. The omitted ones are driven by the\n * component's own props (`selected`, `state`) or do not apply to the element.\n */\nexport type CheckboxInputProps = Omit<\n\tReact.ComponentPropsWithoutRef<'input'>,\n\t'type' | 'checked' | 'defaultChecked' | 'disabled' | 'children' | 'className' | 'style'\n> &\n\tDataQa;\n\ninterface CheckboxDefaults {\n\tselected: CheckboxSelected;\n\tstate: CheckboxStates;\n}\n\nexport const checkboxDefaults: CheckboxDefaults = {\n\tselected: 'default',\n\tstate: 'default'\n};\n\n/*\n * Select component\n * ------------------------------------------------------------------\n */\n\nexport const allowedSelectItemValues = {\n\tstates: ['default', 'disabled', 'selected'] as const\n};\n\nexport type SelectItemStates = (typeof allowedSelectItemValues.states)[number];\n\ninterface SelectItemDefaults {\n\tstate: SelectItemStates;\n}\n\nexport const selectItemDefaults: SelectItemDefaults = {\n\tstate: 'default'\n};\n\nexport const allowedSelectMenuValues = {\n\tpositions: ['bottom', 'top'] as const\n};\n\nexport type SelectMenuPositions = (typeof allowedSelectMenuValues.positions)[number];\n\ninterface SelectMenuDefaults {\n\tposition: SelectMenuPositions;\n}\n\nexport const selectMenuDefaults: SelectMenuDefaults = {\n\tposition: 'bottom'\n};\n\n// Selects are an extension of the shared \"allowedValues\" object but\n// TypeScript won't let me combine the two objects.\nexport const allowedSelectValues = {\n\tstates: ['default', 'disabled', 'open', 'read-only'] as const\n};\n\nexport type SelectStates = (typeof allowedSelectValues.states)[number];\n\ninterface SelectDefaults {\n\tsize: InputSizes;\n\tkind: InputKinds;\n\tstate: SelectStates;\n}\n\nexport const selectDefaults: SelectDefaults = {\n\tkind: 'default',\n\tsize: 'default',\n\tstate: 'default'\n};\n\n/*\n * Text Input component\n * ------------------------------------------------------------------\n */\nexport interface StaticIconConfig {\n\ticon: DSIconType;\n\ttheme?: string;\n}\n\nexport interface RightActionConfig extends StaticIconConfig {\n\taction: (event: React.MouseEvent | React.KeyboardEvent) => void;\n\tlabel: string;\n}\n\n/*\n * Label component\n * ------------------------------------------------------------------\n */\nexport const allowedLabelValues = {\n\tkinds: ['block', 'inline'] as const,\n\tstates: ['default', 'disabled'] as const\n};\n\nexport type LabelStates = (typeof allowedLabelValues.states)[number];\nexport type LabelKind = (typeof allowedLabelValues.kinds)[number];\n\ninterface LabelDefaults {\n\tkind: LabelKind;\n\tstate: LabelStates;\n}\n\nexport const labelDefaults: LabelDefaults = {\n\tkind: 'block',\n\tstate: 'default'\n};\n\nexport interface FormControlDefaults {\n\tdisabled: boolean;\n\tlabel: string;\n}\n\nexport interface FieldsetDefault {\n\tlabel: string;\n}\n\n/**\n * Default values for props on the Fieldset component;\n * Shared between the component and Storybook\n */\nexport const fieldsetDefault: FieldsetDefault = {\n\tlabel: \"fieldset's legend label\"\n};\n\n/**\n * Default values for props on the Fieldset component which is used to group Textarea components;\n * Shared between the component and Storybook\n */\nexport const textareaDefaults: FormControlDefaults = {\n\tdisabled: false,\n\tlabel: 'Legend'\n};\n"],"names":["allowedCheckboxValues","selected","states","checkboxDefaults","state","allowedSelectItemValues","selectItemDefaults","allowedSelectMenuValues","positions","selectMenuDefaults","position","allowedSelectValues","selectDefaults","kind","size","allowedLabelValues","kinds","labelDefaults","fieldsetDefault","label","textareaDefaults","disabled"],"mappings":";;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,IAAMA,qBAAqB,GAAG;AACpCC,EAAAA,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,CAAU;EAC1DC,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW;AACrD;;AAKA;AACA;AACA;AACA;;AAYO,IAAMC,gBAAkC,GAAG;AACjDF,EAAAA,QAAQ,EAAE,SAAS;AACnBG,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;;AAEO,IAAMC,uBAAuB,GAAG;AACtCH,EAAAA,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU;AAC3C;AAQO,IAAMI,kBAAsC,GAAG;AACrDF,EAAAA,KAAK,EAAE;AACR;AAEO,IAAMG,uBAAuB,GAAG;AACtCC,EAAAA,SAAS,EAAE,CAAC,QAAQ,EAAE,KAAK;AAC5B;AAQO,IAAMC,kBAAsC,GAAG;AACrDC,EAAAA,QAAQ,EAAE;AACX;;AAEA;AACA;AACO,IAAMC,mBAAmB,GAAG;EAClCT,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW;AACpD;AAUO,IAAMU,cAA8B,GAAG;AAC7CC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,IAAI,EAAE,SAAS;AACfV,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACO,IAAMW,kBAAkB,GAAG;AACjCC,EAAAA,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAU;AACnCd,EAAAA,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU;AAC/B;AAUO,IAAMe,aAA4B,GAAG;AAC3CJ,EAAAA,IAAI,EAAE,OAAO;AACbT,EAAAA,KAAK,EAAE;AACR;AAWA;AACA;AACA;AACA;AACO,IAAMc,eAAgC,GAAG;AAC/CC,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;AACO,IAAMC,gBAAqC,GAAG;AACpDC,EAAAA,QAAQ,EAAE,KAAK;AACfF,EAAAA,KAAK,EAAE;AACR;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var TOOLKIT_VERSION = "4.84.1";
3
+ var TOOLKIT_VERSION = "4.85.0";
4
4
 
5
5
  exports.TOOLKIT_VERSION = TOOLKIT_VERSION;
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.84.1\";"],"names":["TOOLKIT_VERSION"],"mappings":";;AAAO,IAAMA,eAAe,GAAG;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.85.0\";"],"names":["TOOLKIT_VERSION"],"mappings":";;AAAO,IAAMA,eAAe,GAAG;;;;"}
@@ -10,7 +10,7 @@ import { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics/useMrl
10
10
  import { getUniqueId, setAttributes } from '../../../../utils/setAttributes/setAttributes.js';
11
11
  import { MrlLabelWithDescription } from '../../label/MrlLabelWithDescription/MrlLabelWithDescription.js';
12
12
 
13
- var _excluded = ["attrs", "className", "description", "hasMultilineLabel", "state", "selected", "icon", "label", "eventId"];
13
+ var _excluded = ["attrs", "className", "description", "hasMultilineLabel", "state", "selected", "icon", "label", "eventId", "onChange"];
14
14
  /**
15
15
  * Form element with an associated text label that allows the user to select one or more options
16
16
  * from a provided list
@@ -31,6 +31,8 @@ function MrlCheckbox(_ref) {
31
31
  icon = _ref.icon,
32
32
  label = _ref.label,
33
33
  eventId = _ref.eventId,
34
+ _ref$onChange = _ref.onChange,
35
+ onChange = _ref$onChange === void 0 ? attrs.onChange : _ref$onChange,
34
36
  rest = _objectWithoutProperties(_ref, _excluded);
35
37
  var trackInteraction = useMrlTrackInteraction('MrlCheckbox', eventId);
36
38
  var checkboxIdRef = React.useRef(getUniqueId('mrl-checkbox'));
@@ -51,24 +53,27 @@ function MrlCheckbox(_ref) {
51
53
  // setAttributes always sets className="" which always triggers the warning message in the MrlCheckboxStandalone component
52
54
  delete attributes.className;
53
55
 
54
- // the consumer's handler arrives through `attrs`, so wrap it before handing the
55
- // attributes down to the standalone input.
56
- var consumerOnChange = attributes.onChange;
57
- attributes.onChange = e => {
56
+ /**
57
+ * Handle change events
58
+ *
59
+ * @param {React.ChangeEvent<HTMLInputElement>} e - change event
60
+ */
61
+ var handleChange = e => {
58
62
  trackInteraction({
59
63
  action: 'checked',
60
64
  metadata: {
61
65
  selected: e.target.checked
62
66
  }
63
67
  });
64
- consumerOnChange === null || consumerOnChange === void 0 ? void 0 : consumerOnChange(e);
68
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
65
69
  };
66
70
  return /*#__PURE__*/React.createElement("div", {
67
71
  className: allClasses
68
72
  }, /*#__PURE__*/React.createElement(MrlCheckboxStandalone, _extends({}, rest, {
73
+ attrs: attributes,
74
+ onChange: handleChange,
69
75
  selected: selected,
70
- state: state,
71
- attrs: attributes
76
+ state: state
72
77
  })), /*#__PURE__*/React.createElement(MrlLabelWithDescription, {
73
78
  isDisabled: state === 'disabled',
74
79
  isSelected: selected === 'checked',
@@ -1 +1 @@
1
- {"version":3,"file":"MrlCheckbox.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckbox/MrlCheckbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport {\n\tcheckboxDefaults,\n\tCheckboxSelected,\n\tCheckboxStates,\n\tStaticIconConfig\n} from '../../constants';\nimport { MrlCheckboxStandalone } from '../MrlCheckboxStandalone/MrlCheckboxStandalone';\nimport { checkInvalidAttributes } from '../../../../utils/checkInvalidAttributes';\n\nimport './MrlCheckbox.global.scss';\nimport styles from './MrlCheckbox.module.scss';\nimport { MrlLabelWithDescription } from '../../label/MrlLabelWithDescription';\nimport { getDescribedby } from '../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlCheckboxProps {\n\t/** Applies additional HTML attributes to the checkbox element */\n\tattrs?: AttrsObject;\n\t/** Additional class to add to the container of the checkbox and label */\n\tclassName?: string;\n\t/** Adjusts the styles of the label, icon and description when the label is multiline */\n\thasMultilineLabel?: boolean;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/** Sets what selection state the checkbox is in. */\n\tselected?: CheckboxSelected;\n\t/** The text to display as the checkbox's label */\n\tlabel: string;\n\t/** Leading label icon */\n\ticon?: StaticIconConfig;\n\t/**\n\t * Description, additional context text for the user.\n\t * It can be a string or a React component for custom render.\n\t * When using a React component it's necessary to add an id to the custom element and\n\t * pass it to the MrlCheckbox through 'attrs[\"aria-describedby\"]' to make it accessible\n\t * to screen readers.\n\t * Custom description should also implement the disabled state styles\n\t * for text when the input is disabled or set color: inherit.\n\t * @example\n\t * <MrlCheckbox attrs={{ 'aria-describedby': customId }} description={\n\t * <p id={customId}>description</p>\n\t * }>\n\t */\n\tdescription?: string | React.ReactNode;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Form element with an associated text label that allows the user to select one or more options\n * from a provided list\n * @param {MrlCheckboxProps} props - the component props\n * @returns a checkbox element with an associated label\n */\nexport function MrlCheckbox({\n\tattrs = {},\n\tclassName,\n\tdescription,\n\thasMultilineLabel = false,\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\ticon,\n\tlabel,\n\teventId,\n\t...rest\n}: MrlCheckboxProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckbox', eventId);\n\tconst checkboxIdRef = React.useRef<string>(getUniqueId('mrl-checkbox'));\n\tconst descriptionId = `${checkboxIdRef.current}-description`;\n\n\tconst allClasses = classnames(\n\t\tattrs.class || attrs.className,\n\t\tclassName,\n\t\t'MrlCheckbox',\n\t\tstyles['MrlCheckbox'],\n\t\t{\n\t\t\t[styles['mrl-is--disabled']]: state === 'disabled',\n\t\t\t[styles['mrl-is--invalid']]: state === 'error',\n\t\t\t[styles['mrl-is--selected']]: selected === 'checked',\n\t\t\t[styles['mrl-is--indeterminate']]: selected === 'indeterminate'\n\t\t}\n\t);\n\n\tcheckInvalidAttributes(attrs);\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs, {\n\t\t...getDescribedby(\n\t\t\tattrs['aria-describedby'],\n\t\t\ttypeof description === 'string' ? descriptionId : undefined\n\t\t),\n\t\tid: checkboxIdRef.current\n\t});\n\n\t// setAttributes always sets className=\"\" which always triggers the warning message in the MrlCheckboxStandalone component\n\tdelete attributes.className;\n\n\t// the consumer's handler arrives through `attrs`, so wrap it before handing the\n\t// attributes down to the standalone input.\n\tconst consumerOnChange = attributes.onChange as\n\t\t| ((e: React.ChangeEvent<HTMLInputElement>) => void)\n\t\t| undefined;\n\n\tattributes.onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'checked', metadata: { selected: e.target.checked } });\n\n\t\tconsumerOnChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={allClasses}>\n\t\t\t<MrlCheckboxStandalone {...rest} selected={selected} state={state} attrs={attributes} />\n\t\t\t<MrlLabelWithDescription\n\t\t\t\tisDisabled={state === 'disabled'}\n\t\t\t\tisSelected={selected === 'checked'}\n\t\t\t\tisIndeterminate={selected === 'indeterminate'}\n\t\t\t\thasMultilineLabel={hasMultilineLabel}\n\t\t\t\thtmlFor={checkboxIdRef.current}\n\t\t\t\ticon={icon}\n\t\t\t\tlabel={label}\n\t\t\t\tdescription={description}\n\t\t\t\tdescriptionId={descriptionId}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckbox","_ref","_ref$attrs","attrs","className","description","_ref$hasMultilineLabe","hasMultilineLabel","_ref$state","state","checkboxDefaults","_ref$selected","selected","icon","label","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","descriptionId","concat","current","allClasses","classnames","class","styles","checkInvalidAttributes","attributes","setAttributes","_objectSpread","getDescribedby","undefined","id","consumerOnChange","onChange","e","action","metadata","target","checked","createElement","MrlCheckboxStandalone","_extends","MrlLabelWithDescription","isDisabled","isSelected","isIndeterminate","htmlFor"],"mappings":";;;;;;;;;;;;;AAsDA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAAC,IAAA,EAWO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAVjCE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,WAAW,GAAAJ,IAAA,CAAXI,WAA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,UAAW;IACjC0C,UAAU,EAAEvC,QAAQ,KAAK,SAAU;IACnCwC,eAAe,EAAExC,QAAQ,KAAK,eAAgB;AAC9CL,IAAAA,iBAAiB,EAAEA,iBAAkB;IACrC8C,OAAO,EAAEhC,aAAa,CAACM,OAAQ;AAC/Bd,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,KAAK,EAAEA,KAAM;AACbT,IAAAA,WAAW,EAAEA,WAAY;AACzBoB,IAAAA,aAAa,EAAEA;AAAc,GAC7B,CACG,CAAC;AAER;;;;"}
1
+ {"version":3,"file":"MrlCheckbox.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckbox/MrlCheckbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport {\n\tcheckboxDefaults,\n\tCheckboxInputProps,\n\tCheckboxSelected,\n\tCheckboxStates,\n\tStaticIconConfig\n} from '../../constants';\nimport { MrlCheckboxStandalone } from '../MrlCheckboxStandalone/MrlCheckboxStandalone';\nimport { checkInvalidAttributes } from '../../../../utils/checkInvalidAttributes';\n\nimport './MrlCheckbox.global.scss';\nimport styles from './MrlCheckbox.module.scss';\nimport { MrlLabelWithDescription } from '../../label/MrlLabelWithDescription';\nimport { getDescribedby } from '../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlCheckboxProps extends CheckboxInputProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element\n\t *\n\t * @deprecated - use the regular HTML attributes instead. When an attribute is passed both\n\t * ways, the regular HTML attribute wins.\n\t */\n\tattrs?: AttrsObject;\n\t/** Additional class to add to the container of the checkbox and label */\n\tclassName?: string;\n\t/** Adjusts the styles of the label, icon and description when the label is multiline */\n\thasMultilineLabel?: boolean;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/** Sets what selection state the checkbox is in. */\n\tselected?: CheckboxSelected;\n\t/** The text to display as the checkbox's label */\n\tlabel: string;\n\t/** Leading label icon */\n\ticon?: StaticIconConfig;\n\t/**\n\t * Description, additional context text for the user.\n\t * It can be a string or a React component for custom render.\n\t * When using a React component it's necessary to add an id to the custom element and\n\t * pass it to the MrlCheckbox through \"aria-describedby\" to make it accessible\n\t * to screen readers.\n\t * Custom description should also implement the disabled state styles\n\t * for text when the input is disabled or set color: inherit.\n\t * @example\n\t * <MrlCheckbox aria-describedby={customId} description={\n\t * <p id={customId}>description</p>\n\t * }>\n\t */\n\tdescription?: string | React.ReactNode;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Form element with an associated text label that allows the user to select one or more options\n * from a provided list\n * @param {MrlCheckboxProps} props - the component props\n * @returns a checkbox element with an associated label\n */\nexport function MrlCheckbox({\n\tattrs = {},\n\tclassName,\n\tdescription,\n\thasMultilineLabel = false,\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\ticon,\n\tlabel,\n\teventId,\n\t// the regular HTML attribute wins over the deprecated `attrs` object\n\tonChange = attrs.onChange,\n\t...rest\n}: MrlCheckboxProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckbox', eventId);\n\tconst checkboxIdRef = React.useRef<string>(getUniqueId('mrl-checkbox'));\n\tconst descriptionId = `${checkboxIdRef.current}-description`;\n\n\tconst allClasses = classnames(\n\t\tattrs.class || attrs.className,\n\t\tclassName,\n\t\t'MrlCheckbox',\n\t\tstyles['MrlCheckbox'],\n\t\t{\n\t\t\t[styles['mrl-is--disabled']]: state === 'disabled',\n\t\t\t[styles['mrl-is--invalid']]: state === 'error',\n\t\t\t[styles['mrl-is--selected']]: selected === 'checked',\n\t\t\t[styles['mrl-is--indeterminate']]: selected === 'indeterminate'\n\t\t}\n\t);\n\n\tcheckInvalidAttributes(attrs);\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs, {\n\t\t...getDescribedby(\n\t\t\tattrs['aria-describedby'],\n\t\t\ttypeof description === 'string' ? descriptionId : undefined\n\t\t),\n\t\tid: checkboxIdRef.current\n\t});\n\n\t// setAttributes always sets className=\"\" which always triggers the warning message in the MrlCheckboxStandalone component\n\tdelete attributes.className;\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'checked', metadata: { selected: e.target.checked } });\n\n\t\tonChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={allClasses}>\n\t\t\t<MrlCheckboxStandalone\n\t\t\t\t{...rest}\n\t\t\t\tattrs={attributes}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tselected={selected}\n\t\t\t\tstate={state}\n\t\t\t/>\n\t\t\t<MrlLabelWithDescription\n\t\t\t\tisDisabled={state === 'disabled'}\n\t\t\t\tisSelected={selected === 'checked'}\n\t\t\t\tisIndeterminate={selected === 'indeterminate'}\n\t\t\t\thasMultilineLabel={hasMultilineLabel}\n\t\t\t\thtmlFor={checkboxIdRef.current}\n\t\t\t\ticon={icon}\n\t\t\t\tlabel={label}\n\t\t\t\tdescription={description}\n\t\t\t\tdescriptionId={descriptionId}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckbox","_ref","_ref$attrs","attrs","className","description","_ref$hasMultilineLabe","hasMultilineLabel","_ref$state","state","checkboxDefaults","_ref$selected","selected","icon","label","eventId","_ref$onChange","onChange","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","descriptionId","concat","current","allClasses","classnames","class","styles","checkInvalidAttributes","attributes","setAttributes","_objectSpread","getDescribedby","undefined","id","handleChange","e","action","metadata","target","checked","createElement","MrlCheckboxStandalone","_extends","MrlLabelWithDescription","isDisabled","isSel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ACd,CAAC;EAED,oBACClB,KAAA,CAAAuB,aAAA,CAAA,KAAA,EAAA;AAAK3C,IAAAA,SAAS,EAAE0B;GAAW,eAC1BN,KAAA,CAAAuB,aAAA,CAACC,qBAAqB,EAAAC,QAAA,KACjB/B,IAAI,EAAA;AACRf,IAAAA,KAAK,EAAEgC,UAAW;AAClBlB,IAAAA,QAAQ,EAAEwB,YAAa;AACvB7B,IAAAA,QAAQ,EAAEA,QAAS;AACnBH,IAAAA,KAAK,EAAEA;AAAM,GAAA,CACb,CAAC,eACFe,KAAA,CAAAuB,aAAA,CAACG,uBAAuB,EAAA;IACvBC,UAAU,EAAE1C,KAAK,KAAK,UAAW;IACjC2C,UAAU,EAAExC,QAAQ,KAAK,SAAU;IACnCyC,eAAe,EAAEzC,QAAQ,KAAK,eAAgB;AAC9CL,IAAAA,iBAAiB,EAAEA,iBAAkB;IACrC+C,OAAO,EAAE/B,aAAa,CAACM,OAAQ;AAC/BhB,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,KAAK,EAAEA,KAAM;AACbT,IAAAA,WAAW,EAAEA,WAAY;AACzBsB,IAAAA,aAAa,EAAEA;AAAc,GAC7B,CACG,CAAC;AAER;;;;"}
@@ -8,11 +8,13 @@ import styles from './MrlCheckboxStandalone.module.scss.js';
8
8
  import { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics/useMrlAnalytics.js';
9
9
  import { getUniqueId, setAttributes } from '../../../../utils/setAttributes/setAttributes.js';
10
10
 
11
- var _excluded = ["attrs", "state", "selected", "eventId"];
11
+ var _excluded = ["attrs", "state", "selected", "eventId", "id", "onChange", "aria-labelledby"];
12
12
  /**
13
13
  * Input that allows the user to select one or more options from a provided list.
14
14
  * Note, this component does not provide out of the box accessibility for ensuring
15
- * an associated label and must be manually setup during adoption.
15
+ * an associated label and must be manually setup during adoption: pass an `id` referenced
16
+ * by a `<label htmlFor>`, or `aria-labelledby` pointing to visible text (a console warning
17
+ * is logged when both are missing).
16
18
  * @param {MrlCheckboxStandaloneProps} props - the component props
17
19
  * @returns a checkbox element
18
20
  */
@@ -24,13 +26,19 @@ function MrlCheckboxStandalone(_ref) {
24
26
  _ref$selected = _ref.selected,
25
27
  selected = _ref$selected === void 0 ? checkboxDefaults.selected : _ref$selected,
26
28
  eventId = _ref.eventId,
29
+ _ref$id = _ref.id,
30
+ id = _ref$id === void 0 ? attrs.id : _ref$id,
31
+ _ref$onChange = _ref.onChange,
32
+ onChange = _ref$onChange === void 0 ? attrs.onChange : _ref$onChange,
33
+ _ref$ariaLabelledby = _ref['aria-labelledby'],
34
+ ariaLabelledby = _ref$ariaLabelledby === void 0 ? attrs['aria-labelledby'] : _ref$ariaLabelledby,
27
35
  rest = _objectWithoutProperties(_ref, _excluded);
28
36
  var trackInteraction = useMrlTrackInteraction('MrlCheckboxStandalone', eventId);
29
- // Use attrs.id if the developer passes in a custom id
37
+ // Use the id if the developer passes in a custom one
30
38
  // but we need to ensure one exists for accessibility
31
- var checkboxIdRef = React.useRef(attrs.id || getUniqueId('mrl-checkbox'));
39
+ var checkboxIdRef = React.useRef(id || getUniqueId('mrl-checkbox'));
32
40
  var inputRef = React.useRef(null);
33
- if (!(attrs.id || attrs['aria-labelledby'])) {
41
+ if (!(id || ariaLabelledby)) {
34
42
  console.warn('Warning: Mural Standalone Checkboxes must have either an id or' + ' aria-labelledby attribute for proper accessibility.');
35
43
  }
36
44
 
@@ -46,10 +54,6 @@ function MrlCheckboxStandalone(_ref) {
46
54
  delete attrs.className;
47
55
  var attributes = setAttributes(attrs);
48
56
 
49
- // the consumer's handler arrives through `attrs`, so wrap it here rather than
50
- // relying on a top-level onChange prop.
51
- var consumerOnChange = attributes.onChange;
52
-
53
57
  /**
54
58
  * Handle change events
55
59
  *
@@ -62,14 +66,15 @@ function MrlCheckboxStandalone(_ref) {
62
66
  selected: e.target.checked
63
67
  }
64
68
  });
65
- consumerOnChange === null || consumerOnChange === void 0 ? void 0 : consumerOnChange(e);
69
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
66
70
  };
67
71
  return /*#__PURE__*/React.createElement("div", {
68
72
  className: classnames(styles['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')
69
73
  }, /*#__PURE__*/React.createElement("span", {
70
74
  className: "mrl-u-focus-wrapper"
71
- }, /*#__PURE__*/React.createElement("input", _extends({}, rest, attributes, {
75
+ }, /*#__PURE__*/React.createElement("input", _extends({}, attributes, rest, {
72
76
  "aria-invalid": state === 'error',
77
+ "aria-labelledby": ariaLabelledby,
73
78
  checked: selected === 'checked',
74
79
  disabled: state === 'disabled',
75
80
  id: checkboxIdRef.current,
@@ -1 +1 @@
1
- {"version":3,"file":"MrlCheckboxStandalone.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport { check, minus } from '@muraldevkit/ds-icons';\nimport { checkboxDefaults, CheckboxSelected, CheckboxStates } from '../../constants';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlCheckboxStandalone.module.scss';\nimport './MrlCheckboxStandalone.global.scss';\n\ninterface MrlCheckboxStandaloneProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element. The component renders no label,\n\t * so label it here: an `id` referenced by a `<label htmlFor>`, or `aria-labelledby` pointing\n\t * to visible text (a console warning is logged when both are missing). Pass the `onChange`\n\t * handler here as well.\n\t */\n\tattrs?: AttrsObject;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/**\n\t * Sets what selection state the checkbox is in. The component is controlled: update it from\n\t * the `onChange` handler passed in `attrs`.\n\t */\n\tselected?: CheckboxSelected;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Input that allows the user to select one or more options from a provided list.\n * Note, this component does not provide out of the box accessibility for ensuring\n * an associated label and must be manually setup during adoption.\n * @param {MrlCheckboxStandaloneProps} props - the component props\n * @returns a checkbox element\n */\nexport function MrlCheckboxStandalone({\n\tattrs = {},\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\teventId,\n\t...rest\n}: MrlCheckboxStandaloneProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckboxStandalone', eventId);\n\t// Use attrs.id if the developer passes in a custom id\n\t// but we need to ensure one exists for accessibility\n\tconst checkboxIdRef = React.useRef<string>(attrs.id || getUniqueId('mrl-checkbox'));\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\n\tif (!(attrs.id || attrs['aria-labelledby'])) {\n\t\tconsole.warn(\n\t\t\t'Warning: Mural Standalone Checkboxes must have either an id or' +\n\t\t\t\t' aria-labelledby attribute for proper accessibility.'\n\t\t);\n\t}\n\n\t// We need to use the ref to set indetermiant attr\n\t// due to not being an intrinsic HTML attr\n\tReact.useEffect(() => {\n\t\tconst indeterminate = selected === 'indeterminate';\n\n\t\tif (inputRef.current) {\n\t\t\tinputRef.current.indeterminate = indeterminate;\n\t\t}\n\t}, [selected]);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t// the consumer's handler arrives through `attrs`, so wrap it here rather than\n\t// relying on a top-level onChange prop.\n\tconst consumerOnChange = attributes.onChange as\n\t\t| ((e: React.ChangeEvent<HTMLInputElement>) => void)\n\t\t| undefined;\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'change', metadata: { selected: e.target.checked } });\n\n\t\tconsumerOnChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={classnames(styles['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')}>\n\t\t\t<span className=\"mrl-u-focus-wrapper\">\n\t\t\t\t<input\n\t\t\t\t\t{...rest}\n\t\t\t\t\t{...attributes}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\tchecked={selected === 'checked'}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\tid={checkboxIdRef.current}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-input'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-input'\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<span className=\"mrl-u-focus-indicator\"></span>\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-inputDisplay'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-inputDisplay'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tsvg={selected !== 'indeterminate' ? check : minus}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tclassName={styles['MrlCheckboxStandalone-inputDisplay-icon']}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckboxStandalone","_ref","_ref$attrs","attrs","_ref$state","state","checkboxDefaults","_ref$selected","selected","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","id","getUniqueId","inputRef","console","warn","useEffect","indeterminate","current","class","className","attributes","setAttributes","consumerOnChange","onChange","handleChange","e","action","metadata","target","checked","createElement","classnames","styles","_extends","disabled","ref","type","MrlSvg","svg","check","minus","size"],"mappings":";;;;;;;;;;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqBA,CAA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AAA,SAAS,EAAC;AAAuB,GAAO,CAAC,eAC/CX,KAAA,CAAAsB,aAAA,CAAA,MAAA,EAAA;IACCX,SAAS,EAAEY,UAAU,CACpBC,MAAM,CAAC,oCAAoC,CAAC,EAC5C,oCACD;AAAE,GAAA,eAEFxB,KAAA,CAAAsB,aAAA,CAACO,MAAM,EAAA;AACNC,IAAAA,GAAG,EAAEtC,QAAQ,KAAK,eAAe,GAAGuC,KAAK,GAAGC,KAAM;AAClDC,IAAAA,IAAI,EAAC,MAAM;IACXtB,SAAS,EAAEa,MAAM,CAAC,yCAAyC;GAC3D,CACI,CACD,CACF,CAAC;AAER;;;;"}
1
+ {"version":3,"file":"MrlCheckboxStandalone.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport { check, minus } from '@muraldevkit/ds-icons';\nimport {\n\tcheckboxDefaults,\n\tCheckboxInputProps,\n\tCheckboxSelected,\n\tCheckboxStates\n} from '../../constants';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlCheckboxStandalone.module.scss';\nimport './MrlCheckboxStandalone.global.scss';\n\ninterface MrlCheckboxStandaloneProps extends CheckboxInputProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element\n\t *\n\t * @deprecated - use the regular HTML attributes instead. When an attribute is passed both\n\t * ways, the regular HTML attribute wins.\n\t */\n\tattrs?: AttrsObject;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/**\n\t * Sets what selection state the checkbox is in. The component is controlled: update it from\n\t * the `onChange` handler.\n\t */\n\tselected?: CheckboxSelected;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Input that allows the user to select one or more options from a provided list.\n * Note, this component does not provide out of the box accessibility for ensuring\n * an associated label and must be manually setup during adoption: pass an `id` referenced\n * by a `<label htmlFor>`, or `aria-labelledby` pointing to visible text (a console warning\n * is logged when both are missing).\n * @param {MrlCheckboxStandaloneProps} props - the component props\n * @returns a checkbox element\n */\nexport function MrlCheckboxStandalone({\n\tattrs = {},\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\teventId,\n\t// the regular HTML attributes win over the deprecated `attrs` object\n\tid = attrs.id,\n\tonChange = attrs.onChange,\n\t'aria-labelledby': ariaLabelledby = attrs['aria-labelledby'],\n\t...rest\n}: MrlCheckboxStandaloneProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckboxStandalone', eventId);\n\t// Use the id if the developer passes in a custom one\n\t// but we need to ensure one exists for accessibility\n\tconst checkboxIdRef = React.useRef<string>(id || getUniqueId('mrl-checkbox'));\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\n\tif (!(id || ariaLabelledby)) {\n\t\tconsole.warn(\n\t\t\t'Warning: Mural Standalone Checkboxes must have either an id or' +\n\t\t\t\t' aria-labelledby attribute for proper accessibility.'\n\t\t);\n\t}\n\n\t// We need to use the ref to set indetermiant attr\n\t// due to not being an intrinsic HTML attr\n\tReact.useEffect(() => {\n\t\tconst indeterminate = selected === 'indeterminate';\n\n\t\tif (inputRef.current) {\n\t\t\tinputRef.current.indeterminate = indeterminate;\n\t\t}\n\t}, [selected]);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'change', metadata: { selected: e.target.checked } });\n\n\t\tonChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={classnames(styles['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')}>\n\t\t\t<span className=\"mrl-u-focus-wrapper\">\n\t\t\t\t<input\n\t\t\t\t\t{...attributes}\n\t\t\t\t\t{...rest}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\taria-labelledby={ariaLabelledby}\n\t\t\t\t\tchecked={selected === 'checked'}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\tid={checkboxIdRef.current}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-input'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-input'\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<span className=\"mrl-u-focus-indicator\"></span>\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-inputDisplay'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-inputDisplay'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tsvg={selected !== 'indeterminate' ? check : minus}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tclassName={styles['MrlCheckboxStandalone-inputDisplay-icon']}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckboxStandalone","_ref","_ref$attrs","attrs","_ref$state","state","checkboxDefaults","_ref$selected","selected","eventId","_ref$id","id","_ref$onChange","onChange","_ref$ariaLabelledby","ariaLabelledby","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","inputRef","console","warn","useEffect","indeterminate","current","class","className","attributes","setAttributes","handleChange","e","action","metadata","target","checked","createElement","classnames","styles","_extends","disabled","ref","type","MrlSvg","svg","check","min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,IAAA,iBAAA,EAAiBU,cAAe;IAChCyB,OAAO,EAAEhC,QAAQ,KAAK,SAAU;IAChCqC,QAAQ,EAAExC,KAAK,KAAK,UAAW;IAC/BM,EAAE,EAAEU,aAAa,CAACS,OAAQ;AAC1BjB,IAAAA,QAAQ,EAAEsB,YAAa;AACvBW,IAAAA,GAAG,EAAErB,QAAS;AACdsB,IAAAA,IAAI,EAAC,UAAU;IACff,SAAS,EAAEU,UAAU,CACpBC,MAAM,CAAC,6BAA6B,CAAC,EACrC,6BACD;AAAE,GAAA,CACF,CAAC,eACFrB,KAAA,CAAAmB,aAAA,CAAA,MAAA,EAAA;AAAMT,IAAAA,SAAS,EAAC;AAAuB,GAAO,CAAC,eAC/CV,KAAA,CAAAmB,aAAA,CAAA,MAAA,EAAA;IACCT,SAAS,EAAEU,UAAU,CACpBC,MAAM,CAAC,oCAAoC,CAAC,EAC5C,oCACD;AAAE,GAAA,eAEFrB,KAAA,CAAAmB,aAAA,CAACO,MAAM,EAAA;AACNC,IAAAA,GAAG,EAAEzC,QAAQ,KAAK,eAAe,GAAG0C,KAAK,GAAGC,KAAM;AAClDC,IAAAA,IAAI,EAAC,MAAM;IACXpB,SAAS,EAAEW,MAAM,CAAC,yCAAyC;GAC3D,CACI,CACD,CACF,CAAC;AAER;;;;"}
@@ -19,6 +19,12 @@ var allowedCheckboxValues = {
19
19
  selected: ['default', 'checked', 'indeterminate'],
20
20
  states: ['default', 'disabled', 'error', 'read-only']
21
21
  };
22
+
23
+ /**
24
+ * Native attributes accepted by the checkbox `input`. The omitted ones are driven by the
25
+ * component's own props (`selected`, `state`) or do not apply to the element.
26
+ */
27
+
22
28
  var checkboxDefaults = {
23
29
  selected: 'default',
24
30
  state: 'default'
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../src/components/form/constants.ts"],"sourcesContent":["import * as React from 'react';\nimport { DSIconType } from '../svg';\n\n/*\n * Shared error object for inputs\n * ------------------------------------------------------------------\n */\n/**\n * This should be used to communciate error information for a specific input\n */\nexport interface MrlFormInputError {\n\tmessage: string;\n}\n\n/*\n * Shared input values\n * ------------------------------------------------------------------\n */\nexport type InputStates = 'disabled' | 'error' | 'read-only';\nexport type InputKinds = 'default' | 'inline' | 'inline-label';\nexport type InputSizes = 'default' | 'large';\n\n/*\n * Checkbox component\n * ------------------------------------------------------------------\n */\nexport const allowedCheckboxValues = {\n\tselected: ['default', 'checked', 'indeterminate'] as const,\n\tstates: [\n\t\t'default',\n\t\t'disabled',\n\t\t'error',\n\t\t'read-only'\n\t] as const\n};\n\nexport type CheckboxStates = (typeof allowedCheckboxValues.states)[number];\nexport type CheckboxSelected = (typeof allowedCheckboxValues.selected)[number];\n\ninterface CheckboxDefaults {\n\tselected: CheckboxSelected;\n\tstate: CheckboxStates;\n}\n\nexport const checkboxDefaults: CheckboxDefaults = {\n\tselected: 'default',\n\tstate: 'default'\n};\n\n/*\n * Select component\n * ------------------------------------------------------------------\n */\n\nexport const allowedSelectItemValues = {\n\tstates: ['default', 'disabled', 'selected'] as const\n};\n\nexport type SelectItemStates = (typeof allowedSelectItemValues.states)[number];\n\ninterface SelectItemDefaults {\n\tstate: SelectItemStates;\n}\n\nexport const selectItemDefaults: SelectItemDefaults = {\n\tstate: 'default'\n};\n\nexport const allowedSelectMenuValues = {\n\tpositions: ['bottom', 'top'] as const\n};\n\nexport type SelectMenuPositions = (typeof allowedSelectMenuValues.positions)[number];\n\ninterface SelectMenuDefaults {\n\tposition: SelectMenuPositions;\n}\n\nexport const selectMenuDefaults: SelectMenuDefaults = {\n\tposition: 'bottom'\n};\n\n// Selects are an extension of the shared \"allowedValues\" object but\n// TypeScript won't let me combine the two objects.\nexport const allowedSelectValues = {\n\tstates: [\n\t\t'default',\n\t\t'disabled',\n\t\t'open',\n\t\t'read-only'\n\t] as const\n};\n\nexport type SelectStates = (typeof allowedSelectValues.states)[number];\n\ninterface SelectDefaults {\n\tsize: InputSizes;\n\tkind: InputKinds;\n\tstate: SelectStates;\n}\n\nexport const selectDefaults: SelectDefaults = {\n\tkind: 'default',\n\tsize: 'default',\n\tstate: 'default'\n};\n\n/*\n * Text Input component\n * ------------------------------------------------------------------\n */\nexport interface StaticIconConfig {\n\ticon: DSIconType;\n\ttheme?: string;\n}\n\nexport interface RightActionConfig extends StaticIconConfig {\n\taction: (event: React.MouseEvent | React.KeyboardEvent) => void;\n\tlabel: string;\n}\n\n/*\n * Label component\n * ------------------------------------------------------------------\n */\nexport const allowedLabelValues = {\n\tkinds: ['block', 'inline'] as const,\n\tstates: ['default', 'disabled'] as const\n};\n\nexport type LabelStates = (typeof allowedLabelValues.states)[number];\nexport type LabelKind = (typeof allowedLabelValues.kinds)[number];\n\ninterface LabelDefaults {\n\tkind: LabelKind;\n\tstate: LabelStates;\n}\n\nexport const labelDefaults: LabelDefaults = {\n\tkind: 'block',\n\tstate: 'default'\n};\n\nexport interface FormControlDefaults {\n\tdisabled: boolean;\n\tlabel: string;\n}\n\nexport interface FieldsetDefault {\n\tlabel: string;\n}\n\n/**\n * Default values for props on the Fieldset component;\n * Shared between the component and Storybook\n */\nexport const fieldsetDefault: FieldsetDefault = {\n\tlabel: \"fieldset's legend label\"\n};\n\n/**\n * Default values for props on the Fieldset component which is used to group Textarea components;\n * Shared between the component and Storybook\n */\nexport const textareaDefaults: FormControlDefaults = {\n\tdisabled: false,\n\tlabel: 'Legend'\n};\n"],"names":["allowedCheckboxValues","selected","states","checkboxDefaults","state","allowedSelectItemValues","selectItemDefaults","allowedSelectMenuValues","positions","selectMenuDefaults","position","allowedSelectValues","selectDefaults","kind","size","allowedLabelValues","kinds","labelDefaults","fieldsetDefault","label","textareaDefaults","disabled"],"mappings":"AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,IAAMA,qBAAqB,GAAG;AACpCC,EAAAA,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,CAAU;EAC1DC,MAAM,EAAE,CACP,SAAS,EACT,UAAU,EACV,OAAO,EACP,WAAW;AAEb;AAUO,IAAMC,gBAAkC,GAAG;AACjDF,EAAAA,QAAQ,EAAE,SAAS;AACnBG,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;;AAEO,IAAMC,uBAAuB,GAAG;AACtCH,EAAAA,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU;AAC3C;AAQO,IAAMI,kBAAsC,GAAG;AACrDF,EAAAA,KAAK,EAAE;AACR;AAEO,IAAMG,uBAAuB,GAAG;AACtCC,EAAAA,SAAS,EAAE,CAAC,QAAQ,EAAE,KAAK;AAC5B;AAQO,IAAMC,kBAAsC,GAAG;AACrDC,EAAAA,QAAQ,EAAE;AACX;;AAEA;AACA;AACO,IAAMC,mBAAmB,GAAG;EAClCT,MAAM,EAAE,CACP,SAAS,EACT,UAAU,EACV,MAAM,EACN,WAAW;AAEb;AAUO,IAAMU,cAA8B,GAAG;AAC7CC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,IAAI,EAAE,SAAS;AACfV,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACO,IAAMW,kBAAkB,GAAG;AACjCC,EAAAA,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAU;AACnCd,EAAAA,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU;AAC/B;AAUO,IAAMe,aAA4B,GAAG;AAC3CJ,EAAAA,IAAI,EAAE,OAAO;AACbT,EAAAA,KAAK,EAAE;AACR;AAWA;AACA;AACA;AACA;AACO,IAAMc,eAAgC,GAAG;AAC/CC,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;AACO,IAAMC,gBAAqC,GAAG;AACpDC,EAAAA,QAAQ,EAAE,KAAK;AACfF,EAAAA,KAAK,EAAE;AACR;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/components/form/constants.ts"],"sourcesContent":["import * as React from 'react';\nimport { DSIconType } from '../svg';\nimport { DataQa } from '../../utils/dataQa';\n\n/*\n * Shared error object for inputs\n * ------------------------------------------------------------------\n */\n/**\n * This should be used to communciate error information for a specific input\n */\nexport interface MrlFormInputError {\n\tmessage: string;\n}\n\n/*\n * Shared input values\n * ------------------------------------------------------------------\n */\nexport type InputStates = 'disabled' | 'error' | 'read-only';\nexport type InputKinds = 'default' | 'inline' | 'inline-label';\nexport type InputSizes = 'default' | 'large';\n\n/*\n * Checkbox component\n * ------------------------------------------------------------------\n */\nexport const allowedCheckboxValues = {\n\tselected: ['default', 'checked', 'indeterminate'] as const,\n\tstates: ['default', 'disabled', 'error', 'read-only'] as const\n};\n\nexport type CheckboxStates = (typeof allowedCheckboxValues.states)[number];\nexport type CheckboxSelected = (typeof allowedCheckboxValues.selected)[number];\n\n/**\n * Native attributes accepted by the checkbox `input`. The omitted ones are driven by the\n * component's own props (`selected`, `state`) or do not apply to the element.\n */\nexport type CheckboxInputProps = Omit<\n\tReact.ComponentPropsWithoutRef<'input'>,\n\t'type' | 'checked' | 'defaultChecked' | 'disabled' | 'children' | 'className' | 'style'\n> &\n\tDataQa;\n\ninterface CheckboxDefaults {\n\tselected: CheckboxSelected;\n\tstate: CheckboxStates;\n}\n\nexport const checkboxDefaults: CheckboxDefaults = {\n\tselected: 'default',\n\tstate: 'default'\n};\n\n/*\n * Select component\n * ------------------------------------------------------------------\n */\n\nexport const allowedSelectItemValues = {\n\tstates: ['default', 'disabled', 'selected'] as const\n};\n\nexport type SelectItemStates = (typeof allowedSelectItemValues.states)[number];\n\ninterface SelectItemDefaults {\n\tstate: SelectItemStates;\n}\n\nexport const selectItemDefaults: SelectItemDefaults = {\n\tstate: 'default'\n};\n\nexport const allowedSelectMenuValues = {\n\tpositions: ['bottom', 'top'] as const\n};\n\nexport type SelectMenuPositions = (typeof allowedSelectMenuValues.positions)[number];\n\ninterface SelectMenuDefaults {\n\tposition: SelectMenuPositions;\n}\n\nexport const selectMenuDefaults: SelectMenuDefaults = {\n\tposition: 'bottom'\n};\n\n// Selects are an extension of the shared \"allowedValues\" object but\n// TypeScript won't let me combine the two objects.\nexport const allowedSelectValues = {\n\tstates: ['default', 'disabled', 'open', 'read-only'] as const\n};\n\nexport type SelectStates = (typeof allowedSelectValues.states)[number];\n\ninterface SelectDefaults {\n\tsize: InputSizes;\n\tkind: InputKinds;\n\tstate: SelectStates;\n}\n\nexport const selectDefaults: SelectDefaults = {\n\tkind: 'default',\n\tsize: 'default',\n\tstate: 'default'\n};\n\n/*\n * Text Input component\n * ------------------------------------------------------------------\n */\nexport interface StaticIconConfig {\n\ticon: DSIconType;\n\ttheme?: string;\n}\n\nexport interface RightActionConfig extends StaticIconConfig {\n\taction: (event: React.MouseEvent | React.KeyboardEvent) => void;\n\tlabel: string;\n}\n\n/*\n * Label component\n * ------------------------------------------------------------------\n */\nexport const allowedLabelValues = {\n\tkinds: ['block', 'inline'] as const,\n\tstates: ['default', 'disabled'] as const\n};\n\nexport type LabelStates = (typeof allowedLabelValues.states)[number];\nexport type LabelKind = (typeof allowedLabelValues.kinds)[number];\n\ninterface LabelDefaults {\n\tkind: LabelKind;\n\tstate: LabelStates;\n}\n\nexport const labelDefaults: LabelDefaults = {\n\tkind: 'block',\n\tstate: 'default'\n};\n\nexport interface FormControlDefaults {\n\tdisabled: boolean;\n\tlabel: string;\n}\n\nexport interface FieldsetDefault {\n\tlabel: string;\n}\n\n/**\n * Default values for props on the Fieldset component;\n * Shared between the component and Storybook\n */\nexport const fieldsetDefault: FieldsetDefault = {\n\tlabel: \"fieldset's legend label\"\n};\n\n/**\n * Default values for props on the Fieldset component which is used to group Textarea components;\n * Shared between the component and Storybook\n */\nexport const textareaDefaults: FormControlDefaults = {\n\tdisabled: false,\n\tlabel: 'Legend'\n};\n"],"names":["allowedCheckboxValues","selected","states","checkboxDefaults","state","allowedSelectItemValues","selectItemDefaults","allowedSelectMenuValues","positions","selectMenuDefaults","position","allowedSelectValues","selectDefaults","kind","size","allowedLabelValues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A,KAAK,EAAE;AACR;AAWA;AACA;AACA;AACA;AACO,IAAMc,eAAgC,GAAG;AAC/CC,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;AACO,IAAMC,gBAAqC,GAAG;AACpDC,EAAAA,QAAQ,EAAE,KAAK;AACfF,EAAAA,KAAK,EAAE;AACR;;;;"}
@@ -1,4 +1,4 @@
1
- var TOOLKIT_VERSION = "4.84.1";
1
+ var TOOLKIT_VERSION = "4.85.0";
2
2
 
3
3
  export { TOOLKIT_VERSION };
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.84.1\";"],"names":["TOOLKIT_VERSION"],"mappings":"AAAO,IAAMA,eAAe,GAAG;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.85.0\";"],"names":["TOOLKIT_VERSION"],"mappings":"AAAO,IAAMA,eAAe,GAAG;;;;"}
@@ -1,9 +1,14 @@
1
1
  import * as React from 'react';
2
2
  import { AttrsObject } from '../../../../utils';
3
- import { CheckboxSelected, CheckboxStates, StaticIconConfig } from '../../constants';
3
+ import { CheckboxInputProps, CheckboxSelected, CheckboxStates, StaticIconConfig } from '../../constants';
4
4
  import './MrlCheckbox.global.scss';
5
- interface MrlCheckboxProps {
6
- /** Applies additional HTML attributes to the checkbox element */
5
+ interface MrlCheckboxProps extends CheckboxInputProps {
6
+ /**
7
+ * Applies additional HTML attributes to the checkbox element
8
+ *
9
+ * @deprecated - use the regular HTML attributes instead. When an attribute is passed both
10
+ * ways, the regular HTML attribute wins.
11
+ */
7
12
  attrs?: AttrsObject;
8
13
  /** Additional class to add to the container of the checkbox and label */
9
14
  className?: string;
@@ -21,12 +26,12 @@ interface MrlCheckboxProps {
21
26
  * Description, additional context text for the user.
22
27
  * It can be a string or a React component for custom render.
23
28
  * When using a React component it's necessary to add an id to the custom element and
24
- * pass it to the MrlCheckbox through 'attrs["aria-describedby"]' to make it accessible
29
+ * pass it to the MrlCheckbox through "aria-describedby" to make it accessible
25
30
  * to screen readers.
26
31
  * Custom description should also implement the disabled state styles
27
32
  * for text when the input is disabled or set color: inherit.
28
33
  * @example
29
- * <MrlCheckbox attrs={{ 'aria-describedby': customId }} description={
34
+ * <MrlCheckbox aria-describedby={customId} description={
30
35
  * <p id={customId}>description</p>
31
36
  * }>
32
37
  */
@@ -43,5 +48,5 @@ interface MrlCheckboxProps {
43
48
  * @param {MrlCheckboxProps} props - the component props
44
49
  * @returns a checkbox element with an associated label
45
50
  */
46
- export declare function MrlCheckbox({ attrs, className, description, hasMultilineLabel, state, selected, icon, label, eventId, ...rest }: MrlCheckboxProps): JSX.Element;
51
+ export declare function MrlCheckbox({ attrs, className, description, hasMultilineLabel, state, selected, icon, label, eventId, onChange, ...rest }: MrlCheckboxProps): JSX.Element;
47
52
  export {};
@@ -1,19 +1,19 @@
1
1
  import { AttrsObject } from '../../../../utils';
2
- import { CheckboxSelected, CheckboxStates } from '../../constants';
2
+ import { CheckboxInputProps, CheckboxSelected, CheckboxStates } from '../../constants';
3
3
  import './MrlCheckboxStandalone.global.scss';
4
- interface MrlCheckboxStandaloneProps {
4
+ interface MrlCheckboxStandaloneProps extends CheckboxInputProps {
5
5
  /**
6
- * Applies additional HTML attributes to the checkbox element. The component renders no label,
7
- * so label it here: an `id` referenced by a `<label htmlFor>`, or `aria-labelledby` pointing
8
- * to visible text (a console warning is logged when both are missing). Pass the `onChange`
9
- * handler here as well.
6
+ * Applies additional HTML attributes to the checkbox element
7
+ *
8
+ * @deprecated - use the regular HTML attributes instead. When an attribute is passed both
9
+ * ways, the regular HTML attribute wins.
10
10
  */
11
11
  attrs?: AttrsObject;
12
12
  /** The current state of the checkbox input based on user interactions or permissions */
13
13
  state?: CheckboxStates;
14
14
  /**
15
15
  * Sets what selection state the checkbox is in. The component is controlled: update it from
16
- * the `onChange` handler passed in `attrs`.
16
+ * the `onChange` handler.
17
17
  */
18
18
  selected?: CheckboxSelected;
19
19
  /**
@@ -25,9 +25,11 @@ interface MrlCheckboxStandaloneProps {
25
25
  /**
26
26
  * Input that allows the user to select one or more options from a provided list.
27
27
  * Note, this component does not provide out of the box accessibility for ensuring
28
- * an associated label and must be manually setup during adoption.
28
+ * an associated label and must be manually setup during adoption: pass an `id` referenced
29
+ * by a `<label htmlFor>`, or `aria-labelledby` pointing to visible text (a console warning
30
+ * is logged when both are missing).
29
31
  * @param {MrlCheckboxStandaloneProps} props - the component props
30
32
  * @returns a checkbox element
31
33
  */
32
- export declare function MrlCheckboxStandalone({ attrs, state, selected, eventId, ...rest }: MrlCheckboxStandaloneProps): JSX.Element;
34
+ export declare function MrlCheckboxStandalone({ attrs, state, selected, eventId, id, onChange, 'aria-labelledby': ariaLabelledby, ...rest }: MrlCheckboxStandaloneProps): JSX.Element;
33
35
  export {};
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { DSIconType } from '../svg';
3
+ import { DataQa } from '../../utils/dataQa';
3
4
  /**
4
5
  * This should be used to communciate error information for a specific input
5
6
  */
@@ -15,6 +16,11 @@ export declare const allowedCheckboxValues: {
15
16
  };
16
17
  export type CheckboxStates = (typeof allowedCheckboxValues.states)[number];
17
18
  export type CheckboxSelected = (typeof allowedCheckboxValues.selected)[number];
19
+ /**
20
+ * Native attributes accepted by the checkbox `input`. The omitted ones are driven by the
21
+ * component's own props (`selected`, `state`) or do not apply to the element.
22
+ */
23
+ export type CheckboxInputProps = Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'checked' | 'defaultChecked' | 'disabled' | 'children' | 'className' | 'style'> & DataQa;
18
24
  interface CheckboxDefaults {
19
25
  selected: CheckboxSelected;
20
26
  state: CheckboxStates;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muraldevkit/ui-toolkit",
3
- "version": "4.84.1",
3
+ "version": "4.85.0",
4
4
  "description": "Mural's UI Toolkit",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",