@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
@@ -1 +1 @@
1
- {"version":3,"file":"index.stories.js","sources":["../../../../../../src/lib/components/input/radio/index.stories.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Radio, RadioProps } from '.';\nimport { images } from '../../../util/images';\n\nconst story = {\n title: 'JSX/Inputs/Radio',\n component: Radio,\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 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 },\n inlineLayout: {\n description:\n 'Property that defines if options should show inline instead of block. Check inline radio options story for examples.',\n },\n inlineIcon: {\n description: 'Property that defines if options should show inline with icon',\n },\n classNames: {\n description: 'ClassNames for custom styling',\n },\n bordered: {\n description: 'Property that defines if option should show with border',\n },\n disabled: {\n description:\n 'Property that defines if the input and corresponding label are disabled and not clickable',\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 value: '',\n wide: false,\n classNames: {\n container: '',\n label: '',\n option: '',\n },\n bordered: true,\n inlineLayout: false,\n inlineIcon: false,\n disabled: false,\n }\n};\n\nexport const RadioStory = ({\n onChange,\n options,\n wide,\n classNames,\n inlineLayout,\n bordered,\n disabled,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n wide={wide}\n options={options}\n onChange={handleOnChange}\n value={checkedValues}\n classNames={classNames}\n inlineLayout={inlineLayout}\n bordered={bordered}\n disabled={disabled}\n />\n );\n};\n\nexport const RadioWithCustomWrapperStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 RadioWithCustomOptionStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 RadioWithCustomLabelStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 RadioWithInlineLayout = ({ onChange }: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 RadioWithCustomLabel = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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\nexport const RadioWithCustomLabelInline = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 inlineIcon\n value={checkedValues}\n classNames={{ option: 'w30' }}\n inlineLayout\n />\n );\n};\n\nRadioStory.storyName = 'Radio';\n\nexport const RadioIconOnly = ({ onChange }: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n options={{ NOTHING: '' }}\n onChange={handleOnChange}\n classNames={{ label: 'jc-start' }}\n value={checkedValues}\n bordered={false}\n />\n );\n};\n\nRadioStory.storyName = 'Radio';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;IAIM,KAAK,GAAG;IACZ,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,WAAW,EACT,uEAAuE;SAC1E;QACD,KAAK,EAAE;YACL,WAAW,EAAE,yBAAyB;SACvC;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K;aACb;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,cAAM,OAAAA,aAAK,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE,GAAG,EAAC,EAAE,GAAG,GAAA;gBACtD,KAAK,EAAE,MAAM;aACd;YACD,KAAK,EAAE;gBACL,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,UAAU,QACV,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAC7B,YAAY,SACZ,EACF;AACJ,EAAE;AAEF,UAAU,CAAC,SAAS,GAAG,OAAO,CAAC;IAElB,aAAa,GAAG,UAAC,EAAgC;QAA9B,QAAQ,cAAA;IAChC,IAAA,KAAoC,QAAQ,EAAU,EAArD,aAAa,QAAA,EAAE,gBAAgB,QAAsB,CAAC;IAE7D,IAAM,cAAc,GAAG,UAAC,QAAgB;QACtC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACpB,CAAC;IAEF,QACEA,IAAC,KAAK,IACJ,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EACxB,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EACjC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,KAAK,GACf,EACF;AACJ,EAAE;AAEF,UAAU,CAAC,SAAS,GAAG,OAAO;;;;;"}
1
+ {"version":3,"file":"index.stories.js","sources":["../../../../../../src/lib/components/input/radio/index.stories.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Radio, RadioProps } from '.';\nimport { images } from '../../../util/images';\n\nconst story = {\n title: 'JSX/Inputs/Radio',\n component: Radio,\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 'Property that describes the purpose of a group of radio buttons, read aloud by screen readers to provide context.',\n },\n groupName: {\n description:\n 'Property passed to each radio button. Informs the browser that the radio buttons belong to the same group, so only one can be selected',\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 },\n inlineLayout: {\n description:\n 'Property that defines if options should show inline instead of block. Check inline radio options story for examples.',\n },\n inlineIcon: {\n description:\n 'Property that defines if options should show inline with icon',\n },\n classNames: {\n description: 'ClassNames for custom styling',\n },\n bordered: {\n description: 'Property that defines if option should show with border',\n },\n disabled: {\n description:\n 'Property that defines if the input and corresponding label are disabled and not clickable',\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 groupName: 'Pets',\n value: '',\n wide: false,\n classNames: {\n container: '',\n label: '',\n option: '',\n },\n bordered: true,\n inlineLayout: false,\n inlineIcon: false,\n disabled: false,\n },\n};\n\nexport const RadioStory = ({\n onChange,\n options,\n wide,\n classNames,\n inlineLayout,\n bordered,\n disabled,\n fieldLegend,\n groupName,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n wide={wide}\n options={options}\n onChange={handleOnChange}\n value={checkedValues}\n classNames={classNames}\n inlineLayout={inlineLayout}\n bordered={bordered}\n disabled={disabled}\n fieldLegend={fieldLegend}\n groupName={groupName}\n />\n );\n};\n\nexport const RadioWithCustomWrapperStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 RadioWithCustomOptionStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 RadioWithCustomLabelStyles = ({\n onChange,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 RadioWithInlineLayout = ({ onChange }: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 RadioWithCustomLabel = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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\nexport const RadioWithCustomLabelInline = ({\n onChange,\n wide,\n classNames,\n inlineLayout,\n}: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\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 inlineIcon\n value={checkedValues}\n classNames={{ option: 'w30' }}\n inlineLayout\n />\n );\n};\n\nRadioStory.storyName = 'Radio';\n\nexport const RadioIconOnly = ({ onChange }: RadioProps<string>) => {\n const [checkedValues, setCheckedValues] = useState<string>();\n\n const handleOnChange = (newValue: string) => {\n setCheckedValues(newValue);\n onChange(newValue);\n };\n\n return (\n <Radio\n options={{ NOTHING: '' }}\n onChange={handleOnChange}\n classNames={{ label: 'jc-start' }}\n value={checkedValues}\n bordered={false}\n />\n );\n};\n\nRadioStory.storyName = 'Radio';\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;IAIM,KAAK,GAAG;IACZ,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,WAAW,EACT,uEAAuE;SAC1E;QACD,KAAK,EAAE;YACL,WAAW,EAAE,yBAAyB;SACvC;QACD,WAAW,EAAE;YACX,WAAW,E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 import '../../../_commonjsHelpers-4730bd53.js';
8
8
  import 'react-dom/test-utils';
9
9
  import '../../../index-6ea95111.js';
10
10
  import '../../../style-inject.es-1f59c1d0.js';
11
+ import '../../../index-69a46657.js';
11
12
 
12
13
  var mockOnChange = jest.fn();
13
14
  var setup = function (onChange, value) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.test.js","sources":["../../../../../../src/lib/components/input/radio/index.test.tsx"],"sourcesContent":["import { render } from '../../../util/testUtils';\n\nimport { Radio, RadioProps } from '.';\n\nconst mockOnChange = jest.fn();\n\nconst setup = (onChange: RadioProps<string>['onChange'], value?: string) => {\n const utils = render(\n <Radio\n options={{\n CAT: 'Cat',\n DOG: 'Dog',\n NONE: 'None',\n }}\n onChange={onChange}\n value={value}\n />\n );\n\n return utils;\n};\n\ndescribe('Radio component', () => {\n it('Should render options', () => {\n const { getByText } = setup(mockOnChange);\n\n expect(getByText('Cat')).toBeInTheDocument();\n expect(getByText('Dog')).toBeInTheDocument();\n expect(getByText('None')).toBeInTheDocument();\n });\n\n it('Should call onchange on selecting an option', async () => {\n const { getByTestId, user } = setup(mockOnChange);\n\n await user.click(getByTestId('radio-DOG'));\n\n expect(mockOnChange).toBeCalledWith('DOG');\n });\n\n it('Should render checked items when value is passed', async () => {\n const { getByTestId } = setup(mockOnChange, 'CAT');\n\n expect(getByTestId('radio-input-CAT')).toBeChecked();\n });\n\n it('Should render custom description', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('Cat description')).toBeInTheDocument();\n });\n\n it('Should render custom icon', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n icon: () => 'ICON',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('ICON')).toBeInTheDocument();\n });\n\n it('Should render custom icon with selected', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n icon: (selected) => (selected ? 'SELECTED-ICON' : 'ICON'),\n },\n }}\n onChange={mockOnChange}\n value={'CAT'}\n />\n );\n\n expect(getByText('SELECTED-ICON')).toBeInTheDocument();\n });\n\n it('Should render label text passed in HTML format', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: <p>Cat</p>,\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('Cat')).toBeInTheDocument();\n });\n\n it('Should disable the input', async () => {\n const { getByTestId } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n disabled\n />\n );\n\n const radioInput = getByTestId('radio-input-CAT');\n\n expect(radioInput).toBeDisabled();\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;AAIA,IAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE/B,IAAM,KAAK,GAAG,UAAC,QAAwC,EAAE,KAAc;IACrE,IAAM,KAAK,GAAGA,YAAM,CAClBC,IAAC,KAAK,IACJ,OAAO,EAAE;YACP,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,QAAQ,CAAC,iBAAiB,EAAE;IAC1B,EAAE,CAAC,uBAAuB,EAAE;QAClB,IAAA,SAAS,GAAK,KAAK,CAAC,YAAY,CAAC,UAAxB,CAAyB;QAE1C,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC7C,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC7C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KAC/C,CAAC,CAAC;IAE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GAAKD,YAAM,CAC1BC,IAAC,KAAK,IACJ,OAAO,EAAE;gBACP,GAAG,EAAE;oBACH,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,UAAC,QAAQ,IAAK,QAAC,QAAQ,GAAG,eAAe,GAAG,MAAM,IAAC;iBAC1D;aACF,EACD,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,KAAK,GACZ,CACH,UAXgB,CAWf;QAEF,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KACxD,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE;QAC3C,IAAA,SAAS,GAAKD,YAAM,CAC1BC,IAAC,KAAK,IACJ,OAAO,EAAE;gBACP,GAAG,EAAE;oBACH,KAAK,EAAEA,6BAAU;oBACjB,WAAW,EAAE,iBAAiB;iBAC/B;aACF,EACD,QAAQ,EAAE,YAAY,GACtB,CACH,UAVgB,CAUf;QAEF,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KAC9C,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE;;;YACrB,WAAW,GAAKD,YAAM,CAC5BC,IAAC,KAAK,IACJ,OAAO,EAAE;oBACP,GAAG,EAAE;wBACH,KAAK,EAAE,KAAK;wBACZ,WAAW,EAAE,iBAAiB;qBAC/B;iBACF,EACD,QAAQ,EAAE,YAAY,EACtB,QAAQ,SACR,CACH,YAXkB,CAWjB;YAEI,UAAU,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;YAElD,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,EAAE,CAAC;;;SACnC,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"index.test.js","sources":["../../../../../../src/lib/components/input/radio/index.test.tsx"],"sourcesContent":["import { render } from '../../../util/testUtils';\n\nimport { Radio, RadioProps } from '.';\n\nconst mockOnChange = jest.fn();\n\nconst setup = (onChange: RadioProps<string>['onChange'], value?: string) => {\n const utils = render(\n <Radio\n options={{\n CAT: 'Cat',\n DOG: 'Dog',\n NONE: 'None',\n }}\n onChange={onChange}\n value={value}\n />\n );\n\n return utils;\n};\n\ndescribe('Radio component', () => {\n it('Should render options', () => {\n const { getByText } = setup(mockOnChange);\n\n expect(getByText('Cat')).toBeInTheDocument();\n expect(getByText('Dog')).toBeInTheDocument();\n expect(getByText('None')).toBeInTheDocument();\n });\n\n it('Should call onchange on selecting an option', async () => {\n const { getByTestId, user } = setup(mockOnChange);\n\n await user.click(getByTestId('radio-DOG'));\n\n expect(mockOnChange).toBeCalledWith('DOG');\n });\n\n it('Should render checked items when value is passed', async () => {\n const { getByTestId } = setup(mockOnChange, 'CAT');\n\n expect(getByTestId('radio-input-CAT')).toBeChecked();\n });\n\n it('Should render custom description', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('Cat description')).toBeInTheDocument();\n });\n\n it('Should render custom icon', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n icon: () => 'ICON',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('ICON')).toBeInTheDocument();\n });\n\n it('Should render custom icon with selected', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n icon: (selected) => (selected ? 'SELECTED-ICON' : 'ICON'),\n },\n }}\n onChange={mockOnChange}\n value={'CAT'}\n />\n );\n\n expect(getByText('SELECTED-ICON')).toBeInTheDocument();\n });\n\n it('Should render label text passed in HTML format', () => {\n const { getByText } = render(\n <Radio\n options={{\n CAT: {\n title: <p>Cat</p>,\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n />\n );\n\n expect(getByText('Cat')).toBeInTheDocument();\n });\n\n it('Should disable the input', async () => {\n const { getByTestId } = render(\n <Radio\n options={{\n CAT: {\n title: 'Cat',\n description: 'Cat description',\n },\n }}\n onChange={mockOnChange}\n disabled\n />\n );\n\n const radioInput = getByTestId('radio-input-CAT');\n\n expect(radioInput).toBeDisabled();\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;AAIA,IAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE/B,IAAM,KAAK,GAAG,UAAC,QAAwC,EAAE,KAAc;IACrE,IAAM,KAAK,GAAGA,YAAM,CAClBC,IAAC,KAAK,IACJ,OAAO,EAAE;YACP,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,MAAM;SACb,EACD,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,QAAQ,CAAC,iBAAiB,EAAE;IAC1B,EAAE,CAAC,uBAAuB,EAAE;QAClB,IAAA,SAAS,GAAK,KAAK,CAAC,YAAY,CAAC,UAAxB,CAAyB;QAE1C,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC7C,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC7C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KAC/C,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE;;;;;oBAC1C,KAAwB,KAAK,CAAC,YAAY,CAAC,EAAzC,WAAW,iBAAA,EAAE,IAAI,UAAA,CAAyB;oBAElD,qBAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAA;;oBAA1C,SAA0C,CAAC;oBAE3C,MAAM,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;;;;SAC5C,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE;;;YAC7C,WAAW,GAA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EAAE,CAAC,gDAAgD,EAAE;QAC3C,IAAA,SAAS,GAAKD,YAAM,CAC1BC,IAAC,KAAK,IACJ,OAAO,EAAE;gBACP,GAAG,EAAE;oBACH,KAAK,EAAEA,6BAAU;oBACjB,WAAW,EAAE,iBAAiB;iBAC/B;aACF,EACD,QAAQ,EAAE,YAAY,GACtB,CACH,UAVgB,CAUf;QAEF,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;KAC9C,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE;;;YACrB,WAAW,GAAKD,YAAM,CAC5BC,IAAC,KAAK,IACJ,OAAO,EAAE;oBACP,GAAG,EAAE;wBACH,KAAK,EAAE,KAAK;wBACZ,WAAW,EAAE,iBAAiB;qBAC/B;iBACF,EACD,QAAQ,EAAE,YAAY,EACtB,QAAQ,SACR,CACH,YAXkB,CAWjB;YAEI,UAAU,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;YAElD,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,EAAE,CAAC;;;SACnC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popsure/dirty-swan",
3
- "version": "0.57.8",
3
+ "version": "0.57.9",
4
4
  "author": "Vincent Audoire <vincent@getpopsure.com>",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -27,6 +27,7 @@ export default ({
27
27
  className={`c-pointer ${styles['chip-button-container']}`}
28
28
  type="button"
29
29
  onClick={() => onRemove(value)}
30
+ aria-label={`Remove ${value.value} option`}
30
31
  >
31
32
  <XIcon className={styles['chip-remove-button']} />
32
33
  </button>
@@ -48,6 +48,11 @@
48
48
  &:hover {
49
49
  color: $ds-purple-500;
50
50
  }
51
+
52
+ &:focus-visible {
53
+ outline: 2px solid var(--ds-primary-500);
54
+ border-radius: 2px;
55
+ }
51
56
  }
52
57
 
53
58
  .chip-remove-button {
@@ -1,4 +1,3 @@
1
-
2
1
  import { useState } from 'react';
3
2
  import { Checkbox, CheckboxProps } from '.';
4
3
  import { images } from '../../../util/images';
@@ -9,28 +8,36 @@ const story = {
9
8
  component: Checkbox,
10
9
  argTypes: {
11
10
  options: {
12
- description: 'Object that contains the possible options for rendering in the input.',
11
+ description:
12
+ 'Object that contains the possible options for rendering in the input.',
13
13
  },
14
14
  value: {
15
15
  description: 'Current checked values.',
16
16
  },
17
+ fieldLegend: {
18
+ description:
19
+ 'Accessibility property that describes the purpose of a group of checkbox buttons, read aloud by screen readers to provide context.',
20
+ },
17
21
  onChange: {
18
22
  description: 'Function called everytime a value changes.',
19
23
  action: true,
20
24
  table: {
21
- category: "Callbacks",
25
+ category: 'Callbacks',
22
26
  },
23
27
  },
24
28
  wide: {
25
- description: 'Property that defines if options should fill 100% of available horizontal space',
26
- defaultValue: false
29
+ description:
30
+ 'Property that defines if options should fill 100% of available horizontal space',
31
+ defaultValue: false,
27
32
  },
28
33
  bordered: {
29
34
  control: 'boolean',
30
- description: 'Property that defines if checkbox should show the border around each label',
35
+ description:
36
+ 'Property that defines if checkbox should show the border around each label',
31
37
  },
32
38
  inlineLayout: {
33
- description: 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',
39
+ description:
40
+ 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',
34
41
  },
35
42
  className: {
36
43
  description: 'ClassNames for custom styling',
@@ -38,133 +45,144 @@ const story = {
38
45
  },
39
46
  args: {
40
47
  options: {
41
- CAT:{
48
+ CAT: {
42
49
  title: 'Cat',
43
- description: 'At least 1'
50
+ description: 'At least 1',
44
51
  },
45
- DOG:{
52
+ DOG: {
46
53
  title: 'Dog',
47
- description: 'At least 2'
54
+ description: 'At least 2',
48
55
  },
49
- NONE:{
56
+ NONE: {
50
57
  title: 'None',
51
- description: 'No pets'
52
- }
58
+ description: 'No pets',
59
+ },
53
60
  },
61
+ fieldLegend: 'Owned pets',
54
62
  wide: false,
55
63
  bordered: true,
56
64
  inlineLayout: false,
57
65
  classNames: {
58
66
  container: '',
59
67
  label: '',
60
- option: ''
68
+ option: '',
61
69
  },
62
70
  value: [],
63
- className: ''
64
- }
71
+ className: '',
72
+ },
65
73
  };
66
74
 
67
- export const CheckboxStory = ({
75
+ export const CheckboxStory = ({
68
76
  onChange,
69
77
  options,
70
78
  wide,
71
79
  bordered,
72
80
  classNames,
73
81
  inlineLayout,
82
+ fieldLegend,
74
83
  }: CheckboxProps<string>) => {
75
84
  const [checkedValues, setCheckedValues] = useState<string[]>([]);
76
85
 
77
86
  const handleOnChange = (newValue: string[]) => {
78
87
  setCheckedValues(newValue);
79
88
  onChange(newValue);
80
- }
89
+ };
81
90
 
82
91
  return (
83
- <Checkbox
92
+ <Checkbox
84
93
  wide={wide}
85
- options={options}
94
+ options={options}
86
95
  onChange={handleOnChange}
87
96
  value={checkedValues}
88
97
  bordered={bordered}
89
98
  classNames={classNames}
90
99
  inlineLayout={inlineLayout}
100
+ fieldLegend={fieldLegend}
91
101
  />
92
102
  );
93
- }
103
+ };
94
104
 
95
- export const CheckboxWithCustomWrapperStyles = ({ onChange }: CheckboxProps<string>) => {
105
+ export const CheckboxWithCustomWrapperStyles = ({
106
+ onChange,
107
+ }: CheckboxProps<string>) => {
96
108
  const [checkedValues, setCheckedValues] = useState<string[]>([]);
97
109
 
98
110
  const handleOnChange = (newValue: string[] = []) => {
99
111
  setCheckedValues(newValue);
100
112
  onChange(newValue);
101
- }
113
+ };
102
114
 
103
115
  return (
104
- <Checkbox
116
+ <Checkbox
105
117
  onChange={handleOnChange}
106
118
  value={checkedValues}
107
119
  options={{
108
120
  CAT1: 'Cat',
109
121
  DOG1: 'Dog',
110
- }}
111
- classNames={{ container: "p32 bg-primary-300 br24 bs-lg" }}
122
+ }}
123
+ classNames={{ container: 'p32 bg-primary-300 br24 bs-lg' }}
112
124
  />
113
125
  );
114
- }
126
+ };
115
127
 
116
- export const CheckboxWithCustomOptionStyles = ({ onChange }: CheckboxProps<string>) => {
128
+ export const CheckboxWithCustomOptionStyles = ({
129
+ onChange,
130
+ }: CheckboxProps<string>) => {
117
131
  const [checkedValues, setCheckedValues] = useState<string[]>([]);
118
132
 
119
133
  const handleOnChange = (newValue: string[] = []) => {
120
134
  setCheckedValues(newValue);
121
135
  onChange(newValue);
122
- }
136
+ };
123
137
 
124
138
  return (
125
- <Checkbox
139
+ <Checkbox
126
140
  onChange={handleOnChange}
127
141
  value={checkedValues}
128
142
  options={{
129
143
  CAT2: 'Cat',
130
144
  DOG2: 'Dog',
131
- }}
132
- classNames={{ option: "mb32 p24 bg-green-100 br12 bs-lg" }}
145
+ }}
146
+ classNames={{ option: 'mb32 p24 bg-green-100 br12 bs-lg' }}
133
147
  />
134
148
  );
135
- }
149
+ };
136
150
 
137
- export const CheckboxWithCustomLabelStyles = ({ onChange }: CheckboxProps<string>) => {
151
+ export const CheckboxWithCustomLabelStyles = ({
152
+ onChange,
153
+ }: CheckboxProps<string>) => {
138
154
  const [checkedValues, setCheckedValues] = useState<string[]>([]);
139
155
 
140
156
  const handleOnChange = (newValue: string[] = []) => {
141
157
  setCheckedValues(newValue);
142
158
  onChange(newValue);
143
- }
159
+ };
144
160
 
145
161
  return (
146
- <Checkbox
162
+ <Checkbox
147
163
  onChange={handleOnChange}
148
164
  value={checkedValues}
149
165
  options={{
150
166
  CAT3: 'Cat',
151
167
  DOG3: 'Dog',
152
- }}
153
- classNames={{ label: "bg-grey-900 tc-white" }}
168
+ }}
169
+ classNames={{ label: 'bg-grey-900 tc-white' }}
154
170
  />
155
171
  );
156
- }
172
+ };
157
173
 
158
- export const CheckboxWithInlineLayout = ({ onChange }: CheckboxProps<string>) => {
174
+ export const CheckboxWithInlineLayout = ({
175
+ onChange,
176
+ }: CheckboxProps<string>) => {
159
177
  const [checkedValues, setCheckedValues] = useState<string[]>([]);
160
178
 
161
179
  const handleOnChange = (newValue: string[] = []) => {
162
180
  setCheckedValues(newValue);
163
181
  onChange(newValue);
164
- }
182
+ };
165
183
 
166
184
  return (
167
- <Checkbox
185
+ <Checkbox
168
186
  onChange={handleOnChange}
169
187
  value={checkedValues}
170
188
  options={{
@@ -174,45 +192,50 @@ export const CheckboxWithInlineLayout = ({ onChange }: CheckboxProps<string>) =>
174
192
  RABBIT: 'Rabbit',
175
193
  RAT: 'Rat',
176
194
  ANOTHER: 'Other',
177
- }}
178
- classNames={{ option: "w30" }}
195
+ }}
196
+ classNames={{ option: 'w30' }}
179
197
  inlineLayout
180
198
  wide
181
199
  />
182
200
  );
183
- }
201
+ };
184
202
 
185
- export const CheckboxWithCustomLabel = ({ onChange, wide, classNames, inlineLayout }: CheckboxProps<string>) => {
203
+ export const CheckboxWithCustomLabel = ({
204
+ onChange,
205
+ wide,
206
+ classNames,
207
+ inlineLayout,
208
+ }: CheckboxProps<string>) => {
186
209
  const [checkedValues, setCheckedValues] = useState<string[]>([]);
187
210
 
188
211
  const handleOnChange = (newValue: string[] = []) => {
189
212
  setCheckedValues(newValue);
190
213
  onChange(newValue);
191
- }
214
+ };
192
215
 
193
216
  return (
194
- <Checkbox
217
+ <Checkbox
195
218
  options={{
196
219
  BIGDOG: {
197
- icon: () => <img src={images.bigDog} alt='' />,
220
+ icon: () => <img src={images.bigDog} alt="" />,
198
221
  title: 'Dog',
199
222
  },
200
- FISH:{
201
- icon: () => <img src={images.brokenAquarium} alt='' />,
223
+ FISH: {
224
+ icon: () => <img src={images.brokenAquarium} alt="" />,
202
225
  title: 'Fish',
203
226
  },
204
- OTHER:{
205
- icon: () => <img src={images.brokenGlass} alt='' />,
227
+ OTHER: {
228
+ icon: () => <img src={images.brokenGlass} alt="" />,
206
229
  title: 'Other',
207
- }
208
- }}
230
+ },
231
+ }}
209
232
  onChange={handleOnChange}
210
233
  value={checkedValues}
211
- classNames={{ option: "w30" }}
234
+ classNames={{ option: 'w30' }}
212
235
  inlineLayout
213
236
  />
214
237
  );
215
- }
238
+ };
216
239
 
217
240
  CheckboxStory.storyName = 'Checkbox';
218
241
 
@@ -20,6 +20,7 @@ export interface CheckboxProps<ValueType extends string> {
20
20
  label?: string;
21
21
  option?: string;
22
22
  };
23
+ fieldLegend?: string;
23
24
  }
24
25
 
25
26
  export const Checkbox = <ValueType extends string>({
@@ -30,6 +31,7 @@ export const Checkbox = <ValueType extends string>({
30
31
  inlineLayout = false,
31
32
  bordered = true,
32
33
  classNames: classNamesObj,
34
+ fieldLegend = 'Select one or more options',
33
35
  }: CheckboxProps<ValueType> & {}) => {
34
36
  const hasNoneValue = Object.keys(options).includes('NONE');
35
37
 
@@ -72,7 +74,7 @@ export const Checkbox = <ValueType extends string>({
72
74
  };
73
75
 
74
76
  return (
75
- <div
77
+ <fieldset
76
78
  className={classNames(
77
79
  classNamesObj?.container,
78
80
  styles.container,
@@ -85,6 +87,7 @@ export const Checkbox = <ValueType extends string>({
85
87
  }
86
88
  )}
87
89
  >
90
+ <legend className="sr-only">{fieldLegend}</legend>
88
91
  {entries.map(([currentValue, label]) => {
89
92
  const checked = value?.includes(currentValue);
90
93
  const customIcon = (label as CheckboxWithDescription)?.icon;
@@ -129,6 +132,6 @@ export const Checkbox = <ValueType extends string>({
129
132
  </div>
130
133
  );
131
134
  })}
132
- </div>
135
+ </fieldset>
133
136
  );
134
137
  };
@@ -1,5 +1,9 @@
1
1
  .container {
2
2
  max-width: 100%;
3
+ border: 0;
4
+ margin: 0;
5
+ min-width: 0;
6
+ padding: 0.01em 0 0 0;
3
7
  }
4
8
 
5
9
  .narrow {
@@ -13,6 +13,14 @@ const story = {
13
13
  value: {
14
14
  description: 'Current checked values.',
15
15
  },
16
+ fieldLegend: {
17
+ description:
18
+ 'Property that describes the purpose of a group of radio buttons, read aloud by screen readers to provide context.',
19
+ },
20
+ groupName: {
21
+ description:
22
+ 'Property passed to each radio button. Informs the browser that the radio buttons belong to the same group, so only one can be selected',
23
+ },
16
24
  onChange: {
17
25
  description: 'Function called everytime a value changes.',
18
26
  action: true,
@@ -29,7 +37,8 @@ const story = {
29
37
  'Property that defines if options should show inline instead of block. Check inline radio options story for examples.',
30
38
  },
31
39
  inlineIcon: {
32
- description: 'Property that defines if options should show inline with icon',
40
+ description:
41
+ 'Property that defines if options should show inline with icon',
33
42
  },
34
43
  classNames: {
35
44
  description: 'ClassNames for custom styling',
@@ -57,6 +66,8 @@ const story = {
57
66
  description: 'No pets',
58
67
  },
59
68
  },
69
+ fieldLegend: 'Owned pets',
70
+ groupName: 'Pets',
60
71
  value: '',
61
72
  wide: false,
62
73
  classNames: {
@@ -68,7 +79,7 @@ const story = {
68
79
  inlineLayout: false,
69
80
  inlineIcon: false,
70
81
  disabled: false,
71
- }
82
+ },
72
83
  };
73
84
 
74
85
  export const RadioStory = ({
@@ -79,6 +90,8 @@ export const RadioStory = ({
79
90
  inlineLayout,
80
91
  bordered,
81
92
  disabled,
93
+ fieldLegend,
94
+ groupName,
82
95
  }: RadioProps<string>) => {
83
96
  const [checkedValues, setCheckedValues] = useState<string>();
84
97
 
@@ -97,6 +110,8 @@ export const RadioStory = ({
97
110
  inlineLayout={inlineLayout}
98
111
  bordered={bordered}
99
112
  disabled={disabled}
113
+ fieldLegend={fieldLegend}
114
+ groupName={groupName}
100
115
  />
101
116
  );
102
117
  };