@pickle-ui/react 0.0.0-stage → 1.0.0-beta.11
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/README.md +498 -2
- package/dist/components/Alert.d.ts +36 -0
- package/dist/components/Alert.d.ts.map +1 -0
- package/dist/components/Alert.js +52 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/AlertDialog.d.ts +41 -0
- package/dist/components/AlertDialog.d.ts.map +1 -0
- package/dist/components/AlertDialog.js +47 -0
- package/dist/components/AlertDialog.js.map +1 -0
- package/dist/components/Avatar.d.ts +18 -0
- package/dist/components/Avatar.d.ts.map +1 -0
- package/dist/components/Avatar.js +34 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.d.ts +12 -0
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/Badge.js +37 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Button.d.ts +19 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +66 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Card.d.ts +27 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +34 -0
- package/dist/components/Card.js.map +1 -0
- package/dist/components/Dialog.d.ts +38 -0
- package/dist/components/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog.js +41 -0
- package/dist/components/Dialog.js.map +1 -0
- package/dist/components/Drawer.d.ts +59 -0
- package/dist/components/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer.js +83 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/Flex.d.ts +22 -0
- package/dist/components/Flex.d.ts.map +1 -0
- package/dist/components/Flex.js +20 -0
- package/dist/components/Flex.js.map +1 -0
- package/dist/components/Grid.d.ts +66 -0
- package/dist/components/Grid.d.ts.map +1 -0
- package/dist/components/Grid.js +63 -0
- package/dist/components/Grid.js.map +1 -0
- package/dist/components/Group.d.ts +20 -0
- package/dist/components/Group.d.ts.map +1 -0
- package/dist/components/Group.js +43 -0
- package/dist/components/Group.js.map +1 -0
- package/dist/components/Menu.d.ts +53 -0
- package/dist/components/Menu.d.ts.map +1 -0
- package/dist/components/Menu.js +78 -0
- package/dist/components/Menu.js.map +1 -0
- package/dist/components/Popover.d.ts +27 -0
- package/dist/components/Popover.d.ts.map +1 -0
- package/dist/components/Popover.js +34 -0
- package/dist/components/Popover.js.map +1 -0
- package/dist/components/Progress.d.ts +23 -0
- package/dist/components/Progress.d.ts.map +1 -0
- package/dist/components/Progress.js +26 -0
- package/dist/components/Progress.js.map +1 -0
- package/dist/components/ScrollArea.d.ts +32 -0
- package/dist/components/ScrollArea.d.ts.map +1 -0
- package/dist/components/ScrollArea.js +36 -0
- package/dist/components/ScrollArea.js.map +1 -0
- package/dist/components/Separator.d.ts +7 -0
- package/dist/components/Separator.d.ts.map +1 -0
- package/dist/components/Separator.js +8 -0
- package/dist/components/Separator.js.map +1 -0
- package/dist/components/Sidebar.d.ts +35 -0
- package/dist/components/Sidebar.d.ts.map +1 -0
- package/dist/components/Sidebar.js +45 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/Spinner.d.ts +11 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +13 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Table.d.ts +32 -0
- package/dist/components/Table.d.ts.map +1 -0
- package/dist/components/Table.js +37 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/Text.d.ts +14 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/Text.js +50 -0
- package/dist/components/Text.js.map +1 -0
- package/dist/components/Toast.d.ts +39 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +97 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/Tooltip.d.ts +18 -0
- package/dist/components/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip.js +22 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/XStack.d.ts +6 -0
- package/dist/components/XStack.d.ts.map +1 -0
- package/dist/components/XStack.js +8 -0
- package/dist/components/XStack.js.map +1 -0
- package/dist/components/YStack.d.ts +6 -0
- package/dist/components/YStack.d.ts.map +1 -0
- package/dist/components/YStack.js +8 -0
- package/dist/components/YStack.js.map +1 -0
- package/dist/components/_internal/VisuallyHiddenInput.d.ts +11 -0
- package/dist/components/_internal/VisuallyHiddenInput.d.ts.map +1 -0
- package/dist/components/_internal/VisuallyHiddenInput.js +87 -0
- package/dist/components/_internal/VisuallyHiddenInput.js.map +1 -0
- package/dist/components/_internal/dialog-styles.d.ts +15 -0
- package/dist/components/_internal/dialog-styles.d.ts.map +1 -0
- package/dist/components/_internal/dialog-styles.js +27 -0
- package/dist/components/_internal/dialog-styles.js.map +1 -0
- package/dist/components/_internal/layout.d.ts +46 -0
- package/dist/components/_internal/layout.d.ts.map +1 -0
- package/dist/components/_internal/layout.js +72 -0
- package/dist/components/_internal/layout.js.map +1 -0
- package/dist/components/form/Checkbox.d.ts +19 -0
- package/dist/components/form/Checkbox.d.ts.map +1 -0
- package/dist/components/form/Checkbox.js +27 -0
- package/dist/components/form/Checkbox.js.map +1 -0
- package/dist/components/form/ColorPicker.d.ts +25 -0
- package/dist/components/form/ColorPicker.d.ts.map +1 -0
- package/dist/components/form/ColorPicker.js +14 -0
- package/dist/components/form/ColorPicker.js.map +1 -0
- package/dist/components/form/ColorPickerPrimitive.d.ts +65 -0
- package/dist/components/form/ColorPickerPrimitive.d.ts.map +1 -0
- package/dist/components/form/ColorPickerPrimitive.js +486 -0
- package/dist/components/form/ColorPickerPrimitive.js.map +1 -0
- package/dist/components/form/Combobox.d.ts +86 -0
- package/dist/components/form/Combobox.d.ts.map +1 -0
- package/dist/components/form/Combobox.js +198 -0
- package/dist/components/form/Combobox.js.map +1 -0
- package/dist/components/form/Form.context.d.ts +28 -0
- package/dist/components/form/Form.context.d.ts.map +1 -0
- package/dist/components/form/Form.context.js +55 -0
- package/dist/components/form/Form.context.js.map +1 -0
- package/dist/components/form/Form.d.ts +68 -0
- package/dist/components/form/Form.d.ts.map +1 -0
- package/dist/components/form/Form.js +32 -0
- package/dist/components/form/Form.js.map +1 -0
- package/dist/components/form/FormCheckbox.d.ts +10 -0
- package/dist/components/form/FormCheckbox.d.ts.map +1 -0
- package/dist/components/form/FormCheckbox.js +24 -0
- package/dist/components/form/FormCheckbox.js.map +1 -0
- package/dist/components/form/FormCombobox.d.ts +28 -0
- package/dist/components/form/FormCombobox.d.ts.map +1 -0
- package/dist/components/form/FormCombobox.js +50 -0
- package/dist/components/form/FormCombobox.js.map +1 -0
- package/dist/components/form/FormDescription.d.ts +7 -0
- package/dist/components/form/FormDescription.d.ts.map +1 -0
- package/dist/components/form/FormDescription.js +9 -0
- package/dist/components/form/FormDescription.js.map +1 -0
- package/dist/components/form/FormError.d.ts +7 -0
- package/dist/components/form/FormError.d.ts.map +1 -0
- package/dist/components/form/FormError.js +9 -0
- package/dist/components/form/FormError.js.map +1 -0
- package/dist/components/form/FormField.d.ts +13 -0
- package/dist/components/form/FormField.d.ts.map +1 -0
- package/dist/components/form/FormField.js +45 -0
- package/dist/components/form/FormField.js.map +1 -0
- package/dist/components/form/FormInput.d.ts +8 -0
- package/dist/components/form/FormInput.d.ts.map +1 -0
- package/dist/components/form/FormInput.js +17 -0
- package/dist/components/form/FormInput.js.map +1 -0
- package/dist/components/form/FormInputGroup.d.ts +7 -0
- package/dist/components/form/FormInputGroup.d.ts.map +1 -0
- package/dist/components/form/FormInputGroup.js +30 -0
- package/dist/components/form/FormInputGroup.js.map +1 -0
- package/dist/components/form/FormLabel.d.ts +7 -0
- package/dist/components/form/FormLabel.d.ts.map +1 -0
- package/dist/components/form/FormLabel.js +9 -0
- package/dist/components/form/FormLabel.js.map +1 -0
- package/dist/components/form/FormRadioGroup.d.ts +14 -0
- package/dist/components/form/FormRadioGroup.d.ts.map +1 -0
- package/dist/components/form/FormRadioGroup.js +25 -0
- package/dist/components/form/FormRadioGroup.js.map +1 -0
- package/dist/components/form/FormRoot.d.ts +10 -0
- package/dist/components/form/FormRoot.d.ts.map +1 -0
- package/dist/components/form/FormRoot.js +10 -0
- package/dist/components/form/FormRoot.js.map +1 -0
- package/dist/components/form/FormSelect.d.ts +19 -0
- package/dist/components/form/FormSelect.d.ts.map +1 -0
- package/dist/components/form/FormSelect.js +34 -0
- package/dist/components/form/FormSelect.js.map +1 -0
- package/dist/components/form/FormSwitch.d.ts +10 -0
- package/dist/components/form/FormSwitch.d.ts.map +1 -0
- package/dist/components/form/FormSwitch.js +24 -0
- package/dist/components/form/FormSwitch.js.map +1 -0
- package/dist/components/form/FormTextarea.d.ts +8 -0
- package/dist/components/form/FormTextarea.d.ts.map +1 -0
- package/dist/components/form/FormTextarea.js +13 -0
- package/dist/components/form/FormTextarea.js.map +1 -0
- package/dist/components/form/Input.d.ts +14 -0
- package/dist/components/form/Input.d.ts.map +1 -0
- package/dist/components/form/Input.js +37 -0
- package/dist/components/form/Input.js.map +1 -0
- package/dist/components/form/InputGroup.d.ts +26 -0
- package/dist/components/form/InputGroup.d.ts.map +1 -0
- package/dist/components/form/InputGroup.js +58 -0
- package/dist/components/form/InputGroup.js.map +1 -0
- package/dist/components/form/RadioGroup.d.ts +23 -0
- package/dist/components/form/RadioGroup.d.ts.map +1 -0
- package/dist/components/form/RadioGroup.js +30 -0
- package/dist/components/form/RadioGroup.js.map +1 -0
- package/dist/components/form/Select.d.ts +42 -0
- package/dist/components/form/Select.d.ts.map +1 -0
- package/dist/components/form/Select.js +68 -0
- package/dist/components/form/Select.js.map +1 -0
- package/dist/components/form/Slider.d.ts +37 -0
- package/dist/components/form/Slider.d.ts.map +1 -0
- package/dist/components/form/Slider.js +35 -0
- package/dist/components/form/Slider.js.map +1 -0
- package/dist/components/form/Switch.d.ts +23 -0
- package/dist/components/form/Switch.d.ts.map +1 -0
- package/dist/components/form/Switch.js +21 -0
- package/dist/components/form/Switch.js.map +1 -0
- package/dist/components/form/Textarea.d.ts +16 -0
- package/dist/components/form/Textarea.d.ts.map +1 -0
- package/dist/components/form/Textarea.js +12 -0
- package/dist/components/form/Textarea.js.map +1 -0
- package/dist/entries/alert-dialog.d.ts +3 -0
- package/dist/entries/alert-dialog.d.ts.map +1 -0
- package/dist/entries/alert-dialog.js +2 -0
- package/dist/entries/alert-dialog.js.map +1 -0
- package/dist/entries/alert.d.ts +3 -0
- package/dist/entries/alert.d.ts.map +1 -0
- package/dist/entries/alert.js +2 -0
- package/dist/entries/alert.js.map +1 -0
- package/dist/entries/avatar.d.ts +3 -0
- package/dist/entries/avatar.d.ts.map +1 -0
- package/dist/entries/avatar.js +2 -0
- package/dist/entries/avatar.js.map +1 -0
- package/dist/entries/badge.d.ts +3 -0
- package/dist/entries/badge.d.ts.map +1 -0
- package/dist/entries/badge.js +2 -0
- package/dist/entries/badge.js.map +1 -0
- package/dist/entries/button.d.ts +3 -0
- package/dist/entries/button.d.ts.map +1 -0
- package/dist/entries/button.js +2 -0
- package/dist/entries/button.js.map +1 -0
- package/dist/entries/card.d.ts +3 -0
- package/dist/entries/card.d.ts.map +1 -0
- package/dist/entries/card.js +2 -0
- package/dist/entries/card.js.map +1 -0
- package/dist/entries/checkbox.d.ts +3 -0
- package/dist/entries/checkbox.d.ts.map +1 -0
- package/dist/entries/checkbox.js +2 -0
- package/dist/entries/checkbox.js.map +1 -0
- package/dist/entries/cn.d.ts +3 -0
- package/dist/entries/cn.d.ts.map +1 -0
- package/dist/entries/cn.js +2 -0
- package/dist/entries/cn.js.map +1 -0
- package/dist/entries/color-picker.d.ts +3 -0
- package/dist/entries/color-picker.d.ts.map +1 -0
- package/dist/entries/color-picker.js +2 -0
- package/dist/entries/color-picker.js.map +1 -0
- package/dist/entries/combobox.d.ts +3 -0
- package/dist/entries/combobox.d.ts.map +1 -0
- package/dist/entries/combobox.js +2 -0
- package/dist/entries/combobox.js.map +1 -0
- package/dist/entries/dialog.d.ts +3 -0
- package/dist/entries/dialog.d.ts.map +1 -0
- package/dist/entries/dialog.js +2 -0
- package/dist/entries/dialog.js.map +1 -0
- package/dist/entries/drawer.d.ts +3 -0
- package/dist/entries/drawer.d.ts.map +1 -0
- package/dist/entries/drawer.js +2 -0
- package/dist/entries/drawer.js.map +1 -0
- package/dist/entries/flex.d.ts +3 -0
- package/dist/entries/flex.d.ts.map +1 -0
- package/dist/entries/flex.js +2 -0
- package/dist/entries/flex.js.map +1 -0
- package/dist/entries/form.d.ts +3 -0
- package/dist/entries/form.d.ts.map +1 -0
- package/dist/entries/form.js +2 -0
- package/dist/entries/form.js.map +1 -0
- package/dist/entries/grid.d.ts +3 -0
- package/dist/entries/grid.d.ts.map +1 -0
- package/dist/entries/grid.js +2 -0
- package/dist/entries/grid.js.map +1 -0
- package/dist/entries/group.d.ts +3 -0
- package/dist/entries/group.d.ts.map +1 -0
- package/dist/entries/group.js +2 -0
- package/dist/entries/group.js.map +1 -0
- package/dist/entries/input-group.d.ts +3 -0
- package/dist/entries/input-group.d.ts.map +1 -0
- package/dist/entries/input-group.js +2 -0
- package/dist/entries/input-group.js.map +1 -0
- package/dist/entries/input.d.ts +3 -0
- package/dist/entries/input.d.ts.map +1 -0
- package/dist/entries/input.js +2 -0
- package/dist/entries/input.js.map +1 -0
- package/dist/entries/menu.d.ts +3 -0
- package/dist/entries/menu.d.ts.map +1 -0
- package/dist/entries/menu.js +2 -0
- package/dist/entries/menu.js.map +1 -0
- package/dist/entries/popover.d.ts +3 -0
- package/dist/entries/popover.d.ts.map +1 -0
- package/dist/entries/popover.js +2 -0
- package/dist/entries/popover.js.map +1 -0
- package/dist/entries/progress.d.ts +3 -0
- package/dist/entries/progress.d.ts.map +1 -0
- package/dist/entries/progress.js +2 -0
- package/dist/entries/progress.js.map +1 -0
- package/dist/entries/radio-group.d.ts +3 -0
- package/dist/entries/radio-group.d.ts.map +1 -0
- package/dist/entries/radio-group.js +2 -0
- package/dist/entries/radio-group.js.map +1 -0
- package/dist/entries/scroll-area.d.ts +3 -0
- package/dist/entries/scroll-area.d.ts.map +1 -0
- package/dist/entries/scroll-area.js +2 -0
- package/dist/entries/scroll-area.js.map +1 -0
- package/dist/entries/select.d.ts +3 -0
- package/dist/entries/select.d.ts.map +1 -0
- package/dist/entries/select.js +2 -0
- package/dist/entries/select.js.map +1 -0
- package/dist/entries/separator.d.ts +3 -0
- package/dist/entries/separator.d.ts.map +1 -0
- package/dist/entries/separator.js +2 -0
- package/dist/entries/separator.js.map +1 -0
- package/dist/entries/sidebar.d.ts +3 -0
- package/dist/entries/sidebar.d.ts.map +1 -0
- package/dist/entries/sidebar.js +2 -0
- package/dist/entries/sidebar.js.map +1 -0
- package/dist/entries/slider.d.ts +3 -0
- package/dist/entries/slider.d.ts.map +1 -0
- package/dist/entries/slider.js +2 -0
- package/dist/entries/slider.js.map +1 -0
- package/dist/entries/spinner.d.ts +3 -0
- package/dist/entries/spinner.d.ts.map +1 -0
- package/dist/entries/spinner.js +2 -0
- package/dist/entries/spinner.js.map +1 -0
- package/dist/entries/switch.d.ts +3 -0
- package/dist/entries/switch.d.ts.map +1 -0
- package/dist/entries/switch.js +2 -0
- package/dist/entries/switch.js.map +1 -0
- package/dist/entries/table.d.ts +3 -0
- package/dist/entries/table.d.ts.map +1 -0
- package/dist/entries/table.js +2 -0
- package/dist/entries/table.js.map +1 -0
- package/dist/entries/text.d.ts +3 -0
- package/dist/entries/text.d.ts.map +1 -0
- package/dist/entries/text.js +2 -0
- package/dist/entries/text.js.map +1 -0
- package/dist/entries/textarea.d.ts +3 -0
- package/dist/entries/textarea.d.ts.map +1 -0
- package/dist/entries/textarea.js +2 -0
- package/dist/entries/textarea.js.map +1 -0
- package/dist/entries/theme.d.ts +3 -0
- package/dist/entries/theme.d.ts.map +1 -0
- package/dist/entries/theme.js +2 -0
- package/dist/entries/theme.js.map +1 -0
- package/dist/entries/toast.d.ts +3 -0
- package/dist/entries/toast.d.ts.map +1 -0
- package/dist/entries/toast.js +2 -0
- package/dist/entries/toast.js.map +1 -0
- package/dist/entries/tooltip.d.ts +3 -0
- package/dist/entries/tooltip.d.ts.map +1 -0
- package/dist/entries/tooltip.js +2 -0
- package/dist/entries/tooltip.js.map +1 -0
- package/dist/entries/x-stack.d.ts +3 -0
- package/dist/entries/x-stack.d.ts.map +1 -0
- package/dist/entries/x-stack.js +2 -0
- package/dist/entries/x-stack.js.map +1 -0
- package/dist/entries/y-stack.d.ts +3 -0
- package/dist/entries/y-stack.d.ts.map +1 -0
- package/dist/entries/y-stack.js +2 -0
- package/dist/entries/y-stack.js.map +1 -0
- package/dist/hooks/use-as-ref.d.ts +4 -0
- package/dist/hooks/use-as-ref.d.ts.map +1 -0
- package/dist/hooks/use-as-ref.js +11 -0
- package/dist/hooks/use-as-ref.js.map +1 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +4 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts.map +1 -0
- package/dist/hooks/use-isomorphic-layout-effect.js +4 -0
- package/dist/hooks/use-isomorphic-layout-effect.js.map +1 -0
- package/dist/hooks/use-lazy-ref.d.ts +4 -0
- package/dist/hooks/use-lazy-ref.d.ts.map +1 -0
- package/dist/hooks/use-lazy-ref.js +9 -0
- package/dist/hooks/use-lazy-ref.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/color.d.ts +42 -0
- package/dist/lib/color.d.ts.map +1 -0
- package/dist/lib/color.js +140 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/lib/compose-refs.d.ts +6 -0
- package/dist/lib/compose-refs.d.ts.map +1 -0
- package/dist/lib/compose-refs.js +44 -0
- package/dist/lib/compose-refs.js.map +1 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +18 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +2 -0
- package/dist/test-setup.js.map +1 -0
- package/package.json +106 -3
- package/src/base.css +81 -0
- package/src/components/Alert.stories.tsx +124 -0
- package/src/components/Alert.test.tsx +76 -0
- package/src/components/Alert.tsx +130 -0
- package/src/components/AlertDialog.stories.tsx +184 -0
- package/src/components/AlertDialog.test.tsx +142 -0
- package/src/components/AlertDialog.tsx +163 -0
- package/src/components/Avatar.stories.tsx +92 -0
- package/src/components/Avatar.test.tsx +26 -0
- package/src/components/Avatar.tsx +96 -0
- package/src/components/Badge.stories.tsx +52 -0
- package/src/components/Badge.test.tsx +35 -0
- package/src/components/Badge.tsx +65 -0
- package/src/components/Button.stories.tsx +171 -0
- package/src/components/Button.test.tsx +116 -0
- package/src/components/Button.tsx +114 -0
- package/src/components/Card.stories.tsx +62 -0
- package/src/components/Card.test.tsx +23 -0
- package/src/components/Card.tsx +128 -0
- package/src/components/Dialog.stories.tsx +133 -0
- package/src/components/Dialog.test.tsx +95 -0
- package/src/components/Dialog.tsx +146 -0
- package/src/components/Drawer.stories.tsx +240 -0
- package/src/components/Drawer.test.tsx +123 -0
- package/src/components/Drawer.tsx +248 -0
- package/src/components/Flex.stories.tsx +70 -0
- package/src/components/Flex.test.tsx +53 -0
- package/src/components/Flex.tsx +58 -0
- package/src/components/Grid.stories.tsx +70 -0
- package/src/components/Grid.test.tsx +46 -0
- package/src/components/Grid.tsx +113 -0
- package/src/components/Group.stories.tsx +130 -0
- package/src/components/Group.test.tsx +57 -0
- package/src/components/Group.tsx +91 -0
- package/src/components/Menu.stories.tsx +139 -0
- package/src/components/Menu.test.tsx +103 -0
- package/src/components/Menu.tsx +289 -0
- package/src/components/Popover.stories.tsx +72 -0
- package/src/components/Popover.tsx +117 -0
- package/src/components/Progress.stories.tsx +105 -0
- package/src/components/Progress.test.tsx +28 -0
- package/src/components/Progress.tsx +111 -0
- package/src/components/ScrollArea.stories.tsx +66 -0
- package/src/components/ScrollArea.test.tsx +32 -0
- package/src/components/ScrollArea.tsx +160 -0
- package/src/components/Separator.stories.tsx +39 -0
- package/src/components/Separator.test.tsx +24 -0
- package/src/components/Separator.tsx +27 -0
- package/src/components/Sidebar.stories.tsx +87 -0
- package/src/components/Sidebar.tsx +166 -0
- package/src/components/Spinner.stories.tsx +36 -0
- package/src/components/Spinner.test.tsx +25 -0
- package/src/components/Spinner.tsx +31 -0
- package/src/components/Table.stories.tsx +76 -0
- package/src/components/Table.tsx +151 -0
- package/src/components/Text.stories.tsx +148 -0
- package/src/components/Text.test.tsx +106 -0
- package/src/components/Text.tsx +85 -0
- package/src/components/Toast.stories.tsx +166 -0
- package/src/components/Toast.test.tsx +97 -0
- package/src/components/Toast.tsx +269 -0
- package/src/components/Tooltip.stories.tsx +116 -0
- package/src/components/Tooltip.test.tsx +51 -0
- package/src/components/Tooltip.tsx +80 -0
- package/src/components/XStack.stories.tsx +64 -0
- package/src/components/XStack.test.tsx +33 -0
- package/src/components/XStack.tsx +18 -0
- package/src/components/YStack.stories.tsx +65 -0
- package/src/components/YStack.test.tsx +31 -0
- package/src/components/YStack.tsx +18 -0
- package/src/components/_internal/Story.tsx +160 -0
- package/src/components/_internal/VisuallyHiddenInput.tsx +146 -0
- package/src/components/_internal/dialog-styles.ts +56 -0
- package/src/components/_internal/layout.ts +103 -0
- package/src/components/form/Checkbox.stories.tsx +78 -0
- package/src/components/form/Checkbox.test.tsx +107 -0
- package/src/components/form/Checkbox.tsx +95 -0
- package/src/components/form/ColorPicker.stories.tsx +160 -0
- package/src/components/form/ColorPicker.test.tsx +45 -0
- package/src/components/form/ColorPicker.tsx +55 -0
- package/src/components/form/ColorPickerPrimitive.test.tsx +14 -0
- package/src/components/form/ColorPickerPrimitive.tsx +1282 -0
- package/src/components/form/Combobox.stories.tsx +378 -0
- package/src/components/form/Combobox.test.tsx +334 -0
- package/src/components/form/Combobox.tsx +666 -0
- package/src/components/form/Form.context.ts +113 -0
- package/src/components/form/Form.stories.tsx +226 -0
- package/src/components/form/Form.test.tsx +293 -0
- package/src/components/form/Form.tsx +49 -0
- package/src/components/form/FormCheckbox.tsx +49 -0
- package/src/components/form/FormCombobox.tsx +92 -0
- package/src/components/form/FormDescription.tsx +21 -0
- package/src/components/form/FormError.tsx +21 -0
- package/src/components/form/FormField.tsx +108 -0
- package/src/components/form/FormInput.tsx +40 -0
- package/src/components/form/FormInputGroup.tsx +46 -0
- package/src/components/form/FormLabel.tsx +24 -0
- package/src/components/form/FormRadioGroup.tsx +46 -0
- package/src/components/form/FormRoot.tsx +41 -0
- package/src/components/form/FormSelect.tsx +60 -0
- package/src/components/form/FormSwitch.tsx +49 -0
- package/src/components/form/FormTextarea.tsx +33 -0
- package/src/components/form/Input.stories.tsx +114 -0
- package/src/components/form/Input.test.tsx +62 -0
- package/src/components/form/Input.tsx +130 -0
- package/src/components/form/InputGroup.stories.tsx +162 -0
- package/src/components/form/InputGroup.tsx +148 -0
- package/src/components/form/RadioGroup.stories.tsx +68 -0
- package/src/components/form/RadioGroup.test.tsx +169 -0
- package/src/components/form/RadioGroup.tsx +127 -0
- package/src/components/form/Select.stories.tsx +114 -0
- package/src/components/form/Select.test.tsx +115 -0
- package/src/components/form/Select.tsx +293 -0
- package/src/components/form/Slider.stories.tsx +121 -0
- package/src/components/form/Slider.test.tsx +33 -0
- package/src/components/form/Slider.tsx +200 -0
- package/src/components/form/Switch.stories.tsx +62 -0
- package/src/components/form/Switch.test.tsx +29 -0
- package/src/components/form/Switch.tsx +81 -0
- package/src/components/form/Textarea.stories.tsx +71 -0
- package/src/components/form/Textarea.test.tsx +31 -0
- package/src/components/form/Textarea.tsx +46 -0
- package/src/entries/alert-dialog.ts +11 -0
- package/src/entries/alert.ts +8 -0
- package/src/entries/avatar.ts +7 -0
- package/src/entries/badge.ts +2 -0
- package/src/entries/button.ts +2 -0
- package/src/entries/card.ts +10 -0
- package/src/entries/checkbox.ts +5 -0
- package/src/entries/cn.ts +2 -0
- package/src/entries/color-picker.ts +13 -0
- package/src/entries/combobox.ts +20 -0
- package/src/entries/dialog.ts +11 -0
- package/src/entries/drawer.ts +12 -0
- package/src/entries/entries.test.ts +65 -0
- package/src/entries/flex.ts +2 -0
- package/src/entries/form.ts +16 -0
- package/src/entries/grid.ts +2 -0
- package/src/entries/group.ts +6 -0
- package/src/entries/input-group.ts +8 -0
- package/src/entries/input.ts +2 -0
- package/src/entries/menu.ts +17 -0
- package/src/entries/popover.ts +10 -0
- package/src/entries/progress.ts +8 -0
- package/src/entries/radio-group.ts +5 -0
- package/src/entries/scroll-area.ts +10 -0
- package/src/entries/select.ts +12 -0
- package/src/entries/separator.ts +2 -0
- package/src/entries/sidebar.ts +13 -0
- package/src/entries/slider.ts +7 -0
- package/src/entries/spinner.ts +2 -0
- package/src/entries/switch.ts +2 -0
- package/src/entries/table.ts +11 -0
- package/src/entries/text.ts +2 -0
- package/src/entries/textarea.ts +2 -0
- package/src/entries/theme.ts +8 -0
- package/src/entries/toast.ts +2 -0
- package/src/entries/tooltip.ts +7 -0
- package/src/entries/x-stack.ts +2 -0
- package/src/entries/y-stack.ts +2 -0
- package/src/hooks/use-as-ref.ts +15 -0
- package/src/hooks/use-isomorphic-layout-effect.ts +6 -0
- package/src/hooks/use-lazy-ref.ts +11 -0
- package/src/index.ts +39 -0
- package/src/lib/color.test.ts +146 -0
- package/src/lib/color.ts +193 -0
- package/src/lib/compose-refs.ts +51 -0
- package/src/lib/utils.ts +25 -0
- package/src/public-api.test.ts +74 -0
- package/src/styles.css +2 -0
- package/src/test-setup.ts +1 -0
- package/src/theme.css +1 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer';
|
|
2
|
+
import { IconX } from '@tabler/icons-react';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn } from '../lib/utils';
|
|
7
|
+
import {
|
|
8
|
+
dialogDescriptionClassName,
|
|
9
|
+
dialogFooterClassName,
|
|
10
|
+
dialogTitleClassName,
|
|
11
|
+
} from './_internal/dialog-styles';
|
|
12
|
+
import { Button } from './Button';
|
|
13
|
+
|
|
14
|
+
// iOS sheet curve, as in coss ui's Drawer. Moves use `transform`, which Base
|
|
15
|
+
// UI's inline drag offset replaces, where `translate-*` would add to it.
|
|
16
|
+
const drawerMotion =
|
|
17
|
+
'duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none';
|
|
18
|
+
|
|
19
|
+
const drawerBackdropClassName = cn(
|
|
20
|
+
'fixed inset-0 z-50 bg-black/32 opacity-[calc(1-var(--drawer-swipe-progress,0))] backdrop-blur-sm transition-opacity data-ending-style:opacity-0 data-starting-style:opacity-0 data-swiping:duration-0',
|
|
21
|
+
drawerMotion,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const drawerViewportClassName = 'fixed inset-0 z-50 flex';
|
|
25
|
+
|
|
26
|
+
// Fills the gap past the screen edge when a drag pulls a docked drawer inwards.
|
|
27
|
+
const drawerEdgeFillClassName =
|
|
28
|
+
'after:bg-popover after:pointer-events-none after:absolute after:inset-y-0 after:left-full after:w-12';
|
|
29
|
+
|
|
30
|
+
const drawerPopupVariants = cva(
|
|
31
|
+
cn(
|
|
32
|
+
'bg-popover text-popover-foreground relative ml-auto flex w-[calc(100%-3rem)] min-w-0 flex-col shadow-lg/5 outline-none not-dark:bg-clip-padding',
|
|
33
|
+
'transition-transform data-ending-style:duration-[calc(var(--drawer-swipe-strength,1)*400ms)] data-swiping:select-none',
|
|
34
|
+
drawerMotion,
|
|
35
|
+
'[transform:translateX(var(--drawer-swipe-movement-x,0px))] data-ending-style:[transform:translateX(calc(100%+var(--inset,0px)))] data-starting-style:[transform:translateX(calc(100%+var(--inset,0px)))]',
|
|
36
|
+
),
|
|
37
|
+
{
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
size: 'md',
|
|
40
|
+
variant: 'inset',
|
|
41
|
+
},
|
|
42
|
+
variants: {
|
|
43
|
+
size: {
|
|
44
|
+
lg: 'max-w-xl',
|
|
45
|
+
md: 'max-w-md',
|
|
46
|
+
sm: 'max-w-sm',
|
|
47
|
+
},
|
|
48
|
+
variant: {
|
|
49
|
+
// Physical sides throughout: the drawer slides in from the right
|
|
50
|
+
// whatever the text direction.
|
|
51
|
+
attached: cn(
|
|
52
|
+
drawerEdgeFillClassName,
|
|
53
|
+
'rounded-l-2xl border-l **:data-[slot=drawer-footer]:rounded-bl-[calc(var(--radius-2xl)-1px)]',
|
|
54
|
+
),
|
|
55
|
+
// Floats inside the viewport, `--inset` away from its edges.
|
|
56
|
+
inset:
|
|
57
|
+
'my-(--inset) mr-(--inset) rounded-2xl border [--inset:--spacing(2)] sm:[--inset:--spacing(4)] **:data-[slot=drawer-footer]:rounded-b-[calc(var(--radius-2xl)-1px)]',
|
|
58
|
+
straight: cn(drawerEdgeFillClassName, 'border-l'),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
type DrawerCloseProps = React.ComponentProps<typeof DrawerPrimitive.Close>;
|
|
65
|
+
|
|
66
|
+
type DrawerContentProps = React.ComponentProps<typeof DrawerPrimitive.Popup> & {
|
|
67
|
+
/** Accessible name of the close icon button. Defaults to `"Close"`. */
|
|
68
|
+
closeLabel?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Renders a close icon button in the top-right corner. Defaults to `false`.
|
|
71
|
+
*/
|
|
72
|
+
showCloseButton?: boolean;
|
|
73
|
+
/** Maximum width of the drawer. Defaults to `md`. */
|
|
74
|
+
size?: DrawerSize;
|
|
75
|
+
/**
|
|
76
|
+
* `inset` floats the drawer away from the viewport's edges, `attached`
|
|
77
|
+
* docks it to the right edge with rounded inner corners, and `straight`
|
|
78
|
+
* docks it without rounding. Defaults to `inset`.
|
|
79
|
+
*/
|
|
80
|
+
variant?: DrawerVariant;
|
|
81
|
+
};
|
|
82
|
+
type DrawerDescriptionProps = React.ComponentProps<
|
|
83
|
+
typeof DrawerPrimitive.Description
|
|
84
|
+
>;
|
|
85
|
+
type DrawerFooterProps = React.ComponentProps<'div'>;
|
|
86
|
+
type DrawerHeaderProps = React.ComponentProps<'div'>;
|
|
87
|
+
type DrawerPanelProps = React.ComponentProps<typeof DrawerPrimitive.Content>;
|
|
88
|
+
// The drawer always slides in from the right, so the swipe direction is fixed
|
|
89
|
+
// and the snap points, which only apply to vertical drawers, are left out.
|
|
90
|
+
type DrawerProps = Omit<
|
|
91
|
+
React.ComponentProps<typeof DrawerPrimitive.Root>,
|
|
92
|
+
| 'defaultSnapPoint'
|
|
93
|
+
| 'onSnapPointChange'
|
|
94
|
+
| 'snapPoint'
|
|
95
|
+
| 'snapPoints'
|
|
96
|
+
| 'snapToSequentialPoints'
|
|
97
|
+
| 'swipeDirection'
|
|
98
|
+
>;
|
|
99
|
+
type DrawerSize = NonNullable<VariantProps<typeof drawerPopupVariants>['size']>;
|
|
100
|
+
type DrawerTitleProps = React.ComponentProps<typeof DrawerPrimitive.Title>;
|
|
101
|
+
type DrawerTriggerProps = React.ComponentProps<typeof DrawerPrimitive.Trigger>;
|
|
102
|
+
type DrawerVariant = NonNullable<
|
|
103
|
+
VariantProps<typeof drawerPopupVariants>['variant']
|
|
104
|
+
>;
|
|
105
|
+
|
|
106
|
+
function DrawerClose({ ...props }: DrawerCloseProps) {
|
|
107
|
+
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function DrawerContent({
|
|
111
|
+
children,
|
|
112
|
+
className,
|
|
113
|
+
closeLabel = 'Close',
|
|
114
|
+
showCloseButton = false,
|
|
115
|
+
size = 'md',
|
|
116
|
+
variant = 'inset',
|
|
117
|
+
...props
|
|
118
|
+
}: DrawerContentProps) {
|
|
119
|
+
return (
|
|
120
|
+
<DrawerPrimitive.Portal>
|
|
121
|
+
<DrawerPrimitive.Backdrop
|
|
122
|
+
className={drawerBackdropClassName}
|
|
123
|
+
data-slot="drawer-backdrop"
|
|
124
|
+
/>
|
|
125
|
+
<DrawerPrimitive.Viewport className={drawerViewportClassName}>
|
|
126
|
+
<DrawerPrimitive.Popup
|
|
127
|
+
className={cn(
|
|
128
|
+
drawerPopupVariants({ size, variant }),
|
|
129
|
+
// Keeps the title clear of the close button.
|
|
130
|
+
showCloseButton && '**:data-[slot=drawer-header]:pr-12',
|
|
131
|
+
className,
|
|
132
|
+
)}
|
|
133
|
+
data-size={size}
|
|
134
|
+
data-slot="drawer-content"
|
|
135
|
+
data-variant={variant}
|
|
136
|
+
{...props}
|
|
137
|
+
>
|
|
138
|
+
{children}
|
|
139
|
+
{showCloseButton ? (
|
|
140
|
+
<DrawerPrimitive.Close
|
|
141
|
+
aria-label={closeLabel}
|
|
142
|
+
className="absolute top-3 right-3"
|
|
143
|
+
data-slot="drawer-close"
|
|
144
|
+
render={<Button size="icon-sm" variant="ghost" />}
|
|
145
|
+
>
|
|
146
|
+
<IconX />
|
|
147
|
+
</DrawerPrimitive.Close>
|
|
148
|
+
) : null}
|
|
149
|
+
</DrawerPrimitive.Popup>
|
|
150
|
+
</DrawerPrimitive.Viewport>
|
|
151
|
+
</DrawerPrimitive.Portal>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function DrawerDescription({ className, ...props }: DrawerDescriptionProps) {
|
|
156
|
+
return (
|
|
157
|
+
<DrawerPrimitive.Description
|
|
158
|
+
className={cn(dialogDescriptionClassName, className)}
|
|
159
|
+
data-slot="drawer-description"
|
|
160
|
+
{...props}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function DrawerFooter({ className, ...props }: DrawerFooterProps) {
|
|
166
|
+
return (
|
|
167
|
+
<div
|
|
168
|
+
className={cn(
|
|
169
|
+
dialogFooterClassName,
|
|
170
|
+
'bg-muted/72 mt-auto border-t px-6 py-4',
|
|
171
|
+
className,
|
|
172
|
+
)}
|
|
173
|
+
data-slot="drawer-footer"
|
|
174
|
+
{...props}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function DrawerHeader({ className, ...props }: DrawerHeaderProps) {
|
|
180
|
+
return (
|
|
181
|
+
<div
|
|
182
|
+
className={cn('flex flex-col gap-1.5 p-6', className)}
|
|
183
|
+
data-slot="drawer-header"
|
|
184
|
+
{...props}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The scrolling body between the header and the footer. Mouse drags in it
|
|
191
|
+
* select text instead of moving the drawer.
|
|
192
|
+
*/
|
|
193
|
+
function DrawerPanel({ className, ...props }: DrawerPanelProps) {
|
|
194
|
+
return (
|
|
195
|
+
<DrawerPrimitive.Content
|
|
196
|
+
className={cn(
|
|
197
|
+
// Pulled 4px into the header's padding and padded back, so the 3px focus
|
|
198
|
+
// ring of a field at its top isn't clipped by the scroll container.
|
|
199
|
+
'-mt-1 min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 pt-1 pb-6 first:mt-0 first:pt-6',
|
|
200
|
+
className,
|
|
201
|
+
)}
|
|
202
|
+
data-slot="drawer-panel"
|
|
203
|
+
{...props}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function DrawerRoot(props: DrawerProps) {
|
|
209
|
+
return <DrawerPrimitive.Root swipeDirection="right" {...props} />;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function DrawerTitle({ className, ...props }: DrawerTitleProps) {
|
|
213
|
+
return (
|
|
214
|
+
<DrawerPrimitive.Title
|
|
215
|
+
className={cn(dialogTitleClassName, className)}
|
|
216
|
+
data-slot="drawer-title"
|
|
217
|
+
{...props}
|
|
218
|
+
/>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function DrawerTrigger({ ...props }: DrawerTriggerProps) {
|
|
223
|
+
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const Drawer = Object.assign(DrawerRoot, {
|
|
227
|
+
Close: DrawerClose,
|
|
228
|
+
Content: DrawerContent,
|
|
229
|
+
Description: DrawerDescription,
|
|
230
|
+
Footer: DrawerFooter,
|
|
231
|
+
Header: DrawerHeader,
|
|
232
|
+
Panel: DrawerPanel,
|
|
233
|
+
Title: DrawerTitle,
|
|
234
|
+
Trigger: DrawerTrigger,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
export { Drawer };
|
|
238
|
+
export type {
|
|
239
|
+
DrawerCloseProps,
|
|
240
|
+
DrawerContentProps,
|
|
241
|
+
DrawerDescriptionProps,
|
|
242
|
+
DrawerFooterProps,
|
|
243
|
+
DrawerHeaderProps,
|
|
244
|
+
DrawerPanelProps,
|
|
245
|
+
DrawerProps,
|
|
246
|
+
DrawerTitleProps,
|
|
247
|
+
DrawerTriggerProps,
|
|
248
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Story } from './_internal/Story';
|
|
4
|
+
import { Flex } from './Flex';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: Flex,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'fullscreen',
|
|
11
|
+
},
|
|
12
|
+
title: 'components/Flex',
|
|
13
|
+
} satisfies Meta<typeof Flex>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
function Item({ children }: { children: string }) {
|
|
19
|
+
return (
|
|
20
|
+
<Flex
|
|
21
|
+
align="center"
|
|
22
|
+
className="bg-muted min-h-16 min-w-24 rounded-md border p-4"
|
|
23
|
+
justify="center"
|
|
24
|
+
>
|
|
25
|
+
<Text>{children}</Text>
|
|
26
|
+
</Flex>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const All: StoryDefinition = {
|
|
31
|
+
render: () => (
|
|
32
|
+
<Story.Layout className="max-w-6xl" title="Flex">
|
|
33
|
+
<Story.Section title="Direction and spacing">
|
|
34
|
+
<Flex direction="column" gap={3}>
|
|
35
|
+
<Item>First</Item>
|
|
36
|
+
<Item>Second</Item>
|
|
37
|
+
<Item>Third</Item>
|
|
38
|
+
</Flex>
|
|
39
|
+
</Story.Section>
|
|
40
|
+
|
|
41
|
+
<Story.Section title="Alignment and distribution">
|
|
42
|
+
<Flex
|
|
43
|
+
align="center"
|
|
44
|
+
className="border-border min-h-40 rounded-md border border-dashed p-4"
|
|
45
|
+
gap={4}
|
|
46
|
+
justify="between"
|
|
47
|
+
>
|
|
48
|
+
<Item>Start</Item>
|
|
49
|
+
<Item>Center</Item>
|
|
50
|
+
<Item>End</Item>
|
|
51
|
+
</Flex>
|
|
52
|
+
</Story.Section>
|
|
53
|
+
|
|
54
|
+
<Story.Section title="Wrapping">
|
|
55
|
+
<Flex gap={3} wrap="wrap">
|
|
56
|
+
{['One', 'Two', 'Three', 'Four', 'Five', 'Six'].map((label) => (
|
|
57
|
+
<Item key={label}>{label}</Item>
|
|
58
|
+
))}
|
|
59
|
+
</Flex>
|
|
60
|
+
</Story.Section>
|
|
61
|
+
|
|
62
|
+
<Story.Section title="Responsive override">
|
|
63
|
+
<Flex className="flex-col md:flex-row" gap={3}>
|
|
64
|
+
<Item>Column on small screens</Item>
|
|
65
|
+
<Item>Row from md</Item>
|
|
66
|
+
</Flex>
|
|
67
|
+
</Story.Section>
|
|
68
|
+
</Story.Layout>
|
|
69
|
+
),
|
|
70
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { Flex } from './Flex';
|
|
5
|
+
|
|
6
|
+
describe('Flex', () => {
|
|
7
|
+
it('renders layout props as Tailwind classes', () => {
|
|
8
|
+
render(
|
|
9
|
+
<Flex
|
|
10
|
+
align="center"
|
|
11
|
+
direction="column"
|
|
12
|
+
gap={4}
|
|
13
|
+
gapX={2}
|
|
14
|
+
gapY={3}
|
|
15
|
+
justify="between"
|
|
16
|
+
wrap="wrap"
|
|
17
|
+
>
|
|
18
|
+
Content
|
|
19
|
+
</Flex>,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
expect(screen.getByText('Content')).toHaveClass(
|
|
23
|
+
'flex',
|
|
24
|
+
'flex-col',
|
|
25
|
+
'flex-wrap',
|
|
26
|
+
'items-center',
|
|
27
|
+
'justify-between',
|
|
28
|
+
'gap-4',
|
|
29
|
+
'gap-x-2',
|
|
30
|
+
'gap-y-3',
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('supports polymorphism, native props, refs, and class overrides', () => {
|
|
35
|
+
const ref = { current: null };
|
|
36
|
+
render(
|
|
37
|
+
<Flex
|
|
38
|
+
aria-label="navigation"
|
|
39
|
+
as="nav"
|
|
40
|
+
className="custom-class flex-row"
|
|
41
|
+
direction="column"
|
|
42
|
+
ref={ref}
|
|
43
|
+
/>,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const element = screen.getByLabelText('navigation');
|
|
47
|
+
expect(element.tagName.toLowerCase()).toBe('nav');
|
|
48
|
+
expect(element).toHaveAttribute('data-slot', 'flex');
|
|
49
|
+
expect(element).toHaveClass('flex-row', 'custom-class');
|
|
50
|
+
expect(element).not.toHaveClass('flex-col');
|
|
51
|
+
expect(ref.current).toBe(element);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
import { getLayoutClasses, type LayoutStyleProps } from './_internal/layout';
|
|
5
|
+
|
|
6
|
+
const directionClasses = {
|
|
7
|
+
column: 'flex-col',
|
|
8
|
+
'column-reverse': 'flex-col-reverse',
|
|
9
|
+
row: 'flex-row',
|
|
10
|
+
'row-reverse': 'flex-row-reverse',
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
const wrapClasses = {
|
|
14
|
+
nowrap: 'flex-nowrap',
|
|
15
|
+
wrap: 'flex-wrap',
|
|
16
|
+
'wrap-reverse': 'flex-wrap-reverse',
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
type FlexProps = LayoutStyleProps &
|
|
20
|
+
Omit<React.ComponentProps<'div'>, keyof LayoutStyleProps> & {
|
|
21
|
+
as?: React.ElementType;
|
|
22
|
+
direction?: keyof typeof directionClasses;
|
|
23
|
+
wrap?: keyof typeof wrapClasses;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function Flex({
|
|
27
|
+
align,
|
|
28
|
+
as,
|
|
29
|
+
className,
|
|
30
|
+
direction,
|
|
31
|
+
gap,
|
|
32
|
+
gapX,
|
|
33
|
+
gapY,
|
|
34
|
+
justify,
|
|
35
|
+
ref,
|
|
36
|
+
wrap,
|
|
37
|
+
...props
|
|
38
|
+
}: FlexProps) {
|
|
39
|
+
const Component = as ?? 'div';
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Component
|
|
43
|
+
className={cn(
|
|
44
|
+
'flex',
|
|
45
|
+
getLayoutClasses({ align, gap, gapX, gapY, justify }),
|
|
46
|
+
direction === undefined ? undefined : directionClasses[direction],
|
|
47
|
+
wrap === undefined ? undefined : wrapClasses[wrap],
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
50
|
+
data-slot="flex"
|
|
51
|
+
ref={ref}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { Flex };
|
|
58
|
+
export type { FlexProps };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Story } from './_internal/Story';
|
|
4
|
+
import { Grid } from './Grid';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: Grid,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'fullscreen',
|
|
11
|
+
},
|
|
12
|
+
title: 'components/Grid',
|
|
13
|
+
} satisfies Meta<typeof Grid>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
function Item({ children }: { children: string }) {
|
|
19
|
+
return (
|
|
20
|
+
<Grid
|
|
21
|
+
className="bg-muted min-h-20 rounded-md border p-4"
|
|
22
|
+
placeItems="center"
|
|
23
|
+
>
|
|
24
|
+
<Text>{children}</Text>
|
|
25
|
+
</Grid>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const All: StoryDefinition = {
|
|
30
|
+
render: () => (
|
|
31
|
+
<Story.Layout className="max-w-6xl" title="Grid">
|
|
32
|
+
<Story.Section title="Columns and gaps">
|
|
33
|
+
<Grid columns={3} gap={4}>
|
|
34
|
+
{['One', 'Two', 'Three', 'Four', 'Five', 'Six'].map((label) => (
|
|
35
|
+
<Item key={label}>{label}</Item>
|
|
36
|
+
))}
|
|
37
|
+
</Grid>
|
|
38
|
+
</Story.Section>
|
|
39
|
+
|
|
40
|
+
<Story.Section title="Rows and column flow">
|
|
41
|
+
<Grid columns={3} flow="column" gapX={4} gapY={2} rows={2}>
|
|
42
|
+
{['A', 'B', 'C', 'D', 'E', 'F'].map((label) => (
|
|
43
|
+
<Item key={label}>{label}</Item>
|
|
44
|
+
))}
|
|
45
|
+
</Grid>
|
|
46
|
+
</Story.Section>
|
|
47
|
+
|
|
48
|
+
<Story.Section title="Placement">
|
|
49
|
+
<Grid
|
|
50
|
+
className="border-border min-h-72 rounded-md border border-dashed p-4"
|
|
51
|
+
columns={2}
|
|
52
|
+
gap={4}
|
|
53
|
+
placeContent="center"
|
|
54
|
+
placeItems="stretch"
|
|
55
|
+
>
|
|
56
|
+
<Item>Centered track</Item>
|
|
57
|
+
<Item>Stretched item</Item>
|
|
58
|
+
</Grid>
|
|
59
|
+
</Story.Section>
|
|
60
|
+
|
|
61
|
+
<Story.Section title="Responsive override">
|
|
62
|
+
<Grid className="grid-cols-1 sm:grid-cols-2 lg:grid-cols-4" gap={3}>
|
|
63
|
+
{['One', 'Two', 'Three', 'Four'].map((label) => (
|
|
64
|
+
<Item key={label}>{label}</Item>
|
|
65
|
+
))}
|
|
66
|
+
</Grid>
|
|
67
|
+
</Story.Section>
|
|
68
|
+
</Story.Layout>
|
|
69
|
+
),
|
|
70
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { Grid } from './Grid';
|
|
5
|
+
|
|
6
|
+
describe('Grid', () => {
|
|
7
|
+
it('renders grid and shared layout props as Tailwind classes', () => {
|
|
8
|
+
render(
|
|
9
|
+
<Grid
|
|
10
|
+
align="start"
|
|
11
|
+
columns={3}
|
|
12
|
+
flow="column-dense"
|
|
13
|
+
gap={4}
|
|
14
|
+
justify="center"
|
|
15
|
+
placeContent="between"
|
|
16
|
+
placeItems="stretch"
|
|
17
|
+
rows={2}
|
|
18
|
+
>
|
|
19
|
+
Content
|
|
20
|
+
</Grid>,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expect(screen.getByText('Content')).toHaveClass(
|
|
24
|
+
'grid',
|
|
25
|
+
'grid-cols-3',
|
|
26
|
+
'grid-rows-2',
|
|
27
|
+
'grid-flow-col-dense',
|
|
28
|
+
'place-content-between',
|
|
29
|
+
'place-items-stretch',
|
|
30
|
+
'items-start',
|
|
31
|
+
'justify-center',
|
|
32
|
+
'gap-4',
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('supports polymorphism and forwards native props', () => {
|
|
37
|
+
render(
|
|
38
|
+
<Grid aria-label="results" as="section" className="md:grid-cols-4" />,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const element = screen.getByLabelText('results');
|
|
42
|
+
expect(element.tagName.toLowerCase()).toBe('section');
|
|
43
|
+
expect(element).toHaveAttribute('data-slot', 'grid');
|
|
44
|
+
expect(element).toHaveClass('md:grid-cols-4');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
import { getLayoutClasses, type LayoutStyleProps } from './_internal/layout';
|
|
5
|
+
|
|
6
|
+
const columnClasses = {
|
|
7
|
+
1: 'grid-cols-1',
|
|
8
|
+
2: 'grid-cols-2',
|
|
9
|
+
3: 'grid-cols-3',
|
|
10
|
+
4: 'grid-cols-4',
|
|
11
|
+
5: 'grid-cols-5',
|
|
12
|
+
6: 'grid-cols-6',
|
|
13
|
+
7: 'grid-cols-7',
|
|
14
|
+
8: 'grid-cols-8',
|
|
15
|
+
9: 'grid-cols-9',
|
|
16
|
+
10: 'grid-cols-10',
|
|
17
|
+
11: 'grid-cols-11',
|
|
18
|
+
12: 'grid-cols-12',
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
const flowClasses = {
|
|
22
|
+
column: 'grid-flow-col',
|
|
23
|
+
'column-dense': 'grid-flow-col-dense',
|
|
24
|
+
dense: 'grid-flow-dense',
|
|
25
|
+
row: 'grid-flow-row',
|
|
26
|
+
'row-dense': 'grid-flow-row-dense',
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
const placeContentClasses = {
|
|
30
|
+
around: 'place-content-around',
|
|
31
|
+
baseline: 'place-content-baseline',
|
|
32
|
+
between: 'place-content-between',
|
|
33
|
+
center: 'place-content-center',
|
|
34
|
+
end: 'place-content-end',
|
|
35
|
+
evenly: 'place-content-evenly',
|
|
36
|
+
start: 'place-content-start',
|
|
37
|
+
stretch: 'place-content-stretch',
|
|
38
|
+
} as const;
|
|
39
|
+
|
|
40
|
+
const placeItemsClasses = {
|
|
41
|
+
baseline: 'place-items-baseline',
|
|
42
|
+
center: 'place-items-center',
|
|
43
|
+
end: 'place-items-end',
|
|
44
|
+
start: 'place-items-start',
|
|
45
|
+
stretch: 'place-items-stretch',
|
|
46
|
+
} as const;
|
|
47
|
+
|
|
48
|
+
const rowClasses = {
|
|
49
|
+
1: 'grid-rows-1',
|
|
50
|
+
2: 'grid-rows-2',
|
|
51
|
+
3: 'grid-rows-3',
|
|
52
|
+
4: 'grid-rows-4',
|
|
53
|
+
5: 'grid-rows-5',
|
|
54
|
+
6: 'grid-rows-6',
|
|
55
|
+
7: 'grid-rows-7',
|
|
56
|
+
8: 'grid-rows-8',
|
|
57
|
+
9: 'grid-rows-9',
|
|
58
|
+
10: 'grid-rows-10',
|
|
59
|
+
11: 'grid-rows-11',
|
|
60
|
+
12: 'grid-rows-12',
|
|
61
|
+
} as const;
|
|
62
|
+
|
|
63
|
+
type GridProps = LayoutStyleProps &
|
|
64
|
+
Omit<React.ComponentProps<'div'>, keyof LayoutStyleProps> & {
|
|
65
|
+
as?: React.ElementType;
|
|
66
|
+
columns?: keyof typeof columnClasses;
|
|
67
|
+
flow?: keyof typeof flowClasses;
|
|
68
|
+
placeContent?: keyof typeof placeContentClasses;
|
|
69
|
+
placeItems?: keyof typeof placeItemsClasses;
|
|
70
|
+
rows?: keyof typeof rowClasses;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
function Grid({
|
|
74
|
+
align,
|
|
75
|
+
as,
|
|
76
|
+
className,
|
|
77
|
+
columns,
|
|
78
|
+
flow,
|
|
79
|
+
gap,
|
|
80
|
+
gapX,
|
|
81
|
+
gapY,
|
|
82
|
+
justify,
|
|
83
|
+
placeContent,
|
|
84
|
+
placeItems,
|
|
85
|
+
ref,
|
|
86
|
+
rows,
|
|
87
|
+
...props
|
|
88
|
+
}: GridProps) {
|
|
89
|
+
const Component = as ?? 'div';
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Component
|
|
93
|
+
className={cn(
|
|
94
|
+
'grid',
|
|
95
|
+
getLayoutClasses({ align, gap, gapX, gapY, justify }),
|
|
96
|
+
columns === undefined ? undefined : columnClasses[columns],
|
|
97
|
+
flow === undefined ? undefined : flowClasses[flow],
|
|
98
|
+
placeContent === undefined
|
|
99
|
+
? undefined
|
|
100
|
+
: placeContentClasses[placeContent],
|
|
101
|
+
placeItems === undefined ? undefined : placeItemsClasses[placeItems],
|
|
102
|
+
rows === undefined ? undefined : rowClasses[rows],
|
|
103
|
+
className,
|
|
104
|
+
)}
|
|
105
|
+
data-slot="grid"
|
|
106
|
+
ref={ref}
|
|
107
|
+
{...props}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { Grid };
|
|
113
|
+
export type { GridProps };
|