@jordan-mace/chaser-design-system 1.2.2 → 1.2.4
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/components/Accordion/Accordion.d.ts +2 -2
- package/dist/components/Accordion/Accordion.js +26 -91
- package/dist/components/Accordion/index.js +1 -2
- package/dist/components/Accordion/styles.css.js +65 -14
- package/dist/components/Alert/Alert.d.ts +1 -1
- package/dist/components/Alert/Alert.js +8 -28
- package/dist/components/Alert/index.js +1 -2
- package/dist/components/Alert/styles.css.js +54 -13
- package/dist/components/AspectRatio/AspectRatio.js +9 -24
- package/dist/components/AspectRatio/index.js +1 -2
- package/dist/components/Avatar/Avatar.d.ts +1 -1
- package/dist/components/Avatar/Avatar.js +10 -24
- package/dist/components/Avatar/index.js +1 -2
- package/dist/components/Avatar/styles.css.js +151 -19
- package/dist/components/Badge/Badge.d.ts +1 -1
- package/dist/components/Badge/Badge.js +8 -13
- package/dist/components/Badge/index.js +1 -2
- package/dist/components/Badge/styles.css.js +77 -23
- package/dist/components/Box/Box.js +18 -17
- package/dist/components/Box/index.js +1 -2
- package/dist/components/Box/reset.css.js +15 -3
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +1 -2
- package/dist/components/Breadcrumb/Breadcrumb.js +8 -66
- package/dist/components/Breadcrumb/index.js +1 -2
- package/dist/components/Breadcrumb/styles.css.js +50 -10
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +8 -15
- package/dist/components/Button/index.js +1 -2
- package/dist/components/Button/styles.css.js +30 -9
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Card/Card.js +8 -15
- package/dist/components/Card/index.js +1 -2
- package/dist/components/Card/styles.css.js +25 -10
- package/dist/components/Checkbox/Checkbox.js +20 -45
- package/dist/components/Checkbox/index.js +1 -2
- package/dist/components/Checkbox/styles.css.js +31 -7
- package/dist/components/Collapse/Collapse.d.ts +1 -1
- package/dist/components/Collapse/Collapse.js +40 -42
- package/dist/components/Collapse/index.js +1 -2
- package/dist/components/Collapse/styles.css.js +36 -8
- package/dist/components/Combobox/Combobox.d.ts +1 -1
- package/dist/components/Combobox/Combobox.js +62 -129
- package/dist/components/Combobox/index.js +1 -2
- package/dist/components/Combobox/styles.css.js +142 -20
- package/dist/components/Container/Container.js +9 -19
- package/dist/components/Container/index.js +1 -2
- package/dist/components/Divider/Divider.d.ts +1 -1
- package/dist/components/Divider/Divider.js +8 -14
- package/dist/components/Divider/index.js +1 -2
- package/dist/components/Divider/styles.css.js +41 -19
- package/dist/components/Drawer/Drawer.d.ts +1 -1
- package/dist/components/Drawer/Drawer.js +37 -85
- package/dist/components/Drawer/index.js +1 -2
- package/dist/components/Drawer/styles.css.js +125 -17
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +33 -88
- package/dist/components/DropdownMenu/index.js +1 -2
- package/dist/components/DropdownMenu/styles.css.d.ts +1 -1
- package/dist/components/DropdownMenu/styles.css.js +93 -22
- package/dist/components/EmptyState/EmptyState.d.ts +1 -1
- package/dist/components/EmptyState/EmptyState.js +8 -32
- package/dist/components/EmptyState/index.js +1 -2
- package/dist/components/EmptyState/styles.css.js +30 -9
- package/dist/components/FileUpload/FileUpload.d.ts +1 -1
- package/dist/components/FileUpload/FileUpload.js +63 -175
- package/dist/components/FileUpload/index.js +1 -2
- package/dist/components/FileUpload/styles.css.js +145 -32
- package/dist/components/Form/Form.d.ts +1 -1
- package/dist/components/Form/Form.js +8 -15
- package/dist/components/Form/FormInput.d.ts +1 -1
- package/dist/components/Form/FormInput.js +9 -15
- package/dist/components/Form/index.js +2 -3
- package/dist/components/Form/styles.css.js +11 -4
- package/dist/components/Grid/Grid.js +14 -19
- package/dist/components/Grid/index.js +1 -2
- package/dist/components/Icon/Icon.d.ts +1 -1
- package/dist/components/Icon/Icon.js +12 -20
- package/dist/components/Icon/index.js +1 -2
- package/dist/components/Icon/styles.css.js +9 -3
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Input/Input.js +9 -38
- package/dist/components/Input/index.js +1 -2
- package/dist/components/Input/styles.css.js +8 -4
- package/dist/components/Kbd/Kbd.d.ts +1 -1
- package/dist/components/Kbd/Kbd.js +6 -10
- package/dist/components/Kbd/index.js +1 -2
- package/dist/components/Kbd/styles.css.js +16 -5
- package/dist/components/List/List.d.ts +1 -1
- package/dist/components/List/List.js +7 -11
- package/dist/components/List/ListItem.d.ts +1 -1
- package/dist/components/List/ListItem.js +7 -11
- package/dist/components/List/index.js +2 -3
- package/dist/components/List/styles.css.js +11 -6
- package/dist/components/Modal/Modal.d.ts +1 -1
- package/dist/components/Modal/Modal.js +21 -57
- package/dist/components/Modal/index.js +1 -2
- package/dist/components/Modal/styles.css.js +92 -16
- package/dist/components/Navbar/Navbar.d.ts +1 -1
- package/dist/components/Navbar/Navbar.js +8 -16
- package/dist/components/Navbar/NavbarItem.d.ts +1 -1
- package/dist/components/Navbar/NavbarItem.js +8 -12
- package/dist/components/Navbar/index.js +2 -3
- package/dist/components/Navbar/styles.css.js +3 -4
- package/dist/components/NumberInput/NumberInput.d.ts +1 -1
- package/dist/components/NumberInput/NumberInput.js +25 -94
- package/dist/components/NumberInput/index.js +1 -2
- package/dist/components/NumberInput/styles.css.js +117 -17
- package/dist/components/Pagination/Pagination.d.ts +1 -2
- package/dist/components/Pagination/Pagination.js +34 -57
- package/dist/components/Pagination/index.js +1 -2
- package/dist/components/Pagination/styles.css.js +44 -11
- package/dist/components/Popover/Popover.d.ts +1 -1
- package/dist/components/Popover/Popover.js +43 -93
- package/dist/components/Popover/index.js +1 -2
- package/dist/components/Popover/styles.css.d.ts +2 -2
- package/dist/components/Popover/styles.css.js +185 -33
- package/dist/components/Progress/Progress.d.ts +1 -2
- package/dist/components/Progress/Progress.js +8 -54
- package/dist/components/Progress/index.js +1 -2
- package/dist/components/Progress/styles.css.js +71 -18
- package/dist/components/Radio/Radio.d.ts +2 -2
- package/dist/components/Radio/Radio.js +17 -52
- package/dist/components/Radio/index.js +1 -2
- package/dist/components/Radio/styles.css.js +42 -9
- package/dist/components/ScrollArea/ScrollArea.d.ts +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +8 -18
- package/dist/components/ScrollArea/index.js +1 -2
- package/dist/components/ScrollArea/styles.css.js +25 -11
- package/dist/components/Select/Select.js +9 -35
- package/dist/components/Select/index.js +1 -2
- package/dist/components/Select/styles.css.js +82 -11
- package/dist/components/Separator/Separator.d.ts +1 -2
- package/dist/components/Separator/Separator.js +8 -13
- package/dist/components/Separator/index.js +1 -2
- package/dist/components/Separator/styles.css.js +28 -15
- package/dist/components/Skeleton/Skeleton.d.ts +1 -1
- package/dist/components/Skeleton/Skeleton.js +9 -24
- package/dist/components/Skeleton/index.js +1 -2
- package/dist/components/Skeleton/styles.css.js +56 -20
- package/dist/components/Spinner/Spinner.d.ts +1 -1
- package/dist/components/Spinner/Spinner.js +8 -14
- package/dist/components/Spinner/index.js +1 -2
- package/dist/components/Spinner/styles.css.d.ts +1 -1
- package/dist/components/Spinner/styles.css.js +55 -19
- package/dist/components/Stack/Stack.js +10 -25
- package/dist/components/Stack/index.js +1 -2
- package/dist/components/Stepper/Stepper.d.ts +1 -1
- package/dist/components/Stepper/Stepper.js +19 -64
- package/dist/components/Stepper/index.js +1 -2
- package/dist/components/Stepper/styles.css.js +104 -22
- package/dist/components/Table/Table.d.ts +7 -7
- package/dist/components/Table/Table.js +30 -56
- package/dist/components/Table/index.js +1 -2
- package/dist/components/Table/styles.css.js +49 -15
- package/dist/components/Tabs/Tabs.d.ts +4 -4
- package/dist/components/Tabs/Tabs.js +33 -52
- package/dist/components/Tabs/index.js +1 -2
- package/dist/components/Tabs/styles.css.js +100 -14
- package/dist/components/Tag/Tag.d.ts +2 -2
- package/dist/components/Tag/Tag.js +16 -38
- package/dist/components/Tag/index.js +1 -2
- package/dist/components/Tag/styles.css.d.ts +1 -1
- package/dist/components/Tag/styles.css.js +93 -14
- package/dist/components/Text/Header.d.ts +1 -1
- package/dist/components/Text/Header.js +8 -12
- package/dist/components/Text/P.d.ts +1 -1
- package/dist/components/Text/P.js +8 -12
- package/dist/components/Text/index.js +2 -3
- package/dist/components/Text/styles.css.js +13 -6
- package/dist/components/TextArea/TextArea.d.ts +1 -1
- package/dist/components/TextArea/TextArea.js +9 -38
- package/dist/components/TextArea/index.js +1 -2
- package/dist/components/TextArea/styles.css.js +10 -4
- package/dist/components/Toast/Toast.d.ts +3 -3
- package/dist/components/Toast/Toast.js +85 -144
- package/dist/components/Toast/index.js +1 -2
- package/dist/components/Toast/styles.css.d.ts +1 -1
- package/dist/components/Toast/styles.css.js +192 -32
- package/dist/components/Toggle/Toggle.d.ts +1 -1
- package/dist/components/Toggle/Toggle.js +12 -57
- package/dist/components/Toggle/index.js +1 -2
- package/dist/components/Toggle/styles.css.js +118 -24
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.js +12 -37
- package/dist/components/Tooltip/index.js +1 -2
- package/dist/components/Tooltip/styles.css.js +86 -17
- package/dist/components/VisuallyHidden/VisuallyHidden.js +7 -6
- package/dist/components/VisuallyHidden/index.js +1 -2
- package/dist/components/VisuallyHidden/styles.css.js +12 -3
- package/dist/components/index.js +47 -48
- package/dist/index.js +1 -1
- package/dist/styles/layers.css.js +3 -4
- package/dist/styles/sprinkles.css.d.ts +115 -115
- package/dist/styles/sprinkles.css.js +72 -2219
- package/dist/styles/theme.css.js +48 -38
- package/dist/styles/utils.js +7 -8
- package/package.json +12 -16
- package/src/components/Accordion/Accordion.stories.tsx +73 -0
- package/src/components/Accordion/Accordion.test.tsx +54 -0
- package/src/components/Accordion/Accordion.tsx +146 -0
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/Accordion/styles.css.ts +72 -0
- package/src/components/Alert/Alert.stories.tsx +82 -0
- package/src/components/Alert/Alert.test.tsx +58 -0
- package/src/components/Alert/Alert.tsx +48 -0
- package/src/components/Alert/__screenshots__/Alert.test.tsx/Alert-renders-dismissible-alert-correctly-1-chromium-linux.png +0 -0
- package/src/components/Alert/__screenshots__/Alert.test.tsx/Alert-renders-error-alert-correctly-1-chromium-linux.png +0 -0
- package/src/components/Alert/__screenshots__/Alert.test.tsx/Alert-renders-info-alert-correctly-1-chromium-linux.png +0 -0
- package/src/components/Alert/__screenshots__/Alert.test.tsx/Alert-renders-success-alert-correctly-1-chromium-linux.png +0 -0
- package/src/components/Alert/__screenshots__/Alert.test.tsx/Alert-renders-warning-alert-correctly-1-chromium-linux.png +0 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/Alert/styles.css.ts +58 -0
- package/src/components/AspectRatio/AspectRatio.stories.tsx +85 -0
- package/src/components/AspectRatio/AspectRatio.test.tsx +50 -0
- package/src/components/AspectRatio/AspectRatio.tsx +42 -0
- package/src/components/AspectRatio/index.ts +2 -0
- package/src/components/Avatar/Avatar.stories.tsx +82 -0
- package/src/components/Avatar/Avatar.test.tsx +45 -0
- package/src/components/Avatar/Avatar.tsx +51 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/styles.css.ts +155 -0
- package/src/components/Badge/Badge.stories.tsx +141 -0
- package/src/components/Badge/Badge.test.tsx +74 -0
- package/src/components/Badge/Badge.tsx +46 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-does-not-render-children-when-dot-is-true-1.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-default-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-dot-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-dot-with-size-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-dot-with-variant-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-error-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-info-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-large-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-medium-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-small-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-span-element-with-proper-attributes-1.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-success-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/__screenshots__/Badge.test.tsx/Badge-renders-warning-badge-correctly-1-chromium-linux.png +0 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/Badge/styles.css.ts +82 -0
- package/src/components/Box/Box.stories.tsx +183 -0
- package/src/components/Box/Box.test.tsx +63 -0
- package/src/components/Box/Box.tsx +72 -0
- package/src/components/Box/index.ts +2 -0
- package/src/components/Box/reset.css.ts +16 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +55 -0
- package/src/components/Breadcrumb/Breadcrumb.test.tsx +44 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +102 -0
- package/src/components/Breadcrumb/index.ts +1 -0
- package/src/components/Breadcrumb/styles.css.ts +56 -0
- package/src/components/Button/Button.stories.tsx +60 -0
- package/src/components/Button/Button.test.tsx +26 -0
- package/src/components/Button/Button.tsx +31 -0
- package/src/components/Button/__screenshots__/Button.test.tsx/Button-renders-correctly-1-chromium-win32.png +0 -0
- package/src/components/Button/__screenshots__/Button.test.tsx/Button-renders-primary-button-correctly-1-chromium-linux.png +0 -0
- package/src/components/Button/__screenshots__/Button.test.tsx/Button-renders-primary-button-correctly-1-chromium-win32.png +0 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Button/styles.css.ts +32 -0
- package/src/components/Card/Card.stories.tsx +85 -0
- package/src/components/Card/Card.test.tsx +43 -0
- package/src/components/Card/Card.tsx +34 -0
- package/src/components/Card/__screenshots__/Card.test.tsx/Card-renders-elevated-card-correctly-1-chromium-linux.png +0 -0
- package/src/components/Card/__screenshots__/Card.test.tsx/Card-renders-filled-card-correctly-1-chromium-linux.png +0 -0
- package/src/components/Card/__screenshots__/Card.test.tsx/Card-renders-outlined-card-correctly-1-chromium-linux.png +0 -0
- package/src/components/Card/__screenshots__/Card.test.tsx/Card-renders-with-no-padding-1-chromium-linux.png +0 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Card/styles.css.ts +27 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +61 -0
- package/src/components/Checkbox/Checkbox.test.tsx +40 -0
- package/src/components/Checkbox/Checkbox.tsx +58 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/Checkbox/styles.css.ts +34 -0
- package/src/components/Collapse/Collapse.stories.tsx +63 -0
- package/src/components/Collapse/Collapse.test.tsx +24 -0
- package/src/components/Collapse/Collapse.tsx +97 -0
- package/src/components/Collapse/index.ts +2 -0
- package/src/components/Collapse/styles.css.ts +42 -0
- package/src/components/Combobox/Combobox.stories.tsx +100 -0
- package/src/components/Combobox/Combobox.test.tsx +49 -0
- package/src/components/Combobox/Combobox.tsx +266 -0
- package/src/components/Combobox/index.ts +2 -0
- package/src/components/Combobox/styles.css.ts +155 -0
- package/src/components/Container/Container.stories.tsx +69 -0
- package/src/components/Container/Container.test.tsx +42 -0
- package/src/components/Container/Container.tsx +47 -0
- package/src/components/Container/index.ts +2 -0
- package/src/components/Divider/Divider.stories.tsx +121 -0
- package/src/components/Divider/Divider.test.tsx +56 -0
- package/src/components/Divider/Divider.tsx +40 -0
- package/src/components/Divider/__screenshots__/Divider.test.tsx/Divider-applies-orientation-correctly-1.png +0 -0
- package/src/components/Divider/__screenshots__/Divider.test.tsx/Divider-renders-horizontal-divider-correctly-1-chromium-linux.png +0 -0
- package/src/components/Divider/__screenshots__/Divider.test.tsx/Divider-renders-hr-element-with-proper-attributes-1.png +0 -0
- package/src/components/Divider/__screenshots__/Divider.test.tsx/Divider-renders-large-divider-correctly-1-chromium-linux.png +0 -0
- package/src/components/Divider/__screenshots__/Divider.test.tsx/Divider-renders-medium-divider-correctly-1-chromium-linux.png +0 -0
- package/src/components/Divider/__screenshots__/Divider.test.tsx/Divider-renders-small-divider-correctly-1-chromium-linux.png +0 -0
- package/src/components/Divider/__screenshots__/Divider.test.tsx/Divider-renders-vertical-divider-correctly-1-chromium-linux.png +0 -0
- package/src/components/Divider/index.ts +2 -0
- package/src/components/Divider/styles.css.ts +45 -0
- package/src/components/Drawer/Drawer.stories.tsx +99 -0
- package/src/components/Drawer/Drawer.test.tsx +51 -0
- package/src/components/Drawer/Drawer.tsx +148 -0
- package/src/components/Drawer/index.ts +2 -0
- package/src/components/Drawer/styles.css.ts +138 -0
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +72 -0
- package/src/components/DropdownMenu/DropdownMenu.test.tsx +43 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +156 -0
- package/src/components/DropdownMenu/index.ts +2 -0
- package/src/components/DropdownMenu/styles.css.ts +102 -0
- package/src/components/EmptyState/EmptyState.stories.tsx +47 -0
- package/src/components/EmptyState/EmptyState.test.tsx +25 -0
- package/src/components/EmptyState/EmptyState.tsx +53 -0
- package/src/components/EmptyState/index.ts +2 -0
- package/src/components/EmptyState/styles.css.ts +36 -0
- package/src/components/FileUpload/FileUpload.stories.tsx +138 -0
- package/src/components/FileUpload/FileUpload.test.tsx +56 -0
- package/src/components/FileUpload/FileUpload.tsx +269 -0
- package/src/components/FileUpload/index.ts +2 -0
- package/src/components/FileUpload/styles.css.ts +164 -0
- package/src/components/Form/Form.stories.tsx +51 -0
- package/src/components/Form/Form.test.tsx +41 -0
- package/src/components/Form/Form.tsx +28 -0
- package/src/components/Form/FormInput.tsx +16 -0
- package/src/components/Form/__screenshots__/Form.test.tsx/Form-can-submit-1.png +0 -0
- package/src/components/Form/__screenshots__/Form.test.tsx/Form-renders-correctly-1-chromium-win32.png +0 -0
- package/src/components/Form/__screenshots__/Form.test.tsx/Form-renders-form-correctly-1-chromium-linux.png +0 -0
- package/src/components/Form/__screenshots__/Form.test.tsx/Form-renders-form-correctly-1-chromium-win32.png +0 -0
- package/src/components/Form/index.ts +2 -0
- package/src/components/Form/styles.css.ts +13 -0
- package/src/components/Grid/Grid.stories.tsx +134 -0
- package/src/components/Grid/Grid.test.tsx +41 -0
- package/src/components/Grid/Grid.tsx +48 -0
- package/src/components/Grid/index.ts +2 -0
- package/src/components/Icon/Icon.tsx +43 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/Icon/styles.css.ts +11 -0
- package/src/components/Input/Input.stories.tsx +38 -0
- package/src/components/Input/Input.test.tsx +16 -0
- package/src/components/Input/Input.tsx +43 -0
- package/src/components/Input/__screenshots__/Input.test.tsx/Input-renders-correctly-with-label-1-chromium-linux.png +0 -0
- package/src/components/Input/__screenshots__/Input.test.tsx/Input-renders-correctly-with-label-1-chromium-win32.png +0 -0
- package/src/components/Input/__screenshots__/Input.test.tsx/Input-renders-correctly-without-label-1-chromium-linux.png +0 -0
- package/src/components/Input/__screenshots__/Input.test.tsx/Input-renders-correctly-without-label-1-chromium-win32.png +0 -0
- package/src/components/Input/index.ts +1 -0
- package/src/components/Input/styles.css.ts +10 -0
- package/src/components/Kbd/Kbd.stories.tsx +53 -0
- package/src/components/Kbd/Kbd.test.tsx +22 -0
- package/src/components/Kbd/Kbd.tsx +17 -0
- package/src/components/Kbd/index.ts +2 -0
- package/src/components/Kbd/styles.css.ts +18 -0
- package/src/components/List/List.test.tsx +18 -0
- package/src/components/List/List.tsx +13 -0
- package/src/components/List/ListItem.tsx +13 -0
- package/src/components/List/__screenshots__/List.test.tsx/List-renders-correctly-1-chromium-win32.png +0 -0
- package/src/components/List/__screenshots__/List.test.tsx/List-renders-list-correctly-1-chromium-linux.png +0 -0
- package/src/components/List/__screenshots__/List.test.tsx/List-renders-list-correctly-1-chromium-win32.png +0 -0
- package/src/components/List/index.ts +2 -0
- package/src/components/List/styles.css.ts +13 -0
- package/src/components/Modal/Modal.stories.tsx +202 -0
- package/src/components/Modal/Modal.test.tsx +168 -0
- package/src/components/Modal/Modal.tsx +109 -0
- package/src/components/Modal/__screenshots__/Modal.test.tsx/Modal-displays-title-correctly-1.png +0 -0
- package/src/components/Modal/__screenshots__/Modal.test.tsx/Modal-handles-backdrop-click-to-close-1.png +0 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Modal/styles.css.ts +99 -0
- package/src/components/Navbar/Navbar.stories.tsx +49 -0
- package/src/components/Navbar/Navbar.test.tsx +18 -0
- package/src/components/Navbar/Navbar.tsx +27 -0
- package/src/components/Navbar/NavbarItem.tsx +14 -0
- package/src/components/Navbar/__screenshots__/Navbar.test.tsx/Navbar-renders-correctly-1-chromium-win32.png +0 -0
- package/src/components/Navbar/__screenshots__/Navbar.test.tsx/Navbar-renders-navbar-correctly-1-chromium-linux.png +0 -0
- package/src/components/Navbar/__screenshots__/Navbar.test.tsx/Navbar-renders-navbar-correctly-1-chromium-win32.png +0 -0
- package/src/components/Navbar/index.ts +2 -0
- package/src/components/Navbar/styles.css.ts +5 -0
- package/src/components/NumberInput/NumberInput.stories.tsx +101 -0
- package/src/components/NumberInput/NumberInput.test.tsx +39 -0
- package/src/components/NumberInput/NumberInput.tsx +161 -0
- package/src/components/NumberInput/index.ts +2 -0
- package/src/components/NumberInput/styles.css.ts +127 -0
- package/src/components/Pagination/Pagination.stories.tsx +63 -0
- package/src/components/Pagination/Pagination.test.tsx +27 -0
- package/src/components/Pagination/Pagination.tsx +138 -0
- package/src/components/Pagination/index.ts +2 -0
- package/src/components/Pagination/styles.css.ts +48 -0
- package/src/components/Popover/Popover.stories.tsx +80 -0
- package/src/components/Popover/Popover.test.tsx +47 -0
- package/src/components/Popover/Popover.tsx +171 -0
- package/src/components/Popover/index.ts +2 -0
- package/src/components/Popover/styles.css.ts +197 -0
- package/src/components/Progress/Progress.stories.tsx +73 -0
- package/src/components/Progress/Progress.test.tsx +53 -0
- package/src/components/Progress/Progress.tsx +66 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Progress/styles.css.ts +75 -0
- package/src/components/Radio/Radio.stories.tsx +75 -0
- package/src/components/Radio/Radio.test.tsx +54 -0
- package/src/components/Radio/Radio.tsx +104 -0
- package/src/components/Radio/index.ts +1 -0
- package/src/components/Radio/styles.css.ts +47 -0
- package/src/components/ScrollArea/ScrollArea.stories.tsx +63 -0
- package/src/components/ScrollArea/ScrollArea.test.tsx +24 -0
- package/src/components/ScrollArea/ScrollArea.tsx +50 -0
- package/src/components/ScrollArea/index.ts +2 -0
- package/src/components/ScrollArea/styles.css.ts +28 -0
- package/src/components/Select/Select.stories.tsx +94 -0
- package/src/components/Select/Select.test.tsx +57 -0
- package/src/components/Select/Select.tsx +60 -0
- package/src/components/Select/index.ts +1 -0
- package/src/components/Select/styles.css.ts +86 -0
- package/src/components/Separator/Separator.stories.tsx +49 -0
- package/src/components/Separator/Separator.test.tsx +22 -0
- package/src/components/Separator/Separator.tsx +37 -0
- package/src/components/Separator/index.ts +2 -0
- package/src/components/Separator/styles.css.ts +32 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +78 -0
- package/src/components/Skeleton/Skeleton.test.tsx +36 -0
- package/src/components/Skeleton/Skeleton.tsx +67 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/Skeleton/styles.css.ts +62 -0
- package/src/components/Spinner/Spinner.stories.tsx +123 -0
- package/src/components/Spinner/Spinner.test.tsx +73 -0
- package/src/components/Spinner/Spinner.tsx +41 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-div-element-with-proper-attributes-1.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-error-color-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-info-color-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-large-spinner-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-medium-spinner-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-primary-spinner-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-secondary-color-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-small-spinner-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-success-color-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/__screenshots__/Spinner.test.tsx/Spinner-renders-warning-color-correctly-1-chromium-linux.png +0 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Spinner/styles.css.ts +59 -0
- package/src/components/Stack/Stack.stories.tsx +123 -0
- package/src/components/Stack/Stack.test.tsx +48 -0
- package/src/components/Stack/Stack.tsx +60 -0
- package/src/components/Stack/index.ts +2 -0
- package/src/components/Stepper/Stepper.stories.tsx +85 -0
- package/src/components/Stepper/Stepper.test.tsx +47 -0
- package/src/components/Stepper/Stepper.tsx +133 -0
- package/src/components/Stepper/index.ts +2 -0
- package/src/components/Stepper/styles.css.ts +118 -0
- package/src/components/Table/Table.stories.tsx +147 -0
- package/src/components/Table/Table.test.tsx +104 -0
- package/src/components/Table/Table.tsx +131 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/Table/styles.css.ts +57 -0
- package/src/components/Tabs/Tabs.stories.tsx +104 -0
- package/src/components/Tabs/Tabs.test.tsx +52 -0
- package/src/components/Tabs/Tabs.tsx +147 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/Tabs/styles.css.ts +106 -0
- package/src/components/Tag/Tag.stories.tsx +72 -0
- package/src/components/Tag/Tag.test.tsx +49 -0
- package/src/components/Tag/Tag.tsx +72 -0
- package/src/components/Tag/index.ts +1 -0
- package/src/components/Tag/styles.css.ts +96 -0
- package/src/components/Text/Header.stories.tsx +45 -0
- package/src/components/Text/Header.tsx +20 -0
- package/src/components/Text/P.stories.tsx +24 -0
- package/src/components/Text/P.tsx +19 -0
- package/src/components/Text/Text.test.tsx +32 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/Header-renders-h1-correctly-1-chromium-linux.png +0 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/Header-renders-h1-correctly-1-chromium-win32.png +0 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/Header-renders-h2-correctly-1-chromium-linux.png +0 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/Header-renders-h2-correctly-1-chromium-win32.png +0 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/Header-renders-h3-correctly-1-chromium-linux.png +0 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/Header-renders-h3-correctly-1-chromium-win32.png +0 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/P-renders-correctly-1-chromium-win32.png +0 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/P-renders-p-correctly-1-chromium-linux.png +0 -0
- package/src/components/Text/__screenshots__/Text.test.tsx/P-renders-p-correctly-1-chromium-win32.png +0 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/Text/styles.css.ts +15 -0
- package/src/components/TextArea/TextArea.stories.tsx +40 -0
- package/src/components/TextArea/TextArea.test.tsx +16 -0
- package/src/components/TextArea/TextArea.tsx +43 -0
- package/src/components/TextArea/index.ts +2 -0
- package/src/components/TextArea/styles.css.ts +12 -0
- package/src/components/Toast/Toast.tsx +342 -0
- package/src/components/Toast/index.ts +9 -0
- package/src/components/Toast/styles.css.ts +213 -0
- package/src/components/Toggle/Toggle.stories.tsx +190 -0
- package/src/components/Toggle/Toggle.test.tsx +85 -0
- package/src/components/Toggle/Toggle.tsx +94 -0
- package/src/components/Toggle/index.ts +2 -0
- package/src/components/Toggle/styles.css.ts +130 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +111 -0
- package/src/components/Tooltip/Tooltip.test.tsx +93 -0
- package/src/components/Tooltip/Tooltip.tsx +72 -0
- package/src/components/Tooltip/__screenshots__/Tooltip.test.tsx/Tooltip-has-proper-role-attribute-1.png +0 -0
- package/src/components/Tooltip/__screenshots__/Tooltip.test.tsx/Tooltip-renders-bottom-tooltip-correctly-1-chromium-linux.png +0 -0
- package/src/components/Tooltip/__screenshots__/Tooltip.test.tsx/Tooltip-renders-left-tooltip-correctly-1-chromium-linux.png +0 -0
- package/src/components/Tooltip/__screenshots__/Tooltip.test.tsx/Tooltip-renders-right-tooltip-correctly-1-chromium-linux.png +0 -0
- package/src/components/Tooltip/__screenshots__/Tooltip.test.tsx/Tooltip-renders-tooltip-without-arrow-1-chromium-linux.png +0 -0
- package/src/components/Tooltip/__screenshots__/Tooltip.test.tsx/Tooltip-renders-top-tooltip-correctly-1-chromium-linux.png +0 -0
- package/src/components/Tooltip/__screenshots__/Tooltip.test.tsx/Tooltip-renders-with-tooltip-content-1.png +0 -0
- package/src/components/Tooltip/__screenshots__/Tooltip.test.tsx/Tooltip-shows-tooltip-on-hover-1.png +0 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/Tooltip/styles.css.ts +94 -0
- package/src/components/VisuallyHidden/VisuallyHidden.stories.tsx +42 -0
- package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +20 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +26 -0
- package/src/components/VisuallyHidden/index.ts +2 -0
- package/src/components/VisuallyHidden/styles.css.ts +14 -0
- package/src/components/index.ts +68 -0
- package/src/index.ts +1 -0
- package/src/styles/layers.css.ts +3 -0
- package/src/styles/reset.css.ts +79 -0
- package/src/styles/sprinkles.css.ts +177 -0
- package/src/styles/theme.css.ts +55 -0
- package/src/styles/utils.ts +9 -0
- package/dist/layers.css.js +0 -4
- package/dist/reset.css.js +0 -1
- package/dist/styles/reset.css.js +0 -1
- package/dist/theme.css.js +0 -41
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { fn } from 'storybook/test';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { FileUpload } from '.';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/FileUpload',
|
|
8
|
+
component: FileUpload,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
},
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
} satisfies Meta<typeof FileUpload>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
label: 'Upload Documents',
|
|
21
|
+
dropzoneText: 'Drag and drop files here, or click to browse',
|
|
22
|
+
hint: 'Maximum file size: 10MB',
|
|
23
|
+
onFileAdd: fn(),
|
|
24
|
+
onFileRemove: fn(),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Multiple: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
label: 'Upload Multiple Files',
|
|
31
|
+
multiple: true,
|
|
32
|
+
dropzoneText: 'Drop multiple files here',
|
|
33
|
+
hint: 'You can upload multiple files at once',
|
|
34
|
+
onFileAdd: fn(),
|
|
35
|
+
onFileRemove: fn(),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const WithFiles: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
label: 'Uploaded Files',
|
|
42
|
+
files: [
|
|
43
|
+
{
|
|
44
|
+
id: '1',
|
|
45
|
+
file: new File(['content'], 'document.pdf', { type: 'application/pdf' }),
|
|
46
|
+
name: 'document.pdf',
|
|
47
|
+
size: 1024000,
|
|
48
|
+
progress: 100,
|
|
49
|
+
status: 'success',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: '2',
|
|
53
|
+
file: new File(['content'], 'image.png', { type: 'image/png' }),
|
|
54
|
+
name: 'image.png',
|
|
55
|
+
size: 2048000,
|
|
56
|
+
progress: 50,
|
|
57
|
+
status: 'uploading',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
onFileRemove: fn(),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const AcceptSpecificTypes: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
label: 'Upload Images',
|
|
67
|
+
accept: 'image/*',
|
|
68
|
+
dropzoneText: 'Drop images here (PNG, JPG, GIF)',
|
|
69
|
+
hint: 'Only image files are accepted',
|
|
70
|
+
onFileAdd: fn(),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const MaxFileSize: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
label: 'Upload Small Files',
|
|
77
|
+
maxFileSize: 1024 * 1024, // 1MB
|
|
78
|
+
dropzoneText: 'Drop files here (max 1MB)',
|
|
79
|
+
hint: 'Files larger than 1MB will be rejected',
|
|
80
|
+
onFileAdd: fn(),
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const MaxFiles: Story = {
|
|
85
|
+
args: {
|
|
86
|
+
label: 'Upload Limited Files',
|
|
87
|
+
multiple: true,
|
|
88
|
+
maxFiles: 3,
|
|
89
|
+
dropzoneText: 'Drop up to 3 files',
|
|
90
|
+
files: [
|
|
91
|
+
{
|
|
92
|
+
id: '1',
|
|
93
|
+
file: new File(['content'], 'file1.pdf', { type: 'application/pdf' }),
|
|
94
|
+
name: 'file1.pdf',
|
|
95
|
+
size: 102400,
|
|
96
|
+
progress: 100,
|
|
97
|
+
status: 'success',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
onFileAdd: fn(),
|
|
101
|
+
onFileRemove: fn(),
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const Disabled: Story = {
|
|
106
|
+
args: {
|
|
107
|
+
label: 'Upload',
|
|
108
|
+
disabled: true,
|
|
109
|
+
files: [
|
|
110
|
+
{
|
|
111
|
+
id: '1',
|
|
112
|
+
file: new File(['content'], 'readonly.pdf', { type: 'application/pdf' }),
|
|
113
|
+
name: 'readonly.pdf',
|
|
114
|
+
size: 512000,
|
|
115
|
+
progress: 100,
|
|
116
|
+
status: 'success',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const WithoutProgress: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
label: 'Simple Upload',
|
|
125
|
+
showProgress: false,
|
|
126
|
+
files: [
|
|
127
|
+
{
|
|
128
|
+
id: '1',
|
|
129
|
+
file: new File(['content'], 'simple.pdf', { type: 'application/pdf' }),
|
|
130
|
+
name: 'simple.pdf',
|
|
131
|
+
size: 1024000,
|
|
132
|
+
progress: 75,
|
|
133
|
+
status: 'uploading',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
onFileRemove: fn(),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { render } from 'vitest-browser-react';
|
|
3
|
+
import FileUpload from './FileUpload';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
describe('FileUpload', () => {
|
|
7
|
+
it('renders correctly in default state', async () => {
|
|
8
|
+
const { container } = await render(
|
|
9
|
+
<FileUpload label="Upload Files" dropzoneText="Drop files here or click to upload" />
|
|
10
|
+
);
|
|
11
|
+
expect(container).toMatchScreenshot();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('renders with files list', async () => {
|
|
15
|
+
const files = [
|
|
16
|
+
{
|
|
17
|
+
id: '1',
|
|
18
|
+
file: new File(['content'], 'document.pdf', { type: 'application/pdf' }),
|
|
19
|
+
name: 'document.pdf',
|
|
20
|
+
size: 1024,
|
|
21
|
+
progress: 100,
|
|
22
|
+
status: 'success' as const
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: '2',
|
|
26
|
+
file: new File(['content'], 'image.png', { type: 'image/png' }),
|
|
27
|
+
name: 'image.png',
|
|
28
|
+
size: 2048,
|
|
29
|
+
progress: 50,
|
|
30
|
+
status: 'uploading' as const
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const { container } = await render(
|
|
35
|
+
<FileUpload label="Upload" files={files} />
|
|
36
|
+
);
|
|
37
|
+
expect(container).toMatchScreenshot();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('renders with hint text', async () => {
|
|
41
|
+
const { container } = await render(
|
|
42
|
+
<FileUpload
|
|
43
|
+
label="Upload Documents"
|
|
44
|
+
hint="Maximum file size: 10MB. Supported formats: PDF, PNG, JPG"
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
expect(container).toMatchScreenshot();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('renders disabled state', async () => {
|
|
51
|
+
const { container } = await render(
|
|
52
|
+
<FileUpload label="Upload" disabled={true} />
|
|
53
|
+
);
|
|
54
|
+
expect(container).toMatchScreenshot();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React, { useState, useRef, useCallback } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
fileUploadContainer,
|
|
5
|
+
fileUploadDropzone,
|
|
6
|
+
fileUploadDropzoneVariants,
|
|
7
|
+
fileUploadLabel,
|
|
8
|
+
fileUploadText,
|
|
9
|
+
fileUploadHint,
|
|
10
|
+
fileUploadInput,
|
|
11
|
+
fileUploadList,
|
|
12
|
+
fileUploadItem,
|
|
13
|
+
fileUploadItemInfo,
|
|
14
|
+
fileUploadItemName,
|
|
15
|
+
fileUploadItemSize,
|
|
16
|
+
fileUploadRemoveButton,
|
|
17
|
+
fileUploadError,
|
|
18
|
+
fileUploadIcon,
|
|
19
|
+
fileUploadProgressBar,
|
|
20
|
+
fileUploadProgressFill,
|
|
21
|
+
fileUploadProgressFillVariants,
|
|
22
|
+
} from './styles.css';
|
|
23
|
+
import Box from '../Box';
|
|
24
|
+
|
|
25
|
+
export interface FileUploadFile {
|
|
26
|
+
id: string;
|
|
27
|
+
file: File;
|
|
28
|
+
name: string;
|
|
29
|
+
size: number;
|
|
30
|
+
progress: number;
|
|
31
|
+
status: 'uploading' | 'success' | 'error';
|
|
32
|
+
errorMessage?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface FileUploadProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
36
|
+
label?: string;
|
|
37
|
+
files?: FileUploadFile[];
|
|
38
|
+
onFilesChange?: (files: FileUploadFile[]) => void;
|
|
39
|
+
onFileAdd?: (files: File[]) => void;
|
|
40
|
+
onFileRemove?: (fileId: string) => void;
|
|
41
|
+
accept?: string;
|
|
42
|
+
multiple?: boolean;
|
|
43
|
+
maxFileSize?: number;
|
|
44
|
+
maxFiles?: number;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
dropzoneText?: string;
|
|
47
|
+
hint?: string;
|
|
48
|
+
showProgress?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const formatFileSize = (bytes: number): string => {
|
|
52
|
+
if (bytes === 0) return '0 Bytes';
|
|
53
|
+
const k = 1024;
|
|
54
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
55
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
56
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const FileUpload = ({
|
|
60
|
+
label,
|
|
61
|
+
files = [],
|
|
62
|
+
onFilesChange,
|
|
63
|
+
onFileAdd,
|
|
64
|
+
onFileRemove,
|
|
65
|
+
accept,
|
|
66
|
+
multiple = false,
|
|
67
|
+
maxFileSize,
|
|
68
|
+
maxFiles,
|
|
69
|
+
disabled = false,
|
|
70
|
+
dropzoneText = 'Drag and drop files here, or click to browse',
|
|
71
|
+
hint,
|
|
72
|
+
showProgress = true,
|
|
73
|
+
className,
|
|
74
|
+
...props
|
|
75
|
+
}: FileUploadProps) => {
|
|
76
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
77
|
+
const [error, setError] = useState<string | null>(null);
|
|
78
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
79
|
+
|
|
80
|
+
const validateFile = (file: File): string | null => {
|
|
81
|
+
if (maxFileSize && file.size > maxFileSize) {
|
|
82
|
+
return `File size exceeds ${formatFileSize(maxFileSize)}`;
|
|
83
|
+
}
|
|
84
|
+
if (accept) {
|
|
85
|
+
const acceptedTypes = accept.split(',').map(type => type.trim());
|
|
86
|
+
const isAccepted = acceptedTypes.some(type => {
|
|
87
|
+
if (type.includes('*')) {
|
|
88
|
+
return file.type.startsWith(type.replace('/*', ''));
|
|
89
|
+
}
|
|
90
|
+
return file.type === type || file.name.endsWith(type);
|
|
91
|
+
});
|
|
92
|
+
if (!isAccepted) {
|
|
93
|
+
return `File type not accepted. Allowed: ${accept}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleFiles = useCallback((fileList: FileList | null) => {
|
|
100
|
+
if (!fileList || disabled) return;
|
|
101
|
+
|
|
102
|
+
const newFiles: File[] = [];
|
|
103
|
+
const errors: string[] = [];
|
|
104
|
+
|
|
105
|
+
Array.from(fileList).forEach(file => {
|
|
106
|
+
const validationError = validateFile(file);
|
|
107
|
+
if (validationError) {
|
|
108
|
+
errors.push(`${file.name}: ${validationError}`);
|
|
109
|
+
} else {
|
|
110
|
+
newFiles.push(file);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (maxFiles && files.length + newFiles.length > maxFiles) {
|
|
115
|
+
errors.push(`Maximum ${maxFiles} files allowed`);
|
|
116
|
+
newFiles.splice(maxFiles - files.length);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (errors.length > 0) {
|
|
120
|
+
setError(errors.join(', '));
|
|
121
|
+
} else {
|
|
122
|
+
setError(null);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (newFiles.length > 0) {
|
|
126
|
+
onFileAdd?.(newFiles);
|
|
127
|
+
}
|
|
128
|
+
}, [disabled, files.length, maxFileSize, maxFiles, accept, onFileAdd]);
|
|
129
|
+
|
|
130
|
+
const handleDragOver = (e: React.DragEvent) => {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
if (!disabled) {
|
|
133
|
+
setIsDragOver(true);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const handleDragLeave = (e: React.DragEvent) => {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
setIsDragOver(false);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const handleDrop = (e: React.DragEvent) => {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
setIsDragOver(false);
|
|
145
|
+
handleFiles(e.dataTransfer.files);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const handleClick = () => {
|
|
149
|
+
if (!disabled) {
|
|
150
|
+
inputRef.current?.click();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
155
|
+
handleFiles(e.target.files);
|
|
156
|
+
e.target.value = '';
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const handleRemove = (fileId: string) => {
|
|
160
|
+
onFileRemove?.(fileId);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const getVariant = () => {
|
|
164
|
+
if (disabled) return 'disabled';
|
|
165
|
+
if (error) return 'error';
|
|
166
|
+
if (isDragOver) return 'dragOver';
|
|
167
|
+
return 'default';
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<Box className={clsx(fileUploadContainer, className)} {...props}>
|
|
172
|
+
{label && (
|
|
173
|
+
<Box as="label" className={fileUploadLabel}>
|
|
174
|
+
{label}
|
|
175
|
+
</Box>
|
|
176
|
+
)}
|
|
177
|
+
|
|
178
|
+
<Box
|
|
179
|
+
as="div"
|
|
180
|
+
className={clsx(
|
|
181
|
+
fileUploadDropzone,
|
|
182
|
+
fileUploadDropzoneVariants[getVariant()],
|
|
183
|
+
)}
|
|
184
|
+
onDragOver={handleDragOver}
|
|
185
|
+
onDragLeave={handleDragLeave}
|
|
186
|
+
onDrop={handleDrop}
|
|
187
|
+
onClick={handleClick}
|
|
188
|
+
role="button"
|
|
189
|
+
tabIndex={disabled ? -1 : 0}
|
|
190
|
+
aria-disabled={disabled}
|
|
191
|
+
>
|
|
192
|
+
<Box className={fileUploadIcon} aria-hidden="true">
|
|
193
|
+
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
194
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
195
|
+
<polyline points="17,8 12,3 7,8" />
|
|
196
|
+
<line x1="12" y1="3" x2="12" y2="15" />
|
|
197
|
+
</svg>
|
|
198
|
+
</Box>
|
|
199
|
+
<Box as="p" className={fileUploadText}>
|
|
200
|
+
{dropzoneText}
|
|
201
|
+
</Box>
|
|
202
|
+
{hint && (
|
|
203
|
+
<Box as="p" className={fileUploadHint}>
|
|
204
|
+
{hint}
|
|
205
|
+
</Box>
|
|
206
|
+
)}
|
|
207
|
+
<Box
|
|
208
|
+
as="input"
|
|
209
|
+
ref={inputRef}
|
|
210
|
+
type="file"
|
|
211
|
+
className={fileUploadInput}
|
|
212
|
+
onChange={handleInputChange}
|
|
213
|
+
accept={accept}
|
|
214
|
+
multiple={multiple}
|
|
215
|
+
disabled={disabled}
|
|
216
|
+
aria-label="File upload input"
|
|
217
|
+
/>
|
|
218
|
+
</Box>
|
|
219
|
+
|
|
220
|
+
{error && (
|
|
221
|
+
<Box as="p" className={fileUploadError} role="alert">
|
|
222
|
+
{error}
|
|
223
|
+
</Box>
|
|
224
|
+
)}
|
|
225
|
+
|
|
226
|
+
{files.length > 0 && (
|
|
227
|
+
<Box as="ul" className={fileUploadList} aria-label="Uploaded files">
|
|
228
|
+
{files.map((file) => (
|
|
229
|
+
<Box key={file.id} as="li" className={fileUploadItem}>
|
|
230
|
+
<Box className={fileUploadItemInfo}>
|
|
231
|
+
<Box as="p" className={fileUploadItemName} title={file.name}>
|
|
232
|
+
{file.name}
|
|
233
|
+
</Box>
|
|
234
|
+
<Box as="p" className={fileUploadItemSize}>
|
|
235
|
+
{formatFileSize(file.size)}
|
|
236
|
+
{file.status === 'uploading' && showProgress && ' • Uploading...'}
|
|
237
|
+
{file.status === 'success' && ' • Complete'}
|
|
238
|
+
{file.status === 'error' && file.errorMessage && ` • ${file.errorMessage}`}
|
|
239
|
+
</Box>
|
|
240
|
+
{showProgress && file.status === 'uploading' && (
|
|
241
|
+
<Box className={fileUploadProgressBar}>
|
|
242
|
+
<Box
|
|
243
|
+
className={clsx(
|
|
244
|
+
fileUploadProgressFill,
|
|
245
|
+
fileUploadProgressFillVariants[file.status],
|
|
246
|
+
)}
|
|
247
|
+
style={{ width: `${file.progress}%` }}
|
|
248
|
+
/>
|
|
249
|
+
</Box>
|
|
250
|
+
)}
|
|
251
|
+
</Box>
|
|
252
|
+
<Box
|
|
253
|
+
as="button"
|
|
254
|
+
className={fileUploadRemoveButton}
|
|
255
|
+
onClick={() => handleRemove(file.id)}
|
|
256
|
+
type="button"
|
|
257
|
+
aria-label={`Remove ${file.name}`}
|
|
258
|
+
>
|
|
259
|
+
×
|
|
260
|
+
</Box>
|
|
261
|
+
</Box>
|
|
262
|
+
))}
|
|
263
|
+
</Box>
|
|
264
|
+
)}
|
|
265
|
+
</Box>
|
|
266
|
+
);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export default FileUpload;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { style, styleVariants } from '@vanilla-extract/css';
|
|
2
|
+
import { vars } from '../../styles/theme.css';
|
|
3
|
+
import { styleWithLayer } from '../../styles/utils';
|
|
4
|
+
|
|
5
|
+
export const fileUploadContainer = styleWithLayer({
|
|
6
|
+
width: '100%',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const fileUploadDropzone = styleWithLayer({
|
|
10
|
+
border: `2px dashed ${vars.colors.borderDefault}`,
|
|
11
|
+
borderRadius: '12px',
|
|
12
|
+
padding: '2rem',
|
|
13
|
+
textAlign: 'center',
|
|
14
|
+
cursor: 'pointer',
|
|
15
|
+
transition: 'all 0.2s ease',
|
|
16
|
+
backgroundColor: vars.colors.backgroundMuted,
|
|
17
|
+
':hover': {
|
|
18
|
+
borderColor: vars.colors.inputBorderFocused,
|
|
19
|
+
backgroundColor: vars.colors.alertInfoBackground,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const fileUploadDropzoneVariants = styleVariants({
|
|
24
|
+
default: {},
|
|
25
|
+
dragOver: {
|
|
26
|
+
borderColor: vars.colors.buttonBackgroundPrimary,
|
|
27
|
+
backgroundColor: vars.colors.alertInfoBackground,
|
|
28
|
+
borderStyle: 'solid',
|
|
29
|
+
},
|
|
30
|
+
error: {
|
|
31
|
+
borderColor: vars.colors.alertErrorBorder,
|
|
32
|
+
backgroundColor: vars.colors.alertErrorBackground,
|
|
33
|
+
},
|
|
34
|
+
disabled: {
|
|
35
|
+
cursor: 'not-allowed',
|
|
36
|
+
opacity: 0.6,
|
|
37
|
+
':hover': {
|
|
38
|
+
borderColor: vars.colors.borderDefault,
|
|
39
|
+
backgroundColor: vars.colors.backgroundMuted,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const fileUploadLabel = styleWithLayer({
|
|
45
|
+
display: 'block',
|
|
46
|
+
fontSize: '14px',
|
|
47
|
+
fontWeight: '500',
|
|
48
|
+
color: vars.colors.textPrimary,
|
|
49
|
+
marginBottom: '8px',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const fileUploadText = styleWithLayer({
|
|
53
|
+
fontSize: '14px',
|
|
54
|
+
color: vars.colors.textSecondary,
|
|
55
|
+
marginTop: '0.5rem',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const fileUploadHint = styleWithLayer({
|
|
59
|
+
fontSize: '12px',
|
|
60
|
+
color: vars.colors.textSecondary,
|
|
61
|
+
marginTop: '0.5rem',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const fileUploadInput = styleWithLayer({
|
|
65
|
+
display: 'none',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const fileUploadList = styleWithLayer({
|
|
69
|
+
marginTop: '1rem',
|
|
70
|
+
display: 'flex',
|
|
71
|
+
flexDirection: 'column',
|
|
72
|
+
gap: '0.75rem',
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const fileUploadItem = styleWithLayer({
|
|
76
|
+
display: 'flex',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
gap: '0.75rem',
|
|
79
|
+
padding: '0.75rem',
|
|
80
|
+
backgroundColor: vars.colors.backgroundDefault,
|
|
81
|
+
border: `1px solid ${vars.colors.borderMuted}`,
|
|
82
|
+
borderRadius: '8px',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const fileUploadItemInfo = styleWithLayer({
|
|
86
|
+
flex: 1,
|
|
87
|
+
minWidth: 0,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export const fileUploadItemName = styleWithLayer({
|
|
91
|
+
fontSize: '14px',
|
|
92
|
+
fontWeight: '500',
|
|
93
|
+
color: vars.colors.textPrimary,
|
|
94
|
+
whiteSpace: 'nowrap',
|
|
95
|
+
overflow: 'hidden',
|
|
96
|
+
textOverflow: 'ellipsis',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export const fileUploadItemSize = styleWithLayer({
|
|
100
|
+
fontSize: '12px',
|
|
101
|
+
color: vars.colors.textSecondary,
|
|
102
|
+
marginTop: '2px',
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export const fileUploadItemProgress = styleWithLayer({
|
|
106
|
+
flex: 1,
|
|
107
|
+
maxWidth: '200px',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const fileUploadRemoveButton = styleWithLayer({
|
|
111
|
+
background: 'none',
|
|
112
|
+
border: 'none',
|
|
113
|
+
cursor: 'pointer',
|
|
114
|
+
padding: '0.25rem',
|
|
115
|
+
color: vars.colors.textSecondary,
|
|
116
|
+
fontSize: '18px',
|
|
117
|
+
display: 'flex',
|
|
118
|
+
alignItems: 'center',
|
|
119
|
+
justifyContent: 'center',
|
|
120
|
+
borderRadius: '4px',
|
|
121
|
+
transition: 'all 0.15s ease',
|
|
122
|
+
':hover': {
|
|
123
|
+
color: vars.colors.alertErrorText,
|
|
124
|
+
backgroundColor: vars.colors.alertErrorBackground,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export const fileUploadError = styleWithLayer({
|
|
129
|
+
fontSize: '12px',
|
|
130
|
+
color: vars.colors.alertErrorText,
|
|
131
|
+
marginTop: '0.5rem',
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export const fileUploadIcon = styleWithLayer({
|
|
135
|
+
fontSize: '24px',
|
|
136
|
+
color: vars.colors.textSecondary,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export const fileUploadProgressBar = styleWithLayer({
|
|
140
|
+
width: '100%',
|
|
141
|
+
height: '4px',
|
|
142
|
+
backgroundColor: vars.colors.borderMuted,
|
|
143
|
+
borderRadius: '2px',
|
|
144
|
+
overflow: 'hidden',
|
|
145
|
+
marginTop: '0.5rem',
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export const fileUploadProgressFill = styleWithLayer({
|
|
149
|
+
height: '100%',
|
|
150
|
+
backgroundColor: vars.colors.buttonBackgroundPrimary,
|
|
151
|
+
transition: 'width 0.3s ease',
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export const fileUploadProgressFillVariants = styleVariants({
|
|
155
|
+
uploading: {
|
|
156
|
+
backgroundColor: vars.colors.buttonBackgroundPrimary,
|
|
157
|
+
},
|
|
158
|
+
success: {
|
|
159
|
+
backgroundColor: vars.colors.alertSuccessBorder,
|
|
160
|
+
},
|
|
161
|
+
error: {
|
|
162
|
+
backgroundColor: vars.colors.alertErrorBorder,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
|
|
3
|
+
import { fn } from 'storybook/test';
|
|
4
|
+
|
|
5
|
+
import { Form } from '.';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { Input } from '../Input';
|
|
8
|
+
import FormInput from './FormInput';
|
|
9
|
+
|
|
10
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'Components/Form',
|
|
13
|
+
component: Form,
|
|
14
|
+
parameters: {
|
|
15
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
16
|
+
layout: 'centered',
|
|
17
|
+
},
|
|
18
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
19
|
+
tags: ['autodocs'],
|
|
20
|
+
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
21
|
+
// argTypes: {
|
|
22
|
+
// backgroundColor: { control: 'color' },
|
|
23
|
+
// },
|
|
24
|
+
decorators: [
|
|
25
|
+
(Story) => (
|
|
26
|
+
<div
|
|
27
|
+
style={{
|
|
28
|
+
maxWidth: '400px',
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<Story />
|
|
32
|
+
</div>
|
|
33
|
+
),
|
|
34
|
+
],
|
|
35
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args
|
|
36
|
+
} satisfies Meta<typeof Form>;
|
|
37
|
+
|
|
38
|
+
export default meta;
|
|
39
|
+
type Story = StoryObj<typeof meta>;
|
|
40
|
+
|
|
41
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
42
|
+
export const Login: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
children: (
|
|
45
|
+
<>
|
|
46
|
+
<FormInput label="Username" placeholder="user" />
|
|
47
|
+
<FormInput label="Password" type="password" placeholder="••••••••" />
|
|
48
|
+
</>
|
|
49
|
+
),
|
|
50
|
+
},
|
|
51
|
+
};
|