@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,65 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Story } from './_internal/Story';
|
|
4
|
+
import { Text } from './Text';
|
|
5
|
+
import { YStack } from './YStack';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: YStack,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'fullscreen',
|
|
11
|
+
},
|
|
12
|
+
title: 'components/YStack',
|
|
13
|
+
} satisfies Meta<typeof YStack>;
|
|
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="YStack">
|
|
27
|
+
<Story.Section title="Vertical spacing">
|
|
28
|
+
<YStack gap={3}>
|
|
29
|
+
<Item>Heading</Item>
|
|
30
|
+
<Item>Supporting content</Item>
|
|
31
|
+
<Item>Actions</Item>
|
|
32
|
+
</YStack>
|
|
33
|
+
</Story.Section>
|
|
34
|
+
|
|
35
|
+
<Story.Section title="Alignment">
|
|
36
|
+
<YStack
|
|
37
|
+
align="center"
|
|
38
|
+
className="border-border rounded-md border border-dashed p-4"
|
|
39
|
+
gap={3}
|
|
40
|
+
>
|
|
41
|
+
<Item>Narrow item</Item>
|
|
42
|
+
<Item>Another item</Item>
|
|
43
|
+
</YStack>
|
|
44
|
+
</Story.Section>
|
|
45
|
+
|
|
46
|
+
<Story.Section title="Distribution">
|
|
47
|
+
<YStack
|
|
48
|
+
className="border-border min-h-80 rounded-md border border-dashed p-4"
|
|
49
|
+
justify="between"
|
|
50
|
+
>
|
|
51
|
+
<Item>Top</Item>
|
|
52
|
+
<Item>Middle</Item>
|
|
53
|
+
<Item>Bottom</Item>
|
|
54
|
+
</YStack>
|
|
55
|
+
</Story.Section>
|
|
56
|
+
|
|
57
|
+
<Story.Section title="Responsive override">
|
|
58
|
+
<YStack className="md:flex-row" gap={3}>
|
|
59
|
+
<Item>Vertical by default</Item>
|
|
60
|
+
<Item>Horizontal from md</Item>
|
|
61
|
+
</YStack>
|
|
62
|
+
</Story.Section>
|
|
63
|
+
</Story.Layout>
|
|
64
|
+
),
|
|
65
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { YStack } from './YStack';
|
|
5
|
+
|
|
6
|
+
describe('YStack', () => {
|
|
7
|
+
it('renders a column stack with shared Flex props', () => {
|
|
8
|
+
render(
|
|
9
|
+
<YStack align="stretch" gap={3} justify="center">
|
|
10
|
+
Content
|
|
11
|
+
</YStack>,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
expect(screen.getByText('Content')).toHaveClass(
|
|
15
|
+
'flex',
|
|
16
|
+
'flex-col',
|
|
17
|
+
'items-stretch',
|
|
18
|
+
'justify-center',
|
|
19
|
+
'gap-3',
|
|
20
|
+
);
|
|
21
|
+
expect(screen.getByText('Content')).toHaveAttribute('data-slot', 'y-stack');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('merges consumer classes after the fixed direction', () => {
|
|
25
|
+
render(<YStack className="custom-class flex-row">Content</YStack>);
|
|
26
|
+
|
|
27
|
+
const element = screen.getByText('Content');
|
|
28
|
+
expect(element).toHaveClass('flex-row', 'custom-class');
|
|
29
|
+
expect(element).not.toHaveClass('flex-col');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { cn } from '@/lib/utils';
|
|
2
|
+
|
|
3
|
+
import { Flex, type FlexProps } from './Flex';
|
|
4
|
+
|
|
5
|
+
type YStackProps = Omit<FlexProps, 'direction'>;
|
|
6
|
+
|
|
7
|
+
function YStack({ className, ref, ...props }: YStackProps) {
|
|
8
|
+
return (
|
|
9
|
+
<Flex
|
|
10
|
+
className={cn('flex-col', className)}
|
|
11
|
+
data-slot="y-stack"
|
|
12
|
+
ref={ref}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { YStack };
|
|
19
|
+
export type { YStackProps };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { type ComponentType, Fragment, type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
import { Text } from '../Text';
|
|
6
|
+
|
|
7
|
+
type ComponentMatrixCellProps = {
|
|
8
|
+
column: ComponentMatrixColumn;
|
|
9
|
+
row: ComponentMatrixRow;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type ComponentMatrixColumn = {
|
|
13
|
+
description?: string;
|
|
14
|
+
key: string;
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type ComponentMatrixProps = {
|
|
19
|
+
Cell: ComponentType<ComponentMatrixCellProps>;
|
|
20
|
+
cellClassName?: string;
|
|
21
|
+
cellWidth?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
columns: ComponentMatrixColumn[];
|
|
24
|
+
rows: ComponentMatrixRow[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type ComponentMatrixRow = {
|
|
28
|
+
description?: string;
|
|
29
|
+
key: string;
|
|
30
|
+
label: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function Layout({
|
|
34
|
+
children,
|
|
35
|
+
className,
|
|
36
|
+
title,
|
|
37
|
+
}: {
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
className?: string;
|
|
40
|
+
title: string;
|
|
41
|
+
}) {
|
|
42
|
+
return (
|
|
43
|
+
<div className="bg-background text-foreground min-h-screen font-sans">
|
|
44
|
+
<div className={cn('mx-auto px-8 py-12', className)}>
|
|
45
|
+
<header className="mb-12">
|
|
46
|
+
<Text as="h1" variant="h1">
|
|
47
|
+
{title}
|
|
48
|
+
</Text>
|
|
49
|
+
</header>
|
|
50
|
+
<div className="space-y-16">{children}</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function Matrix({
|
|
57
|
+
Cell,
|
|
58
|
+
cellClassName,
|
|
59
|
+
cellWidth = 'minmax(12rem, 1fr)',
|
|
60
|
+
className,
|
|
61
|
+
columns,
|
|
62
|
+
rows,
|
|
63
|
+
}: ComponentMatrixProps) {
|
|
64
|
+
const resolvedCellWidth =
|
|
65
|
+
cellWidth.includes('fr') || cellWidth.includes('minmax(')
|
|
66
|
+
? cellWidth
|
|
67
|
+
: `minmax(${cellWidth}, 1fr)`;
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
className={cn(
|
|
72
|
+
'border-border bg-card/20 overflow-x-auto rounded-md border',
|
|
73
|
+
className,
|
|
74
|
+
)}
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
className="grid min-w-max"
|
|
78
|
+
style={{
|
|
79
|
+
gridTemplateColumns: `12rem repeat(${columns.length}, ${resolvedCellWidth})`,
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
<div className="border-border bg-muted/30 border-r border-b p-3" />
|
|
83
|
+
{columns.map((column, columnIndex) => (
|
|
84
|
+
<div
|
|
85
|
+
className={cn(
|
|
86
|
+
'border-border bg-muted/30 border-b p-3',
|
|
87
|
+
columnIndex < columns.length - 1 && 'border-r',
|
|
88
|
+
)}
|
|
89
|
+
key={column.key}
|
|
90
|
+
>
|
|
91
|
+
<div className="text-foreground text-sm font-medium">
|
|
92
|
+
{column.label}
|
|
93
|
+
</div>
|
|
94
|
+
{column.description ? (
|
|
95
|
+
<div className="text-muted-foreground mt-1 text-xs">
|
|
96
|
+
{column.description}
|
|
97
|
+
</div>
|
|
98
|
+
) : null}
|
|
99
|
+
</div>
|
|
100
|
+
))}
|
|
101
|
+
|
|
102
|
+
{rows.map((row, rowIndex) => (
|
|
103
|
+
<Fragment key={row.key}>
|
|
104
|
+
<div
|
|
105
|
+
className={cn(
|
|
106
|
+
'border-border bg-background/80 border-r p-3',
|
|
107
|
+
rowIndex < rows.length - 1 && 'border-b',
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
<div className="text-foreground text-sm font-medium">
|
|
111
|
+
{row.label}
|
|
112
|
+
</div>
|
|
113
|
+
{row.description ? (
|
|
114
|
+
<div className="text-muted-foreground mt-1 max-w-40 text-xs">
|
|
115
|
+
{row.description}
|
|
116
|
+
</div>
|
|
117
|
+
) : null}
|
|
118
|
+
</div>
|
|
119
|
+
{columns.map((column, columnIndex) => (
|
|
120
|
+
<div
|
|
121
|
+
className={cn(
|
|
122
|
+
'border-border bg-background/55 flex min-h-24 items-center justify-center p-4',
|
|
123
|
+
rowIndex < rows.length - 1 && 'border-b',
|
|
124
|
+
columnIndex < columns.length - 1 && 'border-r',
|
|
125
|
+
cellClassName,
|
|
126
|
+
)}
|
|
127
|
+
key={`${row.key}-${column.key}`}
|
|
128
|
+
>
|
|
129
|
+
<Cell column={column} row={row} />
|
|
130
|
+
</div>
|
|
131
|
+
))}
|
|
132
|
+
</Fragment>
|
|
133
|
+
))}
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function Section({ children, title }: { children: ReactNode; title: string }) {
|
|
140
|
+
return (
|
|
141
|
+
<section>
|
|
142
|
+
<Text as="h2" className="mb-6" variant="h3">
|
|
143
|
+
{title}
|
|
144
|
+
</Text>
|
|
145
|
+
{children}
|
|
146
|
+
</section>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const Story = Object.assign(Layout, {
|
|
151
|
+
Layout,
|
|
152
|
+
Matrix,
|
|
153
|
+
Section,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export { Story };
|
|
157
|
+
export type {
|
|
158
|
+
ComponentMatrixCellProps,
|
|
159
|
+
ComponentMatrixColumn,
|
|
160
|
+
ComponentMatrixRow,
|
|
161
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable react-hooks/refs -- this component intentionally reads prevValueRef.current during render to track the previous value across renders; the ref holds derived bookkeeping state, not render-affecting data. */
|
|
6
|
+
|
|
7
|
+
type InputValue = string | string[];
|
|
8
|
+
|
|
9
|
+
interface VisuallyHiddenInputProps<T = InputValue> extends Omit<
|
|
10
|
+
React.InputHTMLAttributes<HTMLInputElement>,
|
|
11
|
+
'checked' | 'onReset' | 'value'
|
|
12
|
+
> {
|
|
13
|
+
bubbles?: boolean;
|
|
14
|
+
checked?: boolean;
|
|
15
|
+
control: HTMLElement | null;
|
|
16
|
+
value?: T;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function VisuallyHiddenInput<T = InputValue>(
|
|
20
|
+
props: VisuallyHiddenInputProps<T>,
|
|
21
|
+
) {
|
|
22
|
+
const {
|
|
23
|
+
bubbles = true,
|
|
24
|
+
checked,
|
|
25
|
+
control,
|
|
26
|
+
style,
|
|
27
|
+
type = 'hidden',
|
|
28
|
+
value,
|
|
29
|
+
...inputProps
|
|
30
|
+
// react-doctor-disable-next-line react-doctor/no-event-handler -- this hidden input intentionally mirrors value/checked into the native control and dispatches a native input/click event from an effect; the side effect is driven by prop changes, not a user event, so it cannot move into an event handler
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
const isCheckInput = React.useMemo(
|
|
34
|
+
() => type === 'checkbox' || type === 'radio' || type === 'switch',
|
|
35
|
+
[type],
|
|
36
|
+
);
|
|
37
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
38
|
+
|
|
39
|
+
const prevValueRef = React.useRef<{
|
|
40
|
+
previous: boolean | T | undefined;
|
|
41
|
+
value: boolean | T | undefined;
|
|
42
|
+
}>({
|
|
43
|
+
previous: isCheckInput ? checked : value,
|
|
44
|
+
value: isCheckInput ? checked : value,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const prevValue = React.useMemo(() => {
|
|
48
|
+
const currentValue = isCheckInput ? checked : value;
|
|
49
|
+
if (prevValueRef.current.value !== currentValue) {
|
|
50
|
+
prevValueRef.current.previous = prevValueRef.current.value;
|
|
51
|
+
prevValueRef.current.value = currentValue;
|
|
52
|
+
}
|
|
53
|
+
return prevValueRef.current.previous;
|
|
54
|
+
}, [isCheckInput, value, checked]);
|
|
55
|
+
|
|
56
|
+
const [controlSize, setControlSize] = React.useState<{
|
|
57
|
+
height?: number;
|
|
58
|
+
width?: number;
|
|
59
|
+
}>({});
|
|
60
|
+
|
|
61
|
+
// react-doctor-disable-next-line react-doctor/no-cascading-set-state -- this effect measures the control element and only calls setControlSize in mutually exclusive branches (or inside an async ResizeObserver callback), not as a synchronous render cascade
|
|
62
|
+
React.useLayoutEffect(() => {
|
|
63
|
+
if (!control) {
|
|
64
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- reset measured size synchronously when the control is removed so the hidden input does not retain a stale size
|
|
65
|
+
setControlSize({});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setControlSize({
|
|
70
|
+
height: control.offsetHeight,
|
|
71
|
+
width: control.offsetWidth,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (typeof window === 'undefined') return;
|
|
75
|
+
|
|
76
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
77
|
+
if (!Array.isArray(entries) || !entries.length) return;
|
|
78
|
+
|
|
79
|
+
const entry = entries[0];
|
|
80
|
+
if (!entry) return;
|
|
81
|
+
|
|
82
|
+
let width: number;
|
|
83
|
+
let height: number;
|
|
84
|
+
|
|
85
|
+
if ('borderBoxSize' in entry) {
|
|
86
|
+
const borderSizeEntry = entry.borderBoxSize;
|
|
87
|
+
const borderSize = Array.isArray(borderSizeEntry)
|
|
88
|
+
? borderSizeEntry[0]
|
|
89
|
+
: borderSizeEntry;
|
|
90
|
+
width = borderSize.inlineSize;
|
|
91
|
+
height = borderSize.blockSize;
|
|
92
|
+
} else {
|
|
93
|
+
width = control.offsetWidth;
|
|
94
|
+
height = control.offsetHeight;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setControlSize({ height, width });
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
resizeObserver.observe(control, { box: 'border-box' });
|
|
101
|
+
return () => {
|
|
102
|
+
resizeObserver.disconnect();
|
|
103
|
+
};
|
|
104
|
+
}, [control]);
|
|
105
|
+
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
const input = inputRef.current;
|
|
108
|
+
if (!input) return;
|
|
109
|
+
|
|
110
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
111
|
+
const propertyKey = isCheckInput ? 'checked' : 'value';
|
|
112
|
+
const eventType = isCheckInput ? 'click' : 'input';
|
|
113
|
+
const currentValue = isCheckInput ? checked : value;
|
|
114
|
+
|
|
115
|
+
const serializedCurrentValue = isCheckInput
|
|
116
|
+
? checked
|
|
117
|
+
: typeof value === 'object' && value !== null
|
|
118
|
+
? JSON.stringify(value)
|
|
119
|
+
: value;
|
|
120
|
+
|
|
121
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, propertyKey);
|
|
122
|
+
|
|
123
|
+
const setter = descriptor?.set;
|
|
124
|
+
|
|
125
|
+
if (prevValue !== currentValue && setter) {
|
|
126
|
+
const event = new Event(eventType, { bubbles });
|
|
127
|
+
setter.call(input, serializedCurrentValue);
|
|
128
|
+
input.dispatchEvent(event);
|
|
129
|
+
}
|
|
130
|
+
}, [prevValue, value, checked, bubbles, isCheckInput]);
|
|
131
|
+
|
|
132
|
+
const composedStyle = React.useMemo<React.CSSProperties>(() => {
|
|
133
|
+
return {
|
|
134
|
+
...style,
|
|
135
|
+
...(controlSize.width !== undefined && controlSize.height !== undefined
|
|
136
|
+
? controlSize
|
|
137
|
+
: {}),
|
|
138
|
+
border: 0,
|
|
139
|
+
clip: 'rect(0 0 0 0)',
|
|
140
|
+
clipPath: 'inset(50%)',
|
|
141
|
+
height: '1px',
|
|
142
|
+
margin: '-1px',
|
|
143
|
+
overflow: 'hidden',
|
|
144
|
+
padding: 0,
|
|
145
|
+
position: 'absolute',
|
|
146
|
+
whiteSpace: 'nowrap',
|
|
147
|
+
width: '1px',
|
|
148
|
+
};
|
|
149
|
+
}, [style, controlSize]);
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<input
|
|
153
|
+
type={type}
|
|
154
|
+
{...inputProps}
|
|
155
|
+
aria-hidden={isCheckInput}
|
|
156
|
+
defaultChecked={isCheckInput ? checked : undefined}
|
|
157
|
+
ref={inputRef}
|
|
158
|
+
style={composedStyle}
|
|
159
|
+
tabIndex={-1}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { VisuallyHiddenInput };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
import { textVariants } from '../Text';
|
|
6
|
+
|
|
7
|
+
/** Shared look for `Dialog` and `AlertDialog`; not part of the public API. */
|
|
8
|
+
|
|
9
|
+
const dialogBackdropClassName =
|
|
10
|
+
'fixed inset-0 z-50 bg-black/32 backdrop-blur-sm duration-200 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0';
|
|
11
|
+
|
|
12
|
+
const dialogViewportClassName =
|
|
13
|
+
'fixed inset-0 z-50 flex flex-col items-center overflow-y-auto p-4 sm:p-6';
|
|
14
|
+
|
|
15
|
+
const dialogPopupVariants = cva(
|
|
16
|
+
'bg-popover text-popover-foreground relative my-auto flex w-full min-w-0 flex-col gap-4 rounded-2xl border p-6 shadow-lg/5 duration-200 outline-none not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] 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 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]',
|
|
17
|
+
{
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: 'md',
|
|
20
|
+
},
|
|
21
|
+
variants: {
|
|
22
|
+
size: {
|
|
23
|
+
lg: 'max-w-2xl',
|
|
24
|
+
md: 'max-w-lg',
|
|
25
|
+
sm: 'max-w-sm',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const dialogHeaderClassName = 'flex flex-col gap-1.5 text-center sm:text-start';
|
|
32
|
+
|
|
33
|
+
const dialogFooterClassName =
|
|
34
|
+
'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end';
|
|
35
|
+
|
|
36
|
+
const dialogTitleClassName = cn(
|
|
37
|
+
textVariants({ variant: 'h4' }),
|
|
38
|
+
'font-heading leading-snug font-semibold',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const dialogDescriptionClassName = textVariants({
|
|
42
|
+
tone: 'muted',
|
|
43
|
+
variant: 'body',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
type DialogSize = NonNullable<VariantProps<typeof dialogPopupVariants>['size']>;
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
dialogBackdropClassName,
|
|
50
|
+
dialogDescriptionClassName,
|
|
51
|
+
dialogFooterClassName,
|
|
52
|
+
dialogHeaderClassName,
|
|
53
|
+
dialogPopupVariants,
|
|
54
|
+
dialogTitleClassName,
|
|
55
|
+
dialogViewportClassName,
|
|
56
|
+
};
|
|
57
|
+
export type { DialogSize };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { cn } from '@/lib/utils';
|
|
2
|
+
|
|
3
|
+
const alignClasses = {
|
|
4
|
+
baseline: 'items-baseline',
|
|
5
|
+
center: 'items-center',
|
|
6
|
+
end: 'items-end',
|
|
7
|
+
start: 'items-start',
|
|
8
|
+
stretch: 'items-stretch',
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
const gapClasses = {
|
|
12
|
+
0: 'gap-0',
|
|
13
|
+
0.5: 'gap-0.5',
|
|
14
|
+
1: 'gap-1',
|
|
15
|
+
1.5: 'gap-1.5',
|
|
16
|
+
2: 'gap-2',
|
|
17
|
+
2.5: 'gap-2.5',
|
|
18
|
+
3: 'gap-3',
|
|
19
|
+
3.5: 'gap-3.5',
|
|
20
|
+
4: 'gap-4',
|
|
21
|
+
5: 'gap-5',
|
|
22
|
+
6: 'gap-6',
|
|
23
|
+
8: 'gap-8',
|
|
24
|
+
10: 'gap-10',
|
|
25
|
+
12: 'gap-12',
|
|
26
|
+
16: 'gap-16',
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
const gapXClasses = {
|
|
30
|
+
0: 'gap-x-0',
|
|
31
|
+
0.5: 'gap-x-0.5',
|
|
32
|
+
1: 'gap-x-1',
|
|
33
|
+
1.5: 'gap-x-1.5',
|
|
34
|
+
2: 'gap-x-2',
|
|
35
|
+
2.5: 'gap-x-2.5',
|
|
36
|
+
3: 'gap-x-3',
|
|
37
|
+
3.5: 'gap-x-3.5',
|
|
38
|
+
4: 'gap-x-4',
|
|
39
|
+
5: 'gap-x-5',
|
|
40
|
+
6: 'gap-x-6',
|
|
41
|
+
8: 'gap-x-8',
|
|
42
|
+
10: 'gap-x-10',
|
|
43
|
+
12: 'gap-x-12',
|
|
44
|
+
16: 'gap-x-16',
|
|
45
|
+
} as const;
|
|
46
|
+
|
|
47
|
+
const gapYClasses = {
|
|
48
|
+
0: 'gap-y-0',
|
|
49
|
+
0.5: 'gap-y-0.5',
|
|
50
|
+
1: 'gap-y-1',
|
|
51
|
+
1.5: 'gap-y-1.5',
|
|
52
|
+
2: 'gap-y-2',
|
|
53
|
+
2.5: 'gap-y-2.5',
|
|
54
|
+
3: 'gap-y-3',
|
|
55
|
+
3.5: 'gap-y-3.5',
|
|
56
|
+
4: 'gap-y-4',
|
|
57
|
+
5: 'gap-y-5',
|
|
58
|
+
6: 'gap-y-6',
|
|
59
|
+
8: 'gap-y-8',
|
|
60
|
+
10: 'gap-y-10',
|
|
61
|
+
12: 'gap-y-12',
|
|
62
|
+
16: 'gap-y-16',
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
const justifyClasses = {
|
|
66
|
+
around: 'justify-around',
|
|
67
|
+
between: 'justify-between',
|
|
68
|
+
center: 'justify-center',
|
|
69
|
+
end: 'justify-end',
|
|
70
|
+
evenly: 'justify-evenly',
|
|
71
|
+
start: 'justify-start',
|
|
72
|
+
} as const;
|
|
73
|
+
|
|
74
|
+
type LayoutAlign = keyof typeof alignClasses;
|
|
75
|
+
type LayoutGap = keyof typeof gapClasses;
|
|
76
|
+
type LayoutJustify = keyof typeof justifyClasses;
|
|
77
|
+
|
|
78
|
+
type LayoutStyleProps = {
|
|
79
|
+
align?: LayoutAlign;
|
|
80
|
+
gap?: LayoutGap;
|
|
81
|
+
gapX?: LayoutGap;
|
|
82
|
+
gapY?: LayoutGap;
|
|
83
|
+
justify?: LayoutJustify;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
function getLayoutClasses({
|
|
87
|
+
align,
|
|
88
|
+
gap,
|
|
89
|
+
gapX,
|
|
90
|
+
gapY,
|
|
91
|
+
justify,
|
|
92
|
+
}: LayoutStyleProps) {
|
|
93
|
+
return cn(
|
|
94
|
+
align === undefined ? undefined : alignClasses[align],
|
|
95
|
+
gap === undefined ? undefined : gapClasses[gap],
|
|
96
|
+
gapX === undefined ? undefined : gapXClasses[gapX],
|
|
97
|
+
gapY === undefined ? undefined : gapYClasses[gapY],
|
|
98
|
+
justify === undefined ? undefined : justifyClasses[justify],
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { getLayoutClasses };
|
|
103
|
+
export type { LayoutStyleProps };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { type ComponentMatrixCellProps, Story } from '../_internal/Story';
|
|
4
|
+
import { Checkbox, type CheckboxProps } from './Checkbox';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
component: Checkbox,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'fullscreen',
|
|
10
|
+
},
|
|
11
|
+
title: 'components/form/Checkbox',
|
|
12
|
+
} satisfies Meta<typeof Checkbox>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
type CheckboxSize = NonNullable<CheckboxProps['size']>;
|
|
16
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const STATE_COLUMNS: {
|
|
19
|
+
key: string;
|
|
20
|
+
label: string;
|
|
21
|
+
props: Partial<CheckboxProps>;
|
|
22
|
+
}[] = [
|
|
23
|
+
{ key: 'unchecked', label: 'Unchecked', props: {} },
|
|
24
|
+
{ key: 'checked', label: 'Checked', props: { defaultChecked: true } },
|
|
25
|
+
{ key: 'indeterminate', label: 'Mixed', props: { indeterminate: true } },
|
|
26
|
+
{
|
|
27
|
+
key: 'focus',
|
|
28
|
+
label: 'Focus',
|
|
29
|
+
props: { className: 'pseudo-focus-visible', defaultChecked: true },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
key: 'invalid',
|
|
33
|
+
label: 'Invalid',
|
|
34
|
+
props: { 'aria-invalid': true, defaultChecked: true },
|
|
35
|
+
},
|
|
36
|
+
{ key: 'disabled', label: 'Disabled', props: { disabled: true } },
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const SIZE_ROWS: {
|
|
40
|
+
key: CheckboxSize;
|
|
41
|
+
label: string;
|
|
42
|
+
}[] = [
|
|
43
|
+
{ key: 'md', label: 'Medium' },
|
|
44
|
+
{ key: 'sm', label: 'Small' },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const STATE_PROPS = Object.fromEntries(
|
|
48
|
+
STATE_COLUMNS.map((state) => [state.key, state.props]),
|
|
49
|
+
) as Record<string, Partial<CheckboxProps>>;
|
|
50
|
+
|
|
51
|
+
function CheckboxStateCell({ column, row }: ComponentMatrixCellProps) {
|
|
52
|
+
return (
|
|
53
|
+
<Checkbox
|
|
54
|
+
aria-label={`${row.label} ${column.label}`}
|
|
55
|
+
size={row.key as CheckboxSize}
|
|
56
|
+
{...STATE_PROPS[column.key]}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const All: StoryDefinition = {
|
|
62
|
+
render: () => (
|
|
63
|
+
<Story.Layout className="max-w-5xl" title="Checkbox">
|
|
64
|
+
<Story.Section title="Sizes and states">
|
|
65
|
+
<Story.Matrix
|
|
66
|
+
Cell={CheckboxStateCell}
|
|
67
|
+
cellWidth="8rem"
|
|
68
|
+
columns={STATE_COLUMNS}
|
|
69
|
+
rows={SIZE_ROWS}
|
|
70
|
+
/>
|
|
71
|
+
</Story.Section>
|
|
72
|
+
|
|
73
|
+
<Story.Section title="Label">
|
|
74
|
+
<Checkbox id="story-checkbox-label" label="Accept terms" />
|
|
75
|
+
</Story.Section>
|
|
76
|
+
</Story.Layout>
|
|
77
|
+
),
|
|
78
|
+
};
|