@popsure/dirty-swan 0.57.8 → 0.57.9

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.
Files changed (31) hide show
  1. package/dist/cjs/index.js +38 -37
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/input/checkbox/index.d.ts +2 -1
  4. package/dist/cjs/lib/components/input/checkbox/index.stories.d.ts +11 -7
  5. package/dist/cjs/lib/components/input/radio/index.d.ts +3 -1
  6. package/dist/cjs/lib/components/input/radio/index.stories.d.ts +10 -2
  7. package/dist/esm/components/chip/index.js +2 -2
  8. package/dist/esm/components/chip/index.js.map +1 -1
  9. package/dist/esm/components/input/checkbox/index.js +16 -16
  10. package/dist/esm/components/input/checkbox/index.js.map +1 -1
  11. package/dist/esm/components/input/checkbox/index.stories.js +24 -20
  12. package/dist/esm/components/input/checkbox/index.stories.js.map +1 -1
  13. package/dist/esm/components/input/radio/index.js +23 -21
  14. package/dist/esm/components/input/radio/index.js.map +1 -1
  15. package/dist/esm/components/input/radio/index.stories.js +12 -3
  16. package/dist/esm/components/input/radio/index.stories.js.map +1 -1
  17. package/dist/esm/components/input/radio/index.test.js +1 -0
  18. package/dist/esm/components/input/radio/index.test.js.map +1 -1
  19. package/dist/esm/lib/components/input/checkbox/index.d.ts +2 -1
  20. package/dist/esm/lib/components/input/checkbox/index.stories.d.ts +11 -7
  21. package/dist/esm/lib/components/input/radio/index.d.ts +3 -1
  22. package/dist/esm/lib/components/input/radio/index.stories.d.ts +10 -2
  23. package/package.json +1 -1
  24. package/src/lib/components/chip/index.tsx +1 -0
  25. package/src/lib/components/chip/style.module.scss +5 -0
  26. package/src/lib/components/input/checkbox/index.stories.tsx +81 -58
  27. package/src/lib/components/input/checkbox/index.tsx +5 -2
  28. package/src/lib/components/input/checkbox/styles.module.scss +4 -0
  29. package/src/lib/components/input/radio/index.stories.tsx +17 -2
  30. package/src/lib/components/input/radio/index.tsx +11 -2
  31. package/src/lib/components/input/radio/styles.module.scss +5 -1
@@ -16,5 +16,6 @@ export interface CheckboxProps<ValueType extends string> {
16
16
  label?: string;
17
17
  option?: string;
18
18
  };
19
+ fieldLegend?: string;
19
20
  }
20
- export declare const Checkbox: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, bordered, classNames: classNamesObj, }: CheckboxProps<ValueType> & {}) => JSX.Element;
21
+ export declare const Checkbox: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, bordered, classNames: classNamesObj, fieldLegend, }: CheckboxProps<ValueType> & {}) => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { CheckboxProps } from '.';
2
2
  declare const story: {
3
3
  title: string;
4
- component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, bordered, classNames: classNamesObj, }: CheckboxProps<ValueType>) => JSX.Element;
4
+ component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, bordered, classNames: classNamesObj, fieldLegend, }: CheckboxProps<ValueType>) => JSX.Element;
5
5
  argTypes: {
6
6
  options: {
7
7
  description: string;
@@ -9,6 +9,9 @@ declare const story: {
9
9
  value: {
10
10
  description: string;
11
11
  };
12
+ fieldLegend: {
13
+ description: string;
14
+ };
12
15
  onChange: {
13
16
  description: string;
14
17
  action: boolean;
@@ -46,6 +49,7 @@ declare const story: {
46
49
  description: string;
47
50
  };
48
51
  };
52
+ fieldLegend: string;
49
53
  wide: boolean;
50
54
  bordered: boolean;
51
55
  inlineLayout: boolean;
@@ -59,12 +63,12 @@ declare const story: {
59
63
  };
60
64
  };
61
65
  export declare const CheckboxStory: {
62
- ({ onChange, options, wide, bordered, classNames, inlineLayout, }: CheckboxProps<string>): JSX.Element;
66
+ ({ onChange, options, wide, bordered, classNames, inlineLayout, fieldLegend, }: CheckboxProps<string>): JSX.Element;
63
67
  storyName: string;
64
68
  };
65
- export declare const CheckboxWithCustomWrapperStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
66
- export declare const CheckboxWithCustomOptionStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
67
- export declare const CheckboxWithCustomLabelStyles: ({ onChange }: CheckboxProps<string>) => JSX.Element;
68
- export declare const CheckboxWithInlineLayout: ({ onChange }: CheckboxProps<string>) => JSX.Element;
69
- export declare const CheckboxWithCustomLabel: ({ onChange, wide, classNames, inlineLayout }: CheckboxProps<string>) => JSX.Element;
69
+ export declare const CheckboxWithCustomWrapperStyles: ({ onChange, }: CheckboxProps<string>) => JSX.Element;
70
+ export declare const CheckboxWithCustomOptionStyles: ({ onChange, }: CheckboxProps<string>) => JSX.Element;
71
+ export declare const CheckboxWithCustomLabelStyles: ({ onChange, }: CheckboxProps<string>) => JSX.Element;
72
+ export declare const CheckboxWithInlineLayout: ({ onChange, }: CheckboxProps<string>) => JSX.Element;
73
+ export declare const CheckboxWithCustomLabel: ({ onChange, wide, classNames, inlineLayout, }: CheckboxProps<string>) => JSX.Element;
70
74
  export default story;
@@ -19,5 +19,7 @@ export interface RadioProps<ValueType extends string> {
19
19
  };
20
20
  bordered?: boolean;
21
21
  disabled?: boolean;
22
+ fieldLegend?: string;
23
+ groupName?: string;
22
24
  }
23
- export declare const Radio: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, inlineIcon, classNames: classNamesObj, bordered, disabled, }: RadioProps<ValueType>) => JSX.Element;
25
+ export declare const Radio: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, inlineIcon, classNames: classNamesObj, bordered, disabled, fieldLegend, groupName, }: RadioProps<ValueType>) => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { RadioProps } from '.';
2
2
  declare const story: {
3
3
  title: string;
4
- component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, inlineIcon, classNames: classNamesObj, bordered, disabled, }: RadioProps<ValueType>) => JSX.Element;
4
+ component: <ValueType extends string>({ options, value, onChange, wide, inlineLayout, inlineIcon, classNames: classNamesObj, bordered, disabled, fieldLegend, groupName, }: RadioProps<ValueType>) => JSX.Element;
5
5
  argTypes: {
6
6
  options: {
7
7
  description: string;
@@ -9,6 +9,12 @@ declare const story: {
9
9
  value: {
10
10
  description: string;
11
11
  };
12
+ fieldLegend: {
13
+ description: string;
14
+ };
15
+ groupName: {
16
+ description: string;
17
+ };
12
18
  onChange: {
13
19
  description: string;
14
20
  action: boolean;
@@ -50,6 +56,8 @@ declare const story: {
50
56
  description: string;
51
57
  };
52
58
  };
59
+ fieldLegend: string;
60
+ groupName: string;
53
61
  value: string;
54
62
  wide: boolean;
55
63
  classNames: {
@@ -64,7 +72,7 @@ declare const story: {
64
72
  };
65
73
  };
66
74
  export declare const RadioStory: {
67
- ({ onChange, options, wide, classNames, inlineLayout, bordered, disabled, }: RadioProps<string>): JSX.Element;
75
+ ({ onChange, options, wide, classNames, inlineLayout, bordered, disabled, fieldLegend, groupName, }: RadioProps<string>): JSX.Element;
68
76
  storyName: string;
69
77
  };
70
78
  export declare const RadioWithCustomWrapperStyles: ({ onChange, }: RadioProps<string>) => JSX.Element;
@@ -6,13 +6,13 @@ import '../icon/IconWrapper/IconWrapper.js';
6
6
  import '../../tslib.es6-a39f91fc.js';
7
7
  import '../../index-6ea95111.js';
8
8
 
9
- var css_248z = ".style-module_chip__3LMgV {\n background: var(--ds-primary-100);\n border: 2px solid var(--ds-primary-100);\n border-radius: 8px;\n padding: 4px 8px;\n width: fit-content;\n width: -moz-fit-content;\n display: flex;\n align-items: center;\n animation-name: style-module_appearInAnimation__33Ebn;\n animation-duration: 0.5s;\n animation-fill-mode: both;\n}\n\n.style-module_chip__3LMgV:hover {\n transition: 0.2s ease-in;\n border: 2px solid var(--ds-primary-500);\n}\n\n.style-module_chip-image__2vVqF {\n width: 24px;\n height: 14px;\n}\n\n.style-module_chip-button-container__3gSRY {\n color: #b1b0f5;\n position: relative;\n width: 16px;\n height: 16px;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n text-align: inherit;\n outline: none;\n box-shadow: none;\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n cursor: pointer;\n}\n.style-module_chip-button-container__3gSRY:hover {\n color: #8e8cee;\n}\n\n.style-module_chip-remove-button__3LK7e {\n margin: 0;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.style-module_chip-remove-button__3LK7e svg {\n vertical-align: top;\n}\n\n@keyframes style-module_appearInAnimation__33Ebn {\n from {\n opacity: 0;\n transform: translateX(16px);\n }\n to {\n opacity: 1;\n }\n}";
9
+ var css_248z = ".style-module_chip__3LMgV {\n background: var(--ds-primary-100);\n border: 2px solid var(--ds-primary-100);\n border-radius: 8px;\n padding: 4px 8px;\n width: fit-content;\n width: -moz-fit-content;\n display: flex;\n align-items: center;\n animation-name: style-module_appearInAnimation__33Ebn;\n animation-duration: 0.5s;\n animation-fill-mode: both;\n}\n\n.style-module_chip__3LMgV:hover {\n transition: 0.2s ease-in;\n border: 2px solid var(--ds-primary-500);\n}\n\n.style-module_chip-image__2vVqF {\n width: 24px;\n height: 14px;\n}\n\n.style-module_chip-button-container__3gSRY {\n color: #b1b0f5;\n position: relative;\n width: 16px;\n height: 16px;\n background: none;\n border: none;\n padding: 0;\n margin: 0;\n text-align: inherit;\n outline: none;\n box-shadow: none;\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n cursor: pointer;\n}\n.style-module_chip-button-container__3gSRY:hover {\n color: #8e8cee;\n}\n.style-module_chip-button-container__3gSRY:focus-visible {\n outline: 2px solid var(--ds-primary-500);\n border-radius: 2px;\n}\n\n.style-module_chip-remove-button__3LK7e {\n margin: 0;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.style-module_chip-remove-button__3LK7e svg {\n vertical-align: top;\n}\n\n@keyframes style-module_appearInAnimation__33Ebn {\n from {\n opacity: 0;\n transform: translateX(16px);\n }\n to {\n opacity: 1;\n }\n}";
10
10
  var styles = {"chip":"style-module_chip__3LMgV","appearInAnimation":"style-module_appearInAnimation__33Ebn","chip-image":"style-module_chip-image__2vVqF","chip-button-container":"style-module_chip-button-container__3gSRY","chip-remove-button":"style-module_chip-remove-button__3LK7e"};
11
11
  styleInject(css_248z);
12
12
 
13
13
  var Chip = (function (_a) {
14
14
  var className = _a.className, value = _a.value, onRemove = _a.onRemove;
15
- return (jsxs("div", { className: "p-p mr8 mb8 d-flex ".concat(className, " ").concat(styles['chip']), children: [value.leftIcon && (jsx("img", { className: "mr8 ".concat(styles['chip-image']), src: value.leftIcon, alt: value.value })), jsx("div", { className: "mr8", children: value.value }), jsx("button", { className: "c-pointer ".concat(styles['chip-button-container']), type: "button", onClick: function () { return onRemove(value); }, children: jsx(XIcon, { className: styles['chip-remove-button'] }) })] }));
15
+ return (jsxs("div", { className: "p-p mr8 mb8 d-flex ".concat(className, " ").concat(styles['chip']), children: [value.leftIcon && (jsx("img", { className: "mr8 ".concat(styles['chip-image']), src: value.leftIcon, alt: value.value })), jsx("div", { className: "mr8", children: value.value }), jsx("button", { className: "c-pointer ".concat(styles['chip-button-container']), type: "button", onClick: function () { return onRemove(value); }, "aria-label": "Remove ".concat(value.value, " option"), children: jsx(XIcon, { className: styles['chip-remove-button'] }) })] }));
16
16
  });
17
17
 
18
18
  export default Chip;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/lib/components/chip/index.tsx"],"sourcesContent":["import { Option } from '../../models/autoSuggestInput';\nimport { XIcon } from '../icon/icons';\n\nimport styles from './style.module.scss';\n\nexport interface ChipProps {\n value: Option;\n onRemove: (value: Option) => void;\n className?: string;\n}\n\nexport default ({\n className,\n value,\n onRemove,\n}: ChipProps) => (\n <div className={`p-p mr8 mb8 d-flex ${className} ${styles['chip']}`}>\n {value.leftIcon && (\n <img\n className={`mr8 ${styles['chip-image']}`}\n src={value.leftIcon}\n alt={value.value}\n />\n )}\n <div className=\"mr8\">{value.value}</div>\n <button\n className={`c-pointer ${styles['chip-button-container']}`}\n type=\"button\"\n onClick={() => onRemove(value)}\n >\n <XIcon className={styles['chip-remove-button']} />\n </button>\n </div>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAWA,YAAe,UAAC,EAIJ;QAHV,SAAS,eAAA,EACT,KAAK,WAAA,EACL,QAAQ,cAAA;IACO,QACfA,cAAK,SAAS,EAAE,6BAAsB,SAAS,cAAI,MAAM,CAAC,MAAM,CAAC,CAAE,aAChE,KAAK,CAAC,QAAQ,KACbC,aACE,SAAS,EAAE,cAAO,MAAM,CAAC,YAAY,CAAC,CAAE,EACxC,GAAG,EAAE,KAAK,CAAC,QAAQ,EACnB,GAAG,EAAE,KAAK,CAAC,KAAK,GAChB,CACH,EACDA,aAAK,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAO,EACxCA,gBACE,SAAS,EAAE,oBAAa,MAAM,CAAC,uBAAuB,CAAC,CAAE,EACzD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,CAAC,GAAA,YAE9BA,IAAC,KAAK,IAAC,SAAS,EAAE,MAAM,CAAC,oBAAoB,CAAC,GAAI,GAC3C,IACL;AAjBS,CAkBhB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/lib/components/chip/index.tsx"],"sourcesContent":["import { Option } from '../../models/autoSuggestInput';\nimport { XIcon } from '../icon/icons';\n\nimport styles from './style.module.scss';\n\nexport interface ChipProps {\n value: Option;\n onRemove: (value: Option) => void;\n className?: string;\n}\n\nexport default ({\n className,\n value,\n onRemove,\n}: ChipProps) => (\n <div className={`p-p mr8 mb8 d-flex ${className} ${styles['chip']}`}>\n {value.leftIcon && (\n <img\n className={`mr8 ${styles['chip-image']}`}\n src={value.leftIcon}\n alt={value.value}\n />\n )}\n <div className=\"mr8\">{value.value}</div>\n <button\n className={`c-pointer ${styles['chip-button-container']}`}\n type=\"button\"\n onClick={() => onRemove(value)}\n aria-label={`Remove ${value.value} option`}\n >\n <XIcon className={styles['chip-remove-button']} />\n </button>\n </div>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAWA,YAAe,UAAC,EAIJ;QAHV,SAAS,eAAA,EACT,KAAK,WAAA,EACL,QAAQ,cAAA;IACO,QACfA,cAAK,SAAS,EAAE,6BAAsB,SAAS,cAAI,MAAM,CAAC,MAAM,CAAC,CAAE,aAChE,KAAK,CAAC,QAAQ,KACbC,aACE,SAAS,EAAE,cAAO,MAAM,CAAC,YAAY,CAAC,CAAE,EACxC,GAAG,EAAE,KAAK,CAAC,QAAQ,EACnB,GAAG,EAAE,KAAK,CAAC,KAAK,GAChB,CACH,EACDA,aAAK,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAO,EACxCA,gBACE,SAAS,EAAE,oBAAa,MAAM,CAAC,uBAAuB,CAAC,CAAE,EACzD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,CAAC,GAAA,gBAClB,iBAAU,KAAK,CAAC,KAAK,YAAS,YAE1CA,IAAC,KAAK,IAAC,SAAS,EAAE,MAAM,CAAC,oBAAoB,CAAC,GAAI,GAC3C,IACL;AAlBS,CAmBhB;;;;"}
@@ -1,15 +1,15 @@
1
1
  import { _ as __spreadArray } from '../../../tslib.es6-a39f91fc.js';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { c as classNames } from '../../../index-6ea95111.js';
4
4
  import { s as styleInject } from '../../../style-inject.es-1f59c1d0.js';
5
5
 
6
- var css_248z = ".styles-module_container__3zJJC {\n max-width: 100%;\n}\n\n.styles-module_narrow__2p34b {\n max-width: 424px;\n}";
6
+ var css_248z = ".styles-module_container__3zJJC {\n max-width: 100%;\n border: 0;\n margin: 0;\n min-width: 0;\n padding: 0.01em 0 0 0;\n}\n\n.styles-module_narrow__2p34b {\n max-width: 424px;\n}";
7
7
  var styles = {"container":"styles-module_container__3zJJC","narrow":"styles-module_narrow__2p34b"};
8
8
  styleInject(css_248z);
9
9
 
10
10
  var Checkbox = function (_a) {
11
11
  var _b;
12
- var options = _a.options, _c = _a.value, value = _c === void 0 ? [] : _c, onChange = _a.onChange, _d = _a.wide, wide = _d === void 0 ? false : _d, _e = _a.inlineLayout, inlineLayout = _e === void 0 ? false : _e, _f = _a.bordered, bordered = _f === void 0 ? true : _f, classNamesObj = _a.classNames;
12
+ var options = _a.options, _c = _a.value, value = _c === void 0 ? [] : _c, onChange = _a.onChange, _d = _a.wide, wide = _d === void 0 ? false : _d, _e = _a.inlineLayout, inlineLayout = _e === void 0 ? false : _e, _f = _a.bordered, bordered = _f === void 0 ? true : _f, classNamesObj = _a.classNames, _g = _a.fieldLegend, fieldLegend = _g === void 0 ? 'Select one or more options' : _g;
13
13
  var hasNoneValue = Object.keys(options).includes('NONE');
14
14
  var handleOnChange = function (newValue) {
15
15
  if (value === null || value === void 0 ? void 0 : value.includes(newValue)) {
@@ -34,23 +34,23 @@ var Checkbox = function (_a) {
34
34
  var isCheckboxLabelObject = function (label) {
35
35
  return label.title !== undefined;
36
36
  };
37
- return (jsx("div", { className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.container, styles.container, 'd-flex gap8', (_b = {},
37
+ return (jsxs("fieldset", { className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.container, styles.container, 'd-flex gap8', (_b = {},
38
38
  _b[styles.narrow] = !wide,
39
39
  _b['fd-row'] = inlineLayout,
40
40
  _b['f-wrap'] = inlineLayout,
41
41
  _b['fd-column'] = !inlineLayout,
42
- _b)), children: entries.map(function (_a) {
43
- var currentValue = _a[0], label = _a[1];
44
- var checked = value === null || value === void 0 ? void 0 : value.includes(currentValue);
45
- var customIcon = label === null || label === void 0 ? void 0 : label.icon;
46
- return (jsxs("div", { className: classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.option, children: [jsx("input", { className: classNames('p-checkbox', {
47
- 'p-checkbox--no-icon': customIcon,
48
- }), id: currentValue, type: "checkbox", value: currentValue, onChange: function () { return handleOnChange(currentValue); }, checked: checked, "data-testid": "checkbox-input-".concat(currentValue) }), jsxs("label", { htmlFor: currentValue, className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.label, 'p-label pr16', {
49
- 'p-label--bordered': bordered,
50
- 'jc-center': customIcon,
51
- 'fd-column': customIcon,
52
- }), "data-cy": "checkbox-".concat(currentValue), "data-testid": "checkbox-".concat(currentValue), children: [customIcon && jsx("div", { className: "mt8", children: customIcon === null || customIcon === void 0 ? void 0 : customIcon(checked) }), isCheckboxLabelObject(label) ? (jsxs("div", { children: [jsx("p", { className: "p-p", children: label.title }), jsx("span", { className: "d-block p-p p-p--small tc-grey-600", children: label.description })] })) : (label)] })] }, currentValue));
53
- }) }));
42
+ _b)), children: [jsx("legend", { className: "sr-only", children: fieldLegend }), entries.map(function (_a) {
43
+ var currentValue = _a[0], label = _a[1];
44
+ var checked = value === null || value === void 0 ? void 0 : value.includes(currentValue);
45
+ var customIcon = label === null || label === void 0 ? void 0 : label.icon;
46
+ return (jsxs("div", { className: classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.option, children: [jsx("input", { className: classNames('p-checkbox', {
47
+ 'p-checkbox--no-icon': customIcon,
48
+ }), id: currentValue, type: "checkbox", value: currentValue, onChange: function () { return handleOnChange(currentValue); }, checked: checked, "data-testid": "checkbox-input-".concat(currentValue) }), jsxs("label", { htmlFor: currentValue, className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.label, 'p-label pr16', {
49
+ 'p-label--bordered': bordered,
50
+ 'jc-center': customIcon,
51
+ 'fd-column': customIcon,
52
+ }), "data-cy": "checkbox-".concat(currentValue), "data-testid": "checkbox-".concat(currentValue), children: [customIcon && jsx("div", { className: "mt8", children: customIcon === null || customIcon === void 0 ? void 0 : customIcon(checked) }), isCheckboxLabelObject(label) ? (jsxs("div", { children: [jsx("p", { className: "p-p", children: label.title }), jsx("span", { className: "d-block p-p p-p--small tc-grey-600", children: label.description })] })) : (label)] })] }, currentValue));
53
+ })] }));
54
54
  };
55
55
 
56
56
  export { Checkbox };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/checkbox/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode } from 'react';\n\nimport styles from './styles.module.scss';\nexport interface CheckboxWithDescription {\n title: ReactNode;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n}\n\nexport interface CheckboxProps<ValueType extends string> {\n options: Record<ValueType, ReactNode | CheckboxWithDescription>;\n value?: ValueType[];\n onChange: (value: ValueType[]) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n bordered?: Boolean;\n classNames?: {\n container?: string;\n label?: string;\n option?: string;\n };\n}\n\nexport const Checkbox = <ValueType extends string>({\n options,\n value = [],\n onChange,\n wide = false,\n inlineLayout = false,\n bordered = true,\n classNames: classNamesObj,\n}: CheckboxProps<ValueType> & {}) => {\n const hasNoneValue = Object.keys(options).includes('NONE');\n\n const handleOnChange = (newValue: ValueType) => {\n if (value?.includes(newValue)) {\n const filteredCheckboxValues = value.filter(\n (selectedValue) => selectedValue !== newValue\n );\n\n onChange(filteredCheckboxValues);\n return;\n }\n\n if (hasNoneValue && newValue === 'NONE') {\n onChange([newValue]);\n return;\n }\n\n if (hasNoneValue && newValue !== 'NONE') {\n const newValues = value\n ? [...value.filter((v) => v !== 'NONE'), newValue]\n : [newValue];\n onChange(newValues);\n return;\n }\n\n const newValues = value ? [...value, newValue] : [newValue];\n onChange(newValues);\n };\n\n const entries = Object.entries(options) as [\n ValueType,\n ReactNode | CheckboxWithDescription\n ][];\n\n const isCheckboxLabelObject = (\n label: ReactNode | CheckboxWithDescription\n ): label is CheckboxWithDescription => {\n return (label as CheckboxWithDescription).title !== undefined;\n };\n\n return (\n <div\n className={classNames(\n classNamesObj?.container,\n styles.container,\n 'd-flex gap8',\n {\n [styles.narrow]: !wide,\n 'fd-row': inlineLayout,\n 'f-wrap': inlineLayout,\n 'fd-column': !inlineLayout,\n }\n )}\n >\n {entries.map(([currentValue, label]) => {\n const checked = value?.includes(currentValue);\n const customIcon = (label as CheckboxWithDescription)?.icon;\n\n return (\n <div className={classNamesObj?.option} key={currentValue}>\n <input\n className={classNames('p-checkbox', {\n 'p-checkbox--no-icon': customIcon,\n })}\n id={currentValue}\n type=\"checkbox\"\n value={currentValue}\n onChange={() => handleOnChange(currentValue)}\n checked={checked}\n data-testid={`checkbox-input-${currentValue}`}\n />\n\n <label\n htmlFor={currentValue}\n className={classNames(classNamesObj?.label, 'p-label pr16', {\n 'p-label--bordered': bordered,\n 'jc-center': customIcon,\n 'fd-column': customIcon,\n })}\n data-cy={`checkbox-${currentValue}`}\n data-testid={`checkbox-${currentValue}`}\n >\n {customIcon && <div className=\"mt8\">{customIcon?.(checked)}</div>}\n\n {isCheckboxLabelObject(label) ? (\n <div>\n <p className=\"p-p\">{label.title}</p>\n <span className=\"d-block p-p p-p--small tc-grey-600\">\n {label.description}\n </span>\n </div>\n ) : (\n label\n )}\n </label>\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;IAwBa,QAAQ,GAAG,UAA2B,EAQnB;;QAP9B,OAAO,aAAA,EACP,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EACV,QAAQ,cAAA,EACR,YAAY,EAAZ,IAAI,mBAAG,KAAK,KAAA,EACZ,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA,EACpB,gBAAe,EAAf,QAAQ,mBAAG,IAAI,KAAA,EACH,aAAa,gBAAA;IAEzB,IAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE3D,IAAM,cAAc,GAAG,UAAC,QAAmB;QACzC,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC7B,IAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CACzC,UAAC,aAAa,IAAK,OAAA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U,GAAI,KAAiC,aAAjC,KAAK,uBAAL,KAAK,CAA8B,IAAI,CAAC;YAE5D,QACEC,cAAK,SAAS,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,aACnCD,eACE,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE;4BAClC,qBAAqB,EAAE,UAAU;yBAClC,CAAC,EACF,EAAE,EAAE,YAAY,EAChB,IAAI,EAAC,UAAU,EACf,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAM,OAAA,cAAc,CAAC,YAAY,CAAC,GAAA,EAC5C,OAAO,EAAE,OAAO,iBACH,yBAAkB,YAAY,CAAE,GAC7C,EAEFC,gBACE,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,UAAU,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAAE,cAAc,EAAE;4BAC1D,mBAAmB,EAAE,QAAQ;4BAC7B,WAAW,EAAE,UAAU;4BACvB,WAAW,EAAE,UAAU;yBACxB,CAAC,aACO,mBAAY,YAAY,CAAE,iBACtB,mBAAY,YAAY,CAAE,aAEtC,UAAU,IAAID,aAAK,SAAS,EAAC,KAAK,YAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,OAAO,CAAC,GAAO,EAEhE,qBAAqB,CAAC,KAAK,CAAC,IAC3BC,yBACED,WAAG,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAK,EACpCA,cAAM,SAAS,EAAC,oCAAoC,YACjD,KAAK,CAAC,WAAW,GACb,IACH,KAEN,KAAK,CACN,IACK,KAnCkC,YAAY,CAoClD,EACN;SACH,CAAC,GACE,EACN;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/checkbox/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode } from 'react';\n\nimport styles from './styles.module.scss';\nexport interface CheckboxWithDescription {\n title: ReactNode;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n}\n\nexport interface CheckboxProps<ValueType extends string> {\n options: Record<ValueType, ReactNode | CheckboxWithDescription>;\n value?: ValueType[];\n onChange: (value: ValueType[]) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n bordered?: Boolean;\n classNames?: {\n container?: string;\n label?: string;\n option?: string;\n };\n fieldLegend?: string;\n}\n\nexport const Checkbox = <ValueType extends string>({\n options,\n value = [],\n onChange,\n wide = false,\n inlineLayout = false,\n bordered = true,\n classNames: classNamesObj,\n fieldLegend = 'Select one or more options',\n}: CheckboxProps<ValueType> & {}) => {\n const hasNoneValue = Object.keys(options).includes('NONE');\n\n const handleOnChange = (newValue: ValueType) => {\n if (value?.includes(newValue)) {\n const filteredCheckboxValues = value.filter(\n (selectedValue) => selectedValue !== newValue\n );\n\n onChange(filteredCheckboxValues);\n return;\n }\n\n if (hasNoneValue && newValue === 'NONE') {\n onChange([newValue]);\n return;\n }\n\n if (hasNoneValue && newValue !== 'NONE') {\n const newValues = value\n ? [...value.filter((v) => v !== 'NONE'), newValue]\n : [newValue];\n onChange(newValues);\n return;\n }\n\n const newValues = value ? [...value, newValue] : [newValue];\n onChange(newValues);\n };\n\n const entries = Object.entries(options) as [\n ValueType,\n ReactNode | CheckboxWithDescription\n ][];\n\n const isCheckboxLabelObject = (\n label: ReactNode | CheckboxWithDescription\n ): label is CheckboxWithDescription => {\n return (label as CheckboxWithDescription).title !== undefined;\n };\n\n return (\n <fieldset\n className={classNames(\n classNamesObj?.container,\n styles.container,\n 'd-flex gap8',\n {\n [styles.narrow]: !wide,\n 'fd-row': inlineLayout,\n 'f-wrap': inlineLayout,\n 'fd-column': !inlineLayout,\n }\n )}\n >\n <legend className=\"sr-only\">{fieldLegend}</legend>\n {entries.map(([currentValue, label]) => {\n const checked = value?.includes(currentValue);\n const customIcon = (label as CheckboxWithDescription)?.icon;\n\n return (\n <div className={classNamesObj?.option} key={currentValue}>\n <input\n className={classNames('p-checkbox', {\n 'p-checkbox--no-icon': customIcon,\n })}\n id={currentValue}\n type=\"checkbox\"\n value={currentValue}\n onChange={() => handleOnChange(currentValue)}\n checked={checked}\n data-testid={`checkbox-input-${currentValue}`}\n />\n\n <label\n htmlFor={currentValue}\n className={classNames(classNamesObj?.label, 'p-label pr16', {\n 'p-label--bordered': bordered,\n 'jc-center': customIcon,\n 'fd-column': customIcon,\n })}\n data-cy={`checkbox-${currentValue}`}\n data-testid={`checkbox-${currentValue}`}\n >\n {customIcon && <div className=\"mt8\">{customIcon?.(checked)}</div>}\n\n {isCheckboxLabelObject(label) ? (\n <div>\n <p className=\"p-p\">{label.title}</p>\n <span className=\"d-block p-p p-p--small tc-grey-600\">\n {label.description}\n </span>\n </div>\n ) : (\n label\n )}\n </label>\n </div>\n );\n })}\n </fieldset>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;IAyBa,QAAQ,GAAG,UAA2B,EASnB;;QAR9B,OAAO,aAAA,EACP,aAAU,EAAV,KAAK,mBAAG,EAAE,KAAA,EACV,QAAQ,cAAA,EACR,YAAY,EAAZ,IAAI,mBAAG,KAAK,KAAA,EACZ,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA,EACpB,gBAAe,EAAf,QAAQ,mBAAG,IAAI,KAAA,EACH,aAAa,gBAAA,EACzB,mBAA0C,EAA1C,WAAW,mBAAG,4BAA4B,KAAA;IAE1C,IAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE3D,IAAM,cAAc,GAAG,UAAC,QAAmB;QACzC,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC7B,IAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CACzC,UAAC,aAAa,IAAK,OAAA,aAAa,KAAK,QAAQ,GAAA,CAC9C,CAAC;YAEF,QAAQ,CAAC,sBAAsB,CAAC,CAAC;YACjC,OAAO;SACR;QAED,IAAI,YAAY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AAC;gBAE5D,QACED,cAAK,SAAS,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,aACnCC,eACE,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE;gCAClC,qBAAqB,EAAE,UAAU;6BAClC,CAAC,EACF,EAAE,EAAE,YAAY,EAChB,IAAI,EAAC,UAAU,EACf,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAM,OAAA,cAAc,CAAC,YAAY,CAAC,GAAA,EAC5C,OAAO,EAAE,OAAO,iBACH,yBAAkB,YAAY,CAAE,GAC7C,EAEFD,gBACE,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,UAAU,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAAE,cAAc,EAAE;gCAC1D,mBAAmB,EAAE,QAAQ;gCAC7B,WAAW,EAAE,UAAU;gCACvB,WAAW,EAAE,UAAU;6BACxB,CAAC,aACO,mBAAY,YAAY,CAAE,iBACtB,mBAAY,YAAY,CAAE,aAEtC,UAAU,IAAIC,aAAK,SAAS,EAAC,KAAK,YAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,OAAO,CAAC,GAAO,EAEhE,qBAAqB,CAAC,KAAK,CAAC,IAC3BD,yBACEC,WAAG,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAK,EACpCA,cAAM,SAAS,EAAC,oCAAoC,YACjD,KAAK,CAAC,WAAW,GACb,IACH,KAEN,KAAK,CACN,IACK,KAnCkC,YAAY,CAoClD,EACN;aACH,CAAC,IACO,EACX;AACJ;;;;"}
@@ -16,16 +16,19 @@ var story = {
16
16
  value: {
17
17
  description: 'Current checked values.',
18
18
  },
19
+ fieldLegend: {
20
+ description: 'Accessibility property that describes the purpose of a group of checkbox buttons, read aloud by screen readers to provide context.',
21
+ },
19
22
  onChange: {
20
23
  description: 'Function called everytime a value changes.',
21
24
  action: true,
22
25
  table: {
23
- category: "Callbacks",
26
+ category: 'Callbacks',
24
27
  },
25
28
  },
26
29
  wide: {
27
30
  description: 'Property that defines if options should fill 100% of available horizontal space',
28
- defaultValue: false
31
+ defaultValue: false,
29
32
  },
30
33
  bordered: {
31
34
  control: 'boolean',
@@ -42,37 +45,38 @@ var story = {
42
45
  options: {
43
46
  CAT: {
44
47
  title: 'Cat',
45
- description: 'At least 1'
48
+ description: 'At least 1',
46
49
  },
47
50
  DOG: {
48
51
  title: 'Dog',
49
- description: 'At least 2'
52
+ description: 'At least 2',
50
53
  },
51
54
  NONE: {
52
55
  title: 'None',
53
- description: 'No pets'
54
- }
56
+ description: 'No pets',
57
+ },
55
58
  },
59
+ fieldLegend: 'Owned pets',
56
60
  wide: false,
57
61
  bordered: true,
58
62
  inlineLayout: false,
59
63
  classNames: {
60
64
  container: '',
61
65
  label: '',
62
- option: ''
66
+ option: '',
63
67
  },
64
68
  value: [],
65
- className: ''
66
- }
69
+ className: '',
70
+ },
67
71
  };
68
72
  var CheckboxStory = function (_a) {
69
- var onChange = _a.onChange, options = _a.options, wide = _a.wide, bordered = _a.bordered, classNames = _a.classNames, inlineLayout = _a.inlineLayout;
73
+ var onChange = _a.onChange, options = _a.options, wide = _a.wide, bordered = _a.bordered, classNames = _a.classNames, inlineLayout = _a.inlineLayout, fieldLegend = _a.fieldLegend;
70
74
  var _b = useState([]), checkedValues = _b[0], setCheckedValues = _b[1];
71
75
  var handleOnChange = function (newValue) {
72
76
  setCheckedValues(newValue);
73
77
  onChange(newValue);
74
78
  };
75
- return (jsx(Checkbox, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, bordered: bordered, classNames: classNames, inlineLayout: inlineLayout }));
79
+ return (jsx(Checkbox, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, bordered: bordered, classNames: classNames, inlineLayout: inlineLayout, fieldLegend: fieldLegend }));
76
80
  };
77
81
  var CheckboxWithCustomWrapperStyles = function (_a) {
78
82
  var onChange = _a.onChange;
@@ -85,7 +89,7 @@ var CheckboxWithCustomWrapperStyles = function (_a) {
85
89
  return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
86
90
  CAT1: 'Cat',
87
91
  DOG1: 'Dog',
88
- }, classNames: { container: "p32 bg-primary-300 br24 bs-lg" } }));
92
+ }, classNames: { container: 'p32 bg-primary-300 br24 bs-lg' } }));
89
93
  };
90
94
  var CheckboxWithCustomOptionStyles = function (_a) {
91
95
  var onChange = _a.onChange;
@@ -98,7 +102,7 @@ var CheckboxWithCustomOptionStyles = function (_a) {
98
102
  return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
99
103
  CAT2: 'Cat',
100
104
  DOG2: 'Dog',
101
- }, classNames: { option: "mb32 p24 bg-green-100 br12 bs-lg" } }));
105
+ }, classNames: { option: 'mb32 p24 bg-green-100 br12 bs-lg' } }));
102
106
  };
103
107
  var CheckboxWithCustomLabelStyles = function (_a) {
104
108
  var onChange = _a.onChange;
@@ -111,7 +115,7 @@ var CheckboxWithCustomLabelStyles = function (_a) {
111
115
  return (jsx(Checkbox, { onChange: handleOnChange, value: checkedValues, options: {
112
116
  CAT3: 'Cat',
113
117
  DOG3: 'Dog',
114
- }, classNames: { label: "bg-grey-900 tc-white" } }));
118
+ }, classNames: { label: 'bg-grey-900 tc-white' } }));
115
119
  };
116
120
  var CheckboxWithInlineLayout = function (_a) {
117
121
  var onChange = _a.onChange;
@@ -128,7 +132,7 @@ var CheckboxWithInlineLayout = function (_a) {
128
132
  RABBIT: 'Rabbit',
129
133
  RAT: 'Rat',
130
134
  ANOTHER: 'Other',
131
- }, classNames: { option: "w30" }, inlineLayout: true, wide: true }));
135
+ }, classNames: { option: 'w30' }, inlineLayout: true, wide: true }));
132
136
  };
133
137
  var CheckboxWithCustomLabel = function (_a) {
134
138
  var onChange = _a.onChange; _a.wide; _a.classNames; _a.inlineLayout;
@@ -140,18 +144,18 @@ var CheckboxWithCustomLabel = function (_a) {
140
144
  };
141
145
  return (jsx(Checkbox, { options: {
142
146
  BIGDOG: {
143
- icon: function () { return jsx("img", { src: images.bigDog, alt: '' }); },
147
+ icon: function () { return jsx("img", { src: images.bigDog, alt: "" }); },
144
148
  title: 'Dog',
145
149
  },
146
150
  FISH: {
147
- icon: function () { return jsx("img", { src: images.brokenAquarium, alt: '' }); },
151
+ icon: function () { return jsx("img", { src: images.brokenAquarium, alt: "" }); },
148
152
  title: 'Fish',
149
153
  },
150
154
  OTHER: {
151
- icon: function () { return jsx("img", { src: images.brokenGlass, alt: '' }); },
155
+ icon: function () { return jsx("img", { src: images.brokenGlass, alt: "" }); },
152
156
  title: 'Other',
153
- }
154
- }, onChange: handleOnChange, value: checkedValues, classNames: { option: "w30" }, inlineLayout: true }));
157
+ },
158
+ }, onChange: handleOnChange, value: checkedValues, classNames: { option: 'w30' }, inlineLayout: true }));
155
159
  };
156
160
  CheckboxStory.storyName = 'Checkbox';
157
161
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.stories.js","sources":["../../../../../../src/lib/components/input/checkbox/index.stories.tsx"],"sourcesContent":["\nimport { useState } from 'react';\nimport { Checkbox, CheckboxProps } from '.';\nimport { images } from '../../../util/images';\nimport classNames from 'classnames';\n\nconst story = {\n title: 'JSX/Inputs/Checkbox',\n component: Checkbox,\n argTypes: {\n options: {\n description: 'Object that contains the possible options for rendering in the input.',\n },\n value: {\n description: 'Current checked values.',\n },\n onChange: {\n description: 'Function called everytime a value changes.',\n action: true,\n table: {\n category: \"Callbacks\",\n },\n },\n wide: {\n description: 'Property that defines if options should fill 100% of available horizontal space',\n defaultValue: false\n },\n bordered: {\n control: 'boolean',\n description: 'Property that defines if checkbox should show the border around each label',\n },\n inlineLayout: {\n description: 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',\n },\n className: {\n description: 'ClassNames for custom styling',\n },\n },\n args: {\n options: {\n CAT:{\n title: 'Cat',\n description: 'At least 1'\n },\n DOG:{\n title: 'Dog',\n description: 'At least 2'\n },\n NONE:{\n title: 'None',\n description: 'No pets'\n }\n },\n wide: false,\n bordered: true,\n inlineLayout: false,\n classNames: {\n container: '',\n label: '',\n option: ''\n },\n value: [],\n className: ''\n }\n};\n\nexport const CheckboxStory = ({ \n onChange,\n options,\n wide,\n bordered,\n classNames,\n inlineLayout,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[]) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n wide={wide}\n options={options} \n onChange={handleOnChange}\n value={checkedValues}\n bordered={bordered}\n classNames={classNames}\n inlineLayout={inlineLayout}\n />\n );\n}\n\nexport const CheckboxWithCustomWrapperStyles = ({ onChange }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT1: 'Cat',\n DOG1: 'Dog',\n }} \n classNames={{ container: \"p32 bg-primary-300 br24 bs-lg\" }}\n />\n );\n}\n\nexport const CheckboxWithCustomOptionStyles = ({ onChange }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT2: 'Cat',\n DOG2: 'Dog',\n }} \n classNames={{ option: \"mb32 p24 bg-green-100 br12 bs-lg\" }}\n />\n );\n}\n\nexport const CheckboxWithCustomLabelStyles = ({ onChange }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT3: 'Cat',\n DOG3: 'Dog',\n }} \n classNames={{ label: \"bg-grey-900 tc-white\" }}\n />\n );\n}\n\nexport const CheckboxWithInlineLayout = ({ onChange }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT4: 'Cat',\n DOG4: 'Dog',\n FISHER: 'Fish',\n RABBIT: 'Rabbit',\n RAT: 'Rat',\n ANOTHER: 'Other',\n }} \n classNames={{ option: \"w30\" }}\n inlineLayout\n wide\n />\n );\n}\n\nexport const CheckboxWithCustomLabel = ({ onChange, wide, classNames, inlineLayout }: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n }\n\n return (\n <Checkbox \n options={{\n BIGDOG: {\n icon: () => <img src={images.bigDog} alt='' />,\n title: 'Dog',\n },\n FISH:{\n icon: () => <img src={images.brokenAquarium} alt='' />,\n title: 'Fish',\n },\n OTHER:{\n icon: () => <img src={images.brokenGlass} alt='' />,\n title: 'Other',\n }\n }} \n onChange={handleOnChange}\n value={checkedValues}\n classNames={{ option: \"w30\" }}\n inlineLayout\n />\n );\n}\n\nCheckboxStory.storyName = 'Checkbox';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;IAMM,KAAK,GAAG;IACZ,KAAK,EAAE,qBAAqB;IAC5B,SAAS,EAAE,QAAQ;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,WAAW,EAAE,uEAAuE;SACrF;QACD,KAAK,EAAE;YACL,WAAW,EAAE,yBAAyB;SACvC;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,4CAA4C;YACzD,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL,QAAQ,EAAE,WAAW;aACtB;SACF;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,iFAAiF;YAC9F,YAAY,EAAE,KAAK;SACpB;QACD,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Q,CAAC,QAAQ,CAAC,CAAC;KACpB,CAAA;IAED,QACEA,IAAC,QAAQ,IACP,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBAC9C,KAAK,EAAE,KAAK;aACb;YACD,IAAI,EAAC;gBACH,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBACtD,KAAK,EAAE,MAAM;aACd;YACD,KAAK,EAAC;gBACJ,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBACnD,KAAK,EAAE,OAAO;aACf;SACF,EACD,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC7B,YAAY,SACZ,EACF;AACJ,EAAC;AAED,aAAa,CAAC,SAAS,GAAG,UAAU;;;;;"}
1
+ {"version":3,"file":"index.stories.js","sources":["../../../../../../src/lib/components/input/checkbox/index.stories.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Checkbox, CheckboxProps } from '.';\nimport { images } from '../../../util/images';\nimport classNames from 'classnames';\n\nconst story = {\n title: 'JSX/Inputs/Checkbox',\n component: Checkbox,\n argTypes: {\n options: {\n description:\n 'Object that contains the possible options for rendering in the input.',\n },\n value: {\n description: 'Current checked values.',\n },\n fieldLegend: {\n description:\n 'Accessibility property that describes the purpose of a group of checkbox buttons, read aloud by screen readers to provide context.',\n },\n onChange: {\n description: 'Function called everytime a value changes.',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n wide: {\n description:\n 'Property that defines if options should fill 100% of available horizontal space',\n defaultValue: false,\n },\n bordered: {\n control: 'boolean',\n description:\n 'Property that defines if checkbox should show the border around each label',\n },\n inlineLayout: {\n description:\n 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',\n },\n className: {\n description: 'ClassNames for custom styling',\n },\n },\n args: {\n options: {\n CAT: {\n title: 'Cat',\n description: 'At least 1',\n },\n DOG: {\n title: 'Dog',\n description: 'At least 2',\n },\n NONE: {\n title: 'None',\n description: 'No pets',\n },\n },\n fieldLegend: 'Owned pets',\n wide: false,\n bordered: true,\n inlineLayout: false,\n classNames: {\n container: '',\n label: '',\n option: '',\n },\n value: [],\n className: '',\n },\n};\n\nexport const CheckboxStory = ({\n onChange,\n options,\n wide,\n bordered,\n classNames,\n inlineLayout,\n fieldLegend,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[]) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n wide={wide}\n options={options}\n onChange={handleOnChange}\n value={checkedValues}\n bordered={bordered}\n classNames={classNames}\n inlineLayout={inlineLayout}\n fieldLegend={fieldLegend}\n />\n );\n};\n\nexport const CheckboxWithCustomWrapperStyles = ({\n onChange,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT1: 'Cat',\n DOG1: 'Dog',\n }}\n classNames={{ container: 'p32 bg-primary-300 br24 bs-lg' }}\n />\n );\n};\n\nexport const CheckboxWithCustomOptionStyles = ({\n onChange,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT2: 'Cat',\n DOG2: 'Dog',\n }}\n classNames={{ option: 'mb32 p24 bg-green-100 br12 bs-lg' }}\n />\n );\n};\n\nexport const CheckboxWithCustomLabelStyles = ({\n onChange,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT3: 'Cat',\n DOG3: 'Dog',\n }}\n classNames={{ label: 'bg-grey-900 tc-white' }}\n />\n );\n};\n\nexport const CheckboxWithInlineLayout = ({\n onChange,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n onChange={handleOnChange}\n value={checkedValues}\n options={{\n CAT4: 'Cat',\n DOG4: 'Dog',\n FISHER: 'Fish',\n RABBIT: 'Rabbit',\n RAT: 'Rat',\n ANOTHER: 'Other',\n }}\n classNames={{ option: 'w30' }}\n inlineLayout\n wide\n />\n );\n};\n\nexport const CheckboxWithCustomLabel = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: CheckboxProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string[]>([]);\n\n const handleOnChange = (newValue: string[] = []) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Checkbox\n options={{\n BIGDOG: {\n icon: () => <img src={images.bigDog} alt=\"\" />,\n title: 'Dog',\n },\n FISH: {\n icon: () => <img src={images.brokenAquarium} alt=\"\" />,\n title: 'Fish',\n },\n OTHER: {\n icon: () => <img src={images.brokenGlass} alt=\"\" />,\n title: 'Other',\n },\n }}\n onChange={handleOnChange}\n value={checkedValues}\n classNames={{ option: 'w30' }}\n inlineLayout\n />\n );\n};\n\nCheckboxStory.storyName = 'Checkbox';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;IAKM,KAAK,GAAG;IACZ,KAAK,EAAE,qBAAqB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import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { c as classNames } from '../../../index-6ea95111.js';
3
3
  import { s as styleInject } from '../../../style-inject.es-1f59c1d0.js';
4
+ import { g as generateId } from '../../../index-69a46657.js';
4
5
 
5
- var css_248z = ".styles-module_container__3M-sc {\n max-width: 100%;\n}\n\n.styles-module_narrow__3VUzp {\n max-width: 424px;\n}\n\n.styles-module_wide__3nLhz {\n max-width: 736px;\n}";
6
+ var css_248z = ".styles-module_container__3M-sc {\n max-width: 100%;\n border: 0;\n margin: 0;\n min-width: 0;\n padding: 0.01em 0 0 0;\n}\n\n.styles-module_narrow__3VUzp {\n max-width: 424px;\n}\n\n.styles-module_wide__3nLhz {\n max-width: 736px;\n}";
6
7
  var styles = {"container":"styles-module_container__3M-sc","narrow":"styles-module_narrow__3VUzp","wide":"styles-module_wide__3nLhz"};
7
8
  styleInject(css_248z);
8
9
 
9
10
  var Radio = function (_a) {
10
11
  var _b;
11
- var options = _a.options, value = _a.value, onChange = _a.onChange, _c = _a.wide, wide = _c === void 0 ? false : _c, _d = _a.inlineLayout, inlineLayout = _d === void 0 ? false : _d, _e = _a.inlineIcon, inlineIcon = _e === void 0 ? false : _e, classNamesObj = _a.classNames, _f = _a.bordered, bordered = _f === void 0 ? true : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g;
12
+ var options = _a.options, value = _a.value, onChange = _a.onChange, _c = _a.wide, wide = _c === void 0 ? false : _c, _d = _a.inlineLayout, inlineLayout = _d === void 0 ? false : _d, _e = _a.inlineIcon, inlineIcon = _e === void 0 ? false : _e, classNamesObj = _a.classNames, _f = _a.bordered, bordered = _f === void 0 ? true : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.fieldLegend, fieldLegend = _h === void 0 ? 'Select an option' : _h, groupName = _a.groupName;
12
13
  var entries = Object.entries(options);
13
- return (jsx("div", { className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.container, styles.container, 'd-flex gap8', (_b = {},
14
+ var name = groupName !== null && groupName !== void 0 ? groupName : generateId();
15
+ return (jsxs("fieldset", { className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.container, styles.container, 'd-flex gap8', (_b = {},
14
16
  _b[styles.wide] = wide,
15
17
  _b[styles.narrow] = !wide,
16
18
  _b['fd-row'] = inlineLayout,
17
19
  _b['f-wrap'] = inlineLayout,
18
20
  _b['fd-column'] = !inlineLayout,
19
- _b)), children: entries.map(function (_a) {
20
- var currentValue = _a[0], label = _a[1];
21
- var checked = value === currentValue;
22
- var customIcon = label === null || label === void 0 ? void 0 : label.icon;
23
- var hideIcon = label === null || label === void 0 ? void 0 : label.hideBox;
24
- var isRadioLabelObject = function (label) {
25
- return label.title !== undefined;
26
- };
27
- return (jsxs("div", { className: classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.option, children: [jsx("input", { className: classNames('p-radio', {
28
- 'p-radio--no-icon': customIcon || hideIcon,
29
- 'p-radio--centered': !label,
30
- }), id: currentValue, type: "radio", value: currentValue, onChange: function () { return onChange(currentValue); }, checked: checked, "data-testid": "radio-input-".concat(currentValue), disabled: disabled }), jsxs("label", { htmlFor: currentValue, className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.label, 'p-label', {
31
- 'jc-center': customIcon && !inlineIcon,
32
- 'fd-column': customIcon && !inlineIcon,
33
- 'p-label--bordered': bordered,
34
- }), "data-cy": "radio-".concat(currentValue), "data-testid": "radio-".concat(currentValue), children: [customIcon && (jsx("div", { className: classNames('d-inline-flex ai-center jc-center', inlineIcon ? 'mr8' : 'mt8'), children: customIcon === null || customIcon === void 0 ? void 0 : customIcon(checked) })), isRadioLabelObject(label) ? (jsxs("div", { children: [jsx("p", { className: "p-p", children: label.title }), jsx("span", { className: "d-block p-p p-p--small tc-grey-600", children: label.description })] })) : (label)] })] }, currentValue));
35
- }) }));
21
+ _b)), children: [jsx("legend", { className: "sr-only", children: fieldLegend }), entries.map(function (_a) {
22
+ var currentValue = _a[0], label = _a[1];
23
+ var checked = value === currentValue;
24
+ var customIcon = label === null || label === void 0 ? void 0 : label.icon;
25
+ var hideIcon = label === null || label === void 0 ? void 0 : label.hideBox;
26
+ var isRadioLabelObject = function (label) {
27
+ return label.title !== undefined;
28
+ };
29
+ return (jsxs("div", { className: classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.option, children: [jsx("input", { className: classNames('p-radio', {
30
+ 'p-radio--no-icon': customIcon || hideIcon,
31
+ 'p-radio--centered': !label,
32
+ }), id: currentValue, type: "radio", value: currentValue, onChange: function () { return onChange(currentValue); }, checked: checked, "data-testid": "radio-input-".concat(currentValue), disabled: disabled, name: name }), jsxs("label", { htmlFor: currentValue, className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.label, 'p-label', {
33
+ 'jc-center': customIcon && !inlineIcon,
34
+ 'fd-column': customIcon && !inlineIcon,
35
+ 'p-label--bordered': bordered,
36
+ }), "data-cy": "radio-".concat(currentValue), "data-testid": "radio-".concat(currentValue), children: [customIcon && (jsx("div", { className: classNames('d-inline-flex ai-center jc-center', inlineIcon ? 'mr8' : 'mt8'), children: customIcon === null || customIcon === void 0 ? void 0 : customIcon(checked) })), isRadioLabelObject(label) ? (jsxs("div", { children: [jsx("p", { className: "p-p", children: label.title }), jsx("span", { className: "d-block p-p p-p--small tc-grey-600", children: label.description })] })) : (label)] })] }, currentValue));
37
+ })] }));
36
38
  };
37
39
 
38
40
  export { Radio };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/radio/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode } from 'react';\n\nimport styles from './styles.module.scss';\nexport interface RadioWithDescription {\n title: ReactNode;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n hideBox?: boolean;\n}\n\nexport interface RadioProps<ValueType extends string> {\n options: Record<ValueType, ReactNode | RadioWithDescription>;\n value?: ValueType;\n onChange: (value: ValueType) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n inlineIcon?: boolean;\n classNames?: {\n container?: string;\n label?: string;\n option?: string;\n };\n bordered?: boolean;\n disabled?: boolean;\n}\n\nexport const Radio = <ValueType extends string>({\n options,\n value,\n onChange,\n wide = false,\n inlineLayout = false,\n inlineIcon = false,\n classNames: classNamesObj,\n bordered = true,\n disabled = false,\n}: RadioProps<ValueType>) => {\n const entries = Object.entries(options) as [\n ValueType,\n ReactNode | RadioWithDescription\n ][];\n\n return (\n <div\n className={classNames(\n classNamesObj?.container,\n styles.container,\n 'd-flex gap8',\n {\n [styles.wide]: wide,\n [styles.narrow]: !wide,\n 'fd-row': inlineLayout,\n 'f-wrap': inlineLayout,\n 'fd-column': !inlineLayout,\n }\n )}\n >\n {entries.map(([currentValue, label]) => {\n const checked = value === currentValue;\n const customIcon = (label as RadioWithDescription)?.icon;\n const hideIcon = (label as RadioWithDescription)?.hideBox;\n\n const isRadioLabelObject = (\n label: ReactNode | RadioWithDescription\n ): label is RadioWithDescription => {\n return (label as RadioWithDescription).title !== undefined;\n };\n\n return (\n <div className={classNamesObj?.option} key={currentValue}>\n <input\n className={classNames('p-radio', {\n 'p-radio--no-icon': customIcon || hideIcon,\n 'p-radio--centered': !label,\n })}\n id={currentValue}\n type=\"radio\"\n value={currentValue}\n onChange={() => onChange(currentValue)}\n checked={checked}\n data-testid={`radio-input-${currentValue}`}\n disabled={disabled}\n />\n\n <label\n htmlFor={currentValue}\n className={classNames(classNamesObj?.label, 'p-label', {\n 'jc-center': customIcon && !inlineIcon,\n 'fd-column': customIcon && !inlineIcon,\n 'p-label--bordered': bordered,\n })}\n data-cy={`radio-${currentValue}`}\n data-testid={`radio-${currentValue}`}\n >\n {customIcon && (\n <div\n className={classNames(\n 'd-inline-flex ai-center jc-center',\n inlineIcon ? 'mr8' : 'mt8'\n )}\n >\n {customIcon?.(checked)}\n </div>\n )}\n\n {isRadioLabelObject(label) ? (\n <div>\n <p className=\"p-p\">{label.title}</p>\n <span className=\"d-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,QACEC,cAAK,SAAS,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,aACnCD,eACE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE;4BAC/B,kBAAkB,EAAE,UAAU,IAAI,QAAQ;4BAC1C,mBAAmB,EAAE,CAAC,KAAK;yBAC5B,CAAC,EACF,EAAE,EAAE,YAAY,EAChB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAM,OAAA,QAAQ,CAAC,YAAY,CAAC,GAAA,EACtC,OAAO,EAAE,OAAO,iBACH,sBAAe,YAAY,CAAE,EAC1C,QAAQ,EAAE,QAAQ,GAClB,EAEFC,gBACE,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,UAAU,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAAE,SAAS,EAAE;4BACrD,WAAW,EAAE,UAAU,IAAI,CAAC,UAAU;4BACtC,WAAW,EAAE,UAAU,IAAI,CAAC,UAAU;4BACtC,mBAAmB,EAAE,QAAQ;yBAC9B,CAAC,aACO,gBAAS,YAAY,CAAE,iBACnB,gBAAS,YAAY,CAAE,aAEnC,UAAU,KACTD,aACE,SAAS,EAAE,UAAU,CACnB,mCAAmC,EACnC,UAAU,GAAG,KAAK,GAAG,KAAK,CAC3B,YAEA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,OAAO,CAAC,GAClB,CACP,EAEA,kBAAkB,CAAC,KAAK,CAAC,IACxBC,yBACED,WAAG,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAK,EACpCA,cAAM,SAAS,EAAC,oCAAoC,YACjD,KAAK,CAAC,WAAW,GACb,IACH,KAEN,KAAK,CACN,IACK,KA9CkC,YAAY,CA+ClD,EACN;SACH,CAAC,GACE,EACN;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/lib/components/input/radio/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { ReactNode } from 'react';\n\nimport styles from './styles.module.scss';\nimport generateId from '../../../util/generateId';\nexport interface RadioWithDescription {\n title: ReactNode;\n description?: string;\n icon?: (selected: boolean) => ReactNode;\n hideBox?: boolean;\n}\n\nexport interface RadioProps<ValueType extends string> {\n options: Record<ValueType, ReactNode | RadioWithDescription>;\n value?: ValueType;\n onChange: (value: ValueType) => void;\n wide?: boolean;\n inlineLayout?: boolean;\n inlineIcon?: boolean;\n classNames?: {\n container?: string;\n label?: string;\n option?: string;\n };\n bordered?: boolean;\n disabled?: boolean;\n fieldLegend?: string;\n groupName?: string;\n}\n\nexport const Radio = <ValueType extends string>({\n options,\n value,\n onChange,\n wide = false,\n inlineLayout = false,\n inlineIcon = false,\n classNames: classNamesObj,\n bordered = true,\n disabled = false,\n fieldLegend = 'Select an option',\n groupName,\n}: RadioProps<ValueType>) => {\n const entries = Object.entries(options) as [\n ValueType,\n ReactNode | RadioWithDescription\n ][];\n\n const name = groupName ?? generateId();\n\n return (\n <fieldset\n className={classNames(\n classNamesObj?.container,\n styles.container,\n 'd-flex gap8',\n {\n [styles.wide]: wide,\n [styles.narrow]: !wide,\n 'fd-row': inlineLayout,\n 'f-wrap': inlineLayout,\n 'fd-column': !inlineLayout,\n }\n )}\n >\n <legend className=\"sr-only\">{fieldLegend}</legend>\n {entries.map(([currentValue, label]) => {\n const checked = value === currentValue;\n const customIcon = (label as RadioWithDescription)?.icon;\n const hideIcon = (label as RadioWithDescription)?.hideBox;\n\n const isRadioLabelObject = (\n label: ReactNode | RadioWithDescription\n ): label is RadioWithDescription => {\n return (label as RadioWithDescription).title !== undefined;\n };\n\n return (\n <div className={classNamesObj?.option} key={currentValue}>\n <input\n className={classNames('p-radio', {\n 'p-radio--no-icon': customIcon || hideIcon,\n 'p-radio--centered': !label,\n })}\n id={currentValue}\n type=\"radio\"\n value={currentValue}\n onChange={() => onChange(currentValue)}\n checked={checked}\n data-testid={`radio-input-${currentValue}`}\n disabled={disabled}\n name={name}\n />\n\n <label\n htmlFor={currentValue}\n className={classNames(classNamesObj?.label, 'p-label', {\n 'jc-center': customIcon && !inlineIcon,\n 'fd-column': customIcon && !inlineIcon,\n 'p-label--bordered': bordered,\n })}\n data-cy={`radio-${currentValue}`}\n data-testid={`radio-${currentValue}`}\n >\n {customIcon && (\n <div\n className={classNames(\n 'd-inline-flex ai-center jc-center',\n inlineIcon ? 'mr8' : 'mt8'\n )}\n >\n {customIcon?.(checked)}\n </div>\n )}\n\n {isRadioLabelObject(label) ? (\n <div>\n <p className=\"p-p\">{label.title}</p>\n <span className=\"d-block p-p p-p--small tc-grey-600\">\n {label.description}\n </span>\n </div>\n ) : (\n label\n )}\n </label>\n </div>\n );\n })}\n </fieldset>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;IA8Ba,KAAK,GAAG,UAA2B,EAYxB;;QAXtB,OAAO,aAAA,EACP,KAAK,WAAA,EACL,QAAQ,cAAA,EACR,YAAY,EAAZ,IAAI,mBAAG,KAAK,KAAA,EACZ,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA,EACpB,kBAAkB,EAAlB,UAAU,mBAAG,KAAK,KAAA,EACN,aAAa,gBAAA,EACzB,gBAAe,EAAf,QAAQ,mBAAG,IAAI,KAAA,EACf,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,mBAAgC,EAAhC,WAAW,mBAAG,kBAAkB,KAAA,EAChC,SAAS,eAAA;IAET,IAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAGnC,CAAC;IAEJ,IAAM,IAAI,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,UAAU,EAAE,CAAC;IAEvC,QACEA,mBACE,SAAS,EAAE,UAAU,CACnB,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,EACxB,MAAM,CAAC,SAAS,EAChB,aAAa;YAEX,GAAC,MAAM,CAAC,IAAI,IAAG,IAAI;YACnB,GAAC,MAAM,CAAC,MAAM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B,EAAE,QAAQ;6BAC9B,CAAC,aACO,gBAAS,YAAY,CAAE,iBACnB,gBAAS,YAAY,CAAE,aAEnC,UAAU,KACTC,aACE,SAAS,EAAE,UAAU,CACnB,mCAAmC,EACnC,UAAU,GAAG,KAAK,GAAG,KAAK,CAC3B,YAEA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,OAAO,CAAC,GAClB,CACP,EAEA,kBAAkB,CAAC,KAAK,CAAC,IACxBD,yBACEC,WAAG,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,KAAK,GAAK,EACpCA,cAAM,SAAS,EAAC,oCAAoC,YACjD,KAAK,CAAC,WAAW,GACb,IACH,KAEN,KAAK,CACN,IACK,KA/CkC,YAAY,CAgDlD,EACN;aACH,CAAC,IACO,EACX;AACJ;;;;"}
@@ -4,6 +4,7 @@ import { Radio } from './index.js';
4
4
  import { a as images } from '../../../index-29e6f39e.js';
5
5
  import '../../../index-6ea95111.js';
6
6
  import '../../../style-inject.es-1f59c1d0.js';
7
+ import '../../../index-69a46657.js';
7
8
 
8
9
  var story = {
9
10
  title: 'JSX/Inputs/Radio',
@@ -15,6 +16,12 @@ var story = {
15
16
  value: {
16
17
  description: 'Current checked values.',
17
18
  },
19
+ fieldLegend: {
20
+ description: 'Property that describes the purpose of a group of radio buttons, read aloud by screen readers to provide context.',
21
+ },
22
+ groupName: {
23
+ description: 'Property passed to each radio button. Informs the browser that the radio buttons belong to the same group, so only one can be selected',
24
+ },
18
25
  onChange: {
19
26
  description: 'Function called everytime a value changes.',
20
27
  action: true,
@@ -56,6 +63,8 @@ var story = {
56
63
  description: 'No pets',
57
64
  },
58
65
  },
66
+ fieldLegend: 'Owned pets',
67
+ groupName: 'Pets',
59
68
  value: '',
60
69
  wide: false,
61
70
  classNames: {
@@ -67,16 +76,16 @@ var story = {
67
76
  inlineLayout: false,
68
77
  inlineIcon: false,
69
78
  disabled: false,
70
- }
79
+ },
71
80
  };
72
81
  var RadioStory = function (_a) {
73
- var onChange = _a.onChange, options = _a.options, wide = _a.wide, classNames = _a.classNames, inlineLayout = _a.inlineLayout, bordered = _a.bordered, disabled = _a.disabled;
82
+ var onChange = _a.onChange, options = _a.options, wide = _a.wide, classNames = _a.classNames, inlineLayout = _a.inlineLayout, bordered = _a.bordered, disabled = _a.disabled, fieldLegend = _a.fieldLegend, groupName = _a.groupName;
74
83
  var _b = useState(), checkedValues = _b[0], setCheckedValues = _b[1];
75
84
  var handleOnChange = function (newValue) {
76
85
  setCheckedValues(newValue);
77
86
  onChange(newValue);
78
87
  };
79
- return (jsx(Radio, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, classNames: classNames, inlineLayout: inlineLayout, bordered: bordered, disabled: disabled }));
88
+ return (jsx(Radio, { wide: wide, options: options, onChange: handleOnChange, value: checkedValues, classNames: classNames, inlineLayout: inlineLayout, bordered: bordered, disabled: disabled, fieldLegend: fieldLegend, groupName: groupName }));
80
89
  };
81
90
  var RadioWithCustomWrapperStyles = function (_a) {
82
91
  var onChange = _a.onChange;