@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,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useController } from 'react-hook-form';
|
|
4
|
+
|
|
5
|
+
import { Checkbox, type CheckboxProps } from '@/components/form/Checkbox';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
useFormControlProps,
|
|
9
|
+
useFormMethods,
|
|
10
|
+
useRequiredFieldName,
|
|
11
|
+
type WithoutAriaInvalid,
|
|
12
|
+
} from './Form.context';
|
|
13
|
+
|
|
14
|
+
type FormCheckboxProps = WithoutAriaInvalid<CheckboxProps>;
|
|
15
|
+
|
|
16
|
+
function FormCheckboxRoot({
|
|
17
|
+
id: idProp,
|
|
18
|
+
name: nameProp,
|
|
19
|
+
...props
|
|
20
|
+
}: FormCheckboxProps) {
|
|
21
|
+
const { control } = useFormMethods();
|
|
22
|
+
const name = useRequiredFieldName(nameProp, 'Form.Checkbox');
|
|
23
|
+
const { field } = useController({
|
|
24
|
+
control,
|
|
25
|
+
defaultValue: props.defaultChecked ?? false,
|
|
26
|
+
name,
|
|
27
|
+
});
|
|
28
|
+
const controlProps = useFormControlProps({ id: idProp });
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Checkbox
|
|
32
|
+
{...props}
|
|
33
|
+
{...controlProps}
|
|
34
|
+
checked={Boolean(field.value)}
|
|
35
|
+
inputRef={field.ref}
|
|
36
|
+
name={field.name}
|
|
37
|
+
onCheckedChange={(checked, eventDetails) => {
|
|
38
|
+
field.onChange(checked);
|
|
39
|
+
props.onCheckedChange?.(checked, eventDetails);
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const FormCheckbox = Object.assign(FormCheckboxRoot, {
|
|
46
|
+
Label: Checkbox.Label,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export { FormCheckbox, FormCheckboxRoot };
|
|
50
|
+
export type { FormCheckboxProps };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useController } from 'react-hook-form';
|
|
5
|
+
|
|
6
|
+
import { Combobox, type ComboboxProps } from './Combobox';
|
|
7
|
+
import {
|
|
8
|
+
useFormControlProps,
|
|
9
|
+
useFormMethods,
|
|
10
|
+
useRequiredFieldName,
|
|
11
|
+
type WithoutAriaInvalid,
|
|
12
|
+
} from './Form.context';
|
|
13
|
+
|
|
14
|
+
// Stable fallback so an unset multiple value keeps the same identity.
|
|
15
|
+
const EMPTY_VALUE: never[] = [];
|
|
16
|
+
|
|
17
|
+
type FormComboboxProps<
|
|
18
|
+
Value,
|
|
19
|
+
Multiple extends boolean | undefined = false,
|
|
20
|
+
> = WithoutAriaInvalid<ComboboxProps<Value, Multiple>>;
|
|
21
|
+
|
|
22
|
+
function FormComboboxChipsInput({
|
|
23
|
+
id: idProp,
|
|
24
|
+
...props
|
|
25
|
+
}: WithoutAriaInvalid<React.ComponentProps<typeof Combobox.ChipsInput>>) {
|
|
26
|
+
const controlProps = useFormControlProps({ id: idProp });
|
|
27
|
+
|
|
28
|
+
return <Combobox.ChipsInput {...props} {...controlProps} />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function FormComboboxInput({
|
|
32
|
+
id: idProp,
|
|
33
|
+
...props
|
|
34
|
+
}: WithoutAriaInvalid<React.ComponentProps<typeof Combobox.Input>>) {
|
|
35
|
+
const controlProps = useFormControlProps({ id: idProp });
|
|
36
|
+
|
|
37
|
+
return <Combobox.Input {...props} {...controlProps} />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function FormComboboxRoot<Value, Multiple extends boolean | undefined = false>({
|
|
41
|
+
name: nameProp,
|
|
42
|
+
...props
|
|
43
|
+
}: FormComboboxProps<Value, Multiple>) {
|
|
44
|
+
const { control } = useFormMethods();
|
|
45
|
+
const name = useRequiredFieldName(nameProp, 'Form.Combobox');
|
|
46
|
+
const { field } = useController({
|
|
47
|
+
control,
|
|
48
|
+
defaultValue: props.defaultValue,
|
|
49
|
+
name,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Combobox<Value, Multiple>
|
|
54
|
+
{...props}
|
|
55
|
+
inputRef={field.ref}
|
|
56
|
+
name={field.name}
|
|
57
|
+
onValueChange={(value, eventDetails) => {
|
|
58
|
+
field.onChange(value);
|
|
59
|
+
props.onValueChange?.(value, eventDetails);
|
|
60
|
+
}}
|
|
61
|
+
// Keep the combobox controlled while the form value is still unset.
|
|
62
|
+
value={field.value ?? (props.multiple ? EMPTY_VALUE : null)}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const FormCombobox = Object.assign(FormComboboxRoot, {
|
|
68
|
+
Chip: Combobox.Chip,
|
|
69
|
+
Chips: Combobox.Chips,
|
|
70
|
+
ChipsInput: FormComboboxChipsInput,
|
|
71
|
+
Clear: Combobox.Clear,
|
|
72
|
+
Collection: Combobox.Collection,
|
|
73
|
+
Content: Combobox.Content,
|
|
74
|
+
Empty: Combobox.Empty,
|
|
75
|
+
Group: Combobox.Group,
|
|
76
|
+
GroupLabel: Combobox.GroupLabel,
|
|
77
|
+
Input: FormComboboxInput,
|
|
78
|
+
Item: Combobox.Item,
|
|
79
|
+
List: Combobox.List,
|
|
80
|
+
Separator: Combobox.Separator,
|
|
81
|
+
Status: Combobox.Status,
|
|
82
|
+
Trigger: Combobox.Trigger,
|
|
83
|
+
Value: Combobox.Value,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
FormCombobox,
|
|
88
|
+
FormComboboxChipsInput,
|
|
89
|
+
FormComboboxInput,
|
|
90
|
+
FormComboboxRoot,
|
|
91
|
+
};
|
|
92
|
+
export type { FormComboboxProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Field } from '@base-ui/react/field';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
type FormDescriptionProps = React.ComponentProps<typeof Field.Description>;
|
|
9
|
+
|
|
10
|
+
function FormDescription({ className, ...props }: FormDescriptionProps) {
|
|
11
|
+
return (
|
|
12
|
+
<Field.Description
|
|
13
|
+
className={cn('text-muted-foreground text-sm', className)}
|
|
14
|
+
data-slot="field-description"
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { FormDescription };
|
|
21
|
+
export type { FormDescriptionProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Field } from '@base-ui/react/field';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
type FormErrorProps = React.ComponentProps<typeof Field.Error>;
|
|
9
|
+
|
|
10
|
+
function FormError({ className, ...props }: FormErrorProps) {
|
|
11
|
+
return (
|
|
12
|
+
<Field.Error
|
|
13
|
+
className={cn('text-destructive text-sm font-medium', className)}
|
|
14
|
+
data-slot="field-error"
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { FormError };
|
|
21
|
+
export type { FormErrorProps };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Field } from '@base-ui/react/field';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useFormState } from 'react-hook-form';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/lib/utils';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
FormFieldContext,
|
|
11
|
+
getErrorMessage,
|
|
12
|
+
useFormMethods,
|
|
13
|
+
} from './Form.context';
|
|
14
|
+
import { FormDescription } from './FormDescription';
|
|
15
|
+
import { FormError } from './FormError';
|
|
16
|
+
import { FormLabel } from './FormLabel';
|
|
17
|
+
import { type FormRadioGroupProps, FormRadioGroupRoot } from './FormRadioGroup';
|
|
18
|
+
import { type FormSelectProps, FormSelectRoot } from './FormSelect';
|
|
19
|
+
|
|
20
|
+
type FormFieldProps = Omit<
|
|
21
|
+
React.ComponentProps<typeof Field.Root>,
|
|
22
|
+
'children'
|
|
23
|
+
> & {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
controlId?: string;
|
|
26
|
+
description?: React.ReactNode;
|
|
27
|
+
error?: React.ReactNode;
|
|
28
|
+
label?: React.ReactNode;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function FormField({
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
controlId: controlIdProp,
|
|
35
|
+
description,
|
|
36
|
+
error,
|
|
37
|
+
label,
|
|
38
|
+
...props
|
|
39
|
+
}: FormFieldProps) {
|
|
40
|
+
const { control, getFieldState } = useFormMethods();
|
|
41
|
+
const name = props.name;
|
|
42
|
+
const formState = useFormState({
|
|
43
|
+
control,
|
|
44
|
+
disabled: !name,
|
|
45
|
+
exact: true,
|
|
46
|
+
name,
|
|
47
|
+
});
|
|
48
|
+
const fieldError = name ? getFieldState(name, formState).error : undefined;
|
|
49
|
+
const errorMessage = error ?? getErrorMessage(fieldError);
|
|
50
|
+
// The control id is the focus target for the visible field label.
|
|
51
|
+
// It is generated by default to avoid duplicate DOM ids across forms/rows.
|
|
52
|
+
const generatedControlId = React.useId();
|
|
53
|
+
const controlId = controlIdProp ?? generatedControlId;
|
|
54
|
+
const nativeLabel = shouldUseNativeFieldLabel(children);
|
|
55
|
+
const contextValue = React.useMemo(
|
|
56
|
+
() => ({
|
|
57
|
+
controlId,
|
|
58
|
+
name,
|
|
59
|
+
}),
|
|
60
|
+
[controlId, name],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Field.Root
|
|
65
|
+
className={cn('grid gap-2.5', className)}
|
|
66
|
+
data-slot="field"
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
{/* Native inputs use htmlFor/id for label focus; Base UI composites
|
|
70
|
+
use non-native labels so their primitives can wire aria-labelledby. */}
|
|
71
|
+
{label && nativeLabel ? (
|
|
72
|
+
<FormLabel htmlFor={controlId}>{label}</FormLabel>
|
|
73
|
+
) : label ? (
|
|
74
|
+
<FormLabel nativeLabel={false} render={<span />}>
|
|
75
|
+
{label}
|
|
76
|
+
</FormLabel>
|
|
77
|
+
) : null}
|
|
78
|
+
<FormFieldContext.Provider value={contextValue}>
|
|
79
|
+
{children}
|
|
80
|
+
</FormFieldContext.Provider>
|
|
81
|
+
{errorMessage ? (
|
|
82
|
+
<FormError match>{errorMessage}</FormError>
|
|
83
|
+
) : description ? (
|
|
84
|
+
<FormDescription>{description}</FormDescription>
|
|
85
|
+
) : null}
|
|
86
|
+
</Field.Root>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function isFormRadioGroupElement(
|
|
91
|
+
child: React.ReactNode,
|
|
92
|
+
): child is React.ReactElement<FormRadioGroupProps> {
|
|
93
|
+
return React.isValidElement(child) && child.type === FormRadioGroupRoot;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isFormSelectElement(
|
|
97
|
+
child: React.ReactNode,
|
|
98
|
+
): child is React.ReactElement<FormSelectProps> {
|
|
99
|
+
return React.isValidElement(child) && child.type === FormSelectRoot;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function shouldUseNativeFieldLabel(children: React.ReactNode) {
|
|
103
|
+
return !React.Children.toArray(children).some(
|
|
104
|
+
(child) => isFormRadioGroupElement(child) || isFormSelectElement(child),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { FormField };
|
|
109
|
+
export type { FormFieldProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Input } from '@/components/form/Input';
|
|
6
|
+
import { InputGroupInput } from '@/components/form/InputGroup';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
FormInputGroupContext,
|
|
10
|
+
useFormControlProps,
|
|
11
|
+
useFormMethods,
|
|
12
|
+
useRequiredFieldName,
|
|
13
|
+
type WithoutAriaInvalid,
|
|
14
|
+
} from './Form.context';
|
|
15
|
+
|
|
16
|
+
type FormInputProps = WithoutAriaInvalid<React.ComponentProps<typeof Input>>;
|
|
17
|
+
|
|
18
|
+
function FormInput({ id: idProp, name: nameProp, ...props }: FormInputProps) {
|
|
19
|
+
const isInsideInputGroup = React.useContext(FormInputGroupContext);
|
|
20
|
+
const name = useRequiredFieldName(nameProp, 'Form.Input');
|
|
21
|
+
const methods = useFormMethods();
|
|
22
|
+
const registeredProps = methods.register(name);
|
|
23
|
+
const controlProps = useFormControlProps(
|
|
24
|
+
{ id: idProp },
|
|
25
|
+
{ enabled: !isInsideInputGroup },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const InputComponent = isInsideInputGroup ? InputGroupInput : Input;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<InputComponent
|
|
32
|
+
{...props}
|
|
33
|
+
{...registeredProps}
|
|
34
|
+
{...controlProps}
|
|
35
|
+
name={name}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { FormInput };
|
|
41
|
+
export type { FormInputProps };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import { InputGroup } from '@/components/form/InputGroup';
|
|
6
|
+
|
|
7
|
+
import { FormFieldContext, FormInputGroupContext } from './Form.context';
|
|
8
|
+
import { FormInput, type FormInputProps } from './FormInput';
|
|
9
|
+
|
|
10
|
+
type FormInputGroupProps = React.ComponentProps<typeof InputGroup>;
|
|
11
|
+
|
|
12
|
+
function FormInputGroup({ children, ...props }: FormInputGroupProps) {
|
|
13
|
+
const field = React.useContext(FormFieldContext);
|
|
14
|
+
const childArray = React.Children.toArray(children);
|
|
15
|
+
const controlIndex = field?.controlId
|
|
16
|
+
? childArray.findIndex(isFormInputElement)
|
|
17
|
+
: -1;
|
|
18
|
+
const controlChildren = childArray.map((child, index) => {
|
|
19
|
+
if (
|
|
20
|
+
index === controlIndex &&
|
|
21
|
+
field?.controlId &&
|
|
22
|
+
isFormInputElement(child)
|
|
23
|
+
) {
|
|
24
|
+
// A group-level label should focus the first input in the group.
|
|
25
|
+
return React.cloneElement(child, {
|
|
26
|
+
id: field.controlId,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return child;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<FormInputGroupContext.Provider value>
|
|
35
|
+
<InputGroup {...props}>{controlChildren}</InputGroup>
|
|
36
|
+
</FormInputGroupContext.Provider>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isFormInputElement(
|
|
41
|
+
child: React.ReactNode,
|
|
42
|
+
): child is React.ReactElement<FormInputProps> {
|
|
43
|
+
return React.isValidElement(child) && child.type === FormInput;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { FormInputGroup };
|
|
47
|
+
export type { FormInputGroupProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Field } from '@base-ui/react/field';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
type FormLabelProps = React.ComponentProps<typeof Field.Label>;
|
|
9
|
+
|
|
10
|
+
function FormLabel({ className, ...props }: FormLabelProps) {
|
|
11
|
+
return (
|
|
12
|
+
<Field.Label
|
|
13
|
+
className={cn(
|
|
14
|
+
'text-sm leading-none font-medium data-disabled:cursor-not-allowed data-disabled:opacity-50',
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
data-slot="field-label"
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { FormLabel };
|
|
24
|
+
export type { FormLabelProps };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useController } from 'react-hook-form';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
useFormControlProps,
|
|
7
|
+
useFormMethods,
|
|
8
|
+
useRequiredFieldName,
|
|
9
|
+
type WithoutAriaInvalid,
|
|
10
|
+
} from './Form.context';
|
|
11
|
+
import { RadioGroup, type RadioGroupProps } from './RadioGroup';
|
|
12
|
+
|
|
13
|
+
type FormRadioGroupProps = WithoutAriaInvalid<RadioGroupProps>;
|
|
14
|
+
|
|
15
|
+
function FormRadioGroupRoot({ name: nameProp, ...props }: FormRadioGroupProps) {
|
|
16
|
+
const { id: idProp, ...radioGroupProps } = props;
|
|
17
|
+
const { control } = useFormMethods();
|
|
18
|
+
const name = useRequiredFieldName(nameProp, 'Form.RadioGroup');
|
|
19
|
+
const { field } = useController({
|
|
20
|
+
control,
|
|
21
|
+
defaultValue: radioGroupProps.defaultValue,
|
|
22
|
+
name,
|
|
23
|
+
});
|
|
24
|
+
const controlProps = useFormControlProps({ id: idProp });
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<RadioGroup
|
|
28
|
+
{...radioGroupProps}
|
|
29
|
+
{...controlProps}
|
|
30
|
+
inputRef={field.ref}
|
|
31
|
+
name={field.name}
|
|
32
|
+
onValueChange={(value, eventDetails) => {
|
|
33
|
+
field.onChange(value);
|
|
34
|
+
radioGroupProps.onValueChange?.(value, eventDetails);
|
|
35
|
+
}}
|
|
36
|
+
value={field.value}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const FormRadioGroup = Object.assign(FormRadioGroupRoot, {
|
|
42
|
+
Item: RadioGroup.Item,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export { FormRadioGroup, FormRadioGroupRoot };
|
|
46
|
+
export type { FormRadioGroupProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import {
|
|
5
|
+
type FieldValues,
|
|
6
|
+
FormProvider,
|
|
7
|
+
type SubmitHandler,
|
|
8
|
+
type UseFormReturn,
|
|
9
|
+
} from 'react-hook-form';
|
|
10
|
+
|
|
11
|
+
import { cn } from '@/lib/utils';
|
|
12
|
+
|
|
13
|
+
type FormProps<FormValues extends FieldValues = FieldValues> = Omit<
|
|
14
|
+
React.ComponentProps<'form'>,
|
|
15
|
+
'onSubmit'
|
|
16
|
+
> & {
|
|
17
|
+
form: UseFormReturn<FormValues>;
|
|
18
|
+
onSubmit?: SubmitHandler<FormValues>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function FormRoot<FormValues extends FieldValues = FieldValues>({
|
|
22
|
+
className,
|
|
23
|
+
form,
|
|
24
|
+
onSubmit,
|
|
25
|
+
...props
|
|
26
|
+
}: FormProps<FormValues>) {
|
|
27
|
+
const content = (
|
|
28
|
+
<form
|
|
29
|
+
className={cn('space-y-6', className)}
|
|
30
|
+
data-slot="form"
|
|
31
|
+
noValidate
|
|
32
|
+
onSubmit={onSubmit ? form.handleSubmit(onSubmit) : undefined}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return <FormProvider {...form}>{content}</FormProvider>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { FormRoot };
|
|
41
|
+
export type { FormProps };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useController } from 'react-hook-form';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
useFormControlProps,
|
|
8
|
+
useFormMethods,
|
|
9
|
+
useRequiredFieldName,
|
|
10
|
+
type WithoutAriaInvalid,
|
|
11
|
+
} from './Form.context';
|
|
12
|
+
import { Select, type SelectProps } from './Select';
|
|
13
|
+
|
|
14
|
+
type FormSelectProps = WithoutAriaInvalid<SelectProps>;
|
|
15
|
+
|
|
16
|
+
function FormSelectRoot({ name: nameProp, ...props }: FormSelectProps) {
|
|
17
|
+
const { control } = useFormMethods();
|
|
18
|
+
const name = useRequiredFieldName(nameProp, 'Form.Select');
|
|
19
|
+
const { field } = useController({
|
|
20
|
+
control,
|
|
21
|
+
defaultValue: props.defaultValue,
|
|
22
|
+
name,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Select
|
|
27
|
+
{...props}
|
|
28
|
+
inputRef={field.ref}
|
|
29
|
+
name={field.name}
|
|
30
|
+
onValueChange={(value, eventDetails) => {
|
|
31
|
+
field.onChange(value);
|
|
32
|
+
props.onValueChange?.(value, eventDetails);
|
|
33
|
+
}}
|
|
34
|
+
value={field.value}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function FormSelectTrigger({
|
|
40
|
+
id: idProp,
|
|
41
|
+
...props
|
|
42
|
+
}: WithoutAriaInvalid<React.ComponentProps<typeof Select.Trigger>>) {
|
|
43
|
+
const controlProps = useFormControlProps({ id: idProp });
|
|
44
|
+
|
|
45
|
+
return <Select.Trigger {...props} {...controlProps} />;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const FormSelect = Object.assign(FormSelectRoot, {
|
|
49
|
+
Content: Select.Content,
|
|
50
|
+
Group: Select.Group,
|
|
51
|
+
GroupLabel: Select.GroupLabel,
|
|
52
|
+
Item: Select.Item,
|
|
53
|
+
Label: Select.Label,
|
|
54
|
+
Separator: Select.Separator,
|
|
55
|
+
Trigger: FormSelectTrigger,
|
|
56
|
+
Value: Select.Value,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export { FormSelect, FormSelectRoot, FormSelectTrigger };
|
|
60
|
+
export type { FormSelectProps };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useController } from 'react-hook-form';
|
|
4
|
+
|
|
5
|
+
import { Switch, type SwitchProps } from '@/components/form/Switch';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
useFormControlProps,
|
|
9
|
+
useFormMethods,
|
|
10
|
+
useRequiredFieldName,
|
|
11
|
+
type WithoutAriaInvalid,
|
|
12
|
+
} from './Form.context';
|
|
13
|
+
|
|
14
|
+
type FormSwitchProps = WithoutAriaInvalid<SwitchProps>;
|
|
15
|
+
|
|
16
|
+
function FormSwitchRoot({
|
|
17
|
+
id: idProp,
|
|
18
|
+
name: nameProp,
|
|
19
|
+
...props
|
|
20
|
+
}: FormSwitchProps) {
|
|
21
|
+
const { control } = useFormMethods();
|
|
22
|
+
const name = useRequiredFieldName(nameProp, 'Form.Switch');
|
|
23
|
+
const { field } = useController({
|
|
24
|
+
control,
|
|
25
|
+
defaultValue: props.defaultChecked ?? false,
|
|
26
|
+
name,
|
|
27
|
+
});
|
|
28
|
+
const controlProps = useFormControlProps({ id: idProp });
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Switch
|
|
32
|
+
{...props}
|
|
33
|
+
{...controlProps}
|
|
34
|
+
checked={Boolean(field.value)}
|
|
35
|
+
inputRef={field.ref}
|
|
36
|
+
name={field.name}
|
|
37
|
+
onCheckedChange={(checked, eventDetails) => {
|
|
38
|
+
field.onChange(checked);
|
|
39
|
+
props.onCheckedChange?.(checked, eventDetails);
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const FormSwitch = Object.assign(FormSwitchRoot, {
|
|
46
|
+
Label: Switch.Label,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export { FormSwitch, FormSwitchRoot };
|
|
50
|
+
export type { FormSwitchProps };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Textarea } from '@/components/form/Textarea';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
useFormControlProps,
|
|
9
|
+
useFormMethods,
|
|
10
|
+
useRequiredFieldName,
|
|
11
|
+
type WithoutAriaInvalid,
|
|
12
|
+
} from './Form.context';
|
|
13
|
+
|
|
14
|
+
type FormTextareaProps = WithoutAriaInvalid<
|
|
15
|
+
React.ComponentProps<typeof Textarea>
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
function FormTextarea({
|
|
19
|
+
id: idProp,
|
|
20
|
+
name: nameProp,
|
|
21
|
+
...props
|
|
22
|
+
}: FormTextareaProps) {
|
|
23
|
+
const name = useRequiredFieldName(nameProp, 'Form.Textarea');
|
|
24
|
+
const methods = useFormMethods();
|
|
25
|
+
const registeredProps = methods.register(name);
|
|
26
|
+
const controlProps = useFormControlProps({ id: idProp });
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Textarea {...props} {...registeredProps} {...controlProps} name={name} />
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { FormTextarea };
|
|
34
|
+
export type { FormTextareaProps };
|