@ark-ui/react 3.6.2 → 3.7.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/field/field-root.cjs +1 -0
- package/dist/components/field/field-root.js +1 -0
- package/dist/components/field/use-field.cjs +24 -20
- package/dist/components/field/use-field.d.cts +15 -0
- package/dist/components/field/use-field.d.ts +15 -0
- package/dist/components/field/use-field.js +19 -15
- package/dist/components/progress/progress-value-text.cjs +1 -1
- package/dist/components/progress/progress-value-text.js +1 -1
- package/dist/components/select/use-select.cjs +19 -13
- package/dist/components/select/use-select.js +20 -14
- package/dist/components/steps/index.cjs +37 -0
- package/dist/components/steps/index.d.cts +16 -0
- package/dist/components/steps/index.d.ts +16 -0
- package/dist/components/steps/index.js +16 -0
- package/dist/components/steps/steps-completed-content.cjs +21 -0
- package/dist/components/steps/steps-completed-content.d.cts +8 -0
- package/dist/components/steps/steps-completed-content.d.ts +8 -0
- package/dist/components/steps/steps-completed-content.js +17 -0
- package/dist/components/steps/steps-content.cjs +21 -0
- package/dist/components/steps/steps-content.d.cts +9 -0
- package/dist/components/steps/steps-content.d.ts +9 -0
- package/dist/components/steps/steps-content.js +17 -0
- package/dist/components/steps/steps-context.d.cts +10 -0
- package/dist/components/steps/steps-context.d.ts +10 -0
- package/dist/components/steps/steps-indicator.cjs +21 -0
- package/dist/components/steps/steps-indicator.d.cts +8 -0
- package/dist/components/steps/steps-indicator.d.ts +8 -0
- package/dist/components/steps/steps-indicator.js +17 -0
- package/dist/components/steps/steps-item.cjs +22 -0
- package/dist/components/steps/steps-item.d.cts +9 -0
- package/dist/components/steps/steps-item.d.ts +9 -0
- package/dist/components/steps/steps-item.js +18 -0
- package/dist/components/steps/steps-list.cjs +19 -0
- package/dist/components/steps/steps-list.d.cts +8 -0
- package/dist/components/steps/steps-list.d.ts +8 -0
- package/dist/components/steps/steps-list.js +15 -0
- package/dist/components/steps/steps-next-trigger.cjs +21 -0
- package/dist/components/steps/steps-next-trigger.d.cts +8 -0
- package/dist/components/steps/steps-next-trigger.d.ts +8 -0
- package/dist/components/steps/steps-next-trigger.js +17 -0
- package/dist/components/steps/steps-prev-trigger.cjs +21 -0
- package/dist/components/steps/steps-prev-trigger.d.cts +8 -0
- package/dist/components/steps/steps-prev-trigger.d.ts +8 -0
- package/dist/components/steps/steps-prev-trigger.js +17 -0
- package/dist/components/steps/steps-progress.cjs +19 -0
- package/dist/components/steps/steps-progress.d.cts +8 -0
- package/dist/components/steps/steps-progress.d.ts +8 -0
- package/dist/components/steps/steps-progress.js +15 -0
- package/dist/components/steps/steps-root-provider.cjs +22 -0
- package/dist/components/steps/steps-root-provider.d.cts +13 -0
- package/dist/components/steps/steps-root-provider.d.ts +13 -0
- package/dist/components/steps/steps-root-provider.js +18 -0
- package/dist/components/steps/steps-root.cjs +32 -0
- package/dist/components/steps/steps-root.d.cts +9 -0
- package/dist/components/steps/steps-root.d.ts +9 -0
- package/dist/components/steps/steps-root.js +28 -0
- package/dist/components/steps/steps-separator.cjs +21 -0
- package/dist/components/steps/steps-separator.d.cts +8 -0
- package/dist/components/steps/steps-separator.d.ts +8 -0
- package/dist/components/steps/steps-separator.js +17 -0
- package/dist/components/steps/steps-trigger.cjs +21 -0
- package/dist/components/steps/steps-trigger.d.cts +8 -0
- package/dist/components/steps/steps-trigger.d.ts +8 -0
- package/dist/components/steps/steps-trigger.js +17 -0
- package/dist/components/steps/steps.cjs +31 -0
- package/dist/components/steps/steps.d.cts +13 -0
- package/dist/components/steps/steps.d.ts +13 -0
- package/dist/components/steps/steps.js +12 -0
- package/dist/components/steps/use-steps-context.cjs +15 -0
- package/dist/components/steps/use-steps-context.d.cts +6 -0
- package/dist/components/steps/use-steps-context.d.ts +6 -0
- package/dist/components/steps/use-steps-context.js +10 -0
- package/dist/components/steps/use-steps-item-context.d.cts +7 -0
- package/dist/components/steps/use-steps-item-context.d.ts +7 -0
- package/dist/components/steps/use-steps-item-props-context.cjs +15 -0
- package/dist/components/steps/use-steps-item-props-context.d.cts +6 -0
- package/dist/components/steps/use-steps-item-props-context.d.ts +6 -0
- package/dist/components/steps/use-steps-item-props-context.js +10 -0
- package/dist/components/steps/use-steps.cjs +54 -0
- package/dist/components/steps/use-steps.d.cts +13 -0
- package/dist/components/steps/use-steps.d.ts +13 -0
- package/dist/components/steps/use-steps.js +31 -0
- package/dist/utils/use-safe-layout-effect.cjs +10 -0
- package/dist/utils/use-safe-layout-effect.d.cts +3 -0
- package/dist/utils/use-safe-layout-effect.d.ts +3 -0
- package/dist/utils/use-safe-layout-effect.js +6 -0
- package/package.json +65 -53
|
@@ -15,6 +15,7 @@ const useFieldContext = require('./use-field-context.cjs');
|
|
|
15
15
|
const FieldRoot = react.forwardRef((props, ref) => {
|
|
16
16
|
const [useFieldProps, localProps] = createSplitProps.createSplitProps()(props, [
|
|
17
17
|
"id",
|
|
18
|
+
"ids",
|
|
18
19
|
"disabled",
|
|
19
20
|
"invalid",
|
|
20
21
|
"readOnly",
|
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
|
|
6
6
|
const domQuery = require('@zag-js/dom-query');
|
|
7
7
|
const react = require('react');
|
|
8
|
+
const useSafeLayoutEffect = require('../../utils/use-safe-layout-effect.cjs');
|
|
8
9
|
const useFieldsetContext = require('../fieldset/use-fieldset-context.cjs');
|
|
9
10
|
const field_anatomy = require('./field.anatomy.cjs');
|
|
10
11
|
|
|
11
12
|
const useField = (props) => {
|
|
12
13
|
const fieldset = useFieldsetContext.useFieldsetContext();
|
|
13
14
|
const {
|
|
15
|
+
ids,
|
|
14
16
|
disabled = Boolean(fieldset?.disabled),
|
|
15
17
|
invalid = false,
|
|
16
18
|
readOnly = false,
|
|
@@ -20,10 +22,11 @@ const useField = (props) => {
|
|
|
20
22
|
const hasHelperText = react.useRef(false);
|
|
21
23
|
const id = props.id ?? react.useId();
|
|
22
24
|
const rootRef = react.useRef(null);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const rootId = ids?.control ?? `field::${id}`;
|
|
26
|
+
const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
|
|
27
|
+
const helperTextId = ids?.helperText ?? `field::${id}::helper-text`;
|
|
28
|
+
const labelId = ids?.label ?? `field::${id}::label`;
|
|
29
|
+
useSafeLayoutEffect.useSafeLayoutEffect(() => {
|
|
27
30
|
const rootNode = rootRef.current;
|
|
28
31
|
if (!rootNode) return;
|
|
29
32
|
const win = domQuery.getWindow(rootNode);
|
|
@@ -38,29 +41,30 @@ const useField = (props) => {
|
|
|
38
41
|
return () => observer.disconnect();
|
|
39
42
|
}, [errorTextId, helperTextId]);
|
|
40
43
|
const labelIds = react.useMemo(() => {
|
|
41
|
-
const
|
|
42
|
-
if (hasErrorText.current && invalid)
|
|
43
|
-
if (hasHelperText.current)
|
|
44
|
-
return
|
|
44
|
+
const ids2 = [];
|
|
45
|
+
if (hasErrorText.current && invalid) ids2.push(errorTextId);
|
|
46
|
+
if (hasHelperText.current) ids2.push(helperTextId);
|
|
47
|
+
return ids2.join(" ") || void 0;
|
|
45
48
|
}, [invalid, errorTextId, helperTextId]);
|
|
46
49
|
const getRootProps = react.useMemo(
|
|
47
50
|
() => () => ({
|
|
48
51
|
...field_anatomy.parts.root.attrs,
|
|
52
|
+
id: rootId,
|
|
49
53
|
ref: rootRef,
|
|
50
54
|
role: "group",
|
|
51
|
-
"data-disabled": dataAttr(disabled),
|
|
52
|
-
"data-invalid": dataAttr(invalid),
|
|
53
|
-
"data-readonly": dataAttr(readOnly)
|
|
55
|
+
"data-disabled": domQuery.dataAttr(disabled),
|
|
56
|
+
"data-invalid": domQuery.dataAttr(invalid),
|
|
57
|
+
"data-readonly": domQuery.dataAttr(readOnly)
|
|
54
58
|
}),
|
|
55
|
-
[disabled, invalid, readOnly]
|
|
59
|
+
[disabled, invalid, readOnly, rootId]
|
|
56
60
|
);
|
|
57
61
|
const getLabelProps = react.useMemo(
|
|
58
62
|
() => () => ({
|
|
59
63
|
...field_anatomy.parts.label.attrs,
|
|
60
64
|
id: labelId,
|
|
61
|
-
"data-disabled": dataAttr(disabled),
|
|
62
|
-
"data-invalid": dataAttr(invalid),
|
|
63
|
-
"data-readonly": dataAttr(readOnly),
|
|
65
|
+
"data-disabled": domQuery.dataAttr(disabled),
|
|
66
|
+
"data-invalid": domQuery.dataAttr(invalid),
|
|
67
|
+
"data-readonly": domQuery.dataAttr(readOnly),
|
|
64
68
|
htmlFor: id
|
|
65
69
|
}),
|
|
66
70
|
[disabled, invalid, readOnly, id, labelId]
|
|
@@ -68,9 +72,10 @@ const useField = (props) => {
|
|
|
68
72
|
const getControlProps = react.useMemo(
|
|
69
73
|
() => () => ({
|
|
70
74
|
"aria-describedby": labelIds,
|
|
71
|
-
"aria-invalid": ariaAttr(invalid),
|
|
72
|
-
"
|
|
73
|
-
"
|
|
75
|
+
"aria-invalid": domQuery.ariaAttr(invalid),
|
|
76
|
+
"data-invalid": domQuery.dataAttr(invalid),
|
|
77
|
+
"data-required": domQuery.dataAttr(required),
|
|
78
|
+
"data-readonly": domQuery.dataAttr(readOnly),
|
|
74
79
|
id,
|
|
75
80
|
required,
|
|
76
81
|
disabled,
|
|
@@ -117,6 +122,7 @@ const useField = (props) => {
|
|
|
117
122
|
return {
|
|
118
123
|
ariaDescribedby: labelIds,
|
|
119
124
|
ids: {
|
|
125
|
+
root: rootId,
|
|
120
126
|
control: id,
|
|
121
127
|
label: labelId,
|
|
122
128
|
errorText: errorTextId,
|
|
@@ -138,7 +144,5 @@ const useField = (props) => {
|
|
|
138
144
|
getErrorTextProps
|
|
139
145
|
};
|
|
140
146
|
};
|
|
141
|
-
const dataAttr = (condition) => condition ? "true" : void 0;
|
|
142
|
-
const ariaAttr = (condition) => condition ? true : void 0;
|
|
143
147
|
|
|
144
148
|
exports.useField = useField;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { HTMLProps } from '../factory';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
|
|
4
|
+
export interface ElementIds {
|
|
5
|
+
root?: string;
|
|
6
|
+
control?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
errorText?: string;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
}
|
|
4
11
|
export interface UseFieldProps {
|
|
12
|
+
/**
|
|
13
|
+
* The id of the field.
|
|
14
|
+
*/
|
|
5
15
|
id?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The ids of the field parts.
|
|
18
|
+
*/
|
|
19
|
+
ids?: ElementIds;
|
|
6
20
|
/**
|
|
7
21
|
* Indicates whether the field is required.
|
|
8
22
|
*/
|
|
@@ -24,6 +38,7 @@ export type UseFieldReturn = ReturnType<typeof useField>;
|
|
|
24
38
|
export declare const useField: (props: UseFieldProps) => {
|
|
25
39
|
ariaDescribedby: string | undefined;
|
|
26
40
|
ids: {
|
|
41
|
+
root: string;
|
|
27
42
|
control: string;
|
|
28
43
|
label: string;
|
|
29
44
|
errorText: string;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { HTMLProps } from '../factory';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
|
|
4
|
+
export interface ElementIds {
|
|
5
|
+
root?: string;
|
|
6
|
+
control?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
errorText?: string;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
}
|
|
4
11
|
export interface UseFieldProps {
|
|
12
|
+
/**
|
|
13
|
+
* The id of the field.
|
|
14
|
+
*/
|
|
5
15
|
id?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The ids of the field parts.
|
|
18
|
+
*/
|
|
19
|
+
ids?: ElementIds;
|
|
6
20
|
/**
|
|
7
21
|
* Indicates whether the field is required.
|
|
8
22
|
*/
|
|
@@ -24,6 +38,7 @@ export type UseFieldReturn = ReturnType<typeof useField>;
|
|
|
24
38
|
export declare const useField: (props: UseFieldProps) => {
|
|
25
39
|
ariaDescribedby: string | undefined;
|
|
26
40
|
ids: {
|
|
41
|
+
root: string;
|
|
27
42
|
control: string;
|
|
28
43
|
label: string;
|
|
29
44
|
errorText: string;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { getWindow } from '@zag-js/dom-query';
|
|
3
|
-
import { useRef, useId,
|
|
2
|
+
import { getWindow, dataAttr, ariaAttr } from '@zag-js/dom-query';
|
|
3
|
+
import { useRef, useId, useMemo } from 'react';
|
|
4
|
+
import { useSafeLayoutEffect } from '../../utils/use-safe-layout-effect.js';
|
|
4
5
|
import { useFieldsetContext } from '../fieldset/use-fieldset-context.js';
|
|
5
6
|
import { parts } from './field.anatomy.js';
|
|
6
7
|
|
|
7
8
|
const useField = (props) => {
|
|
8
9
|
const fieldset = useFieldsetContext();
|
|
9
10
|
const {
|
|
11
|
+
ids,
|
|
10
12
|
disabled = Boolean(fieldset?.disabled),
|
|
11
13
|
invalid = false,
|
|
12
14
|
readOnly = false,
|
|
@@ -16,10 +18,11 @@ const useField = (props) => {
|
|
|
16
18
|
const hasHelperText = useRef(false);
|
|
17
19
|
const id = props.id ?? useId();
|
|
18
20
|
const rootRef = useRef(null);
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const rootId = ids?.control ?? `field::${id}`;
|
|
22
|
+
const errorTextId = ids?.errorText ?? `field::${id}::error-text`;
|
|
23
|
+
const helperTextId = ids?.helperText ?? `field::${id}::helper-text`;
|
|
24
|
+
const labelId = ids?.label ?? `field::${id}::label`;
|
|
25
|
+
useSafeLayoutEffect(() => {
|
|
23
26
|
const rootNode = rootRef.current;
|
|
24
27
|
if (!rootNode) return;
|
|
25
28
|
const win = getWindow(rootNode);
|
|
@@ -34,21 +37,22 @@ const useField = (props) => {
|
|
|
34
37
|
return () => observer.disconnect();
|
|
35
38
|
}, [errorTextId, helperTextId]);
|
|
36
39
|
const labelIds = useMemo(() => {
|
|
37
|
-
const
|
|
38
|
-
if (hasErrorText.current && invalid)
|
|
39
|
-
if (hasHelperText.current)
|
|
40
|
-
return
|
|
40
|
+
const ids2 = [];
|
|
41
|
+
if (hasErrorText.current && invalid) ids2.push(errorTextId);
|
|
42
|
+
if (hasHelperText.current) ids2.push(helperTextId);
|
|
43
|
+
return ids2.join(" ") || void 0;
|
|
41
44
|
}, [invalid, errorTextId, helperTextId]);
|
|
42
45
|
const getRootProps = useMemo(
|
|
43
46
|
() => () => ({
|
|
44
47
|
...parts.root.attrs,
|
|
48
|
+
id: rootId,
|
|
45
49
|
ref: rootRef,
|
|
46
50
|
role: "group",
|
|
47
51
|
"data-disabled": dataAttr(disabled),
|
|
48
52
|
"data-invalid": dataAttr(invalid),
|
|
49
53
|
"data-readonly": dataAttr(readOnly)
|
|
50
54
|
}),
|
|
51
|
-
[disabled, invalid, readOnly]
|
|
55
|
+
[disabled, invalid, readOnly, rootId]
|
|
52
56
|
);
|
|
53
57
|
const getLabelProps = useMemo(
|
|
54
58
|
() => () => ({
|
|
@@ -65,8 +69,9 @@ const useField = (props) => {
|
|
|
65
69
|
() => () => ({
|
|
66
70
|
"aria-describedby": labelIds,
|
|
67
71
|
"aria-invalid": ariaAttr(invalid),
|
|
68
|
-
"
|
|
69
|
-
"
|
|
72
|
+
"data-invalid": dataAttr(invalid),
|
|
73
|
+
"data-required": dataAttr(required),
|
|
74
|
+
"data-readonly": dataAttr(readOnly),
|
|
70
75
|
id,
|
|
71
76
|
required,
|
|
72
77
|
disabled,
|
|
@@ -113,6 +118,7 @@ const useField = (props) => {
|
|
|
113
118
|
return {
|
|
114
119
|
ariaDescribedby: labelIds,
|
|
115
120
|
ids: {
|
|
121
|
+
root: rootId,
|
|
116
122
|
control: id,
|
|
117
123
|
label: labelId,
|
|
118
124
|
errorText: errorTextId,
|
|
@@ -134,7 +140,5 @@ const useField = (props) => {
|
|
|
134
140
|
getErrorTextProps
|
|
135
141
|
};
|
|
136
142
|
};
|
|
137
|
-
const dataAttr = (condition) => condition ? "true" : void 0;
|
|
138
|
-
const ariaAttr = (condition) => condition ? true : void 0;
|
|
139
143
|
|
|
140
144
|
export { useField };
|
|
@@ -14,7 +14,7 @@ const ProgressValueText = react.forwardRef(
|
|
|
14
14
|
const { children, ...rest } = props;
|
|
15
15
|
const progress = useProgressContext.useProgressContext();
|
|
16
16
|
const mergedProps = react$1.mergeProps(progress.getValueTextProps(), rest);
|
|
17
|
-
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.span, { ...mergedProps, ref, children: children || progress.
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.span, { ...mergedProps, ref, children: children || progress.percentAsString });
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
ProgressValueText.displayName = "ProgressValueText";
|
|
@@ -10,7 +10,7 @@ const ProgressValueText = forwardRef(
|
|
|
10
10
|
const { children, ...rest } = props;
|
|
11
11
|
const progress = useProgressContext();
|
|
12
12
|
const mergedProps = mergeProps(progress.getValueTextProps(), rest);
|
|
13
|
-
return /* @__PURE__ */ jsx(ark.span, { ...mergedProps, ref, children: children || progress.
|
|
13
|
+
return /* @__PURE__ */ jsx(ark.span, { ...mergedProps, ref, children: children || progress.percentAsString });
|
|
14
14
|
}
|
|
15
15
|
);
|
|
16
16
|
ProgressValueText.displayName = "ProgressValueText";
|
|
@@ -42,8 +42,8 @@ const useSelect = (props) => {
|
|
|
42
42
|
() => select__namespace.collection(collectionOptions),
|
|
43
43
|
Object.values(collectionOptions)
|
|
44
44
|
);
|
|
45
|
-
const
|
|
46
|
-
const
|
|
45
|
+
const locale = useLocaleContext.useLocaleContext();
|
|
46
|
+
const environment = useEnvironmentContext.useEnvironmentContext();
|
|
47
47
|
const field = useFieldContext.useFieldContext();
|
|
48
48
|
const initialContext = {
|
|
49
49
|
id: react.useId(),
|
|
@@ -55,26 +55,32 @@ const useSelect = (props) => {
|
|
|
55
55
|
readOnly: field?.readOnly,
|
|
56
56
|
invalid: field?.invalid,
|
|
57
57
|
required: field?.required,
|
|
58
|
-
dir,
|
|
59
|
-
getRootNode,
|
|
58
|
+
dir: locale.dir,
|
|
59
|
+
getRootNode: environment.getRootNode,
|
|
60
60
|
collection,
|
|
61
61
|
open: props.defaultOpen,
|
|
62
62
|
value: props.defaultValue,
|
|
63
63
|
"open.controlled": props.open !== void 0,
|
|
64
64
|
...selectProps
|
|
65
65
|
};
|
|
66
|
-
const context = {
|
|
67
|
-
...initialContext
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
const context = (() => {
|
|
67
|
+
const { collection: _, ...restProps } = initialContext;
|
|
68
|
+
return {
|
|
69
|
+
...restProps,
|
|
70
|
+
value: props.value,
|
|
71
|
+
onValueChange: useEvent.useEvent(props.onValueChange, { sync: true }),
|
|
72
|
+
onHighlightChange: useEvent.useEvent(props.onHighlightChange),
|
|
73
|
+
onOpenChange: useEvent.useEvent(props.onOpenChange)
|
|
74
|
+
};
|
|
75
|
+
})();
|
|
74
76
|
const [state, send] = react$1.useMachine(select__namespace.machine(initialContext), {
|
|
75
77
|
context
|
|
76
78
|
});
|
|
77
|
-
|
|
79
|
+
const api = select__namespace.connect(state, send, react$1.normalizeProps);
|
|
80
|
+
react.useEffect(() => {
|
|
81
|
+
api.setCollection(collection);
|
|
82
|
+
}, [collection]);
|
|
83
|
+
return api;
|
|
78
84
|
};
|
|
79
85
|
|
|
80
86
|
exports.useSelect = useSelect;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
3
3
|
import * as select from '@zag-js/select';
|
|
4
|
-
import { useMemo, useId } from 'react';
|
|
4
|
+
import { useMemo, useId, useEffect } 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 { createSplitProps } from '../../utils/create-split-props.js';
|
|
@@ -19,8 +19,8 @@ const useSelect = (props) => {
|
|
|
19
19
|
() => select.collection(collectionOptions),
|
|
20
20
|
Object.values(collectionOptions)
|
|
21
21
|
);
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
const locale = useLocaleContext();
|
|
23
|
+
const environment = useEnvironmentContext();
|
|
24
24
|
const field = useFieldContext();
|
|
25
25
|
const initialContext = {
|
|
26
26
|
id: useId(),
|
|
@@ -32,26 +32,32 @@ const useSelect = (props) => {
|
|
|
32
32
|
readOnly: field?.readOnly,
|
|
33
33
|
invalid: field?.invalid,
|
|
34
34
|
required: field?.required,
|
|
35
|
-
dir,
|
|
36
|
-
getRootNode,
|
|
35
|
+
dir: locale.dir,
|
|
36
|
+
getRootNode: environment.getRootNode,
|
|
37
37
|
collection,
|
|
38
38
|
open: props.defaultOpen,
|
|
39
39
|
value: props.defaultValue,
|
|
40
40
|
"open.controlled": props.open !== void 0,
|
|
41
41
|
...selectProps
|
|
42
42
|
};
|
|
43
|
-
const context = {
|
|
44
|
-
...initialContext
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
const context = (() => {
|
|
44
|
+
const { collection: _, ...restProps } = initialContext;
|
|
45
|
+
return {
|
|
46
|
+
...restProps,
|
|
47
|
+
value: props.value,
|
|
48
|
+
onValueChange: useEvent(props.onValueChange, { sync: true }),
|
|
49
|
+
onHighlightChange: useEvent(props.onHighlightChange),
|
|
50
|
+
onOpenChange: useEvent(props.onOpenChange)
|
|
51
|
+
};
|
|
52
|
+
})();
|
|
51
53
|
const [state, send] = useMachine(select.machine(initialContext), {
|
|
52
54
|
context
|
|
53
55
|
});
|
|
54
|
-
|
|
56
|
+
const api = select.connect(state, send, normalizeProps);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
api.setCollection(collection);
|
|
59
|
+
}, [collection]);
|
|
60
|
+
return api;
|
|
55
61
|
};
|
|
56
62
|
|
|
57
63
|
export { useSelect };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const stepsContent = require('./steps-content.cjs');
|
|
6
|
+
const stepsCompletedContent = require('./steps-completed-content.cjs');
|
|
7
|
+
const stepsIndicator = require('./steps-indicator.cjs');
|
|
8
|
+
const stepsItem = require('./steps-item.cjs');
|
|
9
|
+
const stepsList = require('./steps-list.cjs');
|
|
10
|
+
const stepsNextTrigger = require('./steps-next-trigger.cjs');
|
|
11
|
+
const stepsPrevTrigger = require('./steps-prev-trigger.cjs');
|
|
12
|
+
const stepsProgress = require('./steps-progress.cjs');
|
|
13
|
+
const stepsRoot = require('./steps-root.cjs');
|
|
14
|
+
const stepsRootProvider = require('./steps-root-provider.cjs');
|
|
15
|
+
const stepsSeparator = require('./steps-separator.cjs');
|
|
16
|
+
const stepsTrigger = require('./steps-trigger.cjs');
|
|
17
|
+
const useSteps = require('./use-steps.cjs');
|
|
18
|
+
const useStepsContext = require('./use-steps-context.cjs');
|
|
19
|
+
const steps = require('./steps.cjs');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
exports.StepsContent = stepsContent.StepsContent;
|
|
24
|
+
exports.StepsCompletedContent = stepsCompletedContent.StepsCompletedContent;
|
|
25
|
+
exports.StepsIndicator = stepsIndicator.StepsIndicator;
|
|
26
|
+
exports.StepsItem = stepsItem.StepsItem;
|
|
27
|
+
exports.StepsList = stepsList.StepsList;
|
|
28
|
+
exports.StepsNextTrigger = stepsNextTrigger.StepsNextTrigger;
|
|
29
|
+
exports.StepsPrevTrigger = stepsPrevTrigger.StepsPrevTrigger;
|
|
30
|
+
exports.StepsProgress = stepsProgress.StepsProgress;
|
|
31
|
+
exports.StepsRoot = stepsRoot.StepsRoot;
|
|
32
|
+
exports.StepsRootProvider = stepsRootProvider.StepsRootProvider;
|
|
33
|
+
exports.StepsSeparator = stepsSeparator.StepsSeparator;
|
|
34
|
+
exports.StepsTrigger = stepsTrigger.StepsTrigger;
|
|
35
|
+
exports.useSteps = useSteps.useSteps;
|
|
36
|
+
exports.useStepsContext = useStepsContext.useStepsContext;
|
|
37
|
+
exports.Steps = steps;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type { StepChangeDetails } from '@zag-js/steps';
|
|
2
|
+
export { StepsContent, type StepsContentBaseProps, type StepsContentProps } from './steps-content';
|
|
3
|
+
export { StepsCompletedContent, type StepsCompletedContentBaseProps, type StepsCompletedContentProps, } from './steps-completed-content';
|
|
4
|
+
export { StepsIndicator, type StepsIndicatorBaseProps, type StepsIndicatorProps, } from './steps-indicator';
|
|
5
|
+
export { StepsItem, type StepsItemBaseProps, type StepsItemProps } from './steps-item';
|
|
6
|
+
export { StepsList, type StepsListBaseProps, type StepsListProps } from './steps-list';
|
|
7
|
+
export { StepsNextTrigger, type StepsNextTriggerBaseProps, type StepsNextTriggerProps, } from './steps-next-trigger';
|
|
8
|
+
export { StepsPrevTrigger, type StepsPrevTriggerBaseProps, type StepsPrevTriggerProps, } from './steps-prev-trigger';
|
|
9
|
+
export { StepsProgress, type StepsProgressBaseProps, type StepsProgressProps, } from './steps-progress';
|
|
10
|
+
export { StepsRoot, type StepsRootBaseProps, type StepsRootProps } from './steps-root';
|
|
11
|
+
export { StepsRootProvider, type StepsRootProviderBaseProps, type StepsRootProviderProps, } from './steps-root-provider';
|
|
12
|
+
export { StepsSeparator, type StepsSeparatorBaseProps, type StepsSeparatorProps, } from './steps-separator';
|
|
13
|
+
export { StepsTrigger, type StepsTriggerBaseProps, type StepsTriggerProps } from './steps-trigger';
|
|
14
|
+
export { useSteps, type UseStepsProps, type UseStepsReturn } from './use-steps';
|
|
15
|
+
export { useStepsContext, type UseStepsContext } from './use-steps-context';
|
|
16
|
+
export * as Steps from './steps';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type { StepChangeDetails } from '@zag-js/steps';
|
|
2
|
+
export { StepsContent, type StepsContentBaseProps, type StepsContentProps } from './steps-content';
|
|
3
|
+
export { StepsCompletedContent, type StepsCompletedContentBaseProps, type StepsCompletedContentProps, } from './steps-completed-content';
|
|
4
|
+
export { StepsIndicator, type StepsIndicatorBaseProps, type StepsIndicatorProps, } from './steps-indicator';
|
|
5
|
+
export { StepsItem, type StepsItemBaseProps, type StepsItemProps } from './steps-item';
|
|
6
|
+
export { StepsList, type StepsListBaseProps, type StepsListProps } from './steps-list';
|
|
7
|
+
export { StepsNextTrigger, type StepsNextTriggerBaseProps, type StepsNextTriggerProps, } from './steps-next-trigger';
|
|
8
|
+
export { StepsPrevTrigger, type StepsPrevTriggerBaseProps, type StepsPrevTriggerProps, } from './steps-prev-trigger';
|
|
9
|
+
export { StepsProgress, type StepsProgressBaseProps, type StepsProgressProps, } from './steps-progress';
|
|
10
|
+
export { StepsRoot, type StepsRootBaseProps, type StepsRootProps } from './steps-root';
|
|
11
|
+
export { StepsRootProvider, type StepsRootProviderBaseProps, type StepsRootProviderProps, } from './steps-root-provider';
|
|
12
|
+
export { StepsSeparator, type StepsSeparatorBaseProps, type StepsSeparatorProps, } from './steps-separator';
|
|
13
|
+
export { StepsTrigger, type StepsTriggerBaseProps, type StepsTriggerProps } from './steps-trigger';
|
|
14
|
+
export { useSteps, type UseStepsProps, type UseStepsReturn } from './use-steps';
|
|
15
|
+
export { useStepsContext, type UseStepsContext } from './use-steps-context';
|
|
16
|
+
export * as Steps from './steps';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { StepsContent } from './steps-content.js';
|
|
2
|
+
export { StepsCompletedContent } from './steps-completed-content.js';
|
|
3
|
+
export { StepsIndicator } from './steps-indicator.js';
|
|
4
|
+
export { StepsItem } from './steps-item.js';
|
|
5
|
+
export { StepsList } from './steps-list.js';
|
|
6
|
+
export { StepsNextTrigger } from './steps-next-trigger.js';
|
|
7
|
+
export { StepsPrevTrigger } from './steps-prev-trigger.js';
|
|
8
|
+
export { StepsProgress } from './steps-progress.js';
|
|
9
|
+
export { StepsRoot } from './steps-root.js';
|
|
10
|
+
export { StepsRootProvider } from './steps-root-provider.js';
|
|
11
|
+
export { StepsSeparator } from './steps-separator.js';
|
|
12
|
+
export { StepsTrigger } from './steps-trigger.js';
|
|
13
|
+
export { useSteps } from './use-steps.js';
|
|
14
|
+
export { useStepsContext } from './use-steps-context.js';
|
|
15
|
+
import * as steps from './steps.js';
|
|
16
|
+
export { steps as Steps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const react$1 = require('@zag-js/react');
|
|
8
|
+
const react = require('react');
|
|
9
|
+
const factory = require('../factory.cjs');
|
|
10
|
+
const useStepsContext = require('./use-steps-context.cjs');
|
|
11
|
+
|
|
12
|
+
const StepsCompletedContent = react.forwardRef(
|
|
13
|
+
(props, ref) => {
|
|
14
|
+
const steps = useStepsContext.useStepsContext();
|
|
15
|
+
const mergedProps = react$1.mergeProps(steps.getContentProps({ index: steps.count }), props);
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
StepsCompletedContent.displayName = "StepsCompletedContent";
|
|
20
|
+
|
|
21
|
+
exports.StepsCompletedContent = StepsCompletedContent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTMLProps, PolymorphicProps } from '../factory';
|
|
2
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface StepsCompletedContentBaseProps extends PolymorphicProps {
|
|
5
|
+
}
|
|
6
|
+
export interface StepsCompletedContentProps extends HTMLProps<'div'>, StepsCompletedContentBaseProps {
|
|
7
|
+
}
|
|
8
|
+
export declare const StepsCompletedContent: ForwardRefExoticComponent<StepsCompletedContentProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTMLProps, PolymorphicProps } from '../factory';
|
|
2
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface StepsCompletedContentBaseProps extends PolymorphicProps {
|
|
5
|
+
}
|
|
6
|
+
export interface StepsCompletedContentProps extends HTMLProps<'div'>, StepsCompletedContentBaseProps {
|
|
7
|
+
}
|
|
8
|
+
export declare const StepsCompletedContent: ForwardRefExoticComponent<StepsCompletedContentProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { mergeProps } from '@zag-js/react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { ark } from '../factory.js';
|
|
6
|
+
import { useStepsContext } from './use-steps-context.js';
|
|
7
|
+
|
|
8
|
+
const StepsCompletedContent = forwardRef(
|
|
9
|
+
(props, ref) => {
|
|
10
|
+
const steps = useStepsContext();
|
|
11
|
+
const mergedProps = mergeProps(steps.getContentProps({ index: steps.count }), props);
|
|
12
|
+
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
StepsCompletedContent.displayName = "StepsCompletedContent";
|
|
16
|
+
|
|
17
|
+
export { StepsCompletedContent };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const react$1 = require('@zag-js/react');
|
|
8
|
+
const react = require('react');
|
|
9
|
+
const createSplitProps = require('../../utils/create-split-props.cjs');
|
|
10
|
+
const factory = require('../factory.cjs');
|
|
11
|
+
const useStepsContext = require('./use-steps-context.cjs');
|
|
12
|
+
|
|
13
|
+
const StepsContent = react.forwardRef((props, ref) => {
|
|
14
|
+
const [itemProps, localProps] = createSplitProps.createSplitProps()(props, ["index"]);
|
|
15
|
+
const steps = useStepsContext.useStepsContext();
|
|
16
|
+
const mergedProps = react$1.mergeProps(steps.getContentProps(itemProps), localProps);
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
|
|
18
|
+
});
|
|
19
|
+
StepsContent.displayName = "StepsContent";
|
|
20
|
+
|
|
21
|
+
exports.StepsContent = StepsContent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ItemProps } from '@zag-js/steps';
|
|
2
|
+
import { HTMLProps, PolymorphicProps } from '../factory';
|
|
3
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
export interface StepsContentBaseProps extends PolymorphicProps, ItemProps {
|
|
6
|
+
}
|
|
7
|
+
export interface StepsContentProps extends HTMLProps<'div'>, StepsContentBaseProps {
|
|
8
|
+
}
|
|
9
|
+
export declare const StepsContent: ForwardRefExoticComponent<StepsContentProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ItemProps } from '@zag-js/steps';
|
|
2
|
+
import { HTMLProps, PolymorphicProps } from '../factory';
|
|
3
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
export interface StepsContentBaseProps extends PolymorphicProps, ItemProps {
|
|
6
|
+
}
|
|
7
|
+
export interface StepsContentProps extends HTMLProps<'div'>, StepsContentBaseProps {
|
|
8
|
+
}
|
|
9
|
+
export declare const StepsContent: ForwardRefExoticComponent<StepsContentProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { mergeProps } from '@zag-js/react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { createSplitProps } from '../../utils/create-split-props.js';
|
|
6
|
+
import { ark } from '../factory.js';
|
|
7
|
+
import { useStepsContext } from './use-steps-context.js';
|
|
8
|
+
|
|
9
|
+
const StepsContent = forwardRef((props, ref) => {
|
|
10
|
+
const [itemProps, localProps] = createSplitProps()(props, ["index"]);
|
|
11
|
+
const steps = useStepsContext();
|
|
12
|
+
const mergedProps = mergeProps(steps.getContentProps(itemProps), localProps);
|
|
13
|
+
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
14
|
+
});
|
|
15
|
+
StepsContent.displayName = "StepsContent";
|
|
16
|
+
|
|
17
|
+
export { StepsContent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { UseStepsContext } from './use-steps-context';
|
|
3
|
+
|
|
4
|
+
export interface StepsContextProps {
|
|
5
|
+
children: (context: UseStepsContext) => ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const StepsContext: {
|
|
8
|
+
(props: StepsContextProps): ReactNode;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { UseStepsContext } from './use-steps-context';
|
|
3
|
+
|
|
4
|
+
export interface StepsContextProps {
|
|
5
|
+
children: (context: UseStepsContext) => ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const StepsContext: {
|
|
8
|
+
(props: StepsContextProps): ReactNode;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|