@ark-ui/react 3.4.0-1 → 3.4.0
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/dist/components/checkbox/checkbox-hidden-input.cjs +3 -1
- package/dist/components/checkbox/checkbox-hidden-input.js +3 -1
- package/dist/components/checkbox/use-checkbox.cjs +10 -0
- package/dist/components/checkbox/use-checkbox.js +10 -0
- package/dist/components/color-picker/color-picker-hidden-input.cjs +3 -1
- package/dist/components/color-picker/color-picker-hidden-input.js +3 -1
- package/dist/components/color-picker/color-picker-root.cjs +1 -0
- package/dist/components/color-picker/color-picker-root.js +1 -0
- package/dist/components/color-picker/use-color-picker.cjs +9 -0
- package/dist/components/color-picker/use-color-picker.js +9 -0
- package/dist/components/combobox/combobox-input.cjs +3 -1
- package/dist/components/combobox/combobox-input.js +3 -1
- package/dist/components/combobox/combobox-root.cjs +1 -0
- package/dist/components/combobox/combobox-root.js +1 -0
- package/dist/components/combobox/use-combobox.cjs +10 -0
- package/dist/components/combobox/use-combobox.js +10 -0
- package/dist/components/dialog/dialog-description.d.cts +1 -1
- package/dist/components/dialog/dialog-description.d.ts +1 -1
- package/dist/components/editable/editable-input.cjs +3 -1
- package/dist/components/editable/editable-input.js +3 -1
- package/dist/components/editable/editable-root.cjs +1 -0
- package/dist/components/editable/editable-root.js +1 -0
- package/dist/components/editable/use-editable.cjs +10 -0
- package/dist/components/editable/use-editable.js +10 -0
- package/dist/components/field/field-context.cjs +10 -0
- package/dist/components/field/field-context.d.cts +7 -0
- package/dist/components/field/field-context.d.ts +7 -0
- package/dist/components/field/field-context.js +6 -0
- package/dist/components/field/field-error-text.cjs +22 -0
- package/dist/components/field/field-error-text.d.cts +8 -0
- package/dist/components/field/field-error-text.d.ts +8 -0
- package/dist/components/field/field-error-text.js +18 -0
- package/dist/components/field/field-helper-text.cjs +19 -0
- package/dist/components/field/field-helper-text.d.cts +8 -0
- package/dist/components/field/field-helper-text.d.ts +8 -0
- package/dist/components/field/field-helper-text.js +15 -0
- package/dist/components/field/field-input.cjs +19 -0
- package/dist/components/field/field-input.d.cts +8 -0
- package/dist/components/field/field-input.d.ts +8 -0
- package/dist/components/field/field-input.js +15 -0
- package/dist/components/field/field-label.cjs +19 -0
- package/dist/components/field/field-label.d.cts +8 -0
- package/dist/components/field/field-label.d.ts +8 -0
- package/dist/components/field/field-label.js +15 -0
- package/dist/components/field/field-root-provider.cjs +22 -0
- package/dist/components/field/field-root-provider.d.cts +13 -0
- package/dist/components/field/field-root-provider.d.ts +13 -0
- package/dist/components/field/field-root-provider.js +18 -0
- package/dist/components/field/field-root.cjs +29 -0
- package/dist/components/field/field-root.d.cts +9 -0
- package/dist/components/field/field-root.d.ts +9 -0
- package/dist/components/field/field-root.js +25 -0
- package/dist/components/field/field-select.cjs +19 -0
- package/dist/components/field/field-select.d.cts +8 -0
- package/dist/components/field/field-select.d.ts +8 -0
- package/dist/components/field/field-select.js +15 -0
- package/dist/components/field/field-textarea.cjs +19 -0
- package/dist/components/field/field-textarea.d.cts +8 -0
- package/dist/components/field/field-textarea.d.ts +8 -0
- package/dist/components/field/field-textarea.js +15 -0
- package/dist/components/field/field.cjs +25 -0
- package/dist/components/field/field.d.cts +9 -0
- package/dist/components/field/field.d.ts +9 -0
- package/dist/components/field/field.js +9 -0
- package/dist/components/field/index.cjs +29 -0
- package/dist/components/field/index.d.cts +11 -0
- package/dist/components/field/index.d.ts +11 -0
- package/dist/components/field/index.js +12 -0
- package/dist/components/field/use-field-context.cjs +16 -0
- package/dist/components/field/use-field-context.d.cts +6 -0
- package/dist/components/field/use-field-context.d.ts +6 -0
- package/dist/components/field/use-field-context.js +11 -0
- package/dist/components/field/use-field.cjs +110 -0
- package/dist/components/field/use-field.d.cts +100 -0
- package/dist/components/field/use-field.d.ts +100 -0
- package/dist/components/field/use-field.js +106 -0
- package/dist/components/file-upload/file-upload-hidden-input.cjs +3 -1
- package/dist/components/file-upload/file-upload-hidden-input.js +3 -1
- package/dist/components/file-upload/file-upload-root.cjs +1 -0
- package/dist/components/file-upload/file-upload-root.js +1 -0
- package/dist/components/file-upload/use-file-upload.cjs +8 -0
- package/dist/components/file-upload/use-file-upload.js +8 -0
- package/dist/components/index.cjs +24 -0
- package/dist/components/index.d.cts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +13 -0
- package/dist/components/menu/menu-checkbox-item.cjs +2 -2
- package/dist/components/menu/menu-checkbox-item.js +2 -2
- package/dist/components/menu/menu-radio-item.cjs +2 -2
- package/dist/components/menu/menu-radio-item.js +2 -2
- package/dist/components/number-input/number-input-input.cjs +3 -1
- package/dist/components/number-input/number-input-input.js +3 -1
- package/dist/components/number-input/number-input-root.cjs +1 -0
- package/dist/components/number-input/number-input-root.js +1 -0
- package/dist/components/number-input/use-number-input.cjs +10 -0
- package/dist/components/number-input/use-number-input.js +10 -0
- package/dist/components/pin-input/pin-input-hidden-input.cjs +3 -1
- package/dist/components/pin-input/pin-input-hidden-input.js +3 -1
- package/dist/components/pin-input/pin-input-root.cjs +2 -0
- package/dist/components/pin-input/pin-input-root.js +2 -0
- package/dist/components/pin-input/use-pin-input.cjs +10 -0
- package/dist/components/pin-input/use-pin-input.js +10 -0
- package/dist/components/popover/popover-description.d.cts +1 -1
- package/dist/components/popover/popover-description.d.ts +1 -1
- package/dist/components/portal/portal.cjs +8 -2
- package/dist/components/portal/portal.js +8 -2
- package/dist/components/rating-group/rating-group-hidden-input.cjs +3 -1
- package/dist/components/rating-group/rating-group-hidden-input.js +3 -1
- package/dist/components/rating-group/rating-group-root.cjs +1 -0
- package/dist/components/rating-group/rating-group-root.js +1 -0
- package/dist/components/rating-group/use-rating-group.cjs +9 -0
- package/dist/components/rating-group/use-rating-group.js +9 -0
- package/dist/components/select/select-hidden-select.cjs +3 -1
- package/dist/components/select/select-hidden-select.js +3 -1
- package/dist/components/select/select-root.cjs +1 -0
- package/dist/components/select/select-root.js +1 -0
- package/dist/components/select/use-select.cjs +10 -0
- package/dist/components/select/use-select.js +10 -0
- package/dist/components/signature-pad/index.cjs +2 -0
- package/dist/components/signature-pad/index.d.cts +1 -0
- package/dist/components/signature-pad/index.d.ts +1 -0
- package/dist/components/signature-pad/index.js +1 -0
- package/dist/components/signature-pad/signature-pad-hidden-input.cjs +25 -0
- package/dist/components/signature-pad/signature-pad-hidden-input.d.cts +10 -0
- package/dist/components/signature-pad/signature-pad-hidden-input.d.ts +10 -0
- package/dist/components/signature-pad/signature-pad-hidden-input.js +21 -0
- package/dist/components/signature-pad/signature-pad-root.cjs +4 -1
- package/dist/components/signature-pad/signature-pad-root.js +4 -1
- package/dist/components/signature-pad/signature-pad.cjs +2 -0
- package/dist/components/signature-pad/signature-pad.d.cts +1 -0
- package/dist/components/signature-pad/signature-pad.d.ts +1 -0
- package/dist/components/signature-pad/signature-pad.js +1 -0
- package/dist/components/signature-pad/use-signature-pad.cjs +9 -0
- package/dist/components/signature-pad/use-signature-pad.js +9 -0
- package/dist/components/switch/switch-hidden-input.cjs +3 -1
- package/dist/components/switch/switch-hidden-input.js +3 -1
- package/dist/components/switch/use-switch.cjs +10 -0
- package/dist/components/switch/use-switch.js +10 -0
- package/dist/components/tags-input/tags-input-hidden-input.cjs +3 -1
- package/dist/components/tags-input/tags-input-hidden-input.js +3 -1
- package/dist/components/tags-input/tags-input-root.cjs +1 -0
- package/dist/components/tags-input/tags-input-root.js +1 -0
- package/dist/components/tags-input/use-tags-input.cjs +10 -0
- package/dist/components/tags-input/use-tags-input.js +10 -0
- package/dist/index.cjs +24 -0
- package/dist/index.js +13 -0
- package/package.json +60 -49
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { HTMLProps } from '../factory';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface UseFieldProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Indicates whether the field is required.
|
|
8
|
+
*/
|
|
9
|
+
required?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Indicates whether the field is disabled.
|
|
12
|
+
*/
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Indicates whether the field is invalid.
|
|
16
|
+
*/
|
|
17
|
+
invalid?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates whether the field is read-only.
|
|
20
|
+
*/
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type UseFieldReturn = ReturnType<typeof useField>;
|
|
24
|
+
export declare const useField: (props: UseFieldProps) => {
|
|
25
|
+
ariaDescribedby: string;
|
|
26
|
+
ids: {
|
|
27
|
+
control: string;
|
|
28
|
+
label: string;
|
|
29
|
+
errorText: string;
|
|
30
|
+
helperText: string;
|
|
31
|
+
};
|
|
32
|
+
refs: {
|
|
33
|
+
rootRef: RefObject<HTMLDivElement>;
|
|
34
|
+
};
|
|
35
|
+
disabled: boolean;
|
|
36
|
+
invalid: boolean;
|
|
37
|
+
readOnly: boolean;
|
|
38
|
+
required: boolean;
|
|
39
|
+
getLabelProps: () => {
|
|
40
|
+
id: string;
|
|
41
|
+
'data-disabled': Booleanish;
|
|
42
|
+
'data-invalid': Booleanish;
|
|
43
|
+
'data-readonly': Booleanish;
|
|
44
|
+
htmlFor: string;
|
|
45
|
+
"data-scope": string;
|
|
46
|
+
"data-part": string;
|
|
47
|
+
};
|
|
48
|
+
getRootProps: () => {
|
|
49
|
+
role: string;
|
|
50
|
+
'data-disabled': Booleanish;
|
|
51
|
+
'data-invalid': Booleanish;
|
|
52
|
+
'data-readonly': Booleanish;
|
|
53
|
+
"data-scope": string;
|
|
54
|
+
"data-part": string;
|
|
55
|
+
};
|
|
56
|
+
getInputProps: () => {
|
|
57
|
+
"data-scope": string;
|
|
58
|
+
"data-part": string;
|
|
59
|
+
'aria-describedby': string | undefined;
|
|
60
|
+
'aria-invalid': boolean | undefined;
|
|
61
|
+
'aria-required': boolean | undefined;
|
|
62
|
+
'aria-readonly': boolean | undefined;
|
|
63
|
+
id: string;
|
|
64
|
+
required: boolean;
|
|
65
|
+
disabled: boolean;
|
|
66
|
+
readOnly: boolean;
|
|
67
|
+
};
|
|
68
|
+
getTextareaProps: () => {
|
|
69
|
+
"data-scope": string;
|
|
70
|
+
"data-part": string;
|
|
71
|
+
'aria-describedby': string | undefined;
|
|
72
|
+
'aria-invalid': boolean | undefined;
|
|
73
|
+
'aria-required': boolean | undefined;
|
|
74
|
+
'aria-readonly': boolean | undefined;
|
|
75
|
+
id: string;
|
|
76
|
+
required: boolean;
|
|
77
|
+
disabled: boolean;
|
|
78
|
+
readOnly: boolean;
|
|
79
|
+
};
|
|
80
|
+
getSelectProps: () => {
|
|
81
|
+
"data-scope": string;
|
|
82
|
+
"data-part": string;
|
|
83
|
+
'aria-describedby': string | undefined;
|
|
84
|
+
'aria-invalid': boolean | undefined;
|
|
85
|
+
'aria-required': boolean | undefined;
|
|
86
|
+
'aria-readonly': boolean | undefined;
|
|
87
|
+
id: string;
|
|
88
|
+
required: boolean;
|
|
89
|
+
disabled: boolean;
|
|
90
|
+
readOnly: boolean;
|
|
91
|
+
};
|
|
92
|
+
getHelperTextProps: () => {
|
|
93
|
+
"data-scope": string;
|
|
94
|
+
"data-part": string;
|
|
95
|
+
id: string;
|
|
96
|
+
};
|
|
97
|
+
getErrorTextProps: () => HTMLProps<"span">;
|
|
98
|
+
};
|
|
99
|
+
type Booleanish = boolean | 'true' | 'false';
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { HTMLProps } from '../factory';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface UseFieldProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Indicates whether the field is required.
|
|
8
|
+
*/
|
|
9
|
+
required?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Indicates whether the field is disabled.
|
|
12
|
+
*/
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Indicates whether the field is invalid.
|
|
16
|
+
*/
|
|
17
|
+
invalid?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates whether the field is read-only.
|
|
20
|
+
*/
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type UseFieldReturn = ReturnType<typeof useField>;
|
|
24
|
+
export declare const useField: (props: UseFieldProps) => {
|
|
25
|
+
ariaDescribedby: string;
|
|
26
|
+
ids: {
|
|
27
|
+
control: string;
|
|
28
|
+
label: string;
|
|
29
|
+
errorText: string;
|
|
30
|
+
helperText: string;
|
|
31
|
+
};
|
|
32
|
+
refs: {
|
|
33
|
+
rootRef: RefObject<HTMLDivElement>;
|
|
34
|
+
};
|
|
35
|
+
disabled: boolean;
|
|
36
|
+
invalid: boolean;
|
|
37
|
+
readOnly: boolean;
|
|
38
|
+
required: boolean;
|
|
39
|
+
getLabelProps: () => {
|
|
40
|
+
id: string;
|
|
41
|
+
'data-disabled': Booleanish;
|
|
42
|
+
'data-invalid': Booleanish;
|
|
43
|
+
'data-readonly': Booleanish;
|
|
44
|
+
htmlFor: string;
|
|
45
|
+
"data-scope": string;
|
|
46
|
+
"data-part": string;
|
|
47
|
+
};
|
|
48
|
+
getRootProps: () => {
|
|
49
|
+
role: string;
|
|
50
|
+
'data-disabled': Booleanish;
|
|
51
|
+
'data-invalid': Booleanish;
|
|
52
|
+
'data-readonly': Booleanish;
|
|
53
|
+
"data-scope": string;
|
|
54
|
+
"data-part": string;
|
|
55
|
+
};
|
|
56
|
+
getInputProps: () => {
|
|
57
|
+
"data-scope": string;
|
|
58
|
+
"data-part": string;
|
|
59
|
+
'aria-describedby': string | undefined;
|
|
60
|
+
'aria-invalid': boolean | undefined;
|
|
61
|
+
'aria-required': boolean | undefined;
|
|
62
|
+
'aria-readonly': boolean | undefined;
|
|
63
|
+
id: string;
|
|
64
|
+
required: boolean;
|
|
65
|
+
disabled: boolean;
|
|
66
|
+
readOnly: boolean;
|
|
67
|
+
};
|
|
68
|
+
getTextareaProps: () => {
|
|
69
|
+
"data-scope": string;
|
|
70
|
+
"data-part": string;
|
|
71
|
+
'aria-describedby': string | undefined;
|
|
72
|
+
'aria-invalid': boolean | undefined;
|
|
73
|
+
'aria-required': boolean | undefined;
|
|
74
|
+
'aria-readonly': boolean | undefined;
|
|
75
|
+
id: string;
|
|
76
|
+
required: boolean;
|
|
77
|
+
disabled: boolean;
|
|
78
|
+
readOnly: boolean;
|
|
79
|
+
};
|
|
80
|
+
getSelectProps: () => {
|
|
81
|
+
"data-scope": string;
|
|
82
|
+
"data-part": string;
|
|
83
|
+
'aria-describedby': string | undefined;
|
|
84
|
+
'aria-invalid': boolean | undefined;
|
|
85
|
+
'aria-required': boolean | undefined;
|
|
86
|
+
'aria-readonly': boolean | undefined;
|
|
87
|
+
id: string;
|
|
88
|
+
required: boolean;
|
|
89
|
+
disabled: boolean;
|
|
90
|
+
readOnly: boolean;
|
|
91
|
+
};
|
|
92
|
+
getHelperTextProps: () => {
|
|
93
|
+
"data-scope": string;
|
|
94
|
+
"data-part": string;
|
|
95
|
+
id: string;
|
|
96
|
+
};
|
|
97
|
+
getErrorTextProps: () => HTMLProps<"span">;
|
|
98
|
+
};
|
|
99
|
+
type Booleanish = boolean | 'true' | 'false';
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { fieldAnatomy } from '@ark-ui/anatomy';
|
|
3
|
+
import { getWindow } from '@zag-js/dom-query';
|
|
4
|
+
import { useState, useId, useRef, useLayoutEffect } from 'react';
|
|
5
|
+
|
|
6
|
+
const parts = fieldAnatomy.build();
|
|
7
|
+
const useField = (props) => {
|
|
8
|
+
const { required = false, disabled = false, invalid = false, readOnly = false } = props;
|
|
9
|
+
const [hasErrorText, setHasErrorText] = useState(false);
|
|
10
|
+
const [hasHelperText, setHasHelperText] = useState(false);
|
|
11
|
+
const id = props.id ?? useId();
|
|
12
|
+
const rootRef = useRef(null);
|
|
13
|
+
const errorTextId = `field::${id}::error-text`;
|
|
14
|
+
const helperTextId = `field::${id}::helper-text`;
|
|
15
|
+
const labelId = `field::${id}::label`;
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
const rootNode = rootRef.current;
|
|
18
|
+
if (!rootNode) return;
|
|
19
|
+
const win = getWindow(rootNode);
|
|
20
|
+
const doc = win.document;
|
|
21
|
+
const checkTextElements = () => {
|
|
22
|
+
setHasErrorText(!!doc.getElementById(errorTextId));
|
|
23
|
+
setHasHelperText(!!doc.getElementById(helperTextId));
|
|
24
|
+
};
|
|
25
|
+
checkTextElements();
|
|
26
|
+
const observer = new win.MutationObserver(checkTextElements);
|
|
27
|
+
observer.observe(rootNode, { childList: true, subtree: true });
|
|
28
|
+
return () => observer.disconnect();
|
|
29
|
+
}, [errorTextId, helperTextId]);
|
|
30
|
+
const getRootProps = () => ({
|
|
31
|
+
...parts.root.attrs,
|
|
32
|
+
role: "group",
|
|
33
|
+
"data-disabled": dataAttr(disabled),
|
|
34
|
+
"data-invalid": dataAttr(invalid),
|
|
35
|
+
"data-readonly": dataAttr(readOnly)
|
|
36
|
+
});
|
|
37
|
+
const getLabelProps = () => ({
|
|
38
|
+
...parts.label.attrs,
|
|
39
|
+
id: labelId,
|
|
40
|
+
"data-disabled": dataAttr(disabled),
|
|
41
|
+
"data-invalid": dataAttr(invalid),
|
|
42
|
+
"data-readonly": dataAttr(readOnly),
|
|
43
|
+
htmlFor: id
|
|
44
|
+
});
|
|
45
|
+
const labelIds = [];
|
|
46
|
+
if (hasErrorText && invalid) labelIds.push(errorTextId);
|
|
47
|
+
if (hasHelperText) labelIds.push(helperTextId);
|
|
48
|
+
const getControlProps = () => ({
|
|
49
|
+
"aria-describedby": labelIds.join(" ") || void 0,
|
|
50
|
+
"aria-invalid": ariaAttr(invalid),
|
|
51
|
+
"aria-required": ariaAttr(required),
|
|
52
|
+
"aria-readonly": ariaAttr(readOnly),
|
|
53
|
+
id,
|
|
54
|
+
required,
|
|
55
|
+
disabled,
|
|
56
|
+
readOnly
|
|
57
|
+
});
|
|
58
|
+
const getInputProps = () => ({
|
|
59
|
+
...getControlProps(),
|
|
60
|
+
...parts.input.attrs
|
|
61
|
+
});
|
|
62
|
+
const getTextareaProps = () => ({
|
|
63
|
+
...getControlProps(),
|
|
64
|
+
...parts.textarea.attrs
|
|
65
|
+
});
|
|
66
|
+
const getSelectProps = () => ({
|
|
67
|
+
...getControlProps(),
|
|
68
|
+
...parts.select.attrs
|
|
69
|
+
});
|
|
70
|
+
const getHelperTextProps = () => ({
|
|
71
|
+
id: helperTextId,
|
|
72
|
+
...parts.helperText.attrs
|
|
73
|
+
});
|
|
74
|
+
const getErrorTextProps = () => ({
|
|
75
|
+
id: errorTextId,
|
|
76
|
+
...parts.errorText.attrs,
|
|
77
|
+
"aria-live": "polite"
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
ariaDescribedby: labelIds.join(" "),
|
|
81
|
+
ids: {
|
|
82
|
+
control: id,
|
|
83
|
+
label: labelId,
|
|
84
|
+
errorText: errorTextId,
|
|
85
|
+
helperText: helperTextId
|
|
86
|
+
},
|
|
87
|
+
refs: {
|
|
88
|
+
rootRef
|
|
89
|
+
},
|
|
90
|
+
disabled,
|
|
91
|
+
invalid,
|
|
92
|
+
readOnly,
|
|
93
|
+
required,
|
|
94
|
+
getLabelProps,
|
|
95
|
+
getRootProps,
|
|
96
|
+
getInputProps,
|
|
97
|
+
getTextareaProps,
|
|
98
|
+
getSelectProps,
|
|
99
|
+
getHelperTextProps,
|
|
100
|
+
getErrorTextProps
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const dataAttr = (condition) => condition ? "" : void 0;
|
|
104
|
+
const ariaAttr = (condition) => condition ? true : void 0;
|
|
105
|
+
|
|
106
|
+
export { useField };
|
|
@@ -7,13 +7,15 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
const react$1 = require('@zag-js/react');
|
|
8
8
|
const react = require('react');
|
|
9
9
|
const factory = require('../factory.cjs');
|
|
10
|
+
const useFieldContext = require('../field/use-field-context.cjs');
|
|
10
11
|
const useFileUploadContext = require('./use-file-upload-context.cjs');
|
|
11
12
|
|
|
12
13
|
const FileUploadHiddenInput = react.forwardRef(
|
|
13
14
|
(props, ref) => {
|
|
14
15
|
const fileUpload = useFileUploadContext.useFileUploadContext();
|
|
15
16
|
const mergedProps = react$1.mergeProps(fileUpload.getHiddenInputProps(), props);
|
|
16
|
-
|
|
17
|
+
const field = useFieldContext.useFieldContext();
|
|
18
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.input, { "aria-describedby": field?.ariaDescribedby, ...mergedProps, ref });
|
|
17
19
|
}
|
|
18
20
|
);
|
|
19
21
|
FileUploadHiddenInput.displayName = "FileUploadHiddenInput";
|
|
@@ -3,13 +3,15 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { mergeProps } from '@zag-js/react';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { ark } from '../factory.js';
|
|
6
|
+
import { useFieldContext } from '../field/use-field-context.js';
|
|
6
7
|
import { useFileUploadContext } from './use-file-upload-context.js';
|
|
7
8
|
|
|
8
9
|
const FileUploadHiddenInput = forwardRef(
|
|
9
10
|
(props, ref) => {
|
|
10
11
|
const fileUpload = useFileUploadContext();
|
|
11
12
|
const mergedProps = mergeProps(fileUpload.getHiddenInputProps(), props);
|
|
12
|
-
|
|
13
|
+
const field = useFieldContext();
|
|
14
|
+
return /* @__PURE__ */ jsx(ark.input, { "aria-describedby": field?.ariaDescribedby, ...mergedProps, ref });
|
|
13
15
|
}
|
|
14
16
|
);
|
|
15
17
|
FileUploadHiddenInput.displayName = "FileUploadHiddenInput";
|
|
@@ -9,6 +9,7 @@ const react = require('react');
|
|
|
9
9
|
const useEnvironmentContext = require('../../providers/environment/use-environment-context.cjs');
|
|
10
10
|
const useLocaleContext = require('../../providers/locale/use-locale-context.cjs');
|
|
11
11
|
const useEvent = require('../../utils/use-event.cjs');
|
|
12
|
+
const useFieldContext = require('../field/use-field-context.cjs');
|
|
12
13
|
|
|
13
14
|
function _interopNamespaceDefault(e) {
|
|
14
15
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -32,9 +33,16 @@ const fileUpload__namespace = /*#__PURE__*/_interopNamespaceDefault(fileUpload);
|
|
|
32
33
|
const useFileUpload = (props = {}) => {
|
|
33
34
|
const { getRootNode } = useEnvironmentContext.useEnvironmentContext();
|
|
34
35
|
const { dir } = useLocaleContext.useLocaleContext();
|
|
36
|
+
const field = useFieldContext.useFieldContext();
|
|
35
37
|
const initialContext = {
|
|
36
38
|
id: react.useId(),
|
|
39
|
+
ids: {
|
|
40
|
+
label: field?.ids.label,
|
|
41
|
+
hiddenInput: field?.ids.control
|
|
42
|
+
},
|
|
37
43
|
dir,
|
|
44
|
+
disabled: field?.disabled,
|
|
45
|
+
required: field?.required,
|
|
38
46
|
getRootNode,
|
|
39
47
|
...props
|
|
40
48
|
};
|
|
@@ -5,13 +5,21 @@ import { useId } from 'react';
|
|
|
5
5
|
import { useEnvironmentContext } from '../../providers/environment/use-environment-context.js';
|
|
6
6
|
import { useLocaleContext } from '../../providers/locale/use-locale-context.js';
|
|
7
7
|
import { useEvent } from '../../utils/use-event.js';
|
|
8
|
+
import { useFieldContext } from '../field/use-field-context.js';
|
|
8
9
|
|
|
9
10
|
const useFileUpload = (props = {}) => {
|
|
10
11
|
const { getRootNode } = useEnvironmentContext();
|
|
11
12
|
const { dir } = useLocaleContext();
|
|
13
|
+
const field = useFieldContext();
|
|
12
14
|
const initialContext = {
|
|
13
15
|
id: useId(),
|
|
16
|
+
ids: {
|
|
17
|
+
label: field?.ids.label,
|
|
18
|
+
hiddenInput: field?.ids.control
|
|
19
|
+
},
|
|
14
20
|
dir,
|
|
21
|
+
disabled: field?.disabled,
|
|
22
|
+
required: field?.required,
|
|
15
23
|
getRootNode,
|
|
16
24
|
...props
|
|
17
25
|
};
|
|
@@ -178,6 +178,17 @@ const useEditable = require('./editable/use-editable.cjs');
|
|
|
178
178
|
const useEditableContext = require('./editable/use-editable-context.cjs');
|
|
179
179
|
const editable = require('./editable/editable.cjs');
|
|
180
180
|
const factory = require('./factory.cjs');
|
|
181
|
+
const fieldContext = require('./field/field-context.cjs');
|
|
182
|
+
const fieldErrorText = require('./field/field-error-text.cjs');
|
|
183
|
+
const fieldHelperText = require('./field/field-helper-text.cjs');
|
|
184
|
+
const fieldInput = require('./field/field-input.cjs');
|
|
185
|
+
const fieldLabel = require('./field/field-label.cjs');
|
|
186
|
+
const fieldSelect = require('./field/field-select.cjs');
|
|
187
|
+
const fieldRoot = require('./field/field-root.cjs');
|
|
188
|
+
const fieldRootProvider = require('./field/field-root-provider.cjs');
|
|
189
|
+
const fieldTextarea = require('./field/field-textarea.cjs');
|
|
190
|
+
const useFieldContext = require('./field/use-field-context.cjs');
|
|
191
|
+
const field = require('./field/field.cjs');
|
|
181
192
|
const fileUploadContext = require('./file-upload/file-upload-context.cjs');
|
|
182
193
|
const fileUploadDropzone = require('./file-upload/file-upload-dropzone.cjs');
|
|
183
194
|
const fileUploadHiddenInput = require('./file-upload/file-upload-hidden-input.cjs');
|
|
@@ -378,6 +389,7 @@ const signaturePadContext = require('./signature-pad/signature-pad-context.cjs')
|
|
|
378
389
|
const signaturePadControl = require('./signature-pad/signature-pad-control.cjs');
|
|
379
390
|
const signaturePadGuide = require('./signature-pad/signature-pad-guide.cjs');
|
|
380
391
|
const signaturePadLabel = require('./signature-pad/signature-pad-label.cjs');
|
|
392
|
+
const signaturePadHiddenInput = require('./signature-pad/signature-pad-hidden-input.cjs');
|
|
381
393
|
const signaturePadRoot = require('./signature-pad/signature-pad-root.cjs');
|
|
382
394
|
const signaturePadRootProvider = require('./signature-pad/signature-pad-root-provider.cjs');
|
|
383
395
|
const signaturePadSegment = require('./signature-pad/signature-pad-segment.cjs');
|
|
@@ -672,6 +684,17 @@ exports.useEditableContext = useEditableContext.useEditableContext;
|
|
|
672
684
|
exports.Editable = editable;
|
|
673
685
|
exports.ark = factory.ark;
|
|
674
686
|
exports.jsxFactory = factory.jsxFactory;
|
|
687
|
+
exports.FieldContext = fieldContext.FieldContext;
|
|
688
|
+
exports.FieldErrorText = fieldErrorText.FieldErrorText;
|
|
689
|
+
exports.FieldHelperText = fieldHelperText.FieldHelperText;
|
|
690
|
+
exports.FieldInput = fieldInput.FieldInput;
|
|
691
|
+
exports.FieldLabel = fieldLabel.FieldLabel;
|
|
692
|
+
exports.FieldSelect = fieldSelect.FieldSelect;
|
|
693
|
+
exports.FieldRoot = fieldRoot.FieldRoot;
|
|
694
|
+
exports.FieldRootProvider = fieldRootProvider.FieldRootProvider;
|
|
695
|
+
exports.FieldTextarea = fieldTextarea.FieldTextarea;
|
|
696
|
+
exports.useFieldContext = useFieldContext.useFieldContext;
|
|
697
|
+
exports.Field = field;
|
|
675
698
|
exports.FileUploadContext = fileUploadContext.FileUploadContext;
|
|
676
699
|
exports.FileUploadDropzone = fileUploadDropzone.FileUploadDropzone;
|
|
677
700
|
exports.FileUploadHiddenInput = fileUploadHiddenInput.FileUploadHiddenInput;
|
|
@@ -873,6 +896,7 @@ exports.SignaturePadContext = signaturePadContext.SignaturePadContext;
|
|
|
873
896
|
exports.SignaturePadControl = signaturePadControl.SignaturePadControl;
|
|
874
897
|
exports.SignaturePadGuide = signaturePadGuide.SignaturePadGuide;
|
|
875
898
|
exports.SignaturePadLabel = signaturePadLabel.SignaturePadLabel;
|
|
899
|
+
exports.SignaturePadHiddenInput = signaturePadHiddenInput.SignaturePadHiddenInput;
|
|
876
900
|
exports.SignaturePadRoot = signaturePadRoot.SignaturePadRoot;
|
|
877
901
|
exports.SignaturePadRootProvider = signaturePadRootProvider.SignaturePadRootProvider;
|
|
878
902
|
exports.SignaturePadSegment = signaturePadSegment.SignaturePadSegment;
|
package/dist/components/index.js
CHANGED
|
@@ -185,6 +185,18 @@ export { useEditableContext } from './editable/use-editable-context.js';
|
|
|
185
185
|
import * as editable from './editable/editable.js';
|
|
186
186
|
export { editable as Editable };
|
|
187
187
|
export { ark, jsxFactory } from './factory.js';
|
|
188
|
+
export { FieldContext } from './field/field-context.js';
|
|
189
|
+
export { FieldErrorText } from './field/field-error-text.js';
|
|
190
|
+
export { FieldHelperText } from './field/field-helper-text.js';
|
|
191
|
+
export { FieldInput } from './field/field-input.js';
|
|
192
|
+
export { FieldLabel } from './field/field-label.js';
|
|
193
|
+
export { FieldSelect } from './field/field-select.js';
|
|
194
|
+
export { FieldRoot } from './field/field-root.js';
|
|
195
|
+
export { FieldRootProvider } from './field/field-root-provider.js';
|
|
196
|
+
export { FieldTextarea } from './field/field-textarea.js';
|
|
197
|
+
export { useFieldContext } from './field/use-field-context.js';
|
|
198
|
+
import * as field from './field/field.js';
|
|
199
|
+
export { field as Field };
|
|
188
200
|
export { FileUploadContext } from './file-upload/file-upload-context.js';
|
|
189
201
|
export { FileUploadDropzone } from './file-upload/file-upload-dropzone.js';
|
|
190
202
|
export { FileUploadHiddenInput } from './file-upload/file-upload-hidden-input.js';
|
|
@@ -399,6 +411,7 @@ export { SignaturePadContext } from './signature-pad/signature-pad-context.js';
|
|
|
399
411
|
export { SignaturePadControl } from './signature-pad/signature-pad-control.js';
|
|
400
412
|
export { SignaturePadGuide } from './signature-pad/signature-pad-guide.js';
|
|
401
413
|
export { SignaturePadLabel } from './signature-pad/signature-pad-label.js';
|
|
414
|
+
export { SignaturePadHiddenInput } from './signature-pad/signature-pad-hidden-input.js';
|
|
402
415
|
export { SignaturePadRoot } from './signature-pad/signature-pad-root.js';
|
|
403
416
|
export { SignaturePadRootProvider } from './signature-pad/signature-pad-root-provider.js';
|
|
404
417
|
export { SignaturePadSegment } from './signature-pad/signature-pad-segment.js';
|
|
@@ -26,9 +26,9 @@ const MenuCheckboxItem = react.forwardRef((props, ref) => {
|
|
|
26
26
|
type: "checkbox"
|
|
27
27
|
};
|
|
28
28
|
const menu = useMenuContext.useMenuContext();
|
|
29
|
-
const item = menu.getOptionItemState(optionItemProps);
|
|
30
29
|
const mergedProps = react$1.mergeProps(menu.getOptionItemProps(optionItemProps), localProps);
|
|
31
|
-
|
|
30
|
+
const optionItemState = menu.getOptionItemState(optionItemProps);
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx(useMenuOptionItemPropsContext.MenuOptionItemPropsProvider, { value: optionItemProps, children: /* @__PURE__ */ jsxRuntime.jsx(useMenuItemContext.MenuItemProvider, { value: optionItemState, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref }) }) });
|
|
32
32
|
});
|
|
33
33
|
MenuCheckboxItem.displayName = "MenuCheckboxItem";
|
|
34
34
|
|
|
@@ -22,9 +22,9 @@ const MenuCheckboxItem = forwardRef((props, ref) => {
|
|
|
22
22
|
type: "checkbox"
|
|
23
23
|
};
|
|
24
24
|
const menu = useMenuContext();
|
|
25
|
-
const item = menu.getOptionItemState(optionItemProps);
|
|
26
25
|
const mergedProps = mergeProps(menu.getOptionItemProps(optionItemProps), localProps);
|
|
27
|
-
|
|
26
|
+
const optionItemState = menu.getOptionItemState(optionItemProps);
|
|
27
|
+
return /* @__PURE__ */ jsx(MenuOptionItemPropsProvider, { value: optionItemProps, children: /* @__PURE__ */ jsx(MenuItemProvider, { value: optionItemState, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref }) }) });
|
|
28
28
|
});
|
|
29
29
|
MenuCheckboxItem.displayName = "MenuCheckboxItem";
|
|
30
30
|
|
|
@@ -29,8 +29,8 @@ const MenuRadioItem = react.forwardRef((props, ref) => {
|
|
|
29
29
|
onCheckedChange: () => itemGroup.onValueChange?.({ value: partialItemProps.value })
|
|
30
30
|
};
|
|
31
31
|
const mergedProps = react$1.mergeProps(menu.getOptionItemProps(optionItemProps), localProps);
|
|
32
|
-
const
|
|
33
|
-
return /* @__PURE__ */ jsxRuntime.jsx(useMenuOptionItemPropsContext.MenuOptionItemPropsProvider, { value: optionItemProps, children: /* @__PURE__ */ jsxRuntime.jsx(useMenuItemContext.MenuItemProvider, { value:
|
|
32
|
+
const optionItemState = menu.getOptionItemState(optionItemProps);
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(useMenuOptionItemPropsContext.MenuOptionItemPropsProvider, { value: optionItemProps, children: /* @__PURE__ */ jsxRuntime.jsx(useMenuItemContext.MenuItemProvider, { value: optionItemState, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref }) }) });
|
|
34
34
|
});
|
|
35
35
|
MenuRadioItem.displayName = "MenuRadioItem";
|
|
36
36
|
|
|
@@ -25,8 +25,8 @@ const MenuRadioItem = forwardRef((props, ref) => {
|
|
|
25
25
|
onCheckedChange: () => itemGroup.onValueChange?.({ value: partialItemProps.value })
|
|
26
26
|
};
|
|
27
27
|
const mergedProps = mergeProps(menu.getOptionItemProps(optionItemProps), localProps);
|
|
28
|
-
const
|
|
29
|
-
return /* @__PURE__ */ jsx(MenuOptionItemPropsProvider, { value: optionItemProps, children: /* @__PURE__ */ jsx(MenuItemProvider, { value:
|
|
28
|
+
const optionItemState = menu.getOptionItemState(optionItemProps);
|
|
29
|
+
return /* @__PURE__ */ jsx(MenuOptionItemPropsProvider, { value: optionItemProps, children: /* @__PURE__ */ jsx(MenuItemProvider, { value: optionItemState, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref }) }) });
|
|
30
30
|
});
|
|
31
31
|
MenuRadioItem.displayName = "MenuRadioItem";
|
|
32
32
|
|
|
@@ -7,13 +7,15 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
const react$1 = require('@zag-js/react');
|
|
8
8
|
const react = require('react');
|
|
9
9
|
const factory = require('../factory.cjs');
|
|
10
|
+
const useFieldContext = require('../field/use-field-context.cjs');
|
|
10
11
|
const useNumberInputContext = require('./use-number-input-context.cjs');
|
|
11
12
|
|
|
12
13
|
const NumberInputInput = react.forwardRef(
|
|
13
14
|
(props, ref) => {
|
|
14
15
|
const numberInput = useNumberInputContext.useNumberInputContext();
|
|
15
16
|
const mergedProps = react$1.mergeProps(numberInput.getInputProps(), props);
|
|
16
|
-
|
|
17
|
+
const field = useFieldContext.useFieldContext();
|
|
18
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.input, { "aria-describedby": field?.ariaDescribedby, ...mergedProps, ref });
|
|
17
19
|
}
|
|
18
20
|
);
|
|
19
21
|
NumberInputInput.displayName = "NumberInputInput";
|
|
@@ -3,13 +3,15 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { mergeProps } from '@zag-js/react';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { ark } from '../factory.js';
|
|
6
|
+
import { useFieldContext } from '../field/use-field-context.js';
|
|
6
7
|
import { useNumberInputContext } from './use-number-input-context.js';
|
|
7
8
|
|
|
8
9
|
const NumberInputInput = forwardRef(
|
|
9
10
|
(props, ref) => {
|
|
10
11
|
const numberInput = useNumberInputContext();
|
|
11
12
|
const mergedProps = mergeProps(numberInput.getInputProps(), props);
|
|
12
|
-
|
|
13
|
+
const field = useFieldContext();
|
|
14
|
+
return /* @__PURE__ */ jsx(ark.input, { "aria-describedby": field?.ariaDescribedby, ...mergedProps, ref });
|
|
13
15
|
}
|
|
14
16
|
);
|
|
15
17
|
NumberInputInput.displayName = "NumberInputInput";
|
|
@@ -9,6 +9,7 @@ const react = require('react');
|
|
|
9
9
|
const useEnvironmentContext = require('../../providers/environment/use-environment-context.cjs');
|
|
10
10
|
const useLocaleContext = require('../../providers/locale/use-locale-context.cjs');
|
|
11
11
|
const useEvent = require('../../utils/use-event.cjs');
|
|
12
|
+
const useFieldContext = require('../field/use-field-context.cjs');
|
|
12
13
|
|
|
13
14
|
function _interopNamespaceDefault(e) {
|
|
14
15
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -32,8 +33,17 @@ const numberInput__namespace = /*#__PURE__*/_interopNamespaceDefault(numberInput
|
|
|
32
33
|
const useNumberInput = (props = {}) => {
|
|
33
34
|
const { getRootNode } = useEnvironmentContext.useEnvironmentContext();
|
|
34
35
|
const { dir } = useLocaleContext.useLocaleContext();
|
|
36
|
+
const field = useFieldContext.useFieldContext();
|
|
35
37
|
const initialContext = {
|
|
36
38
|
id: react.useId(),
|
|
39
|
+
ids: {
|
|
40
|
+
label: field?.ids.label,
|
|
41
|
+
input: field?.ids.control
|
|
42
|
+
},
|
|
43
|
+
disabled: field?.disabled,
|
|
44
|
+
readOnly: field?.readOnly,
|
|
45
|
+
required: field?.required,
|
|
46
|
+
invalid: field?.invalid,
|
|
37
47
|
dir,
|
|
38
48
|
getRootNode,
|
|
39
49
|
value: props.defaultValue,
|
|
@@ -5,12 +5,22 @@ import { useId } from 'react';
|
|
|
5
5
|
import { useEnvironmentContext } from '../../providers/environment/use-environment-context.js';
|
|
6
6
|
import { useLocaleContext } from '../../providers/locale/use-locale-context.js';
|
|
7
7
|
import { useEvent } from '../../utils/use-event.js';
|
|
8
|
+
import { useFieldContext } from '../field/use-field-context.js';
|
|
8
9
|
|
|
9
10
|
const useNumberInput = (props = {}) => {
|
|
10
11
|
const { getRootNode } = useEnvironmentContext();
|
|
11
12
|
const { dir } = useLocaleContext();
|
|
13
|
+
const field = useFieldContext();
|
|
12
14
|
const initialContext = {
|
|
13
15
|
id: useId(),
|
|
16
|
+
ids: {
|
|
17
|
+
label: field?.ids.label,
|
|
18
|
+
input: field?.ids.control
|
|
19
|
+
},
|
|
20
|
+
disabled: field?.disabled,
|
|
21
|
+
readOnly: field?.readOnly,
|
|
22
|
+
required: field?.required,
|
|
23
|
+
invalid: field?.invalid,
|
|
14
24
|
dir,
|
|
15
25
|
getRootNode,
|
|
16
26
|
value: props.defaultValue,
|