@pickle-ui/react 0.0.0-stage → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +490 -2
- package/dist/components/Alert.d.ts +38 -0
- package/dist/components/Alert.d.ts.map +1 -0
- package/dist/components/Alert.js +54 -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 +105 -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 +56 -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 +22 -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 +10 -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 +14 -0
- package/dist/lib/compose-refs.d.ts.map +1 -0
- package/dist/lib/compose-refs.js +57 -0
- package/dist/lib/compose-refs.js.map +1 -0
- package/dist/lib/theme.d.ts +40 -0
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/lib/theme.js +82 -0
- package/dist/lib/theme.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 +107 -4
- package/src/base.css +99 -0
- package/src/components/Alert.stories.tsx +124 -0
- package/src/components/Alert.test.tsx +76 -0
- package/src/components/Alert.tsx +133 -0
- package/src/components/AlertDialog.stories.tsx +184 -0
- package/src/components/AlertDialog.test.tsx +142 -0
- package/src/components/AlertDialog.tsx +164 -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 +112 -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 +129 -0
- package/src/components/Dialog.stories.tsx +133 -0
- package/src/components/Dialog.test.tsx +95 -0
- package/src/components/Dialog.tsx +147 -0
- package/src/components/Flex.stories.tsx +70 -0
- package/src/components/Flex.test.tsx +53 -0
- package/src/components/Flex.tsx +59 -0
- package/src/components/Grid.stories.tsx +70 -0
- package/src/components/Grid.test.tsx +46 -0
- package/src/components/Grid.tsx +114 -0
- package/src/components/Group.stories.tsx +130 -0
- package/src/components/Group.test.tsx +57 -0
- package/src/components/Group.tsx +92 -0
- package/src/components/Menu.stories.tsx +139 -0
- package/src/components/Menu.test.tsx +103 -0
- package/src/components/Menu.tsx +290 -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 +270 -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 +19 -0
- package/src/components/YStack.stories.tsx +65 -0
- package/src/components/YStack.test.tsx +31 -0
- package/src/components/YStack.tsx +19 -0
- package/src/components/_internal/Story.tsx +161 -0
- package/src/components/_internal/VisuallyHiddenInput.tsx +164 -0
- package/src/components/_internal/dialog-styles.ts +57 -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 +1283 -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 +667 -0
- package/src/components/form/Form.context.ts +114 -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 +50 -0
- package/src/components/form/FormCheckbox.tsx +50 -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 +109 -0
- package/src/components/form/FormInput.tsx +41 -0
- package/src/components/form/FormInputGroup.tsx +47 -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 +50 -0
- package/src/components/form/FormTextarea.tsx +34 -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 +93 -0
- package/src/components/form/InputGroup.stories.tsx +162 -0
- package/src/components/form/InputGroup.tsx +149 -0
- package/src/components/form/RadioGroup.stories.tsx +68 -0
- package/src/components/form/RadioGroup.test.tsx +171 -0
- package/src/components/form/RadioGroup.tsx +127 -0
- package/src/components/form/Select.stories.tsx +115 -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 +13 -0
- package/src/index.ts +38 -0
- package/src/lib/color.test.ts +148 -0
- package/src/lib/color.ts +193 -0
- package/src/lib/compose-refs.ts +63 -0
- package/src/lib/theme.test.ts +64 -0
- package/src/lib/theme.ts +143 -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 +195 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Toast as ToastPrimitive } from '@base-ui/react/toast';
|
|
4
|
+
import {
|
|
5
|
+
IconAlertCircle,
|
|
6
|
+
IconAlertTriangle,
|
|
7
|
+
IconCircleCheck,
|
|
8
|
+
IconInfoCircle,
|
|
9
|
+
IconX,
|
|
10
|
+
} from '@tabler/icons-react';
|
|
11
|
+
import { cva } from 'class-variance-authority';
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
|
|
14
|
+
import { cn } from '@/lib/utils';
|
|
15
|
+
|
|
16
|
+
import { buttonVariants } from './Button';
|
|
17
|
+
import { Spinner } from './Spinner';
|
|
18
|
+
import { Text } from './Text';
|
|
19
|
+
|
|
20
|
+
type SwipeDirection = 'down' | 'left' | 'right' | 'up';
|
|
21
|
+
|
|
22
|
+
type ToastActionProps = React.ComponentProps<typeof ToastPrimitive.Action>;
|
|
23
|
+
type ToastCloseProps = React.ComponentProps<typeof ToastPrimitive.Close>;
|
|
24
|
+
type ToastDescriptionProps = React.ComponentProps<
|
|
25
|
+
typeof ToastPrimitive.Description
|
|
26
|
+
>;
|
|
27
|
+
type ToastObject = ToastPrimitive.Root.ToastObject;
|
|
28
|
+
type ToastPosition =
|
|
29
|
+
| 'bottom-center'
|
|
30
|
+
| 'bottom-left'
|
|
31
|
+
| 'bottom-right'
|
|
32
|
+
| 'top-center'
|
|
33
|
+
| 'top-left'
|
|
34
|
+
| 'top-right';
|
|
35
|
+
type ToastProviderProps = React.ComponentProps<
|
|
36
|
+
typeof ToastPrimitive.Provider
|
|
37
|
+
> & {
|
|
38
|
+
/**
|
|
39
|
+
* Accessible name of each toast's close button.
|
|
40
|
+
* @default 'Close'
|
|
41
|
+
*/
|
|
42
|
+
closeLabel?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Where the toast stack is anchored in the window.
|
|
45
|
+
* @default 'bottom-right'
|
|
46
|
+
*/
|
|
47
|
+
position?: ToastPosition;
|
|
48
|
+
};
|
|
49
|
+
type ToastTitleProps = React.ComponentProps<typeof ToastPrimitive.Title>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Global toast manager, usable outside React (`Toast.manager.add({ … })`).
|
|
53
|
+
* `Toast.Provider` subscribes to it, so mount a single provider per app.
|
|
54
|
+
*/
|
|
55
|
+
const toastManager = ToastPrimitive.createToastManager();
|
|
56
|
+
|
|
57
|
+
const swipeDirections: Record<ToastPosition, SwipeDirection[]> = {
|
|
58
|
+
'bottom-center': ['down'],
|
|
59
|
+
'bottom-left': ['down', 'left'],
|
|
60
|
+
'bottom-right': ['down', 'right'],
|
|
61
|
+
'top-center': ['up'],
|
|
62
|
+
'top-left': ['up', 'left'],
|
|
63
|
+
'top-right': ['up', 'right'],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const toastViewportVariants = cva(
|
|
67
|
+
'fixed z-50 flex w-[calc(100%-var(--spacing)*8)] max-w-90 outline-none',
|
|
68
|
+
{
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
position: 'bottom-right',
|
|
71
|
+
},
|
|
72
|
+
variants: {
|
|
73
|
+
position: {
|
|
74
|
+
'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2 [--toast-dir:-1]',
|
|
75
|
+
'bottom-left': 'bottom-4 left-4 [--toast-dir:-1]',
|
|
76
|
+
'bottom-right': 'right-4 bottom-4 [--toast-dir:-1]',
|
|
77
|
+
'top-center': 'top-4 left-1/2 -translate-x-1/2 [--toast-dir:1]',
|
|
78
|
+
'top-left': 'top-4 left-4 [--toast-dir:1]',
|
|
79
|
+
'top-right': 'top-4 right-4 [--toast-dir:1]',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const toastIcons: Record<string, React.ReactNode> = {
|
|
86
|
+
error: <IconAlertCircle className="text-destructive" />,
|
|
87
|
+
info: <IconInfoCircle className="text-info" />,
|
|
88
|
+
loading: <Spinner aria-hidden className="text-muted-foreground" />,
|
|
89
|
+
success: <IconCircleCheck className="text-success" />,
|
|
90
|
+
warning: <IconAlertTriangle className="text-warning" />,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
function ToastAction({ className, ...props }: ToastActionProps) {
|
|
94
|
+
return (
|
|
95
|
+
<ToastPrimitive.Action
|
|
96
|
+
className={cn(
|
|
97
|
+
buttonVariants({ size: 'xs', variant: 'outline' }),
|
|
98
|
+
className,
|
|
99
|
+
)}
|
|
100
|
+
data-slot="toast-action"
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function ToastClose({
|
|
107
|
+
'aria-label': ariaLabel = 'Close',
|
|
108
|
+
children,
|
|
109
|
+
className,
|
|
110
|
+
...props
|
|
111
|
+
}: ToastCloseProps) {
|
|
112
|
+
return (
|
|
113
|
+
<ToastPrimitive.Close
|
|
114
|
+
aria-label={ariaLabel}
|
|
115
|
+
className={cn(
|
|
116
|
+
buttonVariants({ size: 'icon-xs', variant: 'ghost' }),
|
|
117
|
+
'text-muted-foreground hover:text-foreground -me-1',
|
|
118
|
+
className,
|
|
119
|
+
)}
|
|
120
|
+
data-slot="toast-close"
|
|
121
|
+
{...props}
|
|
122
|
+
>
|
|
123
|
+
{children ?? <IconX />}
|
|
124
|
+
</ToastPrimitive.Close>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function ToastDescription({ className, ...props }: ToastDescriptionProps) {
|
|
129
|
+
return (
|
|
130
|
+
<ToastPrimitive.Description
|
|
131
|
+
className={cn('text-sm leading-5', className)}
|
|
132
|
+
data-slot="toast-description"
|
|
133
|
+
render={<Text tone="muted" variant="body" />}
|
|
134
|
+
{...props}
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function ToastList({
|
|
140
|
+
closeLabel,
|
|
141
|
+
position,
|
|
142
|
+
}: {
|
|
143
|
+
closeLabel: string;
|
|
144
|
+
position: ToastPosition;
|
|
145
|
+
}) {
|
|
146
|
+
const { toasts } = ToastPrimitive.useToastManager();
|
|
147
|
+
|
|
148
|
+
return toasts.map((toast) => (
|
|
149
|
+
<ToastRoot
|
|
150
|
+
closeLabel={closeLabel}
|
|
151
|
+
key={toast.id}
|
|
152
|
+
swipeDirection={swipeDirections[position]}
|
|
153
|
+
toast={toast}
|
|
154
|
+
/>
|
|
155
|
+
));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Mount once near the root of the app. Renders `children` plus the portalled
|
|
160
|
+
* viewport that stacks toasts added through `Toast.manager` or
|
|
161
|
+
* `Toast.useToast()`. A toast's `type` (`success`, `error`, `warning`,
|
|
162
|
+
* `info`, `loading`) picks its icon.
|
|
163
|
+
*/
|
|
164
|
+
function ToastProvider({
|
|
165
|
+
children,
|
|
166
|
+
closeLabel = 'Close',
|
|
167
|
+
position = 'bottom-right',
|
|
168
|
+
toastManager: manager = toastManager,
|
|
169
|
+
...props
|
|
170
|
+
}: ToastProviderProps) {
|
|
171
|
+
return (
|
|
172
|
+
<ToastPrimitive.Provider toastManager={manager} {...props}>
|
|
173
|
+
{children}
|
|
174
|
+
<ToastPrimitive.Portal>
|
|
175
|
+
<ToastPrimitive.Viewport
|
|
176
|
+
className={toastViewportVariants({ position })}
|
|
177
|
+
data-position={position}
|
|
178
|
+
data-slot="toast-viewport"
|
|
179
|
+
>
|
|
180
|
+
<ToastList closeLabel={closeLabel} position={position} />
|
|
181
|
+
</ToastPrimitive.Viewport>
|
|
182
|
+
</ToastPrimitive.Portal>
|
|
183
|
+
</ToastPrimitive.Provider>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** A single toast; `Toast.Provider` renders one per queued toast. */
|
|
188
|
+
function ToastRoot({
|
|
189
|
+
closeLabel,
|
|
190
|
+
swipeDirection,
|
|
191
|
+
toast,
|
|
192
|
+
}: {
|
|
193
|
+
closeLabel: string;
|
|
194
|
+
swipeDirection: SwipeDirection[];
|
|
195
|
+
toast: ToastObject;
|
|
196
|
+
}) {
|
|
197
|
+
const icon = toast.type ? toastIcons[toast.type] : undefined;
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<ToastPrimitive.Root
|
|
201
|
+
className={cn(
|
|
202
|
+
// Stack geometry, driven by Base UI's --toast-* variables and the
|
|
203
|
+
// viewport's --toast-dir (-1 stacks upwards, 1 stacks downwards).
|
|
204
|
+
'[--toast-expanded-y:calc(var(--toast-dir)*(var(--toast-offset-y)+var(--toast-index)*var(--toast-gap))+var(--toast-swipe-movement-y))] [--toast-gap:--spacing(3)] [--toast-peek:--spacing(3)] [--toast-scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--toast-shrink:calc(1-var(--toast-scale))] [--toast-stack-height:var(--toast-frontmost-height,var(--toast-height))]',
|
|
205
|
+
'absolute inset-x-0 z-[calc(1000-var(--toast-index))] h-(--toast-stack-height) w-full select-none in-[[data-position^=bottom]]:bottom-0 in-[[data-position^=bottom]]:origin-bottom in-[[data-position^=top]]:top-0 in-[[data-position^=top]]:origin-top data-expanded:h-(--toast-height)',
|
|
206
|
+
'translate-x-(--toast-swipe-movement-x) translate-y-[calc(var(--toast-swipe-movement-y)+var(--toast-dir)*(var(--toast-index)*var(--toast-peek)+var(--toast-shrink)*var(--toast-stack-height)))] scale-(--toast-scale) data-expanded:translate-y-(--toast-expanded-y) data-expanded:scale-100',
|
|
207
|
+
'transition-[translate,scale,opacity,height] duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] data-ending-style:opacity-0 data-limited:opacity-0 data-starting-style:translate-y-[calc(var(--toast-dir)*-150%)] [&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:translate-y-[calc(var(--toast-dir)*-150%)]',
|
|
208
|
+
'data-ending-style:data-[swipe-direction=down]:translate-y-[calc(var(--toast-swipe-movement-y)+150%)] data-ending-style:data-[swipe-direction=left]:translate-x-[calc(var(--toast-swipe-movement-x)-150%)] data-ending-style:data-[swipe-direction=left]:translate-y-(--toast-expanded-y) data-ending-style:data-[swipe-direction=right]:translate-x-[calc(var(--toast-swipe-movement-x)+150%)] data-ending-style:data-[swipe-direction=right]:translate-y-(--toast-expanded-y) data-ending-style:data-[swipe-direction=up]:translate-y-[calc(var(--toast-swipe-movement-y)-150%)]',
|
|
209
|
+
// Keeps the stack expanded while the pointer crosses the gap.
|
|
210
|
+
"after:absolute after:inset-x-0 after:h-[calc(var(--toast-gap)+1px)] after:content-[''] in-[[data-position^=bottom]]:after:top-full in-[[data-position^=top]]:after:bottom-full",
|
|
211
|
+
'bg-popover text-popover-foreground rounded-xl border bg-clip-padding text-sm shadow-lg/5',
|
|
212
|
+
)}
|
|
213
|
+
data-slot="toast"
|
|
214
|
+
swipeDirection={swipeDirection}
|
|
215
|
+
toast={toast}
|
|
216
|
+
>
|
|
217
|
+
<ToastPrimitive.Content className="flex items-start gap-2.5 overflow-hidden px-3.5 py-3 transition-opacity duration-250 data-behind:pointer-events-none data-behind:opacity-0 data-expanded:pointer-events-auto data-expanded:opacity-100">
|
|
218
|
+
{icon ? (
|
|
219
|
+
<div
|
|
220
|
+
aria-hidden
|
|
221
|
+
className="flex h-5 shrink-0 items-center [&_svg]:size-4"
|
|
222
|
+
data-slot="toast-icon"
|
|
223
|
+
>
|
|
224
|
+
{icon}
|
|
225
|
+
</div>
|
|
226
|
+
) : null}
|
|
227
|
+
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
228
|
+
<ToastTitle />
|
|
229
|
+
<ToastDescription />
|
|
230
|
+
</div>
|
|
231
|
+
<div className="flex shrink-0 items-center gap-1">
|
|
232
|
+
<ToastAction />
|
|
233
|
+
<ToastClose aria-label={closeLabel} />
|
|
234
|
+
</div>
|
|
235
|
+
</ToastPrimitive.Content>
|
|
236
|
+
</ToastPrimitive.Root>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function ToastTitle({ className, ...props }: ToastTitleProps) {
|
|
241
|
+
return (
|
|
242
|
+
<ToastPrimitive.Title
|
|
243
|
+
className={cn('text-sm leading-5 font-medium', className)}
|
|
244
|
+
data-slot="toast-title"
|
|
245
|
+
render={<Text as="h2" variant="body" />}
|
|
246
|
+
{...props}
|
|
247
|
+
/>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Returns the toast manager of the nearest `Toast.Provider`: `add`, `close`,
|
|
253
|
+
* `update`, `promise` and the current `toasts`.
|
|
254
|
+
*/
|
|
255
|
+
function useToast() {
|
|
256
|
+
return ToastPrimitive.useToastManager();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Toasts are added imperatively, so `Toast` groups the provider and the two
|
|
261
|
+
* ways to reach its manager rather than rendering a toast itself.
|
|
262
|
+
*/
|
|
263
|
+
const Toast = {
|
|
264
|
+
manager: toastManager,
|
|
265
|
+
Provider: ToastProvider,
|
|
266
|
+
useToast,
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export { Toast };
|
|
270
|
+
export type { ToastProviderProps };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { IconCopy, IconEdit, IconTrash } from '@tabler/icons-react';
|
|
4
|
+
|
|
5
|
+
import { type ComponentMatrixCellProps, Story } from './_internal/Story';
|
|
6
|
+
import { Button } from './Button';
|
|
7
|
+
import { Text } from './Text';
|
|
8
|
+
import { Tooltip, type TooltipContentProps } from './Tooltip';
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
component: Tooltip,
|
|
12
|
+
parameters: {
|
|
13
|
+
layout: 'fullscreen',
|
|
14
|
+
},
|
|
15
|
+
title: 'components/Tooltip',
|
|
16
|
+
} satisfies Meta<typeof Tooltip>;
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
const SIDE_COLUMNS: {
|
|
22
|
+
key: NonNullable<TooltipContentProps['side']>;
|
|
23
|
+
label: string;
|
|
24
|
+
}[] = [
|
|
25
|
+
{ key: 'top', label: 'Top' },
|
|
26
|
+
{ key: 'right', label: 'Right' },
|
|
27
|
+
{ key: 'bottom', label: 'Bottom' },
|
|
28
|
+
{ key: 'left', label: 'Left' },
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const TRIGGER_ROWS = [
|
|
32
|
+
{ key: 'text', label: 'Text trigger' },
|
|
33
|
+
{ key: 'icon', label: 'Icon-only trigger' },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
function TooltipMatrixCell({ column, row }: ComponentMatrixCellProps) {
|
|
37
|
+
const side = column.key as NonNullable<TooltipContentProps['side']>;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Tooltip>
|
|
41
|
+
{row.key === 'icon' ? (
|
|
42
|
+
<Tooltip.Trigger
|
|
43
|
+
render={
|
|
44
|
+
<Button aria-label="Copy link" size="icon" variant="outline" />
|
|
45
|
+
}
|
|
46
|
+
>
|
|
47
|
+
<IconCopy />
|
|
48
|
+
</Tooltip.Trigger>
|
|
49
|
+
) : (
|
|
50
|
+
<Tooltip.Trigger render={<Button variant="outline" />}>
|
|
51
|
+
Hover me
|
|
52
|
+
</Tooltip.Trigger>
|
|
53
|
+
)}
|
|
54
|
+
<Tooltip.Content side={side}>
|
|
55
|
+
{row.key === 'icon' ? 'Copy link' : `Shown on the ${column.label}`}
|
|
56
|
+
</Tooltip.Content>
|
|
57
|
+
</Tooltip>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const All: StoryDefinition = {
|
|
62
|
+
render: () => (
|
|
63
|
+
<Story.Layout className="max-w-6xl" title="Tooltip">
|
|
64
|
+
<Story.Section title="Sides and triggers">
|
|
65
|
+
<Story.Matrix
|
|
66
|
+
Cell={TooltipMatrixCell}
|
|
67
|
+
columns={SIDE_COLUMNS}
|
|
68
|
+
rows={TRIGGER_ROWS}
|
|
69
|
+
/>
|
|
70
|
+
</Story.Section>
|
|
71
|
+
<Story.Section title="Shared delay with Provider">
|
|
72
|
+
<Text className="mb-4" tone="muted">
|
|
73
|
+
Once one tooltip is open, moving to a neighbour opens it instantly.
|
|
74
|
+
</Text>
|
|
75
|
+
<Tooltip.Provider delay={300}>
|
|
76
|
+
<div className="flex gap-2">
|
|
77
|
+
<Tooltip>
|
|
78
|
+
<Tooltip.Trigger
|
|
79
|
+
render={
|
|
80
|
+
<Button aria-label="Edit" size="icon" variant="outline" />
|
|
81
|
+
}
|
|
82
|
+
>
|
|
83
|
+
<IconEdit />
|
|
84
|
+
</Tooltip.Trigger>
|
|
85
|
+
<Tooltip.Content>Edit</Tooltip.Content>
|
|
86
|
+
</Tooltip>
|
|
87
|
+
<Tooltip>
|
|
88
|
+
<Tooltip.Trigger
|
|
89
|
+
render={
|
|
90
|
+
<Button
|
|
91
|
+
aria-label="Duplicate"
|
|
92
|
+
size="icon"
|
|
93
|
+
variant="outline"
|
|
94
|
+
/>
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
<IconCopy />
|
|
98
|
+
</Tooltip.Trigger>
|
|
99
|
+
<Tooltip.Content>Duplicate</Tooltip.Content>
|
|
100
|
+
</Tooltip>
|
|
101
|
+
<Tooltip>
|
|
102
|
+
<Tooltip.Trigger
|
|
103
|
+
render={
|
|
104
|
+
<Button aria-label="Delete" size="icon" variant="outline" />
|
|
105
|
+
}
|
|
106
|
+
>
|
|
107
|
+
<IconTrash />
|
|
108
|
+
</Tooltip.Trigger>
|
|
109
|
+
<Tooltip.Content>Delete</Tooltip.Content>
|
|
110
|
+
</Tooltip>
|
|
111
|
+
</div>
|
|
112
|
+
</Tooltip.Provider>
|
|
113
|
+
</Story.Section>
|
|
114
|
+
</Story.Layout>
|
|
115
|
+
),
|
|
116
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { Tooltip } from './Tooltip';
|
|
5
|
+
|
|
6
|
+
describe('Tooltip', () => {
|
|
7
|
+
it('renders the content when open', () => {
|
|
8
|
+
render(
|
|
9
|
+
<Tooltip.Provider>
|
|
10
|
+
<Tooltip defaultOpen>
|
|
11
|
+
<Tooltip.Trigger>Save</Tooltip.Trigger>
|
|
12
|
+
<Tooltip.Content>Save changes</Tooltip.Content>
|
|
13
|
+
</Tooltip>
|
|
14
|
+
</Tooltip.Provider>,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
expect(screen.getByRole('button', { name: 'Save' })).toHaveAttribute(
|
|
18
|
+
'data-slot',
|
|
19
|
+
'tooltip-trigger',
|
|
20
|
+
);
|
|
21
|
+
expect(screen.getByText('Save changes')).toHaveAttribute(
|
|
22
|
+
'data-slot',
|
|
23
|
+
'tooltip-content',
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('does not render the content while closed', () => {
|
|
28
|
+
render(
|
|
29
|
+
<Tooltip>
|
|
30
|
+
<Tooltip.Trigger>Save</Tooltip.Trigger>
|
|
31
|
+
<Tooltip.Content>Save changes</Tooltip.Content>
|
|
32
|
+
</Tooltip>,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(screen.queryByText('Save changes')).not.toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('places the content on the requested side', () => {
|
|
39
|
+
render(
|
|
40
|
+
<Tooltip open>
|
|
41
|
+
<Tooltip.Trigger>Save</Tooltip.Trigger>
|
|
42
|
+
<Tooltip.Content side="bottom">Save changes</Tooltip.Content>
|
|
43
|
+
</Tooltip>,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(screen.getByText('Save changes')).toHaveAttribute(
|
|
47
|
+
'data-side',
|
|
48
|
+
'bottom',
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
|
|
6
|
+
type TooltipContentProps = Pick<
|
|
7
|
+
React.ComponentProps<typeof TooltipPrimitive.Positioner>,
|
|
8
|
+
'align' | 'alignOffset' | 'side' | 'sideOffset'
|
|
9
|
+
> &
|
|
10
|
+
React.ComponentProps<typeof TooltipPrimitive.Popup>;
|
|
11
|
+
type TooltipProps = React.ComponentProps<typeof TooltipPrimitive.Root>;
|
|
12
|
+
type TooltipProviderProps = React.ComponentProps<
|
|
13
|
+
typeof TooltipPrimitive.Provider
|
|
14
|
+
>;
|
|
15
|
+
type TooltipTriggerProps = React.ComponentProps<
|
|
16
|
+
typeof TooltipPrimitive.Trigger
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
function TooltipContent({
|
|
20
|
+
align = 'center',
|
|
21
|
+
alignOffset = 0,
|
|
22
|
+
children,
|
|
23
|
+
className,
|
|
24
|
+
side = 'top',
|
|
25
|
+
sideOffset = 6,
|
|
26
|
+
...props
|
|
27
|
+
}: TooltipContentProps) {
|
|
28
|
+
return (
|
|
29
|
+
<TooltipPrimitive.Portal>
|
|
30
|
+
<TooltipPrimitive.Positioner
|
|
31
|
+
align={align}
|
|
32
|
+
alignOffset={alignOffset}
|
|
33
|
+
className="z-50"
|
|
34
|
+
side={side}
|
|
35
|
+
sideOffset={sideOffset}
|
|
36
|
+
>
|
|
37
|
+
<TooltipPrimitive.Popup
|
|
38
|
+
className={cn(
|
|
39
|
+
'bg-foreground text-background 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 relative z-50 w-fit max-w-xs origin-(--transform-origin) rounded-md px-2 py-1 text-xs text-balance duration-100',
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
data-slot="tooltip-content"
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
<TooltipPrimitive.Arrow
|
|
47
|
+
className="bg-foreground size-2 rotate-45 rounded-[1px] data-[side=bottom]:-top-1 data-[side=left]:-right-1 data-[side=right]:-left-1 data-[side=top]:-bottom-1"
|
|
48
|
+
data-slot="tooltip-arrow"
|
|
49
|
+
/>
|
|
50
|
+
</TooltipPrimitive.Popup>
|
|
51
|
+
</TooltipPrimitive.Positioner>
|
|
52
|
+
</TooltipPrimitive.Portal>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function TooltipProvider({ ...props }: TooltipProviderProps) {
|
|
57
|
+
return <TooltipPrimitive.Provider {...props} />;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function TooltipRoot({ ...props }: TooltipProps) {
|
|
61
|
+
return <TooltipPrimitive.Root {...props} />;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function TooltipTrigger({ ...props }: TooltipTriggerProps) {
|
|
65
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const Tooltip = Object.assign(TooltipRoot, {
|
|
69
|
+
Content: TooltipContent,
|
|
70
|
+
Provider: TooltipProvider,
|
|
71
|
+
Trigger: TooltipTrigger,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
75
|
+
export type {
|
|
76
|
+
TooltipContentProps,
|
|
77
|
+
TooltipProps,
|
|
78
|
+
TooltipProviderProps,
|
|
79
|
+
TooltipTriggerProps,
|
|
80
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Story } from './_internal/Story';
|
|
4
|
+
import { Text } from './Text';
|
|
5
|
+
import { XStack } from './XStack';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: XStack,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'fullscreen',
|
|
11
|
+
},
|
|
12
|
+
title: 'components/XStack',
|
|
13
|
+
} satisfies Meta<typeof XStack>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
function Item({ children }: { children: string }) {
|
|
19
|
+
return (
|
|
20
|
+
<Text className="bg-muted rounded-md border px-4 py-3">{children}</Text>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const All: StoryDefinition = {
|
|
25
|
+
render: () => (
|
|
26
|
+
<Story.Layout className="max-w-6xl" title="XStack">
|
|
27
|
+
<Story.Section title="Horizontal spacing">
|
|
28
|
+
<XStack align="center" gap={3}>
|
|
29
|
+
<Item>Avatar</Item>
|
|
30
|
+
<Item>Profile details</Item>
|
|
31
|
+
<Item>Status</Item>
|
|
32
|
+
</XStack>
|
|
33
|
+
</Story.Section>
|
|
34
|
+
|
|
35
|
+
<Story.Section title="Distribution">
|
|
36
|
+
<XStack
|
|
37
|
+
align="center"
|
|
38
|
+
className="border-border rounded-md border border-dashed p-4"
|
|
39
|
+
justify="between"
|
|
40
|
+
>
|
|
41
|
+
<Item>Leading action</Item>
|
|
42
|
+
<Item>Trailing action</Item>
|
|
43
|
+
</XStack>
|
|
44
|
+
</Story.Section>
|
|
45
|
+
|
|
46
|
+
<Story.Section title="Wrapping">
|
|
47
|
+
<XStack gap={2} wrap="wrap">
|
|
48
|
+
{['Design', 'Engineering', 'Product', 'Research', 'Support'].map(
|
|
49
|
+
(label) => (
|
|
50
|
+
<Item key={label}>{label}</Item>
|
|
51
|
+
),
|
|
52
|
+
)}
|
|
53
|
+
</XStack>
|
|
54
|
+
</Story.Section>
|
|
55
|
+
|
|
56
|
+
<Story.Section title="Responsive override">
|
|
57
|
+
<XStack className="max-sm:flex-col" gap={3}>
|
|
58
|
+
<Item>Horizontal by default</Item>
|
|
59
|
+
<Item>Vertical below sm</Item>
|
|
60
|
+
</XStack>
|
|
61
|
+
</Story.Section>
|
|
62
|
+
</Story.Layout>
|
|
63
|
+
),
|
|
64
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { XStack } from './XStack';
|
|
5
|
+
|
|
6
|
+
describe('XStack', () => {
|
|
7
|
+
it('renders a row stack with shared Flex props', () => {
|
|
8
|
+
render(
|
|
9
|
+
<XStack align="center" gap={2} justify="between">
|
|
10
|
+
Content
|
|
11
|
+
</XStack>,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
expect(screen.getByText('Content')).toHaveClass(
|
|
15
|
+
'flex',
|
|
16
|
+
'flex-row',
|
|
17
|
+
'items-center',
|
|
18
|
+
'justify-between',
|
|
19
|
+
'gap-2',
|
|
20
|
+
);
|
|
21
|
+
expect(screen.getByText('Content')).toHaveAttribute('data-slot', 'x-stack');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('supports polymorphism, native props, and responsive overrides', () => {
|
|
25
|
+
render(
|
|
26
|
+
<XStack aria-label="actions" as="nav" className="max-md:flex-col" />,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const element = screen.getByLabelText('actions');
|
|
30
|
+
expect(element.tagName.toLowerCase()).toBe('nav');
|
|
31
|
+
expect(element).toHaveClass('max-md:flex-col');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { cn } from '@/lib/utils';
|
|
2
|
+
|
|
3
|
+
import { Flex, type FlexProps } from './Flex';
|
|
4
|
+
|
|
5
|
+
type XStackProps = Omit<FlexProps, 'direction'>;
|
|
6
|
+
|
|
7
|
+
function XStack({ className, ref, ...props }: XStackProps) {
|
|
8
|
+
return (
|
|
9
|
+
<Flex
|
|
10
|
+
className={cn('flex-row', className)}
|
|
11
|
+
data-slot="x-stack"
|
|
12
|
+
ref={ref}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { XStack };
|
|
19
|
+
export type { XStackProps };
|