@vertz/ui 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +339 -857
- package/dist/css/public.d.ts +24 -27
- package/dist/css/public.js +5 -1
- package/dist/form/public.d.ts +94 -38
- package/dist/form/public.js +5 -3
- package/dist/index.d.ts +754 -167
- package/dist/index.js +606 -84
- package/dist/internals.d.ts +192 -23
- package/dist/internals.js +151 -102
- package/dist/jsx-runtime/index.d.ts +44 -17
- package/dist/jsx-runtime/index.js +26 -7
- package/dist/query/public.d.ts +73 -7
- package/dist/query/public.js +12 -4
- package/dist/router/public.d.ts +199 -26
- package/dist/router/public.js +22 -7
- package/dist/shared/chunk-0xcmwgdb.js +288 -0
- package/dist/shared/{chunk-j8vzvne3.js → chunk-9e92w0wt.js} +4 -1
- package/dist/shared/chunk-g4rch80a.js +33 -0
- package/dist/shared/chunk-hh0dhmb4.js +528 -0
- package/dist/shared/{chunk-pgymxpn1.js → chunk-hrd0mft1.js} +136 -34
- package/dist/shared/chunk-jrtrk5z4.js +125 -0
- package/dist/shared/chunk-ka5ked7n.js +188 -0
- package/dist/shared/chunk-n91rwj2r.js +483 -0
- package/dist/shared/chunk-prj7nm08.js +67 -0
- package/dist/shared/chunk-q6cpe5k7.js +230 -0
- package/dist/shared/{chunk-f1ynwam4.js → chunk-qacth5ah.js} +162 -36
- package/dist/shared/chunk-ryb49346.js +374 -0
- package/dist/shared/chunk-v3yyf79g.js +48 -0
- package/dist/test/index.d.ts +67 -6
- package/dist/test/index.js +4 -3
- package/package.json +14 -9
- package/dist/shared/chunk-bp3v6s9j.js +0 -62
- package/dist/shared/chunk-d8h2eh8d.js +0 -141
- package/dist/shared/chunk-tsdpgmks.js +0 -98
- package/dist/shared/chunk-xd9d7q5p.js +0 -115
- package/dist/shared/chunk-zbbvx05f.js +0 -202
package/dist/index.js
CHANGED
|
@@ -1,83 +1,102 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
ANIMATION_DURATION,
|
|
3
|
+
ANIMATION_EASING,
|
|
4
|
+
accordionDown,
|
|
5
|
+
accordionUp,
|
|
6
|
+
fadeIn,
|
|
7
|
+
fadeOut,
|
|
3
8
|
hydrate,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
isQueryDescriptor,
|
|
10
|
+
keyframes,
|
|
11
|
+
onAnimationsComplete,
|
|
12
|
+
palettes,
|
|
13
|
+
slideInFromBottom,
|
|
14
|
+
slideInFromLeft,
|
|
15
|
+
slideInFromRight,
|
|
16
|
+
slideInFromTop,
|
|
17
|
+
slideOutToBottom,
|
|
18
|
+
slideOutToLeft,
|
|
19
|
+
slideOutToRight,
|
|
20
|
+
slideOutToTop,
|
|
21
|
+
zoomIn,
|
|
22
|
+
zoomOut
|
|
23
|
+
} from "./shared/chunk-n91rwj2r.js";
|
|
10
24
|
import {
|
|
25
|
+
Outlet,
|
|
26
|
+
OutletContext,
|
|
27
|
+
RouterContext,
|
|
28
|
+
RouterView,
|
|
11
29
|
createLink,
|
|
12
|
-
createOutlet,
|
|
13
30
|
parseSearchParams,
|
|
31
|
+
useParams,
|
|
32
|
+
useRouter,
|
|
14
33
|
useSearchParams
|
|
15
|
-
} from "./shared/chunk-
|
|
34
|
+
} from "./shared/chunk-0xcmwgdb.js";
|
|
35
|
+
import"./shared/chunk-v3yyf79g.js";
|
|
16
36
|
import {
|
|
17
37
|
createRouter
|
|
18
|
-
} from "./shared/chunk-
|
|
38
|
+
} from "./shared/chunk-ka5ked7n.js";
|
|
19
39
|
import {
|
|
20
40
|
defineRoutes
|
|
21
|
-
} from "./shared/chunk-
|
|
41
|
+
} from "./shared/chunk-9e92w0wt.js";
|
|
22
42
|
import {
|
|
43
|
+
createFieldState,
|
|
23
44
|
form,
|
|
24
45
|
formDataToObject,
|
|
25
46
|
validate
|
|
26
|
-
} from "./shared/chunk-
|
|
47
|
+
} from "./shared/chunk-q6cpe5k7.js";
|
|
27
48
|
import {
|
|
28
|
-
query
|
|
29
|
-
|
|
49
|
+
query,
|
|
50
|
+
queryMatch
|
|
51
|
+
} from "./shared/chunk-hh0dhmb4.js";
|
|
52
|
+
import"./shared/chunk-jrtrk5z4.js";
|
|
53
|
+
import {
|
|
54
|
+
ThemeProvider,
|
|
55
|
+
children,
|
|
56
|
+
compileTheme,
|
|
57
|
+
css,
|
|
58
|
+
defineTheme,
|
|
59
|
+
getInjectedCSS,
|
|
60
|
+
globalCss,
|
|
61
|
+
injectCSS,
|
|
62
|
+
resetInjectedStyles,
|
|
63
|
+
resolveChildren,
|
|
64
|
+
s,
|
|
65
|
+
variants
|
|
66
|
+
} from "./shared/chunk-qacth5ah.js";
|
|
67
|
+
import {
|
|
68
|
+
__append,
|
|
69
|
+
__element,
|
|
70
|
+
__enterChildren,
|
|
71
|
+
__exitChildren,
|
|
72
|
+
__staticText,
|
|
73
|
+
endHydration,
|
|
74
|
+
startHydration
|
|
75
|
+
} from "./shared/chunk-ryb49346.js";
|
|
76
|
+
import {
|
|
77
|
+
RENDER_NODE_BRAND,
|
|
78
|
+
createDOMAdapter,
|
|
79
|
+
getAdapter,
|
|
80
|
+
isRenderNode,
|
|
81
|
+
setAdapter
|
|
82
|
+
} from "./shared/chunk-g4rch80a.js";
|
|
30
83
|
import {
|
|
31
84
|
DisposalScopeError,
|
|
32
85
|
_tryOnCleanup,
|
|
33
86
|
batch,
|
|
34
87
|
computed,
|
|
35
88
|
createContext,
|
|
36
|
-
|
|
37
|
-
|
|
89
|
+
domEffect,
|
|
90
|
+
getContextScope,
|
|
38
91
|
popScope,
|
|
39
92
|
pushScope,
|
|
40
93
|
runCleanups,
|
|
94
|
+
setContextScope,
|
|
41
95
|
signal,
|
|
42
96
|
untrack,
|
|
43
97
|
useContext
|
|
44
|
-
} from "./shared/chunk-
|
|
45
|
-
import
|
|
46
|
-
ThemeProvider,
|
|
47
|
-
compileTheme,
|
|
48
|
-
css,
|
|
49
|
-
defineTheme,
|
|
50
|
-
globalCss,
|
|
51
|
-
s,
|
|
52
|
-
variants
|
|
53
|
-
} from "./shared/chunk-f1ynwam4.js";
|
|
54
|
-
|
|
55
|
-
// src/component/children.ts
|
|
56
|
-
function resolveChildren(value) {
|
|
57
|
-
if (value == null) {
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
if (typeof value === "string") {
|
|
61
|
-
return [document.createTextNode(value)];
|
|
62
|
-
}
|
|
63
|
-
if (typeof value === "number") {
|
|
64
|
-
return [document.createTextNode(String(value))];
|
|
65
|
-
}
|
|
66
|
-
if (Array.isArray(value)) {
|
|
67
|
-
const result = [];
|
|
68
|
-
for (const child of value) {
|
|
69
|
-
const resolved = resolveChildren(child);
|
|
70
|
-
for (const node of resolved) {
|
|
71
|
-
result.push(node);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
return [value];
|
|
77
|
-
}
|
|
78
|
-
function children(accessor) {
|
|
79
|
-
return () => resolveChildren(accessor());
|
|
80
|
-
}
|
|
98
|
+
} from "./shared/chunk-hrd0mft1.js";
|
|
99
|
+
import"./shared/chunk-prj7nm08.js";
|
|
81
100
|
// src/component/error-boundary-context.ts
|
|
82
101
|
var handlerStack = [];
|
|
83
102
|
function pushErrorHandler(handler) {
|
|
@@ -137,9 +156,17 @@ function ErrorBoundary(props) {
|
|
|
137
156
|
}
|
|
138
157
|
// src/component/lifecycle.ts
|
|
139
158
|
function onMount(callback) {
|
|
159
|
+
if (typeof globalThis !== "undefined") {
|
|
160
|
+
const check = globalThis.__VERTZ_IS_SSR__;
|
|
161
|
+
if (typeof check === "function" && check())
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
140
164
|
const scope = pushScope();
|
|
141
165
|
try {
|
|
142
|
-
untrack(callback);
|
|
166
|
+
const cleanup = untrack(callback);
|
|
167
|
+
if (typeof cleanup === "function") {
|
|
168
|
+
_tryOnCleanup(cleanup);
|
|
169
|
+
}
|
|
143
170
|
} finally {
|
|
144
171
|
popScope();
|
|
145
172
|
if (scope.length > 0) {
|
|
@@ -147,26 +174,74 @@ function onMount(callback) {
|
|
|
147
174
|
}
|
|
148
175
|
}
|
|
149
176
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
177
|
+
// src/component/presence.ts
|
|
178
|
+
function Presence(props) {
|
|
179
|
+
const anchor = document.createComment("presence");
|
|
180
|
+
let currentNode = null;
|
|
181
|
+
let exitingNode = null;
|
|
182
|
+
let branchCleanups = [];
|
|
183
|
+
let generation = 0;
|
|
184
|
+
const outerScope = pushScope();
|
|
185
|
+
try {
|
|
186
|
+
domEffect(() => {
|
|
187
|
+
const show = props.when;
|
|
188
|
+
if (show && !currentNode) {
|
|
189
|
+
generation++;
|
|
190
|
+
if (exitingNode?.parentNode) {
|
|
191
|
+
exitingNode.parentNode.removeChild(exitingNode);
|
|
192
|
+
exitingNode = null;
|
|
193
|
+
}
|
|
194
|
+
const scope = pushScope();
|
|
195
|
+
const child = props.children();
|
|
196
|
+
popScope();
|
|
197
|
+
if (!(child instanceof HTMLElement)) {
|
|
198
|
+
runCleanups(scope);
|
|
199
|
+
throw new Error("Presence requires a single HTMLElement child. Wrap multiple children in a container element.");
|
|
200
|
+
}
|
|
201
|
+
branchCleanups = scope;
|
|
202
|
+
currentNode = child;
|
|
203
|
+
child.setAttribute("data-presence", "enter");
|
|
204
|
+
anchor.parentNode?.insertBefore(currentNode, anchor.nextSibling);
|
|
205
|
+
onAnimationsComplete(child, () => {
|
|
206
|
+
if (currentNode === child) {
|
|
207
|
+
child.removeAttribute("data-presence");
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
} else if (!show && currentNode) {
|
|
211
|
+
const gen = ++generation;
|
|
212
|
+
const exitingEl = currentNode;
|
|
213
|
+
currentNode = null;
|
|
214
|
+
exitingNode = exitingEl;
|
|
215
|
+
runCleanups(branchCleanups);
|
|
216
|
+
branchCleanups = [];
|
|
217
|
+
exitingEl.setAttribute("data-presence", "exit");
|
|
218
|
+
exitingEl.offsetHeight;
|
|
219
|
+
onAnimationsComplete(exitingEl, () => {
|
|
220
|
+
if (generation === gen) {
|
|
221
|
+
exitingEl.parentNode?.removeChild(exitingEl);
|
|
222
|
+
exitingNode = null;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
} finally {
|
|
228
|
+
popScope();
|
|
229
|
+
}
|
|
230
|
+
const dispose = () => {
|
|
231
|
+
runCleanups(branchCleanups);
|
|
232
|
+
runCleanups(outerScope);
|
|
233
|
+
if (currentNode?.parentNode) {
|
|
234
|
+
currentNode.parentNode.removeChild(currentNode);
|
|
235
|
+
currentNode = null;
|
|
167
236
|
}
|
|
168
|
-
|
|
169
|
-
|
|
237
|
+
};
|
|
238
|
+
_tryOnCleanup(dispose);
|
|
239
|
+
const fragment = document.createDocumentFragment();
|
|
240
|
+
fragment.appendChild(anchor);
|
|
241
|
+
if (currentNode) {
|
|
242
|
+
fragment.appendChild(currentNode);
|
|
243
|
+
}
|
|
244
|
+
return Object.assign(fragment, { dispose });
|
|
170
245
|
}
|
|
171
246
|
// src/component/refs.ts
|
|
172
247
|
function ref() {
|
|
@@ -217,45 +292,492 @@ function Suspense(props) {
|
|
|
217
292
|
return placeholder;
|
|
218
293
|
}
|
|
219
294
|
}
|
|
295
|
+
// src/dialog/dialog-stack.ts
|
|
296
|
+
var DialogStackContext = createContext();
|
|
297
|
+
function useDialogStack() {
|
|
298
|
+
const stack = useContext(DialogStackContext);
|
|
299
|
+
if (!stack) {
|
|
300
|
+
throw new Error("useDialogStack() must be called within DialogStackProvider");
|
|
301
|
+
}
|
|
302
|
+
const capturedScope = getContextScope();
|
|
303
|
+
return {
|
|
304
|
+
open(component, props) {
|
|
305
|
+
return stack.openWithScope(component, props, capturedScope);
|
|
306
|
+
},
|
|
307
|
+
openWithScope: stack.openWithScope,
|
|
308
|
+
get size() {
|
|
309
|
+
return stack.size;
|
|
310
|
+
},
|
|
311
|
+
closeAll() {
|
|
312
|
+
stack.closeAll();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
class DialogDismissedError extends Error {
|
|
318
|
+
constructor() {
|
|
319
|
+
super("Dialog was dismissed");
|
|
320
|
+
this.name = "DialogDismissedError";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function createDialogStack(container) {
|
|
324
|
+
const entries = [];
|
|
325
|
+
let nextId = 0;
|
|
326
|
+
function open(component, props, capturedScope) {
|
|
327
|
+
return new Promise((resolve, reject) => {
|
|
328
|
+
if (entries.length > 0) {
|
|
329
|
+
entries[entries.length - 1].wrapper.setAttribute("data-state", "background");
|
|
330
|
+
}
|
|
331
|
+
const wrapper = document.createElement("div");
|
|
332
|
+
wrapper.setAttribute("data-dialog-wrapper", "");
|
|
333
|
+
wrapper.setAttribute("data-state", "open");
|
|
334
|
+
wrapper.setAttribute("data-dialog-depth", "0");
|
|
335
|
+
const entry = {
|
|
336
|
+
id: nextId++,
|
|
337
|
+
wrapper,
|
|
338
|
+
node: null,
|
|
339
|
+
resolve,
|
|
340
|
+
reject,
|
|
341
|
+
cleanups: [],
|
|
342
|
+
dismissible: true
|
|
343
|
+
};
|
|
344
|
+
const prevScope = setContextScope(capturedScope ?? null);
|
|
345
|
+
const scope = pushScope();
|
|
346
|
+
const handle = {
|
|
347
|
+
close: (...args) => {
|
|
348
|
+
closeEntry(entry, args[0]);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
entry.node = component({ ...props, dialog: handle });
|
|
352
|
+
entry.cleanups = [...scope];
|
|
353
|
+
popScope();
|
|
354
|
+
setContextScope(prevScope);
|
|
355
|
+
if (entry.dismissible) {
|
|
356
|
+
wrapper.addEventListener("keydown", (e) => {
|
|
357
|
+
if (e.key === "Escape" && entries[entries.length - 1] === entry) {
|
|
358
|
+
e.preventDefault();
|
|
359
|
+
e.stopPropagation();
|
|
360
|
+
dismissEntry(entry);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
wrapper.appendChild(entry.node);
|
|
365
|
+
container.appendChild(wrapper);
|
|
366
|
+
entries.push(entry);
|
|
367
|
+
updateDepthAttributes();
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
function closeEntry(entry, result) {
|
|
371
|
+
const idx = entries.indexOf(entry);
|
|
372
|
+
if (idx === -1)
|
|
373
|
+
return;
|
|
374
|
+
entry.wrapper.setAttribute("data-state", "closed");
|
|
375
|
+
onAnimationsComplete(entry.wrapper, () => {
|
|
376
|
+
runCleanups(entry.cleanups);
|
|
377
|
+
if (entry.wrapper.parentNode === container) {
|
|
378
|
+
container.removeChild(entry.wrapper);
|
|
379
|
+
}
|
|
380
|
+
const entryIdx = entries.indexOf(entry);
|
|
381
|
+
if (entryIdx !== -1) {
|
|
382
|
+
entries.splice(entryIdx, 1);
|
|
383
|
+
}
|
|
384
|
+
if (entries.length > 0) {
|
|
385
|
+
entries[entries.length - 1].wrapper.setAttribute("data-state", "open");
|
|
386
|
+
}
|
|
387
|
+
updateDepthAttributes();
|
|
388
|
+
entry.resolve(result);
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
function updateDepthAttributes() {
|
|
392
|
+
for (let i = 0;i < entries.length; i++) {
|
|
393
|
+
entries[i].wrapper.setAttribute("data-dialog-depth", String(entries.length - 1 - i));
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
open(component, props) {
|
|
398
|
+
return open(component, props);
|
|
399
|
+
},
|
|
400
|
+
openWithScope(component, props, scope) {
|
|
401
|
+
return open(component, props, scope);
|
|
402
|
+
},
|
|
403
|
+
get size() {
|
|
404
|
+
return entries.length;
|
|
405
|
+
},
|
|
406
|
+
closeAll() {
|
|
407
|
+
for (let i = entries.length - 1;i >= 0; i--) {
|
|
408
|
+
dismissEntry(entries[i]);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
function dismissEntry(entry) {
|
|
413
|
+
const idx = entries.indexOf(entry);
|
|
414
|
+
if (idx === -1)
|
|
415
|
+
return;
|
|
416
|
+
entry.wrapper.setAttribute("data-state", "closed");
|
|
417
|
+
onAnimationsComplete(entry.wrapper, () => {
|
|
418
|
+
runCleanups(entry.cleanups);
|
|
419
|
+
if (entry.wrapper.parentNode === container) {
|
|
420
|
+
container.removeChild(entry.wrapper);
|
|
421
|
+
}
|
|
422
|
+
const entryIdx = entries.indexOf(entry);
|
|
423
|
+
if (entryIdx !== -1) {
|
|
424
|
+
entries.splice(entryIdx, 1);
|
|
425
|
+
}
|
|
426
|
+
if (entries.length > 0) {
|
|
427
|
+
entries[entries.length - 1].wrapper.setAttribute("data-state", "open");
|
|
428
|
+
}
|
|
429
|
+
updateDepthAttributes();
|
|
430
|
+
entry.reject(new DialogDismissedError);
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
// src/mount.ts
|
|
435
|
+
function mount(app, selector, options) {
|
|
436
|
+
if (typeof selector !== "string" && !(selector instanceof HTMLElement)) {
|
|
437
|
+
throw new Error(`mount(): selector must be a string or HTMLElement, got ${typeof selector}`);
|
|
438
|
+
}
|
|
439
|
+
const root = typeof selector === "string" ? document.querySelector(selector) : selector;
|
|
440
|
+
if (!root) {
|
|
441
|
+
throw new Error(`mount(): root element "${selector}" not found`);
|
|
442
|
+
}
|
|
443
|
+
if (options?.theme) {
|
|
444
|
+
const { css: css2 } = compileTheme(options.theme);
|
|
445
|
+
injectCSS(css2);
|
|
446
|
+
}
|
|
447
|
+
if (options?.styles) {
|
|
448
|
+
for (const css2 of options.styles) {
|
|
449
|
+
injectCSS(css2);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (root.firstChild) {
|
|
453
|
+
const scope2 = pushScope();
|
|
454
|
+
try {
|
|
455
|
+
startHydration(root);
|
|
456
|
+
app();
|
|
457
|
+
endHydration();
|
|
458
|
+
popScope();
|
|
459
|
+
options?.onMount?.(root);
|
|
460
|
+
return {
|
|
461
|
+
unmount: () => {
|
|
462
|
+
runCleanups(scope2);
|
|
463
|
+
root.textContent = "";
|
|
464
|
+
},
|
|
465
|
+
root
|
|
466
|
+
};
|
|
467
|
+
} catch (e) {
|
|
468
|
+
endHydration();
|
|
469
|
+
popScope();
|
|
470
|
+
runCleanups(scope2);
|
|
471
|
+
if (typeof process !== "undefined" && true) {
|
|
472
|
+
console.warn("[mount] Hydration failed — re-rendering from scratch (no data loss):", e);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
const scope = pushScope();
|
|
477
|
+
root.textContent = "";
|
|
478
|
+
const appElement = app();
|
|
479
|
+
root.appendChild(appElement);
|
|
480
|
+
popScope();
|
|
481
|
+
options?.onMount?.(root);
|
|
482
|
+
return {
|
|
483
|
+
unmount: () => {
|
|
484
|
+
runCleanups(scope);
|
|
485
|
+
root.textContent = "";
|
|
486
|
+
},
|
|
487
|
+
root
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
// src/store/merge.ts
|
|
491
|
+
function shallowMerge(existing, incoming) {
|
|
492
|
+
const result = { ...existing };
|
|
493
|
+
for (const key of Object.keys(incoming)) {
|
|
494
|
+
const value = incoming[key];
|
|
495
|
+
if (value !== undefined) {
|
|
496
|
+
result[key] = value;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return result;
|
|
500
|
+
}
|
|
501
|
+
function shallowEqual(a, b) {
|
|
502
|
+
const keysA = Object.keys(a);
|
|
503
|
+
const keysB = Object.keys(b);
|
|
504
|
+
if (keysA.length !== keysB.length) {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
for (const key of keysA) {
|
|
508
|
+
if (a[key] !== b[key]) {
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// src/store/query-result-index.ts
|
|
516
|
+
class QueryResultIndex {
|
|
517
|
+
_indices = new Map;
|
|
518
|
+
set(queryKey, ids) {
|
|
519
|
+
this._indices.set(queryKey, ids);
|
|
520
|
+
}
|
|
521
|
+
get(queryKey) {
|
|
522
|
+
return this._indices.get(queryKey);
|
|
523
|
+
}
|
|
524
|
+
removeEntity(entityId) {
|
|
525
|
+
for (const [queryKey, ids] of this._indices.entries()) {
|
|
526
|
+
const filtered = ids.filter((id) => id !== entityId);
|
|
527
|
+
if (filtered.length !== ids.length) {
|
|
528
|
+
this._indices.set(queryKey, filtered);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
clear(queryKey) {
|
|
533
|
+
this._indices.delete(queryKey);
|
|
534
|
+
}
|
|
535
|
+
keys() {
|
|
536
|
+
return Array.from(this._indices.keys());
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// src/store/entity-store.ts
|
|
541
|
+
class EntityStore {
|
|
542
|
+
_entities = new Map;
|
|
543
|
+
_typeListeners = new Map;
|
|
544
|
+
_queryIndices = new QueryResultIndex;
|
|
545
|
+
constructor(options) {
|
|
546
|
+
if (options?.initialData) {
|
|
547
|
+
this.hydrate(options.initialData);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
get(type, id) {
|
|
551
|
+
const typeMap = this._entities.get(type);
|
|
552
|
+
if (typeMap?.has(id)) {
|
|
553
|
+
return typeMap.get(id);
|
|
554
|
+
}
|
|
555
|
+
const sig = signal(undefined);
|
|
556
|
+
this._getOrCreateTypeMap(type).set(id, sig);
|
|
557
|
+
return sig;
|
|
558
|
+
}
|
|
559
|
+
getMany(type, ids) {
|
|
560
|
+
return computed(() => ids.map((id) => this.get(type, id).value));
|
|
561
|
+
}
|
|
562
|
+
merge(type, data) {
|
|
563
|
+
const items = Array.isArray(data) ? data : [data];
|
|
564
|
+
if (items.length === 0) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
batch(() => {
|
|
568
|
+
for (const item of items) {
|
|
569
|
+
const typeMap = this._entities.get(type);
|
|
570
|
+
const existing = typeMap?.get(item.id);
|
|
571
|
+
if (existing) {
|
|
572
|
+
const current = existing.peek();
|
|
573
|
+
const merged = shallowMerge(current || {}, item);
|
|
574
|
+
if (!shallowEqual(current || {}, merged)) {
|
|
575
|
+
untrack(() => {
|
|
576
|
+
existing.value = merged;
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
} else {
|
|
580
|
+
const newSignal = signal(item);
|
|
581
|
+
this._getOrCreateTypeMap(type).set(item.id, newSignal);
|
|
582
|
+
this._notifyTypeChange(type);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
remove(type, id) {
|
|
588
|
+
const typeMap = this._entities.get(type);
|
|
589
|
+
if (!typeMap?.has(id)) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const existing = typeMap.get(id);
|
|
593
|
+
if (existing) {
|
|
594
|
+
existing.value = undefined;
|
|
595
|
+
}
|
|
596
|
+
typeMap.delete(id);
|
|
597
|
+
this._queryIndices.removeEntity(id);
|
|
598
|
+
this._notifyTypeChange(type);
|
|
599
|
+
}
|
|
600
|
+
onTypeChange(type, callback) {
|
|
601
|
+
const listeners = this._getOrCreateListeners(type);
|
|
602
|
+
listeners.add(callback);
|
|
603
|
+
return () => {
|
|
604
|
+
listeners.delete(callback);
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
has(type, id) {
|
|
608
|
+
const typeMap = this._entities.get(type);
|
|
609
|
+
if (!typeMap?.has(id)) {
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
const signal2 = typeMap.get(id);
|
|
613
|
+
return signal2?.peek() !== undefined;
|
|
614
|
+
}
|
|
615
|
+
size(type) {
|
|
616
|
+
const typeMap = this._entities.get(type);
|
|
617
|
+
if (!typeMap) {
|
|
618
|
+
return 0;
|
|
619
|
+
}
|
|
620
|
+
let count = 0;
|
|
621
|
+
for (const signal2 of typeMap.values()) {
|
|
622
|
+
if (signal2.peek() !== undefined) {
|
|
623
|
+
count++;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return count;
|
|
627
|
+
}
|
|
628
|
+
dehydrate() {
|
|
629
|
+
const entities = {};
|
|
630
|
+
for (const [type, typeMap] of this._entities.entries()) {
|
|
631
|
+
const typeEntities = {};
|
|
632
|
+
for (const [id, signal2] of typeMap.entries()) {
|
|
633
|
+
const value = signal2.peek();
|
|
634
|
+
if (value !== undefined) {
|
|
635
|
+
typeEntities[id] = value;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (Object.keys(typeEntities).length > 0) {
|
|
639
|
+
entities[type] = typeEntities;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
const queries = {};
|
|
643
|
+
for (const queryKey of this._queryIndices.keys()) {
|
|
644
|
+
const ids = this._queryIndices.get(queryKey);
|
|
645
|
+
if (ids) {
|
|
646
|
+
queries[queryKey] = { ids };
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return {
|
|
650
|
+
entities,
|
|
651
|
+
...Object.keys(queries).length > 0 ? { queries } : {}
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
hydrate(data) {
|
|
655
|
+
for (const [type, typeEntities] of Object.entries(data.entities)) {
|
|
656
|
+
const entities = Object.values(typeEntities).map((entity) => ({
|
|
657
|
+
...entity,
|
|
658
|
+
id: entity.id
|
|
659
|
+
}));
|
|
660
|
+
this.merge(type, entities);
|
|
661
|
+
}
|
|
662
|
+
if (data.queries) {
|
|
663
|
+
for (const [queryKey, queryData] of Object.entries(data.queries)) {
|
|
664
|
+
this._queryIndices.set(queryKey, queryData.ids);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
_getOrCreateTypeMap(type) {
|
|
669
|
+
let typeMap = this._entities.get(type);
|
|
670
|
+
if (!typeMap) {
|
|
671
|
+
typeMap = new Map;
|
|
672
|
+
this._entities.set(type, typeMap);
|
|
673
|
+
}
|
|
674
|
+
return typeMap;
|
|
675
|
+
}
|
|
676
|
+
_getOrCreateListeners(type) {
|
|
677
|
+
let listeners = this._typeListeners.get(type);
|
|
678
|
+
if (!listeners) {
|
|
679
|
+
listeners = new Set;
|
|
680
|
+
this._typeListeners.set(type, listeners);
|
|
681
|
+
}
|
|
682
|
+
return listeners;
|
|
683
|
+
}
|
|
684
|
+
_notifyTypeChange(type) {
|
|
685
|
+
const listeners = this._typeListeners.get(type);
|
|
686
|
+
if (listeners) {
|
|
687
|
+
for (const callback of listeners) {
|
|
688
|
+
callback();
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
// src/store/test-utils.ts
|
|
694
|
+
function createTestStore(data) {
|
|
695
|
+
const store = new EntityStore;
|
|
696
|
+
for (const [type, entities] of Object.entries(data)) {
|
|
697
|
+
const entityArray = Object.values(entities);
|
|
698
|
+
if (entityArray.length > 0) {
|
|
699
|
+
store.merge(type, entityArray);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return store;
|
|
703
|
+
}
|
|
220
704
|
export {
|
|
221
|
-
|
|
222
|
-
|
|
705
|
+
zoomOut,
|
|
706
|
+
zoomIn,
|
|
223
707
|
variants,
|
|
224
708
|
validate,
|
|
225
709
|
useSearchParams,
|
|
710
|
+
useRouter,
|
|
711
|
+
useParams,
|
|
712
|
+
useDialogStack,
|
|
226
713
|
useContext,
|
|
227
714
|
untrack,
|
|
715
|
+
slideOutToTop,
|
|
716
|
+
slideOutToRight,
|
|
717
|
+
slideOutToLeft,
|
|
718
|
+
slideOutToBottom,
|
|
719
|
+
slideInFromTop,
|
|
720
|
+
slideInFromRight,
|
|
721
|
+
slideInFromLeft,
|
|
722
|
+
slideInFromBottom,
|
|
228
723
|
signal,
|
|
724
|
+
setAdapter,
|
|
229
725
|
s,
|
|
230
726
|
resolveChildren,
|
|
727
|
+
resetInjectedStyles,
|
|
231
728
|
ref,
|
|
729
|
+
queryMatch,
|
|
232
730
|
query,
|
|
233
731
|
parseSearchParams,
|
|
732
|
+
palettes,
|
|
234
733
|
onMount,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
734
|
+
mount,
|
|
735
|
+
keyframes,
|
|
736
|
+
isRenderNode,
|
|
737
|
+
isQueryDescriptor,
|
|
738
|
+
injectCSS,
|
|
240
739
|
hydrate,
|
|
241
740
|
globalCss,
|
|
741
|
+
getInjectedCSS,
|
|
742
|
+
getAdapter,
|
|
242
743
|
formDataToObject,
|
|
243
744
|
form,
|
|
244
|
-
|
|
245
|
-
|
|
745
|
+
fadeOut,
|
|
746
|
+
fadeIn,
|
|
246
747
|
defineTheme,
|
|
247
748
|
defineRoutes,
|
|
248
749
|
css,
|
|
750
|
+
createTestStore,
|
|
249
751
|
createRouter,
|
|
250
|
-
createOutlet,
|
|
251
752
|
createLink,
|
|
753
|
+
createFieldState,
|
|
754
|
+
createDialogStack,
|
|
755
|
+
createDOMAdapter,
|
|
252
756
|
createContext,
|
|
253
757
|
computed,
|
|
254
758
|
compileTheme,
|
|
255
759
|
children,
|
|
256
760
|
batch,
|
|
761
|
+
accordionUp,
|
|
762
|
+
accordionDown,
|
|
763
|
+
__staticText,
|
|
764
|
+
__exitChildren,
|
|
765
|
+
__enterChildren,
|
|
766
|
+
__element,
|
|
767
|
+
__append,
|
|
257
768
|
ThemeProvider,
|
|
258
769
|
Suspense,
|
|
770
|
+
RouterView,
|
|
771
|
+
RouterContext,
|
|
772
|
+
RENDER_NODE_BRAND,
|
|
773
|
+
Presence,
|
|
774
|
+
OutletContext,
|
|
775
|
+
Outlet,
|
|
259
776
|
ErrorBoundary,
|
|
260
|
-
|
|
777
|
+
EntityStore,
|
|
778
|
+
DisposalScopeError,
|
|
779
|
+
DialogStackContext,
|
|
780
|
+
DialogDismissedError,
|
|
781
|
+
ANIMATION_EASING,
|
|
782
|
+
ANIMATION_DURATION
|
|
261
783
|
};
|