@cfxjs/sirius-next-common 0.1.37 → 0.1.39
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/chunk-3RVRAMNW.js +69 -0
- package/dist/chunk-3RVRAMNW.js.map +1 -0
- package/dist/chunk-4HTI24KG.js +3629 -0
- package/dist/chunk-4HTI24KG.js.map +1 -0
- package/dist/chunk-6AGMKWAW.js +286 -0
- package/dist/chunk-6AGMKWAW.js.map +1 -0
- package/dist/chunk-6GBDCZIP.js +414 -0
- package/dist/chunk-6GBDCZIP.js.map +1 -0
- package/dist/chunk-73IFRWHE.js +130 -0
- package/dist/chunk-73IFRWHE.js.map +1 -0
- package/dist/chunk-AAQD5VX5.js +212 -0
- package/dist/chunk-AAQD5VX5.js.map +1 -0
- package/dist/chunk-AD46ITJC.js +416 -0
- package/dist/chunk-AD46ITJC.js.map +1 -0
- package/dist/chunk-AV2OU3PU.js +108 -0
- package/dist/chunk-AV2OU3PU.js.map +1 -0
- package/dist/chunk-B5XWZ3ZE.js +150 -0
- package/dist/chunk-B5XWZ3ZE.js.map +1 -0
- package/dist/chunk-CDYRVFSO.js +150 -0
- package/dist/chunk-CDYRVFSO.js.map +1 -0
- package/dist/chunk-EP4RVV4C.js +3629 -0
- package/dist/chunk-EP4RVV4C.js.map +1 -0
- package/dist/chunk-EVMUOMAM.js +412 -0
- package/dist/chunk-EVMUOMAM.js.map +1 -0
- package/dist/chunk-EYT54RGS.js +63 -0
- package/dist/chunk-EYT54RGS.js.map +1 -0
- package/dist/chunk-FMHO65DC.js +105 -0
- package/dist/chunk-FMHO65DC.js.map +1 -0
- package/dist/chunk-H6W3LPDS.js +2324 -0
- package/dist/chunk-H6W3LPDS.js.map +1 -0
- package/dist/chunk-HC2D4STF.js +69 -0
- package/dist/chunk-HC2D4STF.js.map +1 -0
- package/dist/chunk-IV4QQOMI.js +416 -0
- package/dist/chunk-IV4QQOMI.js.map +1 -0
- package/dist/chunk-IWECTQOD.js +212 -0
- package/dist/chunk-IWECTQOD.js.map +1 -0
- package/dist/chunk-JQUV4NMR.js +416 -0
- package/dist/chunk-JQUV4NMR.js.map +1 -0
- package/dist/chunk-KAGEJPGK.js +416 -0
- package/dist/chunk-KAGEJPGK.js.map +1 -0
- package/dist/chunk-KCPSCEXG.js +69 -0
- package/dist/chunk-KCPSCEXG.js.map +1 -0
- package/dist/chunk-KKR2JERD.js +284 -0
- package/dist/chunk-KKR2JERD.js.map +1 -0
- package/dist/chunk-LQXAMTBE.js +69 -0
- package/dist/chunk-LQXAMTBE.js.map +1 -0
- package/dist/chunk-M43SICPO.js +63 -0
- package/dist/chunk-M43SICPO.js.map +1 -0
- package/dist/chunk-M6MXSMYM.js +284 -0
- package/dist/chunk-M6MXSMYM.js.map +1 -0
- package/dist/chunk-MIAX5LP5.js +141 -0
- package/dist/chunk-MIAX5LP5.js.map +1 -0
- package/dist/chunk-N5TMLKGL.js +141 -0
- package/dist/chunk-N5TMLKGL.js.map +1 -0
- package/dist/chunk-NIYCXPXR.js +108 -0
- package/dist/chunk-NIYCXPXR.js.map +1 -0
- package/dist/chunk-O474QMUU.js +105 -0
- package/dist/chunk-O474QMUU.js.map +1 -0
- package/dist/chunk-OF33MONA.js +69 -0
- package/dist/chunk-OF33MONA.js.map +1 -0
- package/dist/chunk-PLU4IMEZ.js +130 -0
- package/dist/chunk-PLU4IMEZ.js.map +1 -0
- package/dist/chunk-RB2U3Y7F.js +49 -0
- package/dist/chunk-RB2U3Y7F.js.map +1 -0
- package/dist/chunk-RVVVAX7C.js +796 -0
- package/dist/chunk-RVVVAX7C.js.map +1 -0
- package/dist/chunk-TAJNIINB.js +69 -0
- package/dist/chunk-TAJNIINB.js.map +1 -0
- package/dist/chunk-VLDX5EPR.js +69 -0
- package/dist/chunk-VLDX5EPR.js.map +1 -0
- package/dist/chunk-VUULJBTQ.js +796 -0
- package/dist/chunk-VUULJBTQ.js.map +1 -0
- package/dist/chunk-VY6BUAPS.js +49 -0
- package/dist/chunk-VY6BUAPS.js.map +1 -0
- package/dist/chunk-XGOIDR7R.js +416 -0
- package/dist/chunk-XGOIDR7R.js.map +1 -0
- package/dist/chunk-XMBEB34D.js +69 -0
- package/dist/chunk-XMBEB34D.js.map +1 -0
- package/dist/chunk-XMWQQ4A6.js +414 -0
- package/dist/chunk-XMWQQ4A6.js.map +1 -0
- package/dist/chunk-Z6EYKGBH.js +286 -0
- package/dist/chunk-Z6EYKGBH.js.map +1 -0
- package/dist/chunk-ZKNMJZ5R.js +2324 -0
- package/dist/chunk-ZKNMJZ5R.js.map +1 -0
- package/dist/components/AddressContainer/CoreAddressContainer.js +10 -10
- package/dist/components/AddressContainer/EVMAddressContainer.js +9 -9
- package/dist/components/AddressContainer/addressSwitcher.js +7 -7
- package/dist/components/AddressContainer/addressView.js +6 -6
- package/dist/components/AddressContainer/label.js +4 -4
- package/dist/components/Age/index.js +4 -4
- package/dist/components/Charts/ChartOptions.js +2 -2
- package/dist/components/Charts/PreviewChartTemplate.js +6 -4
- package/dist/components/Charts/PreviewChartTemplate.js.map +1 -1
- package/dist/components/Charts/StockChartTemplate.js +7 -5
- package/dist/components/Charts/StockChartTemplate.js.map +1 -1
- package/dist/components/Charts/config.d.ts +5 -4
- package/dist/components/Charts/config.js +3 -1
- package/dist/components/CopyButton/index.js +3 -3
- package/dist/components/DownloadCSV/index.js +4 -4
- package/dist/components/GasPriceDropdown/index.js +2 -2
- package/dist/components/IncreasePercent/index.js +2 -2
- package/dist/components/InfoIconWithTooltip/index.js +3 -3
- package/dist/components/Modal/index.js +3 -3
- package/dist/components/NetworkIcon/index.js +2 -2
- package/dist/components/PhishingAddressContainer/index.js +4 -4
- package/dist/components/Price/index.js +3 -3
- package/dist/components/Radio/index.js +2 -2
- package/dist/components/Select/index.js +3 -3
- package/dist/components/Select/select.js +3 -3
- package/dist/components/Text/index.js +4 -4
- package/dist/components/Tooltip/index.js +3 -3
- package/dist/components/TransactionAction/coreTransactionAction.js +10 -10
- package/dist/components/TransactionAction/evmTransactionAction.js +9 -9
- package/dist/components/TransactionAction/evmTransactionAction.js.map +1 -1
- package/dist/utils/address.d.ts +1 -1
- package/dist/utils/address.js +2 -2
- package/dist/utils/contractManagerTool.js +2 -2
- package/dist/utils/hooks/useChartQueryParams.d.ts +18 -0
- package/dist/utils/hooks/useChartQueryParams.js +31 -0
- package/dist/utils/hooks/useChartQueryParams.js.map +1 -0
- package/dist/utils/hooks/useENS.js +3 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/request.d.ts +1 -1
- package/dist/utils/request.js +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,2324 @@
|
|
|
1
|
+
import {
|
|
2
|
+
arrow,
|
|
3
|
+
computePosition,
|
|
4
|
+
flip,
|
|
5
|
+
getOverflowAncestors,
|
|
6
|
+
offset,
|
|
7
|
+
shift,
|
|
8
|
+
size
|
|
9
|
+
} from "./chunk-LRCAKRPK.js";
|
|
10
|
+
import {
|
|
11
|
+
cn
|
|
12
|
+
} from "./chunk-RVVVAX7C.js";
|
|
13
|
+
|
|
14
|
+
// src/components/Tooltip/index.tsx
|
|
15
|
+
import {
|
|
16
|
+
useRef as useRef4
|
|
17
|
+
} from "react";
|
|
18
|
+
|
|
19
|
+
// ../../node_modules/.pnpm/@cfx-kit+ui-components@0.0.18_@zag-js+accordion@0.19.1_@zag-js+checkbox@0.19.1_@zag-js+dialog_toqhwacqm4ck723ovqekq5mm7u/node_modules/@cfx-kit/ui-components/dist/chunk-W7QWXYJO.js
|
|
20
|
+
var __defProp = Object.defineProperty;
|
|
21
|
+
var __defProps = Object.defineProperties;
|
|
22
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
23
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
24
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
25
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
26
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
27
|
+
var __spreadValues = (a2, b) => {
|
|
28
|
+
for (var prop in b || (b = {}))
|
|
29
|
+
if (__hasOwnProp.call(b, prop))
|
|
30
|
+
__defNormalProp(a2, prop, b[prop]);
|
|
31
|
+
if (__getOwnPropSymbols)
|
|
32
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
33
|
+
if (__propIsEnum.call(b, prop))
|
|
34
|
+
__defNormalProp(a2, prop, b[prop]);
|
|
35
|
+
}
|
|
36
|
+
return a2;
|
|
37
|
+
};
|
|
38
|
+
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
|
|
39
|
+
var __objRest = (source, exclude) => {
|
|
40
|
+
var target = {};
|
|
41
|
+
for (var prop in source)
|
|
42
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
43
|
+
target[prop] = source[prop];
|
|
44
|
+
if (source != null && __getOwnPropSymbols)
|
|
45
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
46
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
47
|
+
target[prop] = source[prop];
|
|
48
|
+
}
|
|
49
|
+
return target;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// ../../node_modules/.pnpm/@cfx-kit+ui-components@0.0.18_@zag-js+accordion@0.19.1_@zag-js+checkbox@0.19.1_@zag-js+dialog_toqhwacqm4ck723ovqekq5mm7u/node_modules/@cfx-kit/ui-components/dist/Tooltip.js
|
|
53
|
+
import { useEffect as useEffect3, useId, isValidElement, cloneElement, Children, Fragment } from "react";
|
|
54
|
+
|
|
55
|
+
// ../../node_modules/.pnpm/@zag-js+anatomy@0.19.1/node_modules/@zag-js/anatomy/dist/index.mjs
|
|
56
|
+
var createAnatomy = (name, parts2 = []) => ({
|
|
57
|
+
parts: (...values) => {
|
|
58
|
+
if (isEmpty(parts2)) {
|
|
59
|
+
return createAnatomy(name, values);
|
|
60
|
+
}
|
|
61
|
+
throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?");
|
|
62
|
+
},
|
|
63
|
+
extendWith: (...values) => createAnatomy(name, [...parts2, ...values]),
|
|
64
|
+
rename: (newName) => createAnatomy(newName, parts2),
|
|
65
|
+
keys: () => parts2,
|
|
66
|
+
build: () => [...new Set(parts2)].reduce(
|
|
67
|
+
(prev, part) => Object.assign(prev, {
|
|
68
|
+
[part]: {
|
|
69
|
+
selector: [
|
|
70
|
+
`&[data-scope="${toKebabCase(name)}"][data-part="${toKebabCase(part)}"]`,
|
|
71
|
+
`& [data-scope="${toKebabCase(name)}"][data-part="${toKebabCase(part)}"]`
|
|
72
|
+
].join(", "),
|
|
73
|
+
attrs: { "data-scope": toKebabCase(name), "data-part": toKebabCase(part) }
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
{}
|
|
77
|
+
)
|
|
78
|
+
});
|
|
79
|
+
var toKebabCase = (value) => value.replace(/([A-Z])([A-Z])/g, "$1-$2").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
80
|
+
var isEmpty = (v) => v.length === 0;
|
|
81
|
+
|
|
82
|
+
// ../../node_modules/.pnpm/@zag-js+dom-query@0.19.1/node_modules/@zag-js/dom-query/dist/index.mjs
|
|
83
|
+
var dataAttr = (guard) => {
|
|
84
|
+
return guard ? "" : void 0;
|
|
85
|
+
};
|
|
86
|
+
function isHTMLElement(value) {
|
|
87
|
+
return typeof value === "object" && value?.nodeType === Node.ELEMENT_NODE && typeof value?.nodeName === "string";
|
|
88
|
+
}
|
|
89
|
+
var getDocument = (node) => {
|
|
90
|
+
if (node.nodeType === Node.DOCUMENT_NODE)
|
|
91
|
+
return node;
|
|
92
|
+
return node.ownerDocument ?? document;
|
|
93
|
+
};
|
|
94
|
+
function createScope(methods) {
|
|
95
|
+
const screen = {
|
|
96
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
97
|
+
getDoc: (ctx) => getDocument(screen.getRootNode(ctx)),
|
|
98
|
+
getWin: (ctx) => screen.getDoc(ctx).defaultView ?? window,
|
|
99
|
+
getActiveElement: (ctx) => screen.getDoc(ctx).activeElement,
|
|
100
|
+
getById: (ctx, id) => screen.getRootNode(ctx).getElementById(id),
|
|
101
|
+
setValue: (elem, value) => {
|
|
102
|
+
if (elem == null || value == null)
|
|
103
|
+
return;
|
|
104
|
+
elem.value = value.toString();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return { ...screen, ...methods };
|
|
108
|
+
}
|
|
109
|
+
function isScrollParent(el) {
|
|
110
|
+
const win = el.ownerDocument.defaultView || window;
|
|
111
|
+
const { overflow, overflowX, overflowY } = win.getComputedStyle(el);
|
|
112
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
113
|
+
}
|
|
114
|
+
function getParent(el) {
|
|
115
|
+
if (el.localName === "html")
|
|
116
|
+
return el;
|
|
117
|
+
return el.assignedSlot || el.parentElement || el.ownerDocument.documentElement;
|
|
118
|
+
}
|
|
119
|
+
function getScrollParent(el) {
|
|
120
|
+
if (["html", "body", "#document"].includes(el.localName)) {
|
|
121
|
+
return el.ownerDocument.body;
|
|
122
|
+
}
|
|
123
|
+
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
124
|
+
return el;
|
|
125
|
+
}
|
|
126
|
+
return getScrollParent(getParent(el));
|
|
127
|
+
}
|
|
128
|
+
function getScrollParents(el, list = []) {
|
|
129
|
+
const parent = getScrollParent(el);
|
|
130
|
+
const isBody = parent === el.ownerDocument.body;
|
|
131
|
+
const win = parent.ownerDocument.defaultView || window;
|
|
132
|
+
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(parent) ? parent : []) : parent;
|
|
133
|
+
const parents = list.concat(target);
|
|
134
|
+
return isBody ? parents : parents.concat(getScrollParents(getParent(target)));
|
|
135
|
+
}
|
|
136
|
+
var isDom = () => typeof document !== "undefined";
|
|
137
|
+
function getPlatform() {
|
|
138
|
+
const agent = navigator.userAgentData;
|
|
139
|
+
return agent?.platform ?? navigator.platform;
|
|
140
|
+
}
|
|
141
|
+
var pt = (v) => isDom() && v.test(getPlatform());
|
|
142
|
+
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
143
|
+
var isSafari = () => isApple() && vn(/apple/i);
|
|
144
|
+
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
145
|
+
function raf(fn) {
|
|
146
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
147
|
+
return () => {
|
|
148
|
+
globalThis.cancelAnimationFrame(id);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ../../node_modules/.pnpm/@zag-js+utils@0.19.1/node_modules/@zag-js/utils/dist/index.mjs
|
|
153
|
+
var callAll = (...fns) => (...a2) => {
|
|
154
|
+
fns.forEach(function(fn) {
|
|
155
|
+
fn?.(...a2);
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
function compact(obj) {
|
|
159
|
+
if (!isPlainObject(obj) || obj === void 0) {
|
|
160
|
+
return obj;
|
|
161
|
+
}
|
|
162
|
+
const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
163
|
+
const filtered = {};
|
|
164
|
+
for (const key of keys) {
|
|
165
|
+
const value = obj[key];
|
|
166
|
+
if (value !== void 0) {
|
|
167
|
+
filtered[key] = compact(value);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return filtered;
|
|
171
|
+
}
|
|
172
|
+
var isPlainObject = (value) => {
|
|
173
|
+
return value && typeof value === "object" && value.constructor === Object;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// ../../node_modules/.pnpm/@zag-js+element-rect@0.19.1/node_modules/@zag-js/element-rect/dist/index.mjs
|
|
177
|
+
var rafId;
|
|
178
|
+
var observedElements = /* @__PURE__ */ new Map();
|
|
179
|
+
var getRectFn = (el) => el.getBoundingClientRect();
|
|
180
|
+
function trackElementRect(el, options) {
|
|
181
|
+
const { scope = "rect", getRect = getRectFn, onChange } = options;
|
|
182
|
+
const loop = getLoopFn({ scope, getRect });
|
|
183
|
+
const data = observedElements.get(el);
|
|
184
|
+
if (!data) {
|
|
185
|
+
observedElements.set(el, {
|
|
186
|
+
rect: {},
|
|
187
|
+
callbacks: [onChange]
|
|
188
|
+
});
|
|
189
|
+
if (observedElements.size === 1) {
|
|
190
|
+
rafId = requestAnimationFrame(loop);
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
data.callbacks.push(onChange);
|
|
194
|
+
onChange(getRect(el));
|
|
195
|
+
}
|
|
196
|
+
return function unobserve() {
|
|
197
|
+
const data2 = observedElements.get(el);
|
|
198
|
+
if (!data2)
|
|
199
|
+
return;
|
|
200
|
+
const index = data2.callbacks.indexOf(onChange);
|
|
201
|
+
if (index > -1) {
|
|
202
|
+
data2.callbacks.splice(index, 1);
|
|
203
|
+
}
|
|
204
|
+
if (data2.callbacks.length === 0) {
|
|
205
|
+
observedElements.delete(el);
|
|
206
|
+
if (observedElements.size === 0) {
|
|
207
|
+
cancelAnimationFrame(rafId);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function getLoopFn(options) {
|
|
213
|
+
const { scope, getRect } = options;
|
|
214
|
+
const isEqual = getEqualityFn(scope);
|
|
215
|
+
return function loop() {
|
|
216
|
+
const changedRectsData = [];
|
|
217
|
+
observedElements.forEach((data, element) => {
|
|
218
|
+
const newRect = getRect(element);
|
|
219
|
+
if (!isEqual(data.rect, newRect)) {
|
|
220
|
+
data.rect = newRect;
|
|
221
|
+
changedRectsData.push(data);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
changedRectsData.forEach((data) => {
|
|
225
|
+
data.callbacks.forEach((callback) => callback(data.rect));
|
|
226
|
+
});
|
|
227
|
+
rafId = requestAnimationFrame(loop);
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
var isEqualSize = (a2, b) => a2.width === b.width && a2.height === b.height;
|
|
231
|
+
var isEqualPosition = (a2, b) => a2.top === b.top && a2.left === b.left;
|
|
232
|
+
var isEqualRect = (a2, b) => isEqualSize(a2, b) && isEqualPosition(a2, b);
|
|
233
|
+
function getEqualityFn(scope) {
|
|
234
|
+
if (scope === "size")
|
|
235
|
+
return isEqualSize;
|
|
236
|
+
if (scope === "position")
|
|
237
|
+
return isEqualPosition;
|
|
238
|
+
return isEqualRect;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ../../node_modules/.pnpm/@zag-js+popper@0.19.1/node_modules/@zag-js/popper/dist/index.mjs
|
|
242
|
+
var callAll2 = (...fns) => () => fns.forEach((fn) => fn());
|
|
243
|
+
var isHTMLElement2 = (el) => {
|
|
244
|
+
return typeof el === "object" && el !== null && el.nodeType === 1;
|
|
245
|
+
};
|
|
246
|
+
var addDomEvent = (el, type, fn, options) => {
|
|
247
|
+
el.addEventListener(type, fn, options);
|
|
248
|
+
return () => el.removeEventListener(type, fn, options);
|
|
249
|
+
};
|
|
250
|
+
function resolveOptions(option) {
|
|
251
|
+
const bool = typeof option === "boolean";
|
|
252
|
+
return {
|
|
253
|
+
ancestorResize: bool ? option : option.ancestorResize ?? true,
|
|
254
|
+
ancestorScroll: bool ? option : option.ancestorScroll ?? true,
|
|
255
|
+
referenceResize: bool ? option : option.referenceResize ?? true
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function autoUpdate(reference, floating, update, options = false) {
|
|
259
|
+
const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
|
|
260
|
+
const useAncestors = ancestorScroll || ancestorResize;
|
|
261
|
+
const ancestors = [];
|
|
262
|
+
if (useAncestors && isHTMLElement2(reference)) {
|
|
263
|
+
ancestors.push(...getOverflowAncestors(reference));
|
|
264
|
+
}
|
|
265
|
+
function addResizeListeners() {
|
|
266
|
+
let cleanups = [trackElementRect(floating, { scope: "size", onChange: update })];
|
|
267
|
+
if (referenceResize && isHTMLElement2(reference)) {
|
|
268
|
+
cleanups.push(trackElementRect(reference, { onChange: update }));
|
|
269
|
+
}
|
|
270
|
+
cleanups.push(callAll2(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
271
|
+
return () => cleanups.forEach((fn) => fn());
|
|
272
|
+
}
|
|
273
|
+
function addScrollListeners() {
|
|
274
|
+
return callAll2(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
|
|
275
|
+
}
|
|
276
|
+
return callAll2(addResizeListeners(), addScrollListeners());
|
|
277
|
+
}
|
|
278
|
+
var toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
279
|
+
var cssVars = {
|
|
280
|
+
arrowSize: toVar("--arrow-size"),
|
|
281
|
+
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
282
|
+
arrowBg: toVar("--arrow-background"),
|
|
283
|
+
transformOrigin: toVar("--transform-origin"),
|
|
284
|
+
arrowOffset: toVar("--arrow-offset")
|
|
285
|
+
};
|
|
286
|
+
var getTransformOrigin = (arrow2) => ({
|
|
287
|
+
top: "bottom center",
|
|
288
|
+
"top-start": arrow2 ? `${arrow2.x}px bottom` : "left bottom",
|
|
289
|
+
"top-end": arrow2 ? `${arrow2.x}px bottom` : "right bottom",
|
|
290
|
+
bottom: "top center",
|
|
291
|
+
"bottom-start": arrow2 ? `${arrow2.x}px top` : "top left",
|
|
292
|
+
"bottom-end": arrow2 ? `${arrow2.x}px top` : "top right",
|
|
293
|
+
left: "right center",
|
|
294
|
+
"left-start": arrow2 ? `right ${arrow2.y}px` : "right top",
|
|
295
|
+
"left-end": arrow2 ? `right ${arrow2.y}px` : "right bottom",
|
|
296
|
+
right: "left center",
|
|
297
|
+
"right-start": arrow2 ? `left ${arrow2.y}px` : "left top",
|
|
298
|
+
"right-end": arrow2 ? `left ${arrow2.y}px` : "left bottom"
|
|
299
|
+
});
|
|
300
|
+
var transformOrigin = {
|
|
301
|
+
name: "transformOrigin",
|
|
302
|
+
fn({ placement, elements, middlewareData }) {
|
|
303
|
+
const { arrow: arrow2 } = middlewareData;
|
|
304
|
+
const transformOrigin2 = getTransformOrigin(arrow2)[placement];
|
|
305
|
+
const { floating } = elements;
|
|
306
|
+
floating.style.setProperty(cssVars.transformOrigin.variable, transformOrigin2);
|
|
307
|
+
return {
|
|
308
|
+
data: { transformOrigin: transformOrigin2 }
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
var shiftArrow = (opts) => ({
|
|
313
|
+
name: "shiftArrow",
|
|
314
|
+
fn({ placement, middlewareData }) {
|
|
315
|
+
const { element: arrow2 } = opts;
|
|
316
|
+
if (middlewareData.arrow) {
|
|
317
|
+
const { x, y: y2 } = middlewareData.arrow;
|
|
318
|
+
const dir = placement.split("-")[0];
|
|
319
|
+
Object.assign(arrow2.style, {
|
|
320
|
+
left: x != null ? `${x}px` : "",
|
|
321
|
+
top: y2 != null ? `${y2}px` : "",
|
|
322
|
+
[dir]: `calc(100% + ${cssVars.arrowOffset.reference})`
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return {};
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
var defaultOptions = {
|
|
329
|
+
strategy: "absolute",
|
|
330
|
+
placement: "bottom",
|
|
331
|
+
listeners: true,
|
|
332
|
+
gutter: 8,
|
|
333
|
+
flip: true,
|
|
334
|
+
sameWidth: false,
|
|
335
|
+
overflowPadding: 8
|
|
336
|
+
};
|
|
337
|
+
function getPlacementImpl(reference, floating, opts = {}) {
|
|
338
|
+
if (!floating || !reference)
|
|
339
|
+
return;
|
|
340
|
+
const options = Object.assign({}, defaultOptions, opts);
|
|
341
|
+
const arrowEl = floating.querySelector("[data-part=arrow]");
|
|
342
|
+
const middleware = [];
|
|
343
|
+
const boundary = typeof options.boundary === "function" ? options.boundary() : options.boundary;
|
|
344
|
+
if (options.flip) {
|
|
345
|
+
middleware.push(
|
|
346
|
+
flip({
|
|
347
|
+
boundary,
|
|
348
|
+
padding: options.overflowPadding
|
|
349
|
+
})
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
if (options.gutter || options.offset) {
|
|
353
|
+
const arrowOffset = arrowEl ? arrowEl.offsetHeight / 2 : 0;
|
|
354
|
+
let mainAxis = options.offset?.mainAxis ?? options.gutter;
|
|
355
|
+
let crossAxis = options.offset?.crossAxis;
|
|
356
|
+
if (mainAxis != null)
|
|
357
|
+
mainAxis += arrowOffset;
|
|
358
|
+
const offsetOptions = compact({ mainAxis, crossAxis });
|
|
359
|
+
middleware.push(offset(offsetOptions));
|
|
360
|
+
}
|
|
361
|
+
middleware.push(
|
|
362
|
+
shift({
|
|
363
|
+
boundary,
|
|
364
|
+
crossAxis: options.overlap,
|
|
365
|
+
padding: options.overflowPadding
|
|
366
|
+
})
|
|
367
|
+
);
|
|
368
|
+
if (arrowEl) {
|
|
369
|
+
middleware.push(
|
|
370
|
+
arrow({ element: arrowEl, padding: 8 }),
|
|
371
|
+
shiftArrow({ element: arrowEl })
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
middleware.push(transformOrigin);
|
|
375
|
+
middleware.push(
|
|
376
|
+
size({
|
|
377
|
+
padding: options.overflowPadding,
|
|
378
|
+
apply({ rects, availableHeight, availableWidth }) {
|
|
379
|
+
const referenceWidth = Math.round(rects.reference.width);
|
|
380
|
+
floating.style.setProperty("--reference-width", `${referenceWidth}px`);
|
|
381
|
+
floating.style.setProperty("--available-width", `${availableWidth}px`);
|
|
382
|
+
floating.style.setProperty("--available-height", `${availableHeight}px`);
|
|
383
|
+
}
|
|
384
|
+
})
|
|
385
|
+
);
|
|
386
|
+
function compute(config = {}) {
|
|
387
|
+
if (!reference || !floating)
|
|
388
|
+
return;
|
|
389
|
+
const { placement, strategy, onComplete } = options;
|
|
390
|
+
computePosition(reference, floating, {
|
|
391
|
+
placement,
|
|
392
|
+
middleware,
|
|
393
|
+
strategy,
|
|
394
|
+
...config
|
|
395
|
+
}).then((data) => {
|
|
396
|
+
const x = Math.round(data.x);
|
|
397
|
+
floating.style.setProperty("--x", `${x}px`);
|
|
398
|
+
const y2 = Math.round(data.y);
|
|
399
|
+
floating.style.setProperty("--y", `${y2}px`);
|
|
400
|
+
onComplete?.(data);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
compute();
|
|
404
|
+
return callAll(
|
|
405
|
+
options.listeners ? autoUpdate(reference, floating, compute, options.listeners) : void 0,
|
|
406
|
+
options.onCleanup
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
function getPlacement(referenceOrFn, floatingOrFn, opts = {}) {
|
|
410
|
+
const { defer, ...restOptions } = opts;
|
|
411
|
+
const func = defer ? raf : (v) => v();
|
|
412
|
+
const cleanups = [];
|
|
413
|
+
cleanups.push(
|
|
414
|
+
func(() => {
|
|
415
|
+
const reference = typeof referenceOrFn === "function" ? referenceOrFn() : referenceOrFn;
|
|
416
|
+
const floating = typeof floatingOrFn === "function" ? floatingOrFn() : floatingOrFn;
|
|
417
|
+
cleanups.push(getPlacementImpl(reference, floating, restOptions));
|
|
418
|
+
})
|
|
419
|
+
);
|
|
420
|
+
return () => {
|
|
421
|
+
cleanups.forEach((fn) => fn?.());
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
var ARROW_FLOATING_STYLE = {
|
|
425
|
+
bottom: "rotate(45deg)",
|
|
426
|
+
left: "rotate(135deg)",
|
|
427
|
+
top: "rotate(225deg)",
|
|
428
|
+
right: "rotate(315deg)"
|
|
429
|
+
};
|
|
430
|
+
function getPlacementStyles(options = {}) {
|
|
431
|
+
const { placement = "bottom", sameWidth, fitViewport, strategy = "absolute" } = options;
|
|
432
|
+
return {
|
|
433
|
+
arrow: {
|
|
434
|
+
position: "absolute",
|
|
435
|
+
width: cssVars.arrowSize.reference,
|
|
436
|
+
height: cssVars.arrowSize.reference,
|
|
437
|
+
[cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
|
|
438
|
+
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`
|
|
439
|
+
},
|
|
440
|
+
arrowTip: {
|
|
441
|
+
transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
|
|
442
|
+
background: cssVars.arrowBg.reference,
|
|
443
|
+
top: "0",
|
|
444
|
+
left: "0",
|
|
445
|
+
width: "100%",
|
|
446
|
+
height: "100%",
|
|
447
|
+
position: "absolute",
|
|
448
|
+
zIndex: "inherit"
|
|
449
|
+
},
|
|
450
|
+
floating: {
|
|
451
|
+
position: strategy,
|
|
452
|
+
minWidth: sameWidth ? void 0 : "max-content",
|
|
453
|
+
width: sameWidth ? "var(--reference-width)" : void 0,
|
|
454
|
+
maxWidth: fitViewport ? "var(--available-width)" : void 0,
|
|
455
|
+
maxHeight: fitViewport ? "var(--available-height)" : void 0,
|
|
456
|
+
top: "0px",
|
|
457
|
+
left: "0px",
|
|
458
|
+
transform: `translate3d(var(--x), var(--y), 0)`
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// ../../node_modules/.pnpm/proxy-compare@2.5.1/node_modules/proxy-compare/dist/index.modern.js
|
|
464
|
+
var e = Symbol();
|
|
465
|
+
var t = Symbol();
|
|
466
|
+
var r = "a";
|
|
467
|
+
var n = "w";
|
|
468
|
+
var o = (e2, t2) => new Proxy(e2, t2);
|
|
469
|
+
var s = Object.getPrototypeOf;
|
|
470
|
+
var c = /* @__PURE__ */ new WeakMap();
|
|
471
|
+
var l = (e2) => e2 && (c.has(e2) ? c.get(e2) : s(e2) === Object.prototype || s(e2) === Array.prototype);
|
|
472
|
+
var f = (e2) => "object" == typeof e2 && null !== e2;
|
|
473
|
+
var i = (e2) => {
|
|
474
|
+
if (Array.isArray(e2))
|
|
475
|
+
return Array.from(e2);
|
|
476
|
+
const t2 = Object.getOwnPropertyDescriptors(e2);
|
|
477
|
+
return Object.values(t2).forEach((e3) => {
|
|
478
|
+
e3.configurable = true;
|
|
479
|
+
}), Object.create(s(e2), t2);
|
|
480
|
+
};
|
|
481
|
+
var u = (e2) => e2[t] || e2;
|
|
482
|
+
var a = (s2, c2, f2, p2) => {
|
|
483
|
+
if (!l(s2))
|
|
484
|
+
return s2;
|
|
485
|
+
let g = p2 && p2.get(s2);
|
|
486
|
+
if (!g) {
|
|
487
|
+
const e2 = u(s2);
|
|
488
|
+
g = ((e3) => Object.values(Object.getOwnPropertyDescriptors(e3)).some((e4) => !e4.configurable && !e4.writable))(e2) ? [e2, i(e2)] : [e2], null == p2 || p2.set(s2, g);
|
|
489
|
+
}
|
|
490
|
+
const [y2, h2] = g;
|
|
491
|
+
let w = f2 && f2.get(y2);
|
|
492
|
+
return w && w[1].f === !!h2 || (w = ((o2, s3) => {
|
|
493
|
+
const c3 = { f: s3 };
|
|
494
|
+
let l2 = false;
|
|
495
|
+
const f3 = (e2, t2) => {
|
|
496
|
+
if (!l2) {
|
|
497
|
+
let s4 = c3[r].get(o2);
|
|
498
|
+
if (s4 || (s4 = {}, c3[r].set(o2, s4)), e2 === n)
|
|
499
|
+
s4[n] = true;
|
|
500
|
+
else {
|
|
501
|
+
let r2 = s4[e2];
|
|
502
|
+
r2 || (r2 = /* @__PURE__ */ new Set(), s4[e2] = r2), r2.add(t2);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}, i2 = { get: (e2, n2) => n2 === t ? o2 : (f3("k", n2), a(Reflect.get(e2, n2), c3[r], c3.c, c3.t)), has: (t2, n2) => n2 === e ? (l2 = true, c3[r].delete(o2), true) : (f3("h", n2), Reflect.has(t2, n2)), getOwnPropertyDescriptor: (e2, t2) => (f3("o", t2), Reflect.getOwnPropertyDescriptor(e2, t2)), ownKeys: (e2) => (f3(n), Reflect.ownKeys(e2)) };
|
|
506
|
+
return s3 && (i2.set = i2.deleteProperty = () => false), [i2, c3];
|
|
507
|
+
})(y2, !!h2), w[1].p = o(h2 || y2, w[0]), f2 && f2.set(y2, w)), w[1][r] = c2, w[1].c = f2, w[1].t = p2, w[1].p;
|
|
508
|
+
};
|
|
509
|
+
var p = (e2, t2, r2, o2) => {
|
|
510
|
+
if (Object.is(e2, t2))
|
|
511
|
+
return false;
|
|
512
|
+
if (!f(e2) || !f(t2))
|
|
513
|
+
return true;
|
|
514
|
+
const s2 = r2.get(u(e2));
|
|
515
|
+
if (!s2)
|
|
516
|
+
return true;
|
|
517
|
+
if (o2) {
|
|
518
|
+
const r3 = o2.get(e2);
|
|
519
|
+
if (r3 && r3.n === t2)
|
|
520
|
+
return r3.g;
|
|
521
|
+
o2.set(e2, { n: t2, g: false });
|
|
522
|
+
}
|
|
523
|
+
let c2 = null;
|
|
524
|
+
try {
|
|
525
|
+
for (const r3 of s2.h || [])
|
|
526
|
+
if (c2 = Reflect.has(e2, r3) !== Reflect.has(t2, r3), c2)
|
|
527
|
+
return c2;
|
|
528
|
+
if (true === s2[n]) {
|
|
529
|
+
if (c2 = ((e3, t3) => {
|
|
530
|
+
const r3 = Reflect.ownKeys(e3), n2 = Reflect.ownKeys(t3);
|
|
531
|
+
return r3.length !== n2.length || r3.some((e4, t4) => e4 !== n2[t4]);
|
|
532
|
+
})(e2, t2), c2)
|
|
533
|
+
return c2;
|
|
534
|
+
} else
|
|
535
|
+
for (const r3 of s2.o || [])
|
|
536
|
+
if (c2 = !!Reflect.getOwnPropertyDescriptor(e2, r3) != !!Reflect.getOwnPropertyDescriptor(t2, r3), c2)
|
|
537
|
+
return c2;
|
|
538
|
+
for (const n2 of s2.k || [])
|
|
539
|
+
if (c2 = p(e2[n2], t2[n2], r2, o2), c2)
|
|
540
|
+
return c2;
|
|
541
|
+
return null === c2 && (c2 = true), c2;
|
|
542
|
+
} finally {
|
|
543
|
+
o2 && o2.set(e2, { n: t2, g: c2 });
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
var y = (e2) => l(e2) && e2[t] || null;
|
|
547
|
+
var h = (e2, t2 = true) => {
|
|
548
|
+
c.set(e2, t2);
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
// ../../node_modules/.pnpm/@zag-js+store@0.19.1/node_modules/@zag-js/store/dist/index.mjs
|
|
552
|
+
var isDev = process.env.NODE_ENV !== "production";
|
|
553
|
+
var isObject = (x) => typeof x === "object" && x !== null;
|
|
554
|
+
var proxyStateMap = /* @__PURE__ */ new WeakMap();
|
|
555
|
+
var refSet = /* @__PURE__ */ new WeakSet();
|
|
556
|
+
var buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), defaultHandlePromise = (promise) => {
|
|
557
|
+
switch (promise.status) {
|
|
558
|
+
case "fulfilled":
|
|
559
|
+
return promise.value;
|
|
560
|
+
case "rejected":
|
|
561
|
+
throw promise.reason;
|
|
562
|
+
default:
|
|
563
|
+
throw promise;
|
|
564
|
+
}
|
|
565
|
+
}, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version, handlePromise = defaultHandlePromise) => {
|
|
566
|
+
const cache = snapCache.get(target);
|
|
567
|
+
if (cache?.[0] === version) {
|
|
568
|
+
return cache[1];
|
|
569
|
+
}
|
|
570
|
+
const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
|
|
571
|
+
h(snap, true);
|
|
572
|
+
snapCache.set(target, [version, snap]);
|
|
573
|
+
Reflect.ownKeys(target).forEach((key) => {
|
|
574
|
+
const value = Reflect.get(target, key);
|
|
575
|
+
if (refSet.has(value)) {
|
|
576
|
+
h(value, false);
|
|
577
|
+
snap[key] = value;
|
|
578
|
+
} else if (value instanceof Promise) {
|
|
579
|
+
Object.defineProperty(snap, key, {
|
|
580
|
+
get() {
|
|
581
|
+
return handlePromise(value);
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
} else if (proxyStateMap.has(value)) {
|
|
585
|
+
snap[key] = snapshot(value, handlePromise);
|
|
586
|
+
} else {
|
|
587
|
+
snap[key] = value;
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
return Object.freeze(snap);
|
|
591
|
+
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = (initialObject) => {
|
|
592
|
+
if (!isObject(initialObject)) {
|
|
593
|
+
throw new Error("object required");
|
|
594
|
+
}
|
|
595
|
+
const found = proxyCache.get(initialObject);
|
|
596
|
+
if (found) {
|
|
597
|
+
return found;
|
|
598
|
+
}
|
|
599
|
+
let version = versionHolder[0];
|
|
600
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
601
|
+
const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
|
|
602
|
+
if (version !== nextVersion) {
|
|
603
|
+
version = nextVersion;
|
|
604
|
+
listeners.forEach((listener) => listener(op, nextVersion));
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
let checkVersion = versionHolder[1];
|
|
608
|
+
const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => {
|
|
609
|
+
if (checkVersion !== nextCheckVersion && !listeners.size) {
|
|
610
|
+
checkVersion = nextCheckVersion;
|
|
611
|
+
propProxyStates.forEach(([propProxyState]) => {
|
|
612
|
+
const propVersion = propProxyState[1](nextCheckVersion);
|
|
613
|
+
if (propVersion > version) {
|
|
614
|
+
version = propVersion;
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
return version;
|
|
619
|
+
};
|
|
620
|
+
const createPropListener = (prop) => (op, nextVersion) => {
|
|
621
|
+
const newOp = [...op];
|
|
622
|
+
newOp[1] = [prop, ...newOp[1]];
|
|
623
|
+
notifyUpdate(newOp, nextVersion);
|
|
624
|
+
};
|
|
625
|
+
const propProxyStates = /* @__PURE__ */ new Map();
|
|
626
|
+
const addPropListener = (prop, propProxyState) => {
|
|
627
|
+
if (isDev && propProxyStates.has(prop)) {
|
|
628
|
+
throw new Error("prop listener already exists");
|
|
629
|
+
}
|
|
630
|
+
if (listeners.size) {
|
|
631
|
+
const remove = propProxyState[3](createPropListener(prop));
|
|
632
|
+
propProxyStates.set(prop, [propProxyState, remove]);
|
|
633
|
+
} else {
|
|
634
|
+
propProxyStates.set(prop, [propProxyState]);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
const removePropListener = (prop) => {
|
|
638
|
+
const entry = propProxyStates.get(prop);
|
|
639
|
+
if (entry) {
|
|
640
|
+
propProxyStates.delete(prop);
|
|
641
|
+
entry[1]?.();
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
const addListener = (listener) => {
|
|
645
|
+
listeners.add(listener);
|
|
646
|
+
if (listeners.size === 1) {
|
|
647
|
+
propProxyStates.forEach(([propProxyState, prevRemove], prop) => {
|
|
648
|
+
if (isDev && prevRemove) {
|
|
649
|
+
throw new Error("remove already exists");
|
|
650
|
+
}
|
|
651
|
+
const remove = propProxyState[3](createPropListener(prop));
|
|
652
|
+
propProxyStates.set(prop, [propProxyState, remove]);
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
const removeListener = () => {
|
|
656
|
+
listeners.delete(listener);
|
|
657
|
+
if (listeners.size === 0) {
|
|
658
|
+
propProxyStates.forEach(([propProxyState, remove], prop) => {
|
|
659
|
+
if (remove) {
|
|
660
|
+
remove();
|
|
661
|
+
propProxyStates.set(prop, [propProxyState]);
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
return removeListener;
|
|
667
|
+
};
|
|
668
|
+
const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
|
|
669
|
+
const handler = {
|
|
670
|
+
deleteProperty(target, prop) {
|
|
671
|
+
const prevValue = Reflect.get(target, prop);
|
|
672
|
+
removePropListener(prop);
|
|
673
|
+
const deleted = Reflect.deleteProperty(target, prop);
|
|
674
|
+
if (deleted) {
|
|
675
|
+
notifyUpdate(["delete", [prop], prevValue]);
|
|
676
|
+
}
|
|
677
|
+
return deleted;
|
|
678
|
+
},
|
|
679
|
+
set(target, prop, value, receiver) {
|
|
680
|
+
const hasPrevValue = Reflect.has(target, prop);
|
|
681
|
+
const prevValue = Reflect.get(target, prop, receiver);
|
|
682
|
+
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) {
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
removePropListener(prop);
|
|
686
|
+
if (isObject(value)) {
|
|
687
|
+
value = y(value) || value;
|
|
688
|
+
}
|
|
689
|
+
let nextValue = value;
|
|
690
|
+
if (Object.getOwnPropertyDescriptor(target, prop)?.set) {
|
|
691
|
+
} else if (value instanceof Promise) {
|
|
692
|
+
value.then((v) => {
|
|
693
|
+
value.status = "fulfilled";
|
|
694
|
+
value.value = v;
|
|
695
|
+
notifyUpdate(["resolve", [prop], v]);
|
|
696
|
+
}).catch((e2) => {
|
|
697
|
+
value.status = "rejected";
|
|
698
|
+
value.reason = e2;
|
|
699
|
+
notifyUpdate(["reject", [prop], e2]);
|
|
700
|
+
});
|
|
701
|
+
} else {
|
|
702
|
+
if (!proxyStateMap.has(value) && canProxy(value)) {
|
|
703
|
+
nextValue = proxy(value);
|
|
704
|
+
}
|
|
705
|
+
const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);
|
|
706
|
+
if (childProxyState) {
|
|
707
|
+
addPropListener(prop, childProxyState);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
Reflect.set(target, prop, nextValue, receiver);
|
|
711
|
+
notifyUpdate(["set", [prop], value, prevValue]);
|
|
712
|
+
return true;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
const proxyObject = newProxy(baseObject, handler);
|
|
716
|
+
proxyCache.set(initialObject, proxyObject);
|
|
717
|
+
const proxyState = [baseObject, ensureVersion, createSnapshot, addListener];
|
|
718
|
+
proxyStateMap.set(proxyObject, proxyState);
|
|
719
|
+
Reflect.ownKeys(initialObject).forEach((key) => {
|
|
720
|
+
const desc = Object.getOwnPropertyDescriptor(initialObject, key);
|
|
721
|
+
if (desc.get || desc.set) {
|
|
722
|
+
Object.defineProperty(baseObject, key, desc);
|
|
723
|
+
} else {
|
|
724
|
+
proxyObject[key] = initialObject[key];
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
return proxyObject;
|
|
728
|
+
}) => [
|
|
729
|
+
// public functions
|
|
730
|
+
proxyFunction2,
|
|
731
|
+
// shared state
|
|
732
|
+
proxyStateMap,
|
|
733
|
+
refSet,
|
|
734
|
+
// internal things
|
|
735
|
+
objectIs,
|
|
736
|
+
newProxy,
|
|
737
|
+
canProxy,
|
|
738
|
+
defaultHandlePromise,
|
|
739
|
+
snapCache,
|
|
740
|
+
createSnapshot,
|
|
741
|
+
proxyCache,
|
|
742
|
+
versionHolder
|
|
743
|
+
];
|
|
744
|
+
var [proxyFunction] = buildProxyFunction();
|
|
745
|
+
function proxy(initialObject = {}) {
|
|
746
|
+
return proxyFunction(initialObject);
|
|
747
|
+
}
|
|
748
|
+
function subscribe(proxyObject, callback, notifyInSync) {
|
|
749
|
+
const proxyState = proxyStateMap.get(proxyObject);
|
|
750
|
+
if (isDev && !proxyState) {
|
|
751
|
+
console.warn("Please use proxy object");
|
|
752
|
+
}
|
|
753
|
+
let promise;
|
|
754
|
+
const ops = [];
|
|
755
|
+
const addListener = proxyState[3];
|
|
756
|
+
let isListenerActive = false;
|
|
757
|
+
const listener = (op) => {
|
|
758
|
+
ops.push(op);
|
|
759
|
+
if (notifyInSync) {
|
|
760
|
+
callback(ops.splice(0));
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
if (!promise) {
|
|
764
|
+
promise = Promise.resolve().then(() => {
|
|
765
|
+
promise = void 0;
|
|
766
|
+
if (isListenerActive) {
|
|
767
|
+
callback(ops.splice(0));
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
const removeListener = addListener(listener);
|
|
773
|
+
isListenerActive = true;
|
|
774
|
+
return () => {
|
|
775
|
+
isListenerActive = false;
|
|
776
|
+
removeListener();
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function snapshot(proxyObject, handlePromise) {
|
|
780
|
+
const proxyState = proxyStateMap.get(proxyObject);
|
|
781
|
+
if (isDev && !proxyState) {
|
|
782
|
+
console.warn("Please use proxy object");
|
|
783
|
+
}
|
|
784
|
+
const [target, ensureVersion, createSnapshot] = proxyState;
|
|
785
|
+
return createSnapshot(target, ensureVersion(), handlePromise);
|
|
786
|
+
}
|
|
787
|
+
function ref(obj) {
|
|
788
|
+
refSet.add(obj);
|
|
789
|
+
return obj;
|
|
790
|
+
}
|
|
791
|
+
function proxyWithComputed(initialObject, computedFns) {
|
|
792
|
+
const keys = Object.keys(computedFns);
|
|
793
|
+
keys.forEach((key) => {
|
|
794
|
+
if (Object.getOwnPropertyDescriptor(initialObject, key)) {
|
|
795
|
+
throw new Error("object property already defined");
|
|
796
|
+
}
|
|
797
|
+
const computedFn = computedFns[key];
|
|
798
|
+
const { get, set: set2 } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
|
|
799
|
+
const desc = {};
|
|
800
|
+
desc.get = () => get(snapshot(proxyObject));
|
|
801
|
+
if (set2) {
|
|
802
|
+
desc.set = (newValue) => set2(proxyObject, newValue);
|
|
803
|
+
}
|
|
804
|
+
Object.defineProperty(initialObject, key, desc);
|
|
805
|
+
});
|
|
806
|
+
const proxyObject = proxy(initialObject);
|
|
807
|
+
return proxyObject;
|
|
808
|
+
}
|
|
809
|
+
var defaultCompareFn = (prev, next) => Object.is(prev, next);
|
|
810
|
+
function subscribeKey(obj, key, fn, sync, compareFn) {
|
|
811
|
+
let prev = Reflect.get(snapshot(obj), key);
|
|
812
|
+
const isEqual = compareFn || defaultCompareFn;
|
|
813
|
+
function onSnapshotChange() {
|
|
814
|
+
const snap = snapshot(obj);
|
|
815
|
+
if (isEqual(prev, snap[key]))
|
|
816
|
+
return;
|
|
817
|
+
fn(snap[key]);
|
|
818
|
+
prev = Reflect.get(snap, key);
|
|
819
|
+
}
|
|
820
|
+
return subscribe(obj, onSnapshotChange, sync);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/full/index.mjs
|
|
824
|
+
function set(obj, key, val) {
|
|
825
|
+
if (typeof val.value === "object")
|
|
826
|
+
val.value = klona(val.value);
|
|
827
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
|
|
828
|
+
Object.defineProperty(obj, key, val);
|
|
829
|
+
} else
|
|
830
|
+
obj[key] = val.value;
|
|
831
|
+
}
|
|
832
|
+
function klona(x) {
|
|
833
|
+
if (typeof x !== "object")
|
|
834
|
+
return x;
|
|
835
|
+
var i2 = 0, k, list, tmp, str = Object.prototype.toString.call(x);
|
|
836
|
+
if (str === "[object Object]") {
|
|
837
|
+
tmp = Object.create(x.__proto__ || null);
|
|
838
|
+
} else if (str === "[object Array]") {
|
|
839
|
+
tmp = Array(x.length);
|
|
840
|
+
} else if (str === "[object Set]") {
|
|
841
|
+
tmp = /* @__PURE__ */ new Set();
|
|
842
|
+
x.forEach(function(val) {
|
|
843
|
+
tmp.add(klona(val));
|
|
844
|
+
});
|
|
845
|
+
} else if (str === "[object Map]") {
|
|
846
|
+
tmp = /* @__PURE__ */ new Map();
|
|
847
|
+
x.forEach(function(val, key) {
|
|
848
|
+
tmp.set(klona(key), klona(val));
|
|
849
|
+
});
|
|
850
|
+
} else if (str === "[object Date]") {
|
|
851
|
+
tmp = /* @__PURE__ */ new Date(+x);
|
|
852
|
+
} else if (str === "[object RegExp]") {
|
|
853
|
+
tmp = new RegExp(x.source, x.flags);
|
|
854
|
+
} else if (str === "[object DataView]") {
|
|
855
|
+
tmp = new x.constructor(klona(x.buffer));
|
|
856
|
+
} else if (str === "[object ArrayBuffer]") {
|
|
857
|
+
tmp = x.slice(0);
|
|
858
|
+
} else if (str.slice(-6) === "Array]") {
|
|
859
|
+
tmp = new x.constructor(x);
|
|
860
|
+
}
|
|
861
|
+
if (tmp) {
|
|
862
|
+
for (list = Object.getOwnPropertySymbols(x); i2 < list.length; i2++) {
|
|
863
|
+
set(tmp, list[i2], Object.getOwnPropertyDescriptor(x, list[i2]));
|
|
864
|
+
}
|
|
865
|
+
for (i2 = 0, list = Object.getOwnPropertyNames(x); i2 < list.length; i2++) {
|
|
866
|
+
if (Object.hasOwnProperty.call(tmp, k = list[i2]) && tmp[k] === x[k])
|
|
867
|
+
continue;
|
|
868
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
return tmp || x;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// ../../node_modules/.pnpm/@zag-js+core@0.19.1/node_modules/@zag-js/core/dist/index.mjs
|
|
875
|
+
var __defProp2 = Object.defineProperty;
|
|
876
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
877
|
+
var __publicField = (obj, key, value) => {
|
|
878
|
+
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
879
|
+
return value;
|
|
880
|
+
};
|
|
881
|
+
function clear(v) {
|
|
882
|
+
while (v.length > 0)
|
|
883
|
+
v.pop();
|
|
884
|
+
return v;
|
|
885
|
+
}
|
|
886
|
+
var runIfFn = (v, ...a2) => {
|
|
887
|
+
const res = typeof v === "function" ? v(...a2) : v;
|
|
888
|
+
return res ?? void 0;
|
|
889
|
+
};
|
|
890
|
+
var cast = (v) => v;
|
|
891
|
+
var noop = () => {
|
|
892
|
+
};
|
|
893
|
+
var uuid = /* @__PURE__ */ (() => {
|
|
894
|
+
let id = 0;
|
|
895
|
+
return () => {
|
|
896
|
+
id++;
|
|
897
|
+
return id.toString(36);
|
|
898
|
+
};
|
|
899
|
+
})();
|
|
900
|
+
var isDev2 = () => process.env.NODE_ENV !== "production";
|
|
901
|
+
var isArray = (v) => Array.isArray(v);
|
|
902
|
+
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
903
|
+
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
|
|
904
|
+
var isString = (v) => typeof v === "string";
|
|
905
|
+
var isFunction = (v) => typeof v === "function";
|
|
906
|
+
function compact2(obj) {
|
|
907
|
+
if (!isPlainObject2(obj) || obj === void 0) {
|
|
908
|
+
return obj;
|
|
909
|
+
}
|
|
910
|
+
const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
911
|
+
const filtered = {};
|
|
912
|
+
for (const key of keys) {
|
|
913
|
+
const value = obj[key];
|
|
914
|
+
if (value !== void 0) {
|
|
915
|
+
filtered[key] = compact2(value);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
return filtered;
|
|
919
|
+
}
|
|
920
|
+
var isPlainObject2 = (value) => {
|
|
921
|
+
return value && typeof value === "object" && value.constructor === Object;
|
|
922
|
+
};
|
|
923
|
+
function warn(...a2) {
|
|
924
|
+
const m = a2.length === 1 ? a2[0] : a2[1];
|
|
925
|
+
const c2 = a2.length === 2 ? a2[0] : true;
|
|
926
|
+
if (c2 && process.env.NODE_ENV !== "production") {
|
|
927
|
+
console.warn(m);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function invariant(...a2) {
|
|
931
|
+
const m = a2.length === 1 ? a2[0] : a2[1];
|
|
932
|
+
const c2 = a2.length === 2 ? a2[0] : true;
|
|
933
|
+
if (c2 && process.env.NODE_ENV !== "production") {
|
|
934
|
+
throw new Error(m);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function deepMerge(source, ...objects) {
|
|
938
|
+
for (const obj of objects) {
|
|
939
|
+
const target = compact2(obj);
|
|
940
|
+
for (const key in target) {
|
|
941
|
+
if (isObject2(obj[key])) {
|
|
942
|
+
if (!source[key]) {
|
|
943
|
+
source[key] = {};
|
|
944
|
+
}
|
|
945
|
+
deepMerge(source[key], obj[key]);
|
|
946
|
+
} else {
|
|
947
|
+
source[key] = obj[key];
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return source;
|
|
952
|
+
}
|
|
953
|
+
function structuredClone(v) {
|
|
954
|
+
return klona(v);
|
|
955
|
+
}
|
|
956
|
+
function toEvent(event) {
|
|
957
|
+
const obj = isString(event) ? { type: event } : event;
|
|
958
|
+
return obj;
|
|
959
|
+
}
|
|
960
|
+
function toArray(value) {
|
|
961
|
+
if (!value)
|
|
962
|
+
return [];
|
|
963
|
+
return isArray(value) ? value.slice() : [value];
|
|
964
|
+
}
|
|
965
|
+
function isGuardHelper(value) {
|
|
966
|
+
return isObject2(value) && value.predicate != null;
|
|
967
|
+
}
|
|
968
|
+
var Truthy = () => true;
|
|
969
|
+
function exec(guardMap, ctx, event, meta) {
|
|
970
|
+
return (guard) => {
|
|
971
|
+
if (isString(guard)) {
|
|
972
|
+
return !!guardMap[guard]?.(ctx, event, meta);
|
|
973
|
+
}
|
|
974
|
+
if (isFunction(guard)) {
|
|
975
|
+
return guard(ctx, event, meta);
|
|
976
|
+
}
|
|
977
|
+
return guard.predicate(guardMap)(ctx, event, meta);
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
function or(...conditions) {
|
|
981
|
+
return {
|
|
982
|
+
predicate: (guardMap) => (ctx, event, meta) => conditions.map(exec(guardMap, ctx, event, meta)).some(Boolean)
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
function and(...conditions) {
|
|
986
|
+
return {
|
|
987
|
+
predicate: (guardMap) => (ctx, event, meta) => conditions.map(exec(guardMap, ctx, event, meta)).every(Boolean)
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
function not(condition) {
|
|
991
|
+
return {
|
|
992
|
+
predicate: (guardMap) => (ctx, event, meta) => {
|
|
993
|
+
return !exec(guardMap, ctx, event, meta)(condition);
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
function stateIn(...values) {
|
|
998
|
+
return (_ctx, _evt, meta) => meta.state.matches(...values);
|
|
999
|
+
}
|
|
1000
|
+
var guards = { or, and, not, stateIn };
|
|
1001
|
+
function determineGuardFn(guard, guardMap) {
|
|
1002
|
+
guard = guard ?? Truthy;
|
|
1003
|
+
return (context, event, meta) => {
|
|
1004
|
+
if (isString(guard)) {
|
|
1005
|
+
const value = guardMap[guard];
|
|
1006
|
+
return isFunction(value) ? value(context, event, meta) : value;
|
|
1007
|
+
}
|
|
1008
|
+
if (isGuardHelper(guard)) {
|
|
1009
|
+
return guard.predicate(guardMap)(context, event, meta);
|
|
1010
|
+
}
|
|
1011
|
+
return guard?.(context, event, meta);
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
function determineActionsFn(values, guardMap) {
|
|
1015
|
+
return (context, event, meta) => {
|
|
1016
|
+
if (isGuardHelper(values)) {
|
|
1017
|
+
return values.predicate(guardMap)(context, event, meta);
|
|
1018
|
+
}
|
|
1019
|
+
return values;
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
function createProxy(config) {
|
|
1023
|
+
const computedContext = config.computed ?? cast({});
|
|
1024
|
+
const initialContext = config.context ?? cast({});
|
|
1025
|
+
const state = proxy({
|
|
1026
|
+
value: config.initial ?? "",
|
|
1027
|
+
previousValue: "",
|
|
1028
|
+
event: cast({}),
|
|
1029
|
+
previousEvent: cast({}),
|
|
1030
|
+
context: proxyWithComputed(initialContext, computedContext),
|
|
1031
|
+
done: false,
|
|
1032
|
+
tags: [],
|
|
1033
|
+
hasTag(tag) {
|
|
1034
|
+
return this.tags.includes(tag);
|
|
1035
|
+
},
|
|
1036
|
+
matches(...value) {
|
|
1037
|
+
return value.includes(this.value);
|
|
1038
|
+
},
|
|
1039
|
+
can(event) {
|
|
1040
|
+
return cast(this).nextEvents.includes(event);
|
|
1041
|
+
},
|
|
1042
|
+
get nextEvents() {
|
|
1043
|
+
const stateEvents = config.states?.[this.value]?.["on"] ?? {};
|
|
1044
|
+
const globalEvents = config?.on ?? {};
|
|
1045
|
+
return Object.keys({ ...stateEvents, ...globalEvents });
|
|
1046
|
+
},
|
|
1047
|
+
get changed() {
|
|
1048
|
+
if (this.event.value === "machine.init" || !this.previousValue)
|
|
1049
|
+
return false;
|
|
1050
|
+
return this.value !== this.previousValue;
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
return cast(state);
|
|
1054
|
+
}
|
|
1055
|
+
function determineDelayFn(delay, delaysMap) {
|
|
1056
|
+
return (context, event) => {
|
|
1057
|
+
if (isNumber(delay))
|
|
1058
|
+
return delay;
|
|
1059
|
+
if (isFunction(delay)) {
|
|
1060
|
+
return delay(context, event);
|
|
1061
|
+
}
|
|
1062
|
+
if (isString(delay)) {
|
|
1063
|
+
const value = Number.parseFloat(delay);
|
|
1064
|
+
if (!Number.isNaN(value)) {
|
|
1065
|
+
return value;
|
|
1066
|
+
}
|
|
1067
|
+
if (delaysMap) {
|
|
1068
|
+
const valueOrFn = delaysMap?.[delay];
|
|
1069
|
+
invariant(
|
|
1070
|
+
valueOrFn == null,
|
|
1071
|
+
`[@zag-js/core > determine-delay] Cannot determine delay for \`${delay}\`. It doesn't exist in \`options.delays\``
|
|
1072
|
+
);
|
|
1073
|
+
return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
function toTarget(target) {
|
|
1079
|
+
return isString(target) ? { target } : target;
|
|
1080
|
+
}
|
|
1081
|
+
function determineTransitionFn(transitions, guardMap) {
|
|
1082
|
+
return (context, event, meta) => {
|
|
1083
|
+
return toArray(transitions).map(toTarget).find((transition) => {
|
|
1084
|
+
const determineGuard = determineGuardFn(transition.guard, guardMap);
|
|
1085
|
+
const guard = determineGuard(context, event, meta);
|
|
1086
|
+
return guard ?? transition.target ?? transition.actions;
|
|
1087
|
+
});
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
var Machine = class _Machine {
|
|
1091
|
+
// Let's get started!
|
|
1092
|
+
constructor(config, options) {
|
|
1093
|
+
__publicField(
|
|
1094
|
+
this,
|
|
1095
|
+
"status",
|
|
1096
|
+
"Not Started"
|
|
1097
|
+
/* NotStarted */
|
|
1098
|
+
);
|
|
1099
|
+
__publicField(this, "state");
|
|
1100
|
+
__publicField(this, "initialState");
|
|
1101
|
+
__publicField(this, "initialContext");
|
|
1102
|
+
__publicField(this, "id");
|
|
1103
|
+
__publicField(
|
|
1104
|
+
this,
|
|
1105
|
+
"type",
|
|
1106
|
+
"machine"
|
|
1107
|
+
/* Machine */
|
|
1108
|
+
);
|
|
1109
|
+
__publicField(this, "activityEvents", /* @__PURE__ */ new Map());
|
|
1110
|
+
__publicField(this, "delayedEvents", /* @__PURE__ */ new Map());
|
|
1111
|
+
__publicField(this, "stateListeners", /* @__PURE__ */ new Set());
|
|
1112
|
+
__publicField(this, "contextListeners", /* @__PURE__ */ new Set());
|
|
1113
|
+
__publicField(this, "eventListeners", /* @__PURE__ */ new Set());
|
|
1114
|
+
__publicField(this, "doneListeners", /* @__PURE__ */ new Set());
|
|
1115
|
+
__publicField(this, "contextWatchers", /* @__PURE__ */ new Set());
|
|
1116
|
+
__publicField(this, "removeStateListener", noop);
|
|
1117
|
+
__publicField(this, "removeEventListener", noop);
|
|
1118
|
+
__publicField(this, "removeContextListener", noop);
|
|
1119
|
+
__publicField(this, "parent");
|
|
1120
|
+
__publicField(this, "children", /* @__PURE__ */ new Map());
|
|
1121
|
+
__publicField(this, "guardMap");
|
|
1122
|
+
__publicField(this, "actionMap");
|
|
1123
|
+
__publicField(this, "delayMap");
|
|
1124
|
+
__publicField(this, "activityMap");
|
|
1125
|
+
__publicField(this, "sync");
|
|
1126
|
+
__publicField(this, "options");
|
|
1127
|
+
__publicField(this, "config");
|
|
1128
|
+
__publicField(this, "start", (init) => {
|
|
1129
|
+
this.state.value = "";
|
|
1130
|
+
if (this.status === "Running") {
|
|
1131
|
+
return this;
|
|
1132
|
+
}
|
|
1133
|
+
this.status = "Running";
|
|
1134
|
+
this.removeStateListener = subscribe(
|
|
1135
|
+
this.state,
|
|
1136
|
+
() => {
|
|
1137
|
+
this.stateListeners.forEach((listener) => {
|
|
1138
|
+
listener(this.stateSnapshot);
|
|
1139
|
+
});
|
|
1140
|
+
},
|
|
1141
|
+
this.sync
|
|
1142
|
+
);
|
|
1143
|
+
this.removeEventListener = subscribeKey(
|
|
1144
|
+
this.state,
|
|
1145
|
+
"event",
|
|
1146
|
+
(event22) => {
|
|
1147
|
+
this.executeActions(this.config.onEvent, event22);
|
|
1148
|
+
this.eventListeners.forEach((listener) => {
|
|
1149
|
+
listener(event22);
|
|
1150
|
+
});
|
|
1151
|
+
},
|
|
1152
|
+
this.sync
|
|
1153
|
+
);
|
|
1154
|
+
this.removeContextListener = subscribe(
|
|
1155
|
+
this.state.context,
|
|
1156
|
+
() => {
|
|
1157
|
+
this.log("Context:", this.contextSnapshot);
|
|
1158
|
+
this.contextListeners.forEach((listener) => {
|
|
1159
|
+
listener(this.contextSnapshot);
|
|
1160
|
+
});
|
|
1161
|
+
},
|
|
1162
|
+
this.sync || this.options.debug
|
|
1163
|
+
);
|
|
1164
|
+
this.setupContextWatchers();
|
|
1165
|
+
this.executeActivities(
|
|
1166
|
+
toEvent(
|
|
1167
|
+
"machine.start"
|
|
1168
|
+
/* Start */
|
|
1169
|
+
),
|
|
1170
|
+
toArray(this.config.activities),
|
|
1171
|
+
"machine.start"
|
|
1172
|
+
/* Start */
|
|
1173
|
+
);
|
|
1174
|
+
this.executeActions(this.config.entry, toEvent(
|
|
1175
|
+
"machine.start"
|
|
1176
|
+
/* Start */
|
|
1177
|
+
));
|
|
1178
|
+
const event2 = toEvent(
|
|
1179
|
+
"machine.init"
|
|
1180
|
+
/* Init */
|
|
1181
|
+
);
|
|
1182
|
+
const target = isObject2(init) ? init.value : init;
|
|
1183
|
+
const context = isObject2(init) ? init.context : void 0;
|
|
1184
|
+
if (context) {
|
|
1185
|
+
this.setContext(context);
|
|
1186
|
+
}
|
|
1187
|
+
const transition = {
|
|
1188
|
+
target: target ?? this.config.initial
|
|
1189
|
+
};
|
|
1190
|
+
const next = this.getNextStateInfo(transition, event2);
|
|
1191
|
+
this.initialState = next;
|
|
1192
|
+
this.performStateChangeEffects(this.state.value, next, event2);
|
|
1193
|
+
return this;
|
|
1194
|
+
});
|
|
1195
|
+
__publicField(this, "setupContextWatchers", () => {
|
|
1196
|
+
for (const [key, fn] of Object.entries(this.config.watch ?? {})) {
|
|
1197
|
+
const compareFn = this.options.compareFns?.[key];
|
|
1198
|
+
const cleanup = subscribeKey(
|
|
1199
|
+
this.state.context,
|
|
1200
|
+
key,
|
|
1201
|
+
() => {
|
|
1202
|
+
this.executeActions(fn, this.state.event);
|
|
1203
|
+
},
|
|
1204
|
+
this.sync,
|
|
1205
|
+
compareFn
|
|
1206
|
+
);
|
|
1207
|
+
this.contextWatchers.add(cleanup);
|
|
1208
|
+
}
|
|
1209
|
+
});
|
|
1210
|
+
__publicField(this, "stop", () => {
|
|
1211
|
+
if (this.status === "Stopped")
|
|
1212
|
+
return;
|
|
1213
|
+
this.performExitEffects(this.state.value, toEvent(
|
|
1214
|
+
"machine.stop"
|
|
1215
|
+
/* Stop */
|
|
1216
|
+
));
|
|
1217
|
+
this.executeActions(this.config.exit, toEvent(
|
|
1218
|
+
"machine.stop"
|
|
1219
|
+
/* Stop */
|
|
1220
|
+
));
|
|
1221
|
+
this.setState("");
|
|
1222
|
+
this.setEvent(
|
|
1223
|
+
"machine.stop"
|
|
1224
|
+
/* Stop */
|
|
1225
|
+
);
|
|
1226
|
+
this.stopStateListeners();
|
|
1227
|
+
this.stopChildren();
|
|
1228
|
+
this.stopActivities();
|
|
1229
|
+
this.stopDelayedEvents();
|
|
1230
|
+
this.stopContextWatchers();
|
|
1231
|
+
this.stopEventListeners();
|
|
1232
|
+
this.stopContextListeners();
|
|
1233
|
+
this.status = "Stopped";
|
|
1234
|
+
return this;
|
|
1235
|
+
});
|
|
1236
|
+
__publicField(this, "stopEventListeners", () => {
|
|
1237
|
+
this.eventListeners.clear();
|
|
1238
|
+
this.removeEventListener();
|
|
1239
|
+
});
|
|
1240
|
+
__publicField(this, "stopContextListeners", () => {
|
|
1241
|
+
this.contextListeners.clear();
|
|
1242
|
+
this.removeContextListener();
|
|
1243
|
+
});
|
|
1244
|
+
__publicField(this, "stopStateListeners", () => {
|
|
1245
|
+
this.removeStateListener();
|
|
1246
|
+
this.stateListeners.clear();
|
|
1247
|
+
});
|
|
1248
|
+
__publicField(this, "stopContextWatchers", () => {
|
|
1249
|
+
this.contextWatchers.forEach((fn) => fn());
|
|
1250
|
+
this.contextWatchers.clear();
|
|
1251
|
+
});
|
|
1252
|
+
__publicField(this, "stopDelayedEvents", () => {
|
|
1253
|
+
this.delayedEvents.forEach((state) => {
|
|
1254
|
+
state.forEach((stop) => stop());
|
|
1255
|
+
});
|
|
1256
|
+
this.delayedEvents.clear();
|
|
1257
|
+
});
|
|
1258
|
+
__publicField(this, "stopActivities", (state) => {
|
|
1259
|
+
if (state) {
|
|
1260
|
+
this.activityEvents.get(state)?.forEach((stop) => stop());
|
|
1261
|
+
this.activityEvents.get(state)?.clear();
|
|
1262
|
+
this.activityEvents.delete(state);
|
|
1263
|
+
} else {
|
|
1264
|
+
this.activityEvents.forEach((state2) => {
|
|
1265
|
+
state2.forEach((stop) => stop());
|
|
1266
|
+
state2.clear();
|
|
1267
|
+
});
|
|
1268
|
+
this.activityEvents.clear();
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
__publicField(this, "sendChild", (evt, to) => {
|
|
1272
|
+
const event2 = toEvent(evt);
|
|
1273
|
+
const id = runIfFn(to, this.contextSnapshot);
|
|
1274
|
+
const child = this.children.get(id);
|
|
1275
|
+
if (!child) {
|
|
1276
|
+
invariant(`[@zag-js/core] Cannot send '${event2.type}' event to unknown child`);
|
|
1277
|
+
}
|
|
1278
|
+
child.send(event2);
|
|
1279
|
+
});
|
|
1280
|
+
__publicField(this, "stopChild", (id) => {
|
|
1281
|
+
if (!this.children.has(id)) {
|
|
1282
|
+
invariant(`[@zag-js/core > stop-child] Cannot stop unknown child ${id}`);
|
|
1283
|
+
}
|
|
1284
|
+
this.children.get(id).stop();
|
|
1285
|
+
this.children.delete(id);
|
|
1286
|
+
});
|
|
1287
|
+
__publicField(this, "removeChild", (id) => {
|
|
1288
|
+
this.children.delete(id);
|
|
1289
|
+
});
|
|
1290
|
+
__publicField(this, "stopChildren", () => {
|
|
1291
|
+
this.children.forEach((child) => child.stop());
|
|
1292
|
+
this.children.clear();
|
|
1293
|
+
});
|
|
1294
|
+
__publicField(this, "setParent", (parent) => {
|
|
1295
|
+
this.parent = parent;
|
|
1296
|
+
});
|
|
1297
|
+
__publicField(this, "spawn", (src, id) => {
|
|
1298
|
+
const actor = runIfFn(src);
|
|
1299
|
+
if (id)
|
|
1300
|
+
actor.id = id;
|
|
1301
|
+
actor.type = "machine.actor";
|
|
1302
|
+
actor.setParent(this);
|
|
1303
|
+
this.children.set(actor.id, cast(actor));
|
|
1304
|
+
actor.onDone(() => {
|
|
1305
|
+
this.removeChild(actor.id);
|
|
1306
|
+
}).start();
|
|
1307
|
+
return cast(ref(actor));
|
|
1308
|
+
});
|
|
1309
|
+
__publicField(this, "stopActivity", (key) => {
|
|
1310
|
+
if (!this.state.value)
|
|
1311
|
+
return;
|
|
1312
|
+
const cleanups = this.activityEvents.get(this.state.value);
|
|
1313
|
+
cleanups?.get(key)?.();
|
|
1314
|
+
cleanups?.delete(key);
|
|
1315
|
+
});
|
|
1316
|
+
__publicField(this, "addActivityCleanup", (state, key, cleanup) => {
|
|
1317
|
+
if (!state)
|
|
1318
|
+
return;
|
|
1319
|
+
if (!this.activityEvents.has(state)) {
|
|
1320
|
+
this.activityEvents.set(state, /* @__PURE__ */ new Map([[key, cleanup]]));
|
|
1321
|
+
} else {
|
|
1322
|
+
this.activityEvents.get(state)?.set(key, cleanup);
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
__publicField(this, "setState", (target) => {
|
|
1326
|
+
this.state.previousValue = this.state.value;
|
|
1327
|
+
this.state.value = target;
|
|
1328
|
+
const stateNode = this.getStateNode(target);
|
|
1329
|
+
if (target == null) {
|
|
1330
|
+
clear(this.state.tags);
|
|
1331
|
+
} else {
|
|
1332
|
+
this.state.tags = toArray(stateNode?.tags);
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
__publicField(this, "transformContext", (context) => {
|
|
1336
|
+
this.options?.transformContext?.(context);
|
|
1337
|
+
return context;
|
|
1338
|
+
});
|
|
1339
|
+
__publicField(this, "setContext", (context) => {
|
|
1340
|
+
if (!context)
|
|
1341
|
+
return;
|
|
1342
|
+
deepMerge(this.state.context, this.transformContext(context));
|
|
1343
|
+
});
|
|
1344
|
+
__publicField(this, "withContext", (context) => {
|
|
1345
|
+
const transformed = this.transformContext(context);
|
|
1346
|
+
const newContext = { ...this.config.context, ...compact2(transformed) };
|
|
1347
|
+
return new _Machine({ ...this.config, context: newContext }, this.options);
|
|
1348
|
+
});
|
|
1349
|
+
__publicField(this, "setOptions", (options2) => {
|
|
1350
|
+
const opts = compact2(options2);
|
|
1351
|
+
this.actionMap = { ...this.actionMap, ...opts.actions };
|
|
1352
|
+
this.delayMap = { ...this.delayMap, ...opts.delays };
|
|
1353
|
+
this.activityMap = { ...this.activityMap, ...opts.activities };
|
|
1354
|
+
this.guardMap = { ...this.guardMap, ...opts.guards };
|
|
1355
|
+
});
|
|
1356
|
+
__publicField(this, "getStateNode", (state) => {
|
|
1357
|
+
if (!state)
|
|
1358
|
+
return;
|
|
1359
|
+
return this.config.states?.[state];
|
|
1360
|
+
});
|
|
1361
|
+
__publicField(this, "getNextStateInfo", (transitions, event2) => {
|
|
1362
|
+
const transition = this.determineTransition(transitions, event2);
|
|
1363
|
+
const isTargetless = !transition?.target;
|
|
1364
|
+
const target = transition?.target ?? this.state.value;
|
|
1365
|
+
const changed = this.state.value !== target;
|
|
1366
|
+
const stateNode = this.getStateNode(target);
|
|
1367
|
+
const reenter = !isTargetless && !changed && !transition?.internal;
|
|
1368
|
+
const info = {
|
|
1369
|
+
reenter,
|
|
1370
|
+
transition,
|
|
1371
|
+
stateNode,
|
|
1372
|
+
target,
|
|
1373
|
+
changed
|
|
1374
|
+
};
|
|
1375
|
+
this.log("NextState:", `[${event2.type}]`, this.state.value, "---->", info.target);
|
|
1376
|
+
return info;
|
|
1377
|
+
});
|
|
1378
|
+
__publicField(this, "getActionFromDelayedTransition", (transition) => {
|
|
1379
|
+
const event2 = toEvent(
|
|
1380
|
+
"machine.after"
|
|
1381
|
+
/* After */
|
|
1382
|
+
);
|
|
1383
|
+
const determineDelay = determineDelayFn(transition.delay, this.delayMap);
|
|
1384
|
+
const delay = determineDelay(this.contextSnapshot, event2);
|
|
1385
|
+
let id;
|
|
1386
|
+
return {
|
|
1387
|
+
entry: () => {
|
|
1388
|
+
id = globalThis.setTimeout(() => {
|
|
1389
|
+
const next = this.getNextStateInfo(transition, event2);
|
|
1390
|
+
this.performStateChangeEffects(this.state.value, next, event2);
|
|
1391
|
+
}, delay);
|
|
1392
|
+
},
|
|
1393
|
+
exit: () => {
|
|
1394
|
+
globalThis.clearTimeout(id);
|
|
1395
|
+
}
|
|
1396
|
+
};
|
|
1397
|
+
});
|
|
1398
|
+
__publicField(this, "getDelayedEventActions", (state) => {
|
|
1399
|
+
const stateNode = this.getStateNode(state);
|
|
1400
|
+
const event2 = toEvent(
|
|
1401
|
+
"machine.after"
|
|
1402
|
+
/* After */
|
|
1403
|
+
);
|
|
1404
|
+
if (!stateNode || !stateNode.after)
|
|
1405
|
+
return;
|
|
1406
|
+
const entries = [];
|
|
1407
|
+
const exits = [];
|
|
1408
|
+
if (isArray(stateNode.after)) {
|
|
1409
|
+
const transition = this.determineTransition(stateNode.after, event2);
|
|
1410
|
+
if (!transition)
|
|
1411
|
+
return;
|
|
1412
|
+
const actions = this.getActionFromDelayedTransition(transition);
|
|
1413
|
+
entries.push(actions.entry);
|
|
1414
|
+
exits.push(actions.exit);
|
|
1415
|
+
} else if (isObject2(stateNode.after)) {
|
|
1416
|
+
for (const delay in stateNode.after) {
|
|
1417
|
+
const transition = stateNode.after[delay];
|
|
1418
|
+
let resolvedTransition = {};
|
|
1419
|
+
if (isArray(transition)) {
|
|
1420
|
+
const picked = this.determineTransition(transition, event2);
|
|
1421
|
+
if (picked)
|
|
1422
|
+
resolvedTransition = picked;
|
|
1423
|
+
} else if (isString(transition)) {
|
|
1424
|
+
resolvedTransition = { target: transition, delay };
|
|
1425
|
+
} else {
|
|
1426
|
+
resolvedTransition = { ...transition, delay };
|
|
1427
|
+
}
|
|
1428
|
+
const actions = this.getActionFromDelayedTransition(resolvedTransition);
|
|
1429
|
+
entries.push(actions.entry);
|
|
1430
|
+
exits.push(actions.exit);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
return { entries, exits };
|
|
1434
|
+
});
|
|
1435
|
+
__publicField(this, "executeActions", (actions, event2) => {
|
|
1436
|
+
const pickedActions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event2, this.guardMeta);
|
|
1437
|
+
for (const action of toArray(pickedActions)) {
|
|
1438
|
+
const fn = isString(action) ? this.actionMap?.[action] : action;
|
|
1439
|
+
warn(
|
|
1440
|
+
isString(action) && !fn,
|
|
1441
|
+
`[@zag-js/core > execute-actions] No implementation found for action: \`${action}\``
|
|
1442
|
+
);
|
|
1443
|
+
fn?.(this.state.context, event2, this.meta);
|
|
1444
|
+
}
|
|
1445
|
+
});
|
|
1446
|
+
__publicField(this, "executeActivities", (event2, activities, state) => {
|
|
1447
|
+
for (const activity of activities) {
|
|
1448
|
+
const fn = isString(activity) ? this.activityMap?.[activity] : activity;
|
|
1449
|
+
if (!fn) {
|
|
1450
|
+
warn(`[@zag-js/core > execute-activity] No implementation found for activity: \`${activity}\``);
|
|
1451
|
+
continue;
|
|
1452
|
+
}
|
|
1453
|
+
const cleanup = fn(this.state.context, event2, this.meta);
|
|
1454
|
+
if (cleanup) {
|
|
1455
|
+
const key = isString(activity) ? activity : activity.name || uuid();
|
|
1456
|
+
this.addActivityCleanup(state ?? this.state.value, key, cleanup);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
__publicField(this, "createEveryActivities", (every, callbackfn) => {
|
|
1461
|
+
if (!every)
|
|
1462
|
+
return;
|
|
1463
|
+
const event2 = toEvent(
|
|
1464
|
+
"machine.every"
|
|
1465
|
+
/* Every */
|
|
1466
|
+
);
|
|
1467
|
+
if (isArray(every)) {
|
|
1468
|
+
const picked = toArray(every).find((transition) => {
|
|
1469
|
+
const delayOrFn = transition.delay;
|
|
1470
|
+
const determineDelay2 = determineDelayFn(delayOrFn, this.delayMap);
|
|
1471
|
+
const delay2 = determineDelay2(this.contextSnapshot, event2);
|
|
1472
|
+
const determineGuard = determineGuardFn(transition.guard, this.guardMap);
|
|
1473
|
+
const guard = determineGuard(this.contextSnapshot, event2, this.guardMeta);
|
|
1474
|
+
return guard ?? delay2 != null;
|
|
1475
|
+
});
|
|
1476
|
+
if (!picked)
|
|
1477
|
+
return;
|
|
1478
|
+
const determineDelay = determineDelayFn(picked.delay, this.delayMap);
|
|
1479
|
+
const delay = determineDelay(this.contextSnapshot, event2);
|
|
1480
|
+
const activity = () => {
|
|
1481
|
+
const id = globalThis.setInterval(() => {
|
|
1482
|
+
this.executeActions(picked.actions, event2);
|
|
1483
|
+
}, delay);
|
|
1484
|
+
return () => {
|
|
1485
|
+
globalThis.clearInterval(id);
|
|
1486
|
+
};
|
|
1487
|
+
};
|
|
1488
|
+
callbackfn(activity);
|
|
1489
|
+
} else {
|
|
1490
|
+
for (const interval in every) {
|
|
1491
|
+
const actions = every?.[interval];
|
|
1492
|
+
const determineDelay = determineDelayFn(interval, this.delayMap);
|
|
1493
|
+
const delay = determineDelay(this.contextSnapshot, event2);
|
|
1494
|
+
const activity = () => {
|
|
1495
|
+
const id = globalThis.setInterval(() => {
|
|
1496
|
+
this.executeActions(actions, event2);
|
|
1497
|
+
}, delay);
|
|
1498
|
+
return () => {
|
|
1499
|
+
globalThis.clearInterval(id);
|
|
1500
|
+
};
|
|
1501
|
+
};
|
|
1502
|
+
callbackfn(activity);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
__publicField(this, "setEvent", (event2) => {
|
|
1507
|
+
this.state.previousEvent = this.state.event;
|
|
1508
|
+
this.state.event = ref(toEvent(event2));
|
|
1509
|
+
});
|
|
1510
|
+
__publicField(this, "performExitEffects", (current, event2) => {
|
|
1511
|
+
const currentState = this.state.value;
|
|
1512
|
+
if (currentState === "")
|
|
1513
|
+
return;
|
|
1514
|
+
const stateNode = current ? this.getStateNode(current) : void 0;
|
|
1515
|
+
this.stopActivities(currentState);
|
|
1516
|
+
const _exit = determineActionsFn(stateNode?.exit, this.guardMap)(this.contextSnapshot, event2, this.guardMeta);
|
|
1517
|
+
const exitActions = toArray(_exit);
|
|
1518
|
+
const afterExitActions = this.delayedEvents.get(currentState);
|
|
1519
|
+
if (afterExitActions) {
|
|
1520
|
+
exitActions.push(...afterExitActions);
|
|
1521
|
+
}
|
|
1522
|
+
this.executeActions(exitActions, event2);
|
|
1523
|
+
this.eventListeners.clear();
|
|
1524
|
+
});
|
|
1525
|
+
__publicField(this, "performEntryEffects", (next, event2) => {
|
|
1526
|
+
const stateNode = this.getStateNode(next);
|
|
1527
|
+
const activities = toArray(stateNode?.activities);
|
|
1528
|
+
this.createEveryActivities(stateNode?.every, (activity) => {
|
|
1529
|
+
activities.unshift(activity);
|
|
1530
|
+
});
|
|
1531
|
+
if (activities.length > 0) {
|
|
1532
|
+
this.executeActivities(event2, activities);
|
|
1533
|
+
}
|
|
1534
|
+
const pickedActions = determineActionsFn(stateNode?.entry, this.guardMap)(
|
|
1535
|
+
this.contextSnapshot,
|
|
1536
|
+
event2,
|
|
1537
|
+
this.guardMeta
|
|
1538
|
+
);
|
|
1539
|
+
const entryActions = toArray(pickedActions);
|
|
1540
|
+
const afterActions = this.getDelayedEventActions(next);
|
|
1541
|
+
if (stateNode?.after && afterActions) {
|
|
1542
|
+
this.delayedEvents.set(next, afterActions?.exits);
|
|
1543
|
+
entryActions.push(...afterActions.entries);
|
|
1544
|
+
}
|
|
1545
|
+
this.executeActions(entryActions, event2);
|
|
1546
|
+
if (stateNode?.type === "final") {
|
|
1547
|
+
this.state.done = true;
|
|
1548
|
+
this.doneListeners.forEach((listener) => {
|
|
1549
|
+
listener(this.stateSnapshot);
|
|
1550
|
+
});
|
|
1551
|
+
this.stop();
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
__publicField(this, "performTransitionEffects", (transitions, event2) => {
|
|
1555
|
+
const transition = this.determineTransition(transitions, event2);
|
|
1556
|
+
this.executeActions(transition?.actions, event2);
|
|
1557
|
+
});
|
|
1558
|
+
__publicField(this, "performStateChangeEffects", (current, next, event2) => {
|
|
1559
|
+
this.setEvent(event2);
|
|
1560
|
+
const changed = next.changed || next.reenter;
|
|
1561
|
+
if (changed) {
|
|
1562
|
+
this.performExitEffects(current, event2);
|
|
1563
|
+
}
|
|
1564
|
+
this.performTransitionEffects(next.transition, event2);
|
|
1565
|
+
this.setState(next.target);
|
|
1566
|
+
if (changed) {
|
|
1567
|
+
this.performEntryEffects(next.target, event2);
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
__publicField(this, "determineTransition", (transition, event2) => {
|
|
1571
|
+
const fn = determineTransitionFn(transition, this.guardMap);
|
|
1572
|
+
return fn?.(this.contextSnapshot, event2, this.guardMeta);
|
|
1573
|
+
});
|
|
1574
|
+
__publicField(this, "sendParent", (evt) => {
|
|
1575
|
+
if (!this.parent) {
|
|
1576
|
+
invariant("[@zag-js/core > send-parent] Cannot send event to an unknown parent");
|
|
1577
|
+
}
|
|
1578
|
+
const event2 = toEvent(evt);
|
|
1579
|
+
this.parent?.send(event2);
|
|
1580
|
+
});
|
|
1581
|
+
__publicField(this, "log", (...args) => {
|
|
1582
|
+
if (isDev2() && this.options.debug) {
|
|
1583
|
+
console.log(...args);
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1586
|
+
__publicField(this, "send", (evt) => {
|
|
1587
|
+
const event2 = toEvent(evt);
|
|
1588
|
+
this.transition(this.state.value, event2);
|
|
1589
|
+
});
|
|
1590
|
+
__publicField(this, "transition", (state, evt) => {
|
|
1591
|
+
const stateNode = isString(state) ? this.getStateNode(state) : state?.stateNode;
|
|
1592
|
+
const event2 = toEvent(evt);
|
|
1593
|
+
if (!stateNode && !this.config.on) {
|
|
1594
|
+
const msg = this.status === "Stopped" ? "[@zag-js/core > transition] Cannot transition a stopped machine" : `[@zag-js/core > transition] State does not have a definition for \`state\`: ${state}, \`event\`: ${event2.type}`;
|
|
1595
|
+
warn(msg);
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
const transitions = stateNode?.on?.[event2.type] ?? this.config.on?.[event2.type];
|
|
1599
|
+
const next = this.getNextStateInfo(transitions, event2);
|
|
1600
|
+
this.performStateChangeEffects(this.state.value, next, event2);
|
|
1601
|
+
return next.stateNode;
|
|
1602
|
+
});
|
|
1603
|
+
__publicField(this, "subscribe", (listener) => {
|
|
1604
|
+
this.stateListeners.add(listener);
|
|
1605
|
+
if (this.status === "Running") {
|
|
1606
|
+
listener(this.stateSnapshot);
|
|
1607
|
+
}
|
|
1608
|
+
return () => {
|
|
1609
|
+
this.stateListeners.delete(listener);
|
|
1610
|
+
};
|
|
1611
|
+
});
|
|
1612
|
+
__publicField(this, "onDone", (listener) => {
|
|
1613
|
+
this.doneListeners.add(listener);
|
|
1614
|
+
return this;
|
|
1615
|
+
});
|
|
1616
|
+
__publicField(this, "onTransition", (listener) => {
|
|
1617
|
+
this.stateListeners.add(listener);
|
|
1618
|
+
if (this.status === "Running") {
|
|
1619
|
+
listener(this.stateSnapshot);
|
|
1620
|
+
}
|
|
1621
|
+
return this;
|
|
1622
|
+
});
|
|
1623
|
+
__publicField(this, "onChange", (listener) => {
|
|
1624
|
+
this.contextListeners.add(listener);
|
|
1625
|
+
return this;
|
|
1626
|
+
});
|
|
1627
|
+
__publicField(this, "onEvent", (listener) => {
|
|
1628
|
+
this.eventListeners.add(listener);
|
|
1629
|
+
return this;
|
|
1630
|
+
});
|
|
1631
|
+
this.config = structuredClone(config);
|
|
1632
|
+
this.options = structuredClone(options ?? {});
|
|
1633
|
+
this.id = this.config.id ?? `machine-${uuid()}`;
|
|
1634
|
+
this.guardMap = this.options?.guards ?? {};
|
|
1635
|
+
this.actionMap = this.options?.actions ?? {};
|
|
1636
|
+
this.delayMap = this.options?.delays ?? {};
|
|
1637
|
+
this.activityMap = this.options?.activities ?? {};
|
|
1638
|
+
this.sync = this.options?.sync ?? false;
|
|
1639
|
+
this.state = createProxy(this.config);
|
|
1640
|
+
this.initialContext = snapshot(this.state.context);
|
|
1641
|
+
this.transformContext(this.state.context);
|
|
1642
|
+
const event = toEvent(
|
|
1643
|
+
"machine.created"
|
|
1644
|
+
/* Created */
|
|
1645
|
+
);
|
|
1646
|
+
this.executeActions(this.config?.created, event);
|
|
1647
|
+
}
|
|
1648
|
+
// immutable state value
|
|
1649
|
+
get stateSnapshot() {
|
|
1650
|
+
return cast(snapshot(this.state));
|
|
1651
|
+
}
|
|
1652
|
+
getState() {
|
|
1653
|
+
return this.stateSnapshot;
|
|
1654
|
+
}
|
|
1655
|
+
// immutable context value
|
|
1656
|
+
get contextSnapshot() {
|
|
1657
|
+
return this.stateSnapshot.context;
|
|
1658
|
+
}
|
|
1659
|
+
/**
|
|
1660
|
+
* A reference to the instance methods of the machine.
|
|
1661
|
+
* Useful when spawning child machines and managing the communication between them.
|
|
1662
|
+
*/
|
|
1663
|
+
get self() {
|
|
1664
|
+
const self = this;
|
|
1665
|
+
return {
|
|
1666
|
+
id: this.id,
|
|
1667
|
+
send: this.send.bind(this),
|
|
1668
|
+
sendParent: this.sendParent.bind(this),
|
|
1669
|
+
sendChild: this.sendChild.bind(this),
|
|
1670
|
+
stop: this.stop.bind(this),
|
|
1671
|
+
stopChild: this.stopChild.bind(this),
|
|
1672
|
+
spawn: this.spawn.bind(this),
|
|
1673
|
+
stopActivity: this.stopActivity.bind(this),
|
|
1674
|
+
get state() {
|
|
1675
|
+
return self.stateSnapshot;
|
|
1676
|
+
},
|
|
1677
|
+
get initialContext() {
|
|
1678
|
+
return self.initialContext;
|
|
1679
|
+
},
|
|
1680
|
+
get initialState() {
|
|
1681
|
+
return self.initialState?.target ?? "";
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
get meta() {
|
|
1686
|
+
return {
|
|
1687
|
+
state: this.stateSnapshot,
|
|
1688
|
+
guards: this.guardMap,
|
|
1689
|
+
send: this.send.bind(this),
|
|
1690
|
+
self: this.self,
|
|
1691
|
+
initialContext: this.initialContext,
|
|
1692
|
+
initialState: this.initialState?.target ?? "",
|
|
1693
|
+
getState: () => this.stateSnapshot,
|
|
1694
|
+
getAction: (key) => this.actionMap[key],
|
|
1695
|
+
getGuard: (key) => this.guardMap[key]
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
get guardMeta() {
|
|
1699
|
+
return {
|
|
1700
|
+
state: this.stateSnapshot
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
get [Symbol.toStringTag]() {
|
|
1704
|
+
return "Machine";
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
var createMachine = (config, options) => new Machine(config, options);
|
|
1708
|
+
|
|
1709
|
+
// ../../node_modules/.pnpm/@zag-js+dom-event@0.19.1/node_modules/@zag-js/dom-event/dist/index.mjs
|
|
1710
|
+
var addDomEvent2 = (target, eventName, handler, options) => {
|
|
1711
|
+
const node = typeof target === "function" ? target() : target;
|
|
1712
|
+
node?.addEventListener(eventName, handler, options);
|
|
1713
|
+
return () => {
|
|
1714
|
+
node?.removeEventListener(eventName, handler, options);
|
|
1715
|
+
};
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1718
|
+
// ../../node_modules/.pnpm/@zag-js+tooltip@0.19.1/node_modules/@zag-js/tooltip/dist/index.mjs
|
|
1719
|
+
var anatomy = createAnatomy("tooltip").parts("trigger", "arrow", "arrowTip", "positioner", "content");
|
|
1720
|
+
var parts = anatomy.build();
|
|
1721
|
+
var dom = createScope({
|
|
1722
|
+
getTriggerId: (ctx) => ctx.ids?.trigger ?? `tooltip:${ctx.id}:trigger`,
|
|
1723
|
+
getContentId: (ctx) => ctx.ids?.content ?? `tooltip:${ctx.id}:content`,
|
|
1724
|
+
getArrowId: (ctx) => ctx.ids?.arrow ?? `tooltip:${ctx.id}:arrow`,
|
|
1725
|
+
getPositionerId: (ctx) => ctx.ids?.positioner ?? `tooltip:${ctx.id}:popper`,
|
|
1726
|
+
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
1727
|
+
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
1728
|
+
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
1729
|
+
getArrowEl: (ctx) => dom.getById(ctx, dom.getArrowId(ctx)),
|
|
1730
|
+
getScrollParent: (ctx) => getScrollParent(dom.getTriggerEl(ctx))
|
|
1731
|
+
});
|
|
1732
|
+
var store = proxy({
|
|
1733
|
+
id: null,
|
|
1734
|
+
prevId: null,
|
|
1735
|
+
setId(val) {
|
|
1736
|
+
this.prevId = this.id;
|
|
1737
|
+
this.id = val;
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1740
|
+
function connect(state, send, normalize) {
|
|
1741
|
+
const id = state.context.id;
|
|
1742
|
+
const hasAriaLabel = state.context.hasAriaLabel;
|
|
1743
|
+
const isOpen = state.hasTag("open");
|
|
1744
|
+
const triggerId = dom.getTriggerId(state.context);
|
|
1745
|
+
const contentId = dom.getContentId(state.context);
|
|
1746
|
+
const isDisabled = state.context.disabled;
|
|
1747
|
+
const popperStyles = getPlacementStyles({
|
|
1748
|
+
...state.context.positioning,
|
|
1749
|
+
placement: state.context.currentPlacement
|
|
1750
|
+
});
|
|
1751
|
+
return {
|
|
1752
|
+
isOpen,
|
|
1753
|
+
open() {
|
|
1754
|
+
send("OPEN");
|
|
1755
|
+
},
|
|
1756
|
+
close() {
|
|
1757
|
+
send("CLOSE");
|
|
1758
|
+
},
|
|
1759
|
+
setPositioning(options = {}) {
|
|
1760
|
+
send({ type: "SET_POSITIONING", options });
|
|
1761
|
+
},
|
|
1762
|
+
triggerProps: normalize.button({
|
|
1763
|
+
...parts.trigger.attrs,
|
|
1764
|
+
id: triggerId,
|
|
1765
|
+
"data-expanded": dataAttr(isOpen),
|
|
1766
|
+
"data-state": isOpen ? "open" : "closed",
|
|
1767
|
+
"aria-describedby": isOpen ? contentId : void 0,
|
|
1768
|
+
onClick() {
|
|
1769
|
+
send("CLICK");
|
|
1770
|
+
},
|
|
1771
|
+
onFocus() {
|
|
1772
|
+
if (state.event.type === "POINTER_DOWN")
|
|
1773
|
+
return;
|
|
1774
|
+
send("FOCUS");
|
|
1775
|
+
},
|
|
1776
|
+
onBlur() {
|
|
1777
|
+
if (id === store.id) {
|
|
1778
|
+
send("BLUR");
|
|
1779
|
+
}
|
|
1780
|
+
},
|
|
1781
|
+
onPointerDown() {
|
|
1782
|
+
if (isDisabled)
|
|
1783
|
+
return;
|
|
1784
|
+
if (id === store.id) {
|
|
1785
|
+
send("POINTER_DOWN");
|
|
1786
|
+
}
|
|
1787
|
+
},
|
|
1788
|
+
onPointerMove(event) {
|
|
1789
|
+
if (isDisabled || event.pointerType === "touch")
|
|
1790
|
+
return;
|
|
1791
|
+
send("POINTER_MOVE");
|
|
1792
|
+
},
|
|
1793
|
+
onPointerLeave() {
|
|
1794
|
+
if (isDisabled)
|
|
1795
|
+
return;
|
|
1796
|
+
send("POINTER_LEAVE");
|
|
1797
|
+
},
|
|
1798
|
+
onPointerCancel() {
|
|
1799
|
+
if (isDisabled)
|
|
1800
|
+
return;
|
|
1801
|
+
send("POINTER_LEAVE");
|
|
1802
|
+
}
|
|
1803
|
+
}),
|
|
1804
|
+
arrowProps: normalize.element({
|
|
1805
|
+
id: dom.getArrowId(state.context),
|
|
1806
|
+
...parts.arrow.attrs,
|
|
1807
|
+
style: popperStyles.arrow
|
|
1808
|
+
}),
|
|
1809
|
+
arrowTipProps: normalize.element({
|
|
1810
|
+
...parts.arrowTip.attrs,
|
|
1811
|
+
style: popperStyles.arrowTip
|
|
1812
|
+
}),
|
|
1813
|
+
positionerProps: normalize.element({
|
|
1814
|
+
id: dom.getPositionerId(state.context),
|
|
1815
|
+
...parts.positioner.attrs,
|
|
1816
|
+
style: popperStyles.floating
|
|
1817
|
+
}),
|
|
1818
|
+
contentProps: normalize.element({
|
|
1819
|
+
...parts.content.attrs,
|
|
1820
|
+
hidden: !isOpen,
|
|
1821
|
+
"data-state": isOpen ? "open" : "closed",
|
|
1822
|
+
role: hasAriaLabel ? void 0 : "tooltip",
|
|
1823
|
+
id: hasAriaLabel ? void 0 : contentId,
|
|
1824
|
+
"data-placement": state.context.currentPlacement,
|
|
1825
|
+
onPointerEnter() {
|
|
1826
|
+
send("CONTENT.POINTER_MOVE");
|
|
1827
|
+
},
|
|
1828
|
+
onPointerLeave() {
|
|
1829
|
+
send("CONTENT.POINTER_LEAVE");
|
|
1830
|
+
},
|
|
1831
|
+
style: {
|
|
1832
|
+
pointerEvents: state.context.interactive ? "auto" : "none"
|
|
1833
|
+
}
|
|
1834
|
+
})
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
var { and: and2, not: not2 } = guards;
|
|
1838
|
+
function machine(userContext) {
|
|
1839
|
+
const ctx = compact(userContext);
|
|
1840
|
+
return createMachine(
|
|
1841
|
+
{
|
|
1842
|
+
id: "tooltip",
|
|
1843
|
+
initial: "closed",
|
|
1844
|
+
context: {
|
|
1845
|
+
openDelay: 1e3,
|
|
1846
|
+
closeDelay: 500,
|
|
1847
|
+
closeOnPointerDown: true,
|
|
1848
|
+
closeOnEsc: true,
|
|
1849
|
+
interactive: true,
|
|
1850
|
+
currentPlacement: void 0,
|
|
1851
|
+
...ctx,
|
|
1852
|
+
hasPointerMoveOpened: false,
|
|
1853
|
+
positioning: {
|
|
1854
|
+
placement: "bottom",
|
|
1855
|
+
...ctx.positioning
|
|
1856
|
+
}
|
|
1857
|
+
},
|
|
1858
|
+
computed: {
|
|
1859
|
+
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
1860
|
+
},
|
|
1861
|
+
watch: {
|
|
1862
|
+
disabled: ["closeIfDisabled"],
|
|
1863
|
+
open: ["toggleVisibility"]
|
|
1864
|
+
},
|
|
1865
|
+
on: {
|
|
1866
|
+
OPEN: "open",
|
|
1867
|
+
CLOSE: "closed"
|
|
1868
|
+
},
|
|
1869
|
+
states: {
|
|
1870
|
+
closed: {
|
|
1871
|
+
tags: ["closed"],
|
|
1872
|
+
entry: ["clearGlobalId", "invokeOnClose"],
|
|
1873
|
+
on: {
|
|
1874
|
+
FOCUS: "open",
|
|
1875
|
+
POINTER_LEAVE: {
|
|
1876
|
+
actions: ["clearPointerMoveOpened"]
|
|
1877
|
+
},
|
|
1878
|
+
POINTER_MOVE: [
|
|
1879
|
+
{
|
|
1880
|
+
guard: and2("noVisibleTooltip", not2("hasPointerMoveOpened")),
|
|
1881
|
+
target: "opening"
|
|
1882
|
+
},
|
|
1883
|
+
{
|
|
1884
|
+
guard: not2("hasPointerMoveOpened"),
|
|
1885
|
+
target: "open",
|
|
1886
|
+
actions: ["setPointerMoveOpened"]
|
|
1887
|
+
}
|
|
1888
|
+
]
|
|
1889
|
+
}
|
|
1890
|
+
},
|
|
1891
|
+
opening: {
|
|
1892
|
+
tags: ["closed"],
|
|
1893
|
+
activities: ["trackScroll", "trackPointerlockChange"],
|
|
1894
|
+
after: {
|
|
1895
|
+
OPEN_DELAY: {
|
|
1896
|
+
target: "open",
|
|
1897
|
+
actions: ["setPointerMoveOpened"]
|
|
1898
|
+
}
|
|
1899
|
+
},
|
|
1900
|
+
on: {
|
|
1901
|
+
POINTER_LEAVE: {
|
|
1902
|
+
target: "closed",
|
|
1903
|
+
actions: ["clearPointerMoveOpened"]
|
|
1904
|
+
},
|
|
1905
|
+
BLUR: "closed",
|
|
1906
|
+
SCROLL: "closed",
|
|
1907
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
1908
|
+
POINTER_DOWN: {
|
|
1909
|
+
guard: "closeOnPointerDown",
|
|
1910
|
+
target: "closed"
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
},
|
|
1914
|
+
open: {
|
|
1915
|
+
tags: ["open"],
|
|
1916
|
+
activities: [
|
|
1917
|
+
"trackEscapeKey",
|
|
1918
|
+
"trackDisabledTriggerOnSafari",
|
|
1919
|
+
"trackScroll",
|
|
1920
|
+
"trackPointerlockChange",
|
|
1921
|
+
"trackPositioning"
|
|
1922
|
+
],
|
|
1923
|
+
entry: ["setGlobalId", "invokeOnOpen"],
|
|
1924
|
+
on: {
|
|
1925
|
+
POINTER_LEAVE: [
|
|
1926
|
+
{
|
|
1927
|
+
guard: "isVisible",
|
|
1928
|
+
target: "closing",
|
|
1929
|
+
actions: ["clearPointerMoveOpened"]
|
|
1930
|
+
},
|
|
1931
|
+
{
|
|
1932
|
+
target: "closed",
|
|
1933
|
+
actions: ["clearPointerMoveOpened"]
|
|
1934
|
+
}
|
|
1935
|
+
],
|
|
1936
|
+
BLUR: "closed",
|
|
1937
|
+
ESCAPE: "closed",
|
|
1938
|
+
SCROLL: "closed",
|
|
1939
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
1940
|
+
"CONTENT.POINTER_LEAVE": {
|
|
1941
|
+
guard: "isInteractive",
|
|
1942
|
+
target: "closing"
|
|
1943
|
+
},
|
|
1944
|
+
POINTER_DOWN: {
|
|
1945
|
+
guard: "closeOnPointerDown",
|
|
1946
|
+
target: "closed"
|
|
1947
|
+
},
|
|
1948
|
+
CLICK: "closed",
|
|
1949
|
+
SET_POSITIONING: {
|
|
1950
|
+
actions: "setPositioning"
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
},
|
|
1954
|
+
closing: {
|
|
1955
|
+
tags: ["open"],
|
|
1956
|
+
activities: ["trackStore", "trackPositioning"],
|
|
1957
|
+
after: {
|
|
1958
|
+
CLOSE_DELAY: "closed"
|
|
1959
|
+
},
|
|
1960
|
+
on: {
|
|
1961
|
+
FORCE_CLOSE: "closed",
|
|
1962
|
+
POINTER_MOVE: {
|
|
1963
|
+
target: "open",
|
|
1964
|
+
actions: ["setPointerMoveOpened"]
|
|
1965
|
+
},
|
|
1966
|
+
"CONTENT.POINTER_MOVE": {
|
|
1967
|
+
guard: "isInteractive",
|
|
1968
|
+
target: "open"
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
},
|
|
1974
|
+
{
|
|
1975
|
+
activities: {
|
|
1976
|
+
trackPositioning(ctx2) {
|
|
1977
|
+
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
1978
|
+
const getPositionerEl = () => dom.getPositionerEl(ctx2);
|
|
1979
|
+
return getPlacement(dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
1980
|
+
...ctx2.positioning,
|
|
1981
|
+
defer: true,
|
|
1982
|
+
onComplete(data) {
|
|
1983
|
+
ctx2.currentPlacement = data.placement;
|
|
1984
|
+
},
|
|
1985
|
+
onCleanup() {
|
|
1986
|
+
ctx2.currentPlacement = void 0;
|
|
1987
|
+
}
|
|
1988
|
+
});
|
|
1989
|
+
},
|
|
1990
|
+
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
1991
|
+
const onChange = () => send("POINTER_LOCK_CHANGE");
|
|
1992
|
+
return addDomEvent2(dom.getDoc(ctx2), "pointerlockchange", onChange, false);
|
|
1993
|
+
},
|
|
1994
|
+
trackScroll(ctx2, _evt, { send }) {
|
|
1995
|
+
const trigger = dom.getTriggerEl(ctx2);
|
|
1996
|
+
if (!trigger)
|
|
1997
|
+
return;
|
|
1998
|
+
const cleanups = getScrollParents(trigger).map((el) => {
|
|
1999
|
+
const opts = { passive: true, capture: true };
|
|
2000
|
+
return addDomEvent2(el, "scroll", () => send("SCROLL"), opts);
|
|
2001
|
+
});
|
|
2002
|
+
return () => {
|
|
2003
|
+
cleanups.forEach((fn) => fn?.());
|
|
2004
|
+
};
|
|
2005
|
+
},
|
|
2006
|
+
trackStore(ctx2, _evt, { send }) {
|
|
2007
|
+
return subscribe(store, () => {
|
|
2008
|
+
if (store.id !== ctx2.id) {
|
|
2009
|
+
send("FORCE_CLOSE");
|
|
2010
|
+
}
|
|
2011
|
+
});
|
|
2012
|
+
},
|
|
2013
|
+
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
2014
|
+
if (!isSafari())
|
|
2015
|
+
return;
|
|
2016
|
+
const doc = dom.getDoc(ctx2);
|
|
2017
|
+
return addDomEvent2(doc, "pointermove", (event) => {
|
|
2018
|
+
const selector = "[data-part=trigger][data-expanded]";
|
|
2019
|
+
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
2020
|
+
return;
|
|
2021
|
+
send("POINTER_LEAVE");
|
|
2022
|
+
});
|
|
2023
|
+
},
|
|
2024
|
+
trackEscapeKey(ctx2, _evt, { send }) {
|
|
2025
|
+
if (!ctx2.closeOnEsc)
|
|
2026
|
+
return;
|
|
2027
|
+
const doc = dom.getDoc(ctx2);
|
|
2028
|
+
return addDomEvent2(doc, "keydown", (event) => {
|
|
2029
|
+
if (event.key === "Escape") {
|
|
2030
|
+
send("ESCAPE");
|
|
2031
|
+
}
|
|
2032
|
+
});
|
|
2033
|
+
}
|
|
2034
|
+
},
|
|
2035
|
+
actions: {
|
|
2036
|
+
setGlobalId(ctx2) {
|
|
2037
|
+
store.setId(ctx2.id);
|
|
2038
|
+
},
|
|
2039
|
+
clearGlobalId(ctx2) {
|
|
2040
|
+
if (ctx2.id === store.id) {
|
|
2041
|
+
store.setId(null);
|
|
2042
|
+
}
|
|
2043
|
+
},
|
|
2044
|
+
invokeOnOpen(ctx2, evt) {
|
|
2045
|
+
const omit = ["CONTENT.POINTER_MOVE", "POINTER_MOVE"];
|
|
2046
|
+
if (!omit.includes(evt.type)) {
|
|
2047
|
+
ctx2.onOpen?.();
|
|
2048
|
+
}
|
|
2049
|
+
},
|
|
2050
|
+
invokeOnClose(ctx2) {
|
|
2051
|
+
ctx2.onClose?.();
|
|
2052
|
+
},
|
|
2053
|
+
closeIfDisabled(ctx2, _evt, { send }) {
|
|
2054
|
+
if (!ctx2.disabled)
|
|
2055
|
+
return;
|
|
2056
|
+
send("CLOSE");
|
|
2057
|
+
},
|
|
2058
|
+
setPositioning(ctx2, evt) {
|
|
2059
|
+
const getPositionerEl = () => dom.getPositionerEl(ctx2);
|
|
2060
|
+
getPlacement(dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
2061
|
+
...ctx2.positioning,
|
|
2062
|
+
...evt.options,
|
|
2063
|
+
defer: true,
|
|
2064
|
+
listeners: false
|
|
2065
|
+
});
|
|
2066
|
+
},
|
|
2067
|
+
toggleVisibility(ctx2, _evt, { send }) {
|
|
2068
|
+
send({ type: ctx2.open ? "OPEN" : "CLOSE", src: "controlled" });
|
|
2069
|
+
},
|
|
2070
|
+
setPointerMoveOpened(ctx2) {
|
|
2071
|
+
ctx2.hasPointerMoveOpened = true;
|
|
2072
|
+
},
|
|
2073
|
+
clearPointerMoveOpened(ctx2) {
|
|
2074
|
+
ctx2.hasPointerMoveOpened = false;
|
|
2075
|
+
}
|
|
2076
|
+
},
|
|
2077
|
+
guards: {
|
|
2078
|
+
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
2079
|
+
noVisibleTooltip: () => store.id === null,
|
|
2080
|
+
isVisible: (ctx2) => ctx2.id === store.id,
|
|
2081
|
+
isInteractive: (ctx2) => ctx2.interactive,
|
|
2082
|
+
hasPointerMoveOpened: (ctx2) => !!ctx2.hasPointerMoveOpened
|
|
2083
|
+
},
|
|
2084
|
+
delays: {
|
|
2085
|
+
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
2086
|
+
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
);
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
// ../../node_modules/.pnpm/@zag-js+types@0.19.1/node_modules/@zag-js/types/dist/index.mjs
|
|
2093
|
+
function createNormalizer(fn) {
|
|
2094
|
+
return new Proxy({}, {
|
|
2095
|
+
get() {
|
|
2096
|
+
return fn;
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
// ../../node_modules/.pnpm/@zag-js+react@0.19.1_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/@zag-js/react/dist/index.mjs
|
|
2102
|
+
import { createElement, useReducer, useRef } from "react";
|
|
2103
|
+
import { createPortal } from "react-dom";
|
|
2104
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
2105
|
+
import ReactExports, { useCallback, useEffect as useEffect2, useMemo, useRef as useRef2, useSyncExternalStore } from "react";
|
|
2106
|
+
import { useRef as useRef3 } from "react";
|
|
2107
|
+
var normalizeProps = createNormalizer((v) => v);
|
|
2108
|
+
var useSafeLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
2109
|
+
function Portal(props) {
|
|
2110
|
+
const { children, target } = props;
|
|
2111
|
+
const node = useRef(null);
|
|
2112
|
+
const portalNode = useRef(null);
|
|
2113
|
+
const [, forceUpdate] = useReducer((s2) => s2 + 1, 0);
|
|
2114
|
+
useSafeLayoutEffect(() => {
|
|
2115
|
+
if (!node.current)
|
|
2116
|
+
return;
|
|
2117
|
+
const doc = node.current.ownerDocument;
|
|
2118
|
+
portalNode.current = doc.createElement("zag-portal");
|
|
2119
|
+
doc.body.appendChild(portalNode.current);
|
|
2120
|
+
forceUpdate();
|
|
2121
|
+
return () => {
|
|
2122
|
+
if (portalNode.current) {
|
|
2123
|
+
doc.body.removeChild(portalNode.current);
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
}, []);
|
|
2127
|
+
const targetNode = target?.current ?? portalNode.current;
|
|
2128
|
+
if (targetNode) {
|
|
2129
|
+
return createPortal(children, targetNode);
|
|
2130
|
+
}
|
|
2131
|
+
return createElement("span", { ref: node });
|
|
2132
|
+
}
|
|
2133
|
+
var { use } = ReactExports;
|
|
2134
|
+
var targetCache = /* @__PURE__ */ new WeakMap();
|
|
2135
|
+
function useSnapshot(proxyObject, options) {
|
|
2136
|
+
const notifyInSync = options?.sync;
|
|
2137
|
+
const lastSnapshot = useRef2();
|
|
2138
|
+
const lastAffected = useRef2();
|
|
2139
|
+
const currSnapshot = useSyncExternalStore(
|
|
2140
|
+
useCallback(
|
|
2141
|
+
(callback) => {
|
|
2142
|
+
const unsub = subscribe(proxyObject, callback, notifyInSync);
|
|
2143
|
+
callback();
|
|
2144
|
+
return unsub;
|
|
2145
|
+
},
|
|
2146
|
+
[proxyObject, notifyInSync]
|
|
2147
|
+
),
|
|
2148
|
+
() => {
|
|
2149
|
+
const nextSnapshot = snapshot(proxyObject, use);
|
|
2150
|
+
try {
|
|
2151
|
+
if (lastSnapshot.current && lastAffected.current && !p(lastSnapshot.current, nextSnapshot, lastAffected.current, /* @__PURE__ */ new WeakMap())) {
|
|
2152
|
+
return lastSnapshot.current;
|
|
2153
|
+
}
|
|
2154
|
+
} catch (e2) {
|
|
2155
|
+
}
|
|
2156
|
+
return nextSnapshot;
|
|
2157
|
+
},
|
|
2158
|
+
() => snapshot(proxyObject, use)
|
|
2159
|
+
);
|
|
2160
|
+
const currAffected = /* @__PURE__ */ new WeakMap();
|
|
2161
|
+
useEffect2(() => {
|
|
2162
|
+
lastSnapshot.current = currSnapshot;
|
|
2163
|
+
lastAffected.current = currAffected;
|
|
2164
|
+
});
|
|
2165
|
+
const proxyCache = useMemo(() => /* @__PURE__ */ new WeakMap(), []);
|
|
2166
|
+
return a(currSnapshot, currAffected, proxyCache, targetCache);
|
|
2167
|
+
}
|
|
2168
|
+
function useConstant(fn) {
|
|
2169
|
+
const ref2 = useRef3();
|
|
2170
|
+
if (!ref2.current)
|
|
2171
|
+
ref2.current = { v: fn() };
|
|
2172
|
+
return ref2.current.v;
|
|
2173
|
+
}
|
|
2174
|
+
function useService(machine2, options) {
|
|
2175
|
+
const { actions, state: hydratedState, context } = options ?? {};
|
|
2176
|
+
const service = useConstant(() => {
|
|
2177
|
+
const instance = typeof machine2 === "function" ? machine2() : machine2;
|
|
2178
|
+
return context ? instance.withContext(context) : instance;
|
|
2179
|
+
});
|
|
2180
|
+
useSafeLayoutEffect(() => {
|
|
2181
|
+
service.start(hydratedState);
|
|
2182
|
+
if (service.state.can("SETUP")) {
|
|
2183
|
+
service.send("SETUP");
|
|
2184
|
+
}
|
|
2185
|
+
return () => {
|
|
2186
|
+
service.stop();
|
|
2187
|
+
};
|
|
2188
|
+
}, []);
|
|
2189
|
+
service.setOptions({ actions });
|
|
2190
|
+
service.setContext(context);
|
|
2191
|
+
return service;
|
|
2192
|
+
}
|
|
2193
|
+
function useMachine(machine2, options) {
|
|
2194
|
+
const service = useService(machine2, options);
|
|
2195
|
+
const state = useSnapshot(service.state);
|
|
2196
|
+
const typedState = state;
|
|
2197
|
+
return [typedState, service.send, service];
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
// ../../node_modules/.pnpm/@cfx-kit+ui-components@0.0.18_@zag-js+accordion@0.19.1_@zag-js+checkbox@0.19.1_@zag-js+dialog_toqhwacqm4ck723ovqekq5mm7u/node_modules/@cfx-kit/ui-components/dist/Tooltip.js
|
|
2201
|
+
import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
|
|
2202
|
+
var Tooltip = (_a) => {
|
|
2203
|
+
var _b = _a, {
|
|
2204
|
+
id,
|
|
2205
|
+
open = false,
|
|
2206
|
+
openDelay = 200,
|
|
2207
|
+
closeDelay = 200,
|
|
2208
|
+
arrow: arrow2 = true,
|
|
2209
|
+
positioning,
|
|
2210
|
+
children,
|
|
2211
|
+
containerClassName,
|
|
2212
|
+
trigger,
|
|
2213
|
+
portalled = false
|
|
2214
|
+
} = _b, props = __objRest(_b, [
|
|
2215
|
+
"id",
|
|
2216
|
+
"open",
|
|
2217
|
+
"openDelay",
|
|
2218
|
+
"closeDelay",
|
|
2219
|
+
"arrow",
|
|
2220
|
+
"positioning",
|
|
2221
|
+
"children",
|
|
2222
|
+
"containerClassName",
|
|
2223
|
+
"trigger",
|
|
2224
|
+
"portalled"
|
|
2225
|
+
]);
|
|
2226
|
+
const Wrapper = portalled ? Portal : Fragment;
|
|
2227
|
+
const uniqueId = useId();
|
|
2228
|
+
const [state, send] = useMachine(machine(__spreadValues({ id: id != null ? id : uniqueId, openDelay, closeDelay, positioning }, props)));
|
|
2229
|
+
const api = connect(state, send, normalizeProps);
|
|
2230
|
+
useEffect3(() => {
|
|
2231
|
+
if (open === true) {
|
|
2232
|
+
api.open();
|
|
2233
|
+
} else {
|
|
2234
|
+
api.close();
|
|
2235
|
+
}
|
|
2236
|
+
}, [open]);
|
|
2237
|
+
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
2238
|
+
typeof trigger === "function" ? trigger({ triggerProps: api.triggerProps }) : null,
|
|
2239
|
+
api.isOpen && /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsxs("div", __spreadProps(__spreadValues({ className: `ui-tooltip${containerClassName ? ` ${containerClassName}` : ""}` }, api.positionerProps), { children: [
|
|
2240
|
+
arrow2 && /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, api.arrowProps), { children: /* @__PURE__ */ jsx("div", __spreadValues({}, api.arrowTipProps)) })),
|
|
2241
|
+
typeof children === "function" && children({ contentProps: api.contentProps }),
|
|
2242
|
+
typeof children !== "function" ? Children.count(children) === 1 && isValidElement(children) ? cloneElement(children, __spreadValues({}, api.contentProps)) : /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, api.contentProps), { children })) : null
|
|
2243
|
+
] })) })
|
|
2244
|
+
] });
|
|
2245
|
+
};
|
|
2246
|
+
var Tooltip_default = Tooltip;
|
|
2247
|
+
|
|
2248
|
+
// src/components/Tooltip/index.tsx
|
|
2249
|
+
import { useClickAway } from "@cfx-kit/react-utils/dist/hooks";
|
|
2250
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
2251
|
+
var Tooltip2 = ({
|
|
2252
|
+
title,
|
|
2253
|
+
children = null,
|
|
2254
|
+
positioning = {},
|
|
2255
|
+
className,
|
|
2256
|
+
containerClassName,
|
|
2257
|
+
...rest
|
|
2258
|
+
}) => {
|
|
2259
|
+
const { placement = "top" } = positioning;
|
|
2260
|
+
const onCloseRef = useRef4();
|
|
2261
|
+
const triggerRef = useRef4(null);
|
|
2262
|
+
const triggerContentRef = useRef4(null);
|
|
2263
|
+
useClickAway([triggerRef, triggerContentRef], (e2) => {
|
|
2264
|
+
onCloseRef.current?.(
|
|
2265
|
+
e2
|
|
2266
|
+
);
|
|
2267
|
+
});
|
|
2268
|
+
return /* @__PURE__ */ jsx2(
|
|
2269
|
+
Tooltip_default,
|
|
2270
|
+
{
|
|
2271
|
+
trigger: ({ triggerProps }) => {
|
|
2272
|
+
onCloseRef.current = triggerProps.onClick;
|
|
2273
|
+
triggerProps.onClick = (e2) => {
|
|
2274
|
+
triggerProps.onPointerMove?.(e2);
|
|
2275
|
+
};
|
|
2276
|
+
return /* @__PURE__ */ jsx2(
|
|
2277
|
+
"span",
|
|
2278
|
+
{
|
|
2279
|
+
ref: triggerRef,
|
|
2280
|
+
...title ? triggerProps : {},
|
|
2281
|
+
className: cn(className, triggerProps.className),
|
|
2282
|
+
children
|
|
2283
|
+
}
|
|
2284
|
+
);
|
|
2285
|
+
},
|
|
2286
|
+
containerClassName: cn(
|
|
2287
|
+
"sirius-next-tooltip",
|
|
2288
|
+
"lh-normal max-w-320px z-1000 w-max min-w-unset!",
|
|
2289
|
+
"all-[a]:text-[var(--theme-color-blue0)] all-[a:hover]:text-[var(--theme-color-blue2)]",
|
|
2290
|
+
"[&.sirius-next-tooltip>[data-part=arrow]]:[--arrow-size:6px] [&.sirius-next-tooltip>[data-part=arrow]]:[--arrow-background:#333]",
|
|
2291
|
+
containerClassName
|
|
2292
|
+
),
|
|
2293
|
+
openDelay: 0,
|
|
2294
|
+
closeOnPointerDown: false,
|
|
2295
|
+
...rest,
|
|
2296
|
+
positioning: {
|
|
2297
|
+
...positioning,
|
|
2298
|
+
placement
|
|
2299
|
+
},
|
|
2300
|
+
children: ({ contentProps }) => {
|
|
2301
|
+
const _onPointerLeave = contentProps.onPointerLeave;
|
|
2302
|
+
contentProps.onPointerLeave = (e2) => {
|
|
2303
|
+
if (e2.pointerType === "touch")
|
|
2304
|
+
return;
|
|
2305
|
+
_onPointerLeave?.(e2);
|
|
2306
|
+
};
|
|
2307
|
+
return /* @__PURE__ */ jsx2(
|
|
2308
|
+
"div",
|
|
2309
|
+
{
|
|
2310
|
+
className: "px-8px py-6px text-12px text-#fff text-left shadow break-words ws-normal bg-#333 min-w-30px min-h-32px decoration-none rounded-2px",
|
|
2311
|
+
ref: (_ref) => _ref ? triggerContentRef.current = _ref.parentElement : triggerContentRef.current = null,
|
|
2312
|
+
...contentProps,
|
|
2313
|
+
children: title
|
|
2314
|
+
}
|
|
2315
|
+
);
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
);
|
|
2319
|
+
};
|
|
2320
|
+
|
|
2321
|
+
export {
|
|
2322
|
+
Tooltip2 as Tooltip
|
|
2323
|
+
};
|
|
2324
|
+
//# sourceMappingURL=chunk-H6W3LPDS.js.map
|