@pickle-ui/react 0.0.0-stage → 1.0.0-beta.3
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,114 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { type ComponentMatrixCellProps, Story } from '../_internal/Story';
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { XStack } from '../XStack';
|
|
6
|
+
import { Input } from './Input';
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
component: Input,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'fullscreen',
|
|
12
|
+
},
|
|
13
|
+
title: 'components/form/Input',
|
|
14
|
+
} satisfies Meta<typeof Input>;
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
const STATE_COLUMNS = [
|
|
20
|
+
{ key: 'empty', label: 'Empty' },
|
|
21
|
+
{ key: 'filled', label: 'Filled' },
|
|
22
|
+
{ key: 'focus', label: 'Focus' },
|
|
23
|
+
{ key: 'disabled', label: 'Disabled' },
|
|
24
|
+
{ key: 'invalid', label: 'Invalid' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const TYPE_ROWS = [
|
|
28
|
+
{ description: 'General text input', key: 'text', label: 'Text' },
|
|
29
|
+
{ description: 'Keyboard hint for email', key: 'email', label: 'Email' },
|
|
30
|
+
{ description: 'Masked text entry', key: 'password', label: 'Password' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
function InputMatrixCell({ column, row }: ComponentMatrixCellProps) {
|
|
34
|
+
const isInvalid = column.key === 'invalid';
|
|
35
|
+
const input = (
|
|
36
|
+
<Input
|
|
37
|
+
aria-invalid={isInvalid || undefined}
|
|
38
|
+
aria-label={`${row.label} ${column.label}`}
|
|
39
|
+
defaultValue={
|
|
40
|
+
column.key === 'filled' || column.key === 'focus'
|
|
41
|
+
? row.key === 'email'
|
|
42
|
+
? 'hello@pickle.dev'
|
|
43
|
+
: 'Pickle UI'
|
|
44
|
+
: undefined
|
|
45
|
+
}
|
|
46
|
+
disabled={column.key === 'disabled'}
|
|
47
|
+
placeholder={isInvalid ? 'Check this value' : row.label}
|
|
48
|
+
type={row.key}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
// The focus ring is styled on the wrapper via :has(:focus-visible), so the
|
|
53
|
+
// pseudo-state class goes on an ancestor to reach the inner <input>.
|
|
54
|
+
return column.key === 'focus' ? (
|
|
55
|
+
<div className="pseudo-focus-visible-all w-full">{input}</div>
|
|
56
|
+
) : (
|
|
57
|
+
input
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const SIZE_COLUMNS = [
|
|
62
|
+
{ key: 'sm', label: 'Small' },
|
|
63
|
+
{ key: 'md', label: 'Medium' },
|
|
64
|
+
{ key: 'lg', label: 'Large' },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
function InputSizeCell({ column }: ComponentMatrixCellProps) {
|
|
68
|
+
const size = column.key as 'lg' | 'md' | 'sm';
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<XStack className="w-full gap-2">
|
|
72
|
+
<Input
|
|
73
|
+
aria-label={`${column.label} email`}
|
|
74
|
+
placeholder="Email"
|
|
75
|
+
size={size}
|
|
76
|
+
/>
|
|
77
|
+
<Button size={size} variant="outline">
|
|
78
|
+
Subscribe
|
|
79
|
+
</Button>
|
|
80
|
+
</XStack>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const All: StoryDefinition = {
|
|
85
|
+
render: () => (
|
|
86
|
+
<Story.Layout className="max-w-6xl" title="Input">
|
|
87
|
+
<Story.Section title="Types and states">
|
|
88
|
+
<Story.Matrix
|
|
89
|
+
Cell={InputMatrixCell}
|
|
90
|
+
cellClassName="justify-stretch"
|
|
91
|
+
cellWidth="16rem"
|
|
92
|
+
columns={STATE_COLUMNS}
|
|
93
|
+
rows={TYPE_ROWS}
|
|
94
|
+
/>
|
|
95
|
+
</Story.Section>
|
|
96
|
+
|
|
97
|
+
<Story.Section title="Sizes">
|
|
98
|
+
<Story.Matrix
|
|
99
|
+
Cell={InputSizeCell}
|
|
100
|
+
cellClassName="justify-stretch"
|
|
101
|
+
cellWidth="20rem"
|
|
102
|
+
columns={SIZE_COLUMNS}
|
|
103
|
+
rows={[
|
|
104
|
+
{
|
|
105
|
+
description: 'Matches the Button of the same size',
|
|
106
|
+
key: 'with-button',
|
|
107
|
+
label: 'With button',
|
|
108
|
+
},
|
|
109
|
+
]}
|
|
110
|
+
/>
|
|
111
|
+
</Story.Section>
|
|
112
|
+
</Story.Layout>
|
|
113
|
+
),
|
|
114
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { Input } from './Input';
|
|
6
|
+
|
|
7
|
+
const heightClasses = (element: Element) =>
|
|
8
|
+
[...element.classList].filter((name) => /^(sm:)?h-/.test(name)).sort();
|
|
9
|
+
|
|
10
|
+
describe('Input', () => {
|
|
11
|
+
it.each(['sm', 'md', 'lg'] as const)(
|
|
12
|
+
'matches the Button height at size %s',
|
|
13
|
+
(size) => {
|
|
14
|
+
const { container } = render(
|
|
15
|
+
<>
|
|
16
|
+
<Input aria-label="Email" size={size} />
|
|
17
|
+
<Button size={size}>Submit</Button>
|
|
18
|
+
</>,
|
|
19
|
+
);
|
|
20
|
+
const control = container.querySelector('[data-slot="input-control"]')!;
|
|
21
|
+
const unstyled = render(
|
|
22
|
+
<Input aria-label="Name" size={size} unstyled />,
|
|
23
|
+
).getByRole('textbox', { name: 'Name' });
|
|
24
|
+
const button = screen.getByRole('button', { name: 'Submit' });
|
|
25
|
+
|
|
26
|
+
expect(heightClasses(control)).toEqual(heightClasses(button));
|
|
27
|
+
expect(heightClasses(unstyled)).toEqual(heightClasses(button));
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
it('styles the control wrapper with className and the input with classNames.input', () => {
|
|
32
|
+
const { container } = render(
|
|
33
|
+
<Input
|
|
34
|
+
aria-label="Email"
|
|
35
|
+
className="control-x"
|
|
36
|
+
classNames={{ input: 'input-x' }}
|
|
37
|
+
/>,
|
|
38
|
+
);
|
|
39
|
+
expect(container.querySelector('[data-slot="input-control"]')).toHaveClass(
|
|
40
|
+
'control-x',
|
|
41
|
+
);
|
|
42
|
+
expect(screen.getByRole('textbox', { name: 'Email' })).toHaveClass(
|
|
43
|
+
'input-x',
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('exposes the resolved size on the control wrapper', () => {
|
|
48
|
+
const { container } = render(
|
|
49
|
+
<>
|
|
50
|
+
<Input aria-label="Default" />
|
|
51
|
+
<Input aria-label="Small" size="sm" />
|
|
52
|
+
<Input aria-label="Numeric" size={20} />
|
|
53
|
+
</>,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(
|
|
57
|
+
[...container.querySelectorAll('[data-slot="input-control"]')].map(
|
|
58
|
+
(control) => control.getAttribute('data-size'),
|
|
59
|
+
),
|
|
60
|
+
).toEqual(['md', 'sm', 'md']);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Input as InputPrimitive } from '@base-ui/react/input';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn, type SlotClassNames } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
// Matches the `Button` height for the same size, so they line up side by side.
|
|
9
|
+
const inputControlHeights = {
|
|
10
|
+
lg: 'h-9',
|
|
11
|
+
md: 'h-8',
|
|
12
|
+
sm: 'h-7',
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
type InputProps = Omit<
|
|
16
|
+
InputPrimitive.Props & React.RefAttributes<HTMLInputElement>,
|
|
17
|
+
'size'
|
|
18
|
+
> & {
|
|
19
|
+
/** Class overrides for the inner `input`; `className` styles the control wrapper. */
|
|
20
|
+
classNames?: SlotClassNames<'input'>;
|
|
21
|
+
nativeInput?: boolean;
|
|
22
|
+
size?: 'lg' | 'md' | 'sm' | number;
|
|
23
|
+
unstyled?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function Input({
|
|
27
|
+
className,
|
|
28
|
+
classNames,
|
|
29
|
+
nativeInput = false,
|
|
30
|
+
size = 'md',
|
|
31
|
+
style,
|
|
32
|
+
unstyled = false,
|
|
33
|
+
...props
|
|
34
|
+
}: InputProps) {
|
|
35
|
+
const resolvedSize = typeof size === 'number' ? 'md' : size;
|
|
36
|
+
const inputClassName = cn(
|
|
37
|
+
unstyled
|
|
38
|
+
? cn(
|
|
39
|
+
'w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-none outline-none [transition:background-color_5000000s_ease-in-out_0s] placeholder:text-muted-foreground/72',
|
|
40
|
+
inputControlHeights[resolvedSize],
|
|
41
|
+
resolvedSize === 'sm' && 'px-[calc(--spacing(2.5)-1px)]',
|
|
42
|
+
resolvedSize === 'lg' && 'px-[calc(--spacing(3.5)-1px)]',
|
|
43
|
+
)
|
|
44
|
+
: cn(
|
|
45
|
+
'h-full min-h-0 w-full rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-none outline-none [transition:background-color_5000000s_ease-in-out_0s] placeholder:text-muted-foreground/72',
|
|
46
|
+
resolvedSize === 'sm' && 'px-[calc(--spacing(2.5)-1px)]',
|
|
47
|
+
resolvedSize === 'lg' && 'px-[calc(--spacing(3.5)-1px)]',
|
|
48
|
+
),
|
|
49
|
+
props.type === 'search' &&
|
|
50
|
+
'[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none',
|
|
51
|
+
props.type === 'file' &&
|
|
52
|
+
'text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm',
|
|
53
|
+
classNames?.input,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<span
|
|
58
|
+
className={
|
|
59
|
+
cn(
|
|
60
|
+
!unstyled &&
|
|
61
|
+
cn(
|
|
62
|
+
inputControlHeights[resolvedSize],
|
|
63
|
+
'border-input bg-background text-foreground ring-ring/24 has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-autofill:bg-foreground/4 dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-aria-invalid:ring-destructive/24 relative inline-flex w-full rounded-lg border text-base shadow-xs/5 transition-shadow not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:ring-[3px] has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none sm:text-sm dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]',
|
|
64
|
+
),
|
|
65
|
+
className,
|
|
66
|
+
) || undefined
|
|
67
|
+
}
|
|
68
|
+
data-size={resolvedSize}
|
|
69
|
+
data-slot="input-control"
|
|
70
|
+
>
|
|
71
|
+
{nativeInput ? (
|
|
72
|
+
<input
|
|
73
|
+
className={inputClassName}
|
|
74
|
+
data-slot="input"
|
|
75
|
+
size={typeof size === 'number' ? size : undefined}
|
|
76
|
+
style={typeof style === 'function' ? undefined : style}
|
|
77
|
+
{...props}
|
|
78
|
+
/>
|
|
79
|
+
) : (
|
|
80
|
+
<InputPrimitive
|
|
81
|
+
className={inputClassName}
|
|
82
|
+
data-slot="input"
|
|
83
|
+
size={typeof size === 'number' ? size : undefined}
|
|
84
|
+
style={style}
|
|
85
|
+
{...props}
|
|
86
|
+
/>
|
|
87
|
+
)}
|
|
88
|
+
</span>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { Input, InputPrimitive };
|
|
93
|
+
export type { InputProps };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { IconEye, IconEyeOff, IconSearch } from '@tabler/icons-react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { type ComponentMatrixCellProps, Story } from '../_internal/Story';
|
|
7
|
+
import { Button } from '../Button';
|
|
8
|
+
import { InputGroup } from './InputGroup';
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
component: InputGroup,
|
|
12
|
+
parameters: {
|
|
13
|
+
layout: 'fullscreen',
|
|
14
|
+
},
|
|
15
|
+
title: 'components/form/InputGroup',
|
|
16
|
+
} satisfies Meta<typeof InputGroup>;
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
const STATE_COLUMNS = [
|
|
22
|
+
{ key: 'default', label: 'Default' },
|
|
23
|
+
{ key: 'disabled', label: 'Disabled' },
|
|
24
|
+
{ key: 'invalid', label: 'Invalid' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const PATTERN_ROWS = [
|
|
28
|
+
{
|
|
29
|
+
description: 'Leading icon addon',
|
|
30
|
+
key: 'search',
|
|
31
|
+
label: 'Search',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: 'Trailing visibility toggle',
|
|
35
|
+
key: 'password',
|
|
36
|
+
label: 'Password',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
description: 'Leading text addon',
|
|
40
|
+
key: 'currency',
|
|
41
|
+
label: 'Currency',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
description: 'Trailing text addon',
|
|
45
|
+
key: 'domain',
|
|
46
|
+
label: 'Domain',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
function InputGroupMatrixCell({ column, row }: ComponentMatrixCellProps) {
|
|
51
|
+
const inputProps = {
|
|
52
|
+
'aria-invalid': column.key === 'invalid' || undefined,
|
|
53
|
+
disabled: column.key === 'disabled',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
if (row.key === 'search') {
|
|
57
|
+
return (
|
|
58
|
+
<InputGroup className="w-full max-w-64">
|
|
59
|
+
<InputGroup.Addon>
|
|
60
|
+
<IconSearch aria-hidden size={16} />
|
|
61
|
+
</InputGroup.Addon>
|
|
62
|
+
<InputGroup.Input
|
|
63
|
+
aria-label="Search"
|
|
64
|
+
placeholder="Search…"
|
|
65
|
+
type="search"
|
|
66
|
+
{...inputProps}
|
|
67
|
+
/>
|
|
68
|
+
</InputGroup>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (row.key === 'password') {
|
|
73
|
+
return (
|
|
74
|
+
<PasswordInputGroupCell
|
|
75
|
+
disabled={column.key === 'disabled'}
|
|
76
|
+
invalid={column.key === 'invalid'}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (row.key === 'currency') {
|
|
82
|
+
return (
|
|
83
|
+
<InputGroup className="w-full max-w-64">
|
|
84
|
+
<InputGroup.Addon>$</InputGroup.Addon>
|
|
85
|
+
<InputGroup.Input
|
|
86
|
+
aria-label="Amount in USD"
|
|
87
|
+
defaultValue="1200"
|
|
88
|
+
{...inputProps}
|
|
89
|
+
/>
|
|
90
|
+
</InputGroup>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (row.key === 'domain') {
|
|
95
|
+
return (
|
|
96
|
+
<InputGroup className="w-full max-w-64">
|
|
97
|
+
<InputGroup.Input
|
|
98
|
+
aria-label="Pickle subdomain ending in .dev"
|
|
99
|
+
defaultValue="pickle"
|
|
100
|
+
{...inputProps}
|
|
101
|
+
/>
|
|
102
|
+
<InputGroup.Addon align="inline-end">.dev</InputGroup.Addon>
|
|
103
|
+
</InputGroup>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function PasswordInputGroupCell({
|
|
111
|
+
disabled,
|
|
112
|
+
invalid,
|
|
113
|
+
}: {
|
|
114
|
+
disabled?: boolean;
|
|
115
|
+
invalid?: boolean;
|
|
116
|
+
}) {
|
|
117
|
+
const [showPassword, setShowPassword] = React.useState(false);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<InputGroup className="w-full max-w-64">
|
|
121
|
+
<InputGroup.Input
|
|
122
|
+
aria-invalid={invalid || undefined}
|
|
123
|
+
aria-label="Password with toggle visibility"
|
|
124
|
+
disabled={disabled}
|
|
125
|
+
placeholder="Enter your password"
|
|
126
|
+
type={showPassword ? 'text' : 'password'}
|
|
127
|
+
/>
|
|
128
|
+
<InputGroup.Addon align="inline-end">
|
|
129
|
+
<Button
|
|
130
|
+
aria-label={showPassword ? 'Hide password' : 'Show password'}
|
|
131
|
+
disabled={disabled}
|
|
132
|
+
onClick={() => setShowPassword((visible) => !visible)}
|
|
133
|
+
size="icon-xs"
|
|
134
|
+
type="button"
|
|
135
|
+
variant="ghost"
|
|
136
|
+
>
|
|
137
|
+
{showPassword ? (
|
|
138
|
+
<IconEyeOff aria-hidden size={16} />
|
|
139
|
+
) : (
|
|
140
|
+
<IconEye aria-hidden size={16} />
|
|
141
|
+
)}
|
|
142
|
+
</Button>
|
|
143
|
+
</InputGroup.Addon>
|
|
144
|
+
</InputGroup>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const All: StoryDefinition = {
|
|
149
|
+
render: () => (
|
|
150
|
+
<Story.Layout className="max-w-6xl" title="InputGroup">
|
|
151
|
+
<Story.Section title="Patterns and states">
|
|
152
|
+
<Story.Matrix
|
|
153
|
+
Cell={InputGroupMatrixCell}
|
|
154
|
+
cellClassName="justify-stretch"
|
|
155
|
+
cellWidth="16rem"
|
|
156
|
+
columns={STATE_COLUMNS}
|
|
157
|
+
rows={PATTERN_ROWS}
|
|
158
|
+
/>
|
|
159
|
+
</Story.Section>
|
|
160
|
+
</Story.Layout>
|
|
161
|
+
),
|
|
162
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
import { Button, type ButtonProps } from '../Button';
|
|
9
|
+
import { Input, type InputProps } from './Input';
|
|
10
|
+
|
|
11
|
+
const inputGroupAddonVariants = cva(
|
|
12
|
+
"flex h-auto cursor-text select-none items-center justify-center gap-2 leading-none [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 [&_svg]:-mx-0.5 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80",
|
|
13
|
+
{
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
align: 'inline-start',
|
|
16
|
+
},
|
|
17
|
+
variants: {
|
|
18
|
+
align: {
|
|
19
|
+
'block-end':
|
|
20
|
+
'order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]',
|
|
21
|
+
'block-start':
|
|
22
|
+
'order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]',
|
|
23
|
+
'inline-end':
|
|
24
|
+
'order-last pe-[calc(--spacing(3)-1px)] has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]',
|
|
25
|
+
'inline-start':
|
|
26
|
+
'order-first ps-[calc(--spacing(3)-1px)] has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
type InputGroupAddonProps = React.ComponentProps<'div'> &
|
|
33
|
+
VariantProps<typeof inputGroupAddonVariants>;
|
|
34
|
+
|
|
35
|
+
type InputGroupButtonProps = ButtonProps &
|
|
36
|
+
VariantProps<typeof inputGroupAddonVariants>;
|
|
37
|
+
|
|
38
|
+
type InputGroupInputProps = InputProps;
|
|
39
|
+
|
|
40
|
+
type InputGroupProps = React.ComponentProps<'div'>;
|
|
41
|
+
|
|
42
|
+
type InputGroupTextProps = React.ComponentProps<'span'>;
|
|
43
|
+
|
|
44
|
+
function InputGroupAddon({
|
|
45
|
+
align = 'inline-start',
|
|
46
|
+
className,
|
|
47
|
+
...props
|
|
48
|
+
}: InputGroupAddonProps) {
|
|
49
|
+
return (
|
|
50
|
+
// react-doctor-disable-next-line react-doctor/no-static-element-interactions -- mousedown delegates focus to the grouped input without making the addon itself a separate control
|
|
51
|
+
<div
|
|
52
|
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
53
|
+
data-align={align}
|
|
54
|
+
data-slot="input-group-addon"
|
|
55
|
+
onMouseDown={(event) => {
|
|
56
|
+
const target = event.target as HTMLElement;
|
|
57
|
+
const isInteractive = target.closest(
|
|
58
|
+
"button, a, input, select, textarea, [role='button'], [role='combobox'], [role='listbox'], [data-slot='select-trigger']",
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (isInteractive) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
|
|
67
|
+
const parent = event.currentTarget.parentElement;
|
|
68
|
+
const input = parent?.querySelector<
|
|
69
|
+
HTMLInputElement | HTMLTextAreaElement
|
|
70
|
+
>('input, textarea');
|
|
71
|
+
|
|
72
|
+
if (input && !parent?.querySelector('input:focus, textarea:focus')) {
|
|
73
|
+
input.focus();
|
|
74
|
+
}
|
|
75
|
+
}}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function InputGroupButton({
|
|
82
|
+
align = 'inline-end',
|
|
83
|
+
className,
|
|
84
|
+
size = 'icon-xs',
|
|
85
|
+
variant = 'ghost',
|
|
86
|
+
...props
|
|
87
|
+
}: InputGroupButtonProps) {
|
|
88
|
+
return (
|
|
89
|
+
<InputGroupAddon align={align} className={className}>
|
|
90
|
+
<Button size={size} variant={variant} {...props} />
|
|
91
|
+
</InputGroupAddon>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function InputGroupInput({ className, ...props }: InputGroupInputProps) {
|
|
96
|
+
return <Input className={className} unstyled {...props} />;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function InputGroupRoot({ className, ...props }: InputGroupProps) {
|
|
100
|
+
return (
|
|
101
|
+
<div
|
|
102
|
+
className={cn(
|
|
103
|
+
// Divide adjacent inputs, like Group.Separator does between Inputs.
|
|
104
|
+
'[&>[data-slot=input-control]~[data-slot=input-control]>[data-slot=input]]:border-input [&>[data-slot=input-control]~[data-slot=input-control]>[data-slot=input]]:border-s',
|
|
105
|
+
'border-input bg-background text-foreground ring-ring/24 has-[input:focus-visible]:has-[input[aria-invalid]]:border-destructive/64 has-[input:focus-visible]:has-[input[aria-invalid]]:ring-destructive/16 has-[input[aria-invalid]]:border-destructive/36 has-[input:focus-visible]:border-ring dark:bg-input/32 dark:has-[input[aria-invalid]]:ring-destructive/24 relative inline-flex h-8 w-full min-w-0 items-center rounded-lg border text-base shadow-xs/5 transition-shadow not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled]:not-has-[input:focus-visible]:not-has-[input[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:disabled]:opacity-64 has-[input:disabled,input:focus-visible,input[aria-invalid]]:shadow-none has-[input:focus-visible]:ring-[3px] sm:text-sm dark:not-has-[input:disabled]:not-has-[input:focus-visible]:not-has-[input[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)] has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 *:[[data-slot=input-control]]:contents *:[[data-slot=input-control]]:before:hidden has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=inline-start]:**:[input]:ps-2',
|
|
106
|
+
className,
|
|
107
|
+
)}
|
|
108
|
+
data-slot="input-group"
|
|
109
|
+
// react-doctor-disable-next-line react-doctor/prefer-tag-over-role -- role="group" is the correct ARIA pattern for composite input controls
|
|
110
|
+
role="group"
|
|
111
|
+
{...props}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function InputGroupText({ className, ...props }: InputGroupTextProps) {
|
|
117
|
+
return (
|
|
118
|
+
<span
|
|
119
|
+
className={cn(
|
|
120
|
+
"text-muted-foreground line-clamp-1 flex items-center gap-2 leading-none whitespace-nowrap [&_svg]:pointer-events-none [&_svg]:-mx-0.5 in-[[data-slot=input-group]:has([data-slot=input-control])]:[&_svg:not([class*='size-'])]:size-4",
|
|
121
|
+
className,
|
|
122
|
+
)}
|
|
123
|
+
{...props}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const InputGroup = Object.assign(InputGroupRoot, {
|
|
129
|
+
Addon: InputGroupAddon,
|
|
130
|
+
Button: InputGroupButton,
|
|
131
|
+
Input: InputGroupInput,
|
|
132
|
+
Text: InputGroupText,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
InputGroup,
|
|
137
|
+
InputGroupAddon,
|
|
138
|
+
inputGroupAddonVariants,
|
|
139
|
+
InputGroupButton,
|
|
140
|
+
InputGroupInput,
|
|
141
|
+
InputGroupText,
|
|
142
|
+
};
|
|
143
|
+
export type {
|
|
144
|
+
InputGroupAddonProps,
|
|
145
|
+
InputGroupButtonProps,
|
|
146
|
+
InputGroupInputProps,
|
|
147
|
+
InputGroupProps,
|
|
148
|
+
InputGroupTextProps,
|
|
149
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { type ComponentMatrixCellProps, Story } from '../_internal/Story';
|
|
4
|
+
import { RadioGroup, type RadioGroupItemProps } from './RadioGroup';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
component: RadioGroup,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'fullscreen',
|
|
10
|
+
},
|
|
11
|
+
title: 'components/form/RadioGroup',
|
|
12
|
+
} satisfies Meta<typeof RadioGroup>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
type RadioSize = NonNullable<RadioGroupItemProps['size']>;
|
|
16
|
+
type StoryDefinition = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const SIZE_ROWS: {
|
|
19
|
+
key: RadioSize;
|
|
20
|
+
label: string;
|
|
21
|
+
}[] = [
|
|
22
|
+
{ key: 'md', label: 'Medium' },
|
|
23
|
+
{ key: 'sm', label: 'Small' },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const STATE_COLUMNS = [
|
|
27
|
+
{ key: 'unchecked', label: 'Unchecked' },
|
|
28
|
+
{ key: 'checked', label: 'Checked' },
|
|
29
|
+
{ key: 'disabled', label: 'Disabled' },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
function RadioStateCell({ column, row }: ComponentMatrixCellProps) {
|
|
33
|
+
const value = column.key === 'checked' ? 'option' : undefined;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<RadioGroup defaultValue={value}>
|
|
37
|
+
<RadioGroup.Item
|
|
38
|
+
disabled={column.key === 'disabled'}
|
|
39
|
+
label={column.label}
|
|
40
|
+
size={row.key as RadioSize}
|
|
41
|
+
value="option"
|
|
42
|
+
/>
|
|
43
|
+
</RadioGroup>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const All: StoryDefinition = {
|
|
48
|
+
render: () => (
|
|
49
|
+
<Story.Layout className="max-w-5xl" title="RadioGroup">
|
|
50
|
+
<Story.Section title="Sizes and states">
|
|
51
|
+
<Story.Matrix
|
|
52
|
+
Cell={RadioStateCell}
|
|
53
|
+
cellWidth="9rem"
|
|
54
|
+
columns={STATE_COLUMNS}
|
|
55
|
+
rows={SIZE_ROWS}
|
|
56
|
+
/>
|
|
57
|
+
</Story.Section>
|
|
58
|
+
|
|
59
|
+
<Story.Section title="Group">
|
|
60
|
+
<RadioGroup defaultValue="email">
|
|
61
|
+
<RadioGroup.Item label="Email" value="email" />
|
|
62
|
+
<RadioGroup.Item label="SMS" value="sms" />
|
|
63
|
+
<RadioGroup.Item disabled label="Push" value="push" />
|
|
64
|
+
</RadioGroup>
|
|
65
|
+
</Story.Section>
|
|
66
|
+
</Story.Layout>
|
|
67
|
+
),
|
|
68
|
+
};
|