@sproutsocial/racine 12.19.0 → 12.21.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 +33 -0
- package/README.md +46 -44
- package/__flow__/Avatar/index.js +26 -26
- package/__flow__/Avatar/index.stories.js +8 -8
- package/__flow__/Avatar/index.test.js +13 -13
- package/__flow__/Badge/constants.js +14 -14
- package/__flow__/Badge/index.js +18 -18
- package/__flow__/Badge/index.stories.js +8 -8
- package/__flow__/Badge/index.test.js +43 -43
- package/__flow__/Badge/styles.js +13 -9
- package/__flow__/Banner/index.js +21 -21
- package/__flow__/Banner/index.stories.js +56 -68
- package/__flow__/Banner/index.test.js +32 -34
- package/__flow__/Banner/styles.js +4 -4
- package/__flow__/Box/index.js +4 -4
- package/__flow__/Box/index.stories.js +58 -51
- package/__flow__/Box/index.test.js +7 -7
- package/__flow__/Box/styles.js +6 -6
- package/__flow__/Breadcrumb/index.js +9 -13
- package/__flow__/Breadcrumb/index.stories.js +14 -14
- package/__flow__/Breadcrumb/index.test.js +20 -20
- package/__flow__/Breadcrumb/styles.js +5 -5
- package/__flow__/Button/index.js +23 -23
- package/__flow__/Button/index.stories.js +34 -34
- package/__flow__/Button/styles.js +11 -11
- package/__flow__/Card/index.js +7 -7
- package/__flow__/Card/index.stories.js +14 -14
- package/__flow__/Card/styles.js +7 -7
- package/__flow__/CharacterCounter/index.js +7 -7
- package/__flow__/CharacterCounter/index.stories.js +25 -26
- package/__flow__/CharacterCounter/index.test.js +11 -11
- package/__flow__/CharacterCounter/styles.js +3 -3
- package/__flow__/ChartLegend/index.js +7 -7
- package/__flow__/ChartLegend/index.stories.js +22 -22
- package/__flow__/ChartLegend/index.test.js +27 -27
- package/__flow__/ChartLegend/styles.js +7 -7
- package/__flow__/Checkbox/index.js +10 -10
- package/__flow__/Checkbox/index.stories.js +24 -24
- package/__flow__/Checkbox/index.test.js +25 -25
- package/__flow__/Checkbox/styles.js +27 -28
- package/__flow__/Collapsible/index.js +15 -15
- package/__flow__/Collapsible/index.stories.js +13 -13
- package/__flow__/Collapsible/index.test.js +27 -27
- package/__flow__/Collapsible/styles.js +5 -5
- package/__flow__/DatePicker/DateRangePicker.js +5 -8
- package/__flow__/DatePicker/DateRangePicker.stories.js +19 -19
- package/__flow__/DatePicker/DateRangePicker.test.js +21 -21
- package/__flow__/DatePicker/SingleDatePicker.js +6 -9
- package/__flow__/DatePicker/SingleDatePicker.stories.js +10 -10
- package/__flow__/DatePicker/SingleDatePicker.test.js +21 -23
- package/__flow__/DatePicker/StatefulDateRangePicker.js +6 -6
- package/__flow__/DatePicker/StatefulSingleDatePicker.js +3 -3
- package/__flow__/DatePicker/common.js +13 -13
- package/__flow__/DatePicker/index.js +3 -3
- package/__flow__/DatePicker/styles.js +42 -42
- package/__flow__/Drawer/SlideTransition.js +10 -10
- package/__flow__/Drawer/index.js +29 -29
- package/__flow__/Drawer/index.stories.js +58 -141
- package/__flow__/Drawer/index.test.js +28 -28
- package/__flow__/Drawer/styles.js +4 -4
- package/__flow__/EmptyState/index.js +5 -5
- package/__flow__/EmptyState/index.stories.js +10 -10
- package/__flow__/EmptyState/index.test.js +27 -27
- package/__flow__/EnumIllustrationNames.js +1 -1
- package/__flow__/Fieldset/index.js +14 -14
- package/__flow__/Fieldset/index.stories.js +19 -20
- package/__flow__/Fieldset/index.test.js +14 -14
- package/__flow__/Fieldset/styles.js +5 -5
- package/__flow__/FormField/index.js +14 -14
- package/__flow__/FormField/index.stories.js +31 -21
- package/__flow__/FormField/index.test.js +19 -19
- package/__flow__/Icon/deprecatedIcons.js +36 -36
- package/__flow__/Icon/index.js +17 -17
- package/__flow__/Icon/index.stories.js +62 -29
- package/__flow__/Icon/index.test.js +15 -15
- package/__flow__/Icon/styles.js +12 -23
- package/__flow__/IllustrationViewBoxes.js +1 -1
- package/__flow__/Image/index.js +6 -7
- package/__flow__/Image/index.stories.js +5 -5
- package/__flow__/Image/index.test.js +24 -24
- package/__flow__/Image/styles.js +6 -5
- package/__flow__/Indicator/index.js +7 -7
- package/__flow__/Indicator/index.stories.js +8 -14
- package/__flow__/Indicator/index.test.js +6 -6
- package/__flow__/Indicator/styles.js +6 -6
- package/__flow__/Input/index.js +37 -37
- package/__flow__/Input/index.stories.js +96 -189
- package/__flow__/Input/index.test.js +117 -117
- package/__flow__/Input/styles.js +13 -13
- package/__flow__/KeyboardKey/index.js +5 -5
- package/__flow__/KeyboardKey/index.stories.js +9 -12
- package/__flow__/KeyboardKey/index.test.js +7 -7
- package/__flow__/KeyboardKey/styles.js +4 -4
- package/__flow__/Label/index.js +6 -6
- package/__flow__/Label/index.stories.js +5 -7
- package/__flow__/Label/index.test.js +8 -8
- package/__flow__/Link/constants.js +4 -4
- package/__flow__/Link/index.js +11 -11
- package/__flow__/Link/index.stories.js +61 -102
- package/__flow__/Link/index.test.js +40 -40
- package/__flow__/Link/styles.js +6 -6
- package/__flow__/Listbox/index.js +16 -16
- package/__flow__/Listbox/index.stories.js +35 -35
- package/__flow__/Listbox/index.test.js +63 -65
- package/__flow__/Loader/index.js +12 -12
- package/__flow__/Loader/index.stories.js +10 -10
- package/__flow__/Loader/index.test.js +17 -17
- package/__flow__/Loader/styles.js +9 -13
- package/__flow__/LoaderButton/index.js +36 -18
- package/__flow__/LoaderButton/index.stories.js +35 -7
- package/__flow__/LoaderButton/index.test.js +15 -15
- package/__flow__/Menu/__snapshots__/index.test.js.snap +0 -9
- package/__flow__/Menu/constants.js +8 -8
- package/__flow__/Menu/descendants.js +89 -80
- package/__flow__/Menu/hooks.js +22 -22
- package/__flow__/Menu/index.flow.js +13 -13
- package/__flow__/Menu/index.js +56 -60
- package/__flow__/Menu/index.stories.js +19 -19
- package/__flow__/Menu/index.test.js +22 -22
- package/__flow__/Menu/names.js +4945 -4945
- package/__flow__/Menu/styles.js +5 -5
- package/__flow__/Message/index.js +33 -33
- package/__flow__/Message/index.stories.js +18 -13
- package/__flow__/Message/index.test.js +6 -6
- package/__flow__/Message/styles.js +15 -15
- package/__flow__/Modal/index.js +19 -19
- package/__flow__/Modal/index.stories.js +43 -43
- package/__flow__/Modal/index.test.js +29 -29
- package/__flow__/Modal/styles.js +27 -32
- package/__flow__/Numeral/index.js +22 -22
- package/__flow__/Numeral/index.stories.js +74 -74
- package/__flow__/Numeral/styles.js +3 -3
- package/__flow__/Numeral/tests/A11y.test.js +7 -7
- package/__flow__/Numeral/tests/abbreviate.test.js +40 -40
- package/__flow__/Numeral/tests/currency.test.js +24 -24
- package/__flow__/Numeral/tests/defaults.test.js +20 -20
- package/__flow__/Numeral/tests/invalid.test.js +9 -9
- package/__flow__/Numeral/tests/locale.test.js +38 -38
- package/__flow__/Numeral/tests/precision.test.js +76 -76
- package/__flow__/Numeral/tests/testNumeral.js +11 -11
- package/__flow__/Numeral/tests/zero.test.js +8 -8
- package/__flow__/OverflowList/index.flow.js +2 -2
- package/__flow__/OverflowList/index.js +12 -12
- package/__flow__/OverflowList/index.stories.js +10 -10
- package/__flow__/OverflowList/index.test.js +25 -25
- package/__flow__/OverflowList/styles.js +5 -5
- package/__flow__/PartnerLogo/TypePartnerNames.js +37 -37
- package/__flow__/PartnerLogo/index.js +21 -27
- package/__flow__/PartnerLogo/index.stories.js +52 -52
- package/__flow__/PartnerLogo/styles.js +12 -24
- package/__flow__/Popout/index.js +66 -67
- package/__flow__/Popout/index.stories.js +101 -82
- package/__flow__/Popout/index.test.js +43 -43
- package/__flow__/Popout/styles.js +4 -5
- package/__flow__/Portal/index.js +9 -9
- package/__flow__/Portal/index.stories.js +12 -12
- package/__flow__/Radio/index.js +4 -4
- package/__flow__/Radio/index.stories.js +11 -11
- package/__flow__/Radio/index.test.js +12 -12
- package/__flow__/Radio/styles.js +15 -16
- package/__flow__/SegmentedControl/index.js +7 -7
- package/__flow__/SegmentedControl/index.stories.js +7 -7
- package/__flow__/SegmentedControl/index.test.js +29 -29
- package/__flow__/SegmentedControl/styles.js +10 -9
- package/__flow__/Select/index.js +10 -10
- package/__flow__/Select/index.stories.js +33 -69
- package/__flow__/Select/index.test.js +14 -14
- package/__flow__/Select/styles.js +16 -16
- package/__flow__/Skeleton/index.js +4 -4
- package/__flow__/Skeleton/index.stories.js +5 -5
- package/__flow__/SpotIllustration/illustrationNames.js +118 -117
- package/__flow__/SpotIllustration/index.js +15 -11
- package/__flow__/SpotIllustration/index.stories.js +18 -18
- package/__flow__/SpotIllustration/spotIllustrations/molecule.svg +14 -0
- package/__flow__/Stack/index.js +43 -33
- package/__flow__/Stack/index.stories.js +41 -91
- package/__flow__/Stack/index.test.js +16 -7
- package/__flow__/Switch/index.js +8 -8
- package/__flow__/Switch/index.stories.js +5 -5
- package/__flow__/Switch/index.test.js +25 -29
- package/__flow__/Switch/styles.js +13 -9
- package/__flow__/Table/index.js +17 -17
- package/__flow__/Table/index.stories.js +99 -99
- package/__flow__/Table/index.test.js +32 -32
- package/__flow__/Table/styles.js +4 -4
- package/__flow__/TableCell/index.js +8 -7
- package/__flow__/TableCell/index.stories.js +20 -23
- package/__flow__/TableCell/index.test.js +11 -11
- package/__flow__/TableCell/styles.js +4 -5
- package/__flow__/TableHeaderCell/index.js +14 -14
- package/__flow__/TableHeaderCell/index.stories.js +35 -30
- package/__flow__/TableHeaderCell/index.test.js +11 -11
- package/__flow__/TableHeaderCell/styles.js +4 -4
- package/__flow__/TableRowAccordion/index.js +8 -8
- package/__flow__/TableRowAccordion/index.stories.js +36 -36
- package/__flow__/TableRowAccordion/index.test.js +28 -30
- package/__flow__/TableRowAccordion/styles.js +11 -7
- package/__flow__/Tabs/index.js +11 -11
- package/__flow__/Tabs/index.stories.js +28 -54
- package/__flow__/Tabs/index.test.js +54 -54
- package/__flow__/Tabs/styles.js +6 -7
- package/__flow__/Text/index.js +14 -14
- package/__flow__/Text/index.stories.js +84 -86
- package/__flow__/Text/index.test.js +29 -33
- package/__flow__/Text/styles.js +4 -4
- package/__flow__/Textarea/index.js +5 -5
- package/__flow__/Textarea/index.stories.js +54 -93
- package/__flow__/Textarea/index.test.js +30 -30
- package/__flow__/Textarea/styles.js +6 -6
- package/__flow__/ThemeProvider/index.js +4 -4
- package/__flow__/Toast/index.js +23 -23
- package/__flow__/Toast/index.stories.js +21 -21
- package/__flow__/Toast/styles.js +6 -6
- package/__flow__/ToggleHint/index.js +8 -8
- package/__flow__/ToggleHint/index.test.js +8 -8
- package/__flow__/ToggleHint/styles.js +8 -8
- package/__flow__/Token/index.js +10 -10
- package/__flow__/Token/index.stories.js +49 -54
- package/__flow__/Token/index.test.js +28 -28
- package/__flow__/Token/styles.js +11 -11
- package/__flow__/TokenInput/index.flow.js +1 -1
- package/__flow__/TokenInput/index.js +39 -39
- package/__flow__/TokenInput/index.stories.js +121 -128
- package/__flow__/TokenInput/styles.js +5 -5
- package/__flow__/TokenInput/tests/default/clicking.test.js +13 -13
- package/__flow__/TokenInput/tests/default/deleting.test.js +39 -39
- package/__flow__/TokenInput/tests/default/focusing.test.js +18 -18
- package/__flow__/TokenInput/tests/default/inputting.test.js +23 -23
- package/__flow__/TokenInput/tests/default/pasting.test.js +52 -52
- package/__flow__/TokenInput/tests/default/rendering.test.js +54 -54
- package/__flow__/TokenInput/util.js +4 -4
- package/__flow__/Tooltip/index.js +21 -21
- package/__flow__/Tooltip/index.stories.js +18 -18
- package/__flow__/Tooltip/index.test.js +54 -54
- package/__flow__/Tooltip/styles.js +4 -5
- package/__flow__/VisuallyHidden/index.js +3 -3
- package/__flow__/building-stories.stories.mdx +121 -0
- package/__flow__/dataviz/dataviz.stories.js +4 -4
- package/__flow__/dataviz/index.js +3 -3
- package/__flow__/index.js +72 -72
- package/__flow__/overview.stories.js +60 -0
- package/__flow__/setupTests.js +5 -5
- package/__flow__/systemProps/background.js +3 -3
- package/__flow__/systemProps/border.js +3 -3
- package/__flow__/systemProps/color.js +3 -3
- package/__flow__/systemProps/custom.js +3 -3
- package/__flow__/systemProps/flexbox.js +3 -3
- package/__flow__/systemProps/grid.js +3 -3
- package/__flow__/systemProps/index.js +14 -14
- package/__flow__/systemProps/layout.js +3 -3
- package/__flow__/systemProps/position.js +3 -3
- package/__flow__/systemProps/shadow.js +3 -3
- package/__flow__/systemProps/space.js +3 -7
- package/__flow__/systemProps/systemProps.js +14 -14
- package/__flow__/systemProps/tests/background.test.js +17 -17
- package/__flow__/systemProps/tests/border.test.js +61 -61
- package/__flow__/systemProps/tests/color.test.js +15 -15
- package/__flow__/systemProps/tests/custom.test.js +12 -12
- package/__flow__/systemProps/tests/flexbox.test.js +33 -33
- package/__flow__/systemProps/tests/grid.test.js +31 -31
- package/__flow__/systemProps/tests/layout.test.js +29 -29
- package/__flow__/systemProps/tests/position.test.js +19 -19
- package/__flow__/systemProps/tests/shadow.test.js +11 -11
- package/__flow__/systemProps/tests/space.test.js +11 -11
- package/__flow__/systemProps/tests/types.flow.js +18 -18
- package/__flow__/systemProps/tests/typography.test.js +21 -21
- package/__flow__/systemProps/tests/variant.test.js +9 -9
- package/__flow__/systemProps/types.flow.js +2 -2
- package/__flow__/systemProps/typography.js +4 -4
- package/__flow__/systemProps/variant.js +5 -5
- package/__flow__/themes/dark/dataviz-palette.js +21 -21
- package/__flow__/themes/dark/decorative-palettes.js +1 -1
- package/__flow__/themes/dark/theme.js +18 -18
- package/__flow__/themes/extendedThemes/README.md +1 -1
- package/__flow__/themes/extendedThemes/sproutTheme/dark/theme.js +16 -4
- package/__flow__/themes/extendedThemes/sproutTheme/index.js +2 -2
- package/__flow__/themes/extendedThemes/sproutTheme/light/theme.js +16 -4
- package/__flow__/themes/light/dataviz-palette.js +21 -21
- package/__flow__/themes/light/decorative-palettes.js +1 -1
- package/__flow__/themes/light/literal-colors.js +133 -133
- package/__flow__/themes/light/theme.js +53 -53
- package/__flow__/types/system-props.flow.js +5 -5
- package/__flow__/types/theme.colors.flow.js +2 -2
- package/__flow__/types/theme.flow.js +5 -5
- package/__flow__/utils/a11yTest.js +1 -1
- package/__flow__/utils/chartColors.js +1 -1
- package/__flow__/utils/constants.js +1 -1
- package/__flow__/utils/dataQaLabelQueries.js +2 -2
- package/__flow__/utils/hooks.js +17 -17
- package/__flow__/utils/index.js +4 -4
- package/__flow__/utils/innerText.js +9 -9
- package/__flow__/utils/mixins.js +6 -6
- package/__flow__/utils/react-testing-library.js +6 -6
- package/__flow__/utils/responsiveProps/index.js +3 -3
- package/__flow__/utils/responsiveProps/index.test.js +8 -8
- package/__flow__/utils/system-props.js +3 -3
- package/__flow__/utils/useInteractiveColor.js +5 -5
- package/__flow__/writing-good-stories.stories.mdx +3 -0
- package/bin/racine-codemod.js +12 -12
- package/codemods/__tests__/migrate-2.x-to-3.x.test.js +2 -2
- package/codemods/migrate-2.x-to-3.x.js +29 -30
- package/commonjs/Avatar/index.js +33 -53
- package/commonjs/Badge/constants.js +18 -15
- package/commonjs/Badge/index.js +14 -28
- package/commonjs/Badge/styles.js +3 -9
- package/commonjs/Banner/index.js +16 -37
- package/commonjs/Banner/styles.js +0 -5
- package/commonjs/Box/index.js +2 -9
- package/commonjs/Box/styles.js +0 -4
- package/commonjs/Breadcrumb/index.js +13 -29
- package/commonjs/Breadcrumb/styles.js +1 -4
- package/commonjs/Button/index.js +29 -43
- package/commonjs/Button/styles.js +6 -15
- package/commonjs/Card/index.js +16 -26
- package/commonjs/Card/styles.js +1 -5
- package/commonjs/CharacterCounter/index.js +6 -23
- package/commonjs/CharacterCounter/styles.js +0 -5
- package/commonjs/ChartLegend/index.js +5 -20
- package/commonjs/ChartLegend/styles.js +2 -11
- package/commonjs/Checkbox/index.js +30 -53
- package/commonjs/Checkbox/styles.js +14 -35
- package/commonjs/Collapsible/index.js +31 -54
- package/commonjs/Collapsible/styles.js +3 -6
- package/commonjs/DatePicker/DateRangePicker.js +4 -17
- package/commonjs/DatePicker/SingleDatePicker.js +3 -17
- package/commonjs/DatePicker/StatefulDateRangePicker.js +16 -31
- package/commonjs/DatePicker/StatefulSingleDatePicker.js +7 -20
- package/commonjs/DatePicker/common.js +8 -22
- package/commonjs/DatePicker/index.js +0 -5
- package/commonjs/DatePicker/styles.js +8 -25
- package/commonjs/Drawer/SlideTransition.js +8 -18
- package/commonjs/Drawer/index.js +51 -90
- package/commonjs/Drawer/styles.js +0 -8
- package/commonjs/EmptyState/index.js +8 -20
- package/commonjs/Fieldset/index.js +15 -32
- package/commonjs/Fieldset/styles.js +2 -7
- package/commonjs/FormField/index.js +19 -36
- package/commonjs/Icon/deprecatedIcons.js +36 -36
- package/commonjs/Icon/index.js +19 -37
- package/commonjs/Icon/styles.js +8 -19
- package/commonjs/IllustrationViewBoxes.js +1 -0
- package/commonjs/Image/index.js +13 -41
- package/commonjs/Image/styles.js +1 -7
- package/commonjs/Indicator/index.js +8 -26
- package/commonjs/Indicator/styles.js +1 -7
- package/commonjs/Input/index.js +80 -119
- package/commonjs/Input/styles.js +9 -19
- package/commonjs/KeyboardKey/index.js +3 -20
- package/commonjs/KeyboardKey/styles.js +0 -4
- package/commonjs/Label/index.js +7 -27
- package/commonjs/Link/constants.js +3 -4
- package/commonjs/Link/index.js +16 -28
- package/commonjs/Link/styles.js +1 -8
- package/commonjs/Listbox/index.js +15 -36
- package/commonjs/Loader/index.js +15 -31
- package/commonjs/Loader/styles.js +2 -13
- package/commonjs/LoaderButton/index.js +37 -39
- package/commonjs/Menu/constants.js +9 -8
- package/commonjs/Menu/descendants.js +70 -105
- package/commonjs/Menu/hooks.js +23 -41
- package/commonjs/Menu/index.flow.js +0 -7
- package/commonjs/Menu/index.js +94 -164
- package/commonjs/Menu/names.js +1 -1
- package/commonjs/Menu/styles.js +0 -6
- package/commonjs/Message/index.js +37 -70
- package/commonjs/Message/styles.js +9 -24
- package/commonjs/Modal/index.js +31 -54
- package/commonjs/Modal/styles.js +17 -36
- package/commonjs/Numeral/index.js +39 -67
- package/commonjs/Numeral/styles.js +0 -3
- package/commonjs/Numeral/tests/testNumeral.js +13 -31
- package/commonjs/OverflowList/index.flow.js +0 -2
- package/commonjs/OverflowList/index.js +27 -41
- package/commonjs/OverflowList/styles.js +0 -7
- package/commonjs/PartnerLogo/index.js +22 -37
- package/commonjs/PartnerLogo/styles.js +7 -17
- package/commonjs/Popout/index.js +95 -127
- package/commonjs/Popout/styles.js +0 -5
- package/commonjs/Portal/index.js +8 -31
- package/commonjs/Radio/index.js +18 -42
- package/commonjs/Radio/styles.js +9 -21
- package/commonjs/SegmentedControl/index.js +17 -37
- package/commonjs/SegmentedControl/styles.js +2 -12
- package/commonjs/Select/index.js +24 -47
- package/commonjs/Select/styles.js +12 -24
- package/commonjs/Skeleton/index.js +0 -5
- package/commonjs/SpotIllustration/illustrationNames.js +1 -1
- package/commonjs/SpotIllustration/index.js +5 -11
- package/commonjs/Stack/index.js +27 -42
- package/commonjs/Switch/index.js +17 -42
- package/commonjs/Switch/styles.js +3 -11
- package/commonjs/Table/index.js +26 -50
- package/commonjs/Table/styles.js +0 -4
- package/commonjs/TableCell/index.js +12 -30
- package/commonjs/TableCell/styles.js +0 -5
- package/commonjs/TableHeaderCell/index.js +27 -56
- package/commonjs/TableHeaderCell/styles.js +0 -6
- package/commonjs/TableRowAccordion/index.js +12 -37
- package/commonjs/TableRowAccordion/styles.js +2 -9
- package/commonjs/Tabs/index.js +16 -66
- package/commonjs/Tabs/styles.js +2 -11
- package/commonjs/Text/index.js +12 -25
- package/commonjs/Text/styles.js +1 -6
- package/commonjs/Textarea/index.js +31 -55
- package/commonjs/Textarea/styles.js +2 -9
- package/commonjs/ThemeProvider/index.js +1 -10
- package/commonjs/Toast/index.js +19 -42
- package/commonjs/Toast/styles.js +1 -7
- package/commonjs/ToggleHint/index.js +15 -39
- package/commonjs/ToggleHint/styles.js +2 -9
- package/commonjs/Token/index.js +15 -29
- package/commonjs/Token/styles.js +5 -12
- package/commonjs/TokenInput/index.js +70 -122
- package/commonjs/TokenInput/styles.js +1 -7
- package/commonjs/TokenInput/util.js +2 -7
- package/commonjs/Tooltip/index.js +40 -63
- package/commonjs/Tooltip/styles.js +1 -5
- package/commonjs/VisuallyHidden/index.js +0 -4
- package/commonjs/dataviz/index.js +0 -4
- package/commonjs/index.js +0 -129
- package/commonjs/systemProps/background.js +0 -1
- package/commonjs/systemProps/border.js +0 -1
- package/commonjs/systemProps/color.js +0 -1
- package/commonjs/systemProps/custom.js +0 -1
- package/commonjs/systemProps/flexbox.js +0 -1
- package/commonjs/systemProps/grid.js +0 -1
- package/commonjs/systemProps/index.js +0 -28
- package/commonjs/systemProps/layout.js +0 -1
- package/commonjs/systemProps/position.js +0 -1
- package/commonjs/systemProps/shadow.js +0 -1
- package/commonjs/systemProps/space.js +1 -2
- package/commonjs/systemProps/systemProps.js +0 -13
- package/commonjs/systemProps/tests/types.flow.js +25 -22
- package/commonjs/systemProps/typography.js +0 -1
- package/commonjs/systemProps/variant.js +2 -3
- package/commonjs/themes/dark/dataviz-palette.js +20 -22
- package/commonjs/themes/dark/decorative-palettes.js +0 -2
- package/commonjs/themes/dark/theme.js +15 -29
- package/commonjs/themes/extendedThemes/sproutTheme/dark/theme.js +14 -9
- package/commonjs/themes/extendedThemes/sproutTheme/index.js +0 -5
- package/commonjs/themes/extendedThemes/sproutTheme/light/theme.js +14 -9
- package/commonjs/themes/light/dataviz-palette.js +20 -22
- package/commonjs/themes/light/decorative-palettes.js +0 -2
- package/commonjs/themes/light/literal-colors.js +132 -134
- package/commonjs/themes/light/theme.js +45 -61
- package/commonjs/types/system-props.flow.js +1 -1
- package/commonjs/types/theme.colors.flow.js +0 -2
- package/commonjs/types/theme.flow.js +0 -1
- package/commonjs/utils/a11yTest.js +3 -10
- package/commonjs/utils/chartColors.js +0 -1
- package/commonjs/utils/constants.js +1 -1
- package/commonjs/utils/dataQaLabelQueries.js +12 -21
- package/commonjs/utils/hooks.js +39 -70
- package/commonjs/utils/index.js +2 -9
- package/commonjs/utils/innerText.js +10 -14
- package/commonjs/utils/mixins.js +2 -7
- package/commonjs/utils/react-testing-library.js +4 -26
- package/commonjs/utils/responsiveProps/index.js +1 -11
- package/commonjs/utils/system-props.js +2 -5
- package/commonjs/utils/useInteractiveColor.js +6 -8
- package/dist/illustration.svg +1 -1
- package/dist/illustrationList.js +1 -1
- package/dist/themes/dark/theme.scss +2 -2
- package/dist/themes/extendedThemes/sproutTheme/dark/theme.scss +26 -2
- package/dist/themes/extendedThemes/sproutTheme/light/theme.scss +26 -2
- package/dist/themes/light/theme.scss +2 -2
- package/lib/Avatar/index.js +40 -47
- package/lib/Badge/constants.js +19 -15
- package/lib/Badge/index.js +18 -25
- package/lib/Badge/styles.js +8 -6
- package/lib/Banner/index.js +20 -32
- package/lib/Banner/styles.js +3 -2
- package/lib/Box/index.js +4 -5
- package/lib/Box/styles.js +3 -2
- package/lib/Breadcrumb/index.js +19 -27
- package/lib/Breadcrumb/styles.js +3 -2
- package/lib/Button/index.js +31 -38
- package/lib/Button/styles.js +14 -11
- package/lib/Card/index.js +18 -24
- package/lib/Card/styles.js +5 -4
- package/lib/CharacterCounter/index.js +8 -20
- package/lib/CharacterCounter/styles.js +3 -2
- package/lib/ChartLegend/index.js +9 -17
- package/lib/ChartLegend/styles.js +5 -4
- package/lib/Checkbox/index.js +32 -51
- package/lib/Checkbox/styles.js +21 -26
- package/lib/Collapsible/index.js +36 -51
- package/lib/Collapsible/styles.js +6 -5
- package/lib/DatePicker/DateRangePicker.js +8 -14
- package/lib/DatePicker/SingleDatePicker.js +7 -13
- package/lib/DatePicker/StatefulDateRangePicker.js +19 -26
- package/lib/DatePicker/StatefulSingleDatePicker.js +9 -15
- package/lib/DatePicker/common.js +14 -13
- package/lib/DatePicker/index.js +2 -2
- package/lib/DatePicker/styles.js +12 -22
- package/lib/Drawer/SlideTransition.js +11 -14
- package/lib/Drawer/index.js +64 -88
- package/lib/Drawer/styles.js +4 -3
- package/lib/EmptyState/index.js +11 -17
- package/lib/Fieldset/index.js +19 -29
- package/lib/Fieldset/styles.js +5 -4
- package/lib/FormField/index.js +27 -33
- package/lib/Icon/deprecatedIcons.js +36 -36
- package/lib/Icon/index.js +25 -34
- package/lib/Icon/styles.js +12 -16
- package/lib/IllustrationViewBoxes.js +1 -0
- package/lib/Image/index.js +15 -38
- package/lib/Image/styles.js +4 -4
- package/lib/Indicator/index.js +11 -23
- package/lib/Indicator/styles.js +5 -5
- package/lib/Input/index.js +87 -115
- package/lib/Input/styles.js +13 -15
- package/lib/KeyboardKey/index.js +6 -17
- package/lib/KeyboardKey/styles.js +3 -2
- package/lib/Label/index.js +10 -24
- package/lib/Link/constants.js +5 -4
- package/lib/Link/index.js +18 -25
- package/lib/Link/styles.js +6 -5
- package/lib/Listbox/index.js +21 -29
- package/lib/Loader/index.js +17 -29
- package/lib/Loader/styles.js +6 -8
- package/lib/LoaderButton/index.js +45 -34
- package/lib/Menu/constants.js +10 -8
- package/lib/Menu/descendants.js +73 -94
- package/lib/Menu/hooks.js +28 -39
- package/lib/Menu/index.flow.js +6 -5
- package/lib/Menu/index.js +113 -150
- package/lib/Menu/names.js +1 -1
- package/lib/Menu/styles.js +4 -3
- package/lib/Message/index.js +42 -66
- package/lib/Message/styles.js +15 -23
- package/lib/Modal/index.js +38 -51
- package/lib/Modal/styles.js +23 -32
- package/lib/Numeral/index.js +45 -64
- package/lib/Numeral/styles.js +3 -2
- package/lib/Numeral/tests/testNumeral.js +17 -27
- package/lib/OverflowList/index.flow.js +2 -1
- package/lib/OverflowList/index.js +31 -38
- package/lib/OverflowList/styles.js +5 -4
- package/lib/PartnerLogo/index.js +26 -35
- package/lib/PartnerLogo/styles.js +11 -14
- package/lib/Popout/index.js +105 -121
- package/lib/Popout/styles.js +3 -3
- package/lib/Portal/index.js +11 -29
- package/lib/Radio/index.js +20 -40
- package/lib/Radio/styles.js +14 -14
- package/lib/SegmentedControl/index.js +21 -34
- package/lib/SegmentedControl/styles.js +7 -9
- package/lib/Select/index.js +27 -44
- package/lib/Select/styles.js +16 -20
- package/lib/Skeleton/index.js +7 -4
- package/lib/SpotIllustration/illustrationNames.js +2 -1
- package/lib/SpotIllustration/index.js +9 -10
- package/lib/Stack/index.js +31 -39
- package/lib/Switch/index.js +21 -39
- package/lib/Switch/styles.js +8 -7
- package/lib/Table/index.js +30 -40
- package/lib/Table/styles.js +3 -2
- package/lib/TableCell/index.js +14 -27
- package/lib/TableCell/styles.js +3 -3
- package/lib/TableHeaderCell/index.js +30 -52
- package/lib/TableHeaderCell/styles.js +3 -2
- package/lib/TableRowAccordion/index.js +16 -34
- package/lib/TableRowAccordion/styles.js +5 -3
- package/lib/Tabs/index.js +18 -63
- package/lib/Tabs/styles.js +6 -6
- package/lib/Text/index.js +15 -21
- package/lib/Text/styles.js +4 -3
- package/lib/Textarea/index.js +33 -53
- package/lib/Textarea/styles.js +6 -5
- package/lib/ThemeProvider/index.js +4 -7
- package/lib/Toast/index.js +26 -37
- package/lib/Toast/styles.js +5 -4
- package/lib/ToggleHint/index.js +18 -36
- package/lib/ToggleHint/styles.js +6 -5
- package/lib/Token/index.js +20 -26
- package/lib/Token/styles.js +10 -9
- package/lib/TokenInput/index.js +78 -118
- package/lib/TokenInput/styles.js +5 -4
- package/lib/TokenInput/util.js +5 -3
- package/lib/Tooltip/index.js +45 -60
- package/lib/Tooltip/styles.js +4 -4
- package/lib/VisuallyHidden/index.js +3 -2
- package/lib/dataviz/index.js +4 -3
- package/lib/index.js +66 -64
- package/lib/systemProps/background.js +3 -1
- package/lib/systemProps/border.js +3 -1
- package/lib/systemProps/color.js +3 -1
- package/lib/systemProps/custom.js +3 -1
- package/lib/systemProps/flexbox.js +3 -1
- package/lib/systemProps/grid.js +3 -1
- package/lib/systemProps/index.js +16 -14
- package/lib/systemProps/layout.js +3 -1
- package/lib/systemProps/position.js +3 -1
- package/lib/systemProps/shadow.js +3 -1
- package/lib/systemProps/space.js +2 -1
- package/lib/systemProps/systemProps.js +14 -13
- package/lib/systemProps/tests/types.flow.js +27 -22
- package/lib/systemProps/typography.js +3 -1
- package/lib/systemProps/variant.js +4 -3
- package/lib/themes/dark/dataviz-palette.js +23 -21
- package/lib/themes/dark/decorative-palettes.js +3 -1
- package/lib/themes/dark/theme.js +22 -25
- package/lib/themes/extendedThemes/sproutTheme/dark/theme.js +16 -7
- package/lib/themes/extendedThemes/sproutTheme/index.js +3 -2
- package/lib/themes/extendedThemes/sproutTheme/light/theme.js +16 -7
- package/lib/themes/light/dataviz-palette.js +23 -21
- package/lib/themes/light/decorative-palettes.js +3 -1
- package/lib/themes/light/literal-colors.js +135 -133
- package/lib/themes/light/theme.js +56 -57
- package/lib/types/system-props.flow.js +1 -1
- package/lib/types/theme.colors.flow.js +4 -2
- package/lib/types/theme.flow.js +3 -2
- package/lib/utils/a11yTest.js +5 -8
- package/lib/utils/chartColors.js +3 -1
- package/lib/utils/constants.js +3 -1
- package/lib/utils/dataQaLabelQueries.js +13 -21
- package/lib/utils/hooks.js +41 -64
- package/lib/utils/index.js +2 -5
- package/lib/utils/innerText.js +12 -14
- package/lib/utils/mixins.js +6 -5
- package/lib/utils/react-testing-library.js +10 -20
- package/lib/utils/responsiveProps/index.js +3 -8
- package/lib/utils/system-props.js +4 -3
- package/lib/utils/useInteractiveColor.js +10 -9
- package/package.json +6 -13
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import React from
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import ChartLegend from
|
|
6
|
-
import {
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {render} from '../utils/react-testing-library';
|
|
4
|
+
import 'jest-styled-components';
|
|
5
|
+
import ChartLegend from './';
|
|
6
|
+
import {CONTRAST_THEME, COMPARE_THEME} from '../utils/chartColors';
|
|
7
7
|
|
|
8
|
-
describe(
|
|
9
|
-
let legendLabelsArray = [{
|
|
8
|
+
describe('ChartLegend', () => {
|
|
9
|
+
let legendLabelsArray = [{name: 'Label One'}, {name: 'Label Two'}];
|
|
10
10
|
|
|
11
|
-
it(
|
|
12
|
-
const {
|
|
11
|
+
it('should render labels', () => {
|
|
12
|
+
const {getByText, getAllByDataQaLabel} = render(
|
|
13
13
|
<ChartLegend legendLabels={legendLabelsArray} />
|
|
14
14
|
);
|
|
15
|
-
expect(getAllByDataQaLabel({
|
|
16
|
-
expect(getByText(
|
|
17
|
-
expect(getByText(
|
|
15
|
+
expect(getAllByDataQaLabel({chartlegend: ''}).length).toEqual(1);
|
|
16
|
+
expect(getByText('Label One')).toBeTruthy();
|
|
17
|
+
expect(getByText('Label Two')).toBeTruthy();
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
it(
|
|
21
|
-
const {
|
|
20
|
+
it('should render the correct theme', () => {
|
|
21
|
+
const {getAllByDataQaLabel} = render(
|
|
22
22
|
<ChartLegend legendLabels={legendLabelsArray} theme="contrast" />
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
expect(getAllByDataQaLabel({
|
|
26
|
-
|
|
25
|
+
expect(getAllByDataQaLabel({swatch: ''})[0]).toHaveStyleRule(
|
|
26
|
+
'background-color',
|
|
27
27
|
CONTRAST_THEME[0]
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
expect(getAllByDataQaLabel({
|
|
31
|
-
|
|
30
|
+
expect(getAllByDataQaLabel({swatch: ''})[1]).toHaveStyleRule(
|
|
31
|
+
'background-color',
|
|
32
32
|
CONTRAST_THEME[1]
|
|
33
33
|
);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
it(
|
|
36
|
+
it('should display a custom color', () => {
|
|
37
37
|
const newLegendLabelsArray = [
|
|
38
|
-
{
|
|
39
|
-
{
|
|
38
|
+
{name: 'Label One', color: '#000'},
|
|
39
|
+
{name: 'Label Two'},
|
|
40
40
|
];
|
|
41
|
-
const {
|
|
41
|
+
const {getAllByDataQaLabel} = render(
|
|
42
42
|
<ChartLegend legendLabels={newLegendLabelsArray} />
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
expect(getAllByDataQaLabel({
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
expect(getAllByDataQaLabel({swatch: ''})[0]).toHaveStyleRule(
|
|
46
|
+
'background-color',
|
|
47
|
+
'#000'
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
expect(getAllByDataQaLabel({
|
|
51
|
-
|
|
50
|
+
expect(getAllByDataQaLabel({swatch: ''})[1]).toHaveStyleRule(
|
|
51
|
+
'background-color',
|
|
52
52
|
COMPARE_THEME[1]
|
|
53
53
|
);
|
|
54
54
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//@flow
|
|
2
|
-
import styled, {
|
|
3
|
-
import {
|
|
2
|
+
import styled, {css, type StyledComponent} from 'styled-components';
|
|
3
|
+
import {COMMON, LAYOUT} from '../utils/system-props';
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {TypeTheme} from '../types/theme.flow';
|
|
6
6
|
|
|
7
|
-
export const Label: StyledComponent<{
|
|
7
|
+
export const Label: StyledComponent<{...}, TypeTheme, *> = styled.span`
|
|
8
8
|
display: flex;
|
|
9
9
|
align-items: center;
|
|
10
10
|
color: ${(props) => props.theme.colors.text.subtext};
|
|
@@ -12,7 +12,7 @@ export const Label: StyledComponent<{ ... }, TypeTheme, *> = styled.span`
|
|
|
12
12
|
text-transform: capitalize;
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
|
-
export const Swatch: StyledComponent<{
|
|
15
|
+
export const Swatch: StyledComponent<{...}, TypeTheme, *> = styled.span`
|
|
16
16
|
margin-right: ${(props) => props.theme.space[300]};
|
|
17
17
|
width: ${(props) => props.theme.space[350]};
|
|
18
18
|
height: ${(props) => props.theme.space[350]};
|
|
@@ -37,7 +37,7 @@ const Container: StyledComponent<any, TypeTheme, *> = styled.div`
|
|
|
37
37
|
${LAYOUT}
|
|
38
38
|
`;
|
|
39
39
|
|
|
40
|
-
Label.displayName =
|
|
41
|
-
Swatch.displayName =
|
|
40
|
+
Label.displayName = 'ChartLegendLabel';
|
|
41
|
+
Swatch.displayName = 'ChartLegendSwatch';
|
|
42
42
|
|
|
43
43
|
export default Container;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import * as React from
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import Container, {
|
|
4
4
|
CheckboxBox,
|
|
5
5
|
CheckIcon,
|
|
@@ -7,7 +7,7 @@ import Container, {
|
|
|
7
7
|
InputWrapper,
|
|
8
8
|
LabelText,
|
|
9
9
|
CheckboxContainer,
|
|
10
|
-
} from
|
|
10
|
+
} from './styles';
|
|
11
11
|
|
|
12
12
|
export type TypeProps = {
|
|
13
13
|
/** ID of the form element, should match the "for" value of the associated label */
|
|
@@ -23,7 +23,7 @@ export type TypeProps = {
|
|
|
23
23
|
indeterminate?: boolean,
|
|
24
24
|
disabled?: boolean,
|
|
25
25
|
onChange: (event: SyntheticEvent<HTMLInputElement>) => void,
|
|
26
|
-
appearance?:
|
|
26
|
+
appearance?: 'pill' | 'default',
|
|
27
27
|
qa?: Object,
|
|
28
28
|
tabIndex?: string | number,
|
|
29
29
|
inputProps?: Object,
|
|
@@ -66,19 +66,19 @@ export default class Checkbox extends React.Component<TypeProps> {
|
|
|
66
66
|
indeterminate,
|
|
67
67
|
onChange,
|
|
68
68
|
ariaLabel,
|
|
69
|
-
appearance =
|
|
69
|
+
appearance = 'default',
|
|
70
70
|
qa = {},
|
|
71
71
|
tabIndex,
|
|
72
72
|
inputProps = {},
|
|
73
73
|
...rest
|
|
74
74
|
} = this.props;
|
|
75
|
-
const isPill = appearance ===
|
|
75
|
+
const isPill = appearance === 'pill';
|
|
76
76
|
|
|
77
77
|
// TODO: Refactor pill checkboxes to use fewer elements for performance gains
|
|
78
78
|
if (!isPill) {
|
|
79
79
|
return (
|
|
80
80
|
<CheckboxContainer
|
|
81
|
-
as={label &&
|
|
81
|
+
as={label && 'label'}
|
|
82
82
|
disabled={disabled}
|
|
83
83
|
indeterminate={indeterminate}
|
|
84
84
|
checked={checked}
|
|
@@ -97,7 +97,7 @@ export default class Checkbox extends React.Component<TypeProps> {
|
|
|
97
97
|
onChange={this.handleChange}
|
|
98
98
|
data-qa-checkbox={id}
|
|
99
99
|
data-qa-checkbox-ischecked={
|
|
100
|
-
indeterminate ?
|
|
100
|
+
indeterminate ? 'indeterminate' : checked === true
|
|
101
101
|
}
|
|
102
102
|
data-qa-checkbox-isdisabled={disabled === true}
|
|
103
103
|
tabIndex={tabIndex}
|
|
@@ -115,7 +115,7 @@ export default class Checkbox extends React.Component<TypeProps> {
|
|
|
115
115
|
|
|
116
116
|
return (
|
|
117
117
|
// $FlowIssue - upgrade v0.112.0
|
|
118
|
-
<Container as={label &&
|
|
118
|
+
<Container as={label && 'label'} {...rest}>
|
|
119
119
|
<InputWrapper appearance={appearance}>
|
|
120
120
|
<PillInput
|
|
121
121
|
type="checkbox"
|
|
@@ -129,7 +129,7 @@ export default class Checkbox extends React.Component<TypeProps> {
|
|
|
129
129
|
onChange={this.handleChange}
|
|
130
130
|
data-qa-checkbox={id}
|
|
131
131
|
data-qa-checkbox-ischecked={
|
|
132
|
-
indeterminate ?
|
|
132
|
+
indeterminate ? 'indeterminate' : checked === true
|
|
133
133
|
}
|
|
134
134
|
data-qa-checkbox-isdisabled={disabled === true}
|
|
135
135
|
tabIndex={tabIndex}
|
|
@@ -138,7 +138,7 @@ export default class Checkbox extends React.Component<TypeProps> {
|
|
|
138
138
|
/>
|
|
139
139
|
<CheckboxBox>
|
|
140
140
|
<CheckIcon
|
|
141
|
-
name={indeterminate ?
|
|
141
|
+
name={indeterminate ? 'minus' : 'check'}
|
|
142
142
|
size="mini"
|
|
143
143
|
fixedWidth
|
|
144
144
|
/>
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import React from
|
|
3
|
-
import {
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {action} from '@storybook/addon-actions';
|
|
4
4
|
|
|
5
|
-
import Checkbox, {
|
|
5
|
+
import Checkbox, {type TypeProps} from './';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
|
-
title:
|
|
8
|
+
title: 'Components/Checkbox',
|
|
9
9
|
component: Checkbox,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const Checked = (args: TypeProps) => <Checkbox {...args} />;
|
|
13
13
|
|
|
14
|
-
Checked.args = {
|
|
14
|
+
Checked.args = {checked: true};
|
|
15
15
|
|
|
16
16
|
export const Unchecked = (args: TypeProps) => <Checkbox {...args} />;
|
|
17
17
|
|
|
18
|
-
Unchecked.args = {
|
|
18
|
+
Unchecked.args = {checked: false};
|
|
19
19
|
|
|
20
20
|
export const PillChecked = (args: TypeProps) => <Checkbox {...args} />;
|
|
21
21
|
|
|
22
22
|
PillChecked.args = {
|
|
23
23
|
checked: true,
|
|
24
|
-
appearance:
|
|
24
|
+
appearance: 'pill',
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
PillChecked.story = {
|
|
28
|
-
name:
|
|
28
|
+
name: 'Pill/Checked',
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export const PillUnchecked = (args: TypeProps) => <Checkbox {...args} />;
|
|
32
32
|
|
|
33
33
|
PillUnchecked.args = {
|
|
34
34
|
checked: false,
|
|
35
|
-
appearance:
|
|
35
|
+
appearance: 'pill',
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
PillUnchecked.story = {
|
|
39
|
-
name:
|
|
39
|
+
name: 'Pill/Unchecked',
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export const DisabledChecked = (args: TypeProps) => <Checkbox {...args} />;
|
|
@@ -47,7 +47,7 @@ DisabledChecked.args = {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
DisabledChecked.story = {
|
|
50
|
-
name:
|
|
50
|
+
name: 'Disabled/Checked',
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
export const DisabledUnchecked = (args: TypeProps) => <Checkbox {...args} />;
|
|
@@ -58,7 +58,7 @@ DisabledUnchecked.args = {
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
DisabledUnchecked.story = {
|
|
61
|
-
name:
|
|
61
|
+
name: 'Disabled/Unchecked',
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
export const IndeterminateChecked = (args: TypeProps) => <Checkbox {...args} />;
|
|
@@ -69,7 +69,7 @@ IndeterminateChecked.args = {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
IndeterminateChecked.story = {
|
|
72
|
-
name:
|
|
72
|
+
name: 'Indeterminate/Checked',
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
export const IndeterminateUnchecked = (args: TypeProps) => (
|
|
@@ -82,29 +82,29 @@ IndeterminateUnchecked.args = {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
IndeterminateUnchecked.story = {
|
|
85
|
-
name:
|
|
85
|
+
name: 'Indeterminate/Unchecked',
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
export const LabelledChecked = (args: TypeProps) => <Checkbox {...args} />;
|
|
89
89
|
|
|
90
90
|
LabelledChecked.args = {
|
|
91
91
|
checked: true,
|
|
92
|
-
label:
|
|
92
|
+
label: 'Labelled checkbox',
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
LabelledChecked.story = {
|
|
96
|
-
name:
|
|
96
|
+
name: 'Labelled/Checked',
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
export const LabelledUnchecked = (args: TypeProps) => <Checkbox {...args} />;
|
|
100
100
|
|
|
101
101
|
LabelledUnchecked.args = {
|
|
102
102
|
checked: false,
|
|
103
|
-
label:
|
|
103
|
+
label: 'Labelled checkbox',
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
LabelledUnchecked.story = {
|
|
107
|
-
name:
|
|
107
|
+
name: 'Labelled/Unchecked',
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
export const LabelledDisabled = (args: TypeProps) => <Checkbox {...args} />;
|
|
@@ -112,11 +112,11 @@ export const LabelledDisabled = (args: TypeProps) => <Checkbox {...args} />;
|
|
|
112
112
|
LabelledDisabled.args = {
|
|
113
113
|
checked: true,
|
|
114
114
|
disabled: true,
|
|
115
|
-
label:
|
|
115
|
+
label: 'Labelled checkbox',
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
LabelledDisabled.story = {
|
|
119
|
-
name:
|
|
119
|
+
name: 'Labelled/Disabled',
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
export const InputPropsOnMouseOver = (args: TypeProps) => (
|
|
@@ -125,13 +125,13 @@ export const InputPropsOnMouseOver = (args: TypeProps) => (
|
|
|
125
125
|
|
|
126
126
|
InputPropsOnMouseOver.args = {
|
|
127
127
|
checked: true,
|
|
128
|
-
label:
|
|
128
|
+
label: 'Labelled checkbox',
|
|
129
129
|
inputProps: {
|
|
130
|
-
onMouseOver: action(
|
|
131
|
-
onClick: action(
|
|
130
|
+
onMouseOver: action('checkbox-mouseOver'),
|
|
131
|
+
onClick: action('checkbox-click'),
|
|
132
132
|
},
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
InputPropsOnMouseOver.story = {
|
|
136
|
-
name:
|
|
136
|
+
name: 'InputProps/OnMouseOver',
|
|
137
137
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import React from
|
|
3
|
-
import {
|
|
4
|
-
import Checkbox from
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {render, fireEvent} from '../utils/react-testing-library';
|
|
4
|
+
import Checkbox from './';
|
|
5
5
|
|
|
6
6
|
const mockHandleClick = jest.fn();
|
|
7
7
|
|
|
8
|
-
describe(
|
|
9
|
-
it(
|
|
10
|
-
const {
|
|
8
|
+
describe('Checkbox', () => {
|
|
9
|
+
it('should render by default', async () => {
|
|
10
|
+
const {getByDataQaLabel, runA11yCheck} = render(
|
|
11
11
|
<Checkbox
|
|
12
12
|
checked
|
|
13
13
|
onChange={mockHandleClick}
|
|
@@ -15,12 +15,12 @@ describe("Checkbox", () => {
|
|
|
15
15
|
label="Check Me"
|
|
16
16
|
/>
|
|
17
17
|
);
|
|
18
|
-
expect(getByDataQaLabel({
|
|
18
|
+
expect(getByDataQaLabel({checkbox: 'checkboxid'})).toBeTruthy();
|
|
19
19
|
await runA11yCheck();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
it(
|
|
23
|
-
const {
|
|
22
|
+
it('should toggle to indeterminate', () => {
|
|
23
|
+
const {getByDataQaLabel} = render(
|
|
24
24
|
<Checkbox
|
|
25
25
|
checked
|
|
26
26
|
onChange={mockHandleClick}
|
|
@@ -29,28 +29,28 @@ describe("Checkbox", () => {
|
|
|
29
29
|
/>
|
|
30
30
|
);
|
|
31
31
|
expect(
|
|
32
|
-
getByDataQaLabel({
|
|
32
|
+
getByDataQaLabel({'checkbox-ischecked': 'indeterminate'})
|
|
33
33
|
).toBeTruthy();
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
it(
|
|
36
|
+
it('should fire callback with event', () => {
|
|
37
37
|
const mockHandleClick = jest.fn();
|
|
38
|
-
const {
|
|
38
|
+
const {getByDataQaLabel} = render(
|
|
39
39
|
<Checkbox checked onChange={mockHandleClick} id="checkboxid" />
|
|
40
40
|
);
|
|
41
|
-
fireEvent.click(getByDataQaLabel({
|
|
41
|
+
fireEvent.click(getByDataQaLabel({checkbox: 'checkboxid'}));
|
|
42
42
|
expect(mockHandleClick).toHaveBeenCalled();
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
it(
|
|
46
|
-
const {
|
|
45
|
+
it('should disabled the input when disabled === true', () => {
|
|
46
|
+
const {getByDataQaLabel} = render(
|
|
47
47
|
<Checkbox disabled onChange={mockHandleClick} id="checkboxid" />
|
|
48
48
|
);
|
|
49
|
-
expect(getByDataQaLabel({
|
|
49
|
+
expect(getByDataQaLabel({'checkbox-isdisabled': true})).toBeTruthy();
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
it(
|
|
53
|
-
const {
|
|
52
|
+
it('should display label when label not undefined and appearance is default', () => {
|
|
53
|
+
const {getByLabelText} = render(
|
|
54
54
|
<Checkbox
|
|
55
55
|
checked
|
|
56
56
|
onChange={mockHandleClick}
|
|
@@ -58,11 +58,11 @@ describe("Checkbox", () => {
|
|
|
58
58
|
id="checkboxid"
|
|
59
59
|
/>
|
|
60
60
|
);
|
|
61
|
-
expect(getByLabelText(
|
|
61
|
+
expect(getByLabelText('Checkbox Label')).toBeInTheDocument();
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
it(
|
|
65
|
-
const {
|
|
64
|
+
it('should not display label when label not undefined and appearance is pill', () => {
|
|
65
|
+
const {queryByLabelText} = render(
|
|
66
66
|
<Checkbox
|
|
67
67
|
checked
|
|
68
68
|
onChange={mockHandleClick}
|
|
@@ -71,21 +71,21 @@ describe("Checkbox", () => {
|
|
|
71
71
|
appearance="pill"
|
|
72
72
|
/>
|
|
73
73
|
);
|
|
74
|
-
expect(queryByLabelText(
|
|
74
|
+
expect(queryByLabelText('Checkbox Label')).not.toBeInTheDocument();
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
it(
|
|
77
|
+
it('should support events through inputProps', () => {
|
|
78
78
|
const mockHandleMouseOver = jest.fn();
|
|
79
79
|
const options = render(
|
|
80
80
|
<Checkbox
|
|
81
81
|
checked
|
|
82
82
|
onChange={mockHandleClick}
|
|
83
|
-
inputProps={{
|
|
83
|
+
inputProps={{onMouseOver: mockHandleMouseOver}}
|
|
84
84
|
id="checkboxid"
|
|
85
85
|
label="checkbox"
|
|
86
86
|
/>
|
|
87
87
|
);
|
|
88
|
-
fireEvent.mouseOver(options.getByLabelText(
|
|
88
|
+
fireEvent.mouseOver(options.getByLabelText('checkbox'));
|
|
89
89
|
expect(mockHandleMouseOver).toHaveBeenCalled();
|
|
90
90
|
});
|
|
91
91
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//@flow
|
|
2
|
-
import styled, {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import Box from
|
|
6
|
-
import Icon from
|
|
7
|
-
import Text from
|
|
2
|
+
import styled, {css, type StyledComponent} from 'styled-components';
|
|
3
|
+
import {COMMON} from '../utils/system-props';
|
|
4
|
+
import {focusRing, pill} from '../utils/mixins';
|
|
5
|
+
import Box from '../Box';
|
|
6
|
+
import Icon from '../Icon';
|
|
7
|
+
import Text from '../Text';
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type {TypeTheme} from '../types/theme.flow';
|
|
10
10
|
|
|
11
|
-
const Container: StyledComponent<{
|
|
11
|
+
const Container: StyledComponent<{...}, TypeTheme, *> = styled.span`
|
|
12
12
|
display: inline-flex;
|
|
13
13
|
align-items: center;
|
|
14
14
|
box-sizing: border-box;
|
|
@@ -16,9 +16,8 @@ const Container: StyledComponent<{ ... }, TypeTheme, *> = styled.span`
|
|
|
16
16
|
${COMMON}
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
|
-
Container.displayName =
|
|
19
|
+
Container.displayName = 'Checkbox';
|
|
20
20
|
|
|
21
|
-
// eslint-disable-next-line prettier/prettier
|
|
22
21
|
export const InputWrapper = styled<typeof Box, TypeTheme, any>(Box)`
|
|
23
22
|
box-sizing: border-box;
|
|
24
23
|
position: relative;
|
|
@@ -29,13 +28,13 @@ export const InputWrapper = styled<typeof Box, TypeTheme, any>(Box)`
|
|
|
29
28
|
justify-content: center;
|
|
30
29
|
|
|
31
30
|
${(props) =>
|
|
32
|
-
props.appearance ===
|
|
31
|
+
props.appearance === 'pill' &&
|
|
33
32
|
css`
|
|
34
33
|
background-color: transparent;
|
|
35
34
|
transition: all ${(props) => props.theme.duration.fast}
|
|
36
35
|
${(props) => props.theme.easing.ease_inout};
|
|
37
36
|
/* This solution is temporary. DS-1095 */
|
|
38
|
-
mix-blend-mode: ${props.theme.mode ===
|
|
37
|
+
mix-blend-mode: ${props.theme.mode === 'dark' ? 'screen' : 'multiply'};
|
|
39
38
|
${pill}
|
|
40
39
|
|
|
41
40
|
&:hover {
|
|
@@ -48,9 +47,9 @@ export const InputWrapper = styled<typeof Box, TypeTheme, any>(Box)`
|
|
|
48
47
|
`}
|
|
49
48
|
`;
|
|
50
49
|
|
|
51
|
-
InputWrapper.displayName =
|
|
50
|
+
InputWrapper.displayName = 'InputWrapper';
|
|
52
51
|
|
|
53
|
-
export const CheckboxBox: StyledComponent<{
|
|
52
|
+
export const CheckboxBox: StyledComponent<{...}, TypeTheme, *> = styled.div`
|
|
54
53
|
box-sizing: border-box;
|
|
55
54
|
position: relative;
|
|
56
55
|
width: ${(props) => props.theme.space[400]};
|
|
@@ -65,7 +64,7 @@ export const CheckboxBox: StyledComponent<{ ... }, TypeTheme, *> = styled.div`
|
|
|
65
64
|
pointer-events: none;
|
|
66
65
|
`;
|
|
67
66
|
|
|
68
|
-
CheckboxBox.displayName =
|
|
67
|
+
CheckboxBox.displayName = 'CheckboxBox';
|
|
69
68
|
|
|
70
69
|
export const CheckIcon = styled<typeof Icon, TypeTheme>(Icon)`
|
|
71
70
|
position: absolute;
|
|
@@ -88,7 +87,7 @@ export const CheckIcon = styled<typeof Icon, TypeTheme>(Icon)`
|
|
|
88
87
|
}
|
|
89
88
|
`;
|
|
90
89
|
|
|
91
|
-
CheckIcon.displayName =
|
|
90
|
+
CheckIcon.displayName = 'CheckIcon';
|
|
92
91
|
|
|
93
92
|
export const PillInput: StyledComponent<any, TypeTheme, *> = styled.input`
|
|
94
93
|
position: absolute;
|
|
@@ -98,7 +97,7 @@ export const PillInput: StyledComponent<any, TypeTheme, *> = styled.input`
|
|
|
98
97
|
height: 100%;
|
|
99
98
|
margin: 0;
|
|
100
99
|
appearance: none;
|
|
101
|
-
cursor: ${(props) => (props.disabled ?
|
|
100
|
+
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
|
102
101
|
border-radius: 4px;
|
|
103
102
|
|
|
104
103
|
/* IE 11 overrides */
|
|
@@ -147,13 +146,13 @@ export const PillInput: StyledComponent<any, TypeTheme, *> = styled.input`
|
|
|
147
146
|
`}
|
|
148
147
|
`;
|
|
149
148
|
|
|
150
|
-
PillInput.displayName =
|
|
149
|
+
PillInput.displayName = 'PillInput';
|
|
151
150
|
|
|
152
151
|
export const LabelText = styled<typeof Text, TypeTheme, any>(Text)`
|
|
153
152
|
margin-left: ${(props) => props.theme.space[300]};
|
|
154
153
|
font-size: ${(props) => props.theme.typography[200].fontSize};
|
|
155
154
|
line-height: 1;
|
|
156
|
-
cursor: ${(props) => (props.disabled ?
|
|
155
|
+
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
|
157
156
|
color: ${(props) => props.theme.colors.text.headline};
|
|
158
157
|
|
|
159
158
|
${(props) =>
|
|
@@ -163,7 +162,7 @@ export const LabelText = styled<typeof Text, TypeTheme, any>(Text)`
|
|
|
163
162
|
`}
|
|
164
163
|
`;
|
|
165
164
|
|
|
166
|
-
LabelText.displayName =
|
|
165
|
+
LabelText.displayName = 'LabelText';
|
|
167
166
|
|
|
168
167
|
const checkSVG = (color) =>
|
|
169
168
|
`<svg width='14' height='14' xmlns='http://www.w3.org/2000/svg'><path d='M5.378 11.37L2 7.59l1.438-1.286L5.374 8.47l5.185-5.84L12 3.91l-6.622 7.46' fill='${color}'/></svg>`;
|
|
@@ -172,16 +171,16 @@ const indeterminateSVG = (color) =>
|
|
|
172
171
|
`<svg width='14' height='14' xmlns='http://www.w3.org/2000/svg'><rect width='10' height='2' x='2' y='6' rx='1' ry='1' fill='${color}'/></svg>`;
|
|
173
172
|
|
|
174
173
|
const getIcon = (type, color) => {
|
|
175
|
-
const escapedColor = color.replace(
|
|
174
|
+
const escapedColor = color.replace('#', '%23');
|
|
176
175
|
const icon =
|
|
177
|
-
type ===
|
|
176
|
+
type === 'indeterminate'
|
|
178
177
|
? indeterminateSVG(escapedColor)
|
|
179
178
|
: checkSVG(escapedColor);
|
|
180
179
|
return icon;
|
|
181
180
|
};
|
|
182
181
|
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
export const CheckboxContainer: StyledComponent<any, TypeTheme, *> =
|
|
183
|
+
styled.span(
|
|
185
184
|
(props) => css`
|
|
186
185
|
display: inline-flex;
|
|
187
186
|
align-items: center;
|
|
@@ -192,13 +191,13 @@ export const CheckboxContainer: StyledComponent<any, TypeTheme, *> = styled.span
|
|
|
192
191
|
@supports (-webkit-appearance: none) {
|
|
193
192
|
&:before {
|
|
194
193
|
/* stylelint-disable */
|
|
195
|
-
content: url(
|
|
196
|
-
props.indeterminate ?
|
|
194
|
+
content: url('data:image/svg+xml;utf8,${getIcon(
|
|
195
|
+
props.indeterminate ? 'indeterminate' : 'check',
|
|
197
196
|
|
|
198
197
|
props.checked
|
|
199
198
|
? props.theme.colors.form.background.base
|
|
200
199
|
: props.theme.colors.form.border.base
|
|
201
|
-
)}
|
|
200
|
+
)}');
|
|
202
201
|
opacity: ${props.checked ? 1 : 0};
|
|
203
202
|
position: absolute;
|
|
204
203
|
width: ${props.theme.space[400]};
|
|
@@ -233,7 +232,7 @@ export const CheckboxContainer: StyledComponent<any, TypeTheme, *> = styled.span
|
|
|
233
232
|
background-color: ${props.theme.colors.form.background.base};
|
|
234
233
|
transition: all ${props.theme.duration.fast}
|
|
235
234
|
${props.theme.easing.ease_in};
|
|
236
|
-
cursor: ${props.disabled ?
|
|
235
|
+
cursor: ${props.disabled ? 'not-allowed' : 'pointer'};
|
|
237
236
|
flex-shrink: 0;
|
|
238
237
|
|
|
239
238
|
&:not(:checked) {
|