@vertz/ui 0.2.23 → 0.2.25
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-09ntccdx.js +39 -0
- package/dist/shared/{chunk-g6fb5yc2.js → chunk-1jgws7rs.js} +210 -258
- package/dist/shared/{chunk-016m1fq0.js → chunk-2krx4aqe.js} +119 -15
- package/dist/shared/{chunk-f4d5nphq.js → chunk-7nr2ebrf.js} +1 -1
- package/dist/shared/{chunk-4gmtsf6v.js → chunk-bk7mmn92.js} +1 -1
- package/dist/shared/chunk-djvarb8r.js +333 -0
- package/dist/shared/{chunk-jtma4sh4.js → chunk-e09mdqcx.js} +2 -2
- package/dist/shared/{chunk-4xkw6h1s.js → chunk-h1fsr8kv.js} +67 -1
- package/dist/shared/{chunk-xhc7arn9.js → chunk-j1a7t906.js} +14 -12
- package/dist/shared/{chunk-656n0x6y.js → chunk-ppr06jgn.js} +8 -2
- package/dist/shared/{chunk-2kyhn86t.js → chunk-svvqjmyy.js} +5 -63
- package/dist/shared/{chunk-da2w7j7w.js → chunk-xs5s8gqe.js} +1 -1
- package/dist/shared/{chunk-p3fz6qqp.js → chunk-ymc3wwam.js} +8 -2
- package/dist/src/auth/public.d.ts +35 -1
- package/dist/src/auth/public.js +72 -3
- package/dist/src/components/index.d.ts +3 -2
- package/dist/src/components/index.js +56 -46
- package/dist/src/css/public.d.ts +5 -1
- package/dist/src/css/public.js +4 -5
- package/dist/src/form/public.js +2 -2
- package/dist/src/index.d.ts +162 -53
- package/dist/src/index.js +341 -320
- package/dist/src/internals.d.ts +85 -10
- package/dist/src/internals.js +380 -90
- package/dist/src/jsx-runtime/index.js +3 -5
- package/dist/src/query/public.d.ts +6 -33
- package/dist/src/query/public.js +5 -7
- package/dist/src/router/public.d.ts +27 -4
- package/dist/src/router/public.js +8 -10
- package/dist/src/test/index.d.ts +12 -3
- package/dist/src/test/index.js +3 -3
- package/package.json +4 -3
- package/reactivity.json +1 -1
- package/dist/shared/chunk-13tvh4wq.js +0 -229
- package/dist/shared/chunk-2y9f9j62.js +0 -40
- package/dist/shared/chunk-prj7nm08.js +0 -67
package/dist/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
ANIMATION_DURATION,
|
|
6
6
|
ANIMATION_EASING,
|
|
7
|
+
ListAnimationContext,
|
|
7
8
|
accordionDown,
|
|
8
9
|
accordionUp,
|
|
9
10
|
fadeIn,
|
|
@@ -24,26 +25,27 @@ import {
|
|
|
24
25
|
slideOutToTop,
|
|
25
26
|
zoomIn,
|
|
26
27
|
zoomOut
|
|
27
|
-
} from "../shared/chunk-
|
|
28
|
+
} from "../shared/chunk-ymc3wwam.js";
|
|
28
29
|
import {
|
|
30
|
+
ErrorBoundary,
|
|
29
31
|
Link,
|
|
30
32
|
Outlet,
|
|
31
33
|
OutletContext,
|
|
32
34
|
RouterView,
|
|
33
35
|
createLink,
|
|
36
|
+
getCurrentErrorHandler,
|
|
34
37
|
parseSearchParams,
|
|
35
38
|
useSearchParams
|
|
36
|
-
} from "../shared/chunk-
|
|
39
|
+
} from "../shared/chunk-2krx4aqe.js";
|
|
37
40
|
import {
|
|
38
41
|
beginDeferringMounts,
|
|
39
42
|
discardDeferredMounts,
|
|
40
43
|
flushDeferredMounts,
|
|
41
44
|
onMount
|
|
42
|
-
} from "../shared/chunk-
|
|
43
|
-
import"../shared/chunk-4xkw6h1s.js";
|
|
45
|
+
} from "../shared/chunk-svvqjmyy.js";
|
|
44
46
|
import {
|
|
45
47
|
createRouter
|
|
46
|
-
} from "../shared/chunk-
|
|
48
|
+
} from "../shared/chunk-e09mdqcx.js";
|
|
47
49
|
import {
|
|
48
50
|
defineRoutes
|
|
49
51
|
} from "../shared/chunk-am9zaw4h.js";
|
|
@@ -52,7 +54,7 @@ import {
|
|
|
52
54
|
form,
|
|
53
55
|
formDataToObject,
|
|
54
56
|
validate
|
|
55
|
-
} from "../shared/chunk-
|
|
57
|
+
} from "../shared/chunk-bk7mmn92.js";
|
|
56
58
|
import {
|
|
57
59
|
EntityStore,
|
|
58
60
|
FieldSelectionTracker,
|
|
@@ -61,12 +63,10 @@ import {
|
|
|
61
63
|
getMutationEventBus,
|
|
62
64
|
getQueryEnvelopeStore,
|
|
63
65
|
getRelationSchema,
|
|
64
|
-
invalidate,
|
|
65
66
|
query,
|
|
66
|
-
queryMatch,
|
|
67
67
|
registerRelationSchema,
|
|
68
68
|
resetRelationSchemas_TEST_ONLY
|
|
69
|
-
} from "../shared/chunk-
|
|
69
|
+
} from "../shared/chunk-1jgws7rs.js";
|
|
70
70
|
import"../shared/chunk-jrtrk5z4.js";
|
|
71
71
|
import {
|
|
72
72
|
ThemeProvider,
|
|
@@ -83,30 +83,33 @@ import {
|
|
|
83
83
|
resolveChildren,
|
|
84
84
|
s,
|
|
85
85
|
variants
|
|
86
|
-
} from "../shared/chunk-
|
|
86
|
+
} from "../shared/chunk-j1a7t906.js";
|
|
87
87
|
import {
|
|
88
|
+
RENDER_NODE_BRAND,
|
|
88
89
|
__append,
|
|
89
90
|
__element,
|
|
90
91
|
__enterChildren,
|
|
91
92
|
__exitChildren,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
import"../shared/chunk-prj7nm08.js";
|
|
95
|
-
import {
|
|
96
|
-
RENDER_NODE_BRAND,
|
|
93
|
+
__insert,
|
|
94
|
+
__staticText,
|
|
97
95
|
createDOMAdapter,
|
|
98
96
|
getAdapter,
|
|
99
97
|
isRenderNode,
|
|
100
98
|
setAdapter
|
|
101
|
-
} from "../shared/chunk-
|
|
99
|
+
} from "../shared/chunk-djvarb8r.js";
|
|
100
|
+
import"../shared/chunk-h1fsr8kv.js";
|
|
102
101
|
import {
|
|
103
102
|
RouterContext,
|
|
104
103
|
useParams,
|
|
105
104
|
useRouter
|
|
106
|
-
} from "../shared/chunk-
|
|
105
|
+
} from "../shared/chunk-7nr2ebrf.js";
|
|
106
|
+
import {
|
|
107
|
+
invalidate,
|
|
108
|
+
invalidateTenantQueries
|
|
109
|
+
} from "../shared/chunk-09ntccdx.js";
|
|
107
110
|
import {
|
|
108
111
|
isBrowser
|
|
109
|
-
} from "../shared/chunk-
|
|
112
|
+
} from "../shared/chunk-xs5s8gqe.js";
|
|
110
113
|
import {
|
|
111
114
|
DisposalScopeError,
|
|
112
115
|
_tryOnCleanup,
|
|
@@ -122,6 +125,7 @@ import {
|
|
|
122
125
|
getContextScope,
|
|
123
126
|
getIsHydrating,
|
|
124
127
|
getSSRContext,
|
|
128
|
+
onCleanup,
|
|
125
129
|
popScope,
|
|
126
130
|
pushScope,
|
|
127
131
|
runCleanups,
|
|
@@ -130,66 +134,62 @@ import {
|
|
|
130
134
|
startHydration,
|
|
131
135
|
untrack,
|
|
132
136
|
useContext
|
|
133
|
-
} from "../shared/chunk-
|
|
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
|
-
}
|
|
137
|
+
} from "../shared/chunk-ppr06jgn.js";
|
|
138
|
+
// src/component/default-error-fallback.ts
|
|
139
|
+
function DefaultErrorFallback({ error, retry }) {
|
|
140
|
+
const container = document.createElement("div");
|
|
141
|
+
container.setAttribute("data-testid", "error-fallback");
|
|
142
|
+
Object.assign(container.style, {
|
|
143
|
+
display: "flex",
|
|
144
|
+
flexDirection: "column",
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
justifyContent: "center",
|
|
147
|
+
padding: "2rem",
|
|
148
|
+
textAlign: "center"
|
|
149
|
+
});
|
|
150
|
+
const heading = document.createElement("h2");
|
|
151
|
+
heading.textContent = "Something went wrong";
|
|
152
|
+
Object.assign(heading.style, {
|
|
153
|
+
fontSize: "1.25rem",
|
|
154
|
+
fontWeight: "600",
|
|
155
|
+
marginBottom: "0.5rem",
|
|
156
|
+
color: "inherit"
|
|
157
|
+
});
|
|
158
|
+
const message = document.createElement("p");
|
|
159
|
+
message.textContent = error.message;
|
|
160
|
+
Object.assign(message.style, {
|
|
161
|
+
fontSize: "0.875rem",
|
|
162
|
+
opacity: "0.7",
|
|
163
|
+
marginBottom: "1rem",
|
|
164
|
+
maxWidth: "24rem"
|
|
165
|
+
});
|
|
166
|
+
const button = document.createElement("button");
|
|
167
|
+
button.type = "button";
|
|
168
|
+
button.setAttribute("data-testid", "error-retry");
|
|
169
|
+
button.textContent = "Try again";
|
|
170
|
+
Object.assign(button.style, {
|
|
171
|
+
padding: "0.5rem 1rem",
|
|
172
|
+
borderRadius: "0.375rem",
|
|
173
|
+
border: "1px solid currentColor",
|
|
174
|
+
background: "transparent",
|
|
175
|
+
cursor: "pointer",
|
|
176
|
+
fontSize: "0.875rem"
|
|
177
|
+
});
|
|
178
|
+
button.addEventListener("click", retry);
|
|
179
|
+
container.appendChild(heading);
|
|
180
|
+
container.appendChild(message);
|
|
181
|
+
container.appendChild(button);
|
|
182
|
+
return container;
|
|
190
183
|
}
|
|
191
184
|
// src/component/foreign.ts
|
|
192
|
-
function Foreign({
|
|
185
|
+
function Foreign({
|
|
186
|
+
tag = "div",
|
|
187
|
+
onReady,
|
|
188
|
+
html,
|
|
189
|
+
id,
|
|
190
|
+
className,
|
|
191
|
+
style
|
|
192
|
+
}) {
|
|
193
193
|
const el = __element(tag);
|
|
194
194
|
if (id)
|
|
195
195
|
el.id = id;
|
|
@@ -197,193 +197,14 @@ function Foreign({ tag = "div", onReady, id, className, style }) {
|
|
|
197
197
|
el.setAttribute("class", className);
|
|
198
198
|
if (style)
|
|
199
199
|
Object.assign(el.style, style);
|
|
200
|
+
if (html && getSSRContext()) {
|
|
201
|
+
el.innerHTML = html;
|
|
202
|
+
}
|
|
200
203
|
if (onReady && !getSSRContext()) {
|
|
201
204
|
onMount(() => onReady(el));
|
|
202
205
|
}
|
|
203
206
|
return el;
|
|
204
207
|
}
|
|
205
|
-
// src/dom/list-transition.ts
|
|
206
|
-
function createItemProxy(itemSignal) {
|
|
207
|
-
if (typeof itemSignal.peek() !== "object" || itemSignal.peek() == null) {
|
|
208
|
-
return itemSignal.peek();
|
|
209
|
-
}
|
|
210
|
-
return new Proxy({}, {
|
|
211
|
-
get(_target, prop, receiver) {
|
|
212
|
-
const current = itemSignal.value;
|
|
213
|
-
if (current == null)
|
|
214
|
-
return;
|
|
215
|
-
const value = Reflect.get(current, prop, receiver);
|
|
216
|
-
if (typeof value === "function") {
|
|
217
|
-
return value.bind(current);
|
|
218
|
-
}
|
|
219
|
-
return value;
|
|
220
|
-
},
|
|
221
|
-
has(_target, prop) {
|
|
222
|
-
const current = itemSignal.value;
|
|
223
|
-
if (current == null)
|
|
224
|
-
return false;
|
|
225
|
-
return Reflect.has(current, prop);
|
|
226
|
-
},
|
|
227
|
-
ownKeys() {
|
|
228
|
-
const current = itemSignal.value;
|
|
229
|
-
if (current == null)
|
|
230
|
-
return [];
|
|
231
|
-
return Reflect.ownKeys(current);
|
|
232
|
-
},
|
|
233
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
234
|
-
const current = itemSignal.value;
|
|
235
|
-
if (current == null)
|
|
236
|
-
return;
|
|
237
|
-
return Reflect.getOwnPropertyDescriptor(current, prop);
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
function listTransition(startMarker, endMarker, items, keyFn, renderFn) {
|
|
242
|
-
const getItems = typeof items === "function" ? items : () => items.value;
|
|
243
|
-
const nodeMap = new Map;
|
|
244
|
-
const scopeMap = new Map;
|
|
245
|
-
const itemSignalMap = new Map;
|
|
246
|
-
const exitingNodes = new Set;
|
|
247
|
-
const exitingKeyMap = new Map;
|
|
248
|
-
const keyGeneration = new Map;
|
|
249
|
-
let isFirstRun = true;
|
|
250
|
-
const outerScope = pushScope();
|
|
251
|
-
try {
|
|
252
|
-
domEffect(() => {
|
|
253
|
-
const newItems = getItems() ?? [];
|
|
254
|
-
const newKeySet = new Set(newItems.map((item, i) => keyFn(item, i)));
|
|
255
|
-
if (isFirstRun) {
|
|
256
|
-
isFirstRun = false;
|
|
257
|
-
for (const [i, item] of newItems.entries()) {
|
|
258
|
-
const key = keyFn(item, i);
|
|
259
|
-
const itemSig = signal(item);
|
|
260
|
-
const proxy = createItemProxy(itemSig);
|
|
261
|
-
const scope = pushScope();
|
|
262
|
-
const node = renderFn(proxy);
|
|
263
|
-
popScope();
|
|
264
|
-
nodeMap.set(key, node);
|
|
265
|
-
scopeMap.set(key, scope);
|
|
266
|
-
itemSignalMap.set(key, itemSig);
|
|
267
|
-
endMarker.parentNode?.insertBefore(node, endMarker);
|
|
268
|
-
}
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
for (const [key, node] of nodeMap) {
|
|
272
|
-
if (!newKeySet.has(key)) {
|
|
273
|
-
const scope = scopeMap.get(key);
|
|
274
|
-
if (scope) {
|
|
275
|
-
runCleanups(scope);
|
|
276
|
-
scopeMap.delete(key);
|
|
277
|
-
}
|
|
278
|
-
nodeMap.delete(key);
|
|
279
|
-
itemSignalMap.delete(key);
|
|
280
|
-
const gen = (keyGeneration.get(key) ?? 0) + 1;
|
|
281
|
-
keyGeneration.set(key, gen);
|
|
282
|
-
exitingNodes.add(node);
|
|
283
|
-
exitingKeyMap.set(key, node);
|
|
284
|
-
if (node instanceof Element) {
|
|
285
|
-
node.setAttribute("data-presence", "exit");
|
|
286
|
-
onAnimationsComplete(node, () => {
|
|
287
|
-
if (keyGeneration.get(key) === gen) {
|
|
288
|
-
node.parentNode?.removeChild(node);
|
|
289
|
-
exitingNodes.delete(node);
|
|
290
|
-
exitingKeyMap.delete(key);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
} else {
|
|
294
|
-
node.parentNode?.removeChild(node);
|
|
295
|
-
exitingNodes.delete(node);
|
|
296
|
-
exitingKeyMap.delete(key);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
const desiredNodes = [];
|
|
301
|
-
const enterNodes = [];
|
|
302
|
-
for (const [i, item] of newItems.entries()) {
|
|
303
|
-
const key = keyFn(item, i);
|
|
304
|
-
let node = nodeMap.get(key);
|
|
305
|
-
if (!node) {
|
|
306
|
-
const oldExiting = exitingKeyMap.get(key);
|
|
307
|
-
if (oldExiting) {
|
|
308
|
-
oldExiting.parentNode?.removeChild(oldExiting);
|
|
309
|
-
exitingNodes.delete(oldExiting);
|
|
310
|
-
exitingKeyMap.delete(key);
|
|
311
|
-
}
|
|
312
|
-
const gen = (keyGeneration.get(key) ?? 0) + 1;
|
|
313
|
-
keyGeneration.set(key, gen);
|
|
314
|
-
const itemSig = signal(item);
|
|
315
|
-
const proxy = createItemProxy(itemSig);
|
|
316
|
-
const scope = pushScope();
|
|
317
|
-
node = renderFn(proxy);
|
|
318
|
-
popScope();
|
|
319
|
-
nodeMap.set(key, node);
|
|
320
|
-
scopeMap.set(key, scope);
|
|
321
|
-
itemSignalMap.set(key, itemSig);
|
|
322
|
-
if (node instanceof Element)
|
|
323
|
-
node.setAttribute("data-presence", "enter");
|
|
324
|
-
enterNodes.push({ node, key });
|
|
325
|
-
} else {
|
|
326
|
-
const itemSig = itemSignalMap.get(key);
|
|
327
|
-
if (itemSig) {
|
|
328
|
-
itemSig.value = item;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
desiredNodes.push(node);
|
|
332
|
-
}
|
|
333
|
-
const parent = startMarker.parentNode;
|
|
334
|
-
if (parent) {
|
|
335
|
-
let cursor = startMarker.nextSibling;
|
|
336
|
-
for (const desired of desiredNodes) {
|
|
337
|
-
while (cursor && cursor !== endMarker && exitingNodes.has(cursor)) {
|
|
338
|
-
cursor = cursor.nextSibling;
|
|
339
|
-
}
|
|
340
|
-
if (cursor === desired) {
|
|
341
|
-
cursor = cursor.nextSibling;
|
|
342
|
-
} else {
|
|
343
|
-
parent.insertBefore(desired, cursor);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
for (const { node: enterNode, key } of enterNodes) {
|
|
348
|
-
if (!(enterNode instanceof Element))
|
|
349
|
-
continue;
|
|
350
|
-
onAnimationsComplete(enterNode, () => {
|
|
351
|
-
if (nodeMap.get(key) === enterNode) {
|
|
352
|
-
enterNode.removeAttribute("data-presence");
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
} finally {
|
|
358
|
-
popScope();
|
|
359
|
-
}
|
|
360
|
-
const dispose = () => {
|
|
361
|
-
for (const scope of scopeMap.values()) {
|
|
362
|
-
runCleanups(scope);
|
|
363
|
-
}
|
|
364
|
-
scopeMap.clear();
|
|
365
|
-
for (const node of exitingNodes) {
|
|
366
|
-
node.parentNode?.removeChild(node);
|
|
367
|
-
}
|
|
368
|
-
exitingNodes.clear();
|
|
369
|
-
exitingKeyMap.clear();
|
|
370
|
-
runCleanups(outerScope);
|
|
371
|
-
};
|
|
372
|
-
_tryOnCleanup(dispose);
|
|
373
|
-
return dispose;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// src/component/list-transition.ts
|
|
377
|
-
function ListTransition(props) {
|
|
378
|
-
const startMarker = document.createComment("lt-start");
|
|
379
|
-
const endMarker = document.createComment("lt-end");
|
|
380
|
-
const fragment = document.createDocumentFragment();
|
|
381
|
-
fragment.appendChild(startMarker);
|
|
382
|
-
fragment.appendChild(endMarker);
|
|
383
|
-
const dispose = listTransition(startMarker, endMarker, () => props.each, props.keyFn, props.children);
|
|
384
|
-
_tryOnCleanup(dispose);
|
|
385
|
-
return Object.assign(fragment, { dispose });
|
|
386
|
-
}
|
|
387
208
|
// src/component/presence.ts
|
|
388
209
|
function Presence(props) {
|
|
389
210
|
const anchor = document.createComment("presence");
|
|
@@ -461,7 +282,7 @@ function ref() {
|
|
|
461
282
|
function isPromise(value) {
|
|
462
283
|
return value != null && typeof value === "object" && typeof value.then === "function";
|
|
463
284
|
}
|
|
464
|
-
function
|
|
285
|
+
function toError(value) {
|
|
465
286
|
if (value instanceof Error) {
|
|
466
287
|
return value;
|
|
467
288
|
}
|
|
@@ -493,17 +314,26 @@ function Suspense(props) {
|
|
|
493
314
|
}
|
|
494
315
|
} catch (retryError) {
|
|
495
316
|
if (!isPromise(retryError)) {
|
|
496
|
-
propagateError(
|
|
317
|
+
propagateError(toError(retryError), placeholder, errorHandler);
|
|
497
318
|
}
|
|
498
319
|
}
|
|
499
320
|
}).catch((error) => {
|
|
500
|
-
propagateError(
|
|
321
|
+
propagateError(toError(error), placeholder, errorHandler);
|
|
501
322
|
});
|
|
502
323
|
return placeholder;
|
|
503
324
|
}
|
|
504
325
|
}
|
|
505
326
|
// src/dialog/dialog-stack.ts
|
|
506
327
|
var DialogStackContext = createContext(undefined, "@vertz/ui::DialogStackContext");
|
|
328
|
+
var DialogHandleContext = createContext(undefined, "@vertz/ui::DialogHandleContext");
|
|
329
|
+
var DialogIdContext = createContext(undefined, "@vertz/ui::DialogIdContext");
|
|
330
|
+
function useDialog() {
|
|
331
|
+
const handle = useContext(DialogHandleContext);
|
|
332
|
+
if (!handle) {
|
|
333
|
+
throw new Error("useDialog() must be called within a dialog opened via DialogStack");
|
|
334
|
+
}
|
|
335
|
+
return handle;
|
|
336
|
+
}
|
|
507
337
|
function useDialogStack() {
|
|
508
338
|
const stack = useContext(DialogStackContext);
|
|
509
339
|
if (!stack) {
|
|
@@ -511,10 +341,13 @@ function useDialogStack() {
|
|
|
511
341
|
}
|
|
512
342
|
const capturedScope = getContextScope();
|
|
513
343
|
return {
|
|
514
|
-
open(component, props) {
|
|
515
|
-
return stack.openWithScope(component, props, capturedScope);
|
|
344
|
+
open(component, props, options) {
|
|
345
|
+
return stack.openWithScope(component, props, capturedScope, options);
|
|
516
346
|
},
|
|
517
347
|
openWithScope: stack.openWithScope,
|
|
348
|
+
confirm(opts) {
|
|
349
|
+
return stack.confirm(opts);
|
|
350
|
+
},
|
|
518
351
|
get size() {
|
|
519
352
|
return stack.size;
|
|
520
353
|
},
|
|
@@ -523,25 +356,84 @@ function useDialogStack() {
|
|
|
523
356
|
}
|
|
524
357
|
};
|
|
525
358
|
}
|
|
359
|
+
function DialogStackProvider({ children: children2 }) {
|
|
360
|
+
const container = __element("div", { "data-dialog-container": "" });
|
|
361
|
+
const stack = createDialogStack(container);
|
|
362
|
+
return DialogStackContext.Provider({
|
|
363
|
+
value: stack,
|
|
364
|
+
children: () => {
|
|
365
|
+
const frag = document.createDocumentFragment();
|
|
366
|
+
__insert(frag, children2);
|
|
367
|
+
frag.appendChild(container);
|
|
368
|
+
return frag;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function ConfirmDialogComponent({
|
|
373
|
+
title,
|
|
374
|
+
description,
|
|
375
|
+
confirm: confirmLabel = "Confirm",
|
|
376
|
+
cancel: cancelLabel = "Cancel",
|
|
377
|
+
intent = "primary",
|
|
378
|
+
dialog
|
|
379
|
+
}) {
|
|
380
|
+
const frag = document.createDocumentFragment();
|
|
381
|
+
const titleEl = document.createElement("h2");
|
|
382
|
+
titleEl.setAttribute("data-part", "title");
|
|
383
|
+
titleEl.textContent = title;
|
|
384
|
+
frag.appendChild(titleEl);
|
|
385
|
+
if (description) {
|
|
386
|
+
const descEl = document.createElement("p");
|
|
387
|
+
descEl.setAttribute("data-part", "description");
|
|
388
|
+
descEl.textContent = description;
|
|
389
|
+
frag.appendChild(descEl);
|
|
390
|
+
}
|
|
391
|
+
const footer = document.createElement("div");
|
|
392
|
+
footer.setAttribute("data-part", "footer");
|
|
393
|
+
const cancelBtn = document.createElement("button");
|
|
394
|
+
cancelBtn.setAttribute("type", "button");
|
|
395
|
+
cancelBtn.setAttribute("data-part", "confirm-cancel");
|
|
396
|
+
cancelBtn.textContent = cancelLabel;
|
|
397
|
+
cancelBtn.addEventListener("click", () => dialog.close(false));
|
|
398
|
+
const confirmBtn = document.createElement("button");
|
|
399
|
+
confirmBtn.setAttribute("type", "button");
|
|
400
|
+
confirmBtn.setAttribute("data-part", "confirm-action");
|
|
401
|
+
confirmBtn.setAttribute("data-intent", intent);
|
|
402
|
+
confirmBtn.textContent = confirmLabel;
|
|
403
|
+
confirmBtn.addEventListener("click", () => dialog.close(true));
|
|
404
|
+
footer.appendChild(cancelBtn);
|
|
405
|
+
footer.appendChild(confirmBtn);
|
|
406
|
+
frag.appendChild(footer);
|
|
407
|
+
return frag;
|
|
408
|
+
}
|
|
526
409
|
function createDialogStack(container) {
|
|
527
410
|
const entries = [];
|
|
528
411
|
let nextId = 0;
|
|
529
|
-
function open(component, props, capturedScope) {
|
|
412
|
+
function open(component, props, capturedScope, options) {
|
|
530
413
|
return new Promise((resolve) => {
|
|
531
414
|
if (entries.length > 0) {
|
|
532
|
-
entries[entries.length - 1].
|
|
415
|
+
entries[entries.length - 1].dialogEl.setAttribute("data-state", "background");
|
|
533
416
|
}
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
417
|
+
const dialogId = `dlg-${nextId}`;
|
|
418
|
+
const dialogEl = document.createElement("dialog");
|
|
419
|
+
dialogEl.setAttribute("data-dialog-wrapper", "");
|
|
420
|
+
dialogEl.setAttribute("data-state", "open");
|
|
421
|
+
dialogEl.setAttribute("data-dialog-depth", "0");
|
|
422
|
+
const panel = document.createElement("div");
|
|
423
|
+
panel.setAttribute("data-part", "panel");
|
|
424
|
+
panel.setAttribute("role", "dialog");
|
|
425
|
+
panel.setAttribute("aria-modal", "true");
|
|
426
|
+
panel.setAttribute("aria-labelledby", `${dialogId}-title`);
|
|
427
|
+
panel.setAttribute("aria-describedby", `${dialogId}-desc`);
|
|
428
|
+
dialogEl.appendChild(panel);
|
|
538
429
|
const entry = {
|
|
539
430
|
id: nextId++,
|
|
540
|
-
|
|
431
|
+
dialogEl,
|
|
432
|
+
panel,
|
|
541
433
|
node: null,
|
|
542
434
|
resolve,
|
|
543
435
|
cleanups: [],
|
|
544
|
-
dismissible:
|
|
436
|
+
dismissible: options?.dismissible !== false,
|
|
545
437
|
settled: false
|
|
546
438
|
};
|
|
547
439
|
const prevScope = setContextScope(capturedScope ?? null);
|
|
@@ -551,60 +443,93 @@ function createDialogStack(container) {
|
|
|
551
443
|
closeEntry(entry, args[0]);
|
|
552
444
|
}
|
|
553
445
|
};
|
|
554
|
-
|
|
446
|
+
DialogHandleContext.Provider(handle, () => {
|
|
447
|
+
DialogIdContext.Provider(dialogId, () => {
|
|
448
|
+
entry.node = component({ ...props, dialog: handle });
|
|
449
|
+
});
|
|
450
|
+
});
|
|
555
451
|
entry.cleanups = [...scope];
|
|
556
452
|
popScope();
|
|
557
453
|
setContextScope(prevScope);
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
454
|
+
dialogEl.addEventListener("cancel", (e) => {
|
|
455
|
+
e.preventDefault();
|
|
456
|
+
if (entry.dismissible && entries[entries.length - 1] === entry) {
|
|
457
|
+
dismissEntry(entry);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
dialogEl.addEventListener("click", (e) => {
|
|
461
|
+
if (!entry.dismissible)
|
|
462
|
+
return;
|
|
463
|
+
const rect = panel.getBoundingClientRect();
|
|
464
|
+
const isOutside = e.clientX < rect.left || e.clientX > rect.right || e.clientY < rect.top || e.clientY > rect.bottom;
|
|
465
|
+
if (isOutside) {
|
|
466
|
+
dismissEntry(entry);
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
panel.appendChild(entry.node);
|
|
470
|
+
const titleTarget = panel.querySelector('[data-part="title"]');
|
|
471
|
+
if (titleTarget && !titleTarget.id)
|
|
472
|
+
titleTarget.id = `${dialogId}-title`;
|
|
473
|
+
const descTarget = panel.querySelector('[data-part="description"]');
|
|
474
|
+
if (descTarget && !descTarget.id)
|
|
475
|
+
descTarget.id = `${dialogId}-desc`;
|
|
476
|
+
container.appendChild(dialogEl);
|
|
569
477
|
entries.push(entry);
|
|
570
478
|
updateDepthAttributes();
|
|
479
|
+
dialogEl.showModal();
|
|
571
480
|
});
|
|
572
481
|
}
|
|
573
|
-
function
|
|
482
|
+
function removeEntry(entry, resolution) {
|
|
574
483
|
if (entry.settled)
|
|
575
484
|
return;
|
|
576
485
|
const idx = entries.indexOf(entry);
|
|
577
486
|
if (idx === -1)
|
|
578
487
|
return;
|
|
579
488
|
entry.settled = true;
|
|
580
|
-
entry.
|
|
581
|
-
|
|
489
|
+
entry.dialogEl.setAttribute("data-state", "closed");
|
|
490
|
+
entry.dialogEl.setAttribute("inert", "");
|
|
491
|
+
onAnimationsComplete(entry.dialogEl, () => {
|
|
582
492
|
runCleanups(entry.cleanups);
|
|
583
|
-
if (entry.
|
|
584
|
-
|
|
493
|
+
if (entry.dialogEl.open) {
|
|
494
|
+
entry.dialogEl.close();
|
|
495
|
+
}
|
|
496
|
+
if (entry.dialogEl.parentNode === container) {
|
|
497
|
+
container.removeChild(entry.dialogEl);
|
|
585
498
|
}
|
|
586
499
|
const entryIdx = entries.indexOf(entry);
|
|
587
500
|
if (entryIdx !== -1) {
|
|
588
501
|
entries.splice(entryIdx, 1);
|
|
589
502
|
}
|
|
590
503
|
if (entries.length > 0) {
|
|
591
|
-
entries[entries.length - 1].
|
|
504
|
+
entries[entries.length - 1].dialogEl.setAttribute("data-state", "open");
|
|
592
505
|
}
|
|
593
506
|
updateDepthAttributes();
|
|
594
|
-
entry.resolve(
|
|
507
|
+
entry.resolve(resolution);
|
|
595
508
|
});
|
|
596
509
|
}
|
|
510
|
+
function closeEntry(entry, result) {
|
|
511
|
+
removeEntry(entry, { ok: true, data: result });
|
|
512
|
+
}
|
|
513
|
+
function dismissEntry(entry) {
|
|
514
|
+
removeEntry(entry, { ok: false });
|
|
515
|
+
}
|
|
597
516
|
function updateDepthAttributes() {
|
|
598
517
|
for (let i = 0;i < entries.length; i++) {
|
|
599
|
-
entries[i].
|
|
518
|
+
entries[i].dialogEl.setAttribute("data-dialog-depth", String(entries.length - 1 - i));
|
|
600
519
|
}
|
|
601
520
|
}
|
|
602
521
|
return {
|
|
603
|
-
open(component, props) {
|
|
604
|
-
return open(component, props);
|
|
522
|
+
open(component, props, options) {
|
|
523
|
+
return open(component, props, undefined, options);
|
|
524
|
+
},
|
|
525
|
+
openWithScope(component, props, scope, options) {
|
|
526
|
+
return open(component, props, scope, options);
|
|
605
527
|
},
|
|
606
|
-
|
|
607
|
-
|
|
528
|
+
async confirm(opts) {
|
|
529
|
+
const result = await open(ConfirmDialogComponent, opts, undefined, {
|
|
530
|
+
dismissible: opts.dismissible ?? false
|
|
531
|
+
});
|
|
532
|
+
return result.ok ? result.data : false;
|
|
608
533
|
},
|
|
609
534
|
get size() {
|
|
610
535
|
return entries.length;
|
|
@@ -615,30 +540,118 @@ function createDialogStack(container) {
|
|
|
615
540
|
}
|
|
616
541
|
}
|
|
617
542
|
};
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
543
|
+
}
|
|
544
|
+
// src/format/relative-time.ts
|
|
545
|
+
function toDate(date) {
|
|
546
|
+
if (date instanceof Date)
|
|
547
|
+
return date;
|
|
548
|
+
if (typeof date === "number")
|
|
549
|
+
return new Date(date);
|
|
550
|
+
return new Date(date);
|
|
551
|
+
}
|
|
552
|
+
var rtfCache = new Map;
|
|
553
|
+
function getFormatter(locale, numeric = "auto") {
|
|
554
|
+
const key = `${locale ?? ""}:${numeric}`;
|
|
555
|
+
let rtf = rtfCache.get(key);
|
|
556
|
+
if (!rtf) {
|
|
557
|
+
rtf = new Intl.RelativeTimeFormat(locale, { numeric, style: "long" });
|
|
558
|
+
rtfCache.set(key, rtf);
|
|
559
|
+
}
|
|
560
|
+
return rtf;
|
|
561
|
+
}
|
|
562
|
+
function formatRelativeTime(date, options) {
|
|
563
|
+
const now = options?.now ?? new Date;
|
|
564
|
+
const d = toDate(date);
|
|
565
|
+
if (Number.isNaN(d.getTime())) {
|
|
566
|
+
throw new Error(`formatRelativeTime: invalid date input: ${String(date)}`);
|
|
567
|
+
}
|
|
568
|
+
const diffMs = now.getTime() - d.getTime();
|
|
569
|
+
const diffSec = Math.floor(Math.abs(diffMs) / 1000);
|
|
570
|
+
const locale = options?.locale;
|
|
571
|
+
const numeric = options?.numeric ?? "auto";
|
|
572
|
+
const rtf = getFormatter(locale, numeric);
|
|
573
|
+
const sign = diffMs >= 0 ? -1 : 1;
|
|
574
|
+
if (diffSec < 10) {
|
|
575
|
+
return rtf.format(0, "second");
|
|
641
576
|
}
|
|
577
|
+
if (diffSec < 60) {
|
|
578
|
+
return rtf.format(sign * diffSec, "second");
|
|
579
|
+
}
|
|
580
|
+
const diffMin = Math.floor(diffSec / 60);
|
|
581
|
+
if (diffMin < 60) {
|
|
582
|
+
return rtf.format(sign * diffMin, "minute");
|
|
583
|
+
}
|
|
584
|
+
const diffHours = Math.floor(diffMin / 60);
|
|
585
|
+
if (diffHours < 24) {
|
|
586
|
+
return rtf.format(sign * diffHours, "hour");
|
|
587
|
+
}
|
|
588
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
589
|
+
if (diffDays < 7) {
|
|
590
|
+
return rtf.format(sign * diffDays, "day");
|
|
591
|
+
}
|
|
592
|
+
if (diffDays < 30) {
|
|
593
|
+
const diffWeeks = Math.floor(diffDays / 7);
|
|
594
|
+
return rtf.format(sign * diffWeeks, "week");
|
|
595
|
+
}
|
|
596
|
+
if (diffDays < 365) {
|
|
597
|
+
const diffMonths = Math.floor(diffDays / 30);
|
|
598
|
+
return rtf.format(sign * diffMonths, "month");
|
|
599
|
+
}
|
|
600
|
+
const diffYears = Math.floor(diffDays / 365);
|
|
601
|
+
return rtf.format(sign * diffYears, "year");
|
|
602
|
+
}
|
|
603
|
+
// src/format/relative-time-component.ts
|
|
604
|
+
function getAdaptiveInterval(date) {
|
|
605
|
+
const d = toDate(date);
|
|
606
|
+
const elapsedMs = Math.abs(Date.now() - d.getTime());
|
|
607
|
+
const elapsedSec = elapsedMs / 1000;
|
|
608
|
+
if (elapsedSec < 60)
|
|
609
|
+
return 1e4;
|
|
610
|
+
if (elapsedSec < 3600)
|
|
611
|
+
return 60000;
|
|
612
|
+
if (elapsedSec < 86400)
|
|
613
|
+
return 3600000;
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
function RelativeTime({
|
|
617
|
+
date,
|
|
618
|
+
locale,
|
|
619
|
+
numeric,
|
|
620
|
+
updateInterval,
|
|
621
|
+
className,
|
|
622
|
+
title
|
|
623
|
+
}) {
|
|
624
|
+
const d = toDate(date);
|
|
625
|
+
const isoString = d.toISOString();
|
|
626
|
+
const opts = { locale, numeric };
|
|
627
|
+
const el = document.createElement("time");
|
|
628
|
+
el.setAttribute("datetime", isoString);
|
|
629
|
+
el.textContent = formatRelativeTime(date, opts);
|
|
630
|
+
if (title !== false) {
|
|
631
|
+
el.title = typeof title === "string" ? title : new Intl.DateTimeFormat(locale, {
|
|
632
|
+
dateStyle: "long",
|
|
633
|
+
timeStyle: "medium"
|
|
634
|
+
}).format(d);
|
|
635
|
+
}
|
|
636
|
+
if (className) {
|
|
637
|
+
el.className = className;
|
|
638
|
+
}
|
|
639
|
+
onMount(() => {
|
|
640
|
+
let timerId;
|
|
641
|
+
function tick() {
|
|
642
|
+
el.textContent = formatRelativeTime(date, opts);
|
|
643
|
+
const interval = updateInterval ?? getAdaptiveInterval(date);
|
|
644
|
+
if (interval !== null) {
|
|
645
|
+
timerId = setTimeout(tick, interval);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
const initialInterval = updateInterval ?? getAdaptiveInterval(date);
|
|
649
|
+
if (initialInterval !== null) {
|
|
650
|
+
timerId = setTimeout(tick, initialInterval);
|
|
651
|
+
}
|
|
652
|
+
return () => clearTimeout(timerId);
|
|
653
|
+
});
|
|
654
|
+
return el;
|
|
642
655
|
}
|
|
643
656
|
// src/image/config.ts
|
|
644
657
|
var optimizerBaseUrl = null;
|
|
@@ -895,6 +908,7 @@ export {
|
|
|
895
908
|
useRouter,
|
|
896
909
|
useParams,
|
|
897
910
|
useDialogStack,
|
|
911
|
+
useDialog,
|
|
898
912
|
useContext,
|
|
899
913
|
untrack,
|
|
900
914
|
slideOutToTop,
|
|
@@ -914,17 +928,18 @@ export {
|
|
|
914
928
|
registerTheme,
|
|
915
929
|
registerRelationSchema,
|
|
916
930
|
ref,
|
|
917
|
-
queryMatch,
|
|
918
931
|
query,
|
|
919
932
|
parseSearchParams,
|
|
920
933
|
palettes,
|
|
921
934
|
onMount,
|
|
935
|
+
onCleanup,
|
|
922
936
|
onAnimationsComplete,
|
|
923
937
|
mount,
|
|
924
938
|
keyframes,
|
|
925
939
|
isRenderNode,
|
|
926
940
|
isQueryDescriptor,
|
|
927
941
|
isBrowser,
|
|
942
|
+
invalidateTenantQueries,
|
|
928
943
|
invalidate,
|
|
929
944
|
injectCSS,
|
|
930
945
|
hydrateIslands,
|
|
@@ -935,6 +950,7 @@ export {
|
|
|
935
950
|
getInjectedCSS,
|
|
936
951
|
getEntityStore,
|
|
937
952
|
getAdapter,
|
|
953
|
+
formatRelativeTime,
|
|
938
954
|
formDataToObject,
|
|
939
955
|
form,
|
|
940
956
|
font,
|
|
@@ -969,12 +985,13 @@ export {
|
|
|
969
985
|
Suspense,
|
|
970
986
|
RouterView,
|
|
971
987
|
RouterContext,
|
|
988
|
+
RelativeTime,
|
|
972
989
|
RENDER_NODE_BRAND,
|
|
973
990
|
QueryEnvelopeStore,
|
|
974
991
|
Presence,
|
|
975
992
|
OutletContext,
|
|
976
993
|
Outlet,
|
|
977
|
-
|
|
994
|
+
ListAnimationContext,
|
|
978
995
|
Link,
|
|
979
996
|
Island,
|
|
980
997
|
Image,
|
|
@@ -983,7 +1000,11 @@ export {
|
|
|
983
1000
|
ErrorBoundary,
|
|
984
1001
|
EntityStore,
|
|
985
1002
|
DisposalScopeError,
|
|
1003
|
+
DialogStackProvider,
|
|
986
1004
|
DialogStackContext,
|
|
1005
|
+
DialogIdContext,
|
|
1006
|
+
DialogHandleContext,
|
|
1007
|
+
DefaultErrorFallback,
|
|
987
1008
|
ANIMATION_EASING,
|
|
988
1009
|
ANIMATION_DURATION
|
|
989
1010
|
};
|