@pickle-ui/react-native 1.0.0-beta.0 → 1.0.0-beta.2
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 +70 -11
- package/dist/components/Badge.d.ts +6 -3
- package/dist/components/Badge.d.ts.map +1 -1
- package/dist/components/Badge.js +36 -7
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/Button.d.ts +11 -4
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +100 -15
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.d.ts +15 -5
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Card.js +28 -10
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Flex.d.ts +25 -0
- package/dist/components/Flex.d.ts.map +1 -0
- package/dist/components/Flex.js +24 -0
- package/dist/components/Flex.js.map +1 -0
- package/dist/components/Grid.d.ts +36 -0
- package/dist/components/Grid.d.ts.map +1 -0
- package/dist/components/Grid.js +68 -0
- package/dist/components/Grid.js.map +1 -0
- package/dist/components/Separator.d.ts +11 -0
- package/dist/components/Separator.d.ts.map +1 -0
- package/dist/components/Separator.js +12 -0
- package/dist/components/Separator.js.map +1 -0
- package/dist/components/Spinner.d.ts +14 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +41 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Text.d.ts +7 -3
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +23 -11
- package/dist/components/Text.js.map +1 -1
- package/dist/components/XStack.d.ts +4 -0
- package/dist/components/XStack.d.ts.map +1 -0
- package/dist/components/XStack.js +6 -0
- package/dist/components/XStack.js.map +1 -0
- package/dist/components/YStack.d.ts +4 -0
- package/dist/components/YStack.d.ts.map +1 -0
- package/dist/components/YStack.js +6 -0
- package/dist/components/YStack.js.map +1 -0
- package/dist/components/_internal/InputFrame.d.ts +13 -0
- package/dist/components/_internal/InputFrame.d.ts.map +1 -0
- package/dist/components/_internal/InputFrame.js +14 -0
- package/dist/components/_internal/InputFrame.js.map +1 -0
- package/dist/components/_internal/StoryItem.d.ts +6 -0
- package/dist/components/_internal/StoryItem.d.ts.map +1 -0
- package/dist/components/_internal/StoryItem.js +9 -0
- package/dist/components/_internal/StoryItem.js.map +1 -0
- package/dist/components/_internal/layout.d.ts +79 -0
- package/dist/components/_internal/layout.d.ts.map +1 -0
- package/dist/components/_internal/layout.js +73 -0
- package/dist/components/_internal/layout.js.map +1 -0
- package/dist/components/_internal/useControllableState.d.ts +7 -0
- package/dist/components/_internal/useControllableState.d.ts.map +1 -0
- package/dist/components/_internal/useControllableState.js +17 -0
- package/dist/components/_internal/useControllableState.js.map +1 -0
- package/dist/components/form/Checkbox.d.ts +26 -0
- package/dist/components/form/Checkbox.d.ts.map +1 -0
- package/dist/components/form/Checkbox.js +41 -0
- package/dist/components/form/Checkbox.js.map +1 -0
- package/dist/components/form/Form.context.d.ts +34 -0
- package/dist/components/form/Form.context.d.ts.map +1 -0
- package/dist/components/form/Form.context.js +53 -0
- package/dist/components/form/Form.context.js.map +1 -0
- package/dist/components/form/Form.d.ts +33 -0
- package/dist/components/form/Form.d.ts.map +1 -0
- package/dist/components/form/Form.js +36 -0
- package/dist/components/form/Form.js.map +1 -0
- package/dist/components/form/FormCheckbox.d.ts +7 -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/FormDescription.d.ts +4 -0
- package/dist/components/form/FormDescription.d.ts.map +1 -0
- package/dist/components/form/FormDescription.js +7 -0
- package/dist/components/form/FormDescription.js.map +1 -0
- package/dist/components/form/FormError.d.ts +5 -0
- package/dist/components/form/FormError.d.ts.map +1 -0
- package/dist/components/form/FormError.js +8 -0
- package/dist/components/form/FormError.js.map +1 -0
- package/dist/components/form/FormField.d.ts +17 -0
- package/dist/components/form/FormField.d.ts.map +1 -0
- package/dist/components/form/FormField.js +36 -0
- package/dist/components/form/FormField.js.map +1 -0
- package/dist/components/form/FormInput.d.ts +10 -0
- package/dist/components/form/FormInput.d.ts.map +1 -0
- package/dist/components/form/FormInput.js +36 -0
- package/dist/components/form/FormInput.js.map +1 -0
- package/dist/components/form/FormInputGroup.d.ts +8 -0
- package/dist/components/form/FormInputGroup.d.ts.map +1 -0
- package/dist/components/form/FormInputGroup.js +18 -0
- package/dist/components/form/FormInputGroup.js.map +1 -0
- package/dist/components/form/FormLabel.d.ts +4 -0
- package/dist/components/form/FormLabel.d.ts.map +1 -0
- package/dist/components/form/FormLabel.js +7 -0
- package/dist/components/form/FormLabel.js.map +1 -0
- package/dist/components/form/FormRadioGroup.d.ts +11 -0
- package/dist/components/form/FormRadioGroup.d.ts.map +1 -0
- package/dist/components/form/FormRadioGroup.js +24 -0
- package/dist/components/form/FormRadioGroup.js.map +1 -0
- package/dist/components/form/FormRoot.d.ts +13 -0
- package/dist/components/form/FormRoot.d.ts.map +1 -0
- package/dist/components/form/FormRoot.js +19 -0
- package/dist/components/form/FormRoot.js.map +1 -0
- package/dist/components/form/FormTextarea.d.ts +7 -0
- package/dist/components/form/FormTextarea.d.ts.map +1 -0
- package/dist/components/form/FormTextarea.js +27 -0
- package/dist/components/form/FormTextarea.js.map +1 -0
- package/dist/components/form/Input.d.ts +17 -0
- package/dist/components/form/Input.d.ts.map +1 -0
- package/dist/components/form/Input.js +32 -0
- package/dist/components/form/Input.js.map +1 -0
- package/dist/components/form/InputGroup.context.d.ts +10 -0
- package/dist/components/form/InputGroup.context.d.ts.map +1 -0
- package/dist/components/form/InputGroup.context.js +8 -0
- package/dist/components/form/InputGroup.context.js.map +1 -0
- package/dist/components/form/InputGroup.d.ts +31 -0
- package/dist/components/form/InputGroup.d.ts.map +1 -0
- package/dist/components/form/InputGroup.js +123 -0
- package/dist/components/form/InputGroup.js.map +1 -0
- package/dist/components/form/RadioGroup.d.ts +29 -0
- package/dist/components/form/RadioGroup.d.ts.map +1 -0
- package/dist/components/form/RadioGroup.js +42 -0
- package/dist/components/form/RadioGroup.js.map +1 -0
- package/dist/components/form/Textarea.d.ts +19 -0
- package/dist/components/form/Textarea.d.ts.map +1 -0
- package/dist/components/form/Textarea.js +26 -0
- package/dist/components/form/Textarea.js.map +1 -0
- package/dist/entries/card.d.ts +1 -1
- package/dist/entries/card.d.ts.map +1 -1
- 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/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/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/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/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/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/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/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/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/cn.d.ts.map +1 -1
- package/dist/lib/cn.js +13 -1
- package/dist/lib/cn.js.map +1 -1
- package/package.json +10 -3
- package/src/base.css +7 -2
- package/src/components/Badge.stories.tsx +51 -6
- package/src/components/Badge.test.tsx +15 -0
- package/src/components/Badge.tsx +73 -17
- package/src/components/Button.stories.tsx +96 -8
- package/src/components/Button.test.tsx +69 -0
- package/src/components/Button.tsx +159 -18
- package/src/components/Card.stories.tsx +17 -4
- package/src/components/Card.test.tsx +24 -1
- package/src/components/Card.tsx +71 -13
- package/src/components/Flex.stories.tsx +58 -0
- package/src/components/Flex.test.tsx +57 -0
- package/src/components/Flex.tsx +52 -0
- package/src/components/Grid.stories.tsx +55 -0
- package/src/components/Grid.test.tsx +140 -0
- package/src/components/Grid.tsx +166 -0
- package/src/components/Separator.stories.tsx +39 -0
- package/src/components/Separator.test.tsx +25 -0
- package/src/components/Separator.tsx +30 -0
- package/src/components/Spinner.stories.tsx +35 -0
- package/src/components/Spinner.test.tsx +30 -0
- package/src/components/Spinner.tsx +75 -0
- package/src/components/Text.stories.tsx +52 -2
- package/src/components/Text.test.tsx +35 -3
- package/src/components/Text.tsx +42 -12
- package/src/components/XStack.stories.tsx +46 -0
- package/src/components/XStack.test.tsx +13 -0
- package/src/components/XStack.tsx +7 -0
- package/src/components/YStack.stories.tsx +46 -0
- package/src/components/YStack.test.tsx +13 -0
- package/src/components/YStack.tsx +7 -0
- package/src/components/_internal/InputFrame.tsx +50 -0
- package/src/components/_internal/Story.tsx +34 -0
- package/src/components/_internal/StoryItem.tsx +24 -0
- package/src/components/_internal/layout.ts +103 -0
- package/src/components/_internal/useControllableState.ts +25 -0
- package/src/components/form/Checkbox.stories.tsx +67 -0
- package/src/components/form/Checkbox.test.tsx +88 -0
- package/src/components/form/Checkbox.tsx +141 -0
- package/src/components/form/Form.context.ts +91 -0
- package/src/components/form/Form.stories.tsx +152 -0
- package/src/components/form/Form.test.tsx +195 -0
- package/src/components/form/Form.tsx +51 -0
- package/src/components/form/FormCheckbox.tsx +42 -0
- package/src/components/form/FormDescription.tsx +14 -0
- package/src/components/form/FormError.tsx +17 -0
- package/src/components/form/FormField.tsx +82 -0
- package/src/components/form/FormInput.tsx +70 -0
- package/src/components/form/FormInputGroup.tsx +30 -0
- package/src/components/form/FormLabel.tsx +17 -0
- package/src/components/form/FormRadioGroup.tsx +48 -0
- package/src/components/form/FormRoot.tsx +41 -0
- package/src/components/form/FormTextarea.tsx +56 -0
- package/src/components/form/Input.stories.tsx +105 -0
- package/src/components/form/Input.test.tsx +76 -0
- package/src/components/form/Input.tsx +81 -0
- package/src/components/form/InputGroup.context.ts +11 -0
- package/src/components/form/InputGroup.stories.tsx +129 -0
- package/src/components/form/InputGroup.test.tsx +95 -0
- package/src/components/form/InputGroup.tsx +266 -0
- package/src/components/form/RadioGroup.stories.tsx +62 -0
- package/src/components/form/RadioGroup.test.tsx +98 -0
- package/src/components/form/RadioGroup.tsx +151 -0
- package/src/components/form/Textarea.stories.tsx +61 -0
- package/src/components/form/Textarea.test.tsx +35 -0
- package/src/components/form/Textarea.tsx +74 -0
- package/src/entries/card.ts +2 -0
- package/src/entries/checkbox.ts +2 -0
- package/src/entries/flex.ts +2 -0
- package/src/entries/form.ts +13 -0
- package/src/entries/grid.ts +2 -0
- package/src/entries/input-group.ts +8 -0
- package/src/entries/input.ts +2 -0
- package/src/entries/radio-group.ts +5 -0
- package/src/entries/separator.ts +2 -0
- package/src/entries/spinner.ts +2 -0
- package/src/entries/textarea.ts +2 -0
- package/src/entries/theme.ts +7 -0
- package/src/entries/x-stack.ts +2 -0
- package/src/entries/y-stack.ts +2 -0
- package/src/index.ts +13 -0
- package/src/lib/cn.test.ts +6 -0
- package/src/lib/cn.ts +14 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Pressable } from 'react-native';
|
|
2
|
+
export type CheckboxProps = Omit<React.ComponentProps<typeof Pressable>, 'children' | 'disabled'> & {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
/** Class overrides for the row around the box and label, the check and the label. */
|
|
5
|
+
classNames?: {
|
|
6
|
+
field?: string;
|
|
7
|
+
indicator?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
};
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Shows a minus instead of the check, for a partly selected group. */
|
|
13
|
+
indeterminate?: boolean;
|
|
14
|
+
/** Marks the value as invalid, like the web's `aria-invalid`. */
|
|
15
|
+
invalid?: boolean;
|
|
16
|
+
/** Text next to the box; pressing it toggles the checkbox and names it. */
|
|
17
|
+
label?: React.ReactNode;
|
|
18
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
19
|
+
size?: 'md' | 'sm';
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A checkbox, like `Checkbox` in @pickle-ui/react. Give it a `label`, or an
|
|
23
|
+
* `accessibilityLabel` when visible text elsewhere names it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function Checkbox({ accessibilityState, checked: checkedProp, className, classNames, defaultChecked, disabled, indeterminate, invalid, label, onCheckedChange, size, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/form/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AAsBrD,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,EACtC,UAAU,GAAG,UAAU,CACxB,GAAG;IACF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qFAAqF;IACrF,UAAU,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EACvB,kBAAkB,EAClB,OAAO,EAAE,WAAW,EACpB,SAAS,EACT,UAAU,EACV,cAAsB,EACtB,QAAgB,EAChB,aAAqB,EACrB,OAAe,EACf,KAAK,EACL,eAAe,EACf,IAAW,EACX,GAAG,KAAK,EACT,EAAE,aAAa,+BAkFf"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, Text, View } from 'react-native';
|
|
3
|
+
import { cn } from '../../lib/cn';
|
|
4
|
+
import { useControllableState } from '../_internal/useControllableState';
|
|
5
|
+
// Same box sizes as `Checkbox` in @pickle-ui/react. `hitSlop` stretches the
|
|
6
|
+
// box to a 44pt touch target, vertically only when a label already widens it.
|
|
7
|
+
const boxClasses = { md: 'size-4.5', sm: 'size-3.5' };
|
|
8
|
+
const boxHitSlop = { md: 13, sm: 15 };
|
|
9
|
+
const fieldHitSlop = {
|
|
10
|
+
md: { bottom: 13, top: 13 },
|
|
11
|
+
sm: { bottom: 15, top: 15 },
|
|
12
|
+
};
|
|
13
|
+
// The web draws Tabler's check and minus icons. Without SVG, the check is the
|
|
14
|
+
// bottom and right borders of a rotated box, and the minus a bar.
|
|
15
|
+
const checkClasses = {
|
|
16
|
+
md: 'h-[9px] w-[5px] border-b-[1.5px] border-r-[1.5px]',
|
|
17
|
+
sm: 'h-[7px] w-[4px] border-b-[1.25px] border-r-[1.25px]',
|
|
18
|
+
};
|
|
19
|
+
const minusClasses = { md: 'h-[1.5px] w-2', sm: 'h-[1.25px] w-1.5' };
|
|
20
|
+
/**
|
|
21
|
+
* A checkbox, like `Checkbox` in @pickle-ui/react. Give it a `label`, or an
|
|
22
|
+
* `accessibilityLabel` when visible text elsewhere names it.
|
|
23
|
+
*/
|
|
24
|
+
export function Checkbox({ accessibilityState, checked: checkedProp, className, classNames, defaultChecked = false, disabled = false, indeterminate = false, invalid = false, label, onCheckedChange, size = 'md', ...props }) {
|
|
25
|
+
const [checked, setChecked] = useControllableState(checkedProp, defaultChecked, onCheckedChange);
|
|
26
|
+
const filled = checked && !indeterminate;
|
|
27
|
+
const box = (_jsx(View, { className: cn('items-center justify-center rounded-[4px] border shadow-xs shadow-black/5', boxClasses[size],
|
|
28
|
+
// A checked box is filled in both themes, so the dark input
|
|
29
|
+
// background must not apply to it.
|
|
30
|
+
filled
|
|
31
|
+
? 'border-primary bg-primary'
|
|
32
|
+
: cn('border-input bg-background dark:bg-input/32', invalid && 'border-destructive/36'), (checked || indeterminate || invalid || disabled) && 'shadow-none', disabled && 'opacity-64', className), children: indeterminate ? (_jsx(View, { className: cn('bg-foreground rounded-full', minusClasses[size], classNames?.indicator) })) : checked ? (_jsx(View, { className: cn('border-primary-foreground -mt-px rotate-45', checkClasses[size], classNames?.indicator) })) : null }));
|
|
33
|
+
return (_jsxs(Pressable, { accessibilityState: {
|
|
34
|
+
...accessibilityState,
|
|
35
|
+
checked: indeterminate ? 'mixed' : checked,
|
|
36
|
+
disabled,
|
|
37
|
+
}, "aria-checked": indeterminate ? 'mixed' : checked, "aria-disabled": disabled, className: label
|
|
38
|
+
? cn('flex-row items-center gap-2', classNames?.field)
|
|
39
|
+
: 'self-start', disabled: disabled, hitSlop: label ? fieldHitSlop[size] : boxHitSlop[size], onPress: () => setChecked(!checked), role: "checkbox", ...props, children: [box, label ? (_jsx(Text, { className: cn('text-foreground text-sm leading-none font-medium', disabled && 'opacity-50', classNames?.label), children: label })) : null] }));
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/form/Checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,4EAA4E;AAC5E,8EAA8E;AAC9E,MAAM,UAAU,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAW,CAAC;AAC/D,MAAM,UAAU,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAW,CAAC;AAC/C,MAAM,YAAY,GAAG;IACnB,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;IAC3B,EAAE,EAAE,EAAE,MAAM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,CAAC,CAAC,CACZ,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CACX,4CAA4C,EAC5C,YAAY,CAAC,IAAI,CAAC,EAClB,UAAU,EAAE,SAAS,CACtB,GACD,CACH,CAAC,CAAC,CAAC,IAAI,GACH,CACR,CAAC;IAEF,OAAO,CAGL,MAAC,SAAS,IACR,kBAAkB,EAAE;YAClB,GAAG,kBAAkB;YACrB,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;YAC1C,QAAQ;SACT,kBACa,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,mBAChC,QAAQ,EACvB,SAAS,EACP,KAAK;YACH,CAAC,CAAC,EAAE,CAAC,6BAA6B,EAAE,UAAU,EAAE,KAAK,CAAC;YACtD,CAAC,CAAC,YAAY,EAElB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EACtD,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,EACnC,IAAI,EAAC,UAAU,KACX,KAAK,aAER,GAAG,EACH,KAAK,CAAC,CAAC,CAAC,CACP,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CACX,kDAAkD,EAClD,QAAQ,IAAI,YAAY,EACxB,UAAU,EAAE,KAAK,CAClB,YAEA,KAAK,GACD,CACR,CAAC,CAAC,CAAC,IAAI,IACE,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type UseFormReturn } from 'react-hook-form';
|
|
3
|
+
export type FormFieldContextValue = {
|
|
4
|
+
/** The field's label, used as its control's accessibility label when it is text. */
|
|
5
|
+
label?: ReactNode;
|
|
6
|
+
/** The `nativeID` of the field's label, for `aria-labelledby`. */
|
|
7
|
+
labelId?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
/** Registers the control the label focuses when pressed. */
|
|
10
|
+
setControl: (control: FocusTarget | null) => void;
|
|
11
|
+
};
|
|
12
|
+
type FocusTarget = {
|
|
13
|
+
focus: () => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const FormFieldContext: import("react").Context<FormFieldContextValue | null>;
|
|
16
|
+
/** True inside `Form.InputGroup`, where `Form.Input` renders `InputGroup.Input`. */
|
|
17
|
+
export declare const FormInputGroupContext: import("react").Context<boolean>;
|
|
18
|
+
/** Submits the form, like pressing a submit button or Enter on the web. */
|
|
19
|
+
export declare const FormSubmitContext: import("react").Context<() => void>;
|
|
20
|
+
export declare function getErrorMessage(error: unknown): ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* React Hook Form tracks field state but has no DOM to label: this maps the
|
|
23
|
+
* current `Form.Field` onto its control, naming it by the field's label and
|
|
24
|
+
* marking it `invalid` while the field has an error.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useFormControlProps(): {
|
|
27
|
+
accessibilityLabel: string | undefined;
|
|
28
|
+
'aria-labelledby': string | undefined;
|
|
29
|
+
invalid: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare function useFormMethods(): UseFormReturn;
|
|
32
|
+
export declare function useRequiredFieldName(name: string | undefined, componentName: string): string;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=Form.context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.context.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,SAAS,EAAO,MAAM,OAAO,CAAC;AAC3E,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,qBAAqB,GAAG;IAClC,oFAAoF;IACpF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD,CAAC;AAEF,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEzC,eAAO,MAAM,gBAAgB,uDAE5B,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,kCAAuB,CAAC;AAE1D,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,gCAAuB,IAAI,CAAW,CAAC;AAErE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAUzD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB;;;;EAiBlC;AAED,wBAAgB,cAAc,kBAU7B;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,aAAa,EAAE,MAAM,UAWtB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createContext, isValidElement, use } from 'react';
|
|
2
|
+
import { useFormContext, useFormState, } from 'react-hook-form';
|
|
3
|
+
export const FormFieldContext = createContext(null);
|
|
4
|
+
/** True inside `Form.InputGroup`, where `Form.Input` renders `InputGroup.Input`. */
|
|
5
|
+
export const FormInputGroupContext = createContext(false);
|
|
6
|
+
/** Submits the form, like pressing a submit button or Enter on the web. */
|
|
7
|
+
export const FormSubmitContext = createContext(() => { });
|
|
8
|
+
export function getErrorMessage(error) {
|
|
9
|
+
if (!error || typeof error !== 'object')
|
|
10
|
+
return undefined;
|
|
11
|
+
const message = error.message;
|
|
12
|
+
return isValidElement(message) ||
|
|
13
|
+
typeof message === 'string' ||
|
|
14
|
+
typeof message === 'number'
|
|
15
|
+
? message
|
|
16
|
+
: undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* React Hook Form tracks field state but has no DOM to label: this maps the
|
|
20
|
+
* current `Form.Field` onto its control, naming it by the field's label and
|
|
21
|
+
* marking it `invalid` while the field has an error.
|
|
22
|
+
*/
|
|
23
|
+
export function useFormControlProps() {
|
|
24
|
+
const field = use(FormFieldContext);
|
|
25
|
+
const { control, getFieldState } = useFormMethods();
|
|
26
|
+
const name = field?.name;
|
|
27
|
+
const formState = useFormState({
|
|
28
|
+
control,
|
|
29
|
+
disabled: !name,
|
|
30
|
+
exact: true,
|
|
31
|
+
name,
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
accessibilityLabel: typeof field?.label === 'string' ? field.label : undefined,
|
|
35
|
+
'aria-labelledby': field?.labelId,
|
|
36
|
+
invalid: name ? getFieldState(name, formState).invalid : false,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function useFormMethods() {
|
|
40
|
+
const methods = useFormContext();
|
|
41
|
+
if (!methods) {
|
|
42
|
+
throw new Error('Form components must be rendered inside <Form form={form}>.');
|
|
43
|
+
}
|
|
44
|
+
return methods;
|
|
45
|
+
}
|
|
46
|
+
export function useRequiredFieldName(name, componentName) {
|
|
47
|
+
const fieldName = name ?? use(FormFieldContext)?.name;
|
|
48
|
+
if (!fieldName) {
|
|
49
|
+
throw new Error(`${componentName} requires a name prop or a parent <Form.Field name="...">.`);
|
|
50
|
+
}
|
|
51
|
+
return fieldName;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=Form.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.context.js","sourceRoot":"","sources":["../../../src/components/form/Form.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAkB,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EACL,cAAc,EAEd,YAAY,GACb,MAAM,iBAAiB,CAAC;AAczB,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAC3C,IAAI,CACL,CAAC;AAEF,oFAAoF;AACpF,MAAM,CAAC,MAAM,qBAAqB,GAAG,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,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,IAAwB,EACxB,aAAqB;IAErB,MAAM,SAAS,GAAG,IAAI,IAAI,GAAG,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC;IAEtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,aAAa,4DAA4D,CAC7E,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ButtonProps } from '../Button';
|
|
2
|
+
import { FormCheckbox, type FormCheckboxProps } from './FormCheckbox';
|
|
3
|
+
import { FormDescription, type FormDescriptionProps } from './FormDescription';
|
|
4
|
+
import { FormError, type FormErrorProps } from './FormError';
|
|
5
|
+
import { FormField, type FormFieldProps } from './FormField';
|
|
6
|
+
import { FormInput, type FormInputProps } from './FormInput';
|
|
7
|
+
import { FormInputGroup, type FormInputGroupProps } from './FormInputGroup';
|
|
8
|
+
import { FormLabel, type FormLabelProps } from './FormLabel';
|
|
9
|
+
import { type FormRadioGroupProps } from './FormRadioGroup';
|
|
10
|
+
import { type FormProps, FormRoot } from './FormRoot';
|
|
11
|
+
import { FormTextarea, type FormTextareaProps } from './FormTextarea';
|
|
12
|
+
/**
|
|
13
|
+
* A `Button` that submits the form when pressed, like the web's submit
|
|
14
|
+
* button. Pass `onPress` to give it another action.
|
|
15
|
+
*/
|
|
16
|
+
declare function FormButton({ onPress, ...props }: ButtonProps): import("react").JSX.Element;
|
|
17
|
+
declare const Form: typeof FormRoot & {
|
|
18
|
+
Button: typeof FormButton;
|
|
19
|
+
Checkbox: typeof FormCheckbox;
|
|
20
|
+
Description: typeof FormDescription;
|
|
21
|
+
Error: typeof FormError;
|
|
22
|
+
Field: typeof FormField;
|
|
23
|
+
Input: typeof FormInput;
|
|
24
|
+
InputGroup: typeof FormInputGroup;
|
|
25
|
+
Label: typeof FormLabel;
|
|
26
|
+
RadioGroup: (({ name: nameProp, onValueChange, ...props }: FormRadioGroupProps) => import("react").JSX.Element) & {
|
|
27
|
+
Item: typeof import("./RadioGroup").RadioGroupItem;
|
|
28
|
+
};
|
|
29
|
+
Textarea: typeof FormTextarea;
|
|
30
|
+
};
|
|
31
|
+
export { Form };
|
|
32
|
+
export type { FormCheckboxProps, FormDescriptionProps, FormErrorProps, FormFieldProps, FormInputGroupProps, FormInputProps, FormLabelProps, FormProps, FormRadioGroupProps, FormTextareaProps, };
|
|
33
|
+
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,KAAK,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;;GAGG;AACH,iBAAS,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,+BAIrD;AAED,QAAA,MAAM,IAAI;;;;;;;;;;;;;CAWR,CAAC;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,SAAS,EACT,mBAAmB,EACnB,iBAAiB,GAClB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { use } from 'react';
|
|
3
|
+
import { Button } from '../Button';
|
|
4
|
+
import { FormSubmitContext } from './Form.context';
|
|
5
|
+
import { FormCheckbox } from './FormCheckbox';
|
|
6
|
+
import { FormDescription } from './FormDescription';
|
|
7
|
+
import { FormError } from './FormError';
|
|
8
|
+
import { FormField } from './FormField';
|
|
9
|
+
import { FormInput } from './FormInput';
|
|
10
|
+
import { FormInputGroup } from './FormInputGroup';
|
|
11
|
+
import { FormLabel } from './FormLabel';
|
|
12
|
+
import { FormRadioGroup } from './FormRadioGroup';
|
|
13
|
+
import { FormRoot } from './FormRoot';
|
|
14
|
+
import { FormTextarea } from './FormTextarea';
|
|
15
|
+
/**
|
|
16
|
+
* A `Button` that submits the form when pressed, like the web's submit
|
|
17
|
+
* button. Pass `onPress` to give it another action.
|
|
18
|
+
*/
|
|
19
|
+
function FormButton({ onPress, ...props }) {
|
|
20
|
+
const submit = use(FormSubmitContext);
|
|
21
|
+
return _jsx(Button, { onPress: onPress ?? submit, ...props });
|
|
22
|
+
}
|
|
23
|
+
const Form = Object.assign(FormRoot, {
|
|
24
|
+
Button: FormButton,
|
|
25
|
+
Checkbox: FormCheckbox,
|
|
26
|
+
Description: FormDescription,
|
|
27
|
+
Error: FormError,
|
|
28
|
+
Field: FormField,
|
|
29
|
+
Input: FormInput,
|
|
30
|
+
InputGroup: FormInputGroup,
|
|
31
|
+
Label: FormLabel,
|
|
32
|
+
RadioGroup: FormRadioGroup,
|
|
33
|
+
Textarea: FormTextarea,
|
|
34
|
+
});
|
|
35
|
+
export { Form };
|
|
36
|
+
//# sourceMappingURL=Form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.js","sourceRoot":"","sources":["../../../src/components/form/Form.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAoB,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAA0B,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,eAAe,EAA6B,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,cAAc,EAA4B,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,cAAc,EAA4B,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAkB,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,YAAY,EAA0B,MAAM,gBAAgB,CAAC;AAEtE;;;GAGG;AACH,SAAS,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAe;IACpD,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAEtC,OAAO,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,IAAI,MAAM,KAAM,KAAK,GAAI,CAAC;AAC3D,CAAC;AAED,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;IACnC,MAAM,EAAE,UAAU;IAClB,QAAQ,EAAE,YAAY;IACtB,WAAW,EAAE,eAAe;IAC5B,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,cAAc;IAC1B,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,cAAc;IAC1B,QAAQ,EAAE,YAAY;CACvB,CAAC,CAAC;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type CheckboxProps } from './Checkbox';
|
|
2
|
+
export type FormCheckboxProps = Omit<CheckboxProps, 'checked' | 'invalid'> & {
|
|
3
|
+
name?: string;
|
|
4
|
+
};
|
|
5
|
+
/** A `Checkbox` bound to the field's boolean value. */
|
|
6
|
+
export declare function FormCheckbox({ name: nameProp, onCheckedChange, ...props }: FormCheckboxProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=FormCheckbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormCheckbox.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormCheckbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAO1D,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EAAE,QAAQ,EACd,eAAe,EACf,GAAG,KAAK,EACT,EAAE,iBAAiB,+BAuBnB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
|
+
import { Checkbox } from './Checkbox';
|
|
4
|
+
import { useFormControlProps, useFormMethods, useRequiredFieldName, } from './Form.context';
|
|
5
|
+
/** A `Checkbox` bound to the field's boolean value. */
|
|
6
|
+
export function FormCheckbox({ name: nameProp, onCheckedChange, ...props }) {
|
|
7
|
+
const name = useRequiredFieldName(nameProp, 'Form.Checkbox');
|
|
8
|
+
const { control } = useFormMethods();
|
|
9
|
+
const { field } = useController({
|
|
10
|
+
control,
|
|
11
|
+
defaultValue: props.defaultChecked ?? false,
|
|
12
|
+
name,
|
|
13
|
+
});
|
|
14
|
+
const { accessibilityLabel, invalid } = useFormControlProps();
|
|
15
|
+
return (_jsx(Checkbox
|
|
16
|
+
// A `label` already names the checkbox.
|
|
17
|
+
, {
|
|
18
|
+
// A `label` already names the checkbox.
|
|
19
|
+
accessibilityLabel: props.label ? undefined : accessibilityLabel, ...props, checked: Boolean(field.value), invalid: invalid, onCheckedChange: (checked) => {
|
|
20
|
+
field.onChange(checked);
|
|
21
|
+
onCheckedChange?.(checked);
|
|
22
|
+
} }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=FormCheckbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormCheckbox.js","sourceRoot":"","sources":["../../../src/components/form/FormCheckbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAMxB,uDAAuD;AACvD,MAAM,UAAU,YAAY,CAAC,EAC3B,IAAI,EAAE,QAAQ,EACd,eAAe,EACf,GAAG,KAAK,EACU;IAClB,MAAM,IAAI,GAAG,oBAAoB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAC7D,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;QAC9B,OAAO;QACP,YAAY,EAAE,KAAK,CAAC,cAAc,IAAI,KAAK;QAC3C,IAAI;KACL,CAAC,CAAC;IACH,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAE9D,OAAO,CACL,KAAC,QAAQ;IACP,wCAAwC;;QAAxC,wCAAwC;QACxC,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,KAC5D,KAAK,EACT,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAC7B,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE;YAC3B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxB,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC,GACD,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Text } from 'react-native';
|
|
2
|
+
export type FormDescriptionProps = React.ComponentProps<typeof Text>;
|
|
3
|
+
export declare function FormDescription({ className, ...props }: FormDescriptionProps): import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=FormDescription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDescription.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormDescription.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIpC,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAErE,wBAAgB,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,oBAAoB,+BAO5E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { cn } from '../../lib/cn';
|
|
4
|
+
export function FormDescription({ className, ...props }) {
|
|
5
|
+
return (_jsx(Text, { className: cn('text-muted-foreground text-sm', className), ...props }));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=FormDescription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDescription.js","sourceRoot":"","sources":["../../../src/components/form/FormDescription.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAIlC,MAAM,UAAU,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAwB;IAC3E,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CAAC,+BAA+B,EAAE,SAAS,CAAC,KACrD,KAAK,GACT,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Text } from 'react-native';
|
|
2
|
+
export type FormErrorProps = React.ComponentProps<typeof Text>;
|
|
3
|
+
/** Announced by screen readers when it appears, like the web's live error. */
|
|
4
|
+
export declare function FormError({ className, ...props }: FormErrorProps): import("react").JSX.Element;
|
|
5
|
+
//# sourceMappingURL=FormError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormError.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormError.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIpC,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAE/D,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,+BAShE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { cn } from '../../lib/cn';
|
|
4
|
+
/** Announced by screen readers when it appears, like the web's live error. */
|
|
5
|
+
export function FormError({ className, ...props }) {
|
|
6
|
+
return (_jsx(Text, { accessibilityLiveRegion: "polite", className: cn('text-destructive text-sm font-medium', className), role: "alert", ...props }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=FormError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormError.js","sourceRoot":"","sources":["../../../src/components/form/FormError.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAIlC,8EAA8E;AAC9E,MAAM,UAAU,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAkB;IAC/D,OAAO,CACL,KAAC,IAAI,IACH,uBAAuB,EAAC,QAAQ,EAChC,SAAS,EAAE,EAAE,CAAC,sCAAsC,EAAE,SAAS,CAAC,EAChE,IAAI,EAAC,OAAO,KACR,KAAK,GACT,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
export type FormFieldProps = Omit<React.ComponentProps<typeof View>, 'children'> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
/** Replaces the error message React Hook Form holds for the field. */
|
|
7
|
+
error?: ReactNode;
|
|
8
|
+
/** Names the control and focuses it when pressed, like the web's `<label>`. */
|
|
9
|
+
label?: ReactNode;
|
|
10
|
+
name?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A labelled field bound to `name`, like `Form.Field` in @pickle-ui/react:
|
|
14
|
+
* the label, the control, then the field's error or its description.
|
|
15
|
+
*/
|
|
16
|
+
export declare function FormField({ children, className, description, error, label, name, ...props }: FormFieldProps): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=FormField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAA0B,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAYpC,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,EACjC,UAAU,CACX,GAAG;IACF,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,sEAAsE;IACtE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,SAAS,EACT,WAAW,EACX,KAAK,EACL,KAAK,EACL,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,cAAc,+BA0ChB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useMemo, useRef } from 'react';
|
|
3
|
+
import { useFormState } from 'react-hook-form';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { cn } from '../../lib/cn';
|
|
6
|
+
import { FormFieldContext, getErrorMessage, useFormMethods, } from './Form.context';
|
|
7
|
+
import { FormDescription } from './FormDescription';
|
|
8
|
+
import { FormError } from './FormError';
|
|
9
|
+
import { FormLabel } from './FormLabel';
|
|
10
|
+
/**
|
|
11
|
+
* A labelled field bound to `name`, like `Form.Field` in @pickle-ui/react:
|
|
12
|
+
* the label, the control, then the field's error or its description.
|
|
13
|
+
*/
|
|
14
|
+
export function FormField({ children, className, description, error, label, name, ...props }) {
|
|
15
|
+
const { control, getFieldState } = useFormMethods();
|
|
16
|
+
const formState = useFormState({
|
|
17
|
+
control,
|
|
18
|
+
disabled: !name,
|
|
19
|
+
exact: true,
|
|
20
|
+
name,
|
|
21
|
+
});
|
|
22
|
+
const fieldError = name ? getFieldState(name, formState).error : undefined;
|
|
23
|
+
const errorMessage = error ?? getErrorMessage(fieldError);
|
|
24
|
+
const labelId = useId();
|
|
25
|
+
const controlRef = useRef(null);
|
|
26
|
+
const context = useMemo(() => ({
|
|
27
|
+
label,
|
|
28
|
+
labelId: label ? labelId : undefined,
|
|
29
|
+
name,
|
|
30
|
+
setControl: (target) => {
|
|
31
|
+
controlRef.current = target;
|
|
32
|
+
},
|
|
33
|
+
}), [label, labelId, name]);
|
|
34
|
+
return (_jsxs(View, { className: cn('gap-2.5', className), ...props, children: [label ? (_jsx(FormLabel, { nativeID: labelId, onPress: () => controlRef.current?.focus(), children: label })) : null, _jsx(FormFieldContext, { value: context, children: children }), errorMessage ? (_jsx(FormError, { children: errorMessage })) : description ? (_jsx(FormDescription, { children: description })) : null] }));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=FormField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/form/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,C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E,YAEzC,KAAK,GACI,CACb,CAAC,CAAC,CAAC,IAAI,EACR,KAAC,gBAAgB,IAAC,KAAK,EAAE,OAAO,YAAG,QAAQ,GAAoB,EAC9D,YAAY,CAAC,CAAC,CAAC,CACd,KAAC,SAAS,cAAE,YAAY,GAAa,CACtC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAChB,KAAC,eAAe,cAAE,WAAW,GAAmB,CACjD,CAAC,CAAC,CAAC,IAAI,IACH,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type InputProps } from './Input';
|
|
2
|
+
export type FormInputProps = Omit<InputProps, 'defaultValue' | 'invalid' | 'value'> & {
|
|
3
|
+
name?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* An `Input` bound to the field's value. The return key submits the form,
|
|
7
|
+
* like Enter on the web, unless `onSubmitEditing` is set.
|
|
8
|
+
*/
|
|
9
|
+
export declare function FormInput({ name: nameProp, onBlur, onChangeText, onSubmitEditing, ref, ...props }: FormInputProps): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=FormInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormInput.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormInput.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAGjD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,UAAU,EACV,cAAc,GAAG,SAAS,GAAG,OAAO,CACrC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAItB;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EAAE,QAAQ,EACd,MAAM,EACN,YAAY,EACZ,eAAe,EACf,GAAG,EACH,GAAG,KAAK,EACT,EAAE,cAAc,+BAoChB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { use, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
import { useController } from 'react-hook-form';
|
|
4
|
+
import { FormFieldContext, FormInputGroupContext, FormSubmitContext, useFormControlProps, useFormMethods, useRequiredFieldName, } from './Form.context';
|
|
5
|
+
import { Input } from './Input';
|
|
6
|
+
import { InputGroup } from './InputGroup';
|
|
7
|
+
/**
|
|
8
|
+
* An `Input` bound to the field's value. The return key submits the form,
|
|
9
|
+
* like Enter on the web, unless `onSubmitEditing` is set.
|
|
10
|
+
*/
|
|
11
|
+
export function FormInput({ name: nameProp, onBlur, onChangeText, onSubmitEditing, ref, ...props }) {
|
|
12
|
+
const name = useRequiredFieldName(nameProp, 'Form.Input');
|
|
13
|
+
const { control } = useFormMethods();
|
|
14
|
+
const { field } = useController({ control, name });
|
|
15
|
+
const controlProps = useFormControlProps();
|
|
16
|
+
const fieldContext = use(FormFieldContext);
|
|
17
|
+
const isInsideInputGroup = use(FormInputGroupContext);
|
|
18
|
+
const submit = use(FormSubmitContext);
|
|
19
|
+
const inputRef = useRef(null);
|
|
20
|
+
useImperativeHandle(ref, () => inputRef.current);
|
|
21
|
+
const InputComponent = isInsideInputGroup ? InputGroup.Input : Input;
|
|
22
|
+
return (_jsx(InputComponent, { ...controlProps, ...props, onBlur: (event) => {
|
|
23
|
+
field.onBlur();
|
|
24
|
+
onBlur?.(event);
|
|
25
|
+
}, onChangeText: (text) => {
|
|
26
|
+
field.onChange(text);
|
|
27
|
+
onChangeText?.(text);
|
|
28
|
+
}, onSubmitEditing: onSubmitEditing ?? submit, ref: (node) => {
|
|
29
|
+
inputRef.current = node;
|
|
30
|
+
// React Hook Form focuses the first invalid field after a submit,
|
|
31
|
+
// and the field's label focuses its input when pressed.
|
|
32
|
+
field.ref(node);
|
|
33
|
+
fieldContext?.setControl(node);
|
|
34
|
+
}, value: field.value ?? '' }));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=FormInput.js.map
|
|
@@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AC,CAAC,KAAK,CAAC;IAErE,OAAO,CACL,KAAC,cAAc,OACT,YAAY,KACZ,KAAK,EACT,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,KAAK,CAAC,MAAM,EAAE,CAAC;YACf,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,EACD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE;YACrB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrB,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,EACD,eAAe,EAAE,eAAe,IAAI,MAAM,EAC1C,GAAG,EAAE,CAAC,IAA8B,EAAE,EAAE;YACtC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;YACxB,kEAAkE;YAClE,wDAAwD;YACxD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAChB,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,GACxB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InputGroup } from './InputGroup';
|
|
2
|
+
export type FormInputGroupProps = React.ComponentProps<typeof InputGroup>;
|
|
3
|
+
/**
|
|
4
|
+
* An `InputGroup` whose `Form.Input` renders `InputGroup.Input`, framed as
|
|
5
|
+
* invalid while the field has an error.
|
|
6
|
+
*/
|
|
7
|
+
export declare function FormInputGroup({ children, ...props }: FormInputGroupProps): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=FormInputGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormInputGroup.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormInputGroup.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAE1E;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,+BAgBzE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Children, isValidElement } from 'react';
|
|
3
|
+
import { FormInputGroupContext, useFormControlProps } from './Form.context';
|
|
4
|
+
import { FormInput } from './FormInput';
|
|
5
|
+
import { InputGroup } from './InputGroup';
|
|
6
|
+
import { InputGroupStateContext } from './InputGroup.context';
|
|
7
|
+
/**
|
|
8
|
+
* An `InputGroup` whose `Form.Input` renders `InputGroup.Input`, framed as
|
|
9
|
+
* invalid while the field has an error.
|
|
10
|
+
*/
|
|
11
|
+
export function FormInputGroup({ children, ...props }) {
|
|
12
|
+
const { invalid } = useFormControlProps();
|
|
13
|
+
const disabled = Children.toArray(children).some((child) => isValidElement(child) &&
|
|
14
|
+
child.type === FormInput &&
|
|
15
|
+
Boolean(child.props.disabled));
|
|
16
|
+
return (_jsx(FormInputGroupContext, { value: true, children: _jsx(InputGroupStateContext, { value: { disabled, invalid }, children: _jsx(InputGroup, { ...props, children: children }) }) }));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=FormInputGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormInputGroup.js","sourceRoot":"","sources":["../../../src/components/form/FormInputGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAI9D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAuB;IACxE,MAAM,EAAE,OAAO,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC9C,CAAC,KAAK,EAAE,EAAE,CACR,cAAc,CAAiB,KAAK,CAAC;QACrC,KAAK,CAAC,IAAI,KAAK,SAAS;QACxB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAChC,CAAC;IAEF,OAAO,CACL,KAAC,qBAAqB,IAAC,KAAK,kBAC1B,KAAC,sBAAsB,IAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,YAClD,KAAC,UAAU,OAAK,KAAK,YAAG,QAAQ,GAAc,GACvB,GACH,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLabel.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIpC,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAE/D,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,+BAUhE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { cn } from '../../lib/cn';
|
|
4
|
+
export function FormLabel({ className, ...props }) {
|
|
5
|
+
return (_jsx(Text, { className: cn('text-foreground text-sm leading-none font-medium', className), ...props }));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=FormLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLabel.js","sourceRoot":"","sources":["../../../src/components/form/FormLabel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAIlC,MAAM,UAAU,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAkB;IAC/D,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CACX,kDAAkD,EAClD,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type RadioGroupProps } from './RadioGroup';
|
|
2
|
+
export type FormRadioGroupProps = Omit<RadioGroupProps, 'value'> & {
|
|
3
|
+
name?: string;
|
|
4
|
+
};
|
|
5
|
+
/** A `RadioGroup` bound to the field's value. */
|
|
6
|
+
declare function FormRadioGroupRoot({ name: nameProp, onValueChange, ...props }: FormRadioGroupProps): import("react").JSX.Element;
|
|
7
|
+
declare const FormRadioGroup: typeof FormRadioGroupRoot & {
|
|
8
|
+
Item: typeof import("./RadioGroup").RadioGroupItem;
|
|
9
|
+
};
|
|
10
|
+
export { FormRadioGroup };
|
|
11
|
+
//# sourceMappingURL=FormRadioGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormRadioGroup.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormRadioGroup.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,GAAG;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,iDAAiD;AACjD,iBAAS,kBAAkB,CAAC,EAC1B,IAAI,EAAE,QAAQ,EACd,aAAa,EACb,GAAG,KAAK,EACT,EAAE,mBAAmB,+BAuBrB;AAED,QAAA,MAAM,cAAc;;CAElB,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
|
+
import { useFormControlProps, useFormMethods, useRequiredFieldName, } from './Form.context';
|
|
4
|
+
import { RadioGroup } from './RadioGroup';
|
|
5
|
+
/** A `RadioGroup` bound to the field's value. */
|
|
6
|
+
function FormRadioGroupRoot({ name: nameProp, onValueChange, ...props }) {
|
|
7
|
+
const name = useRequiredFieldName(nameProp, 'Form.RadioGroup');
|
|
8
|
+
const { control } = useFormMethods();
|
|
9
|
+
const { field } = useController({
|
|
10
|
+
control,
|
|
11
|
+
defaultValue: props.defaultValue,
|
|
12
|
+
name,
|
|
13
|
+
});
|
|
14
|
+
const { accessibilityLabel, 'aria-labelledby': labelledBy } = useFormControlProps();
|
|
15
|
+
return (_jsx(RadioGroup, { accessibilityLabel: accessibilityLabel, "aria-labelledby": labelledBy, ...props, onValueChange: (value) => {
|
|
16
|
+
field.onChange(value);
|
|
17
|
+
onValueChange?.(value);
|
|
18
|
+
}, value: field.value }));
|
|
19
|
+
}
|
|
20
|
+
const FormRadioGroup = Object.assign(FormRadioGroupRoot, {
|
|
21
|
+
Item: RadioGroup.Item,
|
|
22
|
+
});
|
|
23
|
+
export { FormRadioGroup };
|
|
24
|
+
//# sourceMappingURL=FormRadioGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormRadioGroup.js","sourceRoot":"","sources":["../../../src/components/form/FormRadioGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAC;AAMhE,iDAAiD;AACjD,SAAS,kBAAkB,CAAC,EAC1B,IAAI,EAAE,QAAQ,EACd,aAAa,EACb,GAAG,KAAK,EACY;IACpB,MAAM,IAAI,GAAG,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC;QAC9B,OAAO;QACP,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,IAAI;KACL,CAAC,CAAC;IACH,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,GACzD,mBAAmB,EAAE,CAAC;IAExB,OAAO,CACL,KAAC,UAAU,IACT,kBAAkB,EAAE,kBAAkB,qBACrB,UAAU,KACvB,KAAK,EACT,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;YACvB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACtB,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,GAClB,CACH,CAAC;AACJ,CAAC;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE;IACvD,IAAI,EAAE,UAAU,CAAC,IAAI;CACtB,CAAC,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FieldValues, type SubmitHandler, type UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
export type FormProps<FormValues extends FieldValues = FieldValues> = React.ComponentProps<typeof View> & {
|
|
4
|
+
form: UseFormReturn<FormValues>;
|
|
5
|
+
onSubmit?: SubmitHandler<FormValues>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* React Native has no `<form>`, so the root shares a submit action:
|
|
9
|
+
* `Form.Button` and the return key in `Form.Input` call it, like a submit
|
|
10
|
+
* button and Enter on the web.
|
|
11
|
+
*/
|
|
12
|
+
export declare function FormRoot<FormValues extends FieldValues = FieldValues>({ className, form, onSubmit, ...props }: FormProps<FormValues>): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=FormRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormRoot.d.ts","sourceRoot":"","sources":["../../../src/components/form/FormRoot.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKpC,MAAM,MAAM,SAAS,CAAC,UAAU,SAAS,WAAW,GAAG,WAAW,IAChE,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG;IAClC,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACtC,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,UAAU,SAAS,WAAW,GAAG,WAAW,EAAE,EACrE,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,SAAS,CAAC,UAAU,CAAC,+BAYvB"}
|