@serendie/ui 0.1.15 → 0.2.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/LICENSE +21 -0
- package/README.md +51 -9
- package/dist/components/{Accordion.d.ts → Accordion/Accordion.d.ts} +2 -2
- package/dist/components/{Accordion.js → Accordion/Accordion.js} +10 -10
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/AccordionGroup.js +4 -4
- package/dist/components/Avatar.js +4 -4
- package/dist/components/Badge.js +4 -4
- package/dist/components/Banner.js +4 -4
- package/dist/components/BottomNavigation.js +3 -3
- package/dist/components/BottomNavigationItem.js +4 -4
- package/dist/components/Button.js +10 -9
- package/dist/components/CheckBox.js +4 -4
- package/dist/components/ChoiceBox.js +10 -10
- package/dist/components/DashboardWidget.js +4 -4
- package/dist/components/Divider.js +4 -4
- package/dist/components/Drawer.js +4 -4
- package/dist/components/DropdownMenu.js +7 -6
- package/dist/components/IconButton.js +4 -4
- package/dist/components/ListItem.js +4 -4
- package/dist/components/ModalDialog.js +4 -4
- package/dist/components/NotificationBadge.js +4 -4
- package/dist/components/PasswordField.js +44 -0
- package/dist/components/ProgressIndicator.js +4 -4
- package/dist/components/RadioButton.js +4 -4
- package/dist/components/Search.js +6 -6
- package/dist/components/Select.js +4 -4
- package/dist/components/Switch.js +4 -4
- package/dist/components/TabItem.js +4 -4
- package/dist/components/Tabs.js +4 -4
- package/dist/components/TextArea.js +4 -4
- package/dist/components/TextField.js +4 -4
- package/dist/components/Toast.js +3 -3
- package/dist/components/TopAppBar.js +4 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +81 -79
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-content.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-indicator.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-trigger.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-root.js +2 -3
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-fallback.js +6 -7
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-image.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-root.js +2 -3
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-control.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-hidden-input.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-label.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-root.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/collapsible-content.js +8 -9
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/collapsible-root.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-content.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-control.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-input.js +6 -7
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item-group.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item-text.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-positioner.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-root.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-trigger.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-backdrop.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-close-trigger.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-content.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-description.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-positioner.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-root.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-title.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-content.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item-group.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item.js +2 -3
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-positioner.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-root.js +2 -3
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-trigger.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-control.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-hidden-input.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-text.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-root.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-content.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-control.js +6 -7
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-item.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-label.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-positioner.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-root.js +7 -7
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-trigger.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-value-text.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/select/use-select.js +35 -31
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-control.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-hidden-input.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-label.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-root.js +8 -9
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-thumb.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tab-list.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tab-trigger.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tabs-root.js +10 -10
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toast-root.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toast-title.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toaster.js +4 -4
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +361 -303
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +229 -216
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +19 -19
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +39 -38
- package/dist/node_modules/@serendie/design-token/dist/panda-tokens.js +823 -20
- package/dist/node_modules/@serendie/design-token/dist/tokens.js +346 -25
- package/dist/node_modules/@zag-js/accordion/dist/index.js +12 -12
- package/dist/node_modules/@zag-js/aria-hidden/dist/index.js +13 -62
- package/dist/node_modules/@zag-js/avatar/dist/index.js +12 -10
- package/dist/node_modules/@zag-js/checkbox/dist/index.js +99 -92
- package/dist/node_modules/@zag-js/collapsible/dist/index.js +5 -5
- package/dist/node_modules/@zag-js/collection/dist/index.js +21 -21
- package/dist/node_modules/@zag-js/combobox/dist/index.js +30 -31
- package/dist/node_modules/@zag-js/core/dist/index.js +285 -320
- package/dist/node_modules/@zag-js/dialog/dist/index.js +56 -62
- package/dist/node_modules/@zag-js/dismissable/dist/index.js +3 -3
- package/dist/node_modules/@zag-js/dom-event/dist/index.js +88 -115
- package/dist/node_modules/@zag-js/dom-query/dist/index.js +2 -2
- package/dist/node_modules/@zag-js/focus-visible/dist/index.js +73 -0
- package/dist/node_modules/@zag-js/interact-outside/dist/index.js +33 -33
- package/dist/node_modules/@zag-js/menu/dist/index.js +81 -77
- package/dist/node_modules/@zag-js/popper/dist/index.js +86 -79
- package/dist/node_modules/@zag-js/radio-group/dist/index.js +116 -109
- package/dist/node_modules/@zag-js/react/dist/index.js +44 -43
- package/dist/node_modules/@zag-js/select/dist/index.js +203 -231
- package/dist/node_modules/@zag-js/store/dist/index.js +110 -110
- package/dist/node_modules/@zag-js/switch/dist/index.js +62 -55
- package/dist/node_modules/@zag-js/tabs/dist/index.js +64 -61
- package/dist/node_modules/@zag-js/toast/dist/index.js +174 -173
- package/dist/node_modules/@zag-js/utils/dist/index.js +93 -71
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +52 -0
- package/dist/node_modules/focus-trap/dist/focus-trap.esm.js +217 -219
- package/dist/preset.d.ts +807 -4
- package/dist/{ui/styled-system → styled-system}/css/css.js +5 -6
- package/dist/{ui/styled-system → styled-system}/css/cva.js +4 -4
- package/dist/{ui/styled-system → styled-system}/css/sva.js +3 -3
- package/dist/styled-system/jsx/is-valid-prop.js +6 -0
- package/dist/styles.css +1 -1
- package/dist/tokens/getToken.d.ts +324 -3
- package/dist/tokens/index.d.ts +806 -3
- package/package.json +31 -5
- package/styled-system/css/css.js +1 -1
- package/styled-system/jsx/is-valid-prop.js +1 -1
- package/styled-system/themes/theme-asagi.json +1 -1
- package/styled-system/themes/theme-kurikawa.json +1 -1
- package/styled-system/themes/theme-sumire.json +1 -1
- package/styled-system/themes/theme-tsutsuji.json +1 -1
- package/styled-system/tokens/index.js +1238 -54
- package/styled-system/tokens/tokens.d.ts +3 -3
- package/styled-system/types/conditions.d.ts +2 -2
- package/styled-system/types/prop-type.d.ts +1 -1
- package/dist/ui/styled-system/jsx/is-valid-prop.js +0 -6
- /package/dist/{ui/styled-system → styled-system}/css/conditions.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/css/cx.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/helpers.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/jsx/box.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/jsx/factory-helper.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/jsx/factory.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/patterns/box.js +0 -0
|
@@ -1,156 +1,121 @@
|
|
|
1
|
-
import { snapshot as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
t.forEach(function(r) {
|
|
11
|
-
r == null || r(...s);
|
|
12
|
-
});
|
|
13
|
-
}, $ = /* @__PURE__ */ (() => {
|
|
14
|
-
let t = 0;
|
|
15
|
-
return () => (t++, t.toString(36));
|
|
16
|
-
})(), Q = () => process.env.NODE_ENV !== "production", w = (t) => Array.isArray(t), A = (t) => !(t == null || typeof t != "object" || w(t)), U = (t) => typeof t == "number" && !Number.isNaN(t), v = (t) => typeof t == "string", N = (t) => typeof t == "function", Y = (t, s) => Object.prototype.hasOwnProperty.call(t, s);
|
|
17
|
-
function D(t) {
|
|
18
|
-
if (!Z(t) || t === void 0)
|
|
19
|
-
return t;
|
|
20
|
-
const s = Reflect.ownKeys(t).filter((o) => typeof o == "string"), r = {};
|
|
21
|
-
for (const o of s) {
|
|
22
|
-
const u = t[o];
|
|
23
|
-
u !== void 0 && (r[o] = D(u));
|
|
1
|
+
import { snapshot as C, proxy as R, proxyWithComputed as V, subscribe as _, ref as P } from "../../store/dist/index.js";
|
|
2
|
+
import { callAll as q, isString as v, uuid as $, cast as m, isFunction as T, noop as B, isObject as M, runIfFn as F, invariant as b, clear as H, compact as j, isArray as N, hasProp as J, warn as w, isDev as X, isPlainObject as K, isNumber as Q } from "../../utils/dist/index.js";
|
|
3
|
+
import { klona as U } from "../../../klona/full/index.js";
|
|
4
|
+
var Y = Object.defineProperty, Z = (e, n, o) => n in e ? Y(e, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[n] = o, a = (e, n, o) => Z(e, typeof n != "symbol" ? n + "" : n, o);
|
|
5
|
+
function I(e, ...n) {
|
|
6
|
+
for (const o of n) {
|
|
7
|
+
const h = j(o);
|
|
8
|
+
for (const l in h)
|
|
9
|
+
K(o[l]) ? (e[l] || (e[l] = {}), I(e[l], o[l])) : e[l] = o[l];
|
|
24
10
|
}
|
|
25
|
-
return
|
|
11
|
+
return e;
|
|
26
12
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const s = t.length === 1 ? t[0] : t[1];
|
|
30
|
-
(t.length === 2 ? t[0] : !0) && process.env.NODE_ENV !== "production" && console.warn(s);
|
|
13
|
+
function O(e) {
|
|
14
|
+
return U(e);
|
|
31
15
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
if ((t.length === 2 ? t[0] : !0) && process.env.NODE_ENV !== "production")
|
|
35
|
-
throw new Error(s);
|
|
36
|
-
}
|
|
37
|
-
function z(t, ...s) {
|
|
38
|
-
for (const r of s) {
|
|
39
|
-
const o = D(r);
|
|
40
|
-
for (const u in o)
|
|
41
|
-
A(r[u]) ? (t[u] || (t[u] = {}), z(t[u], r[u])) : t[u] = r[u];
|
|
42
|
-
}
|
|
43
|
-
return t;
|
|
16
|
+
function g(e) {
|
|
17
|
+
return v(e) ? { type: e } : e;
|
|
44
18
|
}
|
|
45
|
-
function
|
|
46
|
-
return
|
|
19
|
+
function x(e) {
|
|
20
|
+
return e ? N(e) ? e.slice() : [e] : [];
|
|
47
21
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
function x(t) {
|
|
52
|
-
return t ? w(t) ? t.slice() : [t] : [];
|
|
53
|
-
}
|
|
54
|
-
function W(t) {
|
|
55
|
-
return A(t) && t.predicate != null;
|
|
22
|
+
function W(e) {
|
|
23
|
+
return M(e) && e.predicate != null;
|
|
56
24
|
}
|
|
57
25
|
var tt = () => !0;
|
|
58
|
-
function
|
|
59
|
-
return (
|
|
60
|
-
var
|
|
61
|
-
return v(
|
|
26
|
+
function L(e, n, o, h) {
|
|
27
|
+
return (l) => {
|
|
28
|
+
var f;
|
|
29
|
+
return v(l) ? !!((f = e[l]) != null && f.call(e, n, o, h)) : T(l) ? l(n, o, h) : l.predicate(e)(n, o, h);
|
|
62
30
|
};
|
|
63
31
|
}
|
|
64
|
-
function et(...
|
|
32
|
+
function et(...e) {
|
|
65
33
|
return {
|
|
66
|
-
predicate: (
|
|
34
|
+
predicate: (n) => (o, h, l) => e.map(L(n, o, h, l)).some(Boolean)
|
|
67
35
|
};
|
|
68
36
|
}
|
|
69
|
-
function it(...
|
|
37
|
+
function it(...e) {
|
|
70
38
|
return {
|
|
71
|
-
predicate: (
|
|
39
|
+
predicate: (n) => (o, h, l) => e.map(L(n, o, h, l)).every(Boolean)
|
|
72
40
|
};
|
|
73
41
|
}
|
|
74
|
-
function st(
|
|
42
|
+
function st(e) {
|
|
75
43
|
return {
|
|
76
|
-
predicate: (
|
|
44
|
+
predicate: (n) => (o, h, l) => !L(n, o, h, l)(e)
|
|
77
45
|
};
|
|
78
46
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (v(t)) {
|
|
86
|
-
const p = s[t];
|
|
87
|
-
return N(p) ? p(r, o, u) : p;
|
|
47
|
+
var vt = { or: et, and: it, not: st };
|
|
48
|
+
function G(e, n) {
|
|
49
|
+
return e = e ?? tt, (o, h, l) => {
|
|
50
|
+
if (v(e)) {
|
|
51
|
+
const f = n[e];
|
|
52
|
+
return T(f) ? f(o, h, l) : f;
|
|
88
53
|
}
|
|
89
|
-
return W(
|
|
54
|
+
return W(e) ? e.predicate(n)(o, h, l) : e == null ? void 0 : e(o, h, l);
|
|
90
55
|
};
|
|
91
56
|
}
|
|
92
|
-
function
|
|
93
|
-
return (
|
|
57
|
+
function D(e, n) {
|
|
58
|
+
return (o, h, l) => W(e) ? e.predicate(n)(o, h, l) : e;
|
|
94
59
|
}
|
|
95
|
-
function
|
|
96
|
-
var
|
|
97
|
-
const
|
|
98
|
-
value:
|
|
60
|
+
function nt(e) {
|
|
61
|
+
var f, S;
|
|
62
|
+
const n = e.computed ?? m({}), o = e.context ?? m({}), h = e.initial ? (S = (f = e.states) == null ? void 0 : f[e.initial]) == null ? void 0 : S.tags : [], l = R({
|
|
63
|
+
value: e.initial ?? "",
|
|
99
64
|
previousValue: "",
|
|
100
65
|
event: m({}),
|
|
101
66
|
previousEvent: m({}),
|
|
102
|
-
context:
|
|
67
|
+
context: V(o, n),
|
|
103
68
|
done: !1,
|
|
104
|
-
tags:
|
|
105
|
-
hasTag(
|
|
106
|
-
return this.tags.includes(
|
|
69
|
+
tags: h ?? [],
|
|
70
|
+
hasTag(t) {
|
|
71
|
+
return this.tags.includes(t);
|
|
107
72
|
},
|
|
108
|
-
matches(...
|
|
109
|
-
return
|
|
73
|
+
matches(...t) {
|
|
74
|
+
return t.includes(this.value);
|
|
110
75
|
},
|
|
111
|
-
can(
|
|
112
|
-
return m(this).nextEvents.includes(
|
|
76
|
+
can(t) {
|
|
77
|
+
return m(this).nextEvents.includes(t);
|
|
113
78
|
},
|
|
114
79
|
get nextEvents() {
|
|
115
|
-
var i,
|
|
116
|
-
const
|
|
117
|
-
return Object.keys({ ...
|
|
80
|
+
var i, r;
|
|
81
|
+
const t = ((r = (i = e.states) == null ? void 0 : i[this.value]) == null ? void 0 : r.on) ?? {}, s = (e == null ? void 0 : e.on) ?? {};
|
|
82
|
+
return Object.keys({ ...t, ...s });
|
|
118
83
|
},
|
|
119
84
|
get changed() {
|
|
120
85
|
return this.event.value === "machine.init" || !this.previousValue ? !1 : this.value !== this.previousValue;
|
|
121
86
|
}
|
|
122
87
|
});
|
|
123
|
-
return m(
|
|
88
|
+
return m(l);
|
|
124
89
|
}
|
|
125
|
-
function E(
|
|
126
|
-
return (
|
|
127
|
-
if (
|
|
128
|
-
if (
|
|
129
|
-
return
|
|
130
|
-
if (v(
|
|
131
|
-
const
|
|
132
|
-
if (!Number.isNaN(
|
|
133
|
-
return
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
90
|
+
function E(e, n) {
|
|
91
|
+
return (o, h) => {
|
|
92
|
+
if (Q(e)) return e;
|
|
93
|
+
if (T(e))
|
|
94
|
+
return e(o, h);
|
|
95
|
+
if (v(e)) {
|
|
96
|
+
const l = Number.parseFloat(e);
|
|
97
|
+
if (!Number.isNaN(l))
|
|
98
|
+
return l;
|
|
99
|
+
if (n) {
|
|
100
|
+
const f = n == null ? void 0 : n[e];
|
|
136
101
|
return b(
|
|
137
|
-
|
|
138
|
-
`[@zag-js/core > determine-delay] Cannot determine delay for \`${
|
|
139
|
-
),
|
|
102
|
+
f == null,
|
|
103
|
+
`[@zag-js/core > determine-delay] Cannot determine delay for \`${e}\`. It doesn't exist in \`options.delays\``
|
|
104
|
+
), T(f) ? f(o, h) : f;
|
|
140
105
|
}
|
|
141
106
|
}
|
|
142
107
|
};
|
|
143
108
|
}
|
|
144
|
-
function at(
|
|
145
|
-
return v(
|
|
109
|
+
function at(e) {
|
|
110
|
+
return v(e) ? { target: e } : e;
|
|
146
111
|
}
|
|
147
|
-
function
|
|
148
|
-
return (
|
|
112
|
+
function rt(e, n) {
|
|
113
|
+
return (o, h, l) => x(e).map(at).find((f) => G(f.guard, n)(o, h, l) ?? f.target ?? f.actions);
|
|
149
114
|
}
|
|
150
|
-
var
|
|
115
|
+
var k = class {
|
|
151
116
|
// Let's get started!
|
|
152
|
-
constructor(
|
|
153
|
-
var
|
|
117
|
+
constructor(e, n) {
|
|
118
|
+
var o, h, l, f, S;
|
|
154
119
|
a(
|
|
155
120
|
this,
|
|
156
121
|
"status",
|
|
@@ -161,21 +126,21 @@ var G = class {
|
|
|
161
126
|
"type",
|
|
162
127
|
"machine"
|
|
163
128
|
/* Machine */
|
|
164
|
-
), a(this, "activityEvents", /* @__PURE__ */ new Map()), a(this, "delayedEvents", /* @__PURE__ */ new Map()), a(this, "stateListeners", /* @__PURE__ */ new Set()), a(this, "doneListeners", /* @__PURE__ */ new Set()), a(this, "contextWatchers", /* @__PURE__ */ new Set()), a(this, "removeStateListener",
|
|
165
|
-
var
|
|
166
|
-
const
|
|
129
|
+
), a(this, "activityEvents", /* @__PURE__ */ new Map()), a(this, "delayedEvents", /* @__PURE__ */ new Map()), a(this, "stateListeners", /* @__PURE__ */ new Set()), a(this, "doneListeners", /* @__PURE__ */ new Set()), a(this, "contextWatchers", /* @__PURE__ */ new Set()), a(this, "removeStateListener", B), a(this, "parent"), a(this, "children", /* @__PURE__ */ new Map()), a(this, "guardMap"), a(this, "actionMap"), a(this, "delayMap"), a(this, "activityMap"), a(this, "sync"), a(this, "options"), a(this, "config"), a(this, "_created", () => {
|
|
130
|
+
var s;
|
|
131
|
+
const t = g(
|
|
167
132
|
"machine.created"
|
|
168
133
|
/* Created */
|
|
169
134
|
);
|
|
170
|
-
this.executeActions((
|
|
171
|
-
}), a(this, "start", (
|
|
135
|
+
this.executeActions((s = this.config) == null ? void 0 : s.created, t);
|
|
136
|
+
}), a(this, "start", (t) => {
|
|
172
137
|
if (this.state.value = "", this.state.tags = [], this.status === "Running")
|
|
173
138
|
return this;
|
|
174
|
-
this.status = "Running", this.removeStateListener =
|
|
139
|
+
this.status = "Running", this.removeStateListener = _(
|
|
175
140
|
this.state,
|
|
176
141
|
() => {
|
|
177
|
-
this.stateListeners.forEach((
|
|
178
|
-
|
|
142
|
+
this.stateListeners.forEach((d) => {
|
|
143
|
+
d(this.stateSnapshot);
|
|
179
144
|
});
|
|
180
145
|
},
|
|
181
146
|
this.sync
|
|
@@ -191,25 +156,25 @@ var G = class {
|
|
|
191
156
|
"machine.start"
|
|
192
157
|
/* Start */
|
|
193
158
|
));
|
|
194
|
-
const
|
|
159
|
+
const s = g(
|
|
195
160
|
"machine.init"
|
|
196
161
|
/* Init */
|
|
197
|
-
), i =
|
|
198
|
-
|
|
162
|
+
), i = M(t) ? t.value : t, r = M(t) ? t.context : void 0;
|
|
163
|
+
r && this.setContext(r);
|
|
199
164
|
const c = {
|
|
200
165
|
target: i ?? this.config.initial
|
|
201
|
-
},
|
|
202
|
-
return this.initialState =
|
|
166
|
+
}, u = this.getNextStateInfo(c, s);
|
|
167
|
+
return this.initialState = u, this.performStateChangeEffects(this.state.value, u, s), this;
|
|
203
168
|
}), a(this, "setupContextWatchers", () => {
|
|
204
|
-
const { watch:
|
|
205
|
-
if (!
|
|
206
|
-
let
|
|
207
|
-
const i =
|
|
169
|
+
const { watch: t } = this.config;
|
|
170
|
+
if (!t) return;
|
|
171
|
+
let s = C(this.state.context);
|
|
172
|
+
const i = _(this.state.context, () => {
|
|
208
173
|
var c;
|
|
209
|
-
const
|
|
210
|
-
for (const [
|
|
211
|
-
(((c = this.options.compareFns) == null ? void 0 : c[
|
|
212
|
-
|
|
174
|
+
const r = C(this.state.context);
|
|
175
|
+
for (const [u, d] of Object.entries(t))
|
|
176
|
+
(((c = this.options.compareFns) == null ? void 0 : c[u]) ?? Object.is)(s[u], r[u]) || this.executeActions(d, this.state.event);
|
|
177
|
+
s = r;
|
|
213
178
|
});
|
|
214
179
|
this.contextWatchers.add(i);
|
|
215
180
|
}), a(this, "stop", () => {
|
|
@@ -227,208 +192,208 @@ var G = class {
|
|
|
227
192
|
}), a(this, "stopStateListeners", () => {
|
|
228
193
|
this.removeStateListener(), this.stateListeners.clear();
|
|
229
194
|
}), a(this, "stopContextWatchers", () => {
|
|
230
|
-
this.contextWatchers.forEach((
|
|
195
|
+
this.contextWatchers.forEach((t) => t()), this.contextWatchers.clear();
|
|
231
196
|
}), a(this, "stopDelayedEvents", () => {
|
|
232
|
-
this.delayedEvents.forEach((
|
|
233
|
-
|
|
197
|
+
this.delayedEvents.forEach((t) => {
|
|
198
|
+
t.forEach((s) => s());
|
|
234
199
|
}), this.delayedEvents.clear();
|
|
235
|
-
}), a(this, "stopActivities", (
|
|
236
|
-
var
|
|
237
|
-
|
|
238
|
-
|
|
200
|
+
}), a(this, "stopActivities", (t) => {
|
|
201
|
+
var s, i;
|
|
202
|
+
t ? ((s = this.activityEvents.get(t)) == null || s.forEach((r) => r()), (i = this.activityEvents.get(t)) == null || i.clear(), this.activityEvents.delete(t)) : (this.activityEvents.forEach((r) => {
|
|
203
|
+
r.forEach((c) => c()), r.clear();
|
|
239
204
|
}), this.activityEvents.clear());
|
|
240
|
-
}), a(this, "sendChild", (
|
|
241
|
-
const i = g(
|
|
205
|
+
}), a(this, "sendChild", (t, s) => {
|
|
206
|
+
const i = g(t), r = F(s, this.contextSnapshot), c = this.children.get(r);
|
|
242
207
|
c || b(`[@zag-js/core] Cannot send '${i.type}' event to unknown child`), c.send(i);
|
|
243
|
-
}), a(this, "stopChild", (
|
|
244
|
-
this.children.has(
|
|
245
|
-
}), a(this, "removeChild", (
|
|
246
|
-
this.children.delete(
|
|
208
|
+
}), a(this, "stopChild", (t) => {
|
|
209
|
+
this.children.has(t) || b(`[@zag-js/core > stop-child] Cannot stop unknown child ${t}`), this.children.get(t).stop(), this.children.delete(t);
|
|
210
|
+
}), a(this, "removeChild", (t) => {
|
|
211
|
+
this.children.delete(t);
|
|
247
212
|
}), a(this, "stopChildren", () => {
|
|
248
|
-
this.children.forEach((
|
|
249
|
-
}), a(this, "setParent", (
|
|
250
|
-
this.parent =
|
|
251
|
-
}), a(this, "spawn", (
|
|
252
|
-
const i =
|
|
253
|
-
return
|
|
213
|
+
this.children.forEach((t) => t.stop()), this.children.clear();
|
|
214
|
+
}), a(this, "setParent", (t) => {
|
|
215
|
+
this.parent = t;
|
|
216
|
+
}), a(this, "spawn", (t, s) => {
|
|
217
|
+
const i = F(t);
|
|
218
|
+
return s && (i.id = s), i.type = "machine.actor", i.setParent(this), this.children.set(i.id, m(i)), i.onDone(() => {
|
|
254
219
|
this.removeChild(i.id);
|
|
255
|
-
}).start(), m(
|
|
256
|
-
}), a(this, "stopActivity", (
|
|
220
|
+
}).start(), m(P(i));
|
|
221
|
+
}), a(this, "stopActivity", (t) => {
|
|
257
222
|
var i;
|
|
258
223
|
if (!this.state.value) return;
|
|
259
|
-
const
|
|
260
|
-
(i =
|
|
261
|
-
}), a(this, "addActivityCleanup", (
|
|
262
|
-
var
|
|
263
|
-
|
|
264
|
-
}), a(this, "setState", (
|
|
265
|
-
this.state.previousValue = this.state.value, this.state.value =
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
}), a(this, "setContext", (
|
|
269
|
-
|
|
270
|
-
}), a(this, "setOptions", (
|
|
271
|
-
const
|
|
272
|
-
this.actionMap = { ...this.actionMap, ...
|
|
273
|
-
}), a(this, "getStateNode", (
|
|
274
|
-
var
|
|
275
|
-
if (
|
|
276
|
-
return (
|
|
277
|
-
}), a(this, "getNextStateInfo", (
|
|
278
|
-
const i = this.determineTransition(
|
|
279
|
-
reenter: !
|
|
224
|
+
const s = this.activityEvents.get(this.state.value);
|
|
225
|
+
(i = s == null ? void 0 : s.get(t)) == null || i(), s == null || s.delete(t);
|
|
226
|
+
}), a(this, "addActivityCleanup", (t, s, i) => {
|
|
227
|
+
var r;
|
|
228
|
+
t && (this.activityEvents.has(t) ? (r = this.activityEvents.get(t)) == null || r.set(s, i) : this.activityEvents.set(t, /* @__PURE__ */ new Map([[s, i]])));
|
|
229
|
+
}), a(this, "setState", (t) => {
|
|
230
|
+
this.state.previousValue = this.state.value, this.state.value = t;
|
|
231
|
+
const s = this.getStateNode(t);
|
|
232
|
+
t == null ? H(this.state.tags) : this.state.tags = x(s == null ? void 0 : s.tags);
|
|
233
|
+
}), a(this, "setContext", (t) => {
|
|
234
|
+
t && I(this.state.context, j(t));
|
|
235
|
+
}), a(this, "setOptions", (t) => {
|
|
236
|
+
const s = j(t);
|
|
237
|
+
this.actionMap = { ...this.actionMap, ...s.actions }, this.delayMap = { ...this.delayMap, ...s.delays }, this.activityMap = { ...this.activityMap, ...s.activities }, this.guardMap = { ...this.guardMap, ...s.guards };
|
|
238
|
+
}), a(this, "getStateNode", (t) => {
|
|
239
|
+
var s;
|
|
240
|
+
if (t)
|
|
241
|
+
return (s = this.config.states) == null ? void 0 : s[t];
|
|
242
|
+
}), a(this, "getNextStateInfo", (t, s) => {
|
|
243
|
+
const i = this.determineTransition(t, s), r = !(i != null && i.target), c = (i == null ? void 0 : i.target) ?? this.state.value, u = this.state.value !== c, d = this.getStateNode(c), y = {
|
|
244
|
+
reenter: !r && !u && !(i != null && i.internal),
|
|
280
245
|
transition: i,
|
|
281
|
-
stateNode:
|
|
246
|
+
stateNode: d,
|
|
282
247
|
target: c,
|
|
283
|
-
changed:
|
|
248
|
+
changed: u
|
|
284
249
|
};
|
|
285
|
-
return this.log("NextState:", `[${
|
|
286
|
-
}), a(this, "getAfterActions", (
|
|
250
|
+
return this.log("NextState:", `[${s.type}]`, this.state.value, "---->", y.target), y;
|
|
251
|
+
}), a(this, "getAfterActions", (t, s) => {
|
|
287
252
|
let i;
|
|
288
253
|
return {
|
|
289
254
|
entry: () => {
|
|
290
255
|
i = globalThis.setTimeout(() => {
|
|
291
|
-
const
|
|
292
|
-
this.performStateChangeEffects(this.state.value,
|
|
293
|
-
},
|
|
256
|
+
const r = this.getNextStateInfo(t, this.state.event);
|
|
257
|
+
this.performStateChangeEffects(this.state.value, r, this.state.event);
|
|
258
|
+
}, s);
|
|
294
259
|
},
|
|
295
260
|
exit: () => {
|
|
296
261
|
globalThis.clearTimeout(i);
|
|
297
262
|
}
|
|
298
263
|
};
|
|
299
|
-
}), a(this, "getDelayedEventActions", (
|
|
300
|
-
const
|
|
301
|
-
if (!
|
|
302
|
-
const
|
|
303
|
-
if (
|
|
304
|
-
const
|
|
305
|
-
if (!
|
|
306
|
-
if (!
|
|
307
|
-
throw new Error(`[@zag-js/core > after] Delay is required for after transition: ${JSON.stringify(
|
|
308
|
-
const
|
|
309
|
-
return
|
|
264
|
+
}), a(this, "getDelayedEventActions", (t) => {
|
|
265
|
+
const s = this.getStateNode(t), i = this.state.event;
|
|
266
|
+
if (!s || !s.after) return;
|
|
267
|
+
const r = [], c = [];
|
|
268
|
+
if (N(s.after)) {
|
|
269
|
+
const u = this.determineTransition(s.after, i);
|
|
270
|
+
if (!u) return;
|
|
271
|
+
if (!J(u, "delay"))
|
|
272
|
+
throw new Error(`[@zag-js/core > after] Delay is required for after transition: ${JSON.stringify(u)}`);
|
|
273
|
+
const p = E(u.delay, this.delayMap)(this.contextSnapshot, i), y = this.getAfterActions(u, p);
|
|
274
|
+
return r.push(y.entry), c.push(y.exit), { entries: r, exits: c };
|
|
310
275
|
}
|
|
311
|
-
if (
|
|
312
|
-
for (const
|
|
313
|
-
const
|
|
314
|
-
|
|
276
|
+
if (M(s.after))
|
|
277
|
+
for (const u in s.after) {
|
|
278
|
+
const d = s.after[u], y = E(u, this.delayMap)(this.contextSnapshot, i), A = this.getAfterActions(d, y);
|
|
279
|
+
r.push(A.entry), c.push(A.exit);
|
|
315
280
|
}
|
|
316
|
-
return { entries:
|
|
317
|
-
}), a(this, "executeActions", (
|
|
318
|
-
var
|
|
319
|
-
const i =
|
|
281
|
+
return { entries: r, exits: c };
|
|
282
|
+
}), a(this, "executeActions", (t, s) => {
|
|
283
|
+
var r;
|
|
284
|
+
const i = D(t, this.guardMap)(this.contextSnapshot, s, this.guardMeta);
|
|
320
285
|
for (const c of x(i)) {
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
v(c) && !
|
|
286
|
+
const u = v(c) ? (r = this.actionMap) == null ? void 0 : r[c] : c;
|
|
287
|
+
w(
|
|
288
|
+
v(c) && !u,
|
|
324
289
|
`[@zag-js/core > execute-actions] No implementation found for action: \`${c}\``
|
|
325
|
-
),
|
|
290
|
+
), u == null || u(this.state.context, s, this.meta);
|
|
326
291
|
}
|
|
327
|
-
}), a(this, "executeActivities", (
|
|
328
|
-
var
|
|
329
|
-
for (const c of
|
|
330
|
-
const
|
|
331
|
-
if (!
|
|
332
|
-
|
|
292
|
+
}), a(this, "executeActivities", (t, s, i) => {
|
|
293
|
+
var r;
|
|
294
|
+
for (const c of s) {
|
|
295
|
+
const u = v(c) ? (r = this.activityMap) == null ? void 0 : r[c] : c;
|
|
296
|
+
if (!u) {
|
|
297
|
+
w(`[@zag-js/core > execute-activity] No implementation found for activity: \`${c}\``);
|
|
333
298
|
continue;
|
|
334
299
|
}
|
|
335
|
-
const
|
|
336
|
-
if (
|
|
337
|
-
const
|
|
338
|
-
this.addActivityCleanup(i ?? this.state.value,
|
|
300
|
+
const d = u(this.state.context, t, this.meta);
|
|
301
|
+
if (d) {
|
|
302
|
+
const p = v(c) ? c : c.name || $();
|
|
303
|
+
this.addActivityCleanup(i ?? this.state.value, p, d);
|
|
339
304
|
}
|
|
340
305
|
}
|
|
341
|
-
}), a(this, "createEveryActivities", (
|
|
342
|
-
if (
|
|
343
|
-
if (
|
|
344
|
-
const i = x(
|
|
345
|
-
const
|
|
346
|
-
return
|
|
306
|
+
}), a(this, "createEveryActivities", (t, s) => {
|
|
307
|
+
if (t)
|
|
308
|
+
if (N(t)) {
|
|
309
|
+
const i = x(t).find((d) => {
|
|
310
|
+
const p = d.delay, A = E(p, this.delayMap)(this.contextSnapshot, this.state.event);
|
|
311
|
+
return G(d.guard, this.guardMap)(this.contextSnapshot, this.state.event, this.guardMeta) ?? A != null;
|
|
347
312
|
});
|
|
348
313
|
if (!i) return;
|
|
349
314
|
const c = E(i.delay, this.delayMap)(this.contextSnapshot, this.state.event);
|
|
350
|
-
|
|
351
|
-
const
|
|
315
|
+
s(() => {
|
|
316
|
+
const d = globalThis.setInterval(() => {
|
|
352
317
|
this.executeActions(i.actions, this.state.event);
|
|
353
318
|
}, c);
|
|
354
319
|
return () => {
|
|
355
|
-
globalThis.clearInterval(
|
|
320
|
+
globalThis.clearInterval(d);
|
|
356
321
|
};
|
|
357
322
|
});
|
|
358
323
|
} else
|
|
359
|
-
for (const i in
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
const
|
|
363
|
-
this.executeActions(
|
|
364
|
-
},
|
|
324
|
+
for (const i in t) {
|
|
325
|
+
const r = t == null ? void 0 : t[i], u = E(i, this.delayMap)(this.contextSnapshot, this.state.event);
|
|
326
|
+
s(() => {
|
|
327
|
+
const p = globalThis.setInterval(() => {
|
|
328
|
+
this.executeActions(r, this.state.event);
|
|
329
|
+
}, u);
|
|
365
330
|
return () => {
|
|
366
|
-
globalThis.clearInterval(
|
|
331
|
+
globalThis.clearInterval(p);
|
|
367
332
|
};
|
|
368
333
|
});
|
|
369
334
|
}
|
|
370
|
-
}), a(this, "setEvent", (
|
|
371
|
-
this.state.previousEvent = this.state.event, this.state.event =
|
|
372
|
-
}), a(this, "performExitEffects", (
|
|
335
|
+
}), a(this, "setEvent", (t) => {
|
|
336
|
+
this.state.previousEvent = this.state.event, this.state.event = P(g(t));
|
|
337
|
+
}), a(this, "performExitEffects", (t, s) => {
|
|
373
338
|
const i = this.state.value;
|
|
374
339
|
if (i === "") return;
|
|
375
|
-
const
|
|
340
|
+
const r = t ? this.getStateNode(t) : void 0;
|
|
376
341
|
this.stopActivities(i);
|
|
377
|
-
const c =
|
|
378
|
-
|
|
379
|
-
}), a(this, "performEntryEffects", (
|
|
380
|
-
const i = this.getStateNode(
|
|
381
|
-
this.createEveryActivities(i == null ? void 0 : i.every, (
|
|
382
|
-
|
|
383
|
-
}),
|
|
384
|
-
const c =
|
|
342
|
+
const c = D(r == null ? void 0 : r.exit, this.guardMap)(this.contextSnapshot, s, this.guardMeta), u = x(c), d = this.delayedEvents.get(i);
|
|
343
|
+
d && u.push(...d), this.executeActions(u, s);
|
|
344
|
+
}), a(this, "performEntryEffects", (t, s) => {
|
|
345
|
+
const i = this.getStateNode(t), r = x(i == null ? void 0 : i.activities);
|
|
346
|
+
this.createEveryActivities(i == null ? void 0 : i.every, (p) => {
|
|
347
|
+
r.unshift(p);
|
|
348
|
+
}), r.length > 0 && this.executeActivities(s, r);
|
|
349
|
+
const c = D(i == null ? void 0 : i.entry, this.guardMap)(
|
|
385
350
|
this.contextSnapshot,
|
|
386
|
-
|
|
351
|
+
s,
|
|
387
352
|
this.guardMeta
|
|
388
|
-
),
|
|
389
|
-
i != null && i.after &&
|
|
390
|
-
|
|
353
|
+
), u = x(c), d = this.getDelayedEventActions(t);
|
|
354
|
+
i != null && i.after && d && (this.delayedEvents.set(t, d == null ? void 0 : d.exits), u.push(...d.entries)), this.executeActions(u, s), (i == null ? void 0 : i.type) === "final" && (this.state.done = !0, this.doneListeners.forEach((p) => {
|
|
355
|
+
p(this.stateSnapshot);
|
|
391
356
|
}), this.stop());
|
|
392
|
-
}), a(this, "performTransitionEffects", (
|
|
393
|
-
const i = this.determineTransition(
|
|
394
|
-
this.executeActions(i == null ? void 0 : i.actions,
|
|
395
|
-
}), a(this, "performStateChangeEffects", (
|
|
357
|
+
}), a(this, "performTransitionEffects", (t, s) => {
|
|
358
|
+
const i = this.determineTransition(t, s);
|
|
359
|
+
this.executeActions(i == null ? void 0 : i.actions, s);
|
|
360
|
+
}), a(this, "performStateChangeEffects", (t, s, i) => {
|
|
396
361
|
this.setEvent(i);
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
}), a(this, "determineTransition", (
|
|
400
|
-
const i =
|
|
401
|
-
return i == null ? void 0 : i(this.contextSnapshot,
|
|
402
|
-
}), a(this, "sendParent", (
|
|
362
|
+
const r = s.changed || s.reenter;
|
|
363
|
+
r && this.performExitEffects(t, i), this.performTransitionEffects(s.transition, i), this.setState(s.target), r && this.performEntryEffects(s.target, i);
|
|
364
|
+
}), a(this, "determineTransition", (t, s) => {
|
|
365
|
+
const i = rt(t, this.guardMap);
|
|
366
|
+
return i == null ? void 0 : i(this.contextSnapshot, s, this.guardMeta);
|
|
367
|
+
}), a(this, "sendParent", (t) => {
|
|
403
368
|
var i;
|
|
404
369
|
this.parent || b("[@zag-js/core > send-parent] Cannot send event to an unknown parent");
|
|
405
|
-
const
|
|
406
|
-
(i = this.parent) == null || i.send(
|
|
407
|
-
}), a(this, "log", (...
|
|
408
|
-
|
|
409
|
-
}), a(this, "send", (
|
|
410
|
-
const
|
|
411
|
-
this.transition(this.state.value,
|
|
412
|
-
}), a(this, "transition", (
|
|
413
|
-
var
|
|
414
|
-
const i = v(
|
|
370
|
+
const s = g(t);
|
|
371
|
+
(i = this.parent) == null || i.send(s);
|
|
372
|
+
}), a(this, "log", (...t) => {
|
|
373
|
+
X() && this.options.debug && console.log(...t);
|
|
374
|
+
}), a(this, "send", (t) => {
|
|
375
|
+
const s = g(t);
|
|
376
|
+
this.transition(this.state.value, s);
|
|
377
|
+
}), a(this, "transition", (t, s) => {
|
|
378
|
+
var d, p;
|
|
379
|
+
const i = v(t) ? this.getStateNode(t) : t == null ? void 0 : t.stateNode, r = g(s);
|
|
415
380
|
if (!i && !this.config.on) {
|
|
416
|
-
const y = this.status === "Stopped" ? "[@zag-js/core > transition] Cannot transition a stopped machine" : `[@zag-js/core > transition] State does not have a definition for \`state\`: ${
|
|
417
|
-
|
|
381
|
+
const y = this.status === "Stopped" ? "[@zag-js/core > transition] Cannot transition a stopped machine" : `[@zag-js/core > transition] State does not have a definition for \`state\`: ${t}, \`event\`: ${r.type}`;
|
|
382
|
+
w(y);
|
|
418
383
|
return;
|
|
419
384
|
}
|
|
420
385
|
const c = (
|
|
421
386
|
// @ts-expect-error - Fix this
|
|
422
|
-
((
|
|
423
|
-
),
|
|
424
|
-
return this.performStateChangeEffects(this.state.value,
|
|
425
|
-
}), a(this, "subscribe", (
|
|
426
|
-
this.stateListeners.delete(
|
|
427
|
-
})), a(this, "onDone", (
|
|
387
|
+
((d = i == null ? void 0 : i.on) == null ? void 0 : d[r.type]) ?? ((p = this.config.on) == null ? void 0 : p[r.type])
|
|
388
|
+
), u = this.getNextStateInfo(c, r);
|
|
389
|
+
return this.performStateChangeEffects(this.state.value, u, r), u.stateNode;
|
|
390
|
+
}), a(this, "subscribe", (t) => (this.stateListeners.add(t), this.status === "Running" && t(this.stateSnapshot), () => {
|
|
391
|
+
this.stateListeners.delete(t);
|
|
392
|
+
})), a(this, "onDone", (t) => (this.doneListeners.add(t), this)), a(this, "onTransition", (t) => (this.stateListeners.add(t), this.status === "Running" && t(this.stateSnapshot), this)), this.config = O(e), this.options = O(n ?? {}), this.id = this.config.id ?? `machine-${$()}`, this.guardMap = ((o = this.options) == null ? void 0 : o.guards) ?? {}, this.actionMap = ((h = this.options) == null ? void 0 : h.actions) ?? {}, this.delayMap = ((l = this.options) == null ? void 0 : l.delays) ?? {}, this.activityMap = ((f = this.options) == null ? void 0 : f.activities) ?? {}, this.sync = ((S = this.options) == null ? void 0 : S.sync) ?? !1, this.state = nt(this.config), this.initialContext = C(this.state.context);
|
|
428
393
|
}
|
|
429
394
|
// immutable state value
|
|
430
395
|
get stateSnapshot() {
|
|
431
|
-
return m(
|
|
396
|
+
return m(C(this.state));
|
|
432
397
|
}
|
|
433
398
|
getState() {
|
|
434
399
|
return this.stateSnapshot;
|
|
@@ -442,7 +407,7 @@ var G = class {
|
|
|
442
407
|
* Useful when spawning child machines and managing the communication between them.
|
|
443
408
|
*/
|
|
444
409
|
get self() {
|
|
445
|
-
const
|
|
410
|
+
const e = this;
|
|
446
411
|
return {
|
|
447
412
|
id: this.id,
|
|
448
413
|
send: this.send.bind(this),
|
|
@@ -453,29 +418,29 @@ var G = class {
|
|
|
453
418
|
spawn: this.spawn.bind(this),
|
|
454
419
|
stopActivity: this.stopActivity.bind(this),
|
|
455
420
|
get state() {
|
|
456
|
-
return
|
|
421
|
+
return e.stateSnapshot;
|
|
457
422
|
},
|
|
458
423
|
get initialContext() {
|
|
459
|
-
return
|
|
424
|
+
return e.initialContext;
|
|
460
425
|
},
|
|
461
426
|
get initialState() {
|
|
462
|
-
var
|
|
463
|
-
return ((
|
|
427
|
+
var n;
|
|
428
|
+
return ((n = e.initialState) == null ? void 0 : n.target) ?? "";
|
|
464
429
|
}
|
|
465
430
|
};
|
|
466
431
|
}
|
|
467
432
|
get meta() {
|
|
468
|
-
var
|
|
433
|
+
var e;
|
|
469
434
|
return {
|
|
470
435
|
state: this.stateSnapshot,
|
|
471
436
|
guards: this.guardMap,
|
|
472
437
|
send: this.send.bind(this),
|
|
473
438
|
self: this.self,
|
|
474
439
|
initialContext: this.initialContext,
|
|
475
|
-
initialState: ((
|
|
440
|
+
initialState: ((e = this.initialState) == null ? void 0 : e.target) ?? "",
|
|
476
441
|
getState: () => this.stateSnapshot,
|
|
477
|
-
getAction: (
|
|
478
|
-
getGuard: (
|
|
442
|
+
getAction: (n) => this.actionMap[n],
|
|
443
|
+
getGuard: (n) => this.guardMap[n]
|
|
479
444
|
};
|
|
480
445
|
}
|
|
481
446
|
get guardMeta() {
|
|
@@ -487,60 +452,60 @@ var G = class {
|
|
|
487
452
|
return "Machine";
|
|
488
453
|
}
|
|
489
454
|
getHydrationState() {
|
|
490
|
-
const
|
|
455
|
+
const e = this.getState();
|
|
491
456
|
return {
|
|
492
|
-
value:
|
|
493
|
-
tags:
|
|
457
|
+
value: e.value,
|
|
458
|
+
tags: e.tags
|
|
494
459
|
};
|
|
495
460
|
}
|
|
496
|
-
}, gt = (
|
|
497
|
-
var
|
|
498
|
-
return (
|
|
499
|
-
}).filter(Boolean).join(" "),
|
|
500
|
-
const
|
|
501
|
-
let
|
|
502
|
-
for (;
|
|
503
|
-
|
|
504
|
-
return
|
|
505
|
-
},
|
|
506
|
-
if (v(
|
|
507
|
-
if (v(
|
|
508
|
-
|
|
509
|
-
} else v(
|
|
510
|
-
return Object.assign({},
|
|
461
|
+
}, gt = (e, n) => new k(e, n), yt = (e) => e instanceof k || (e == null ? void 0 : e.type) === "machine", ot = (...e) => e.map((n) => {
|
|
462
|
+
var o;
|
|
463
|
+
return (o = n == null ? void 0 : n.trim) == null ? void 0 : o.call(n);
|
|
464
|
+
}).filter(Boolean).join(" "), ht = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g, z = (e) => {
|
|
465
|
+
const n = {};
|
|
466
|
+
let o;
|
|
467
|
+
for (; o = ht.exec(e); )
|
|
468
|
+
n[o[1]] = o[2];
|
|
469
|
+
return n;
|
|
470
|
+
}, ct = (e, n) => {
|
|
471
|
+
if (v(e)) {
|
|
472
|
+
if (v(n)) return `${e};${n}`;
|
|
473
|
+
e = z(e);
|
|
474
|
+
} else v(n) && (n = z(n));
|
|
475
|
+
return Object.assign({}, e ?? {}, n ?? {});
|
|
511
476
|
};
|
|
512
|
-
function mt(...
|
|
513
|
-
let
|
|
514
|
-
for (let
|
|
515
|
-
for (let
|
|
516
|
-
if (
|
|
517
|
-
|
|
477
|
+
function mt(...e) {
|
|
478
|
+
let n = {};
|
|
479
|
+
for (let o of e) {
|
|
480
|
+
for (let h in n) {
|
|
481
|
+
if (h.startsWith("on") && typeof n[h] == "function" && typeof o[h] == "function") {
|
|
482
|
+
n[h] = q(o[h], n[h]);
|
|
518
483
|
continue;
|
|
519
484
|
}
|
|
520
|
-
if (
|
|
521
|
-
|
|
485
|
+
if (h === "className" || h === "class") {
|
|
486
|
+
n[h] = ot(n[h], o[h]);
|
|
522
487
|
continue;
|
|
523
488
|
}
|
|
524
|
-
if (
|
|
525
|
-
|
|
489
|
+
if (h === "style") {
|
|
490
|
+
n[h] = ct(n[h], o[h]);
|
|
526
491
|
continue;
|
|
527
492
|
}
|
|
528
|
-
|
|
493
|
+
n[h] = o[h] !== void 0 ? o[h] : n[h];
|
|
529
494
|
}
|
|
530
|
-
for (let
|
|
531
|
-
|
|
495
|
+
for (let h in o)
|
|
496
|
+
n[h] === void 0 && (n[h] = o[h]);
|
|
532
497
|
}
|
|
533
|
-
return
|
|
498
|
+
return n;
|
|
534
499
|
}
|
|
535
500
|
export {
|
|
536
|
-
|
|
501
|
+
k as Machine,
|
|
537
502
|
gt as createMachine,
|
|
538
|
-
|
|
503
|
+
I as deepMerge,
|
|
539
504
|
vt as guards,
|
|
540
505
|
yt as isMachine,
|
|
541
506
|
mt as mergeProps,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
507
|
+
R as proxy,
|
|
508
|
+
P as ref,
|
|
509
|
+
C as snapshot,
|
|
510
|
+
_ as subscribe
|
|
546
511
|
};
|