@pickle-ui/react 0.0.0-stage → 1.0.0-beta.10
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 +496 -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/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/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 +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -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/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/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 +38 -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,72 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { type ComponentMatrixCellProps, Story } from './_internal/Story';
|
|
4
|
+
import { Button, type ButtonProps } from './Button';
|
|
5
|
+
import { Popover } from './Popover';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: Popover,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'fullscreen',
|
|
11
|
+
},
|
|
12
|
+
title: 'components/Popover',
|
|
13
|
+
} satisfies Meta<typeof Popover>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const ALIGN_ROWS = [
|
|
19
|
+
{ key: 'start', label: 'Start align' },
|
|
20
|
+
{ key: 'center', label: 'Center align' },
|
|
21
|
+
{ key: 'end', label: 'End align' },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const TRIGGER_COLUMNS: {
|
|
25
|
+
key: NonNullable<ButtonProps['variant']>;
|
|
26
|
+
label: string;
|
|
27
|
+
}[] = [
|
|
28
|
+
{ key: 'default', label: 'Default trigger' },
|
|
29
|
+
{ key: 'outline', label: 'Outline trigger' },
|
|
30
|
+
{ key: 'ghost', label: 'Ghost trigger' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
function PopoverMatrixCell({ column, row }: ComponentMatrixCellProps) {
|
|
34
|
+
return (
|
|
35
|
+
<Popover>
|
|
36
|
+
<Popover.Trigger
|
|
37
|
+
render={
|
|
38
|
+
<Button variant={column.key as NonNullable<ButtonProps['variant']>} />
|
|
39
|
+
}
|
|
40
|
+
>
|
|
41
|
+
Open
|
|
42
|
+
</Popover.Trigger>
|
|
43
|
+
<Popover.Content align={row.key as 'center' | 'end' | 'start'}>
|
|
44
|
+
<Popover.Header>
|
|
45
|
+
<Popover.Title>{row.label}</Popover.Title>
|
|
46
|
+
<Popover.Description>
|
|
47
|
+
Contextual content keeps the same spacing, radius, and border
|
|
48
|
+
treatment across trigger styles.
|
|
49
|
+
</Popover.Description>
|
|
50
|
+
</Popover.Header>
|
|
51
|
+
<div className="flex justify-end gap-2">
|
|
52
|
+
<Button variant="ghost">Cancel</Button>
|
|
53
|
+
<Button>Apply</Button>
|
|
54
|
+
</div>
|
|
55
|
+
</Popover.Content>
|
|
56
|
+
</Popover>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const All: StoryDefinition = {
|
|
61
|
+
render: () => (
|
|
62
|
+
<Story.Layout className="max-w-6xl" title="Popover">
|
|
63
|
+
<Story.Section title="Alignment and trigger styles">
|
|
64
|
+
<Story.Matrix
|
|
65
|
+
Cell={PopoverMatrixCell}
|
|
66
|
+
columns={TRIGGER_COLUMNS}
|
|
67
|
+
rows={ALIGN_ROWS}
|
|
68
|
+
/>
|
|
69
|
+
</Story.Section>
|
|
70
|
+
</Story.Layout>
|
|
71
|
+
),
|
|
72
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
|
|
6
|
+
type PopoverAnchorProps = React.ComponentProps<'div'>;
|
|
7
|
+
type PopoverContentProps = Pick<
|
|
8
|
+
React.ComponentProps<typeof PopoverPrimitive.Positioner>,
|
|
9
|
+
'align' | 'side' | 'sideOffset'
|
|
10
|
+
> &
|
|
11
|
+
React.ComponentProps<typeof PopoverPrimitive.Popup>;
|
|
12
|
+
type PopoverDescriptionProps = React.ComponentProps<'p'>;
|
|
13
|
+
type PopoverHeaderProps = React.ComponentProps<'div'>;
|
|
14
|
+
type PopoverProps = React.ComponentProps<typeof PopoverPrimitive.Root>;
|
|
15
|
+
type PopoverTitleProps = React.ComponentProps<'h2'>;
|
|
16
|
+
type PopoverTriggerProps = React.ComponentProps<
|
|
17
|
+
typeof PopoverPrimitive.Trigger
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
function PopoverAnchor({ ...props }: PopoverAnchorProps) {
|
|
21
|
+
return <div data-slot="popover-anchor" {...props} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function PopoverContent({
|
|
25
|
+
align = 'center',
|
|
26
|
+
className,
|
|
27
|
+
side = 'bottom',
|
|
28
|
+
sideOffset = 4,
|
|
29
|
+
...props
|
|
30
|
+
}: PopoverContentProps) {
|
|
31
|
+
return (
|
|
32
|
+
<PopoverPrimitive.Portal>
|
|
33
|
+
<PopoverPrimitive.Positioner
|
|
34
|
+
align={align}
|
|
35
|
+
side={side}
|
|
36
|
+
sideOffset={sideOffset}
|
|
37
|
+
>
|
|
38
|
+
<PopoverPrimitive.Popup
|
|
39
|
+
className={cn(
|
|
40
|
+
'border-border bg-popover text-popover-foreground data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md border p-4 text-sm shadow-lg duration-100 outline-none',
|
|
41
|
+
className,
|
|
42
|
+
)}
|
|
43
|
+
data-slot="popover-content"
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
</PopoverPrimitive.Positioner>
|
|
47
|
+
</PopoverPrimitive.Portal>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function PopoverDescription({ className, ...props }: PopoverDescriptionProps) {
|
|
52
|
+
return (
|
|
53
|
+
<p
|
|
54
|
+
className={cn('text-muted-foreground', className)}
|
|
55
|
+
data-slot="popover-description"
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function PopoverHeader({ className, ...props }: PopoverHeaderProps) {
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
className={cn('flex flex-col gap-1 text-sm', className)}
|
|
65
|
+
data-slot="popover-header"
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function PopoverRoot({ ...props }: PopoverProps) {
|
|
72
|
+
return <PopoverPrimitive.Root {...props} />;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function PopoverTitle({ children, className, ...props }: PopoverTitleProps) {
|
|
76
|
+
return (
|
|
77
|
+
<h2
|
|
78
|
+
className={cn('text-base font-medium', className)}
|
|
79
|
+
data-slot="popover-title"
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
{children}
|
|
83
|
+
</h2>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function PopoverTrigger(props: PopoverTriggerProps) {
|
|
88
|
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const Popover = Object.assign(PopoverRoot, {
|
|
92
|
+
Anchor: PopoverAnchor,
|
|
93
|
+
Content: PopoverContent,
|
|
94
|
+
Description: PopoverDescription,
|
|
95
|
+
Header: PopoverHeader,
|
|
96
|
+
Title: PopoverTitle,
|
|
97
|
+
Trigger: PopoverTrigger,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
Popover,
|
|
102
|
+
PopoverAnchor,
|
|
103
|
+
PopoverContent,
|
|
104
|
+
PopoverDescription,
|
|
105
|
+
PopoverHeader,
|
|
106
|
+
PopoverTitle,
|
|
107
|
+
PopoverTrigger,
|
|
108
|
+
};
|
|
109
|
+
export type {
|
|
110
|
+
PopoverAnchorProps,
|
|
111
|
+
PopoverContentProps,
|
|
112
|
+
PopoverDescriptionProps,
|
|
113
|
+
PopoverHeaderProps,
|
|
114
|
+
PopoverProps,
|
|
115
|
+
PopoverTitleProps,
|
|
116
|
+
PopoverTriggerProps,
|
|
117
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import { type ComponentMatrixCellProps, Story } from './_internal/Story';
|
|
6
|
+
import { Progress } from './Progress';
|
|
7
|
+
import { Text } from './Text';
|
|
8
|
+
import { XStack } from './XStack';
|
|
9
|
+
import { YStack } from './YStack';
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
args: {
|
|
13
|
+
value: 50,
|
|
14
|
+
},
|
|
15
|
+
component: Progress,
|
|
16
|
+
parameters: { layout: 'fullscreen' },
|
|
17
|
+
title: 'components/Progress',
|
|
18
|
+
} satisfies Meta<typeof Progress>;
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
const VALUE_ROWS = [{ key: 'default', label: 'Default' }];
|
|
24
|
+
|
|
25
|
+
const STATE_COLUMNS = [
|
|
26
|
+
{ key: '25', label: '25%' },
|
|
27
|
+
{ key: '50', label: '50%' },
|
|
28
|
+
{ key: '75', label: '75%' },
|
|
29
|
+
{ key: '100', label: 'Complete' },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
function AnimatedProgress() {
|
|
33
|
+
const [value, setValue] = useState(20);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const interval = window.setInterval(() => {
|
|
37
|
+
setValue((current) => (current >= 100 ? 0 : Math.min(100, current + 10)));
|
|
38
|
+
}, 900);
|
|
39
|
+
|
|
40
|
+
return () => window.clearInterval(interval);
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Progress className="max-w-sm grid-cols-[1fr_auto]" value={value}>
|
|
45
|
+
<Progress.Label>Export data</Progress.Label>
|
|
46
|
+
<Progress.Value />
|
|
47
|
+
<Progress.Track className="col-span-2">
|
|
48
|
+
<Progress.Indicator />
|
|
49
|
+
</Progress.Track>
|
|
50
|
+
</Progress>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function ProgressValueCell({ column }: ComponentMatrixCellProps) {
|
|
55
|
+
return <Progress value={Number(column.key)} />;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const All: StoryDefinition = {
|
|
59
|
+
args: {
|
|
60
|
+
value: 50,
|
|
61
|
+
},
|
|
62
|
+
render: () => (
|
|
63
|
+
<Story.Layout className="max-w-5xl" title="Progress">
|
|
64
|
+
<Story.Section title="Values">
|
|
65
|
+
<Story.Matrix
|
|
66
|
+
Cell={ProgressValueCell}
|
|
67
|
+
cellClassName="justify-stretch"
|
|
68
|
+
cellWidth="10rem"
|
|
69
|
+
columns={STATE_COLUMNS}
|
|
70
|
+
rows={VALUE_ROWS}
|
|
71
|
+
/>
|
|
72
|
+
</Story.Section>
|
|
73
|
+
|
|
74
|
+
<Story.Section title="Labeled progress">
|
|
75
|
+
<YStack gap={6}>
|
|
76
|
+
<Progress className="max-w-sm grid-cols-[1fr_auto]" value={72}>
|
|
77
|
+
<Progress.Label>Design capacity</Progress.Label>
|
|
78
|
+
<Progress.Value />
|
|
79
|
+
<Progress.Track className="col-span-2">
|
|
80
|
+
<Progress.Indicator />
|
|
81
|
+
</Progress.Track>
|
|
82
|
+
</Progress>
|
|
83
|
+
</YStack>
|
|
84
|
+
</Story.Section>
|
|
85
|
+
|
|
86
|
+
<Story.Section title="Animated">
|
|
87
|
+
<AnimatedProgress />
|
|
88
|
+
</Story.Section>
|
|
89
|
+
|
|
90
|
+
<Story.Section title="Custom indicator">
|
|
91
|
+
<Progress className="max-w-sm" value={63}>
|
|
92
|
+
<XStack className="mb-2" justify="between">
|
|
93
|
+
<Progress.Label>Engineering</Progress.Label>
|
|
94
|
+
<Text tone="muted" variant="small">
|
|
95
|
+
63%
|
|
96
|
+
</Text>
|
|
97
|
+
</XStack>
|
|
98
|
+
<Progress.Track>
|
|
99
|
+
<Progress.Indicator indicatorClassName="bg-chart-2" />
|
|
100
|
+
</Progress.Track>
|
|
101
|
+
</Progress>
|
|
102
|
+
</Story.Section>
|
|
103
|
+
</Story.Layout>
|
|
104
|
+
),
|
|
105
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { Progress } from './Progress';
|
|
5
|
+
|
|
6
|
+
describe('Progress', () => {
|
|
7
|
+
it('renders a progressbar with the provided value', () => {
|
|
8
|
+
render(<Progress aria-label="Upload" value={45} />);
|
|
9
|
+
|
|
10
|
+
expect(screen.getByRole('progressbar', { name: 'Upload' })).toHaveAttribute(
|
|
11
|
+
'aria-valuenow',
|
|
12
|
+
'45',
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('renders labeled progress parts', () => {
|
|
17
|
+
render(
|
|
18
|
+
<Progress value={72}>
|
|
19
|
+
<Progress.Label>Design</Progress.Label>
|
|
20
|
+
<Progress.Track>
|
|
21
|
+
<Progress.Indicator />
|
|
22
|
+
</Progress.Track>
|
|
23
|
+
</Progress>,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect(screen.getByText('Design')).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Progress as ProgressPrimitive } from '@base-ui/react/progress';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
|
|
6
|
+
type ProgressIndicatorProps = React.ComponentProps<
|
|
7
|
+
typeof ProgressPrimitive.Indicator
|
|
8
|
+
> & {
|
|
9
|
+
indicatorClassName?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type ProgressLabelProps = React.ComponentProps<typeof ProgressPrimitive.Label>;
|
|
13
|
+
type ProgressProps = React.ComponentProps<typeof ProgressPrimitive.Root>;
|
|
14
|
+
type ProgressTrackProps = React.ComponentProps<typeof ProgressPrimitive.Track>;
|
|
15
|
+
|
|
16
|
+
type ProgressValueProps = React.ComponentProps<typeof ProgressPrimitive.Value>;
|
|
17
|
+
|
|
18
|
+
function ProgressIndicator({
|
|
19
|
+
className,
|
|
20
|
+
indicatorClassName,
|
|
21
|
+
...props
|
|
22
|
+
}: ProgressIndicatorProps) {
|
|
23
|
+
return (
|
|
24
|
+
<ProgressPrimitive.Indicator
|
|
25
|
+
className={cn(
|
|
26
|
+
'bg-primary h-full rounded-full transition-[width] duration-300',
|
|
27
|
+
className,
|
|
28
|
+
indicatorClassName,
|
|
29
|
+
)}
|
|
30
|
+
data-slot="progress-indicator"
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function ProgressLabel({ className, ...props }: ProgressLabelProps) {
|
|
37
|
+
return (
|
|
38
|
+
<ProgressPrimitive.Label
|
|
39
|
+
className={cn('text-sm leading-none font-medium', className)}
|
|
40
|
+
data-slot="progress-label"
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function ProgressRoot({ children, className, ...props }: ProgressProps) {
|
|
47
|
+
return (
|
|
48
|
+
<ProgressPrimitive.Root
|
|
49
|
+
className={cn('grid w-full gap-2', className)}
|
|
50
|
+
data-slot="progress"
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
{children ?? (
|
|
54
|
+
<ProgressTrack>
|
|
55
|
+
<ProgressIndicator />
|
|
56
|
+
</ProgressTrack>
|
|
57
|
+
)}
|
|
58
|
+
</ProgressPrimitive.Root>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function ProgressTrack({ children, className, ...props }: ProgressTrackProps) {
|
|
63
|
+
return (
|
|
64
|
+
<ProgressPrimitive.Track
|
|
65
|
+
className={cn(
|
|
66
|
+
'bg-muted h-2 w-full overflow-hidden rounded-full',
|
|
67
|
+
className,
|
|
68
|
+
)}
|
|
69
|
+
data-slot="progress-track"
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
{children ?? <ProgressIndicator />}
|
|
73
|
+
</ProgressPrimitive.Track>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function ProgressValue({ className, ...props }: ProgressValueProps) {
|
|
78
|
+
return (
|
|
79
|
+
<ProgressPrimitive.Value
|
|
80
|
+
className={cn(
|
|
81
|
+
'text-muted-foreground text-right text-sm tabular-nums',
|
|
82
|
+
className,
|
|
83
|
+
)}
|
|
84
|
+
data-slot="progress-value"
|
|
85
|
+
{...props}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const Progress = Object.assign(ProgressRoot, {
|
|
91
|
+
Indicator: ProgressIndicator,
|
|
92
|
+
Label: ProgressLabel,
|
|
93
|
+
Track: ProgressTrack,
|
|
94
|
+
Value: ProgressValue,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
Progress,
|
|
99
|
+
ProgressIndicator,
|
|
100
|
+
ProgressLabel,
|
|
101
|
+
ProgressRoot,
|
|
102
|
+
ProgressTrack,
|
|
103
|
+
ProgressValue,
|
|
104
|
+
};
|
|
105
|
+
export type {
|
|
106
|
+
ProgressIndicatorProps,
|
|
107
|
+
ProgressLabelProps,
|
|
108
|
+
ProgressProps,
|
|
109
|
+
ProgressTrackProps,
|
|
110
|
+
ProgressValueProps,
|
|
111
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Story } from './_internal/Story';
|
|
4
|
+
import { ScrollArea } from './ScrollArea';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: ScrollArea,
|
|
9
|
+
parameters: { layout: 'fullscreen' },
|
|
10
|
+
title: 'components/ScrollArea',
|
|
11
|
+
} satisfies Meta<typeof ScrollArea>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
const releases = Array.from({ length: 18 }, (_, index) => ({
|
|
17
|
+
date: `Jun ${20 - index}`,
|
|
18
|
+
version: `0.${18 - index}.0`,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
export const All: StoryDefinition = {
|
|
22
|
+
render: () => (
|
|
23
|
+
<Story.Layout className="max-w-4xl" title="ScrollArea">
|
|
24
|
+
<Story.Section title="Vertical">
|
|
25
|
+
<ScrollArea
|
|
26
|
+
className="border-border h-72 w-80 overflow-hidden rounded-md border"
|
|
27
|
+
contentClassName="p-4 pr-6 pb-0"
|
|
28
|
+
>
|
|
29
|
+
<Text as="h3" className="mb-3" weight="bold">
|
|
30
|
+
Releases
|
|
31
|
+
</Text>
|
|
32
|
+
{releases.map((release) => (
|
|
33
|
+
<div
|
|
34
|
+
className="border-border flex justify-between border-t py-3 text-sm"
|
|
35
|
+
key={release.version}
|
|
36
|
+
>
|
|
37
|
+
<Text as="span">{release.version}</Text>
|
|
38
|
+
<Text as="span" tone="muted">
|
|
39
|
+
{release.date}
|
|
40
|
+
</Text>
|
|
41
|
+
</div>
|
|
42
|
+
))}
|
|
43
|
+
</ScrollArea>
|
|
44
|
+
</Story.Section>
|
|
45
|
+
|
|
46
|
+
<Story.Section title="Both axes">
|
|
47
|
+
<ScrollArea
|
|
48
|
+
className="border-border h-44 w-full overflow-hidden rounded-md border"
|
|
49
|
+
contentClassName="w-max p-4"
|
|
50
|
+
orientation="both"
|
|
51
|
+
>
|
|
52
|
+
<div className="grid grid-cols-8 gap-3">
|
|
53
|
+
{Array.from({ length: 24 }, (_, index) => (
|
|
54
|
+
<div
|
|
55
|
+
className="bg-muted flex h-20 w-32 items-center justify-center rounded-md text-sm"
|
|
56
|
+
key={index}
|
|
57
|
+
>
|
|
58
|
+
<Text as="span">Item {index + 1}</Text>
|
|
59
|
+
</div>
|
|
60
|
+
))}
|
|
61
|
+
</div>
|
|
62
|
+
</ScrollArea>
|
|
63
|
+
</Story.Section>
|
|
64
|
+
</Story.Layout>
|
|
65
|
+
),
|
|
66
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { ScrollArea } from './ScrollArea';
|
|
5
|
+
|
|
6
|
+
describe('ScrollArea', () => {
|
|
7
|
+
it('composes its viewport and content automatically', async () => {
|
|
8
|
+
const { container } = render(<ScrollArea>Scrollable content</ScrollArea>);
|
|
9
|
+
|
|
10
|
+
await waitFor(() =>
|
|
11
|
+
expect(
|
|
12
|
+
container.querySelector('[data-slot="scroll-area-viewport"]'),
|
|
13
|
+
).toContainElement(screen.getByText('Scrollable content')),
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('keeps low-level parts available for custom composition', async () => {
|
|
18
|
+
render(
|
|
19
|
+
<ScrollArea.Root>
|
|
20
|
+
<ScrollArea.Viewport data-testid="custom-viewport">
|
|
21
|
+
<ScrollArea.Content>Custom content</ScrollArea.Content>
|
|
22
|
+
</ScrollArea.Viewport>
|
|
23
|
+
</ScrollArea.Root>,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
await waitFor(() =>
|
|
27
|
+
expect(screen.getByTestId('custom-viewport')).toHaveTextContent(
|
|
28
|
+
'Custom content',
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
|
|
6
|
+
type ScrollAreaContentProps = React.ComponentProps<
|
|
7
|
+
typeof ScrollAreaPrimitive.Content
|
|
8
|
+
>;
|
|
9
|
+
type ScrollAreaCornerProps = React.ComponentProps<
|
|
10
|
+
typeof ScrollAreaPrimitive.Corner
|
|
11
|
+
>;
|
|
12
|
+
type ScrollAreaProps = Omit<ScrollAreaRootProps, 'children'> & {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
contentClassName?: string;
|
|
15
|
+
orientation?: 'both' | 'horizontal' | 'vertical';
|
|
16
|
+
viewportClassName?: string;
|
|
17
|
+
};
|
|
18
|
+
type ScrollAreaRootProps = React.ComponentProps<
|
|
19
|
+
typeof ScrollAreaPrimitive.Root
|
|
20
|
+
>;
|
|
21
|
+
type ScrollAreaScrollbarProps = React.ComponentProps<
|
|
22
|
+
typeof ScrollAreaPrimitive.Scrollbar
|
|
23
|
+
>;
|
|
24
|
+
type ScrollAreaThumbProps = React.ComponentProps<
|
|
25
|
+
typeof ScrollAreaPrimitive.Thumb
|
|
26
|
+
>;
|
|
27
|
+
type ScrollAreaViewportProps = React.ComponentProps<
|
|
28
|
+
typeof ScrollAreaPrimitive.Viewport
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
function ScrollAreaContent({ className, ...props }: ScrollAreaContentProps) {
|
|
32
|
+
return (
|
|
33
|
+
<ScrollAreaPrimitive.Content
|
|
34
|
+
className={cn('min-w-full', className)}
|
|
35
|
+
data-slot="scroll-area-content"
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function ScrollAreaCorner({ className, ...props }: ScrollAreaCornerProps) {
|
|
42
|
+
return (
|
|
43
|
+
<ScrollAreaPrimitive.Corner
|
|
44
|
+
className={cn('absolute right-0 bottom-0 bg-transparent', className)}
|
|
45
|
+
data-slot="scroll-area-corner"
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function ScrollAreaFacade({
|
|
52
|
+
children,
|
|
53
|
+
contentClassName,
|
|
54
|
+
orientation = 'vertical',
|
|
55
|
+
viewportClassName,
|
|
56
|
+
...props
|
|
57
|
+
}: ScrollAreaProps) {
|
|
58
|
+
const hasHorizontalScrollbar =
|
|
59
|
+
orientation === 'horizontal' || orientation === 'both';
|
|
60
|
+
const hasVerticalScrollbar =
|
|
61
|
+
orientation === 'vertical' || orientation === 'both';
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<ScrollAreaRoot {...props}>
|
|
65
|
+
<ScrollAreaViewport className={viewportClassName}>
|
|
66
|
+
<ScrollAreaContent className={contentClassName}>
|
|
67
|
+
{children}
|
|
68
|
+
</ScrollAreaContent>
|
|
69
|
+
</ScrollAreaViewport>
|
|
70
|
+
{hasVerticalScrollbar ? <ScrollAreaScrollbar /> : null}
|
|
71
|
+
{hasHorizontalScrollbar ? (
|
|
72
|
+
<ScrollAreaScrollbar orientation="horizontal" />
|
|
73
|
+
) : null}
|
|
74
|
+
{orientation === 'both' ? <ScrollAreaCorner /> : null}
|
|
75
|
+
</ScrollAreaRoot>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function ScrollAreaRoot({ className, ...props }: ScrollAreaRootProps) {
|
|
80
|
+
return (
|
|
81
|
+
<ScrollAreaPrimitive.Root
|
|
82
|
+
className={cn('relative', className)}
|
|
83
|
+
data-slot="scroll-area"
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function ScrollAreaScrollbar({
|
|
90
|
+
children,
|
|
91
|
+
className,
|
|
92
|
+
orientation = 'vertical',
|
|
93
|
+
...props
|
|
94
|
+
}: ScrollAreaScrollbarProps) {
|
|
95
|
+
return (
|
|
96
|
+
<ScrollAreaPrimitive.Scrollbar
|
|
97
|
+
className={cn(
|
|
98
|
+
'pointer-events-none absolute flex touch-none p-0.5 opacity-0 transition-opacity duration-150 select-none data-hovering:pointer-events-auto data-hovering:opacity-100 data-scrolling:pointer-events-auto data-scrolling:opacity-100',
|
|
99
|
+
orientation === 'vertical' && 'inset-y-0 right-0 w-2.5 justify-center',
|
|
100
|
+
orientation === 'horizontal' && 'inset-x-0 bottom-0 h-2.5 items-center',
|
|
101
|
+
className,
|
|
102
|
+
)}
|
|
103
|
+
data-slot="scroll-area-scrollbar"
|
|
104
|
+
orientation={orientation}
|
|
105
|
+
{...props}
|
|
106
|
+
>
|
|
107
|
+
{children ?? <ScrollAreaThumb />}
|
|
108
|
+
</ScrollAreaPrimitive.Scrollbar>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function ScrollAreaThumb({ className, ...props }: ScrollAreaThumbProps) {
|
|
113
|
+
return (
|
|
114
|
+
<ScrollAreaPrimitive.Thumb
|
|
115
|
+
className={cn(
|
|
116
|
+
'bg-border relative rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-(--scroll-area-thumb-width) data-[orientation=vertical]:h-(--scroll-area-thumb-height) data-[orientation=vertical]:w-1.5',
|
|
117
|
+
className,
|
|
118
|
+
)}
|
|
119
|
+
data-slot="scroll-area-thumb"
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function ScrollAreaViewport({ className, ...props }: ScrollAreaViewportProps) {
|
|
126
|
+
return (
|
|
127
|
+
<ScrollAreaPrimitive.Viewport
|
|
128
|
+
className={cn('size-full rounded-[inherit] outline-none', className)}
|
|
129
|
+
data-slot="scroll-area-viewport"
|
|
130
|
+
{...props}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const ScrollArea = Object.assign(ScrollAreaFacade, {
|
|
136
|
+
Content: ScrollAreaContent,
|
|
137
|
+
Corner: ScrollAreaCorner,
|
|
138
|
+
Root: ScrollAreaRoot,
|
|
139
|
+
Scrollbar: ScrollAreaScrollbar,
|
|
140
|
+
Thumb: ScrollAreaThumb,
|
|
141
|
+
Viewport: ScrollAreaViewport,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
ScrollArea,
|
|
146
|
+
ScrollAreaContent,
|
|
147
|
+
ScrollAreaCorner,
|
|
148
|
+
ScrollAreaScrollbar,
|
|
149
|
+
ScrollAreaThumb,
|
|
150
|
+
ScrollAreaViewport,
|
|
151
|
+
};
|
|
152
|
+
export type {
|
|
153
|
+
ScrollAreaContentProps,
|
|
154
|
+
ScrollAreaCornerProps,
|
|
155
|
+
ScrollAreaProps,
|
|
156
|
+
ScrollAreaRootProps,
|
|
157
|
+
ScrollAreaScrollbarProps,
|
|
158
|
+
ScrollAreaThumbProps,
|
|
159
|
+
ScrollAreaViewportProps,
|
|
160
|
+
};
|