@moda/om 16.1.0 → 16.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.cjs.js +316 -284
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +315 -283
- 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 +1 -1
- 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 +0 -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 +0 -0
- package/dist/{components → src/components}/Select/SelectOptions.d.ts +0 -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 +7 -7
- package/src/components/Checkbox/Checkbox.test.tsx +12 -14
- package/src/components/Checkbox/Checkbox.tsx +8 -8
- 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 +13 -8
- package/src/components/Select/SelectOption.tsx +1 -1
- package/src/components/Select/SelectOptions.tsx +5 -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
|
@@ -13,6 +13,9 @@ export type PopoverProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const POPOVER_MOUSEOUT_DELAY_MS = 200;
|
|
16
|
+
const THREE_QUARTER_SECOND_DELAY = 750;
|
|
17
|
+
const ONE_SECOND_DELAY = 1000;
|
|
18
|
+
const FIVE_SECOND_DELAY = 5000;
|
|
16
19
|
|
|
17
20
|
enum Mode {
|
|
18
21
|
Opening = 'opening',
|
|
@@ -80,7 +83,7 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
80
83
|
useEffect(() => {
|
|
81
84
|
if (mode !== Mode.Closing) return;
|
|
82
85
|
|
|
83
|
-
const closingTimeout = setTimeout(() => setMode(Mode.Closed),
|
|
86
|
+
const closingTimeout = setTimeout(() => setMode(Mode.Closed), THREE_QUARTER_SECOND_DELAY);
|
|
84
87
|
|
|
85
88
|
return () => clearTimeout(closingTimeout);
|
|
86
89
|
}, [mode]);
|
|
@@ -88,7 +91,7 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
88
91
|
useEffect(() => {
|
|
89
92
|
if (mode !== Mode.AutoOpening) return;
|
|
90
93
|
|
|
91
|
-
const openingTimeout = setTimeout(() => setMode(Mode.AutoOpen),
|
|
94
|
+
const openingTimeout = setTimeout(() => setMode(Mode.AutoOpen), ONE_SECOND_DELAY);
|
|
92
95
|
|
|
93
96
|
return () => clearTimeout(openingTimeout);
|
|
94
97
|
}, [mode]);
|
|
@@ -96,7 +99,7 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
96
99
|
useEffect(() => {
|
|
97
100
|
if (mode !== Mode.Opening) return;
|
|
98
101
|
|
|
99
|
-
const openingTimeout = setTimeout(() => setMode(Mode.Open),
|
|
102
|
+
const openingTimeout = setTimeout(() => setMode(Mode.Open), THREE_QUARTER_SECOND_DELAY);
|
|
100
103
|
|
|
101
104
|
return () => clearTimeout(openingTimeout);
|
|
102
105
|
}, [mode]);
|
|
@@ -104,7 +107,7 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
104
107
|
useEffect(() => {
|
|
105
108
|
if (mode !== Mode.AutoOpen) return;
|
|
106
109
|
|
|
107
|
-
const stayingTimeout = setTimeout(handleClose,
|
|
110
|
+
const stayingTimeout = setTimeout(handleClose, FIVE_SECOND_DELAY);
|
|
108
111
|
|
|
109
112
|
return () => clearTimeout(stayingTimeout);
|
|
110
113
|
}, [handleClose, mode, smoothTransitioning]);
|
|
@@ -125,7 +128,7 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
125
128
|
onMouseLeave={handleMouseLeave}
|
|
126
129
|
{...rest}
|
|
127
130
|
>
|
|
128
|
-
<span className=
|
|
131
|
+
<span className="Popover__trigger">
|
|
129
132
|
{isOpen && (
|
|
130
133
|
<div
|
|
131
134
|
className={classNames('Popover__box', {
|
|
@@ -134,11 +137,11 @@ export const Popover: React.FC<PopoverProps> = ({
|
|
|
134
137
|
})}
|
|
135
138
|
>
|
|
136
139
|
<div
|
|
137
|
-
className=
|
|
140
|
+
className="Popover__caret"
|
|
138
141
|
style={{ zIndex: zIndex != null ? zIndex + 1 : undefined }}
|
|
139
142
|
/>
|
|
140
143
|
|
|
141
|
-
<div className=
|
|
144
|
+
<div className="Popover__content" style={{ zIndex }}>
|
|
142
145
|
{content}
|
|
143
146
|
</div>
|
|
144
147
|
</div>
|
|
@@ -9,22 +9,22 @@ export const Default = () => (
|
|
|
9
9
|
states={[
|
|
10
10
|
{ children: <span>Center</span> },
|
|
11
11
|
{
|
|
12
|
-
children: [<span key=
|
|
12
|
+
children: [<span key="left">Left</span>, <span key="right">Right</span>]
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
children: [
|
|
16
|
-
<span key=
|
|
17
|
-
<span key=
|
|
18
|
-
<span key=
|
|
16
|
+
<span key="left">Left</span>,
|
|
17
|
+
<span key="center">Center</span>,
|
|
18
|
+
<span key="right">Right</span>
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
children: [
|
|
23
|
-
<span key=
|
|
24
|
-
<span key=
|
|
25
|
-
Order by Dec. 12 for delivery by Dec. 25 — <a href=
|
|
23
|
+
<span key="left">Currency: USA (USD $)</span>,
|
|
24
|
+
<span key="center" className="FOO">
|
|
25
|
+
Order by Dec. 12 for delivery by Dec. 25 — <a href="#">LEARN MORE</a>
|
|
26
26
|
</span>,
|
|
27
|
-
<span key=
|
|
27
|
+
<span key="right">Hi, Friend</span>
|
|
28
28
|
]
|
|
29
29
|
}
|
|
30
30
|
]}
|
|
@@ -38,7 +38,7 @@ export const Mobile = () => (
|
|
|
38
38
|
<PromoBanner>
|
|
39
39
|
<span>Currency: USA (USD $)</span>
|
|
40
40
|
<span>
|
|
41
|
-
Order by Dec. 12 for delivery by Dec. 25 — <a href=
|
|
41
|
+
Order by Dec. 12 for delivery by Dec. 25 — <a href="#">LEARN MORE</a>
|
|
42
42
|
</span>
|
|
43
43
|
<span>Hi, Friend</span>
|
|
44
44
|
</PromoBanner>
|
|
@@ -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);
|
|
@@ -44,6 +44,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
44
44
|
name,
|
|
45
45
|
onChange,
|
|
46
46
|
options,
|
|
47
|
+
placeholder,
|
|
47
48
|
searchable,
|
|
48
49
|
shiftIconLeftwards = false,
|
|
49
50
|
value,
|
|
@@ -102,21 +103,25 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
102
103
|
{...rest}
|
|
103
104
|
>
|
|
104
105
|
{!allowAutoFill && name && (
|
|
105
|
-
<input id={idRef} name={name} type=
|
|
106
|
+
<input id={idRef} name={name} type="hidden" value={state.value} />
|
|
106
107
|
)}
|
|
107
108
|
|
|
108
109
|
<Clickable
|
|
109
110
|
id={`Select__value--${idRef}`}
|
|
110
|
-
className=
|
|
111
|
+
className="Select__value"
|
|
111
112
|
disabled={disabled}
|
|
112
113
|
onClick={handleToggle}
|
|
113
|
-
aria-haspopup=
|
|
114
|
+
aria-haspopup="listbox"
|
|
114
115
|
aria-expanded={state.mode === Mode.Open}
|
|
115
116
|
aria-labelledby={`Select__label--${idRef} Select__value--${idRef}`}
|
|
116
|
-
type=
|
|
117
|
-
title=
|
|
117
|
+
type="button"
|
|
118
|
+
title="Select"
|
|
118
119
|
>
|
|
119
|
-
<SelectLabel
|
|
120
|
+
<SelectLabel
|
|
121
|
+
idRef={idRef}
|
|
122
|
+
label={label || (selected === undefined ? placeholder : undefined)}
|
|
123
|
+
hasValue={focused != null || selected != null}
|
|
124
|
+
/>
|
|
120
125
|
|
|
121
126
|
{(focused ?? selected)?.label}
|
|
122
127
|
|
|
@@ -145,11 +150,11 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
145
150
|
|
|
146
151
|
{allowAutoFill && (
|
|
147
152
|
<input
|
|
148
|
-
className=
|
|
153
|
+
className="Select__hidden-field"
|
|
149
154
|
name={name}
|
|
150
155
|
onChange={({ target }) => handleAutofill(target.value)}
|
|
151
156
|
value={value}
|
|
152
|
-
aria-hidden=
|
|
157
|
+
aria-hidden="true"
|
|
153
158
|
tabIndex={-1}
|
|
154
159
|
/>
|
|
155
160
|
)}
|
|
@@ -61,17 +61,17 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
|
61
61
|
<div className={classNames('SelectOptions', className)}>
|
|
62
62
|
{searchable && (
|
|
63
63
|
<SearchInput
|
|
64
|
-
className=
|
|
65
|
-
placeholder=
|
|
64
|
+
className="SelectOptions__search"
|
|
65
|
+
placeholder="Search"
|
|
66
66
|
value={searchPhrase}
|
|
67
67
|
onChange={setSearchPhrase}
|
|
68
68
|
onClear={() => setSearchPhrase('')}
|
|
69
69
|
/>
|
|
70
70
|
)}
|
|
71
71
|
<ul
|
|
72
|
-
className=
|
|
72
|
+
className="SelectOptions__list"
|
|
73
73
|
tabIndex={-1}
|
|
74
|
-
role=
|
|
74
|
+
role="listbox"
|
|
75
75
|
ref={ref}
|
|
76
76
|
aria-labelledby={`Select__label--${idRef}`}
|
|
77
77
|
aria-activedescendant={`SelectOption--${activeOption?.value}-${idRef}`}
|
|
@@ -91,7 +91,7 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
|
|
|
91
91
|
))}
|
|
92
92
|
</ul>
|
|
93
93
|
{options.length === 0 && (
|
|
94
|
-
<Text className=
|
|
94
|
+
<Text className="SelectOptions__none" color="cement">
|
|
95
95
|
Nothing found
|
|
96
96
|
</Text>
|
|
97
97
|
)}
|
|
@@ -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
|
});
|