@moda/om 16.1.1 → 16.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.cjs.js +344 -297
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +343 -296
- package/dist/index.esm.js.map +1 -1
- package/dist/{__mocks__ → src/__mocks__}/Icon.d.ts +0 -0
- package/dist/{components → src/components}/AspectRatioBox/AspectRatioBox.d.ts +0 -0
- package/dist/{components → src/components}/AspectRatioBox/AspectRatioBox.stories.d.ts +0 -0
- package/dist/{components → src/components}/AspectRatioBox/AspectRatioBox.test.d.ts +0 -0
- package/dist/{components → src/components}/AspectRatioBox/index.d.ts +0 -0
- package/dist/{components → src/components}/Badge/Badge.d.ts +0 -0
- package/dist/{components → src/components}/Badge/Badge.stories.d.ts +0 -0
- package/dist/{components → src/components}/Badge/Badge.test.d.ts +0 -0
- package/dist/{components → src/components}/Badge/index.d.ts +0 -0
- package/dist/{components → src/components}/Breadcrumbs/Breadcrumb/Breadcrumb.d.ts +0 -0
- package/dist/{components → src/components}/Breadcrumbs/Breadcrumb/index.d.ts +0 -0
- package/dist/{components → src/components}/Breadcrumbs/Breadcrumbs.d.ts +0 -0
- package/dist/{components → src/components}/Breadcrumbs/Breadcrumbs.stories.d.ts +0 -0
- package/dist/{components → src/components}/Breadcrumbs/Breadcrumbs.test.d.ts +0 -0
- package/dist/{components → src/components}/Breadcrumbs/index.d.ts +0 -0
- package/dist/{components → src/components}/Breakpoint/Breakpoint.d.ts +0 -0
- package/dist/{components → src/components}/Breakpoint/Breakpoint.stories.d.ts +0 -0
- package/dist/{components → src/components}/Breakpoint/Breakpoint.test.d.ts +0 -0
- package/dist/{components → src/components}/Breakpoint/BreakpointProvider.d.ts +0 -0
- package/dist/{components → src/components}/Breakpoint/generateMediaQuery.d.ts +0 -0
- package/dist/{components → src/components}/Breakpoint/generateMediaQuery.test.d.ts +0 -0
- package/dist/{components → src/components}/Breakpoint/index.d.ts +0 -0
- package/dist/{components → src/components}/Button/Button.d.ts +0 -0
- package/dist/{components → src/components}/Button/Button.stories.d.ts +0 -0
- package/dist/{components → src/components}/Button/Button.test.d.ts +0 -0
- package/dist/{components → src/components}/Button/index.d.ts +0 -0
- package/dist/{components → src/components}/Checkbox/Checkbox.d.ts +0 -0
- package/dist/{components → src/components}/Checkbox/Checkbox.stories.d.ts +0 -0
- package/dist/{components → src/components}/Checkbox/Checkbox.test.d.ts +0 -0
- package/dist/{components → src/components}/Checkbox/index.d.ts +0 -0
- package/dist/{components → src/components}/Clickable/Clickable.d.ts +0 -0
- package/dist/{components → src/components}/Clickable/Clickable.stories.d.ts +0 -0
- package/dist/{components → src/components}/Clickable/Clickable.test.d.ts +0 -0
- package/dist/{components → src/components}/Clickable/index.d.ts +0 -0
- package/dist/{components → src/components}/ColorSwatch/ColorSwatch.d.ts +0 -0
- package/dist/{components → src/components}/ColorSwatch/ColorSwatch.stories.d.ts +0 -0
- package/dist/{components → src/components}/ColorSwatch/ColorSwatch.test.d.ts +0 -0
- package/dist/{components → src/components}/ColorSwatch/index.d.ts +0 -0
- package/dist/{components → src/components}/ColorSwatch/skuColors.d.ts +0 -0
- package/dist/{components → src/components}/Constrain/Constrain.d.ts +0 -0
- package/dist/{components → src/components}/Constrain/Constrain.stories.d.ts +0 -0
- package/dist/{components → src/components}/Constrain/Constrain.test.d.ts +0 -0
- package/dist/{components → src/components}/Constrain/ExceedConstrain.d.ts +0 -0
- package/dist/{components → src/components}/Constrain/ExceedConstrain.stories.d.ts +0 -0
- package/dist/{components → src/components}/Constrain/index.d.ts +0 -0
- package/dist/{components → src/components}/ControlLink/ControlLink.d.ts +0 -0
- package/dist/{components → src/components}/ControlLink/ControlLink.stories.d.ts +0 -0
- package/dist/{components → src/components}/ControlLink/ControlLink.test.d.ts +0 -0
- package/dist/{components → src/components}/ControlLink/index.d.ts +0 -0
- package/dist/{components → src/components}/CreditCardNumberInput/CreditCardNumberInput.d.ts +0 -0
- package/dist/{components → src/components}/CreditCardNumberInput/CreditCardNumberInput.stories.d.ts +0 -0
- package/dist/{components → src/components}/CreditCardNumberInput/CreditCardNumberInput.test.d.ts +0 -0
- package/dist/{components → src/components}/CreditCardNumberInput/CreditCardNumberInputField.d.ts +0 -0
- package/dist/{components → src/components}/CreditCardNumberInput/index.d.ts +0 -0
- package/dist/{components → src/components}/DefinitionList/DefinitionList.d.ts +0 -0
- package/dist/{components → src/components}/DefinitionList/DefinitionList.stories.d.ts +0 -0
- package/dist/{components → src/components}/DefinitionList/DefinitionList.test.d.ts +0 -0
- package/dist/{components → src/components}/DefinitionList/index.d.ts +0 -0
- package/dist/{components → src/components}/Divider/Divider.d.ts +0 -0
- package/dist/{components → src/components}/Divider/Divider.stories.d.ts +0 -0
- package/dist/{components → src/components}/Divider/Divider.test.d.ts +0 -0
- package/dist/{components → src/components}/Divider/NoLineDivider.d.ts +0 -0
- package/dist/{components → src/components}/Divider/TwoLineDivider.d.ts +0 -0
- package/dist/{components → src/components}/Divider/index.d.ts +0 -0
- package/dist/{components → src/components}/Expandable/Expandable.d.ts +0 -0
- package/dist/{components → src/components}/Expandable/Expandable.stories.d.ts +0 -0
- package/dist/{components → src/components}/Expandable/Expandable.test.d.ts +0 -0
- package/dist/{components → src/components}/Expandable/index.d.ts +0 -0
- package/dist/{components → src/components}/Field/Field.d.ts +0 -0
- package/dist/{components → src/components}/Field/Field.stories.d.ts +0 -0
- package/dist/{components → src/components}/Field/Field.test.d.ts +0 -0
- package/dist/{components → src/components}/Field/index.d.ts +0 -0
- package/dist/{components → src/components}/Label/Label.d.ts +0 -0
- package/dist/{components → src/components}/Label/Label.stories.d.ts +0 -0
- package/dist/{components → src/components}/Label/Label.test.d.ts +0 -0
- package/dist/{components → src/components}/Label/index.d.ts +0 -0
- package/dist/{components → src/components}/Loading/Loading.d.ts +0 -0
- package/dist/{components → src/components}/Loading/Loading.stories.d.ts +0 -0
- package/dist/{components → src/components}/Loading/Loading.test.d.ts +0 -0
- package/dist/{components → src/components}/Loading/index.d.ts +0 -0
- package/dist/{components → src/components}/LoadingBalls/LoadingBalls.d.ts +0 -0
- package/dist/{components → src/components}/LoadingBalls/LoadingBalls.stories.d.ts +0 -0
- package/dist/{components → src/components}/LoadingBalls/index.d.ts +0 -0
- package/dist/{components → src/components}/Modal/Modal.d.ts +0 -0
- package/dist/{components → src/components}/Modal/Modal.stories.d.ts +0 -0
- package/dist/{components → src/components}/Modal/Modal.test.d.ts +0 -0
- package/dist/{components → src/components}/Modal/index.d.ts +0 -0
- package/dist/{components → src/components}/ModalOverlay/ModalOverlay.d.ts +0 -0
- package/dist/{components → src/components}/ModalOverlay/ModalOverlay.stories.d.ts +0 -0
- package/dist/{components → src/components}/ModalOverlay/ModalOverlay.test.d.ts +0 -0
- package/dist/{components → src/components}/ModalOverlay/index.d.ts +0 -0
- package/dist/{components → src/components}/Overlay/Overlay.d.ts +0 -0
- package/dist/{components → src/components}/Overlay/Overlay.stories.d.ts +0 -0
- package/dist/{components → src/components}/Overlay/Overlay.test.d.ts +0 -0
- package/dist/{components → src/components}/Overlay/index.d.ts +0 -0
- package/dist/{components → src/components}/Paginator/Paginator.d.ts +0 -0
- package/dist/{components → src/components}/Paginator/Paginator.stories.d.ts +0 -0
- package/dist/{components → src/components}/Paginator/index.d.ts +0 -0
- package/dist/{components → src/components}/PasswordInput/PasswordInput.d.ts +0 -0
- package/dist/{components → src/components}/PasswordInput/PasswordInput.stories.d.ts +0 -0
- package/dist/{components → src/components}/PasswordInput/index.d.ts +0 -0
- package/dist/{components → src/components}/Popover/Popover.d.ts +0 -0
- package/dist/{components → src/components}/Popover/Popover.stories.d.ts +0 -0
- package/dist/{components → src/components}/Popover/Popover.test.d.ts +0 -0
- package/dist/{components → src/components}/Popover/index.d.ts +0 -0
- package/dist/{components → src/components}/PromoBanner/PromoBanner.d.ts +0 -0
- package/dist/{components → src/components}/PromoBanner/PromoBanner.stories.d.ts +0 -0
- package/dist/{components → src/components}/PromoBanner/PromoBanner.test.d.ts +0 -0
- package/dist/{components → src/components}/PromoBanner/index.d.ts +0 -0
- package/dist/{components → src/components}/RadioButton/RadioButton.d.ts +0 -0
- package/dist/{components → src/components}/RadioButton/RadioButton.stories.d.ts +0 -0
- package/dist/{components → src/components}/RadioButton/RadioButton.test.d.ts +0 -0
- package/dist/{components → src/components}/RadioButton/index.d.ts +0 -0
- package/dist/{components → src/components}/SearchInput/SearchInput.d.ts +0 -0
- package/dist/{components → src/components}/SearchInput/SearchInput.stories.d.ts +0 -0
- package/dist/{components → src/components}/SearchInput/SearchInput.test.d.ts +0 -0
- package/dist/{components → src/components}/SearchInput/index.d.ts +0 -0
- package/dist/{components → src/components}/Select/MultiSelect.d.ts +0 -0
- package/dist/{components → src/components}/Select/Select.d.ts +1 -0
- package/dist/{components → src/components}/Select/Select.stories.d.ts +0 -0
- package/dist/{components → src/components}/Select/Select.test.d.ts +0 -0
- package/dist/{components → src/components}/Select/SelectLabel.d.ts +0 -0
- package/dist/{components → src/components}/Select/SelectOption.d.ts +1 -0
- package/dist/{components → src/components}/Select/SelectOptions.d.ts +1 -0
- package/dist/{components → src/components}/Select/index.d.ts +0 -0
- package/dist/{components → src/components}/Select/useSelect.d.ts +0 -0
- package/dist/{components → src/components}/SelectableButton/SelectableButton.d.ts +0 -0
- package/dist/{components → src/components}/SelectableButton/SelectableButton.stories.d.ts +0 -0
- package/dist/{components → src/components}/SelectableButton/SelectableButton.test.d.ts +0 -0
- package/dist/{components → src/components}/SelectableButton/index.d.ts +0 -0
- package/dist/{components → src/components}/Shape/ArcWindow.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Bradley.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Brancusi.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Circle.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Diamond.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Keyhole.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Mirror.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Oval.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Shape.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Shape.stories.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Triangle.d.ts +0 -0
- package/dist/{components → src/components}/Shape/Window.d.ts +0 -0
- package/dist/{components → src/components}/Shape/index.d.ts +0 -0
- package/dist/{components → src/components}/Stack/Stack.d.ts +0 -0
- package/dist/{components → src/components}/Stack/Stack.stories.d.ts +0 -0
- package/dist/{components → src/components}/Stack/Stack.test.d.ts +0 -0
- package/dist/{components → src/components}/Stack/index.d.ts +0 -0
- package/dist/{components → src/components}/Tabs/Tab.d.ts +0 -0
- package/dist/{components → src/components}/Tabs/TabList.d.ts +0 -0
- package/dist/{components → src/components}/Tabs/TabPanel.d.ts +0 -0
- package/dist/{components → src/components}/Tabs/TabPanels.d.ts +0 -0
- package/dist/{components → src/components}/Tabs/Tabs.d.ts +0 -0
- package/dist/{components → src/components}/Tabs/Tabs.stories.d.ts +0 -0
- package/dist/{components → src/components}/Tabs/Tabs.test.d.ts +0 -0
- package/dist/{components → src/components}/Tabs/index.d.ts +0 -0
- package/dist/{components → src/components}/Tag/Tag.d.ts +0 -0
- package/dist/{components → src/components}/Tag/Tag.stories.d.ts +0 -0
- package/dist/{components → src/components}/Tag/Tag.test.d.ts +0 -0
- package/dist/{components → src/components}/Tag/index.d.ts +0 -0
- package/dist/{components → src/components}/Text/Text.d.ts +0 -0
- package/dist/{components → src/components}/Text/Text.stories.d.ts +0 -0
- package/dist/{components → src/components}/Text/Text.test.d.ts +0 -0
- package/dist/{components → src/components}/Text/index.d.ts +0 -0
- package/dist/{components → src/components}/TextInput/TextInput.d.ts +0 -0
- package/dist/{components → src/components}/TextInput/TextInput.stories.d.ts +0 -0
- package/dist/{components → src/components}/TextInput/TextInput.test.d.ts +0 -0
- package/dist/{components → src/components}/TextInput/index.d.ts +0 -0
- package/dist/{components → src/components}/Textarea/Textarea.d.ts +0 -0
- package/dist/{components → src/components}/Textarea/Textarea.stories.d.ts +0 -0
- package/dist/{components → src/components}/Textarea/Textarea.test.d.ts +0 -0
- package/dist/{components → src/components}/Textarea/index.d.ts +0 -0
- package/dist/{components → src/components}/Toast/Toast.d.ts +0 -0
- package/dist/{components → src/components}/Toast/Toast.stories.d.ts +0 -0
- package/dist/{components → src/components}/Toast/Toast.test.d.ts +0 -0
- package/dist/{components → src/components}/Toast/index.d.ts +0 -0
- package/dist/{components → src/components}/VerticalDivider/VerticalDivider.d.ts +0 -0
- package/dist/{components → src/components}/VerticalDivider/VerticalDivider.stories.d.ts +0 -0
- package/dist/{components → src/components}/VerticalDivider/VerticalDivider.test.d.ts +0 -0
- package/dist/{components → src/components}/VerticalDivider/index.d.ts +0 -0
- package/dist/{components → src/components}/index.d.ts +0 -0
- package/dist/{hooks → src/hooks}/index.d.ts +0 -0
- package/dist/{hooks → src/hooks}/useBreakpoint.d.ts +0 -0
- package/dist/{hooks → src/hooks}/useClickOutside.d.ts +0 -0
- package/dist/{hooks → src/hooks}/useKeyboardListNavigation.d.ts +0 -0
- package/dist/{hooks → src/hooks}/useKeyboardListNavigation.spec.d.ts +0 -0
- package/dist/{hooks → src/hooks}/useUpdateEffect.d.ts +0 -0
- package/dist/{index.d.ts → src/index.d.ts} +0 -0
- package/dist/{mixins → src/mixins}/font-smoothing/font-smoothing.stories.d.ts +0 -0
- package/dist/{mixins → src/mixins}/overflow-scroll/overflow-scroll.stories.d.ts +0 -0
- package/dist/{mixins → src/mixins}/stack/stack.stories.d.ts +0 -0
- package/dist/{mixins → src/mixins}/thin-underline/thin-underline.stories.d.ts +0 -0
- package/dist/{mixins → src/mixins}/visually-hidden/visually-hidden.stories.d.ts +0 -0
- package/dist/{utilities → src/utilities}/States/State.d.ts +0 -0
- package/dist/{utilities → src/utilities}/States/States.d.ts +0 -0
- package/dist/{utilities → src/utilities}/States/StatesProps.d.ts +0 -0
- package/dist/{utilities → src/utilities}/States/index.d.ts +0 -0
- package/dist/{utilities → src/utilities}/States/isRenderProps.d.ts +0 -0
- package/dist/{utilities → src/utilities}/States/stringifyProps.d.ts +0 -0
- package/dist/{utilities → src/utilities}/index.d.ts +0 -0
- package/dist/{utilities → src/utilities}/omit.d.ts +0 -0
- package/dist/{utilities → src/utilities}/sample.d.ts +0 -0
- package/dist/styles.css +1 -1
- package/dist/test/mocks/matchMedia.d.ts +1 -0
- package/dist/test/setupTests.d.ts +3 -0
- package/package.json +30 -19
- package/src/components/AspectRatioBox/AspectRatioBox.test.tsx +3 -3
- package/src/components/AspectRatioBox/AspectRatioBox.tsx +4 -4
- package/src/components/AspectRatioBox/index.ts +1 -1
- package/src/components/Badge/Badge.stories.tsx +5 -5
- package/src/components/Badge/Badge.test.tsx +5 -12
- package/src/components/Breadcrumbs/Breadcrumb/Breadcrumb.tsx +6 -6
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +6 -6
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +7 -7
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/src/components/Breakpoint/Breakpoint.stories.tsx +10 -9
- package/src/components/Breakpoint/Breakpoint.test.tsx +7 -8
- package/src/components/Breakpoint/generateMediaQuery.ts +5 -4
- package/src/components/Button/Button.stories.tsx +4 -4
- package/src/components/Button/Button.test.tsx +14 -3
- package/src/components/Checkbox/Checkbox.stories.tsx +5 -5
- package/src/components/Checkbox/Checkbox.test.tsx +12 -14
- package/src/components/Checkbox/Checkbox.tsx +4 -4
- package/src/components/Clickable/Clickable.stories.tsx +3 -3
- package/src/components/Clickable/Clickable.test.tsx +3 -3
- package/src/components/ColorSwatch/ColorSwatch.stories.tsx +11 -11
- package/src/components/ColorSwatch/ColorSwatch.test.tsx +3 -5
- package/src/components/ColorSwatch/ColorSwatch.tsx +1 -1
- package/src/components/Constrain/Constrain.stories.tsx +1 -1
- package/src/components/Constrain/Constrain.test.tsx +4 -4
- package/src/components/Constrain/ExceedConstrain.stories.tsx +2 -2
- package/src/components/ControlLink/ControlLink.stories.tsx +1 -1
- package/src/components/ControlLink/ControlLink.test.tsx +10 -12
- package/src/components/ControlLink/index.ts +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.tsx +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.test.tsx +16 -16
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.tsx +1 -0
- package/src/components/DefinitionList/DefinitionList.stories.tsx +3 -3
- package/src/components/DefinitionList/DefinitionList.test.tsx +4 -3
- package/src/components/Divider/Divider.stories.tsx +4 -4
- package/src/components/Divider/Divider.test.tsx +5 -4
- package/src/components/Divider/Divider.tsx +1 -1
- package/src/components/Divider/NoLineDivider.tsx +1 -1
- package/src/components/Divider/TwoLineDivider.tsx +1 -1
- package/src/components/Expandable/Expandable.stories.tsx +8 -8
- package/src/components/Expandable/Expandable.test.tsx +17 -6
- package/src/components/Expandable/Expandable.tsx +3 -2
- package/src/components/Field/Field.stories.tsx +4 -4
- package/src/components/Field/Field.test.tsx +25 -34
- package/src/components/Field/Field.tsx +5 -5
- package/src/components/Field/index.ts +1 -0
- package/src/components/Label/Label.test.tsx +3 -3
- package/src/components/Loading/Loading.test.tsx +3 -5
- package/src/components/Loading/Loading.tsx +2 -1
- package/src/components/Modal/Modal.test.tsx +8 -9
- package/src/components/ModalOverlay/ModalOverlay.test.tsx +11 -11
- package/src/components/ModalOverlay/ModalOverlay.tsx +2 -2
- package/src/components/Overlay/Overlay.stories.tsx +1 -1
- package/src/components/Overlay/Overlay.test.tsx +3 -3
- package/src/components/Paginator/Paginator.tsx +3 -3
- package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
- package/src/components/PasswordInput/PasswordInput.tsx +6 -6
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/Popover/Popover.test.tsx +9 -6
- package/src/components/Popover/Popover.tsx +10 -7
- package/src/components/PromoBanner/PromoBanner.stories.tsx +9 -9
- package/src/components/PromoBanner/PromoBanner.test.tsx +3 -3
- package/src/components/PromoBanner/PromoBanner.tsx +1 -1
- package/src/components/RadioButton/RadioButton.stories.tsx +2 -2
- package/src/components/RadioButton/RadioButton.test.tsx +6 -10
- package/src/components/RadioButton/RadioButton.tsx +4 -4
- package/src/components/SearchInput/SearchInput.stories.tsx +2 -2
- package/src/components/SearchInput/SearchInput.test.tsx +10 -6
- package/src/components/SearchInput/SearchInput.tsx +3 -3
- package/src/components/Select/MultiSelect.tsx +7 -7
- package/src/components/Select/Select.stories.tsx +17 -15
- package/src/components/Select/Select.test.tsx +21 -21
- package/src/components/Select/Select.tsx +17 -8
- package/src/components/Select/SelectOption.tsx +5 -2
- package/src/components/Select/SelectOptions.tsx +8 -5
- package/src/components/SelectableButton/SelectableButton.stories.tsx +1 -1
- package/src/components/SelectableButton/SelectableButton.test.tsx +3 -3
- package/src/components/Shape/ArcWindow.tsx +10 -10
- package/src/components/Shape/Bradley.tsx +4 -4
- package/src/components/Shape/Brancusi.tsx +4 -4
- package/src/components/Shape/Circle.tsx +10 -10
- package/src/components/Shape/Diamond.tsx +10 -10
- package/src/components/Shape/Keyhole.tsx +4 -4
- package/src/components/Shape/Mirror.tsx +4 -4
- package/src/components/Shape/Oval.tsx +4 -4
- package/src/components/Shape/Triangle.tsx +7 -7
- package/src/components/Shape/Window.tsx +4 -4
- package/src/components/Stack/Stack.stories.tsx +3 -3
- package/src/components/Stack/Stack.test.tsx +7 -5
- package/src/components/Tabs/TabList.tsx +1 -1
- package/src/components/Tabs/TabPanel.tsx +1 -1
- package/src/components/Tabs/TabPanels.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +2 -2
- package/src/components/Tabs/Tabs.test.tsx +6 -7
- package/src/components/Tabs/Tabs.tsx +7 -1
- package/src/components/Tag/Tag.test.tsx +1 -1
- package/src/components/Tag/Tag.tsx +6 -5
- package/src/components/Text/Text.stories.tsx +5 -5
- package/src/components/Text/Text.test.tsx +4 -6
- package/src/components/TextInput/TextInput.stories.tsx +1 -1
- package/src/components/TextInput/TextInput.test.tsx +4 -5
- package/src/components/Textarea/Textarea.stories.tsx +1 -1
- package/src/components/Textarea/Textarea.test.tsx +11 -16
- package/src/components/Toast/Toast.stories.tsx +1 -1
- package/src/components/Toast/Toast.test.tsx +2 -2
- package/src/components/Toast/Toast.tsx +6 -6
- package/src/components/VerticalDivider/VerticalDivider.stories.tsx +3 -3
- package/src/components/VerticalDivider/VerticalDivider.test.tsx +6 -7
- package/src/hooks/useKeyboardListNavigation.spec.ts +26 -64
- package/src/hooks/useKeyboardListNavigation.ts +2 -0
- package/src/hooks/useUpdateEffect.ts +1 -0
- package/src/index.ts +2 -2
- package/src/mixins/font-smoothing/font-smoothing.stories.tsx +8 -8
- package/src/mixins/overflow-scroll/overflow-scroll.stories.tsx +2 -2
- package/src/mixins/stack/stack.stories.tsx +5 -6
- package/src/mixins/thin-underline/thin-underline.stories.tsx +1 -1
- package/src/mixins/visually-hidden/visually-hidden.stories.tsx +1 -1
- package/src/utilities/States/State.tsx +3 -2
- package/src/utilities/States/States.tsx +4 -3
- package/src/utilities/States/StatesProps.tsx +5 -2
- package/src/utilities/States/isRenderProps.ts +1 -0
- package/src/utilities/States/stringifyProps.tsx +1 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
|
|
4
4
|
import { PromoBanner } from './PromoBanner';
|
|
5
5
|
|
|
6
6
|
describe('PromoBanner', () => {
|
|
7
7
|
it('renders correctly', () => {
|
|
8
|
-
|
|
8
|
+
render(
|
|
9
9
|
<PromoBanner>
|
|
10
10
|
<span>Hello</span>
|
|
11
11
|
</PromoBanner>
|
|
12
12
|
);
|
|
13
|
-
expect(
|
|
13
|
+
expect(screen.getByText('Hello')).toBeVisible();
|
|
14
14
|
});
|
|
15
15
|
});
|
|
@@ -11,7 +11,7 @@ export const PromoBanner: React.FC<PromoBannerProps> = ({ className, children, .
|
|
|
11
11
|
const length = Children.count(children);
|
|
12
12
|
return (
|
|
13
13
|
<div className={classNames('PromoBanner', className)} {...rest}>
|
|
14
|
-
<Constrain className=
|
|
14
|
+
<Constrain className="PromoBanner__constrain">
|
|
15
15
|
{Children.map(children, (child: JSX.Element, index) => {
|
|
16
16
|
const isCenter = length % 2 !== 0 && Math.floor(length / 2) === index;
|
|
17
17
|
return cloneElement(child, {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { States } from 'storybook-states';
|
|
3
3
|
import { Text } from '../Text';
|
|
4
|
-
import { RadioButton, RadioButtonProps } from './RadioButton';
|
|
5
4
|
import { Stack } from '../Stack';
|
|
5
|
+
import { RadioButton, RadioButtonProps } from './RadioButton';
|
|
6
6
|
|
|
7
7
|
export default { title: 'Components/RadioButton' };
|
|
8
8
|
|
|
@@ -29,7 +29,7 @@ export const Select = () => {
|
|
|
29
29
|
return (
|
|
30
30
|
<States>
|
|
31
31
|
<Stack space={3}>
|
|
32
|
-
<Text color=
|
|
32
|
+
<Text color="burnt-orange">{selected}</Text>
|
|
33
33
|
|
|
34
34
|
{EXAMPLES.map(value => (
|
|
35
35
|
<RadioButton
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
4
3
|
import { RadioButton } from './RadioButton';
|
|
5
4
|
|
|
6
5
|
describe('RadioButton', () => {
|
|
7
6
|
it('renders correctly', () => {
|
|
8
|
-
|
|
9
|
-
expect(
|
|
10
|
-
'<label tabindex="0" class="RadioButton"><span tabindex="-1" class="RadioButton__indicator RadioButton__indicator--unchecked"></span><input tabindex="-1" class="RadioButton__input" type="radio" role="radio" value=""></label>'
|
|
11
|
-
);
|
|
7
|
+
render(<RadioButton />);
|
|
8
|
+
expect(screen.getByRole('radio')).toBeVisible();
|
|
12
9
|
});
|
|
13
10
|
|
|
14
11
|
it('supports checked', () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
expect(
|
|
18
|
-
expect(html).toContain('readonly="" value="" checked=""');
|
|
12
|
+
render(<RadioButton checked readOnly />);
|
|
13
|
+
expect(screen.getByRole('radio')).toBeVisible();
|
|
14
|
+
expect(screen.getByRole('radio')).toBeChecked();
|
|
19
15
|
});
|
|
20
16
|
});
|
|
@@ -36,16 +36,16 @@ export const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
36
36
|
<input
|
|
37
37
|
ref={inputRef}
|
|
38
38
|
tabIndex={-1}
|
|
39
|
-
className=
|
|
40
|
-
type=
|
|
41
|
-
role=
|
|
39
|
+
className="RadioButton__input"
|
|
40
|
+
type="radio"
|
|
41
|
+
role="radio"
|
|
42
42
|
checked={checked}
|
|
43
43
|
value={value}
|
|
44
44
|
disabled={disabled}
|
|
45
45
|
{...rest}
|
|
46
46
|
/>
|
|
47
47
|
{children && (
|
|
48
|
-
<span className=
|
|
48
|
+
<span className="RadioButton__label" tabIndex={-1}>
|
|
49
49
|
{children}
|
|
50
50
|
</span>
|
|
51
51
|
)}
|
|
@@ -9,7 +9,7 @@ export default { title: 'Components/SearchInput' };
|
|
|
9
9
|
export const Default = () => (
|
|
10
10
|
<States<SearchInputProps> states={[{}, { value: 'prada' }, { autoFocus: true }]}>
|
|
11
11
|
<SearchInput
|
|
12
|
-
placeholder=
|
|
12
|
+
placeholder="Search"
|
|
13
13
|
onChange={action('onChange')}
|
|
14
14
|
onChangeValue={action('onChangeValue')}
|
|
15
15
|
/>
|
|
@@ -34,7 +34,7 @@ export const DropdownExample = () => {
|
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
36
|
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
37
|
-
<SearchInput placeholder=
|
|
37
|
+
<SearchInput placeholder="Search" onChangeValue={setQuery} value={query} autoFocus />
|
|
38
38
|
|
|
39
39
|
{query && (
|
|
40
40
|
<Text style={{ border: '1px solid gray', marginTop: '-1px', padding: '1rem' }}>
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
3
4
|
|
|
4
5
|
import { SearchInput } from './SearchInput';
|
|
5
6
|
|
|
6
7
|
describe('SearchInput', () => {
|
|
7
|
-
it('clears the input when the button is clicked', () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
it('clears the input when the button is clicked', async () => {
|
|
9
|
+
render(<SearchInput value="Hello" />);
|
|
10
|
+
|
|
11
|
+
expect(screen.getByRole('textbox')).toHaveValue('Hello');
|
|
12
|
+
|
|
13
|
+
await userEvent.click(screen.getByRole('button'));
|
|
14
|
+
|
|
15
|
+
expect(screen.getByRole('textbox')).toHaveValue('');
|
|
12
16
|
});
|
|
13
17
|
});
|
|
@@ -50,12 +50,12 @@ export const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
52
|
<div className={classNames('SearchInput', className)}>
|
|
53
|
-
<div className=
|
|
53
|
+
<div className="SearchInput__icon">
|
|
54
54
|
<SearchIcon />
|
|
55
55
|
</div>
|
|
56
56
|
|
|
57
57
|
<TextInput
|
|
58
|
-
className=
|
|
58
|
+
className="SearchInput__input"
|
|
59
59
|
onChange={handleChange}
|
|
60
60
|
value={controlledValue}
|
|
61
61
|
ref={ref}
|
|
@@ -63,7 +63,7 @@ export const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
63
63
|
/>
|
|
64
64
|
|
|
65
65
|
{controlledValue && (
|
|
66
|
-
<Clickable className=
|
|
66
|
+
<Clickable className="SearchInput__clear" onClick={handleClick} type="reset">
|
|
67
67
|
<ExitIcon />
|
|
68
68
|
</Clickable>
|
|
69
69
|
)}
|
|
@@ -4,11 +4,11 @@ import { uniq } from 'ramda';
|
|
|
4
4
|
import ChevronDownIcon from '@moda/icons/chevron-down-12';
|
|
5
5
|
import ChevronUpIcon from '@moda/icons/chevron-up-12';
|
|
6
6
|
import ExitIcon from '@moda/icons/exit-16';
|
|
7
|
-
import {
|
|
7
|
+
import { Clickable } from '../Clickable';
|
|
8
8
|
import { SelectOptions } from './SelectOptions';
|
|
9
9
|
import { useSelect } from './useSelect';
|
|
10
|
+
import { SelectableOption } from '.';
|
|
10
11
|
import './MultiSelect.scss';
|
|
11
|
-
import { Clickable } from '../Clickable';
|
|
12
12
|
|
|
13
13
|
type Props = Omit<React.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'value' | 'onChange'> & {
|
|
14
14
|
defaultValue?: string[] | undefined;
|
|
@@ -85,16 +85,16 @@ export const MultiSelect: React.FC<Props> = ({
|
|
|
85
85
|
ref={selectRef}
|
|
86
86
|
{...rest}
|
|
87
87
|
>
|
|
88
|
-
<Clickable className=
|
|
89
|
-
<div className=
|
|
88
|
+
<Clickable className="MultiSelect__search" disabled={disabled} onClick={handleToggle}>
|
|
89
|
+
<div className="MultiSelect__selected-items">
|
|
90
90
|
{values.map((value, index) => (
|
|
91
|
-
<span className=
|
|
92
|
-
<span className=
|
|
91
|
+
<span className="MultiSelect__selected-item" key={index}>
|
|
92
|
+
<span className="MultiSelect__selected-value">
|
|
93
93
|
{options.find(option => option.value === value)?.label || value}
|
|
94
94
|
</span>
|
|
95
95
|
<ExitIcon
|
|
96
96
|
style={{ width: '8px', height: '8px', position: 'relative' }}
|
|
97
|
-
className=
|
|
97
|
+
className="MultiSelect__exit"
|
|
98
98
|
onClick={() => handleRemove(value)}
|
|
99
99
|
/>
|
|
100
100
|
</span>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import { States } from 'storybook-states';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { Input } from '../Field';
|
|
4
6
|
import { Select, SelectProps } from './Select';
|
|
5
7
|
import { MultiSelect } from './MultiSelect';
|
|
6
|
-
import { Input } from '../Field';
|
|
7
|
-
import { useCallback } from 'react';
|
|
8
8
|
|
|
9
9
|
export default { title: 'Components/Select' };
|
|
10
10
|
|
|
@@ -34,10 +34,11 @@ export const Default = () => (
|
|
|
34
34
|
{ disabled: true, idRef: '4', label: 'Sort' },
|
|
35
35
|
{ idRef: '5', label: '' },
|
|
36
36
|
{ idRef: '5', label: '', error: 'Error' },
|
|
37
|
-
{ idRef: '6', label: '', dropDirection: 'up' }
|
|
37
|
+
{ idRef: '6', label: '', dropDirection: 'up' },
|
|
38
|
+
{ idRef: '7', label: undefined, placeholder: 'Placeholder' }
|
|
38
39
|
]}
|
|
39
40
|
>
|
|
40
|
-
<Select label=
|
|
41
|
+
<Select label="Sort by" options={OPTIONS} onChange={action('onChange')} />
|
|
41
42
|
</States>
|
|
42
43
|
);
|
|
43
44
|
|
|
@@ -46,15 +47,16 @@ export const ChangingValue = () => {
|
|
|
46
47
|
|
|
47
48
|
const values = OPTIONS.map(({ value }) => value);
|
|
48
49
|
const value = values[cursor % values.length];
|
|
50
|
+
const HALF_SECOND_INTERVAL = 500;
|
|
49
51
|
|
|
50
52
|
useEffect(() => {
|
|
51
53
|
const interval = setInterval(() => {
|
|
52
54
|
setCursor(prevCursor => prevCursor + 1);
|
|
53
|
-
},
|
|
55
|
+
}, HALF_SECOND_INTERVAL);
|
|
54
56
|
return () => clearInterval(interval);
|
|
55
57
|
}, []);
|
|
56
58
|
|
|
57
|
-
return <Select label=
|
|
59
|
+
return <Select label="Sort by" options={OPTIONS} onChange={action('onChange')} value={value} />;
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
const COUNTRIES = [
|
|
@@ -258,16 +260,16 @@ const COUNTRIES = [
|
|
|
258
260
|
|
|
259
261
|
export const Long = () => (
|
|
260
262
|
<Select
|
|
261
|
-
label=
|
|
263
|
+
label="Choose country"
|
|
262
264
|
options={COUNTRIES.map(country => ({ label: country, value: country }))}
|
|
263
265
|
/>
|
|
264
266
|
);
|
|
265
267
|
|
|
266
268
|
export const AutoFill = () => (
|
|
267
269
|
<>
|
|
268
|
-
<Input label=
|
|
269
|
-
<Input label=
|
|
270
|
-
<Input label=
|
|
270
|
+
<Input label="Address*" name="addressLine1" />
|
|
271
|
+
<Input label="City" name="city" />
|
|
272
|
+
<Input label="Choose country" name="country">
|
|
271
273
|
<Select
|
|
272
274
|
options={COUNTRIES.map(country => ({ label: country, value: country }))}
|
|
273
275
|
allowAutoFill
|
|
@@ -278,7 +280,7 @@ export const AutoFill = () => (
|
|
|
278
280
|
|
|
279
281
|
export const InsideInputComponent = () => (
|
|
280
282
|
<Input error>
|
|
281
|
-
<Select options={OPTIONS}
|
|
283
|
+
<Select options={OPTIONS} />
|
|
282
284
|
</Input>
|
|
283
285
|
);
|
|
284
286
|
|
|
@@ -311,7 +313,7 @@ export const MultiSelectWithDefaultsComponent = () => {
|
|
|
311
313
|
<MultiSelect
|
|
312
314
|
onChange={handleSetItems}
|
|
313
315
|
value={selectedItems}
|
|
314
|
-
placeholder=
|
|
316
|
+
placeholder="United States"
|
|
315
317
|
defaultValue={['Canada', 'Albania', 'Greece']}
|
|
316
318
|
options={COUNTRIES.map(country => ({ label: country, value: country }))}
|
|
317
319
|
/>
|
|
@@ -321,7 +323,7 @@ export const MultiSelectWithDefaultsComponent = () => {
|
|
|
321
323
|
export const MultiSelectUncontrolledComponent = () => {
|
|
322
324
|
return (
|
|
323
325
|
<MultiSelect
|
|
324
|
-
placeholder=
|
|
326
|
+
placeholder="United States"
|
|
325
327
|
defaultValue={['Canada', 'Albania', 'Greece']}
|
|
326
328
|
options={COUNTRIES.map(country => ({ label: country, value: country }))}
|
|
327
329
|
/>
|
|
@@ -331,8 +333,8 @@ export const MultiSelectUncontrolledComponent = () => {
|
|
|
331
333
|
export const MultiSelectUncontrolledSearchComponent = () => {
|
|
332
334
|
return (
|
|
333
335
|
<MultiSelect
|
|
334
|
-
searchable
|
|
335
|
-
placeholder=
|
|
336
|
+
searchable
|
|
337
|
+
placeholder="United States"
|
|
336
338
|
defaultValue={['Canada', 'Albania', 'Greece']}
|
|
337
339
|
options={COUNTRIES.map(country => ({ label: country, value: country }))}
|
|
338
340
|
/>
|
|
@@ -13,7 +13,7 @@ describe('Select', () => {
|
|
|
13
13
|
|
|
14
14
|
it('renders correctly', () => {
|
|
15
15
|
const { container } = render(
|
|
16
|
-
<Select idRef=
|
|
16
|
+
<Select idRef="1" name="name-1" label="Sort by" options={options} />
|
|
17
17
|
);
|
|
18
18
|
expect(container.innerHTML).toEqual(
|
|
19
19
|
'<div id="Select--1" class="Select"><input id="1" name="name-1" type="hidden" value=""><button id="Select__value--1" aria-haspopup="listbox" aria-expanded="false" aria-labelledby="Select__label--1 Select__value--1" type="button" title="Select" class="Clickable Select__value"><label id="Select__label--1">Sort by</label><span class="Select__icon"></span></button></div>'
|
|
@@ -22,9 +22,9 @@ describe('Select', () => {
|
|
|
22
22
|
|
|
23
23
|
it('expands when clicked', async () => {
|
|
24
24
|
const { container } = render(
|
|
25
|
-
<Select idRef=
|
|
25
|
+
<Select idRef="1" name="name-1" label="Sort by" options={options} />
|
|
26
26
|
);
|
|
27
|
-
const button =
|
|
27
|
+
const button = screen.getByRole('button', { name: /Sort by/ });
|
|
28
28
|
await userEvent.click(button);
|
|
29
29
|
expect(container.innerHTML).toEqual(
|
|
30
30
|
'<div id="Select--1" class="Select"><input id="1" name="name-1" type="hidden" value=""><button id="Select__value--1" aria-haspopup="listbox" aria-expanded="true" aria-labelledby="Select__label--1 Select__value--1" type="button" title="Select" class="Clickable Select__value"><label id="Select__label--1">Sort by</label><span class="Select__icon"></span></button><div class="SelectOptions Select__options Select__options--down"><ul class="SelectOptions__list" tabindex="-1" role="listbox" aria-labelledby="Select__label--1" aria-activedescendant="SelectOption--foo-1"><li class="SelectOption SelectOption--active" aria-label="Foo" aria-selected="false" role="option">Foo</li><li class="SelectOption" aria-label="Bar" aria-selected="false" role="option">Bar</li><li class="SelectOption SelectOption--disabled" aria-label="Baz" aria-selected="false" role="option">Baz</li></ul></div></div>'
|
|
@@ -36,13 +36,13 @@ describe('Select', () => {
|
|
|
36
36
|
<Select
|
|
37
37
|
defaultValue={undefined}
|
|
38
38
|
disabled
|
|
39
|
-
idRef=
|
|
40
|
-
name=
|
|
41
|
-
label=
|
|
39
|
+
idRef="1"
|
|
40
|
+
name="name-1"
|
|
41
|
+
label="Sort by"
|
|
42
42
|
options={options}
|
|
43
43
|
/>
|
|
44
44
|
);
|
|
45
|
-
const button =
|
|
45
|
+
const button = screen.getByRole('button', { name: /Sort by/ });
|
|
46
46
|
await userEvent.click(button);
|
|
47
47
|
expect(container.innerHTML).toEqual(
|
|
48
48
|
'<div id="Select--1" class="Select Select--disabled"><input id="1" name="name-1" type="hidden" value=""><button id="Select__value--1" aria-haspopup="listbox" aria-expanded="false" aria-labelledby="Select__label--1 Select__value--1" type="button" title="Select" class="Clickable Clickable--disabled Select__value" disabled=""><label id="Select__label--1">Sort by</label><span class="Select__icon"></span></button></div>'
|
|
@@ -51,17 +51,17 @@ describe('Select', () => {
|
|
|
51
51
|
|
|
52
52
|
it('calls onChange when selecting an option', async () => {
|
|
53
53
|
const onChange = jest.fn();
|
|
54
|
-
|
|
54
|
+
render(
|
|
55
55
|
<Select
|
|
56
56
|
defaultValue={undefined}
|
|
57
|
-
idRef=
|
|
58
|
-
label=
|
|
59
|
-
name=
|
|
57
|
+
idRef="1"
|
|
58
|
+
label="Sort by"
|
|
59
|
+
name="name-1"
|
|
60
60
|
options={options}
|
|
61
61
|
onChange={onChange}
|
|
62
62
|
/>
|
|
63
63
|
);
|
|
64
|
-
const button =
|
|
64
|
+
const button = screen.getByRole('button', { name: /Sort by/ });
|
|
65
65
|
await userEvent.click(button);
|
|
66
66
|
const option = screen.getByLabelText('Bar');
|
|
67
67
|
await userEvent.click(option);
|
|
@@ -70,17 +70,17 @@ describe('Select', () => {
|
|
|
70
70
|
|
|
71
71
|
it('does not call onChange when selecting a disabled option', async () => {
|
|
72
72
|
const onChange = jest.fn();
|
|
73
|
-
|
|
73
|
+
render(
|
|
74
74
|
<Select
|
|
75
75
|
defaultValue={undefined}
|
|
76
|
-
idRef=
|
|
77
|
-
label=
|
|
78
|
-
name=
|
|
76
|
+
idRef="1"
|
|
77
|
+
label="Sort by"
|
|
78
|
+
name="name-1"
|
|
79
79
|
options={options}
|
|
80
80
|
onChange={onChange}
|
|
81
81
|
/>
|
|
82
82
|
);
|
|
83
|
-
const button =
|
|
83
|
+
const button = screen.getByRole('button', { name: /Sort by/ });
|
|
84
84
|
await userEvent.click(button);
|
|
85
85
|
const option = screen.getByLabelText('Baz');
|
|
86
86
|
await userEvent.click(option);
|
|
@@ -89,9 +89,9 @@ describe('Select', () => {
|
|
|
89
89
|
|
|
90
90
|
it('renders correctly with ":" between label and value if value is not undefined', async () => {
|
|
91
91
|
const { container } = render(
|
|
92
|
-
<Select idRef=
|
|
92
|
+
<Select idRef="1" name="name-1" label="Sort by" options={options} />
|
|
93
93
|
);
|
|
94
|
-
const button =
|
|
94
|
+
const button = screen.getByRole('button', { name: /Sort by/ });
|
|
95
95
|
await userEvent.click(button);
|
|
96
96
|
const option = screen.getByLabelText('Bar');
|
|
97
97
|
await userEvent.click(option);
|
|
@@ -101,8 +101,8 @@ describe('Select', () => {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it('renders correctly when there is no label', async () => {
|
|
104
|
-
const { container } = render(<Select idRef=
|
|
105
|
-
const button =
|
|
104
|
+
const { container } = render(<Select idRef="1" name="name-1" options={options} />);
|
|
105
|
+
const button = screen.getByRole('button', { name: 'Select' });
|
|
106
106
|
await userEvent.click(button);
|
|
107
107
|
const option = screen.getByLabelText('Bar');
|
|
108
108
|
await userEvent.click(option);
|
|
@@ -29,6 +29,7 @@ export type SelectProps = Omit<
|
|
|
29
29
|
searchable?: boolean;
|
|
30
30
|
shiftIconLeftwards?: boolean;
|
|
31
31
|
value?: string | undefined;
|
|
32
|
+
dataTestId?: string;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
export const Select: React.FC<SelectProps> = ({
|
|
@@ -44,9 +45,11 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
44
45
|
name,
|
|
45
46
|
onChange,
|
|
46
47
|
options,
|
|
48
|
+
placeholder,
|
|
47
49
|
searchable,
|
|
48
50
|
shiftIconLeftwards = false,
|
|
49
51
|
value,
|
|
52
|
+
dataTestId,
|
|
50
53
|
...rest
|
|
51
54
|
}) => {
|
|
52
55
|
const { state, dispatch, Mode, selectRef } = useSelect({ value, defaultValue });
|
|
@@ -102,21 +105,26 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
102
105
|
{...rest}
|
|
103
106
|
>
|
|
104
107
|
{!allowAutoFill && name && (
|
|
105
|
-
<input id={idRef} name={name} type=
|
|
108
|
+
<input id={idRef} name={name} type="hidden" value={state.value} />
|
|
106
109
|
)}
|
|
107
110
|
|
|
108
111
|
<Clickable
|
|
109
112
|
id={`Select__value--${idRef}`}
|
|
110
|
-
className=
|
|
113
|
+
className="Select__value"
|
|
111
114
|
disabled={disabled}
|
|
112
115
|
onClick={handleToggle}
|
|
113
|
-
|
|
116
|
+
data-test-id={dataTestId}
|
|
117
|
+
aria-haspopup="listbox"
|
|
114
118
|
aria-expanded={state.mode === Mode.Open}
|
|
115
119
|
aria-labelledby={`Select__label--${idRef} Select__value--${idRef}`}
|
|
116
|
-
type=
|
|
117
|
-
title=
|
|
120
|
+
type="button"
|
|
121
|
+
title="Select"
|
|
118
122
|
>
|
|
119
|
-
<SelectLabel
|
|
123
|
+
<SelectLabel
|
|
124
|
+
idRef={idRef}
|
|
125
|
+
label={label || (selected === undefined ? placeholder : undefined)}
|
|
126
|
+
hasValue={focused != null || selected != null}
|
|
127
|
+
/>
|
|
120
128
|
|
|
121
129
|
{(focused ?? selected)?.label}
|
|
122
130
|
|
|
@@ -134,6 +142,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
134
142
|
'Select__options--up': dropDirection === 'up',
|
|
135
143
|
'Select__options--down': dropDirection === 'down'
|
|
136
144
|
})}
|
|
145
|
+
dataTestId={dataTestId}
|
|
137
146
|
searchable={searchable}
|
|
138
147
|
options={options}
|
|
139
148
|
onSelect={handleSelect}
|
|
@@ -145,11 +154,11 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
145
154
|
|
|
146
155
|
{allowAutoFill && (
|
|
147
156
|
<input
|
|
148
|
-
className=
|
|
157
|
+
className="Select__hidden-field"
|
|
149
158
|
name={name}
|
|
150
159
|
onChange={({ target }) => handleAutofill(target.value)}
|
|
151
160
|
value={value}
|
|
152
|
-
aria-hidden=
|
|
161
|
+
aria-hidden="true"
|
|
153
162
|
tabIndex={-1}
|
|
154
163
|
/>
|
|
155
164
|
)}
|
|
@@ -9,6 +9,7 @@ export type SelectOptionProps = Omit<React.HTMLAttributes<HTMLLIElement>, 'onCli
|
|
|
9
9
|
selected: boolean;
|
|
10
10
|
option: SelectableOption;
|
|
11
11
|
onClick: (option: SelectableOption) => void;
|
|
12
|
+
dataTestId?: string;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export const SelectOption: React.FC<SelectOptionProps> = ({
|
|
@@ -16,7 +17,8 @@ export const SelectOption: React.FC<SelectOptionProps> = ({
|
|
|
16
17
|
selected,
|
|
17
18
|
option,
|
|
18
19
|
onClick,
|
|
19
|
-
className
|
|
20
|
+
className,
|
|
21
|
+
dataTestId
|
|
20
22
|
}) => {
|
|
21
23
|
const ref = useRef<HTMLLIElement>(null);
|
|
22
24
|
|
|
@@ -43,9 +45,10 @@ export const SelectOption: React.FC<SelectOptionProps> = ({
|
|
|
43
45
|
'SelectOption--disabled': option.disabled
|
|
44
46
|
})}
|
|
45
47
|
onClick={handleClick}
|
|
48
|
+
data-test-id={dataTestId ? `${dataTestId}--${option.label.replace(' ', '-')}` : undefined}
|
|
46
49
|
aria-label={option.label}
|
|
47
50
|
aria-selected={selected}
|
|
48
|
-
role=
|
|
51
|
+
role="option"
|
|
49
52
|
>
|
|
50
53
|
{option.label}
|
|
51
54
|
</li>
|
|
@@ -19,6 +19,7 @@ export type SelectOptionsProps = Omit<
|
|
|
19
19
|
selectedOption?: SelectableOption | undefined;
|
|
20
20
|
onFocus?(option: SelectableOption): void;
|
|
21
21
|
onSelect(option: SelectableOption): void;
|
|
22
|
+
dataTestId?: string;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
@@ -30,6 +31,7 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
|
30
31
|
onSelect,
|
|
31
32
|
onFocus,
|
|
32
33
|
className,
|
|
34
|
+
dataTestId,
|
|
33
35
|
...rest
|
|
34
36
|
}) => {
|
|
35
37
|
const [searchPhrase, setSearchPhrase] = useState('');
|
|
@@ -61,17 +63,17 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
|
61
63
|
<div className={classNames('SelectOptions', className)}>
|
|
62
64
|
{searchable && (
|
|
63
65
|
<SearchInput
|
|
64
|
-
className=
|
|
65
|
-
placeholder=
|
|
66
|
+
className="SelectOptions__search"
|
|
67
|
+
placeholder="Search"
|
|
66
68
|
value={searchPhrase}
|
|
67
69
|
onChange={setSearchPhrase}
|
|
68
70
|
onClear={() => setSearchPhrase('')}
|
|
69
71
|
/>
|
|
70
72
|
)}
|
|
71
73
|
<ul
|
|
72
|
-
className=
|
|
74
|
+
className="SelectOptions__list"
|
|
73
75
|
tabIndex={-1}
|
|
74
|
-
role=
|
|
76
|
+
role="listbox"
|
|
75
77
|
ref={ref}
|
|
76
78
|
aria-labelledby={`Select__label--${idRef}`}
|
|
77
79
|
aria-activedescendant={`SelectOption--${activeOption?.value}-${idRef}`}
|
|
@@ -82,6 +84,7 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
|
82
84
|
id={`SelectOption--${option.value}-${idRef}`}
|
|
83
85
|
key={option.value}
|
|
84
86
|
option={option}
|
|
87
|
+
dataTestId={dataTestId}
|
|
85
88
|
active={activeOption?.value === option.value}
|
|
86
89
|
selected={selectedOption?.value === option.value}
|
|
87
90
|
onClick={onSelect}
|
|
@@ -91,7 +94,7 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
|
91
94
|
))}
|
|
92
95
|
</ul>
|
|
93
96
|
{options.length === 0 && (
|
|
94
|
-
<Text className=
|
|
97
|
+
<Text className="SelectOptions__none" color="cement">
|
|
95
98
|
Nothing found
|
|
96
99
|
</Text>
|
|
97
100
|
)}
|
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
|
|
4
4
|
import { States } from 'storybook-states';
|
|
5
|
-
import { SelectableButton, SelectableButtonProps } from './SelectableButton';
|
|
6
5
|
import { Stack } from '../Stack';
|
|
6
|
+
import { SelectableButton, SelectableButtonProps } from './SelectableButton';
|
|
7
7
|
|
|
8
8
|
export default { title: 'Components/SelectableButton' };
|
|
9
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
|
|
4
4
|
import { SelectableButton } from './SelectableButton';
|
|
5
5
|
|
|
6
6
|
describe('SelectableButton', () => {
|
|
7
7
|
it('renders correctly', () => {
|
|
8
|
-
|
|
9
|
-
expect(
|
|
8
|
+
render(<SelectableButton>Click me</SelectableButton>);
|
|
9
|
+
expect(screen.getByText('Click me')).toBeVisible();
|
|
10
10
|
});
|
|
11
11
|
});
|
|
@@ -3,18 +3,18 @@ import { ShapeProps } from './Shape';
|
|
|
3
3
|
|
|
4
4
|
export const ArcWindow: React.FC<ShapeProps> = () => (
|
|
5
5
|
<svg
|
|
6
|
-
className=
|
|
7
|
-
width=
|
|
8
|
-
height=
|
|
9
|
-
viewBox=
|
|
10
|
-
fill=
|
|
11
|
-
xmlns=
|
|
6
|
+
className="ArcWindow"
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
12
|
>
|
|
13
13
|
<path
|
|
14
|
-
fillRule=
|
|
15
|
-
clipRule=
|
|
16
|
-
d=
|
|
17
|
-
fill=
|
|
14
|
+
fillRule="evenodd"
|
|
15
|
+
clipRule="evenodd"
|
|
16
|
+
d="M20.1097 24V11.6273V8.8331V8.81993C20.1018 3.96884 16.4806 0 12.0536 0C7.6291 0 4.00527 3.96884 4 8.81993V8.8331V11.6273V24H20.1097Z"
|
|
17
|
+
fill="#003728"
|
|
18
18
|
/>
|
|
19
19
|
</svg>
|
|
20
20
|
);
|