@nearform/quantum 1.9.4 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animations/index.js.map +1 -1
- package/dist/assets/build/open-source.icon.js.map +1 -1
- package/dist/assets/index.d.ts +1 -1
- package/dist/assets/index.js +1 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/colors/index.js.map +1 -1
- package/dist/components/Accordion/index.d.ts +2 -2
- package/dist/components/Accordion/index.js +7 -7
- package/dist/components/Accordion/index.js.map +1 -1
- package/dist/components/AppHeader/index.js +8 -8
- package/dist/components/AppHeader/index.js.map +1 -1
- package/dist/components/Avatar/index.d.ts +3 -3
- package/dist/components/Avatar/index.js +3 -3
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/BackLink/index.d.ts +2 -2
- package/dist/components/BackLink/index.js +3 -3
- package/dist/components/BackLink/index.js.map +1 -1
- package/dist/components/Badge/index.d.ts +3 -3
- package/dist/components/Badge/index.js +2 -2
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Breadcrumb/index.d.ts +1 -1
- package/dist/components/Breadcrumb/index.js +7 -7
- package/dist/components/Breadcrumb/index.js.map +1 -1
- package/dist/components/Button/index.d.ts +3 -3
- package/dist/components/Button/index.js +3 -3
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ButtonGroup/index.d.ts +2 -2
- package/dist/components/ButtonGroup/index.js +2 -2
- package/dist/components/ButtonGroup/index.js.map +1 -1
- package/dist/components/Calendar/index.js +5 -5
- package/dist/components/Calendar/index.js.map +1 -1
- package/dist/components/Card/index.d.ts +4 -4
- package/dist/components/Card/index.js +10 -10
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/Chat/index.d.ts +1 -1
- package/dist/components/Chat/index.js +8 -8
- package/dist/components/Chat/index.js.map +1 -1
- package/dist/components/Checkbox/index.js +3 -3
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.js +3 -3
- package/dist/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroupItem.d.ts +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroupItem.js +7 -7
- package/dist/components/CheckboxGroup/CheckboxGroupItem.js.map +1 -1
- package/dist/components/CheckboxGroup/index.d.ts +2 -2
- package/dist/components/CheckboxGroup/index.js +5 -5
- package/dist/components/CheckboxGroup/index.js.map +1 -1
- package/dist/components/Chip/index.d.ts +2 -2
- package/dist/components/Chip/index.js +3 -3
- package/dist/components/Chip/index.js.map +1 -1
- package/dist/components/CodeBlock/index.js +2 -2
- package/dist/components/CodeBlock/index.js.map +1 -1
- package/dist/components/ControlLabel/index.d.ts +3 -3
- package/dist/components/ControlLabel/index.js +4 -4
- package/dist/components/ControlLabel/index.js.map +1 -1
- package/dist/components/DateInput/index.js +5 -5
- package/dist/components/DateInput/index.js.map +1 -1
- package/dist/components/DocsList/index.js +9 -9
- package/dist/components/DocsList/index.js.map +1 -1
- package/dist/components/FormGroup/index.d.ts +1 -1
- package/dist/components/FormGroup/index.js +16 -19
- package/dist/components/FormGroup/index.js.map +1 -1
- package/dist/components/HeroButton/index.d.ts +2 -2
- package/dist/components/HeroButton/index.js +3 -3
- package/dist/components/HeroButton/index.js.map +1 -1
- package/dist/components/IconButton/index.d.ts +3 -3
- package/dist/components/IconButton/index.js +3 -3
- package/dist/components/IconButton/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +3 -3
- package/dist/components/Input/index.js +5 -5
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Label/index.d.ts +2 -2
- package/dist/components/Label/index.js +3 -3
- package/dist/components/Label/index.js.map +1 -1
- package/dist/components/Link/index.d.ts +3 -3
- package/dist/components/Link/index.js +2 -2
- package/dist/components/Link/index.js.map +1 -1
- package/dist/components/Meter/index.js +5 -5
- package/dist/components/Meter/index.js.map +1 -1
- package/dist/components/Modal/index.d.ts +12 -12
- package/dist/components/Modal/index.js +9 -9
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Navigation/index.js +3 -3
- package/dist/components/Navigation/index.js.map +1 -1
- package/dist/components/Notice/index.d.ts +2 -2
- package/dist/components/Notice/index.js +9 -9
- package/dist/components/Notice/index.js.map +1 -1
- package/dist/components/PageHeader/index.d.ts +2 -2
- package/dist/components/PageHeader/index.js +4 -4
- package/dist/components/PageHeader/index.js.map +1 -1
- package/dist/components/Pagination/index.d.ts +1 -1
- package/dist/components/Pagination/index.js +3 -3
- package/dist/components/Pagination/index.js.map +1 -1
- package/dist/components/Password/index.js +4 -4
- package/dist/components/Password/index.js.map +1 -1
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Popover/index.js +6 -6
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Radio/RadioGroup.js +3 -3
- package/dist/components/Radio/RadioGroup.js.map +1 -1
- package/dist/components/Radio/RadioGroupItem.js +6 -6
- package/dist/components/Radio/RadioGroupItem.js.map +1 -1
- package/dist/components/Radio/index.d.ts +2 -2
- package/dist/components/Radio/index.js +4 -4
- package/dist/components/Radio/index.js.map +1 -1
- package/dist/components/Select/index.d.ts +3 -3
- package/dist/components/Select/index.js +8 -8
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Slider/index.d.ts +1 -1
- package/dist/components/Slider/index.js +6 -6
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/SortAndShow/index.js +5 -5
- package/dist/components/SortAndShow/index.js.map +1 -1
- package/dist/components/SplitButton/index.d.ts +3 -3
- package/dist/components/SplitButton/index.js +6 -6
- package/dist/components/SplitButton/index.js.map +1 -1
- package/dist/components/Stats/index.d.ts +1 -1
- package/dist/components/Stats/index.js +3 -3
- package/dist/components/Stats/index.js.map +1 -1
- package/dist/components/Stepper/index.js +7 -7
- package/dist/components/Stepper/index.js.map +1 -1
- package/dist/components/StepsIndicator/Step.js +3 -3
- package/dist/components/StepsIndicator/Step.js.map +1 -1
- package/dist/components/StepsIndicator/StepsIndicator.js +4 -4
- package/dist/components/StepsIndicator/StepsIndicator.js.map +1 -1
- package/dist/components/StepsIndicator/index.d.ts +2 -2
- package/dist/components/StepsIndicator/index.js +2 -2
- package/dist/components/StepsIndicator/index.js.map +1 -1
- package/dist/components/Subnav/index.js +5 -5
- package/dist/components/Subnav/index.js.map +1 -1
- package/dist/components/Switch/index.js +2 -2
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Table/index.d.ts +2 -2
- package/dist/components/Table/index.js +17 -17
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +4 -4
- package/dist/components/Tabs/index.js +5 -5
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +2 -2
- package/dist/components/Textarea/index.js +2 -2
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/components/ThemeToggle/index.d.ts +1 -1
- package/dist/components/ThemeToggle/index.js +2 -2
- package/dist/components/ThemeToggle/index.js.map +1 -1
- package/dist/components/Toast/index.d.ts +2 -2
- package/dist/components/Toast/index.js +12 -12
- package/dist/components/Toast/index.js.map +1 -1
- package/dist/components/ToggleList/index.d.ts +1 -1
- package/dist/components/ToggleList/index.js +6 -6
- package/dist/components/ToggleList/index.js.map +1 -1
- package/dist/components/Tooltip/index.js +2 -2
- package/dist/components/Tooltip/index.js.map +1 -1
- package/dist/components/WebsiteFooter/index.d.ts +4 -4
- package/dist/components/WebsiteFooter/index.js +5 -5
- package/dist/components/WebsiteFooter/index.js.map +1 -1
- package/dist/components/WebsiteHeader/index.js +8 -8
- package/dist/components/WebsiteHeader/index.js.map +1 -1
- package/dist/components/choice-group.d.ts +3 -3
- package/dist/components/choice-group.js +7 -7
- package/dist/components/choice-group.js.map +1 -1
- package/dist/components/index.d.ts +51 -51
- package/dist/components/index.js +51 -51
- package/dist/components/index.js.map +1 -1
- package/dist/esm/animations/index.d.ts +25 -0
- package/dist/esm/assets/build/open-source.icon.d.ts +2 -0
- package/dist/esm/assets/build/open-source.icon.js +3 -0
- package/dist/esm/assets/build/open-source.icon.js.map +1 -0
- package/dist/esm/assets/index.d.ts +13 -0
- package/dist/esm/assets/index.js +13 -0
- package/dist/esm/assets/index.js.map +1 -0
- package/dist/esm/colors/accent.d.ts +16 -0
- package/dist/esm/colors/accent.js +1 -1
- package/dist/esm/colors/background.d.ts +36 -0
- package/dist/esm/colors/background.js +1 -1
- package/dist/esm/colors/base.d.ts +136 -0
- package/dist/esm/colors/border.d.ts +16 -0
- package/dist/esm/colors/border.js +1 -1
- package/dist/esm/colors/button.d.ts +106 -0
- package/dist/esm/colors/button.js +5 -5
- package/dist/esm/colors/feedback.d.ts +27 -0
- package/dist/esm/colors/feedback.js +1 -1
- package/dist/esm/colors/foreground.d.ts +35 -0
- package/dist/esm/colors/foreground.js +1 -1
- package/dist/esm/colors/index.d.ts +351 -0
- package/dist/esm/colors/index.js +7 -7
- package/dist/esm/components/Accordion/index.d.ts +16 -0
- package/dist/esm/components/Accordion/index.js +58 -0
- package/dist/esm/components/Accordion/index.js.map +1 -0
- package/dist/esm/components/AppHeader/index.d.ts +21 -0
- package/dist/esm/components/AppHeader/index.js +56 -0
- package/dist/esm/components/AppHeader/index.js.map +1 -0
- package/dist/esm/components/Avatar/index.d.ts +32 -0
- package/dist/esm/components/Avatar/index.js +110 -0
- package/dist/esm/components/Avatar/index.js.map +1 -0
- package/dist/esm/components/BackLink/index.d.ts +9 -0
- package/dist/esm/components/BackLink/index.js +43 -0
- package/dist/esm/components/BackLink/index.js.map +1 -0
- package/dist/esm/components/Badge/index.d.ts +48 -0
- package/dist/esm/components/Badge/index.js +154 -0
- package/dist/esm/components/Badge/index.js.map +1 -0
- package/dist/esm/components/Breadcrumb/index.d.ts +13 -0
- package/dist/esm/components/Breadcrumb/index.js +49 -0
- package/dist/esm/components/Breadcrumb/index.js.map +1 -0
- package/dist/esm/components/Button/index.d.ts +17 -0
- package/dist/esm/components/Button/index.js +167 -0
- package/dist/esm/components/Button/index.js.map +1 -0
- package/dist/esm/components/ButtonGroup/index.d.ts +11 -0
- package/dist/esm/components/ButtonGroup/index.js +96 -0
- package/dist/esm/components/ButtonGroup/index.js.map +1 -0
- package/dist/esm/components/Calendar/index.d.ts +8 -0
- package/dist/esm/components/Calendar/index.js +144 -0
- package/dist/esm/components/Calendar/index.js.map +1 -0
- package/dist/esm/components/Card/index.d.ts +28 -0
- package/dist/esm/components/Card/index.js +114 -0
- package/dist/esm/components/Card/index.js.map +1 -0
- package/dist/esm/components/Chat/index.d.ts +39 -0
- package/dist/esm/components/Chat/index.js +91 -0
- package/dist/esm/components/Chat/index.js.map +1 -0
- package/dist/esm/components/Checkbox/index.d.ts +5 -0
- package/dist/esm/components/Checkbox/index.js +92 -0
- package/dist/esm/components/Checkbox/index.js.map +1 -0
- package/dist/esm/components/CheckboxGroup/CheckboxGroup.d.ts +61 -0
- package/dist/esm/components/CheckboxGroup/CheckboxGroup.js +70 -0
- package/dist/esm/components/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/dist/esm/components/CheckboxGroup/CheckboxGroupItem.d.ts +19 -0
- package/dist/esm/components/CheckboxGroup/CheckboxGroupItem.js +47 -0
- package/dist/esm/components/CheckboxGroup/CheckboxGroupItem.js.map +1 -0
- package/dist/esm/components/CheckboxGroup/index.d.ts +2 -0
- package/dist/esm/components/CheckboxGroup/index.js +3 -0
- package/dist/esm/components/CheckboxGroup/index.js.map +1 -0
- package/dist/esm/components/Chip/index.d.ts +11 -0
- package/dist/esm/components/Chip/index.js +99 -0
- package/dist/esm/components/Chip/index.js.map +1 -0
- package/dist/esm/components/CodeBlock/index.d.ts +7 -0
- package/dist/esm/components/CodeBlock/index.js +21 -0
- package/dist/esm/components/CodeBlock/index.js.map +1 -0
- package/dist/esm/components/ControlLabel/index.d.ts +13 -0
- package/dist/esm/components/ControlLabel/index.js +47 -0
- package/dist/esm/components/ControlLabel/index.js.map +1 -0
- package/dist/esm/components/DateInput/index.d.ts +26 -0
- package/dist/esm/components/DateInput/index.js +225 -0
- package/dist/esm/components/DateInput/index.js.map +1 -0
- package/dist/esm/components/DocsList/index.d.ts +18 -0
- package/dist/esm/components/DocsList/index.js +83 -0
- package/dist/esm/components/DocsList/index.js.map +1 -0
- package/dist/esm/components/FormGroup/index.d.ts +121 -0
- package/dist/esm/components/FormGroup/index.js +317 -0
- package/dist/esm/components/FormGroup/index.js.map +1 -0
- package/dist/esm/components/HeroButton/index.d.ts +17 -0
- package/dist/esm/components/HeroButton/index.js +102 -0
- package/dist/esm/components/HeroButton/index.js.map +1 -0
- package/dist/esm/components/IconButton/index.d.ts +77 -0
- package/dist/esm/components/IconButton/index.js +198 -0
- package/dist/esm/components/IconButton/index.js.map +1 -0
- package/dist/esm/components/Input/index.d.ts +27 -0
- package/dist/esm/components/Input/index.js +172 -0
- package/dist/esm/components/Input/index.js.map +1 -0
- package/dist/esm/components/Label/index.d.ts +12 -0
- package/dist/esm/components/Label/index.js +53 -0
- package/dist/esm/components/Label/index.js.map +1 -0
- package/dist/esm/components/Link/index.d.ts +13 -0
- package/dist/esm/components/Link/index.js +76 -0
- package/dist/esm/components/Link/index.js.map +1 -0
- package/dist/esm/components/Meter/index.d.ts +20 -0
- package/dist/esm/components/Meter/index.js +100 -0
- package/dist/esm/components/Meter/index.js.map +1 -0
- package/dist/esm/components/Modal/index.d.ts +26 -0
- package/dist/esm/components/Modal/index.js +97 -0
- package/dist/esm/components/Modal/index.js.map +1 -0
- package/dist/esm/components/Navigation/index.d.ts +8 -0
- package/dist/esm/components/Navigation/index.js +28 -0
- package/dist/esm/components/Navigation/index.js.map +1 -0
- package/dist/esm/components/Notice/index.d.ts +21 -0
- package/dist/esm/components/Notice/index.js +105 -0
- package/dist/esm/components/Notice/index.js.map +1 -0
- package/dist/esm/components/PageHeader/index.d.ts +15 -0
- package/dist/esm/components/PageHeader/index.js +51 -0
- package/dist/esm/components/PageHeader/index.js.map +1 -0
- package/dist/esm/components/Pagination/index.d.ts +17 -0
- package/dist/esm/components/Pagination/index.js +115 -0
- package/dist/esm/components/Pagination/index.js.map +1 -0
- package/dist/esm/components/Password/index.d.ts +18 -0
- package/dist/esm/components/Password/index.js +70 -0
- package/dist/esm/components/Password/index.js.map +1 -0
- package/dist/esm/components/Popover/index.d.ts +28 -0
- package/dist/esm/components/Popover/index.js +54 -0
- package/dist/esm/components/Popover/index.js.map +1 -0
- package/dist/esm/components/Radio/RadioGroup.d.ts +42 -0
- package/dist/esm/components/Radio/RadioGroup.js +46 -0
- package/dist/esm/components/Radio/RadioGroup.js.map +1 -0
- package/dist/esm/components/Radio/RadioGroupItem.d.ts +17 -0
- package/dist/esm/components/Radio/RadioGroupItem.js +81 -0
- package/dist/esm/components/Radio/RadioGroupItem.js.map +1 -0
- package/dist/esm/components/Radio/index.d.ts +2 -0
- package/dist/esm/components/Radio/index.js +3 -0
- package/dist/esm/components/Radio/index.js.map +1 -0
- package/dist/esm/components/Select/index.d.ts +19 -0
- package/dist/esm/components/Select/index.js +162 -0
- package/dist/esm/components/Select/index.js.map +1 -0
- package/dist/esm/components/Slider/index.d.ts +20 -0
- package/dist/esm/components/Slider/index.js +92 -0
- package/dist/esm/components/Slider/index.js.map +1 -0
- package/dist/esm/components/SortAndShow/index.d.ts +15 -0
- package/dist/esm/components/SortAndShow/index.js +31 -0
- package/dist/esm/components/SortAndShow/index.js.map +1 -0
- package/dist/esm/components/SplitButton/index.d.ts +25 -0
- package/dist/esm/components/SplitButton/index.js +184 -0
- package/dist/esm/components/SplitButton/index.js.map +1 -0
- package/dist/esm/components/Stats/index.d.ts +10 -0
- package/dist/esm/components/Stats/index.js +26 -0
- package/dist/esm/components/Stats/index.js.map +1 -0
- package/dist/esm/components/Stepper/index.d.ts +27 -0
- package/dist/esm/components/Stepper/index.js +124 -0
- package/dist/esm/components/Stepper/index.js.map +1 -0
- package/dist/esm/components/StepsIndicator/Step.d.ts +6 -0
- package/dist/esm/components/StepsIndicator/Step.js +21 -0
- package/dist/esm/components/StepsIndicator/Step.js.map +1 -0
- package/dist/esm/components/StepsIndicator/StepsIndicator.d.ts +12 -0
- package/dist/esm/components/StepsIndicator/StepsIndicator.js +31 -0
- package/dist/esm/components/StepsIndicator/StepsIndicator.js.map +1 -0
- package/dist/esm/components/StepsIndicator/index.d.ts +2 -0
- package/dist/esm/components/StepsIndicator/index.js +3 -0
- package/dist/esm/components/StepsIndicator/index.js.map +1 -0
- package/dist/esm/components/Subnav/index.d.ts +14 -0
- package/dist/esm/components/Subnav/index.js +54 -0
- package/dist/esm/components/Subnav/index.js.map +1 -0
- package/dist/esm/components/Switch/index.d.ts +4 -0
- package/dist/esm/components/Switch/index.js +67 -0
- package/dist/esm/components/Switch/index.js.map +1 -0
- package/dist/esm/components/Table/index.d.ts +53 -0
- package/dist/esm/components/Table/index.js +108 -0
- package/dist/esm/components/Table/index.js.map +1 -0
- package/dist/esm/components/Tabs/index.d.ts +16 -0
- package/dist/esm/components/Tabs/index.js +126 -0
- package/dist/esm/components/Tabs/index.js.map +1 -0
- package/dist/esm/components/Textarea/index.d.ts +13 -0
- package/dist/esm/components/Textarea/index.js +89 -0
- package/dist/esm/components/Textarea/index.js.map +1 -0
- package/dist/esm/components/ThemeToggle/index.d.ts +9 -0
- package/dist/esm/components/ThemeToggle/index.js +90 -0
- package/dist/esm/components/ThemeToggle/index.js.map +1 -0
- package/dist/esm/components/Toast/index.d.ts +24 -0
- package/dist/esm/components/Toast/index.js +129 -0
- package/dist/esm/components/Toast/index.js.map +1 -0
- package/dist/esm/components/ToggleList/index.d.ts +20 -0
- package/dist/esm/components/ToggleList/index.js +31 -0
- package/dist/esm/components/ToggleList/index.js.map +1 -0
- package/dist/esm/components/Tooltip/index.d.ts +11 -0
- package/dist/esm/components/Tooltip/index.js +30 -0
- package/dist/esm/components/Tooltip/index.js.map +1 -0
- package/dist/esm/components/WebsiteFooter/index.d.ts +23 -0
- package/dist/esm/components/WebsiteFooter/index.js +104 -0
- package/dist/esm/components/WebsiteFooter/index.js.map +1 -0
- package/dist/esm/components/WebsiteHeader/index.d.ts +21 -0
- package/dist/esm/components/WebsiteHeader/index.js +56 -0
- package/dist/esm/components/WebsiteHeader/index.js.map +1 -0
- package/dist/esm/components/choice-group.d.ts +109 -0
- package/dist/esm/components/choice-group.js +159 -0
- package/dist/esm/components/choice-group.js.map +1 -0
- package/dist/esm/components/index.d.ts +51 -0
- package/dist/esm/components/index.js +52 -0
- package/dist/esm/components/index.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/utils.d.ts +16 -0
- package/dist/esm/lib/utils.js +18 -0
- package/dist/esm/lib/utils.js.map +1 -0
- package/dist/esm/tailwind-base.d.ts +37 -0
- package/dist/esm/tailwind-plugin.d.ts +22 -0
- package/dist/esm/tailwind-plugin.js +2 -2
- package/dist/esm/theme.d.ts +421 -0
- package/dist/esm/theme.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/tailwind-base.js.map +1 -1
- package/dist/tailwind-plugin.js.map +1 -1
- package/dist/theme.js.map +1 -1
- package/package.json +27 -16
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { cva } from 'class-variance-authority';
|
|
15
|
+
import { cn } from '../../lib/utils.js';
|
|
16
|
+
import { Label } from '../Label/index.js';
|
|
17
|
+
/**
|
|
18
|
+
* A field is three things that have to agree with each other: a label, a
|
|
19
|
+
* control, and a message below it. Getting them to agree is entirely id
|
|
20
|
+
* plumbing -- the label's `htmlFor` has to match the control's `id`, the
|
|
21
|
+
* message's `id` has to appear in the control's `aria-describedby`, and the
|
|
22
|
+
* control has to be marked `aria-invalid` when the message is an error. That
|
|
23
|
+
* is what `FormGroup` does; the layout is the smaller half of the job.
|
|
24
|
+
*
|
|
25
|
+
* The plumbing is done by cloning the children rather than by having the
|
|
26
|
+
* children read a context, so the group works with anything that takes the
|
|
27
|
+
* props every form control already takes -- our `Input` and `Select`, a bare
|
|
28
|
+
* `<input>`, a control from somewhere else. The only requirement is that they
|
|
29
|
+
* are direct children, which is the arrangement the design file draws.
|
|
30
|
+
*/
|
|
31
|
+
const formGroupVariants = cva('grid', {
|
|
32
|
+
variants: {
|
|
33
|
+
orientation: {
|
|
34
|
+
// One column, so the children simply stack in source order.
|
|
35
|
+
vertical: ['grid-cols-1', 'gap-y-2'],
|
|
36
|
+
// The label takes as much width as its text and the control takes the
|
|
37
|
+
// rest; the message sits under the control rather than under the label,
|
|
38
|
+
// which is the indent the design shows. There is no `gap-x` because an
|
|
39
|
+
// empty first column would still occupy it -- the label carries its own
|
|
40
|
+
// trailing space instead, so a group with no label has none.
|
|
41
|
+
horizontal: ['grid-cols-[auto_minmax(0,1fr)]', 'items-center', 'gap-y-1']
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
orientation: 'vertical'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const FormGroupContext = React.createContext(null);
|
|
49
|
+
/**
|
|
50
|
+
* The group's messages and the ids they are published under. `null` outside a
|
|
51
|
+
* `FormGroup`, which is what lets `FieldError` and `FieldDescription` be
|
|
52
|
+
* rendered on their own.
|
|
53
|
+
*
|
|
54
|
+
* Useful for a control the group cannot reach -- one nested inside a wrapper
|
|
55
|
+
* of your own, say -- which can take `errorId` from here and put it in its own
|
|
56
|
+
* `aria-describedby`.
|
|
57
|
+
*/
|
|
58
|
+
const useFormGroup = () => React.useContext(FormGroupContext);
|
|
59
|
+
const messageVariants = cva(['text-xs'], {
|
|
60
|
+
variants: {
|
|
61
|
+
tone: {
|
|
62
|
+
description: ['text-foreground-muted', 'dark:text-foreground-muted-dark'],
|
|
63
|
+
error: [
|
|
64
|
+
'font-medium',
|
|
65
|
+
'text-feedback-error',
|
|
66
|
+
'dark:text-feedback-error-dark'
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
defaultVariants: {
|
|
71
|
+
tone: 'description'
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* The hint under the control. Takes its text from the group's `description`,
|
|
76
|
+
* or from its own children when you would rather write it inline.
|
|
77
|
+
*
|
|
78
|
+
* Stands down while the group's `FieldError` has something to say, so the two
|
|
79
|
+
* can be written side by side once and the field shows one message at a time
|
|
80
|
+
* rather than growing a second line as it is validated. The error is the more
|
|
81
|
+
* urgent of the two and it takes the place, not the space below it. A field
|
|
82
|
+
* that genuinely needs both messages at once wants a second element of its
|
|
83
|
+
* own rather than this one.
|
|
84
|
+
*/
|
|
85
|
+
const FieldDescription = React.forwardRef((_a, ref) => {
|
|
86
|
+
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
87
|
+
const group = useFormGroup();
|
|
88
|
+
const content = (group === null || group === void 0 ? void 0 : group.errorShown)
|
|
89
|
+
? undefined
|
|
90
|
+
: (children !== null && children !== void 0 ? children : group === null || group === void 0 ? void 0 : group.description);
|
|
91
|
+
if (!content)
|
|
92
|
+
return null;
|
|
93
|
+
return (_jsx("p", Object.assign({ ref: ref, id: group === null || group === void 0 ? void 0 : group.descriptionId, className: cn(messageVariants({ tone: 'description' }), className) }, props, { children: content })));
|
|
94
|
+
});
|
|
95
|
+
FieldDescription.displayName = 'FieldDescription';
|
|
96
|
+
/**
|
|
97
|
+
* The validation message under the control, and the thing that puts the group
|
|
98
|
+
* in its error state: a `FormGroup` whose `error` is set marks its control
|
|
99
|
+
* `aria-invalid` whether or not a `FieldError` is there to render it.
|
|
100
|
+
*
|
|
101
|
+
* `role="alert"` is what announces a message that appears after the page has
|
|
102
|
+
* loaded -- an element carrying it is read out when it enters the DOM, and
|
|
103
|
+
* this one is not rendered at all until there is something to say. The
|
|
104
|
+
* `aria-describedby` link the group sets up covers the other direction: a
|
|
105
|
+
* message that was already on screen is read when focus reaches the control.
|
|
106
|
+
*/
|
|
107
|
+
const FieldError = React.forwardRef((_a, ref) => {
|
|
108
|
+
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
109
|
+
const group = useFormGroup();
|
|
110
|
+
const content = children !== null && children !== void 0 ? children : group === null || group === void 0 ? void 0 : group.error;
|
|
111
|
+
if (!content)
|
|
112
|
+
return null;
|
|
113
|
+
return (_jsx("p", Object.assign({ ref: ref, id: group === null || group === void 0 ? void 0 : group.errorId, role: "alert", className: cn(messageVariants({ tone: 'error' }), className) }, props, { children: content })));
|
|
114
|
+
});
|
|
115
|
+
FieldError.displayName = 'FieldError';
|
|
116
|
+
/**
|
|
117
|
+
* `disabled` and `required` are real attributes rather than styling, so they
|
|
118
|
+
* are only forwarded to something that can hold them. React renders an unknown
|
|
119
|
+
* attribute on a host element verbatim and warns about it, so
|
|
120
|
+
* `<div disabled="true">` is both a console warning and markup a browser
|
|
121
|
+
* ignores. A component is trusted with them -- what it does with them is its
|
|
122
|
+
* own business.
|
|
123
|
+
*/
|
|
124
|
+
const ATTRIBUTE_HOLDERS = new Set([
|
|
125
|
+
'button',
|
|
126
|
+
'fieldset',
|
|
127
|
+
'input',
|
|
128
|
+
'select',
|
|
129
|
+
'textarea'
|
|
130
|
+
]);
|
|
131
|
+
const takesFormAttributes = (element) => typeof element.type !== 'string' || ATTRIBUTE_HOLDERS.has(element.type);
|
|
132
|
+
const slotOf = (node) => {
|
|
133
|
+
if (!React.isValidElement(node))
|
|
134
|
+
return null;
|
|
135
|
+
if (node.type === Label || node.type === 'label')
|
|
136
|
+
return 'label';
|
|
137
|
+
if (node.type === FieldDescription)
|
|
138
|
+
return 'description';
|
|
139
|
+
if (node.type === FieldError)
|
|
140
|
+
return 'error';
|
|
141
|
+
return 'control';
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Wraps a label, a control and its messages into one field, wiring them
|
|
145
|
+
* together and laying them out in either orientation.
|
|
146
|
+
*
|
|
147
|
+
* ```tsx
|
|
148
|
+
* <FormGroup orientation="vertical" error="Pick a date in the future">
|
|
149
|
+
* <Label>Start date</Label>
|
|
150
|
+
* <Input type="date" variant="error" onClear={clear} />
|
|
151
|
+
* <FieldError />
|
|
152
|
+
* </FormGroup>
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* The label, the messages and the control are recognised by what they are, so
|
|
156
|
+
* they can be written in any order -- though writing them in the order they
|
|
157
|
+
* appear is what makes the vertical layout need no placement rules at all.
|
|
158
|
+
* Anything that is not a `Label`, a `FieldDescription` or a `FieldError` is
|
|
159
|
+
* taken to be the control; only the first one is wired, since an id can only
|
|
160
|
+
* belong to one element.
|
|
161
|
+
*
|
|
162
|
+
* Nothing is overwritten. A child that already has an `htmlFor`, an
|
|
163
|
+
* `aria-describedby`, a `disabled` or a `required` keeps it, and its own
|
|
164
|
+
* `className` is applied after the group's. A control that already has an `id`
|
|
165
|
+
* keeps that too, and the label and the messages are built around it --
|
|
166
|
+
* `controlId` is the one way to override it, since a group asked for a
|
|
167
|
+
* specific id has been asked by the only party above both of them.
|
|
168
|
+
*
|
|
169
|
+
* `aria-invalid="false"` is the single exception, because it is the only one
|
|
170
|
+
* of these that says nothing by being there: it is the attribute's default
|
|
171
|
+
* and reads identically to its absence. See the guard below.
|
|
172
|
+
*/
|
|
173
|
+
const FormGroup = React.forwardRef((_a, ref) => {
|
|
174
|
+
var _b;
|
|
175
|
+
var { className, orientation = 'vertical', controlId, description, error, invalid, disabled, required, children } = _a, props = __rest(_a, ["className", "orientation", "controlId", "description", "error", "invalid", "disabled", "required", "children"]);
|
|
176
|
+
const generatedId = React.useId();
|
|
177
|
+
const horizontal = orientation === 'horizontal';
|
|
178
|
+
const items = React.Children.toArray(children);
|
|
179
|
+
const slots = items.map(slotOf);
|
|
180
|
+
const controlIndex = slots.indexOf('control');
|
|
181
|
+
/**
|
|
182
|
+
* A control that arrived with an `id` keeps it, and the rest of the field
|
|
183
|
+
* is built around that instead: the label points at the id the control
|
|
184
|
+
* actually has, and the messages are published under ids derived from it.
|
|
185
|
+
* Overwriting it would break whatever put it there -- a form library's
|
|
186
|
+
* `register`, or an `aria-controls` elsewhere on the page.
|
|
187
|
+
*/
|
|
188
|
+
const ownControlId = controlIndex === -1
|
|
189
|
+
? undefined
|
|
190
|
+
: items[controlIndex].props.id;
|
|
191
|
+
const fieldId = (_b = controlId !== null && controlId !== void 0 ? controlId : ownControlId) !== null && _b !== void 0 ? _b : generatedId;
|
|
192
|
+
const descriptionId = `${fieldId}-description`;
|
|
193
|
+
const errorId = `${fieldId}-error`;
|
|
194
|
+
/**
|
|
195
|
+
* A message element with children of its own renders them instead of the
|
|
196
|
+
* group's, so "is there a message" is a question about both. Reading the
|
|
197
|
+
* child's props during render rather than having it register itself keeps
|
|
198
|
+
* `aria-invalid` correct on the very first render, including on the
|
|
199
|
+
* server, where an effect would not have run.
|
|
200
|
+
*/
|
|
201
|
+
const contentOf = (slot, fallback) => {
|
|
202
|
+
const index = slots.indexOf(slot);
|
|
203
|
+
if (index === -1)
|
|
204
|
+
return undefined;
|
|
205
|
+
const own = items[index]
|
|
206
|
+
.props.children;
|
|
207
|
+
return own !== null && own !== void 0 ? own : fallback;
|
|
208
|
+
};
|
|
209
|
+
const shownError = contentOf('error', error);
|
|
210
|
+
const errorShown = Boolean(shownError);
|
|
211
|
+
// The error replaces the hint rather than joining it, so on an invalid
|
|
212
|
+
// field there is no hint left to describe the control with.
|
|
213
|
+
const descriptionShown = !errorShown && Boolean(contentOf('description', description));
|
|
214
|
+
const isInvalid = invalid !== null && invalid !== void 0 ? invalid : Boolean(error || shownError);
|
|
215
|
+
/**
|
|
216
|
+
* The group owns its two message ids outright: it strips them from
|
|
217
|
+
* whatever the control arrived with and puts them back only while the
|
|
218
|
+
* message they name is on the page. Everything else the control points at
|
|
219
|
+
* is left exactly as it was.
|
|
220
|
+
*
|
|
221
|
+
* Owning them in both directions is what matters. Only adding them would
|
|
222
|
+
* leave a caller who pre-wired `aria-describedby="<id>-error"` -- which
|
|
223
|
+
* `useFormGroup()` invites, since it hands out these very ids -- pointing
|
|
224
|
+
* at a removed element the moment the error cleared, because the group
|
|
225
|
+
* would have stopped appending the id while the caller's copy stayed put.
|
|
226
|
+
* A dangling idref announces nothing at all, which is the failure this
|
|
227
|
+
* component exists to prevent.
|
|
228
|
+
*/
|
|
229
|
+
const managedIds = new Set([descriptionId, errorId]);
|
|
230
|
+
const describedBy = (existing) => { var _a; return [
|
|
231
|
+
...new Set([
|
|
232
|
+
...((_a = existing === null || existing === void 0 ? void 0 : existing.split(/\s+/)) !== null && _a !== void 0 ? _a : []).filter(token => token && !managedIds.has(token)),
|
|
233
|
+
descriptionShown ? descriptionId : undefined,
|
|
234
|
+
errorShown ? errorId : undefined
|
|
235
|
+
].filter(Boolean))
|
|
236
|
+
].join(' ') || undefined; };
|
|
237
|
+
let controlWired = false;
|
|
238
|
+
const wire = (element, slot) => {
|
|
239
|
+
var _a;
|
|
240
|
+
const own = element.props;
|
|
241
|
+
if (slot === 'label') {
|
|
242
|
+
return React.cloneElement(element, {
|
|
243
|
+
htmlFor: (_a = own.htmlFor) !== null && _a !== void 0 ? _a : fieldId,
|
|
244
|
+
className: cn(horizontal && 'col-start-1 row-start-1 pe-3', disabled && 'opacity-70', own.className)
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
if (slot !== 'control') {
|
|
248
|
+
return React.cloneElement(element, {
|
|
249
|
+
className: cn(horizontal && 'col-start-2', own.className)
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
// Read before the flag is set, not inside `place` -- `place` runs after
|
|
253
|
+
// the assignment below, so a closure over `controlWired` would see
|
|
254
|
+
// `true` for the first control as well and never anchor it to the
|
|
255
|
+
// label's row.
|
|
256
|
+
const isFirstControl = !controlWired;
|
|
257
|
+
controlWired = true;
|
|
258
|
+
// Every control is wrapped in horizontal mode rather than given the
|
|
259
|
+
// placement classes directly: a control's `className` does not
|
|
260
|
+
// necessarily land on its outermost element -- `Input` puts it on the
|
|
261
|
+
// `<input>` inside its border -- so it is not a reliable way to position
|
|
262
|
+
// one in a grid.
|
|
263
|
+
//
|
|
264
|
+
// The first control is pinned to row 1 rather than left to
|
|
265
|
+
// auto-placement, which would happen to put it there only while the
|
|
266
|
+
// children are written in the order they are drawn in. A group whose
|
|
267
|
+
// `FieldError` comes first would otherwise give row 1 to the message and
|
|
268
|
+
// push the control below its own label.
|
|
269
|
+
const place = (node) => horizontal ? (_jsx("div", { className: cn('min-w-0', 'col-start-2', isFirstControl && 'row-start-1'), children: node }, element.key)) : (node);
|
|
270
|
+
if (!isFirstControl)
|
|
271
|
+
return place(element);
|
|
272
|
+
const wiring = {
|
|
273
|
+
// Already the control's own id unless `controlId` overrode it.
|
|
274
|
+
id: fieldId,
|
|
275
|
+
'aria-describedby': describedBy(own['aria-describedby'])
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* The one place the group overrules the control, and only because
|
|
279
|
+
* `aria-invalid="false"` is indistinguishable from no attribute at all
|
|
280
|
+
* in the accessibility tree. It is the attribute's default, so a control
|
|
281
|
+
* carrying it has asserted nothing, and treating it as a considered
|
|
282
|
+
* "this field is valid" would let a template that ships
|
|
283
|
+
* `aria-invalid={false}` -- a common enough default -- sit inside a
|
|
284
|
+
* group with an error and render a field that is visibly invalid,
|
|
285
|
+
* announces an error message, and tells a screen reader it is fine.
|
|
286
|
+
*
|
|
287
|
+
* Every other value is an assertion and is kept, including `grammar`
|
|
288
|
+
* and `spelling`, which say more than the group's `true` would.
|
|
289
|
+
*/
|
|
290
|
+
const ownInvalid = own['aria-invalid'];
|
|
291
|
+
const assertsValidity = ownInvalid !== undefined &&
|
|
292
|
+
ownInvalid !== false &&
|
|
293
|
+
ownInvalid !== 'false';
|
|
294
|
+
if (isInvalid && !assertsValidity) {
|
|
295
|
+
wiring['aria-invalid'] = true;
|
|
296
|
+
}
|
|
297
|
+
if (takesFormAttributes(element)) {
|
|
298
|
+
if (disabled !== undefined && own.disabled === undefined) {
|
|
299
|
+
wiring.disabled = disabled;
|
|
300
|
+
}
|
|
301
|
+
if (required !== undefined && own.required === undefined) {
|
|
302
|
+
wiring.required = required;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return place(React.cloneElement(element, wiring));
|
|
306
|
+
};
|
|
307
|
+
const context = React.useMemo(() => ({ description, error, descriptionId, errorId, errorShown }), [description, error, descriptionId, errorId, errorShown]);
|
|
308
|
+
return (_jsx(FormGroupContext.Provider, { value: context, children: _jsx("div", Object.assign({ ref: ref, className: cn(formGroupVariants({ orientation }), className) }, props, { children: items.map((child, index) => {
|
|
309
|
+
const slot = slots[index];
|
|
310
|
+
return slot === null
|
|
311
|
+
? child
|
|
312
|
+
: wire(child, slot);
|
|
313
|
+
}) })) }));
|
|
314
|
+
});
|
|
315
|
+
FormGroup.displayName = 'FormGroup';
|
|
316
|
+
export { FormGroup, FieldDescription, FieldError, useFormGroup };
|
|
317
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/FormGroup/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,GAAG,EA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AAS,EAAE,CAAC;gBACzD,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,MAA6B,CAAC,CAAC,CAAA;IAC1E,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAC3B,GAAG,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAClE,CAAC,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,CAAC,CACzD,CAAA;IAED,OAAO,CACL,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YACvC,4BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,SAAS,CAAC,IACxD,KAAK,cAER,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;gBACzB,OAAO,IAAI,KAAK,IAAI;oBAClB,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,IAAI,CAAC,KAA2B,EAAE,IAAI,CAAC,CAAA;YAC7C,CAAC,CAAC,IACE,GACoB,CAC7B,CAAA;AACH,CAAC,CACF,CAAA;AACD,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA;AAEnC,OAAO,EACL,SAAS,EAET,gBAAgB,EAChB,UAAU,EAEV,YAAY,EACb,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
declare const heroButtonVariants: (props?: ({
|
|
4
|
+
variant?: "primary" | "secondary" | null | undefined;
|
|
5
|
+
size?: "lg" | "md" | "xl" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export interface HeroButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof heroButtonVariants> {
|
|
8
|
+
leftSideChild?: React.ReactNode;
|
|
9
|
+
rightSideChild?: React.ReactNode;
|
|
10
|
+
leftSideClassName?: string;
|
|
11
|
+
rightSideClassName?: string;
|
|
12
|
+
children: any;
|
|
13
|
+
asChild?: boolean;
|
|
14
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
15
|
+
}
|
|
16
|
+
declare const HeroButton: React.ForwardRefExoticComponent<HeroButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
export { HeroButton, heroButtonVariants };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { Slot, Slottable } from '@radix-ui/react-slot';
|
|
15
|
+
import { cva } from 'class-variance-authority';
|
|
16
|
+
import { cn } from '../../lib/utils.js';
|
|
17
|
+
const heroButtonVariants = cva([
|
|
18
|
+
'inline-flex items-center justify-center',
|
|
19
|
+
'rounded-full',
|
|
20
|
+
'transition-colors',
|
|
21
|
+
'focus-visible:outline-hidden',
|
|
22
|
+
'disabled:pointer-events-none',
|
|
23
|
+
'cursor-pointer',
|
|
24
|
+
'disabled:cursor-default',
|
|
25
|
+
'font-bold'
|
|
26
|
+
], {
|
|
27
|
+
variants: {
|
|
28
|
+
variant: {
|
|
29
|
+
primary: [
|
|
30
|
+
'border-0',
|
|
31
|
+
'bg-button-primary',
|
|
32
|
+
'text-white',
|
|
33
|
+
'hover:bg-button-primary-hover',
|
|
34
|
+
'focus:bg-button-primary-focus',
|
|
35
|
+
'focus:shadow-brandGreen',
|
|
36
|
+
'active:shadow-none',
|
|
37
|
+
'disabled:bg-button-primary-disabled',
|
|
38
|
+
'disabled:text-foreground-subtle',
|
|
39
|
+
'dark:bg-button-primary-dark',
|
|
40
|
+
'dark:text-foreground-inverse-dark',
|
|
41
|
+
'dark:hover:bg-button-primary-hover-dark',
|
|
42
|
+
'dark:focus:bg-button-primary-dark',
|
|
43
|
+
'dark:focus:border-brandGreen-30',
|
|
44
|
+
'dark:active:border-transparent',
|
|
45
|
+
'dark:disabled:bg-button-primary-disabled-dark',
|
|
46
|
+
'dark:disabled:text-foreground-subtle'
|
|
47
|
+
],
|
|
48
|
+
secondary: [
|
|
49
|
+
'border-2',
|
|
50
|
+
'bg-white',
|
|
51
|
+
'text-grey-900',
|
|
52
|
+
'border-border',
|
|
53
|
+
'hover:bg-button-secondary-hover',
|
|
54
|
+
'hover:border-button-secondary-border-hover',
|
|
55
|
+
'focus:shadow-brandGreen',
|
|
56
|
+
'active:border-border',
|
|
57
|
+
'active:shadow-none',
|
|
58
|
+
'disabled:bg-button-secondary-disabled',
|
|
59
|
+
'disabled:border-button-secondary-border-disabled',
|
|
60
|
+
'disabled:text-foreground-subtle',
|
|
61
|
+
'dark:bg-button-secondary-dark',
|
|
62
|
+
'dark:border-button-secondary-border-dark',
|
|
63
|
+
'dark:text-white',
|
|
64
|
+
'dark:hover:bg-button-secondary-hover-dark',
|
|
65
|
+
'dark:hover:border-button-secondary-border-hover-dark',
|
|
66
|
+
'dark:focus:bg-button-secondary-dark',
|
|
67
|
+
'dark:focus:shadow-brandGreen10',
|
|
68
|
+
'dark:active:border-button-secondary-border-dark',
|
|
69
|
+
'dark:active:shadow-none',
|
|
70
|
+
'dark:disabled:bg-button-secondary-disabled-dark',
|
|
71
|
+
'dark:disabled:text-foreground-subtle-dark',
|
|
72
|
+
'dark:disabled:border-button-secondary-disabled-dark'
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
size: {
|
|
76
|
+
xl: ['px-4', 'py-3', 'text-xl', 'gap-2'],
|
|
77
|
+
lg: ['px-4', 'py-3', 'text-lg', 'gap-2'],
|
|
78
|
+
md: ['px-4', 'py-2.5', 'text-base', 'gap-1.5']
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
compoundVariants: [
|
|
82
|
+
{ variant: 'secondary', size: 'xl', class: 'py-2.5' },
|
|
83
|
+
{ variant: 'secondary', size: 'lg', class: 'py-2.5' },
|
|
84
|
+
{ variant: 'secondary', size: 'md', class: 'py-2' }
|
|
85
|
+
],
|
|
86
|
+
defaultVariants: {
|
|
87
|
+
variant: 'primary',
|
|
88
|
+
size: 'lg'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const HeroButton = React.forwardRef((_a, ref) => {
|
|
92
|
+
var { className, variant, children, size, leftSideChild, rightSideChild, leftSideClassName, rightSideClassName, disabled = false, asChild = false, onClick } = _a, props = __rest(_a, ["className", "variant", "children", "size", "leftSideChild", "rightSideChild", "leftSideClassName", "rightSideClassName", "disabled", "asChild", "onClick"]);
|
|
93
|
+
const sideChildClassed = 'inline-flex items-center justify-center text-inherit text-justify';
|
|
94
|
+
const Comp = asChild ? Slot : 'button';
|
|
95
|
+
return (_jsxs(Comp, Object.assign({ className: cn(heroButtonVariants({ variant, size }), className), ref: ref, disabled: disabled, onClick: e => {
|
|
96
|
+
if (onClick)
|
|
97
|
+
onClick(e);
|
|
98
|
+
} }, props, { children: [leftSideChild ? (_jsx("div", { className: cn(sideChildClassed, 'mr-3', leftSideClassName), children: leftSideChild })) : (_jsx(_Fragment, {})), _jsx(Slottable, { children: asChild ? children : _jsx("div", { children: children }) }), rightSideChild ? (_jsx("div", { className: cn(sideChildClassed, 'ml-3', rightSideClassName), children: rightSideChild })) : (_jsx(_Fragment, {}))] })));
|
|
99
|
+
});
|
|
100
|
+
HeroButton.displayName = 'HeroButton';
|
|
101
|
+
export { HeroButton, heroButtonVariants };
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/HeroButton/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AAEvC,MAAM,kBAAkB,GAAG,GAAG,CAC5B;IACE,yCAAyC;IACzC,cAAc;IACd,mBAAmB;IACnB,8BAA8B;IAC9B,8BAA8B;IAC9B,gBAAgB;IAChB,yBAAyB;IACzB,WAAW;CACZ,EACD;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,UAAU;gBACV,mBAAmB;gBACnB,YAAY;gBACZ,+BAA+B;gBAC/B,+BAA+B;gBAC/B,yBAAyB;gBACzB,oBAAoB;gBACpB,qCAAqC;gBACrC,iCAAiC;gBACjC,6BAA6B;gBAC7B,mCAAmC;gBACnC,yCAAyC;gBACzC,mCAAmC;gBACnC,iCAAiC;gBACjC,gCAAgC;gBAChC,+CAA+C;gBAC/C,sCAAsC;aACvC;YACD,SAAS,EAAE;gBACT,UAAU;gBACV,UAAU;gBACV,eAAe;gBACf,eAAe;gBACf,iCAAiC;gBACjC,4CAA4C;gBAC5C,yBAAyB;gBACzB,sB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AAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAA;IAEtC,OAAO,CACL,MAAC,IAAI,kBACH,SAAS,EAAE,EAAE,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,EAC/D,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,CAAC,EAAE;YACX,IAAI,OAAO;gBAAE,OAAO,CAAC,CAAC,CAAC,CAAA;QACzB,CAAC,IACG,KAAK,eAER,aAAa,CAAC,CAAC,CAAC,CACf,cAAK,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,CAAC,YAC5D,aAAa,GACV,CACP,CAAC,CAAC,CAAC,CACF,mBAAK,CACN,EACD,KAAC,SAAS,cAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,wBAAM,QAAQ,GAAO,GAAa,EAClE,cAAc,CAAC,CAAC,CAAC,CAChB,cAAK,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,kBAAkB,CAAC,YAC7D,cAAc,GACX,CACP,CAAC,CAAC,CAAC,CACF,mBAAK,CACN,KACI,CACR,CAAA;AACH,CAAC,CACF,CAAA;AAED,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { buttonVariants } from '../Button/index.tsx';
|
|
4
|
+
/**
|
|
5
|
+
* An icon button is a `Button` with the label taken out, so it takes its
|
|
6
|
+
* colours from `buttonVariants` rather than restating them. That import is
|
|
7
|
+
* the point rather than an economy: the two sit beside each other in a
|
|
8
|
+
* toolbar, so a variant that gained a hover state or a focus ring in one and
|
|
9
|
+
* not the other would be visible in the gap between them.
|
|
10
|
+
*
|
|
11
|
+
* `size: null` is how cva is told to skip a variant *and* its default, so
|
|
12
|
+
* `Button`'s padding and text sizes are left off entirely and the square
|
|
13
|
+
* below is the only thing setting the box.
|
|
14
|
+
*
|
|
15
|
+
* Which is the other half of the borrowing: a `Button`'s height is arithmetic
|
|
16
|
+
* -- padding plus line box plus border, with compound variants putting
|
|
17
|
+
* `secondary`'s 2px back -- and there is no line box here to add up, because
|
|
18
|
+
* there is no text. So the height is set outright, as `Input` sets its own,
|
|
19
|
+
* and `border-box` absorbs `secondary`'s border rather than a compound
|
|
20
|
+
* variant having to. The numbers are `Button`'s, measured: an icon button
|
|
21
|
+
* belongs in a row with one.
|
|
22
|
+
*/
|
|
23
|
+
declare const iconButtonVariants: (props?: ({
|
|
24
|
+
size?: "lg" | "md" | "sm" | "xs" | null | undefined;
|
|
25
|
+
shape?: "circle" | "rounded" | null | undefined;
|
|
26
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
27
|
+
interface IconButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'title'>, VariantProps<typeof iconButtonVariants> {
|
|
28
|
+
/** The icon. It is the whole of the button's content. */
|
|
29
|
+
icon: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* What the button does, in words -- "Close", "Add to basket", not "cross"
|
|
32
|
+
* or "plus". Required, because there is no text for a screen reader to fall
|
|
33
|
+
* back on.
|
|
34
|
+
*/
|
|
35
|
+
label: string;
|
|
36
|
+
variant?: VariantProps<typeof buttonVariants>['variant'];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A button whose content is an icon and nothing else: the close on a dialog,
|
|
40
|
+
* the actions at the end of a table row, a toolbar.
|
|
41
|
+
*
|
|
42
|
+
* `label` is required and has no default, which is the one way this differs
|
|
43
|
+
* from every other prop here. An icon button with no accessible name is a
|
|
44
|
+
* control a screen reader announces as "button" and nothing more, and unlike
|
|
45
|
+
* a missing colour it is invisible to everyone who is not affected by it.
|
|
46
|
+
* There is no name that could be guessed from an icon, so the type asks for
|
|
47
|
+
* one rather than inventing it (WCAG 4.1.2).
|
|
48
|
+
*
|
|
49
|
+
* The icon is left out of the accessibility tree by `aria-label` itself,
|
|
50
|
+
* which replaces an element's contents when the name is computed, so the icon
|
|
51
|
+
* needs no `aria-hidden` of its own. What the icon must not carry is a
|
|
52
|
+
* `title`, which would put a browser tooltip on it that the button's own
|
|
53
|
+
* `Tooltip` did not put there. That one is unreachable from here: `icon` is a
|
|
54
|
+
* `ReactNode`, so there is nothing to type-check.
|
|
55
|
+
*
|
|
56
|
+
* `title` is off the button as well, which is the one prop of a `<button>`
|
|
57
|
+
* this component takes away. It is not that it competes for the name --
|
|
58
|
+
* `title` is the last resort in the naming order, behind both `aria-label`
|
|
59
|
+
* and the contents, so while there is a label it never wins. It is that every
|
|
60
|
+
* reason to reach for it here is already served by something better, and
|
|
61
|
+
* served properly: a tooltip is `Tooltip`, which is reachable by keyboard and
|
|
62
|
+
* by touch as a native one is not, and a name is `label`. What is left is a
|
|
63
|
+
* second tooltip doubling up with the first, and a name that appears out of
|
|
64
|
+
* nowhere in the one case where `label` resolved empty. Neither is worth a
|
|
65
|
+
* prop, so the type stops it at the point where it can still be changed
|
|
66
|
+
* cheaply.
|
|
67
|
+
*
|
|
68
|
+
* Only the type stops it. A `title` arriving through an untyped spread is
|
|
69
|
+
* passed to the element like any other attribute, because deleting an
|
|
70
|
+
* attribute a caller explicitly set is a worse surprise than rendering it.
|
|
71
|
+
*
|
|
72
|
+
* `type` defaults to `"button"`. A bare `<button>` inside a form is a submit
|
|
73
|
+
* button, and an icon button is most often a close or a remove -- the one
|
|
74
|
+
* place that default does the most damage.
|
|
75
|
+
*/
|
|
76
|
+
declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
77
|
+
export { IconButton, iconButtonVariants, type IconButtonProps };
|