@muraldevkit/ui-toolkit 4.84.1 → 4.85.1
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.
- package/dist/cjs/components/form/checkbox/MrlCheckbox/MrlCheckbox.js +13 -8
- package/dist/cjs/components/form/checkbox/MrlCheckbox/MrlCheckbox.js.map +1 -1
- package/dist/cjs/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js +16 -11
- package/dist/cjs/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map +1 -1
- package/dist/cjs/components/form/constants.js +6 -0
- package/dist/cjs/components/form/constants.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/components/form/checkbox/MrlCheckbox/MrlCheckbox.js +13 -8
- package/dist/esm/components/form/checkbox/MrlCheckbox/MrlCheckbox.js.map +1 -1
- package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js +16 -11
- package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map +1 -1
- package/dist/esm/components/form/constants.js +6 -0
- package/dist/esm/components/form/constants.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/components/form/checkbox/MrlCheckbox/MrlCheckbox.d.ts +11 -6
- package/dist/types/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.d.ts +11 -9
- package/dist/types/components/form/constants.d.ts +6 -0
- package/package.json +6 -1
|
@@ -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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
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
|
|
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,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@@ 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
|
|
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(
|
|
64
|
+
var checkboxIdRef = React__namespace.useRef(id || setAttributes.getUniqueId('mrl-checkbox'));
|
|
57
65
|
var inputRef = React__namespace.useRef(null);
|
|
58
|
-
if (!(
|
|
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
|
-
|
|
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({},
|
|
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,
|
package/dist/cjs/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map
CHANGED
|
@@ -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 {
|
|
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;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AAe;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,2BAAU,CACpBC,oCAAM,CAAC,6BAA6B,CAAC,EACrC,6BACD;AAAE,GAAA,CACF,CAAC,eACFrB,gBAAA,CAAAmB,aAAA,CAAA,MAAA,EAAA;AAAMT,IAAAA,SAAS,EAAC;AAAuB,GAAO,CAAC,eAC/CV,gBAAA,CAAAmB,aAAA,CAAA,MAAA,EAAA;IACCT,SAAS,EAAEU,2BAAU,CACpBC,oCAAM,CAAC,oCAAoC,CAAC,EAC5C,oCACD;AAAE,GAAA,eAEFrB,gBAAA,CAAAmB,aAAA,CAACO,aAAM,EAAA;AACNC,IAAAA,GAAG,EAAEzC,QAAQ,KAAK,eAAe,GAAG0C,aAAK,GAAGC,aAAM;AAClDC,IAAAA,IAAI,EAAC,MAAM;IACXpB,SAAS,EAAEW,oCAAM,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: [
|
|
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;;;;;;;;;;;;;;;"}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.85.1\";"],"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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
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
|
|
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,gBAAgB,CAACD,KAAK,GAAAD,UAAA;IAAAG,aAAA,GAAAV,IAAA,CAC9BW,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGD,gBAAgB,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,CAE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raction } 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
|
|
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(
|
|
39
|
+
var checkboxIdRef = React.useRef(id || getUniqueId('mrl-checkbox'));
|
|
32
40
|
var inputRef = React.useRef(null);
|
|
33
|
-
if (!(
|
|
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
|
-
|
|
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({},
|
|
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,
|
package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map
CHANGED
|
@@ -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 {
|
|
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,EA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B,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: [
|
|
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;;;;"}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.85.1\";"],"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
|
-
/**
|
|
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
|
|
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
|
|
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 {};
|
package/dist/types/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.d.ts
CHANGED
|
@@ -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
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
|
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,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muraldevkit/ui-toolkit",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.85.1",
|
|
4
4
|
"description": "Mural's UI Toolkit",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/tactivos/ui-toolkit.git",
|
|
8
|
+
"directory": "packages/ui-toolkit"
|
|
9
|
+
},
|
|
5
10
|
"main": "./dist/cjs/index.js",
|
|
6
11
|
"module": "./dist/esm/index.js",
|
|
7
12
|
"types": "./dist/types/index.d.ts",
|