@photon-ai/pho-ui 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1117 +0,0 @@
1
- "use client";
2
- import { t as u } from "./cn-ChIgwEl3.js";
3
- import { n as ve } from "./link-provider-9TFNyDqO.js";
4
- import { a as ye, o as be } from "./button-DNNs5RsT.js";
5
- import { t as Oe } from "./createReactComponent-BqCmnqfX.js";
6
- import { t as Le } from "./error-Crs-wqMC.js";
7
- import { t as W } from "./IconChevronLeft-CSWMKQ4C.js";
8
- import { t as Pe } from "./toast-DoXaRPIZ.js";
9
- import { t as Be } from "./animated-height-C2eQstGy.js";
10
- import "./scroll-area-Bu7egArU.js";
11
- import { t as Me } from "./form-AiHbbw4m.js";
12
- import { i as H } from "./menu-BQeprfxB.js";
13
- import { Children as ae, Fragment as De, createContext as j, isValidElement as Fe, useContext as R, useEffect as P, useId as He, useLayoutEffect as Y, useMemo as $, useRef as A, useState as v, useSyncExternalStore as Ge } from "react";
14
- import { Fragment as Ve, jsx as a, jsxs as y } from "react/jsx-runtime";
15
- import { AnimatePresence as K, motion as b, useIsPresent as ze, useReducedMotion as k } from "motion/react";
16
- var $e = [["path", {
17
- d: "M9 6l6 6l-6 6",
18
- key: "svg-0"
19
- }]], je = Oe("outline", "chevron-right", "ChevronRight", $e), re = "rounded-base border border-pho-secondary bg-pho-primary", U = "divide-y divide-pho-secondary [&>:has(+[data-basic-page-alert])]:border-b-0", Ke = `${re} ${U}`, de = "flex min-w-0 flex-col gap-3 rounded-base border border-pho-secondary bg-pho-page p-5", Xe = "flex min-h-[4.25rem] min-w-0 flex-col gap-3 px-5 py-4 sm:flex-row sm:items-center sm:justify-between sm:gap-6", We = "flex flex-col gap-3 px-5 py-4", Ye = "-mx-5 -mb-4 flex items-center rounded-b-[calc(0.75rem-1px)] bg-pho-secondary py-1 pr-3 pl-5", Ue = "-mx-2 -mt-1.5 flex items-center rounded-sm bg-pho-secondary px-2 py-0.5", C = {
20
- type: "spring",
21
- stiffness: 400,
22
- damping: 40
23
- }, T = {
24
- duration: 0.25,
25
- ease: "easeOut"
26
- }, V = 12;
27
- function qe({ condense: e = !0, className: t, children: n, ...r }) {
28
- const s = R(Q)?.adopt ?? !1, [o, c] = v(null), [l, i] = v(null), d = $(() => ({
29
- setTitle: c,
30
- setTail: i
31
- }), []);
32
- return /* @__PURE__ */ y("div", {
33
- "data-basic-page-root": "",
34
- className: u("relative flex min-h-full w-full min-w-0 flex-col", t),
35
- ...r,
36
- children: [e && /* @__PURE__ */ a(Qe, {
37
- title: o,
38
- tail: l
39
- }), /* @__PURE__ */ a("div", {
40
- "data-basic-page-column": "",
41
- className: u("mx-auto flex w-full max-w-[44.5rem] min-w-0 flex-1 flex-col px-5 pt-12 pb-12 *:min-w-0", s ? "[&_[data-basic-page-back]]:hidden" : "has-[[data-basic-page-back]]:pt-16"),
42
- children: e ? /* @__PURE__ */ a(se.Provider, {
43
- value: d,
44
- children: n
45
- }) : n
46
- })]
47
- });
48
- }
49
- function Qe({ title: e, tail: t }) {
50
- const n = k(), [r, s] = v(!1), o = R(Q), c = He();
51
- P(() => {
52
- o?.store.set(c, {
53
- condensed: r,
54
- title: e?.label ?? null,
55
- back: t
56
- });
57
- }, [
58
- o,
59
- c,
60
- r,
61
- e,
62
- t
63
- ]), P(() => {
64
- if (o != null)
65
- return () => o.store.clear(c);
66
- }, [o, c]);
67
- const l = e?.el ?? null;
68
- return P(() => {
69
- if (l == null || typeof IntersectionObserver > "u") return;
70
- const i = new IntersectionObserver(([d]) => s(d != null && !d.isIntersecting), { root: ut(l) });
71
- return i.observe(l), () => i.disconnect();
72
- }, [l]), /* @__PURE__ */ a("div", {
73
- "data-basic-page-condense": "",
74
- className: "sticky top-0 z-20 h-0 overflow-visible",
75
- children: /* @__PURE__ */ a(K, { children: r && !(o?.adopt ?? !1) && /* @__PURE__ */ y(b.div, {
76
- initial: {
77
- opacity: 0,
78
- y: n ? 0 : -8
79
- },
80
- animate: {
81
- opacity: 1,
82
- y: 0
83
- },
84
- exit: {
85
- opacity: 0,
86
- y: n ? 0 : -8
87
- },
88
- transition: {
89
- ...oe,
90
- y: ct
91
- },
92
- className: "border-pho-secondary bg-pho-page/85 relative grid h-12 grid-cols-[1fr_minmax(0,auto)_1fr] items-center border-b px-3 backdrop-blur",
93
- children: [/* @__PURE__ */ a("div", {
94
- className: "flex min-w-0 items-center justify-start",
95
- children: t != null && /* @__PURE__ */ a(be, {
96
- variant: "ghost",
97
- size: "sm",
98
- href: t.href,
99
- onClick: t.onClick,
100
- prefix: /* @__PURE__ */ a("span", {
101
- className: "inline-flex [&>svg]:size-[1.125em] [&>svg]:shrink-0",
102
- children: /* @__PURE__ */ a(W, {})
103
- }),
104
- className: "min-w-max",
105
- children: t.label
106
- })
107
- }), /* @__PURE__ */ a("span", {
108
- className: "text-pho-primary block max-w-full min-w-0 truncate text-center text-base font-medium",
109
- children: e?.label
110
- })]
111
- }) })
112
- });
113
- }
114
- function Je(e) {
115
- return e.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
116
- }
117
- function Ze(e) {
118
- if (!(typeof e != "string" && typeof e != "number"))
119
- return Je(String(e)) || void 0;
120
- }
121
- function ie(e, t) {
122
- if (e !== "")
123
- return e ?? Ze(t);
124
- }
125
- var et = (e) => `basic-page-morph-${e}`, tt = { layout: C }, me = 10, fe = {
126
- delay: 0.2,
127
- duration: 0.12,
128
- ease: "easeOut"
129
- }, nt = {
130
- duration: 0.18,
131
- ease: "easeOut"
132
- }, at = -8, rt = {
133
- duration: 0.16,
134
- ease: "easeOut"
135
- }, it = {
136
- delay: 0.14,
137
- duration: 0.16,
138
- ease: "easeOut"
139
- }, xe = {
140
- duration: 0.12,
141
- ease: "easeOut"
142
- }, G = [];
143
- function st(e) {
144
- const t = A({ labels: e });
145
- t.current.labels = e, Y(() => {
146
- const n = t.current;
147
- return G.push(n), () => {
148
- G.splice(G.indexOf(n), 1);
149
- };
150
- }, []);
151
- }
152
- function Ne() {
153
- const [e] = v(() => {
154
- const t = G[G.length - 1];
155
- return t ? { labels: [...t.labels] } : null;
156
- });
157
- return e;
158
- }
159
- var se = j(null), te = {
160
- condensed: !1,
161
- title: null,
162
- back: null
163
- }, Q = j(null), ot = () => () => {
164
- }, pe = () => te;
165
- function lt({ adopt: e = !0, children: t }) {
166
- const [n] = v(() => {
167
- let s = te, o = null;
168
- const c = /* @__PURE__ */ new Set(), l = () => {
169
- for (const i of c) i();
170
- };
171
- return {
172
- get: () => s,
173
- set(i, d) {
174
- o = i, s = d, l();
175
- },
176
- clear(i) {
177
- o === i && (o = null, s = te, l());
178
- },
179
- subscribe(i) {
180
- return c.add(i), () => c.delete(i);
181
- }
182
- };
183
- }), r = $(() => ({
184
- store: n,
185
- adopt: e
186
- }), [n, e]);
187
- return /* @__PURE__ */ a(Q.Provider, {
188
- value: r,
189
- children: t
190
- });
191
- }
192
- function un() {
193
- const e = R(Q);
194
- return Ge(e?.store.subscribe ?? ot, e?.store.get ?? pe, e?.store.get ?? pe);
195
- }
196
- var oe = {
197
- duration: 0.2,
198
- ease: "easeOut"
199
- }, ct = {
200
- duration: oe.duration,
201
- ease: "linear"
202
- }, dn = -8;
203
- function ut(e) {
204
- if (typeof getComputedStyle != "function") return null;
205
- for (let t = e.parentElement; t != null && t !== document.body; t = t.parentElement) {
206
- const { overflowY: n } = getComputedStyle(t);
207
- if (n === "auto" || n === "scroll") return t;
208
- }
209
- return null;
210
- }
211
- var Z = /* @__PURE__ */ new Map(), dt = 96;
212
- function mt(e) {
213
- const t = e.closest("[data-basic-page-root]"), n = t?.querySelector("[data-basic-page-column]");
214
- return !t || !n ? 0 : n.getBoundingClientRect().left - t.getBoundingClientRect().left;
215
- }
216
- function we(e) {
217
- const [t] = v(() => {
218
- if (e == null) return !1;
219
- const r = Z.get(e);
220
- return r != null && r.visible && r.el.isConnected && mt(r.el) <= dt;
221
- }), n = A(null);
222
- return P(() => {
223
- if (e == null || typeof IntersectionObserver > "u") return;
224
- const r = n.current;
225
- if (!r) return;
226
- const s = new IntersectionObserver(([o]) => {
227
- o && Z.set(e, {
228
- visible: o.isIntersecting,
229
- el: r
230
- });
231
- });
232
- return s.observe(r), () => {
233
- s.disconnect(), Z.delete(e);
234
- };
235
- }, [e]), {
236
- fly: t,
237
- ref: n
238
- };
239
- }
240
- var ft = {
241
- fade: {
242
- initial: { opacity: 0 },
243
- animate: { opacity: 1 },
244
- transition: { opacity: T }
245
- },
246
- rise: {
247
- initial: {
248
- opacity: 0,
249
- y: V
250
- },
251
- animate: {
252
- opacity: 1,
253
- y: 0
254
- },
255
- transition: {
256
- y: C,
257
- opacity: T
258
- }
259
- },
260
- slide: {
261
- initial: { x: "-100%" },
262
- animate: { x: 0 },
263
- transition: { x: it }
264
- }
265
- };
266
- function Ae({ morphId: e, fromClassName: t, fly: n, morphRef: r, arrival: s, className: o, children: c }) {
267
- const [l, i] = v(!1), d = !n && s != null ? ft[s] : null;
268
- return /* @__PURE__ */ y(b.span, {
269
- ref: r,
270
- layoutId: et(e),
271
- initial: d?.initial,
272
- animate: d?.animate,
273
- transition: n ? tt : {
274
- layout: { duration: 0 },
275
- ...d?.transition
276
- },
277
- onLayoutAnimationStart: () => {
278
- n && i(!0);
279
- },
280
- onLayoutAnimationComplete: () => i(!1),
281
- className: u("relative inline-block", o),
282
- children: [c, l && /* @__PURE__ */ a(b.span, {
283
- "aria-hidden": !0,
284
- initial: { opacity: 1 },
285
- animate: { opacity: 0 },
286
- transition: nt,
287
- onAnimationComplete: () => i(!1),
288
- className: u("absolute inset-0", t),
289
- children: c
290
- })]
291
- });
292
- }
293
- var he = "max-w-full min-w-0 truncate align-top";
294
- function pt({ id: e, morphId: t, enter: n, className: r, children: s, ...o }) {
295
- const c = ie(e, s), l = k(), i = we(t), d = Ne(), f = !l && (t != null || n === !0), m = n || d != null ? "rise" : void 0, p = R(se), x = A(null);
296
- Y(() => {
297
- if (p != null)
298
- return p.setTitle({
299
- label: s,
300
- el: x.current
301
- }), () => p.setTitle(null);
302
- }, [p, s]);
303
- const [w, _] = v(i.fly && d != null);
304
- return Y(() => {
305
- G.length > 0 && _(!1);
306
- }, []), /* @__PURE__ */ y("h1", {
307
- id: c,
308
- className: u("text-display-base text-pho-primary max-w-full min-w-0 scroll-mt-12 px-5 font-medium", f ? "whitespace-nowrap" : "truncate", r),
309
- ...o,
310
- ref: (S) => {
311
- x.current = S;
312
- const E = o.ref;
313
- typeof E == "function" ? E(S) : E != null && (E.current = S);
314
- },
315
- children: [t != null && !l ? /* @__PURE__ */ a(Ae, {
316
- morphId: t,
317
- fromClassName: "text-pho-secondary",
318
- fly: i.fly,
319
- morphRef: i.ref,
320
- arrival: m,
321
- className: he,
322
- children: s
323
- }) : n && !l ? /* @__PURE__ */ a(b.span, {
324
- initial: {
325
- opacity: 0,
326
- y: V
327
- },
328
- animate: {
329
- opacity: 1,
330
- y: 0
331
- },
332
- transition: {
333
- y: C,
334
- opacity: T
335
- },
336
- className: u("inline-block", he),
337
- children: s
338
- }) : s, w && /* @__PURE__ */ a(b.span, {
339
- "aria-hidden": !0,
340
- initial: { opacity: 1 },
341
- animate: { opacity: 0 },
342
- transition: xe,
343
- onAnimationComplete: () => _(!1),
344
- className: u("text-pho-secondary pointer-events-none absolute inline-flex items-center", Vt),
345
- children: /* @__PURE__ */ a(W, {})
346
- })]
347
- });
348
- }
349
- var Ce = j(!1);
350
- function ht() {
351
- const e = R(Ce), t = k(), [n] = v(() => e && !t);
352
- return n;
353
- }
354
- var gt = {
355
- height: 0,
356
- opacity: 0,
357
- paddingTop: 0,
358
- paddingBottom: 0,
359
- borderTopWidth: 0
360
- }, vt = {
361
- y: C,
362
- opacity: T,
363
- height: C,
364
- paddingTop: C,
365
- paddingBottom: C,
366
- borderTopWidth: C
367
- };
368
- function le() {
369
- const e = ht(), t = ze(), n = k();
370
- return {
371
- initial: e ? {
372
- opacity: 0,
373
- y: V
374
- } : !1,
375
- animate: {
376
- opacity: 1,
377
- y: 0
378
- },
379
- exit: gt,
380
- transition: n ? { duration: 0 } : vt,
381
- leaving: !t
382
- };
383
- }
384
- var yt = typeof process < "u" && process.env.NODE_ENV !== "production";
385
- function _e(e, t, n, r) {
386
- P(() => {
387
- if (!yt || e.current == null || typeof getComputedStyle != "function") return;
388
- const s = (c) => {
389
- const l = getComputedStyle(c).rowGap;
390
- return l === "" || l === "normal" ? null : parseFloat(l);
391
- }, o = s(e.current);
392
- o != null && o !== n && console.warn(`[BasicPage.${t}] spaced at ${o}px instead of ${n}px. Spacing is the system's: Stack gap-10 between blocks, a block gap-3, Fields gap-5. Remove the class and move the wrapper instead.`, e.current);
393
- for (const c of Array.from(e.current.children)) {
394
- const l = r(c);
395
- if (l == null || getComputedStyle(c).display === "contents") continue;
396
- const i = s(c);
397
- i != null && i !== l && console.warn(`[BasicPage.${t}] a child is spaced at ${i}px instead of ${l}px. Spacing is the system's: Stack gap-10 between blocks, a block gap-3, Fields gap-5. Remove the class and move the wrapper instead.`, c);
398
- }
399
- });
400
- }
401
- function bt({ className: e, children: t, ...n }) {
402
- const r = k(), s = A(null);
403
- _e(s, "Stack", 40, (d) => d.hasAttribute("data-basic-page-fields") ? 20 : 12);
404
- const o = n["aria-busy"], c = o === !0 || o === "true", l = A(c), i = l.current && !c;
405
- return P(() => {
406
- l.current = c;
407
- }), /* @__PURE__ */ a(b.div, {
408
- ref: (d) => {
409
- s.current = d;
410
- const f = n.ref;
411
- typeof f == "function" ? f(d) : f != null && (f.current = d);
412
- },
413
- "data-basic-page-stack": "",
414
- initial: r ? !1 : {
415
- opacity: 0,
416
- y: V
417
- },
418
- animate: {
419
- opacity: 1,
420
- y: 0
421
- },
422
- transition: {
423
- y: C,
424
- opacity: T
425
- },
426
- className: u("mt-6 flex min-w-0 flex-col gap-10", "*:flex *:min-w-0 *:flex-col [&>*:not([data-basic-page-fields])]:gap-3", e),
427
- ...n,
428
- children: /* @__PURE__ */ a(Ce.Provider, {
429
- value: i,
430
- children: t
431
- })
432
- });
433
- }
434
- var ge = "flex min-w-0 flex-col mb-3 [[data-basic-page-callout]_&]:mb-0 [[data-basic-page-stack]>*>&]:mb-0";
435
- function xt({ enter: e, className: t, ...n }) {
436
- const r = k();
437
- return e && !r ? /* @__PURE__ */ a(b.div, {
438
- initial: {
439
- opacity: 0,
440
- y: V
441
- },
442
- animate: {
443
- opacity: 1,
444
- y: 0
445
- },
446
- transition: {
447
- y: C,
448
- opacity: T
449
- },
450
- "data-basic-page-header": "",
451
- className: u(ge, t),
452
- ...n
453
- }) : /* @__PURE__ */ a("div", {
454
- "data-basic-page-header": "",
455
- className: u(ge, t),
456
- ...n
457
- });
458
- }
459
- function Nt({ id: e, className: t, children: n, ...r }) {
460
- const s = ie(e, n);
461
- return /* @__PURE__ */ a("h2", {
462
- id: s,
463
- className: u("text-display-xs text-pho-primary max-w-full min-w-0 scroll-mt-12 truncate px-5 font-medium", "mb-3 [[data-basic-page-callout]_&]:mb-0 [[data-basic-page-header]>&]:mb-0 [[data-basic-page-stack]>*>&]:mb-0", t),
464
- ...r,
465
- children: n
466
- });
467
- }
468
- function wt({ className: e, ...t }) {
469
- return /* @__PURE__ */ a("p", {
470
- className: u("text-display-xs text-pho-description px-5 font-normal", e),
471
- ...t
472
- });
473
- }
474
- function At({ className: e, ...t }) {
475
- return /* @__PURE__ */ a("p", {
476
- className: u("text-pho-description px-5 text-xs font-normal", "mt-3 [[data-basic-page-callout]_&]:mt-0 [[data-basic-page-stack]>*>&]:mt-0", e),
477
- ...t
478
- });
479
- }
480
- function Ct({ animateHeight: e, className: t, children: n, ...r }) {
481
- const s = /* @__PURE__ */ a(K, { children: ae.toArray(n) });
482
- return e ? /* @__PURE__ */ a("div", {
483
- className: u(re, "min-h-0 overflow-hidden", t),
484
- ...r,
485
- children: /* @__PURE__ */ a(Be, {
486
- transition: C,
487
- className: U,
488
- children: s
489
- })
490
- }) : /* @__PURE__ */ a("div", {
491
- className: u(Ke, t),
492
- ...r,
493
- children: s
494
- });
495
- }
496
- function _t({ className: e, ...t }) {
497
- const { leaving: n, ...r } = le();
498
- return /* @__PURE__ */ a(b.div, {
499
- ...r,
500
- className: u(We, n && "overflow-hidden", e),
501
- ...t
502
- });
503
- }
504
- function Et({ divided: e = !1, className: t, ...n }) {
505
- return /* @__PURE__ */ a("div", {
506
- className: u(e ? Ue : Ye, t),
507
- ...n
508
- });
509
- }
510
- function Rt({ className: e, icon: t, children: n, ...r }) {
511
- if (t == null || t === !1 || t === !0) return /* @__PURE__ */ a("div", {
512
- "data-basic-page-callout": "",
513
- className: u(de, e),
514
- ...r,
515
- children: n
516
- });
517
- const [s, ...o] = ae.toArray(n);
518
- return /* @__PURE__ */ y("div", {
519
- "data-basic-page-callout": "",
520
- className: u(de, e),
521
- ...r,
522
- children: [/* @__PURE__ */ y("div", {
523
- className: "relative",
524
- children: [/* @__PURE__ */ a("div", {
525
- className: "min-w-0 pr-16",
526
- children: s
527
- }), /* @__PURE__ */ a("div", {
528
- "aria-hidden": !0,
529
- className: "text-pho-primary pointer-events-none absolute top-0 right-0 size-14 opacity-[0.275] [&>svg]:size-full",
530
- children: t
531
- })]
532
- }), o]
533
- });
534
- }
535
- function St({ id: e, className: t, children: n, ...r }) {
536
- const s = ie(e, n);
537
- return /* @__PURE__ */ a("h2", {
538
- id: s,
539
- className: u("text-display-xs text-pho-primary max-w-full min-w-0 scroll-mt-12 truncate font-medium", t),
540
- ...r,
541
- children: n
542
- });
543
- }
544
- function Tt({ className: e, ...t }) {
545
- return /* @__PURE__ */ a("p", {
546
- className: u("text-display-xs text-pho-description font-normal", e),
547
- ...t
548
- });
549
- }
550
- function kt({ label: e, description: t, htmlFor: n, stacked: r = !1, className: s, children: o, ...c }) {
551
- const { leaving: l, ...i } = le();
552
- return /* @__PURE__ */ y(b.div, {
553
- ...i,
554
- className: u(Xe, r && "sm:flex-col sm:items-stretch sm:justify-start sm:gap-3", l && "overflow-hidden", s),
555
- ...c,
556
- children: [/* @__PURE__ */ y("div", {
557
- className: "min-w-0",
558
- children: [n ? /* @__PURE__ */ a("label", {
559
- htmlFor: n,
560
- className: "text-pho-primary block text-base font-normal",
561
- children: e
562
- }) : /* @__PURE__ */ a("div", {
563
- className: "text-pho-primary text-base font-normal",
564
- children: e
565
- }), t ? /* @__PURE__ */ a("p", {
566
- className: "text-pho-description text-xs",
567
- children: t
568
- }) : null]
569
- }), /* @__PURE__ */ a("div", {
570
- className: u("flex w-full min-w-0 items-center gap-2 sm:w-auto", r && "sm:w-full"),
571
- children: o
572
- })]
573
- });
574
- }
575
- function It({ className: e, ...t }) {
576
- return /* @__PURE__ */ a("p", {
577
- className: u("text-pho-description max-w-full min-w-0 truncate text-base", e),
578
- ...t
579
- });
580
- }
581
- function Ot({ error: e, show: t, className: n, children: r, ...s }) {
582
- const o = k(), c = R(z), l = e ?? c?.error ?? void 0;
583
- return /* @__PURE__ */ a(K, {
584
- initial: !1,
585
- children: (t ?? !0) && (l != null || r != null) ? /* @__PURE__ */ a(b.div, {
586
- "data-basic-page-alert": "",
587
- className: "overflow-hidden",
588
- initial: {
589
- height: 0,
590
- opacity: 0
591
- },
592
- animate: {
593
- height: "auto",
594
- opacity: 1
595
- },
596
- exit: {
597
- height: 0,
598
- opacity: 0
599
- },
600
- transition: o ? { duration: 0 } : {
601
- height: C,
602
- opacity: T
603
- },
604
- children: /* @__PURE__ */ a(Le, {
605
- error: l,
606
- className: u("px-5 pb-3", n),
607
- ...s,
608
- children: r
609
- })
610
- }) : null
611
- });
612
- }
613
- function mn() {
614
- return R(z)?.requestSave ?? null;
615
- }
616
- var fn = 800, ee = Pe.createToastManager(), z = j(null);
617
- function Lt({ action: e, errors: t, autoSave: n = !1, className: r, children: s, onChange: o, onBlur: c, ...l }) {
618
- const [i, d] = v(!1), [f, m] = v(!1), [p, x] = v(null), [w, _] = v(t ?? {}), [S, E] = v(null), I = A(null), h = A(null), B = A(null), M = A(!1), O = A(!1), D = A(null), F = A(async () => {
619
- });
620
- P(() => () => {
621
- h.current != null && clearTimeout(h.current);
622
- }, []);
623
- const J = async () => {
624
- const N = I.current;
625
- if (N == null || e == null) return;
626
- if (M.current) {
627
- O.current = !0;
628
- return;
629
- }
630
- if (!N.checkValidity()) return;
631
- const g = Object.fromEntries(new FormData(N).entries()), X = B.current;
632
- M.current = !0, E({
633
- field: X,
634
- phase: "saving"
635
- }), x(null);
636
- try {
637
- const L = (await e(g))?.errors;
638
- if (L != null && Object.keys(L).length > 0) {
639
- _(L), E(null);
640
- return;
641
- }
642
- _({}), m(!1), E({
643
- field: X,
644
- phase: "saved"
645
- }), D.current != null && (ee.close(D.current), D.current = null);
646
- } catch (L) {
647
- E(null), x(L), D.current != null && ee.close(D.current), D.current = ee.add({
648
- type: "error",
649
- title: "Couldn't save",
650
- description: L instanceof Error && L.message !== "" ? L.message : "The change is still here — try again.",
651
- timeout: 0,
652
- actionProps: {
653
- children: "Retry",
654
- onClick: () => {
655
- F.current();
656
- }
657
- }
658
- });
659
- } finally {
660
- M.current = !1, O.current && (O.current = !1, F.current());
661
- }
662
- };
663
- F.current = J;
664
- const ce = () => {
665
- h.current != null && clearTimeout(h.current), h.current = setTimeout(() => {
666
- h.current = null, F.current();
667
- }, 800);
668
- }, ue = $(() => n ? (N) => {
669
- N != null && (B.current = N), m(!0), ce();
670
- } : null, [n]), ke = $(() => ({
671
- pending: i,
672
- dirty: f,
673
- error: p,
674
- auto: S,
675
- requestSave: ue
676
- }), [
677
- i,
678
- f,
679
- p,
680
- S,
681
- ue
682
- ]);
683
- return /* @__PURE__ */ a(z.Provider, {
684
- value: ke,
685
- children: /* @__PURE__ */ a(Me, {
686
- errors: w,
687
- onFormSubmit: async (N) => {
688
- if (e != null) {
689
- d(!0), x(null);
690
- try {
691
- const g = (await e(N))?.errors;
692
- if (g != null && Object.keys(g).length > 0) {
693
- _(g);
694
- return;
695
- }
696
- _({}), m(!1);
697
- } catch (g) {
698
- x(g);
699
- } finally {
700
- d(!1);
701
- }
702
- }
703
- },
704
- onChange: (N) => {
705
- m(!0), x(null);
706
- const g = N.target.name;
707
- g && g in w && _((X) => {
708
- const { [g]: L, ...Ie } = X;
709
- return Ie;
710
- }), n && (g && (B.current = g), ce()), o?.(N);
711
- },
712
- onBlur: (N) => {
713
- n && f && h.current != null && (clearTimeout(h.current), h.current = null, F.current()), c?.(N);
714
- },
715
- className: u("contents [[data-basic-page-stack]>&]:flex [[data-basic-page-stack]>&]:min-w-0 [[data-basic-page-stack]>&]:flex-col", r),
716
- ...l,
717
- ref: (N) => {
718
- I.current = N;
719
- const g = l.ref;
720
- typeof g == "function" ? g(N) : g != null && (g.current = N);
721
- },
722
- children: /* @__PURE__ */ a("fieldset", {
723
- disabled: i,
724
- "aria-busy": i || void 0,
725
- className: "contents",
726
- children: s
727
- })
728
- })
729
- });
730
- }
731
- function Pt({ name: e, className: t, ...n }) {
732
- const r = R(z), s = k(), o = r?.auto ?? null, c = o != null && (e == null || o.field === e), [l, i] = v(!1), d = c ? o.phase : null;
733
- P(() => {
734
- if (d !== "saved") return;
735
- i(!0);
736
- const p = setTimeout(() => i(!1), 1800);
737
- return () => clearTimeout(p);
738
- }, [d, o]);
739
- const f = d === "saving" ? "Saving…" : d === "saved" && l ? "Saved" : null, m = s ? "blur(0px)" : "blur(1px)";
740
- return /* @__PURE__ */ a("span", {
741
- className: "grid justify-items-end",
742
- children: /* @__PURE__ */ a(K, {
743
- initial: !1,
744
- children: f != null && /* @__PURE__ */ a(b.output, {
745
- initial: {
746
- opacity: 0,
747
- filter: m
748
- },
749
- animate: {
750
- opacity: 1,
751
- filter: "blur(0px)"
752
- },
753
- exit: {
754
- opacity: 0,
755
- filter: m
756
- },
757
- transition: oe,
758
- className: u("text-pho-description pl-8 [grid-area:1/1]", t),
759
- style: { background: "linear-gradient(to left, var(--background-color-pho-primary) calc(100% - 2rem), transparent)" },
760
- ...n,
761
- children: f
762
- }, f)
763
- })
764
- });
765
- }
766
- var Bt = "flex min-w-0 flex-col gap-5 p-5 [&>[data-basic-page-alert]]:-mx-5 [&>[data-basic-page-alert]]:-mt-2 [&>[data-basic-page-alert]]:-mb-5 [&>[data-basic-page-footer]]:pr-0 [&>[data-basic-page-reveal]]:flex [&>[data-basic-page-reveal]]:flex-col [&>[data-basic-page-reveal]]:gap-5";
767
- function Mt({ className: e, ...t }) {
768
- const n = A(null);
769
- return _e(n, "Fields", 20, () => null), /* @__PURE__ */ a("div", {
770
- "data-basic-page-fields": "",
771
- className: u(re, Bt, e),
772
- ...t,
773
- ref: (r) => {
774
- n.current = r;
775
- const s = t.ref;
776
- typeof s == "function" ? s(r) : s != null && (s.current = r);
777
- }
778
- });
779
- }
780
- function Dt({ className: e, ...t }) {
781
- return /* @__PURE__ */ a("div", {
782
- className: u("flex min-w-0 flex-col gap-5 *:min-w-0 sm:flex-row sm:gap-3 sm:*:flex-1", e),
783
- ...t
784
- });
785
- }
786
- function Ft({ children: e = "Save changes", ...t }) {
787
- const n = R(z);
788
- return /* @__PURE__ */ a(ye, {
789
- type: "submit",
790
- variant: "effect",
791
- size: "sm",
792
- loading: n?.pending,
793
- ...t,
794
- children: e
795
- });
796
- }
797
- function Ht({ show: e, className: t, ...n }) {
798
- const r = R(z), s = e === "dirty" ? r?.dirty ?? !1 : e, o = /* @__PURE__ */ a("div", {
799
- "data-basic-page-footer": "",
800
- className: u("flex items-center justify-end gap-3 pr-[calc(1.25rem+2.5px)]", t),
801
- ...n
802
- });
803
- return s === void 0 ? o : /* @__PURE__ */ a(Ee, {
804
- show: s,
805
- gap: "block",
806
- clip: !1,
807
- children: o
808
- });
809
- }
810
- var Gt = {
811
- stack: "-2.5rem",
812
- block: "-0.75rem",
813
- fields: "-1.25rem",
814
- none: "0px"
815
- };
816
- function Ee({ show: e, clip: t = !0, gap: n = "stack", dividers: r, className: s, ...o }) {
817
- const c = k(), l = Gt[r ? "none" : n], i = A(null), d = A(e !== !0);
818
- P(() => {
819
- d.current = !0;
820
- }, []);
821
- const f = () => {
822
- t && i.current && (i.current.style.overflow = "hidden");
823
- }, m = () => {
824
- i.current && (i.current.style.overflow = "");
825
- };
826
- return e === void 0 ? /* @__PURE__ */ a(b.div, {
827
- initial: c ? !1 : {
828
- opacity: 0,
829
- y: V
830
- },
831
- animate: {
832
- opacity: 1,
833
- y: 0
834
- },
835
- transition: {
836
- y: C,
837
- opacity: T
838
- },
839
- className: u(r && U, s),
840
- ...o
841
- }) : /* @__PURE__ */ a(K, {
842
- initial: !1,
843
- children: e ? /* @__PURE__ */ a(b.div, {
844
- "data-basic-page-reveal": "",
845
- ref: (p) => {
846
- i.current = p, t && p && d.current && (p.style.overflow = "hidden");
847
- },
848
- onAnimationStart: f,
849
- onAnimationComplete: m,
850
- initial: {
851
- height: 0,
852
- opacity: 0,
853
- marginTop: l
854
- },
855
- animate: {
856
- height: "auto",
857
- opacity: 1,
858
- marginTop: 0
859
- },
860
- exit: {
861
- height: 0,
862
- opacity: 0,
863
- marginTop: l
864
- },
865
- transition: c ? { duration: 0 } : {
866
- height: C,
867
- marginTop: C,
868
- opacity: T
869
- },
870
- className: u(r && U, s),
871
- ...o
872
- }) : null
873
- });
874
- }
875
- var Vt = "top-4 left-5 h-8 text-base [&>svg]:size-[1.125em] [&>svg]:shrink-0", zt = "(min-width: 40rem)";
876
- function $t() {
877
- return typeof window < "u" && typeof window.matchMedia == "function" && !window.matchMedia(zt).matches;
878
- }
879
- var Re = j(null);
880
- function Se({ className: e, children: t, ...n }) {
881
- const r = ae.toArray(t).filter(Fe), s = r.map((I) => I.props.children ?? null), o = Ne();
882
- st(s);
883
- const [c] = v($t), l = k(), i = r.length, d = ve(), f = !c && i >= jt, m = R(se), p = i > 0 ? r[i - 1]?.props : null, x = p?.children ?? "Back", w = p?.href, _ = p?.onClick;
884
- Y(() => {
885
- if (!(m == null || w == null))
886
- return m.setTail({
887
- label: x,
888
- href: w,
889
- onClick: _
890
- }), () => m.setTail(null);
891
- }, [
892
- m,
893
- x,
894
- w,
895
- _
896
- ]);
897
- const [S, E] = v(!l && !c && o != null && o.labels.length > i);
898
- return /* @__PURE__ */ a("nav", {
899
- "aria-label": "Breadcrumb",
900
- "data-basic-page-back": "",
901
- className: u("absolute top-4 left-3 flex min-w-max items-center", e),
902
- ...n,
903
- children: /* @__PURE__ */ y("ol", {
904
- className: "m-0 flex list-none items-center p-0",
905
- children: [r.map((I, h) => f && h > 0 && h < i - 2 ? null : /* @__PURE__ */ y(De, { children: [f && h === i - 2 && /* @__PURE__ */ y("li", {
906
- className: "m-0 flex items-center max-sm:hidden",
907
- children: [/* @__PURE__ */ a("span", {
908
- "aria-hidden": !0,
909
- className: ne,
910
- children: q
911
- }), /* @__PURE__ */ y(H.Root, { children: [/* @__PURE__ */ a(H.Trigger, { render: /* @__PURE__ */ a(ye, {
912
- variant: "ghost",
913
- size: "sm",
914
- "aria-label": "Hidden pages",
915
- className: "px-2",
916
- children: Kt
917
- }) }), /* @__PURE__ */ a(H.Portal, { children: /* @__PURE__ */ a(H.Positioner, {
918
- align: "start",
919
- sideOffset: 4,
920
- children: /* @__PURE__ */ a(H.Popup, { children: r.slice(1, i - 2).map((B, M) => {
921
- const O = B.props;
922
- return /* @__PURE__ */ a(H.LinkItem, {
923
- render: /* @__PURE__ */ a(d, {
924
- href: O.href,
925
- onClick: O.onClick
926
- }),
927
- children: O.children ?? "Back"
928
- }, B.key ?? M);
929
- }) })
930
- }) })] })]
931
- }), /* @__PURE__ */ a("li", {
932
- className: u("m-0 flex items-center", h < i - 1 && "max-sm:hidden"),
933
- children: /* @__PURE__ */ a(Re.Provider, {
934
- value: {
935
- index: h,
936
- count: i,
937
- departing: o,
938
- narrow: c
939
- },
940
- children: I
941
- })
942
- })] }, I.key ?? h)), S && /* @__PURE__ */ a("li", {
943
- "aria-hidden": !0,
944
- className: "m-0 flex items-center max-sm:hidden",
945
- children: /* @__PURE__ */ a(b.span, {
946
- initial: { opacity: 1 },
947
- animate: { opacity: 0 },
948
- transition: xe,
949
- onAnimationComplete: () => E(!1),
950
- className: ne,
951
- children: q
952
- })
953
- })]
954
- })
955
- });
956
- }
957
- var ne = "text-pho-description -mx-1 inline-flex shrink-0 text-base select-none", q = "/", jt = 4, Kt = "…";
958
- function Te({ href: e, className: t, morphId: n, children: r = "Back", ...s }) {
959
- const o = R(Re), c = k(), l = n != null && !c, i = we(l ? n : void 0);
960
- if (o == null) throw new Error("BasicPage.Crumb must be rendered inside BasicPage.Breadcrumbs");
961
- const { index: d, count: f, departing: m, narrow: p } = o, x = d === 0, w = d === f - 1, _ = m != null && m.labels.length < f, S = m != null && m.labels.length > f, E = w && (m == null || _ || p), I = x || w, h = x && w ? "" : x ? "max-sm:hidden" : "sm:hidden", B = m != null, M = w ? p ? S ? "slide" : "fade" : E ? "fade" : void 0 : void 0, [O, D] = v(l && p && i.fly && m != null && !S ? m.labels[m.labels.length - 1] : null), F = l && I && !B, J = l && !x && w && (m == null || _);
962
- return /* @__PURE__ */ y(Ve, { children: [!x && /* @__PURE__ */ a("span", {
963
- "aria-hidden": !0,
964
- className: u(ne, "max-sm:hidden"),
965
- children: J ? /* @__PURE__ */ a(b.span, {
966
- initial: i.fly ? {
967
- opacity: 0,
968
- x: me
969
- } : { opacity: 0 },
970
- animate: i.fly ? {
971
- opacity: 1,
972
- x: 0
973
- } : { opacity: 1 },
974
- transition: i.fly ? fe : T,
975
- className: "inline-flex",
976
- children: q
977
- }) : q
978
- }), /* @__PURE__ */ a(be, {
979
- variant: "ghost",
980
- size: "sm",
981
- href: e,
982
- prefix: I ? F ? /* @__PURE__ */ a(b.span, {
983
- initial: i.fly ? {
984
- opacity: 0,
985
- x: me
986
- } : { opacity: 0 },
987
- animate: i.fly ? {
988
- opacity: 1,
989
- x: 0
990
- } : { opacity: 1 },
991
- transition: i.fly ? fe : T,
992
- className: u("inline-flex [&>svg]:size-[1.125em] [&>svg]:shrink-0", h),
993
- children: /* @__PURE__ */ a(W, {})
994
- }) : /* @__PURE__ */ a("span", {
995
- className: u("inline-flex [&>svg]:size-[1.125em] [&>svg]:shrink-0", h),
996
- children: /* @__PURE__ */ a(W, {})
997
- }) : /* @__PURE__ */ a("span", { className: "hidden" }),
998
- className: u("min-w-max", t),
999
- ...s,
1000
- children: l && n != null ? /* @__PURE__ */ y("span", {
1001
- className: u("relative block", !i.fly && M === "slide" && "overflow-hidden", !w && "max-w-40 truncate"),
1002
- children: [/* @__PURE__ */ a(Ae, {
1003
- morphId: n,
1004
- fromClassName: "text-pho-primary",
1005
- fly: i.fly,
1006
- morphRef: i.ref,
1007
- arrival: M,
1008
- children: r
1009
- }), O != null && /* @__PURE__ */ a(b.span, {
1010
- "aria-hidden": !0,
1011
- initial: {
1012
- x: 0,
1013
- opacity: 1
1014
- },
1015
- animate: {
1016
- x: at,
1017
- opacity: 0
1018
- },
1019
- transition: rt,
1020
- onAnimationComplete: () => D(null),
1021
- className: "pointer-events-none absolute inset-y-0 left-0 whitespace-nowrap",
1022
- children: O
1023
- })]
1024
- }) : /* @__PURE__ */ a("span", {
1025
- className: u("block", !w && "max-w-40 truncate"),
1026
- children: r
1027
- })
1028
- })] });
1029
- }
1030
- function Xt({ className: e, ...t }) {
1031
- return /* @__PURE__ */ a(Se, {
1032
- className: e,
1033
- children: /* @__PURE__ */ a(Te, { ...t })
1034
- });
1035
- }
1036
- function Wt({ label: e, description: t, leading: n, href: r, className: s, children: o, ...c }) {
1037
- const l = ve(), i = $(() => b.create(l), [l]), { leaving: d, ...f } = le();
1038
- return /* @__PURE__ */ y(i, {
1039
- href: r,
1040
- ...f,
1041
- ...c,
1042
- className: u("flex min-h-[4.25rem] min-w-0 flex-row items-center justify-between gap-6 px-5 py-4", "group outline-pho-brand hover:bg-pho-primary-hover cursor-pointer transition-colors focus-visible:outline-2 focus-visible:-outline-offset-2", "first:rounded-t-[calc(var(--radius-base)-1px)] last:rounded-b-[calc(var(--radius-base)-1px)]", d && "overflow-hidden", s),
1043
- children: [/* @__PURE__ */ y("div", {
1044
- className: u("flex min-w-0 flex-1 items-center", n != null && "gap-3"),
1045
- children: [n, /* @__PURE__ */ y("div", {
1046
- className: "min-w-0",
1047
- children: [/* @__PURE__ */ a("div", {
1048
- className: "flex min-w-0 items-center gap-1",
1049
- children: typeof e == "string" || typeof e == "number" ? /* @__PURE__ */ a("p", {
1050
- className: "text-pho-primary truncate text-base font-medium",
1051
- children: e
1052
- }) : e
1053
- }), t ? /* @__PURE__ */ a("div", {
1054
- className: "text-pho-description truncate text-xs",
1055
- children: t
1056
- }) : null]
1057
- })]
1058
- }), /* @__PURE__ */ y("div", {
1059
- className: "flex min-w-0 items-center justify-end gap-2",
1060
- children: [o != null ? /* @__PURE__ */ a("div", {
1061
- className: "min-w-0",
1062
- children: o
1063
- }) : null, /* @__PURE__ */ a(je, {
1064
- "aria-hidden": !0,
1065
- className: "text-pho-secondary group-hover:text-pho-secondary-hover size-4 shrink-0 transition-colors"
1066
- })]
1067
- })]
1068
- });
1069
- }
1070
- var pn = {
1071
- Root: qe,
1072
- CondenseScope: lt,
1073
- Breadcrumbs: Se,
1074
- Crumb: Te,
1075
- Back: Xt,
1076
- Title: pt,
1077
- Stack: bt,
1078
- Header: xt,
1079
- SectionTitle: Nt,
1080
- Description: wt,
1081
- SectionFooter: At,
1082
- Card: Ct,
1083
- Item: _t,
1084
- ItemPanel: Et,
1085
- Callout: Rt,
1086
- CalloutTitle: St,
1087
- CalloutDescription: Tt,
1088
- Row: kt,
1089
- RowLink: Wt,
1090
- Value: It,
1091
- Alert: Ot,
1092
- Footer: Ht,
1093
- Form: Lt,
1094
- Saved: Pt,
1095
- Fields: Mt,
1096
- Inline: Dt,
1097
- Submit: Ft,
1098
- Reveal: Ee
1099
- };
1100
- export {
1101
- Ye as a,
1102
- pn as c,
1103
- ct as d,
1104
- ee as f,
1105
- We as i,
1106
- oe as l,
1107
- un as m,
1108
- de as n,
1109
- Ue as o,
1110
- mn as p,
1111
- Ke as r,
1112
- Xe as s,
1113
- fn as t,
1114
- dn as u
1115
- };
1116
-
1117
- //# sourceMappingURL=basic-page-c_7Ii5Fr.js.map