@vertz/ui 0.2.23 → 0.2.24
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/shared/{chunk-p3fz6qqp.js → chunk-18frwfc4.js} +1 -1
- package/dist/shared/chunk-2eh4p2n7.js +39 -0
- package/dist/shared/{chunk-016m1fq0.js → chunk-2wag9c7v.js} +116 -12
- package/dist/shared/{chunk-g6fb5yc2.js → chunk-4gen306a.js} +209 -152
- package/dist/shared/{chunk-2kyhn86t.js → chunk-ge2e6y2s.js} +4 -62
- package/dist/shared/{chunk-4xkw6h1s.js → chunk-h1fsr8kv.js} +67 -1
- package/dist/shared/{chunk-13tvh4wq.js → chunk-mbnda3pv.js} +60 -3
- package/dist/shared/{chunk-xhc7arn9.js → chunk-t3rnfxc0.js} +13 -11
- package/dist/src/auth/public.d.ts +35 -1
- package/dist/src/auth/public.js +69 -0
- package/dist/src/components/index.d.ts +2 -2
- package/dist/src/components/index.js +51 -46
- package/dist/src/css/public.d.ts +5 -1
- package/dist/src/css/public.js +3 -3
- package/dist/src/index.d.ts +139 -12
- package/dist/src/index.js +332 -126
- package/dist/src/internals.d.ts +35 -6
- package/dist/src/internals.js +106 -26
- package/dist/src/jsx-runtime/index.js +3 -5
- package/dist/src/query/public.d.ts +7 -3
- package/dist/src/query/public.js +2 -1
- package/dist/src/router/public.d.ts +27 -4
- package/dist/src/router/public.js +4 -5
- package/dist/src/test/index.d.ts +12 -3
- package/package.json +4 -3
- package/reactivity.json +1 -1
- package/dist/shared/chunk-prj7nm08.js +0 -67
package/dist/src/index.js
CHANGED
|
@@ -24,23 +24,24 @@ import {
|
|
|
24
24
|
slideOutToTop,
|
|
25
25
|
zoomIn,
|
|
26
26
|
zoomOut
|
|
27
|
-
} from "../shared/chunk-
|
|
27
|
+
} from "../shared/chunk-18frwfc4.js";
|
|
28
28
|
import {
|
|
29
|
+
ErrorBoundary,
|
|
29
30
|
Link,
|
|
30
31
|
Outlet,
|
|
31
32
|
OutletContext,
|
|
32
33
|
RouterView,
|
|
33
34
|
createLink,
|
|
35
|
+
getCurrentErrorHandler,
|
|
34
36
|
parseSearchParams,
|
|
35
37
|
useSearchParams
|
|
36
|
-
} from "../shared/chunk-
|
|
38
|
+
} from "../shared/chunk-2wag9c7v.js";
|
|
37
39
|
import {
|
|
38
40
|
beginDeferringMounts,
|
|
39
41
|
discardDeferredMounts,
|
|
40
42
|
flushDeferredMounts,
|
|
41
43
|
onMount
|
|
42
|
-
} from "../shared/chunk-
|
|
43
|
-
import"../shared/chunk-4xkw6h1s.js";
|
|
44
|
+
} from "../shared/chunk-ge2e6y2s.js";
|
|
44
45
|
import {
|
|
45
46
|
createRouter
|
|
46
47
|
} from "../shared/chunk-jtma4sh4.js";
|
|
@@ -61,12 +62,11 @@ import {
|
|
|
61
62
|
getMutationEventBus,
|
|
62
63
|
getQueryEnvelopeStore,
|
|
63
64
|
getRelationSchema,
|
|
64
|
-
invalidate,
|
|
65
65
|
query,
|
|
66
66
|
queryMatch,
|
|
67
67
|
registerRelationSchema,
|
|
68
68
|
resetRelationSchemas_TEST_ONLY
|
|
69
|
-
} from "../shared/chunk-
|
|
69
|
+
} from "../shared/chunk-4gen306a.js";
|
|
70
70
|
import"../shared/chunk-jrtrk5z4.js";
|
|
71
71
|
import {
|
|
72
72
|
ThemeProvider,
|
|
@@ -83,15 +83,16 @@ import {
|
|
|
83
83
|
resolveChildren,
|
|
84
84
|
s,
|
|
85
85
|
variants
|
|
86
|
-
} from "../shared/chunk-
|
|
86
|
+
} from "../shared/chunk-t3rnfxc0.js";
|
|
87
87
|
import {
|
|
88
88
|
__append,
|
|
89
89
|
__element,
|
|
90
90
|
__enterChildren,
|
|
91
91
|
__exitChildren,
|
|
92
|
+
__insert,
|
|
92
93
|
__staticText
|
|
93
|
-
} from "../shared/chunk-
|
|
94
|
-
import"../shared/chunk-
|
|
94
|
+
} from "../shared/chunk-mbnda3pv.js";
|
|
95
|
+
import"../shared/chunk-h1fsr8kv.js";
|
|
95
96
|
import {
|
|
96
97
|
RENDER_NODE_BRAND,
|
|
97
98
|
createDOMAdapter,
|
|
@@ -104,6 +105,10 @@ import {
|
|
|
104
105
|
useParams,
|
|
105
106
|
useRouter
|
|
106
107
|
} from "../shared/chunk-f4d5nphq.js";
|
|
108
|
+
import {
|
|
109
|
+
invalidate,
|
|
110
|
+
invalidateTenantQueries
|
|
111
|
+
} from "../shared/chunk-2eh4p2n7.js";
|
|
107
112
|
import {
|
|
108
113
|
isBrowser
|
|
109
114
|
} from "../shared/chunk-da2w7j7w.js";
|
|
@@ -122,6 +127,7 @@ import {
|
|
|
122
127
|
getContextScope,
|
|
123
128
|
getIsHydrating,
|
|
124
129
|
getSSRContext,
|
|
130
|
+
onCleanup,
|
|
125
131
|
popScope,
|
|
126
132
|
pushScope,
|
|
127
133
|
runCleanups,
|
|
@@ -131,65 +137,61 @@ import {
|
|
|
131
137
|
untrack,
|
|
132
138
|
useContext
|
|
133
139
|
} from "../shared/chunk-656n0x6y.js";
|
|
134
|
-
// src/component/error-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const retryResult = props.children();
|
|
180
|
-
if (fallbackNode.parentNode) {
|
|
181
|
-
fallbackNode.parentNode.replaceChild(retryResult, fallbackNode);
|
|
182
|
-
}
|
|
183
|
-
} catch (_retryThrown) {}
|
|
184
|
-
};
|
|
185
|
-
popErrorHandler();
|
|
186
|
-
const error = toError(thrown);
|
|
187
|
-
const fallbackNode = props.fallback(error, retry);
|
|
188
|
-
return fallbackNode;
|
|
189
|
-
}
|
|
140
|
+
// src/component/default-error-fallback.ts
|
|
141
|
+
function DefaultErrorFallback({ error, retry }) {
|
|
142
|
+
const container = document.createElement("div");
|
|
143
|
+
container.setAttribute("data-testid", "error-fallback");
|
|
144
|
+
Object.assign(container.style, {
|
|
145
|
+
display: "flex",
|
|
146
|
+
flexDirection: "column",
|
|
147
|
+
alignItems: "center",
|
|
148
|
+
justifyContent: "center",
|
|
149
|
+
padding: "2rem",
|
|
150
|
+
textAlign: "center"
|
|
151
|
+
});
|
|
152
|
+
const heading = document.createElement("h2");
|
|
153
|
+
heading.textContent = "Something went wrong";
|
|
154
|
+
Object.assign(heading.style, {
|
|
155
|
+
fontSize: "1.25rem",
|
|
156
|
+
fontWeight: "600",
|
|
157
|
+
marginBottom: "0.5rem",
|
|
158
|
+
color: "inherit"
|
|
159
|
+
});
|
|
160
|
+
const message = document.createElement("p");
|
|
161
|
+
message.textContent = error.message;
|
|
162
|
+
Object.assign(message.style, {
|
|
163
|
+
fontSize: "0.875rem",
|
|
164
|
+
opacity: "0.7",
|
|
165
|
+
marginBottom: "1rem",
|
|
166
|
+
maxWidth: "24rem"
|
|
167
|
+
});
|
|
168
|
+
const button = document.createElement("button");
|
|
169
|
+
button.type = "button";
|
|
170
|
+
button.setAttribute("data-testid", "error-retry");
|
|
171
|
+
button.textContent = "Try again";
|
|
172
|
+
Object.assign(button.style, {
|
|
173
|
+
padding: "0.5rem 1rem",
|
|
174
|
+
borderRadius: "0.375rem",
|
|
175
|
+
border: "1px solid currentColor",
|
|
176
|
+
background: "transparent",
|
|
177
|
+
cursor: "pointer",
|
|
178
|
+
fontSize: "0.875rem"
|
|
179
|
+
});
|
|
180
|
+
button.addEventListener("click", retry);
|
|
181
|
+
container.appendChild(heading);
|
|
182
|
+
container.appendChild(message);
|
|
183
|
+
container.appendChild(button);
|
|
184
|
+
return container;
|
|
190
185
|
}
|
|
191
186
|
// src/component/foreign.ts
|
|
192
|
-
function Foreign({
|
|
187
|
+
function Foreign({
|
|
188
|
+
tag = "div",
|
|
189
|
+
onReady,
|
|
190
|
+
html,
|
|
191
|
+
id,
|
|
192
|
+
className,
|
|
193
|
+
style
|
|
194
|
+
}) {
|
|
193
195
|
const el = __element(tag);
|
|
194
196
|
if (id)
|
|
195
197
|
el.id = id;
|
|
@@ -197,6 +199,9 @@ function Foreign({ tag = "div", onReady, id, className, style }) {
|
|
|
197
199
|
el.setAttribute("class", className);
|
|
198
200
|
if (style)
|
|
199
201
|
Object.assign(el.style, style);
|
|
202
|
+
if (html && getSSRContext()) {
|
|
203
|
+
el.innerHTML = html;
|
|
204
|
+
}
|
|
200
205
|
if (onReady && !getSSRContext()) {
|
|
201
206
|
onMount(() => onReady(el));
|
|
202
207
|
}
|
|
@@ -461,7 +466,7 @@ function ref() {
|
|
|
461
466
|
function isPromise(value) {
|
|
462
467
|
return value != null && typeof value === "object" && typeof value.then === "function";
|
|
463
468
|
}
|
|
464
|
-
function
|
|
469
|
+
function toError(value) {
|
|
465
470
|
if (value instanceof Error) {
|
|
466
471
|
return value;
|
|
467
472
|
}
|
|
@@ -493,17 +498,26 @@ function Suspense(props) {
|
|
|
493
498
|
}
|
|
494
499
|
} catch (retryError) {
|
|
495
500
|
if (!isPromise(retryError)) {
|
|
496
|
-
propagateError(
|
|
501
|
+
propagateError(toError(retryError), placeholder, errorHandler);
|
|
497
502
|
}
|
|
498
503
|
}
|
|
499
504
|
}).catch((error) => {
|
|
500
|
-
propagateError(
|
|
505
|
+
propagateError(toError(error), placeholder, errorHandler);
|
|
501
506
|
});
|
|
502
507
|
return placeholder;
|
|
503
508
|
}
|
|
504
509
|
}
|
|
505
510
|
// src/dialog/dialog-stack.ts
|
|
506
511
|
var DialogStackContext = createContext(undefined, "@vertz/ui::DialogStackContext");
|
|
512
|
+
var DialogHandleContext = createContext(undefined, "@vertz/ui::DialogHandleContext");
|
|
513
|
+
var DialogIdContext = createContext(undefined, "@vertz/ui::DialogIdContext");
|
|
514
|
+
function useDialog() {
|
|
515
|
+
const handle = useContext(DialogHandleContext);
|
|
516
|
+
if (!handle) {
|
|
517
|
+
throw new Error("useDialog() must be called within a dialog opened via DialogStack");
|
|
518
|
+
}
|
|
519
|
+
return handle;
|
|
520
|
+
}
|
|
507
521
|
function useDialogStack() {
|
|
508
522
|
const stack = useContext(DialogStackContext);
|
|
509
523
|
if (!stack) {
|
|
@@ -511,10 +525,13 @@ function useDialogStack() {
|
|
|
511
525
|
}
|
|
512
526
|
const capturedScope = getContextScope();
|
|
513
527
|
return {
|
|
514
|
-
open(component, props) {
|
|
515
|
-
return stack.openWithScope(component, props, capturedScope);
|
|
528
|
+
open(component, props, options) {
|
|
529
|
+
return stack.openWithScope(component, props, capturedScope, options);
|
|
516
530
|
},
|
|
517
531
|
openWithScope: stack.openWithScope,
|
|
532
|
+
confirm(opts) {
|
|
533
|
+
return stack.confirm(opts);
|
|
534
|
+
},
|
|
518
535
|
get size() {
|
|
519
536
|
return stack.size;
|
|
520
537
|
},
|
|
@@ -523,25 +540,84 @@ function useDialogStack() {
|
|
|
523
540
|
}
|
|
524
541
|
};
|
|
525
542
|
}
|
|
543
|
+
function DialogStackProvider({ children: children2 }) {
|
|
544
|
+
const container = __element("div", { "data-dialog-container": "" });
|
|
545
|
+
const stack = createDialogStack(container);
|
|
546
|
+
return DialogStackContext.Provider({
|
|
547
|
+
value: stack,
|
|
548
|
+
children: () => {
|
|
549
|
+
const frag = document.createDocumentFragment();
|
|
550
|
+
__insert(frag, children2);
|
|
551
|
+
frag.appendChild(container);
|
|
552
|
+
return frag;
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
function ConfirmDialogComponent({
|
|
557
|
+
title,
|
|
558
|
+
description,
|
|
559
|
+
confirm: confirmLabel = "Confirm",
|
|
560
|
+
cancel: cancelLabel = "Cancel",
|
|
561
|
+
intent = "primary",
|
|
562
|
+
dialog
|
|
563
|
+
}) {
|
|
564
|
+
const frag = document.createDocumentFragment();
|
|
565
|
+
const titleEl = document.createElement("h2");
|
|
566
|
+
titleEl.setAttribute("data-part", "title");
|
|
567
|
+
titleEl.textContent = title;
|
|
568
|
+
frag.appendChild(titleEl);
|
|
569
|
+
if (description) {
|
|
570
|
+
const descEl = document.createElement("p");
|
|
571
|
+
descEl.setAttribute("data-part", "description");
|
|
572
|
+
descEl.textContent = description;
|
|
573
|
+
frag.appendChild(descEl);
|
|
574
|
+
}
|
|
575
|
+
const footer = document.createElement("div");
|
|
576
|
+
footer.setAttribute("data-part", "footer");
|
|
577
|
+
const cancelBtn = document.createElement("button");
|
|
578
|
+
cancelBtn.setAttribute("type", "button");
|
|
579
|
+
cancelBtn.setAttribute("data-part", "confirm-cancel");
|
|
580
|
+
cancelBtn.textContent = cancelLabel;
|
|
581
|
+
cancelBtn.addEventListener("click", () => dialog.close(false));
|
|
582
|
+
const confirmBtn = document.createElement("button");
|
|
583
|
+
confirmBtn.setAttribute("type", "button");
|
|
584
|
+
confirmBtn.setAttribute("data-part", "confirm-action");
|
|
585
|
+
confirmBtn.setAttribute("data-intent", intent);
|
|
586
|
+
confirmBtn.textContent = confirmLabel;
|
|
587
|
+
confirmBtn.addEventListener("click", () => dialog.close(true));
|
|
588
|
+
footer.appendChild(cancelBtn);
|
|
589
|
+
footer.appendChild(confirmBtn);
|
|
590
|
+
frag.appendChild(footer);
|
|
591
|
+
return frag;
|
|
592
|
+
}
|
|
526
593
|
function createDialogStack(container) {
|
|
527
594
|
const entries = [];
|
|
528
595
|
let nextId = 0;
|
|
529
|
-
function open(component, props, capturedScope) {
|
|
596
|
+
function open(component, props, capturedScope, options) {
|
|
530
597
|
return new Promise((resolve) => {
|
|
531
598
|
if (entries.length > 0) {
|
|
532
|
-
entries[entries.length - 1].
|
|
599
|
+
entries[entries.length - 1].dialogEl.setAttribute("data-state", "background");
|
|
533
600
|
}
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
601
|
+
const dialogId = `dlg-${nextId}`;
|
|
602
|
+
const dialogEl = document.createElement("dialog");
|
|
603
|
+
dialogEl.setAttribute("data-dialog-wrapper", "");
|
|
604
|
+
dialogEl.setAttribute("data-state", "open");
|
|
605
|
+
dialogEl.setAttribute("data-dialog-depth", "0");
|
|
606
|
+
const panel = document.createElement("div");
|
|
607
|
+
panel.setAttribute("data-part", "panel");
|
|
608
|
+
panel.setAttribute("role", "dialog");
|
|
609
|
+
panel.setAttribute("aria-modal", "true");
|
|
610
|
+
panel.setAttribute("aria-labelledby", `${dialogId}-title`);
|
|
611
|
+
panel.setAttribute("aria-describedby", `${dialogId}-desc`);
|
|
612
|
+
dialogEl.appendChild(panel);
|
|
538
613
|
const entry = {
|
|
539
614
|
id: nextId++,
|
|
540
|
-
|
|
615
|
+
dialogEl,
|
|
616
|
+
panel,
|
|
541
617
|
node: null,
|
|
542
618
|
resolve,
|
|
543
619
|
cleanups: [],
|
|
544
|
-
dismissible:
|
|
620
|
+
dismissible: options?.dismissible !== false,
|
|
545
621
|
settled: false
|
|
546
622
|
};
|
|
547
623
|
const prevScope = setContextScope(capturedScope ?? null);
|
|
@@ -551,60 +627,93 @@ function createDialogStack(container) {
|
|
|
551
627
|
closeEntry(entry, args[0]);
|
|
552
628
|
}
|
|
553
629
|
};
|
|
554
|
-
|
|
630
|
+
DialogHandleContext.Provider(handle, () => {
|
|
631
|
+
DialogIdContext.Provider(dialogId, () => {
|
|
632
|
+
entry.node = component({ ...props, dialog: handle });
|
|
633
|
+
});
|
|
634
|
+
});
|
|
555
635
|
entry.cleanups = [...scope];
|
|
556
636
|
popScope();
|
|
557
637
|
setContextScope(prevScope);
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
638
|
+
dialogEl.addEventListener("cancel", (e) => {
|
|
639
|
+
e.preventDefault();
|
|
640
|
+
if (entry.dismissible && entries[entries.length - 1] === entry) {
|
|
641
|
+
dismissEntry(entry);
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
dialogEl.addEventListener("click", (e) => {
|
|
645
|
+
if (!entry.dismissible)
|
|
646
|
+
return;
|
|
647
|
+
const rect = panel.getBoundingClientRect();
|
|
648
|
+
const isOutside = e.clientX < rect.left || e.clientX > rect.right || e.clientY < rect.top || e.clientY > rect.bottom;
|
|
649
|
+
if (isOutside) {
|
|
650
|
+
dismissEntry(entry);
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
panel.appendChild(entry.node);
|
|
654
|
+
const titleTarget = panel.querySelector('[data-part="title"]');
|
|
655
|
+
if (titleTarget && !titleTarget.id)
|
|
656
|
+
titleTarget.id = `${dialogId}-title`;
|
|
657
|
+
const descTarget = panel.querySelector('[data-part="description"]');
|
|
658
|
+
if (descTarget && !descTarget.id)
|
|
659
|
+
descTarget.id = `${dialogId}-desc`;
|
|
660
|
+
container.appendChild(dialogEl);
|
|
569
661
|
entries.push(entry);
|
|
570
662
|
updateDepthAttributes();
|
|
663
|
+
dialogEl.showModal();
|
|
571
664
|
});
|
|
572
665
|
}
|
|
573
|
-
function
|
|
666
|
+
function removeEntry(entry, resolution) {
|
|
574
667
|
if (entry.settled)
|
|
575
668
|
return;
|
|
576
669
|
const idx = entries.indexOf(entry);
|
|
577
670
|
if (idx === -1)
|
|
578
671
|
return;
|
|
579
672
|
entry.settled = true;
|
|
580
|
-
entry.
|
|
581
|
-
|
|
673
|
+
entry.dialogEl.setAttribute("data-state", "closed");
|
|
674
|
+
entry.dialogEl.setAttribute("inert", "");
|
|
675
|
+
onAnimationsComplete(entry.dialogEl, () => {
|
|
582
676
|
runCleanups(entry.cleanups);
|
|
583
|
-
if (entry.
|
|
584
|
-
|
|
677
|
+
if (entry.dialogEl.open) {
|
|
678
|
+
entry.dialogEl.close();
|
|
679
|
+
}
|
|
680
|
+
if (entry.dialogEl.parentNode === container) {
|
|
681
|
+
container.removeChild(entry.dialogEl);
|
|
585
682
|
}
|
|
586
683
|
const entryIdx = entries.indexOf(entry);
|
|
587
684
|
if (entryIdx !== -1) {
|
|
588
685
|
entries.splice(entryIdx, 1);
|
|
589
686
|
}
|
|
590
687
|
if (entries.length > 0) {
|
|
591
|
-
entries[entries.length - 1].
|
|
688
|
+
entries[entries.length - 1].dialogEl.setAttribute("data-state", "open");
|
|
592
689
|
}
|
|
593
690
|
updateDepthAttributes();
|
|
594
|
-
entry.resolve(
|
|
691
|
+
entry.resolve(resolution);
|
|
595
692
|
});
|
|
596
693
|
}
|
|
694
|
+
function closeEntry(entry, result) {
|
|
695
|
+
removeEntry(entry, { ok: true, data: result });
|
|
696
|
+
}
|
|
697
|
+
function dismissEntry(entry) {
|
|
698
|
+
removeEntry(entry, { ok: false });
|
|
699
|
+
}
|
|
597
700
|
function updateDepthAttributes() {
|
|
598
701
|
for (let i = 0;i < entries.length; i++) {
|
|
599
|
-
entries[i].
|
|
702
|
+
entries[i].dialogEl.setAttribute("data-dialog-depth", String(entries.length - 1 - i));
|
|
600
703
|
}
|
|
601
704
|
}
|
|
602
705
|
return {
|
|
603
|
-
open(component, props) {
|
|
604
|
-
return open(component, props);
|
|
706
|
+
open(component, props, options) {
|
|
707
|
+
return open(component, props, undefined, options);
|
|
708
|
+
},
|
|
709
|
+
openWithScope(component, props, scope, options) {
|
|
710
|
+
return open(component, props, scope, options);
|
|
605
711
|
},
|
|
606
|
-
|
|
607
|
-
|
|
712
|
+
async confirm(opts) {
|
|
713
|
+
const result = await open(ConfirmDialogComponent, opts, undefined, {
|
|
714
|
+
dismissible: opts.dismissible ?? false
|
|
715
|
+
});
|
|
716
|
+
return result.ok ? result.data : false;
|
|
608
717
|
},
|
|
609
718
|
get size() {
|
|
610
719
|
return entries.length;
|
|
@@ -615,30 +724,118 @@ function createDialogStack(container) {
|
|
|
615
724
|
}
|
|
616
725
|
}
|
|
617
726
|
};
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
727
|
+
}
|
|
728
|
+
// src/format/relative-time.ts
|
|
729
|
+
function toDate(date) {
|
|
730
|
+
if (date instanceof Date)
|
|
731
|
+
return date;
|
|
732
|
+
if (typeof date === "number")
|
|
733
|
+
return new Date(date);
|
|
734
|
+
return new Date(date);
|
|
735
|
+
}
|
|
736
|
+
var rtfCache = new Map;
|
|
737
|
+
function getFormatter(locale, numeric = "auto") {
|
|
738
|
+
const key = `${locale ?? ""}:${numeric}`;
|
|
739
|
+
let rtf = rtfCache.get(key);
|
|
740
|
+
if (!rtf) {
|
|
741
|
+
rtf = new Intl.RelativeTimeFormat(locale, { numeric, style: "long" });
|
|
742
|
+
rtfCache.set(key, rtf);
|
|
743
|
+
}
|
|
744
|
+
return rtf;
|
|
745
|
+
}
|
|
746
|
+
function formatRelativeTime(date, options) {
|
|
747
|
+
const now = options?.now ?? new Date;
|
|
748
|
+
const d = toDate(date);
|
|
749
|
+
if (Number.isNaN(d.getTime())) {
|
|
750
|
+
throw new Error(`formatRelativeTime: invalid date input: ${String(date)}`);
|
|
751
|
+
}
|
|
752
|
+
const diffMs = now.getTime() - d.getTime();
|
|
753
|
+
const diffSec = Math.floor(Math.abs(diffMs) / 1000);
|
|
754
|
+
const locale = options?.locale;
|
|
755
|
+
const numeric = options?.numeric ?? "auto";
|
|
756
|
+
const rtf = getFormatter(locale, numeric);
|
|
757
|
+
const sign = diffMs >= 0 ? -1 : 1;
|
|
758
|
+
if (diffSec < 10) {
|
|
759
|
+
return rtf.format(0, "second");
|
|
760
|
+
}
|
|
761
|
+
if (diffSec < 60) {
|
|
762
|
+
return rtf.format(sign * diffSec, "second");
|
|
763
|
+
}
|
|
764
|
+
const diffMin = Math.floor(diffSec / 60);
|
|
765
|
+
if (diffMin < 60) {
|
|
766
|
+
return rtf.format(sign * diffMin, "minute");
|
|
767
|
+
}
|
|
768
|
+
const diffHours = Math.floor(diffMin / 60);
|
|
769
|
+
if (diffHours < 24) {
|
|
770
|
+
return rtf.format(sign * diffHours, "hour");
|
|
771
|
+
}
|
|
772
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
773
|
+
if (diffDays < 7) {
|
|
774
|
+
return rtf.format(sign * diffDays, "day");
|
|
775
|
+
}
|
|
776
|
+
if (diffDays < 30) {
|
|
777
|
+
const diffWeeks = Math.floor(diffDays / 7);
|
|
778
|
+
return rtf.format(sign * diffWeeks, "week");
|
|
779
|
+
}
|
|
780
|
+
if (diffDays < 365) {
|
|
781
|
+
const diffMonths = Math.floor(diffDays / 30);
|
|
782
|
+
return rtf.format(sign * diffMonths, "month");
|
|
641
783
|
}
|
|
784
|
+
const diffYears = Math.floor(diffDays / 365);
|
|
785
|
+
return rtf.format(sign * diffYears, "year");
|
|
786
|
+
}
|
|
787
|
+
// src/format/relative-time-component.ts
|
|
788
|
+
function getAdaptiveInterval(date) {
|
|
789
|
+
const d = toDate(date);
|
|
790
|
+
const elapsedMs = Math.abs(Date.now() - d.getTime());
|
|
791
|
+
const elapsedSec = elapsedMs / 1000;
|
|
792
|
+
if (elapsedSec < 60)
|
|
793
|
+
return 1e4;
|
|
794
|
+
if (elapsedSec < 3600)
|
|
795
|
+
return 60000;
|
|
796
|
+
if (elapsedSec < 86400)
|
|
797
|
+
return 3600000;
|
|
798
|
+
return null;
|
|
799
|
+
}
|
|
800
|
+
function RelativeTime({
|
|
801
|
+
date,
|
|
802
|
+
locale,
|
|
803
|
+
numeric,
|
|
804
|
+
updateInterval,
|
|
805
|
+
className,
|
|
806
|
+
title
|
|
807
|
+
}) {
|
|
808
|
+
const d = toDate(date);
|
|
809
|
+
const isoString = d.toISOString();
|
|
810
|
+
const opts = { locale, numeric };
|
|
811
|
+
const el = document.createElement("time");
|
|
812
|
+
el.setAttribute("datetime", isoString);
|
|
813
|
+
el.textContent = formatRelativeTime(date, opts);
|
|
814
|
+
if (title !== false) {
|
|
815
|
+
el.title = typeof title === "string" ? title : new Intl.DateTimeFormat(locale, {
|
|
816
|
+
dateStyle: "long",
|
|
817
|
+
timeStyle: "medium"
|
|
818
|
+
}).format(d);
|
|
819
|
+
}
|
|
820
|
+
if (className) {
|
|
821
|
+
el.className = className;
|
|
822
|
+
}
|
|
823
|
+
onMount(() => {
|
|
824
|
+
let timerId;
|
|
825
|
+
function tick() {
|
|
826
|
+
el.textContent = formatRelativeTime(date, opts);
|
|
827
|
+
const interval = updateInterval ?? getAdaptiveInterval(date);
|
|
828
|
+
if (interval !== null) {
|
|
829
|
+
timerId = setTimeout(tick, interval);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
const initialInterval = updateInterval ?? getAdaptiveInterval(date);
|
|
833
|
+
if (initialInterval !== null) {
|
|
834
|
+
timerId = setTimeout(tick, initialInterval);
|
|
835
|
+
}
|
|
836
|
+
return () => clearTimeout(timerId);
|
|
837
|
+
});
|
|
838
|
+
return el;
|
|
642
839
|
}
|
|
643
840
|
// src/image/config.ts
|
|
644
841
|
var optimizerBaseUrl = null;
|
|
@@ -895,6 +1092,7 @@ export {
|
|
|
895
1092
|
useRouter,
|
|
896
1093
|
useParams,
|
|
897
1094
|
useDialogStack,
|
|
1095
|
+
useDialog,
|
|
898
1096
|
useContext,
|
|
899
1097
|
untrack,
|
|
900
1098
|
slideOutToTop,
|
|
@@ -919,12 +1117,14 @@ export {
|
|
|
919
1117
|
parseSearchParams,
|
|
920
1118
|
palettes,
|
|
921
1119
|
onMount,
|
|
1120
|
+
onCleanup,
|
|
922
1121
|
onAnimationsComplete,
|
|
923
1122
|
mount,
|
|
924
1123
|
keyframes,
|
|
925
1124
|
isRenderNode,
|
|
926
1125
|
isQueryDescriptor,
|
|
927
1126
|
isBrowser,
|
|
1127
|
+
invalidateTenantQueries,
|
|
928
1128
|
invalidate,
|
|
929
1129
|
injectCSS,
|
|
930
1130
|
hydrateIslands,
|
|
@@ -935,6 +1135,7 @@ export {
|
|
|
935
1135
|
getInjectedCSS,
|
|
936
1136
|
getEntityStore,
|
|
937
1137
|
getAdapter,
|
|
1138
|
+
formatRelativeTime,
|
|
938
1139
|
formDataToObject,
|
|
939
1140
|
form,
|
|
940
1141
|
font,
|
|
@@ -969,6 +1170,7 @@ export {
|
|
|
969
1170
|
Suspense,
|
|
970
1171
|
RouterView,
|
|
971
1172
|
RouterContext,
|
|
1173
|
+
RelativeTime,
|
|
972
1174
|
RENDER_NODE_BRAND,
|
|
973
1175
|
QueryEnvelopeStore,
|
|
974
1176
|
Presence,
|
|
@@ -983,7 +1185,11 @@ export {
|
|
|
983
1185
|
ErrorBoundary,
|
|
984
1186
|
EntityStore,
|
|
985
1187
|
DisposalScopeError,
|
|
1188
|
+
DialogStackProvider,
|
|
986
1189
|
DialogStackContext,
|
|
1190
|
+
DialogIdContext,
|
|
1191
|
+
DialogHandleContext,
|
|
1192
|
+
DefaultErrorFallback,
|
|
987
1193
|
ANIMATION_EASING,
|
|
988
1194
|
ANIMATION_DURATION
|
|
989
1195
|
};
|