@serendie/ui 3.3.0-dev.202605131151 → 3.3.0-dev.202605200751
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 +5 -1
- package/dist/client.js +35 -32
- package/dist/components/Steps/Steps.d.ts +128 -0
- package/dist/components/Steps/Steps.js +335 -0
- package/dist/components/Steps/index.d.ts +2 -0
- package/dist/components/Steps/index.js +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -40
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-completed-content.js +16 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-content.js +17 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-context.js +9 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-indicator.js +17 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-item-context.js +6 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-item.js +25 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-list.js +16 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-next-trigger.js +16 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-prev-trigger.js +16 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-progress.js +16 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-root-provider.js +21 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-root.js +34 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-separator.js +17 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps-trigger.js +17 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/steps.js +34 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/use-steps-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/use-steps-item-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/use-steps-item-props-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/steps/use-steps.js +19 -0
- package/dist/node_modules/@zag-js/steps/dist/steps.anatomy.js +17 -0
- package/dist/node_modules/@zag-js/steps/dist/steps.connect.js +173 -0
- package/dist/node_modules/@zag-js/steps/dist/steps.dom.js +19 -0
- package/dist/node_modules/@zag-js/steps/dist/steps.machine.js +119 -0
- package/dist/node_modules/@zag-js/utils/dist/array.js +24 -23
- package/dist/styles.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { dataAttr as n } from "../../dom-query/dist/shared.js";
|
|
2
|
+
import { parts as a } from "./steps.anatomy.js";
|
|
3
|
+
import { getTriggerId as v, getListId as h, getRootId as C, getContentId as N } from "./steps.dom.js";
|
|
4
|
+
import { fromLength as V } from "../../utils/dist/array.js";
|
|
5
|
+
function j(I, i) {
|
|
6
|
+
const { context: f, send: d, computed: p, prop: r, scope: c } = I, l = f.get("step"), g = r("count"), s = p("percent"), u = p("hasNextStep"), m = p("hasPrevStep"), S = (t) => {
|
|
7
|
+
var e;
|
|
8
|
+
return ((e = r("isStepValid")) == null ? void 0 : e(t)) ?? !0;
|
|
9
|
+
}, x = (t) => {
|
|
10
|
+
var e;
|
|
11
|
+
return ((e = r("isStepSkippable")) == null ? void 0 : e(t)) ?? !1;
|
|
12
|
+
}, o = (t) => ({
|
|
13
|
+
triggerId: v(c, t.index),
|
|
14
|
+
contentId: N(c, t.index),
|
|
15
|
+
current: t.index === l,
|
|
16
|
+
completed: t.index < l,
|
|
17
|
+
incomplete: t.index > l,
|
|
18
|
+
index: t.index,
|
|
19
|
+
first: t.index === 0,
|
|
20
|
+
last: t.index === g - 1,
|
|
21
|
+
skippable: x(t.index),
|
|
22
|
+
isValid: () => S(t.index)
|
|
23
|
+
}), P = () => {
|
|
24
|
+
d({ type: "STEP.NEXT", src: "next.trigger.click" });
|
|
25
|
+
}, b = () => {
|
|
26
|
+
d({ type: "STEP.PREV", src: "prev.trigger.click" });
|
|
27
|
+
}, k = () => {
|
|
28
|
+
d({ type: "STEP.RESET", src: "reset.trigger.click" });
|
|
29
|
+
}, E = (t) => {
|
|
30
|
+
d({ type: "STEP.SET", value: t, src: "api.setValue" });
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
value: l,
|
|
34
|
+
count: g,
|
|
35
|
+
percent: s,
|
|
36
|
+
hasNextStep: u,
|
|
37
|
+
hasPrevStep: m,
|
|
38
|
+
isCompleted: p("completed"),
|
|
39
|
+
isStepValid: S,
|
|
40
|
+
isStepSkippable: x,
|
|
41
|
+
goToNextStep: P,
|
|
42
|
+
goToPrevStep: b,
|
|
43
|
+
resetStep: k,
|
|
44
|
+
getItemState: o,
|
|
45
|
+
setStep: E,
|
|
46
|
+
getRootProps() {
|
|
47
|
+
return i.element({
|
|
48
|
+
...a.root.attrs,
|
|
49
|
+
id: C(c),
|
|
50
|
+
dir: r("dir"),
|
|
51
|
+
"data-orientation": r("orientation"),
|
|
52
|
+
style: {
|
|
53
|
+
"--percent": `${s}%`
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
getListProps() {
|
|
58
|
+
const e = V(g).map((T, y) => v(c, y));
|
|
59
|
+
return i.element({
|
|
60
|
+
...a.list.attrs,
|
|
61
|
+
dir: r("dir"),
|
|
62
|
+
id: h(c),
|
|
63
|
+
role: "tablist",
|
|
64
|
+
"aria-owns": e.join(" "),
|
|
65
|
+
"aria-orientation": r("orientation"),
|
|
66
|
+
"data-orientation": r("orientation")
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
getItemProps(t) {
|
|
70
|
+
const e = o(t);
|
|
71
|
+
return i.element({
|
|
72
|
+
...a.item.attrs,
|
|
73
|
+
dir: r("dir"),
|
|
74
|
+
"aria-current": e.current ? "step" : void 0,
|
|
75
|
+
"data-orientation": r("orientation"),
|
|
76
|
+
"data-skippable": n(e.skippable)
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
getTriggerProps(t) {
|
|
80
|
+
const e = o(t);
|
|
81
|
+
return i.button({
|
|
82
|
+
...a.trigger.attrs,
|
|
83
|
+
id: e.triggerId,
|
|
84
|
+
role: "tab",
|
|
85
|
+
dir: r("dir"),
|
|
86
|
+
tabIndex: !r("linear") || e.current ? 0 : -1,
|
|
87
|
+
"aria-selected": e.current,
|
|
88
|
+
"aria-controls": e.contentId,
|
|
89
|
+
"data-state": e.current ? "open" : "closed",
|
|
90
|
+
"data-orientation": r("orientation"),
|
|
91
|
+
"data-complete": n(e.completed),
|
|
92
|
+
"data-current": n(e.current),
|
|
93
|
+
"data-incomplete": n(e.incomplete),
|
|
94
|
+
onClick(T) {
|
|
95
|
+
T.defaultPrevented || r("linear") || d({ type: "STEP.SET", value: t.index, src: "trigger.click" });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
getContentProps(t) {
|
|
100
|
+
const e = o(t);
|
|
101
|
+
return i.element({
|
|
102
|
+
...a.content.attrs,
|
|
103
|
+
dir: r("dir"),
|
|
104
|
+
id: e.contentId,
|
|
105
|
+
role: "tabpanel",
|
|
106
|
+
tabIndex: 0,
|
|
107
|
+
hidden: !e.current,
|
|
108
|
+
"data-state": e.current ? "open" : "closed",
|
|
109
|
+
"data-orientation": r("orientation"),
|
|
110
|
+
"aria-labelledby": e.triggerId
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
getIndicatorProps(t) {
|
|
114
|
+
const e = o(t);
|
|
115
|
+
return i.element({
|
|
116
|
+
...a.indicator.attrs,
|
|
117
|
+
dir: r("dir"),
|
|
118
|
+
"aria-hidden": !0,
|
|
119
|
+
"data-complete": n(e.completed),
|
|
120
|
+
"data-current": n(e.current),
|
|
121
|
+
"data-incomplete": n(e.incomplete)
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
getSeparatorProps(t) {
|
|
125
|
+
const e = o(t);
|
|
126
|
+
return i.element({
|
|
127
|
+
...a.separator.attrs,
|
|
128
|
+
dir: r("dir"),
|
|
129
|
+
"data-orientation": r("orientation"),
|
|
130
|
+
"data-complete": n(e.completed),
|
|
131
|
+
"data-current": n(e.current),
|
|
132
|
+
"data-incomplete": n(e.incomplete)
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
getNextTriggerProps() {
|
|
136
|
+
return i.button({
|
|
137
|
+
...a.nextTrigger.attrs,
|
|
138
|
+
dir: r("dir"),
|
|
139
|
+
type: "button",
|
|
140
|
+
disabled: !u,
|
|
141
|
+
onClick(t) {
|
|
142
|
+
t.defaultPrevented || P();
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
getPrevTriggerProps() {
|
|
147
|
+
return i.button({
|
|
148
|
+
dir: r("dir"),
|
|
149
|
+
...a.prevTrigger.attrs,
|
|
150
|
+
type: "button",
|
|
151
|
+
disabled: !m,
|
|
152
|
+
onClick(t) {
|
|
153
|
+
t.defaultPrevented || b();
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
getProgressProps() {
|
|
158
|
+
return i.element({
|
|
159
|
+
dir: r("dir"),
|
|
160
|
+
...a.progress.attrs,
|
|
161
|
+
role: "progressbar",
|
|
162
|
+
"aria-valuenow": s,
|
|
163
|
+
"aria-valuemin": 0,
|
|
164
|
+
"aria-valuemax": 100,
|
|
165
|
+
"aria-valuetext": `${s}% complete`,
|
|
166
|
+
"data-complete": n(s === 100)
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export {
|
|
172
|
+
j as connect
|
|
173
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var i = (t) => {
|
|
2
|
+
var s;
|
|
3
|
+
return ((s = t.ids) == null ? void 0 : s.root) ?? `steps:${t.id}`;
|
|
4
|
+
}, r = (t) => {
|
|
5
|
+
var s;
|
|
6
|
+
return ((s = t.ids) == null ? void 0 : s.list) ?? `steps:${t.id}:list`;
|
|
7
|
+
}, g = (t, s) => {
|
|
8
|
+
var e, d;
|
|
9
|
+
return ((d = (e = t.ids) == null ? void 0 : e.triggerId) == null ? void 0 : d.call(e, s)) ?? `steps:${t.id}:trigger:${s}`;
|
|
10
|
+
}, o = (t, s) => {
|
|
11
|
+
var e, d;
|
|
12
|
+
return ((d = (e = t.ids) == null ? void 0 : e.contentId) == null ? void 0 : d.call(e, s)) ?? `steps:${t.id}:content:${s}`;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
o as getContentId,
|
|
16
|
+
r as getListId,
|
|
17
|
+
i as getRootId,
|
|
18
|
+
g as getTriggerId
|
|
19
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createMachine as o } from "../../core/dist/create-machine.js";
|
|
2
|
+
import { memo as p } from "../../core/dist/memo.js";
|
|
3
|
+
import { isValueWithinRange as r } from "../../utils/dist/number.js";
|
|
4
|
+
var c = o({
|
|
5
|
+
props({ props: t }) {
|
|
6
|
+
return {
|
|
7
|
+
defaultStep: 0,
|
|
8
|
+
count: 1,
|
|
9
|
+
linear: !1,
|
|
10
|
+
orientation: "horizontal",
|
|
11
|
+
...t
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
context({ prop: t, bindable: e }) {
|
|
15
|
+
return {
|
|
16
|
+
step: e(() => ({
|
|
17
|
+
defaultValue: t("defaultStep"),
|
|
18
|
+
value: t("step"),
|
|
19
|
+
onChange(n) {
|
|
20
|
+
var a, s;
|
|
21
|
+
(a = t("onStepChange")) == null || a({ step: n }), n == t("count") && ((s = t("onStepComplete")) == null || s());
|
|
22
|
+
}
|
|
23
|
+
}))
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
computed: {
|
|
27
|
+
percent: p(
|
|
28
|
+
({ context: t, prop: e }) => [t.get("step"), e("count")],
|
|
29
|
+
([t, e]) => t / e * 100
|
|
30
|
+
),
|
|
31
|
+
hasNextStep: ({ context: t, prop: e }) => t.get("step") < e("count"),
|
|
32
|
+
hasPrevStep: ({ context: t }) => t.get("step") > 0,
|
|
33
|
+
completed: ({ context: t, prop: e }) => t.get("step") === e("count")
|
|
34
|
+
},
|
|
35
|
+
initialState() {
|
|
36
|
+
return "idle";
|
|
37
|
+
},
|
|
38
|
+
entry: ["validateStepIndex"],
|
|
39
|
+
states: {
|
|
40
|
+
idle: {
|
|
41
|
+
on: {
|
|
42
|
+
"STEP.SET": [
|
|
43
|
+
{
|
|
44
|
+
guard: "isValidStepNavigation",
|
|
45
|
+
actions: ["setStep"]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
actions: ["invokeOnStepInvalid"]
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"STEP.NEXT": [
|
|
52
|
+
{
|
|
53
|
+
guard: "isCurrentStepValid",
|
|
54
|
+
actions: ["goToNextStep"]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
actions: ["invokeOnStepInvalid"]
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"STEP.PREV": {
|
|
61
|
+
actions: ["goToPrevStep"]
|
|
62
|
+
},
|
|
63
|
+
"STEP.RESET": {
|
|
64
|
+
actions: ["resetStep"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
implementations: {
|
|
70
|
+
guards: {
|
|
71
|
+
isCurrentStepValid({ context: t, prop: e }) {
|
|
72
|
+
var a;
|
|
73
|
+
const n = t.get("step");
|
|
74
|
+
if ((a = e("isStepSkippable")) != null && a(n)) return !0;
|
|
75
|
+
const i = e("isStepValid");
|
|
76
|
+
return i ? i(n) : !0;
|
|
77
|
+
},
|
|
78
|
+
isValidStepNavigation({ context: t, event: e, prop: n }) {
|
|
79
|
+
var s;
|
|
80
|
+
const i = t.get("step");
|
|
81
|
+
if (e.value <= i || (s = n("isStepSkippable")) != null && s(i)) return !0;
|
|
82
|
+
const a = n("isStepValid");
|
|
83
|
+
return a ? a(i) : !0;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
actions: {
|
|
87
|
+
goToNextStep({ context: t, prop: e }) {
|
|
88
|
+
const n = e("count");
|
|
89
|
+
t.set("step", Math.min(t.get("step") + 1, n));
|
|
90
|
+
},
|
|
91
|
+
goToPrevStep({ context: t }) {
|
|
92
|
+
t.set("step", Math.max(t.get("step") - 1, 0));
|
|
93
|
+
},
|
|
94
|
+
resetStep({ context: t }) {
|
|
95
|
+
t.set("step", 0);
|
|
96
|
+
},
|
|
97
|
+
setStep({ context: t, event: e }) {
|
|
98
|
+
t.set("step", e.value);
|
|
99
|
+
},
|
|
100
|
+
validateStepIndex({ context: t, prop: e }) {
|
|
101
|
+
S(e("count"), t.get("step"));
|
|
102
|
+
},
|
|
103
|
+
invokeOnStepInvalid({ context: t, event: e, prop: n }) {
|
|
104
|
+
var i;
|
|
105
|
+
(i = n("onStepInvalid")) == null || i({
|
|
106
|
+
step: t.get("step"),
|
|
107
|
+
action: e.type === "STEP.NEXT" ? "next" : "set",
|
|
108
|
+
targetStep: e.value
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}), S = (t, e) => {
|
|
114
|
+
if (!r(e, 0, t))
|
|
115
|
+
throw new RangeError(`[zag-js/steps] step index ${e} is out of bounds`);
|
|
116
|
+
};
|
|
117
|
+
export {
|
|
118
|
+
c as machine
|
|
119
|
+
};
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
function
|
|
1
|
+
function y(r) {
|
|
2
2
|
return r == null ? [] : Array.isArray(r) ? r : [r];
|
|
3
3
|
}
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
const { step:
|
|
7
|
-
return n === -1 ?
|
|
4
|
+
var d = (r) => Array.from(Array(r).keys()), A = (r) => r[0], s = (r) => r[r.length - 1], i = (r, n) => r.indexOf(n) !== -1, l = (r, ...n) => r.concat(n), p = (r, ...n) => r.filter((e) => !n.includes(e)), x = (r) => Array.from(new Set(r)), g = (r, n) => i(r, n) ? p(r, n) : l(r, n);
|
|
5
|
+
function c(r, n, e = {}) {
|
|
6
|
+
const { step: t = 1, loop: u = !0 } = e, o = n + t, a = r.length, f = a - 1;
|
|
7
|
+
return n === -1 ? t > 0 ? 0 : f : o < 0 ? u ? f : 0 : o >= a ? u ? 0 : n > a ? a : n : o;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return r[
|
|
9
|
+
function m(r, n, e = {}) {
|
|
10
|
+
return r[c(r, n, e)];
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const { step:
|
|
14
|
-
return
|
|
12
|
+
function h(r, n, e = {}) {
|
|
13
|
+
const { step: t = 1, loop: u = !0 } = e;
|
|
14
|
+
return c(r, n, { step: -t, loop: u });
|
|
15
15
|
}
|
|
16
|
-
function v(r, n,
|
|
17
|
-
return r[
|
|
16
|
+
function v(r, n, e = {}) {
|
|
17
|
+
return r[h(r, n, e)];
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return r.reduce((
|
|
19
|
+
function k(r, n) {
|
|
20
|
+
return r.reduce((e, t, u) => {
|
|
21
21
|
var o;
|
|
22
|
-
return u % n === 0 ?
|
|
22
|
+
return u % n === 0 ? e.push([t]) : (o = s(e)) == null || o.push(t), e;
|
|
23
23
|
}, []);
|
|
24
24
|
}
|
|
25
25
|
export {
|
|
26
26
|
l as add,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
g as addOrRemove,
|
|
28
|
+
k as chunk,
|
|
29
|
+
A as first,
|
|
30
|
+
d as fromLength,
|
|
30
31
|
i as has,
|
|
31
32
|
s as last,
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
m as next,
|
|
34
|
+
c as nextIndex,
|
|
34
35
|
v as prev,
|
|
35
|
-
|
|
36
|
+
h as prevIndex,
|
|
36
37
|
p as remove,
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
y as toArray,
|
|
39
|
+
x as uniq
|
|
39
40
|
};
|