@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,16 +1,16 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import
|
|
3
|
-
import React from
|
|
4
|
-
import {
|
|
5
|
-
import Modal from
|
|
6
|
-
import {
|
|
2
|
+
import 'jest-styled-components';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {render, fireEvent, cleanup} from '../utils/react-testing-library';
|
|
5
|
+
import Modal from './';
|
|
6
|
+
import {COLOR_PURPLE_300} from '@sproutsocial/seeds-color';
|
|
7
7
|
|
|
8
8
|
afterEach(() => cleanup());
|
|
9
9
|
|
|
10
|
-
describe(
|
|
11
|
-
it(
|
|
10
|
+
describe('Modal', () => {
|
|
11
|
+
it('renders a custom background color', () => {
|
|
12
12
|
// Use baseElement since it renders in a Portal
|
|
13
|
-
const {
|
|
13
|
+
const {baseElement} = render(
|
|
14
14
|
<Modal
|
|
15
15
|
isOpen={true}
|
|
16
16
|
label="Label"
|
|
@@ -21,15 +21,15 @@ describe("Modal", () => {
|
|
|
21
21
|
ajdsfljasdlfjlasdjf
|
|
22
22
|
</Modal>
|
|
23
23
|
);
|
|
24
|
-
expect(baseElement.querySelector(
|
|
25
|
-
|
|
24
|
+
expect(baseElement.querySelector('.ReactModal__Content')).toHaveStyleRule(
|
|
25
|
+
'background-color',
|
|
26
26
|
COLOR_PURPLE_300
|
|
27
27
|
);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it(
|
|
30
|
+
it('should close on overlay click and esc', () => {
|
|
31
31
|
const onClose = jest.fn();
|
|
32
|
-
const {
|
|
32
|
+
const {baseElement, getByText, getByLabelText} = render(
|
|
33
33
|
<Modal
|
|
34
34
|
isOpen={true}
|
|
35
35
|
label="Label"
|
|
@@ -44,24 +44,24 @@ describe("Modal", () => {
|
|
|
44
44
|
</Modal>
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
-
fireEvent.click(baseElement.querySelector(
|
|
47
|
+
fireEvent.click(baseElement.querySelector('.ReactModal__Overlay'));
|
|
48
48
|
expect(onClose).toHaveBeenCalled();
|
|
49
49
|
|
|
50
50
|
onClose.mockClear();
|
|
51
|
-
fireEvent.keyDown(getByText(
|
|
52
|
-
key:
|
|
51
|
+
fireEvent.keyDown(getByText('ajdsfljasdlfjlasdjf'), {
|
|
52
|
+
key: 'Escape',
|
|
53
53
|
keyCode: 27,
|
|
54
54
|
});
|
|
55
55
|
expect(onClose).toHaveBeenCalled();
|
|
56
56
|
|
|
57
57
|
onClose.mockClear();
|
|
58
|
-
fireEvent.click(getByLabelText(
|
|
58
|
+
fireEvent.click(getByLabelText('Close this dialog'));
|
|
59
59
|
expect(onClose).toHaveBeenCalled();
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
it(
|
|
62
|
+
it('should NOT close on overlay click and esc if onClick is not provided', () => {
|
|
63
63
|
const onClose = jest.fn();
|
|
64
|
-
const {
|
|
64
|
+
const {baseElement, getByText, queryByLabelText} = render(
|
|
65
65
|
<Modal
|
|
66
66
|
isOpen={true}
|
|
67
67
|
label="Label"
|
|
@@ -72,22 +72,22 @@ describe("Modal", () => {
|
|
|
72
72
|
</Modal>
|
|
73
73
|
);
|
|
74
74
|
|
|
75
|
-
expect(queryByLabelText(
|
|
75
|
+
expect(queryByLabelText('Close this dialog')).toBe(null);
|
|
76
76
|
|
|
77
|
-
fireEvent.click(baseElement.querySelector(
|
|
77
|
+
fireEvent.click(baseElement.querySelector('.ReactModal__Overlay'));
|
|
78
78
|
expect(onClose).not.toHaveBeenCalled();
|
|
79
79
|
|
|
80
80
|
onClose.mockClear();
|
|
81
|
-
fireEvent.keyDown(getByText(
|
|
82
|
-
key:
|
|
81
|
+
fireEvent.keyDown(getByText('ajdsfljasdlfjlasdjf'), {
|
|
82
|
+
key: 'Escape',
|
|
83
83
|
keyCode: 27,
|
|
84
84
|
});
|
|
85
85
|
expect(onClose).not.toHaveBeenCalled();
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
describe(
|
|
89
|
-
it(
|
|
90
|
-
const {
|
|
88
|
+
describe('Modal.Header', () => {
|
|
89
|
+
it('should have an aria-label on the close button', () => {
|
|
90
|
+
const {getByLabelText} = render(
|
|
91
91
|
<Modal
|
|
92
92
|
isOpen={true}
|
|
93
93
|
label="Label"
|
|
@@ -102,12 +102,12 @@ describe("Modal", () => {
|
|
|
102
102
|
</Modal>
|
|
103
103
|
);
|
|
104
104
|
|
|
105
|
-
expect(getByLabelText(
|
|
105
|
+
expect(getByLabelText('Close this dialog')).toBeTruthy();
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
it(
|
|
108
|
+
it('should accept the onClose handler from ModalContext', () => {
|
|
109
109
|
const onClose = jest.fn();
|
|
110
|
-
const {
|
|
110
|
+
const {getByLabelText} = render(
|
|
111
111
|
<Modal
|
|
112
112
|
isOpen={true}
|
|
113
113
|
label="Label"
|
|
@@ -122,7 +122,7 @@ describe("Modal", () => {
|
|
|
122
122
|
</Modal>
|
|
123
123
|
);
|
|
124
124
|
|
|
125
|
-
fireEvent.click(getByLabelText(
|
|
125
|
+
fireEvent.click(getByLabelText('Close this dialog'));
|
|
126
126
|
expect(onClose).toHaveBeenCalled();
|
|
127
127
|
});
|
|
128
128
|
});
|
package/__flow__/Modal/styles.js
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import React from
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import styled, {
|
|
4
4
|
createGlobalStyle,
|
|
5
5
|
type StyledComponent,
|
|
6
|
-
} from
|
|
7
|
-
import {
|
|
8
|
-
import ReactModal from
|
|
9
|
-
import Box from
|
|
10
|
-
import {
|
|
6
|
+
} from 'styled-components';
|
|
7
|
+
import {width, zIndex} from 'styled-system';
|
|
8
|
+
import ReactModal from 'react-modal';
|
|
9
|
+
import Box from '../Box';
|
|
10
|
+
import {COMMON} from '../utils/system-props';
|
|
11
11
|
|
|
12
|
-
import type {
|
|
12
|
+
import type {TypeTheme} from '../types/theme.flow';
|
|
13
13
|
|
|
14
14
|
// This is the max space allowed between the modal and the edge of the browser
|
|
15
|
-
const BODY_PADDING =
|
|
16
|
-
|
|
17
|
-
function ReactModalAdapter({
|
|
18
|
-
className,
|
|
19
|
-
...props
|
|
20
|
-
}: {
|
|
21
|
-
className?: string,
|
|
22
|
-
...
|
|
23
|
-
}) {
|
|
15
|
+
const BODY_PADDING = '64px';
|
|
16
|
+
|
|
17
|
+
function ReactModalAdapter({className, ...props}: {className?: string, ...}) {
|
|
24
18
|
// We want to create *__Content and *__Overlay class names on the subcomponents.
|
|
25
19
|
// Because `className` could be a space-separated list of class names, we make
|
|
26
20
|
// sure that we append `__Content` and `__Overlay` to every class name.
|
|
27
|
-
const contentClassName = (className ||
|
|
28
|
-
.split(
|
|
21
|
+
const contentClassName = (className || '')
|
|
22
|
+
.split(' ')
|
|
29
23
|
.map((className) => `${className} ${className}__Content`)
|
|
30
|
-
.join(
|
|
31
|
-
const overlayClassName = (className ||
|
|
32
|
-
.split(
|
|
24
|
+
.join(' ');
|
|
25
|
+
const overlayClassName = (className || '')
|
|
26
|
+
.split(' ')
|
|
33
27
|
.map((className) => `${className} ${className}__Overlay`)
|
|
34
|
-
.join(
|
|
28
|
+
.join(' ');
|
|
35
29
|
|
|
36
30
|
return (
|
|
37
31
|
<ReactModal
|
|
@@ -50,8 +44,9 @@ export const Body = createGlobalStyle`
|
|
|
50
44
|
}
|
|
51
45
|
`;
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
export const Container: StyledComponent<any, TypeTheme, *> = styled(
|
|
48
|
+
ReactModalAdapter
|
|
49
|
+
)`
|
|
55
50
|
&__Overlay {
|
|
56
51
|
position: fixed;
|
|
57
52
|
top: 0px;
|
|
@@ -116,22 +111,22 @@ export const Content = styled<typeof Box, TypeTheme>(Box)`
|
|
|
116
111
|
}
|
|
117
112
|
`;
|
|
118
113
|
|
|
119
|
-
// eslint-disable-next-line prettier/prettier
|
|
120
114
|
export const HeaderContainer = styled<typeof Box, TypeTheme>(Box)`
|
|
121
115
|
font-family: ${(props) => props.theme.fontFamily};
|
|
122
116
|
padding: ${(props) => props.theme.space[400]}
|
|
123
117
|
${(props) => props.theme.space[450]};
|
|
124
118
|
`;
|
|
125
119
|
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
export const Header = styled<typeof HeaderContainer, TypeTheme, any>(
|
|
121
|
+
HeaderContainer
|
|
122
|
+
)`
|
|
128
123
|
display: flex;
|
|
129
124
|
align-items: center;
|
|
130
125
|
justify-content: space-between;
|
|
131
126
|
flex: 0 0 auto;
|
|
132
127
|
border-bottom-width: ${(props) => props.theme.borderWidths[500]};
|
|
133
128
|
border-bottom-color: ${(props) =>
|
|
134
|
-
props.bordered ? props.theme.colors.container.border.base :
|
|
129
|
+
props.bordered ? props.theme.colors.container.border.base : 'transparent'};
|
|
135
130
|
border-bottom-style: solid;
|
|
136
131
|
`;
|
|
137
132
|
|
|
@@ -144,7 +139,7 @@ export const Footer = styled<typeof Box, TypeTheme>(Box)`
|
|
|
144
139
|
border-bottom-left-radius: ${(props) => props.theme.radii[500]};
|
|
145
140
|
`;
|
|
146
141
|
|
|
147
|
-
Container.displayName =
|
|
148
|
-
Content.displayName =
|
|
149
|
-
Header.displayName =
|
|
150
|
-
Footer.displayName =
|
|
142
|
+
Container.displayName = 'ModalContainer';
|
|
143
|
+
Content.displayName = 'Content';
|
|
144
|
+
Header.displayName = 'Modal.Header';
|
|
145
|
+
Footer.displayName = 'Modal.Footer';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import * as React from
|
|
3
|
-
import memoize from
|
|
4
|
-
import {
|
|
5
|
-
import Tooltip from
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import memoize from 'lru-memoize';
|
|
4
|
+
import {AbbrContainer, Container} from './styles';
|
|
5
|
+
import Tooltip from '../Tooltip';
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_THRESHOLD,
|
|
8
8
|
MEMO_CACHE_SIZE,
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
MAX_PRECISION,
|
|
11
11
|
ABBREV_PRECISION,
|
|
12
12
|
DefaultPrecisions,
|
|
13
|
-
} from
|
|
14
|
-
import {
|
|
13
|
+
} from './constants';
|
|
14
|
+
import {EM_DASH} from '../utils/constants';
|
|
15
15
|
|
|
16
|
-
type EnumNumeralFormat =
|
|
16
|
+
type EnumNumeralFormat = 'decimal' | 'currency' | 'percent';
|
|
17
17
|
|
|
18
18
|
export type TypeProps = {
|
|
19
19
|
/** The number to be formatted */
|
|
@@ -27,7 +27,7 @@ export type TypeProps = {
|
|
|
27
27
|
/** A boolean determining whether or not the number should be abbreviated, or a number representing the abbreviation threshold */
|
|
28
28
|
abbreviate?: boolean | number,
|
|
29
29
|
/** Override the default decimal precision (2 for decimals/currency, 1 for percentages), or "none" allowing unrestricted precision. */
|
|
30
|
-
precision?: number |
|
|
30
|
+
precision?: number | 'none',
|
|
31
31
|
qa?: Object,
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -51,9 +51,9 @@ type TypeArgs = {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
const _getNumberFormatters = (options: TypeFormatOptions): TypeFormatters => {
|
|
54
|
-
const {
|
|
54
|
+
const {locale, format, currency, min, max} = options;
|
|
55
55
|
const compactPrecision = min === max ? min : ABBREV_PRECISION;
|
|
56
|
-
const _currency = format ===
|
|
56
|
+
const _currency = format === 'currency' ? currency : undefined;
|
|
57
57
|
const standard = {
|
|
58
58
|
style: format,
|
|
59
59
|
minimumFractionDigits: min,
|
|
@@ -65,7 +65,7 @@ const _getNumberFormatters = (options: TypeFormatOptions): TypeFormatters => {
|
|
|
65
65
|
minimumFractionDigits: compactPrecision,
|
|
66
66
|
maximumFractionDigits: compactPrecision,
|
|
67
67
|
currency: _currency,
|
|
68
|
-
notation:
|
|
68
|
+
notation: 'compact',
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// Safari 14.1 is currently throwing errors when trying to use the compact
|
|
@@ -89,7 +89,7 @@ const memoizer = memoize(MEMO_CACHE_SIZE, COMPARE_OBJECTS);
|
|
|
89
89
|
const getNumberFormatters = memoizer(_getNumberFormatters);
|
|
90
90
|
|
|
91
91
|
const getThreshold = (abbreviate: boolean | number): number => {
|
|
92
|
-
if (typeof abbreviate ===
|
|
92
|
+
if (typeof abbreviate === 'number') return Math.max(1000, abbreviate);
|
|
93
93
|
if (abbreviate) return DEFAULT_THRESHOLD;
|
|
94
94
|
return Infinity;
|
|
95
95
|
};
|
|
@@ -98,21 +98,21 @@ const getMinMaxPrecision = (
|
|
|
98
98
|
precision: ?(number | string),
|
|
99
99
|
format: string
|
|
100
100
|
): [number, number] => {
|
|
101
|
-
if (typeof precision ===
|
|
102
|
-
if (precision ===
|
|
101
|
+
if (typeof precision === 'number') return [precision, precision];
|
|
102
|
+
if (precision === 'none') return [0, MAX_PRECISION];
|
|
103
103
|
return DefaultPrecisions[format];
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
const isValidNumber = (value: any): boolean => {
|
|
107
|
-
return typeof value ===
|
|
107
|
+
return typeof value === 'number' && isFinite(value);
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
const normalizeArgs = (props: TypeProps): TypeArgs => {
|
|
111
111
|
const {
|
|
112
112
|
number,
|
|
113
|
-
locale =
|
|
114
|
-
format = props.currency ?
|
|
115
|
-
currency =
|
|
113
|
+
locale = 'us-EN',
|
|
114
|
+
format = props.currency ? 'currency' : 'decimal',
|
|
115
|
+
currency = 'USD',
|
|
116
116
|
abbreviate = true,
|
|
117
117
|
precision,
|
|
118
118
|
qa,
|
|
@@ -123,16 +123,16 @@ const normalizeArgs = (props: TypeProps): TypeArgs => {
|
|
|
123
123
|
const [min, max] = getMinMaxPrecision(precision, format);
|
|
124
124
|
|
|
125
125
|
const _number = number || 0;
|
|
126
|
-
const value = _number * (format ===
|
|
126
|
+
const value = _number * (format === 'percent' ? 0.01 : 1);
|
|
127
127
|
const canAbbreviate = _number >= threshold;
|
|
128
128
|
|
|
129
|
-
const options = {
|
|
129
|
+
const options = {locale, format, currency, min, max};
|
|
130
130
|
|
|
131
|
-
return {
|
|
131
|
+
return {value, canAbbreviate, options, qa, rest};
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
const Numeral = (props: TypeProps) => {
|
|
135
|
-
const {
|
|
135
|
+
const {value, canAbbreviate, options, qa, rest} = normalizeArgs(props);
|
|
136
136
|
|
|
137
137
|
if (!isValidNumber(props.number))
|
|
138
138
|
return <Container {...qa}>{EM_DASH}</Container>;
|
|
@@ -1,122 +1,122 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import React from
|
|
3
|
-
import Numeral, {
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Numeral, {type TypeProps} from './index';
|
|
4
4
|
|
|
5
5
|
const localeOptions = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
'United States (en-US)',
|
|
7
|
+
'English (en)',
|
|
8
|
+
'Arabic (ar-EG)',
|
|
9
|
+
'Brazil (pt-BR)',
|
|
10
|
+
'India (en-IN)',
|
|
11
|
+
'French (fr-FR)',
|
|
12
|
+
'Spain (es-ES)',
|
|
13
|
+
'Mexico (es-MX)',
|
|
14
|
+
'Germany (de-DE)',
|
|
15
|
+
'German (de)',
|
|
16
|
+
'Japan (ja-JP)',
|
|
17
|
+
'Japanese (ja)',
|
|
18
18
|
];
|
|
19
19
|
|
|
20
20
|
const localeMapping = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
'United States (en-US)': 'en-US',
|
|
22
|
+
'English (en)': 'en',
|
|
23
|
+
'Arabic (ar-EG)': 'ar-EG',
|
|
24
|
+
'Brazil (pt-BR)': 'pt-BR',
|
|
25
|
+
'India (en-IN)': 'en-IN',
|
|
26
|
+
'French (fr-FR)': 'fr-FR',
|
|
27
|
+
'Spain (es-ES)': 'es-ES',
|
|
28
|
+
'Mexico (es-MX)': 'es-MX',
|
|
29
|
+
'Germany (de-DE)': 'de-DE',
|
|
30
|
+
'German (de)': 'de',
|
|
31
|
+
'Japan (ja-JP)': 'ja-JP',
|
|
32
|
+
'Japanese (ja)': 'ja',
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const currencyOptions = [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
'Egyptian £',
|
|
37
|
+
'European €',
|
|
38
|
+
'Indian ₹',
|
|
39
|
+
'Japanese ¥',
|
|
40
|
+
'USA $',
|
|
41
41
|
];
|
|
42
42
|
|
|
43
43
|
const currencyMapping = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
'Egyptian £': 'EGP',
|
|
45
|
+
'European €': 'EUR',
|
|
46
|
+
'Indian ₹': 'INR',
|
|
47
|
+
'Japanese ¥': 'JPY',
|
|
48
|
+
'USA $': 'USD',
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const formatOptions = [
|
|
51
|
+
const formatOptions = ['decimal', 'currency', 'percent'];
|
|
52
52
|
|
|
53
53
|
const formatMapping = {
|
|
54
|
-
decimal:
|
|
55
|
-
currency:
|
|
56
|
-
percent:
|
|
54
|
+
decimal: 'decimal',
|
|
55
|
+
currency: 'currency',
|
|
56
|
+
percent: 'percent',
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
const abbreviateOptions = [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
'true',
|
|
61
|
+
'false',
|
|
62
|
+
' 500',
|
|
63
|
+
'1_000',
|
|
64
|
+
'10_000',
|
|
65
|
+
'100_000',
|
|
66
66
|
];
|
|
67
67
|
|
|
68
68
|
const abbreviateMapping = {
|
|
69
69
|
true: true,
|
|
70
70
|
false: false,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
' 500': 500,
|
|
72
|
+
'1_000': 1000,
|
|
73
|
+
'10_000': 10000,
|
|
74
|
+
'100_000': 100000,
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
const precisionOptions = [
|
|
77
|
+
const precisionOptions = ['0', '1', '2', '3', '6', 'none'];
|
|
78
78
|
|
|
79
79
|
const precisionMapping = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
none:
|
|
80
|
+
'0': 0,
|
|
81
|
+
'1': 1,
|
|
82
|
+
'2': 2,
|
|
83
|
+
'3': 3,
|
|
84
|
+
'6': 6,
|
|
85
|
+
none: 'none',
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
export default {
|
|
89
|
-
title:
|
|
89
|
+
title: 'Components/Numeral',
|
|
90
90
|
component: Numeral,
|
|
91
91
|
argTypes: {
|
|
92
92
|
locale: {
|
|
93
|
-
control:
|
|
93
|
+
control: 'select',
|
|
94
94
|
options: localeOptions,
|
|
95
95
|
mapping: localeMapping,
|
|
96
96
|
},
|
|
97
97
|
format: {
|
|
98
|
-
control:
|
|
98
|
+
control: 'select',
|
|
99
99
|
options: formatOptions,
|
|
100
100
|
mapping: formatMapping,
|
|
101
101
|
},
|
|
102
102
|
currency: {
|
|
103
|
-
control:
|
|
103
|
+
control: 'select',
|
|
104
104
|
options: currencyOptions,
|
|
105
105
|
mapping: currencyMapping,
|
|
106
106
|
},
|
|
107
107
|
abbreviate: {
|
|
108
|
-
control:
|
|
108
|
+
control: 'select',
|
|
109
109
|
options: abbreviateOptions,
|
|
110
110
|
mapping: abbreviateMapping,
|
|
111
111
|
},
|
|
112
112
|
precision: {
|
|
113
|
-
control:
|
|
113
|
+
control: 'select',
|
|
114
114
|
options: precisionOptions,
|
|
115
115
|
mapping: precisionMapping,
|
|
116
116
|
},
|
|
117
117
|
},
|
|
118
118
|
args: {
|
|
119
|
-
color:
|
|
119
|
+
color: 'text.headline',
|
|
120
120
|
number: 12.89,
|
|
121
121
|
},
|
|
122
122
|
};
|
|
@@ -124,52 +124,52 @@ export default {
|
|
|
124
124
|
export const defaultStory = (args: TypeProps) => <Numeral {...args} />;
|
|
125
125
|
|
|
126
126
|
defaultStory.story = {
|
|
127
|
-
name:
|
|
127
|
+
name: 'Default',
|
|
128
128
|
};
|
|
129
129
|
|
|
130
130
|
export const total = (args: TypeProps) => <Numeral {...args} />;
|
|
131
131
|
|
|
132
132
|
total.args = {
|
|
133
133
|
number: 100,
|
|
134
|
-
fontWeight:
|
|
134
|
+
fontWeight: 'semibold',
|
|
135
135
|
fontSize: 500,
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
total.story = {
|
|
139
|
-
name:
|
|
139
|
+
name: 'Total',
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
export const trend = (args: TypeProps) => <Numeral {...args} />;
|
|
143
143
|
|
|
144
144
|
trend.args = {
|
|
145
145
|
number: 100,
|
|
146
|
-
color:
|
|
146
|
+
color: 'teal.500',
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
trend.story = {
|
|
150
|
-
name:
|
|
150
|
+
name: 'Trend',
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
export const noPrecision = (args: TypeProps) => <Numeral {...args} />;
|
|
154
154
|
|
|
155
155
|
noPrecision.args = {
|
|
156
156
|
number: 123.45678,
|
|
157
|
-
precision:
|
|
157
|
+
precision: 'none',
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
noPrecision.story = {
|
|
161
|
-
name:
|
|
161
|
+
name: 'No Precision',
|
|
162
162
|
};
|
|
163
163
|
|
|
164
164
|
export const currencyPrecision = (args: TypeProps) => <Numeral {...args} />;
|
|
165
165
|
|
|
166
166
|
currencyPrecision.args = {
|
|
167
167
|
number: 123.4,
|
|
168
|
-
format:
|
|
168
|
+
format: 'currency',
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
currencyPrecision.story = {
|
|
172
|
-
name:
|
|
172
|
+
name: 'Currency precision',
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
export const invalid = (args: TypeProps) => <Numeral {...args} />;
|
|
@@ -179,5 +179,5 @@ invalid.args = {
|
|
|
179
179
|
};
|
|
180
180
|
|
|
181
181
|
invalid.story = {
|
|
182
|
-
name:
|
|
182
|
+
name: 'Invalid',
|
|
183
183
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//@flow
|
|
2
|
-
import styled from
|
|
3
|
-
import Text from
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import Text from '../Text';
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {TypeTheme} from '../types/theme.flow';
|
|
6
6
|
|
|
7
7
|
export const Container = styled<typeof Text, TypeTheme>(Text)`
|
|
8
8
|
font-variant-numeric: tabular-nums;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import Numeral from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {render} from '../../utils/react-testing-library';
|
|
3
|
+
import 'jest-styled-components';
|
|
4
|
+
import Numeral from '../';
|
|
5
5
|
|
|
6
|
-
describe(
|
|
7
|
-
it(
|
|
8
|
-
const {
|
|
6
|
+
describe('When rendering...', () => {
|
|
7
|
+
it('should handle A11y', async () => {
|
|
8
|
+
const {container, runA11yCheck} = render(<Numeral />);
|
|
9
9
|
expect(container).toBeTruthy();
|
|
10
10
|
await runA11yCheck();
|
|
11
11
|
});
|