@alexandregme/zljs 3.10.0 → 3.12.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.
- package/CHANGELOG.md +39 -1
- package/dist/{chunk-JMEGXQKC.js → chunk-TMUYZTIH.js} +747 -327
- package/dist/index.d.ts +92 -20
- package/dist/index.js +18 -157
- package/dist/next/index.d.ts +11 -2
- package/dist/next/index.js +18 -47
- package/package.json +1 -1
|
@@ -178,6 +178,7 @@ var Button = ({
|
|
|
178
178
|
iconPosition = "left",
|
|
179
179
|
disabled = false,
|
|
180
180
|
"aria-label": ariaLabel,
|
|
181
|
+
"aria-expanded": ariaExpanded,
|
|
181
182
|
onClick
|
|
182
183
|
}) => {
|
|
183
184
|
const isIconOnly = icon2 && !children;
|
|
@@ -205,6 +206,7 @@ var Button = ({
|
|
|
205
206
|
disabled,
|
|
206
207
|
onClick,
|
|
207
208
|
"aria-label": ariaLabel,
|
|
209
|
+
"aria-expanded": ariaExpanded,
|
|
208
210
|
className: button({
|
|
209
211
|
variant,
|
|
210
212
|
color: variant === "icon" && color !== "ghost" ? "none" : color,
|
|
@@ -373,105 +375,6 @@ var Heading = ({ children, level = 1, color }) => {
|
|
|
373
375
|
return /* @__PURE__ */ jsx5(Tag, { className: heading({ level, color }), children });
|
|
374
376
|
};
|
|
375
377
|
|
|
376
|
-
// features/toaster/state/toast.store.ts
|
|
377
|
-
import { create } from "zustand";
|
|
378
|
-
import { devtools } from "zustand/middleware";
|
|
379
|
-
|
|
380
|
-
// features/toaster/state/toast.const.ts
|
|
381
|
-
var toastInitialState = {
|
|
382
|
-
toasts: []
|
|
383
|
-
};
|
|
384
|
-
var toastDevtools = { name: "zljs", store: "toast" };
|
|
385
|
-
|
|
386
|
-
// features/toaster/state/toast.store.ts
|
|
387
|
-
var toastId = 0;
|
|
388
|
-
var useToastStore = create()(
|
|
389
|
-
devtools(
|
|
390
|
-
(set, get) => ({
|
|
391
|
-
...toastInitialState,
|
|
392
|
-
addToast: (message, type = "error") => {
|
|
393
|
-
const id = ++toastId;
|
|
394
|
-
set(
|
|
395
|
-
(s) => ({ toasts: [...s.toasts, { id, message, type }] }),
|
|
396
|
-
false,
|
|
397
|
-
"addToast"
|
|
398
|
-
);
|
|
399
|
-
return id;
|
|
400
|
-
},
|
|
401
|
-
removeToast: (id) => set(
|
|
402
|
-
(s) => ({ toasts: s.toasts.filter((t) => t.id !== id) }),
|
|
403
|
-
false,
|
|
404
|
-
"removeToast"
|
|
405
|
-
),
|
|
406
|
-
success: (message) => get().addToast(message, "success"),
|
|
407
|
-
error: (message) => get().addToast(message, "error"),
|
|
408
|
-
info: (message) => get().addToast(message, "info"),
|
|
409
|
-
warning: (message) => get().addToast(message, "warning")
|
|
410
|
-
}),
|
|
411
|
-
toastDevtools
|
|
412
|
-
)
|
|
413
|
-
);
|
|
414
|
-
|
|
415
|
-
// features/toaster/components/toaster/toaster.tsx
|
|
416
|
-
import { useEffect } from "react";
|
|
417
|
-
import { Toaster as SonnerToaster, toast } from "sonner";
|
|
418
|
-
|
|
419
|
-
// features/toaster/components/toaster/toaster.styles.ts
|
|
420
|
-
import { tv as tv6 } from "tailwind-variants";
|
|
421
|
-
var focusOutline = "focus-visible:outline-2! focus-visible:outline-offset-2! focus-visible:outline-current!";
|
|
422
|
-
var toaster = tv6({
|
|
423
|
-
slots: {
|
|
424
|
-
toast: focusOutline,
|
|
425
|
-
closeButton: focusOutline
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
var toasterColors = {
|
|
429
|
-
"--success-text": "var(--color-zl-success-strong)",
|
|
430
|
-
"--success-bg": "color-mix(in oklab, var(--color-zl-success) 15%, white)",
|
|
431
|
-
"--success-border": "color-mix(in oklab, var(--color-zl-success) 30%, white)",
|
|
432
|
-
"--info-text": "var(--color-zl-info-strong)",
|
|
433
|
-
"--info-bg": "color-mix(in oklab, var(--color-zl-info) 15%, white)",
|
|
434
|
-
"--info-border": "color-mix(in oklab, var(--color-zl-info) 30%, white)",
|
|
435
|
-
"--warning-text": "var(--color-zl-warning-strong)",
|
|
436
|
-
"--warning-bg": "color-mix(in oklab, var(--color-zl-warning) 15%, white)",
|
|
437
|
-
"--warning-border": "color-mix(in oklab, var(--color-zl-warning) 30%, white)",
|
|
438
|
-
"--error-text": "var(--color-zl-danger-strong)",
|
|
439
|
-
"--error-bg": "color-mix(in oklab, var(--color-zl-danger) 15%, white)",
|
|
440
|
-
"--error-border": "color-mix(in oklab, var(--color-zl-danger) 30%, white)"
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
// features/toaster/components/toaster/toaster.tsx
|
|
444
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
445
|
-
var Toaster = () => {
|
|
446
|
-
const toasts = useToastStore((s) => s.toasts);
|
|
447
|
-
const removeToast = useToastStore((s) => s.removeToast);
|
|
448
|
-
const { toast: toastStyles, closeButton } = toaster();
|
|
449
|
-
useEffect(() => {
|
|
450
|
-
toasts.forEach((t) => {
|
|
451
|
-
toast[t.type](t.message, { id: `store-${t.id}` });
|
|
452
|
-
removeToast(t.id);
|
|
453
|
-
});
|
|
454
|
-
}, [toasts, removeToast]);
|
|
455
|
-
return /* @__PURE__ */ jsx6(
|
|
456
|
-
SonnerToaster,
|
|
457
|
-
{
|
|
458
|
-
position: "bottom-right",
|
|
459
|
-
richColors: true,
|
|
460
|
-
closeButton: true,
|
|
461
|
-
duration: 4e3,
|
|
462
|
-
expand: true,
|
|
463
|
-
visibleToasts: 5,
|
|
464
|
-
style: toasterColors,
|
|
465
|
-
toastOptions: {
|
|
466
|
-
classNames: { toast: toastStyles(), closeButton: closeButton() }
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
);
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
// features/toaster/components/toaster/index.ts
|
|
473
|
-
import { toast as toast2 } from "sonner";
|
|
474
|
-
|
|
475
378
|
// features/app/state/app.const.ts
|
|
476
379
|
var appInitialState = {
|
|
477
380
|
fetchingCalls: 0,
|
|
@@ -481,10 +384,10 @@ var appInitialState = {
|
|
|
481
384
|
var appDevtools = { name: "zljs", store: "app" };
|
|
482
385
|
|
|
483
386
|
// features/app/state/app.store.ts
|
|
484
|
-
import { create
|
|
485
|
-
import { devtools
|
|
486
|
-
var useAppStore =
|
|
487
|
-
|
|
387
|
+
import { create } from "zustand";
|
|
388
|
+
import { devtools } from "zustand/middleware";
|
|
389
|
+
var useAppStore = create()(
|
|
390
|
+
devtools(
|
|
488
391
|
(set, get) => ({
|
|
489
392
|
...appInitialState,
|
|
490
393
|
startFetching: () => set(
|
|
@@ -529,35 +432,613 @@ var useAppStore = create2()(
|
|
|
529
432
|
)
|
|
530
433
|
);
|
|
531
434
|
|
|
532
|
-
// features/app/components/connected-modal/connected-modal.tsx
|
|
533
|
-
import { jsx as
|
|
534
|
-
var ConnectedModal = ({
|
|
535
|
-
modalId,
|
|
536
|
-
title: title2,
|
|
537
|
-
description: description2,
|
|
538
|
-
size,
|
|
539
|
-
color,
|
|
540
|
-
children
|
|
541
|
-
}) => {
|
|
542
|
-
const open = useAppStore((s) => s.isModalOpen(modalId));
|
|
543
|
-
const closeModal = useAppStore((s) => s.closeModal);
|
|
544
|
-
const close = () => {
|
|
545
|
-
closeModal(modalId);
|
|
546
|
-
};
|
|
547
|
-
return /* @__PURE__ */
|
|
548
|
-
Modal,
|
|
435
|
+
// features/app/components/connected-modal/connected-modal.tsx
|
|
436
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
437
|
+
var ConnectedModal = ({
|
|
438
|
+
modalId,
|
|
439
|
+
title: title2,
|
|
440
|
+
description: description2,
|
|
441
|
+
size,
|
|
442
|
+
color,
|
|
443
|
+
children
|
|
444
|
+
}) => {
|
|
445
|
+
const open = useAppStore((s) => s.isModalOpen(modalId));
|
|
446
|
+
const closeModal = useAppStore((s) => s.closeModal);
|
|
447
|
+
const close = () => {
|
|
448
|
+
closeModal(modalId);
|
|
449
|
+
};
|
|
450
|
+
return /* @__PURE__ */ jsx6(
|
|
451
|
+
Modal,
|
|
452
|
+
{
|
|
453
|
+
open,
|
|
454
|
+
onClose: close,
|
|
455
|
+
title: title2,
|
|
456
|
+
description: description2,
|
|
457
|
+
size,
|
|
458
|
+
color,
|
|
459
|
+
children
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// features/toaster/state/toast.store.ts
|
|
465
|
+
import { create as create2 } from "zustand";
|
|
466
|
+
import { devtools as devtools2 } from "zustand/middleware";
|
|
467
|
+
|
|
468
|
+
// features/toaster/state/toast.const.ts
|
|
469
|
+
var toastInitialState = {
|
|
470
|
+
toasts: []
|
|
471
|
+
};
|
|
472
|
+
var toastDevtools = { name: "zljs", store: "toast" };
|
|
473
|
+
|
|
474
|
+
// features/toaster/state/toast.store.ts
|
|
475
|
+
var toastId = 0;
|
|
476
|
+
var useToastStore = create2()(
|
|
477
|
+
devtools2(
|
|
478
|
+
(set, get) => ({
|
|
479
|
+
...toastInitialState,
|
|
480
|
+
addToast: (message, type = "error") => {
|
|
481
|
+
const id = ++toastId;
|
|
482
|
+
set(
|
|
483
|
+
(s) => ({ toasts: [...s.toasts, { id, message, type }] }),
|
|
484
|
+
false,
|
|
485
|
+
"addToast"
|
|
486
|
+
);
|
|
487
|
+
return id;
|
|
488
|
+
},
|
|
489
|
+
removeToast: (id) => set(
|
|
490
|
+
(s) => ({ toasts: s.toasts.filter((t) => t.id !== id) }),
|
|
491
|
+
false,
|
|
492
|
+
"removeToast"
|
|
493
|
+
),
|
|
494
|
+
success: (message) => get().addToast(message, "success"),
|
|
495
|
+
error: (message) => get().addToast(message, "error"),
|
|
496
|
+
info: (message) => get().addToast(message, "info"),
|
|
497
|
+
warning: (message) => get().addToast(message, "warning")
|
|
498
|
+
}),
|
|
499
|
+
toastDevtools
|
|
500
|
+
)
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
// features/auth/state/auth.store.ts
|
|
504
|
+
import { create as create3 } from "zustand";
|
|
505
|
+
import { devtools as devtools3 } from "zustand/middleware";
|
|
506
|
+
|
|
507
|
+
// features/auth/state/auth.const.ts
|
|
508
|
+
var authInitialState = {
|
|
509
|
+
status: "loading",
|
|
510
|
+
session: null,
|
|
511
|
+
adapter: null,
|
|
512
|
+
appId: null
|
|
513
|
+
};
|
|
514
|
+
var authDevtools = { name: "zljs", store: "auth" };
|
|
515
|
+
|
|
516
|
+
// features/auth/state/auth.store.ts
|
|
517
|
+
var useAuthStore = create3()(
|
|
518
|
+
devtools3(
|
|
519
|
+
(set) => ({
|
|
520
|
+
...authInitialState,
|
|
521
|
+
setSession: (session) => set(
|
|
522
|
+
{
|
|
523
|
+
session,
|
|
524
|
+
status: session ? "authenticated" : "unauthenticated"
|
|
525
|
+
},
|
|
526
|
+
false,
|
|
527
|
+
"setSession"
|
|
528
|
+
),
|
|
529
|
+
configure: (adapter, appId) => set({ adapter, appId }, false, "configure"),
|
|
530
|
+
reset: () => set(authInitialState, false, "reset")
|
|
531
|
+
}),
|
|
532
|
+
authDevtools
|
|
533
|
+
)
|
|
534
|
+
);
|
|
535
|
+
|
|
536
|
+
// features/auth/state/get-auth-session/get-auth-session.ts
|
|
537
|
+
var getAuthSession = () => useAuthStore.getState().session;
|
|
538
|
+
|
|
539
|
+
// features/auth/hooks/use-auth/use-auth.ts
|
|
540
|
+
var requireAdapter = () => {
|
|
541
|
+
const { adapter } = useAuthStore.getState();
|
|
542
|
+
if (!adapter) {
|
|
543
|
+
throw new Error("useAuth must be used inside <AuthProvider>");
|
|
544
|
+
}
|
|
545
|
+
return adapter;
|
|
546
|
+
};
|
|
547
|
+
var useAuth = () => {
|
|
548
|
+
const status = useAuthStore((s) => s.status);
|
|
549
|
+
const session = useAuthStore((s) => s.session);
|
|
550
|
+
const appId = useAuthStore((s) => s.appId);
|
|
551
|
+
const user = session?.user ?? null;
|
|
552
|
+
return {
|
|
553
|
+
status,
|
|
554
|
+
user,
|
|
555
|
+
role: (appId && user?.roles[appId]) ?? null,
|
|
556
|
+
signInWithOAuth: (provider) => requireAdapter().signInWithOAuth(provider),
|
|
557
|
+
signInWithPassword: (credentials) => requireAdapter().signInWithPassword(credentials),
|
|
558
|
+
signInWithMagicLink: (email) => requireAdapter().signInWithMagicLink(email),
|
|
559
|
+
signOut: () => requireAdapter().signOut()
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
// features/auth/components/sign-out/sign-out-modal.const.ts
|
|
564
|
+
var SIGN_OUT_MODAL_ID = "zljs-sign-out";
|
|
565
|
+
|
|
566
|
+
// features/auth/components/sign-out/sign-out-modal.styles.ts
|
|
567
|
+
import { tv as tv6 } from "tailwind-variants";
|
|
568
|
+
var signOutModal = tv6({
|
|
569
|
+
slots: {
|
|
570
|
+
actions: "flex justify-end gap-2"
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// features/auth/components/sign-out/sign-out-modal.tsx
|
|
575
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
576
|
+
var SignOutModal = ({
|
|
577
|
+
title: title2 = "Sign out?",
|
|
578
|
+
confirmLabel = "Sign out",
|
|
579
|
+
cancelLabel = "Cancel",
|
|
580
|
+
errorMessage = "Could not sign out. Try again.",
|
|
581
|
+
onSignOut
|
|
582
|
+
}) => {
|
|
583
|
+
const { signOut } = useAuth();
|
|
584
|
+
const closeModal = useAppStore((s) => s.closeModal);
|
|
585
|
+
const { actions } = signOutModal();
|
|
586
|
+
const stay = () => {
|
|
587
|
+
closeModal(SIGN_OUT_MODAL_ID);
|
|
588
|
+
};
|
|
589
|
+
const signOutOfApp = async () => {
|
|
590
|
+
if (onSignOut) {
|
|
591
|
+
await onSignOut();
|
|
592
|
+
} else {
|
|
593
|
+
await signOut();
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
const showError = () => {
|
|
597
|
+
useToastStore.getState().error(errorMessage);
|
|
598
|
+
};
|
|
599
|
+
const leave = () => {
|
|
600
|
+
closeModal(SIGN_OUT_MODAL_ID);
|
|
601
|
+
signOutOfApp().catch(showError);
|
|
602
|
+
};
|
|
603
|
+
return /* @__PURE__ */ jsx7(
|
|
604
|
+
ConnectedModal,
|
|
605
|
+
{
|
|
606
|
+
modalId: SIGN_OUT_MODAL_ID,
|
|
607
|
+
title: title2,
|
|
608
|
+
size: "xs",
|
|
609
|
+
color: "danger",
|
|
610
|
+
children: /* @__PURE__ */ jsxs3("div", { className: actions(), children: [
|
|
611
|
+
/* @__PURE__ */ jsx7(Button, { color: "ghost", onClick: stay, children: cancelLabel }),
|
|
612
|
+
/* @__PURE__ */ jsx7(Button, { color: "danger", onClick: leave, children: confirmLabel })
|
|
613
|
+
] })
|
|
614
|
+
}
|
|
615
|
+
);
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// features/auth/components/sign-out/sign-out-button.tsx
|
|
619
|
+
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
620
|
+
var SignOutButton = ({
|
|
621
|
+
label = "Sign out",
|
|
622
|
+
size = "md",
|
|
623
|
+
confirmTitle,
|
|
624
|
+
confirmLabel,
|
|
625
|
+
cancelLabel,
|
|
626
|
+
errorMessage,
|
|
627
|
+
onSignOut
|
|
628
|
+
}) => {
|
|
629
|
+
const openModal = useAppStore((s) => s.openModal);
|
|
630
|
+
const ask = () => {
|
|
631
|
+
openModal(SIGN_OUT_MODAL_ID);
|
|
632
|
+
};
|
|
633
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
634
|
+
/* @__PURE__ */ jsx8(
|
|
635
|
+
Button,
|
|
636
|
+
{
|
|
637
|
+
color: "ghost",
|
|
638
|
+
size,
|
|
639
|
+
icon: "LogOut",
|
|
640
|
+
"aria-label": label,
|
|
641
|
+
onClick: ask
|
|
642
|
+
}
|
|
643
|
+
),
|
|
644
|
+
/* @__PURE__ */ jsx8(
|
|
645
|
+
SignOutModal,
|
|
646
|
+
{
|
|
647
|
+
title: confirmTitle,
|
|
648
|
+
confirmLabel,
|
|
649
|
+
cancelLabel,
|
|
650
|
+
errorMessage,
|
|
651
|
+
onSignOut
|
|
652
|
+
}
|
|
653
|
+
)
|
|
654
|
+
] });
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
// core/next/link/link.tsx
|
|
658
|
+
import NextLink from "next/link.js";
|
|
659
|
+
|
|
660
|
+
// core/next/link/link.styles.ts
|
|
661
|
+
import { tv as tv7 } from "tailwind-variants";
|
|
662
|
+
var link = tv7({
|
|
663
|
+
// outline-current draws the focus in the text color.
|
|
664
|
+
base: "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current",
|
|
665
|
+
variants: {
|
|
666
|
+
variant: {
|
|
667
|
+
// The invisible ::after grows the touch target to 44px without changing the layout.
|
|
668
|
+
inline: "relative rounded-sm underline underline-offset-2 hover:decoration-2 after:absolute after:top-1/2 after:left-1/2 after:h-11 after:w-full after:min-w-11 after:-translate-x-1/2 after:-translate-y-1/2",
|
|
669
|
+
// A row of a menu. The translucent backgrounds work on a light or a dark surface.
|
|
670
|
+
nav: "flex h-10 items-center gap-2 overflow-hidden rounded-md px-3 whitespace-nowrap transition-colors"
|
|
671
|
+
},
|
|
672
|
+
active: {
|
|
673
|
+
true: "",
|
|
674
|
+
false: ""
|
|
675
|
+
},
|
|
676
|
+
color: {
|
|
677
|
+
primary: "text-zl-primary hover:text-zl-primary-strong",
|
|
678
|
+
success: "text-zl-success hover:text-zl-success-strong",
|
|
679
|
+
danger: "text-zl-danger hover:text-zl-danger-strong",
|
|
680
|
+
warning: "text-zl-warning hover:text-zl-warning-strong",
|
|
681
|
+
info: "text-zl-info hover:text-zl-info-strong",
|
|
682
|
+
muted: "text-zl-muted hover:text-zl-muted-strong",
|
|
683
|
+
none: ""
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
compoundVariants: [
|
|
687
|
+
{ variant: "nav", active: true, class: "bg-neutral-500/30" },
|
|
688
|
+
{ variant: "nav", active: false, class: "hover:bg-neutral-500/20" }
|
|
689
|
+
],
|
|
690
|
+
defaultVariants: {
|
|
691
|
+
variant: "inline",
|
|
692
|
+
active: false,
|
|
693
|
+
color: "primary"
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
// core/next/link/link.tsx
|
|
698
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
699
|
+
var Link = ({
|
|
700
|
+
children,
|
|
701
|
+
href,
|
|
702
|
+
variant = "inline",
|
|
703
|
+
color = "primary",
|
|
704
|
+
active = false,
|
|
705
|
+
"aria-label": ariaLabel,
|
|
706
|
+
onClick
|
|
707
|
+
}) => {
|
|
708
|
+
return /* @__PURE__ */ jsx9(
|
|
709
|
+
NextLink,
|
|
710
|
+
{
|
|
711
|
+
href,
|
|
712
|
+
"aria-label": ariaLabel,
|
|
713
|
+
onClick,
|
|
714
|
+
className: link({ variant, color, active }),
|
|
715
|
+
...active && { "aria-current": "page" },
|
|
716
|
+
children
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
// core/sidebar/sidebar.tsx
|
|
722
|
+
import { useState } from "react";
|
|
723
|
+
|
|
724
|
+
// core/sidebar/sidebar.styles.ts
|
|
725
|
+
import { tv as tv8 } from "tailwind-variants";
|
|
726
|
+
var sidebar = tv8({
|
|
727
|
+
base: "h-dvh bg-neutral-800 text-neutral-300 flex flex-col overflow-hidden transition-[width] duration-200 divide-y divide-neutral-600/50",
|
|
728
|
+
variants: {
|
|
729
|
+
collapsed: {
|
|
730
|
+
true: "w-14",
|
|
731
|
+
false: "w-64"
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
var nav = tv8({
|
|
736
|
+
base: "flex-1 min-h-0 overflow-y-auto overflow-x-hidden divide-y divide-neutral-600/50"
|
|
737
|
+
});
|
|
738
|
+
var header2 = tv8({
|
|
739
|
+
base: "shrink-0 p-2"
|
|
740
|
+
});
|
|
741
|
+
var section = tv8({
|
|
742
|
+
base: "grid gap-1 p-2"
|
|
743
|
+
});
|
|
744
|
+
var footer = tv8({
|
|
745
|
+
base: "shrink-0 h-16 p-3 flex items-center gap-3",
|
|
746
|
+
variants: {
|
|
747
|
+
collapsed: {
|
|
748
|
+
true: "justify-center"
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
var avatar = tv8({
|
|
753
|
+
base: "shrink-0 size-8 rounded-full bg-neutral-600 text-white text-xs font-medium flex items-center justify-center"
|
|
754
|
+
});
|
|
755
|
+
var userInfo = tv8({
|
|
756
|
+
base: "flex flex-col min-w-0 text-white [&>*]:truncate [&>*:last-child]:text-xs [&>*:last-child]:text-neutral-400"
|
|
757
|
+
});
|
|
758
|
+
var toggleButton = tv8({
|
|
759
|
+
base: "shrink-0 h-14 grid p-2 [&>button]:justify-start [&>button]:px-3 [&>button]:overflow-hidden [&>button]:whitespace-nowrap"
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
// core/sidebar/sidebar.tsx
|
|
763
|
+
import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
764
|
+
var getInitials = (name) => {
|
|
765
|
+
const parts = name.trim().split(/\s+/);
|
|
766
|
+
if (parts.length >= 2) {
|
|
767
|
+
return `${parts[0][0]}${parts[parts.length - 1][0]}`.toUpperCase();
|
|
768
|
+
}
|
|
769
|
+
return (parts[0]?.[0] ?? "").toUpperCase();
|
|
770
|
+
};
|
|
771
|
+
var Sidebar = ({
|
|
772
|
+
sections,
|
|
773
|
+
user,
|
|
774
|
+
activeHref,
|
|
775
|
+
defaultCollapsed = false,
|
|
776
|
+
collapseLabel,
|
|
777
|
+
expandLabel = "Expand sidebar",
|
|
778
|
+
homeHref = "/",
|
|
779
|
+
homeLabel,
|
|
780
|
+
navLabel = "Main navigation",
|
|
781
|
+
logout = {},
|
|
782
|
+
onLogout
|
|
783
|
+
}) => {
|
|
784
|
+
const [collapsed, setCollapsed] = useState(defaultCollapsed);
|
|
785
|
+
const initials = getInitials(user.name);
|
|
786
|
+
const toggleLabel = collapsed ? expandLabel : collapseLabel;
|
|
787
|
+
const toggleIcon = collapsed ? "ChevronRight" : "ChevronLeft";
|
|
788
|
+
const toggle = () => {
|
|
789
|
+
setCollapsed(!collapsed);
|
|
790
|
+
};
|
|
791
|
+
return /* @__PURE__ */ jsxs5("aside", { className: sidebar({ collapsed }), children: [
|
|
792
|
+
homeHref && /* @__PURE__ */ jsx10("div", { className: header2(), children: /* @__PURE__ */ jsxs5(
|
|
793
|
+
Link,
|
|
794
|
+
{
|
|
795
|
+
href: homeHref,
|
|
796
|
+
variant: "nav",
|
|
797
|
+
color: "none",
|
|
798
|
+
active: homeHref === activeHref,
|
|
799
|
+
"aria-label": homeLabel || "Home",
|
|
800
|
+
children: [
|
|
801
|
+
/* @__PURE__ */ jsx10(Icon, { name: "Home" }),
|
|
802
|
+
homeLabel && !collapsed && /* @__PURE__ */ jsx10(Text, { as: "span", variant: "caption", children: homeLabel })
|
|
803
|
+
]
|
|
804
|
+
}
|
|
805
|
+
) }),
|
|
806
|
+
/* @__PURE__ */ jsx10("nav", { "aria-label": navLabel, className: nav(), children: sections.map((sectionData, i) => /* @__PURE__ */ jsx10("div", { className: section(), children: sectionData.items.map((sidebarItem) => /* @__PURE__ */ jsxs5(
|
|
807
|
+
Link,
|
|
808
|
+
{
|
|
809
|
+
href: sidebarItem.href,
|
|
810
|
+
variant: "nav",
|
|
811
|
+
color: "none",
|
|
812
|
+
active: sidebarItem.href === activeHref,
|
|
813
|
+
"aria-label": sidebarItem.label,
|
|
814
|
+
children: [
|
|
815
|
+
/* @__PURE__ */ jsx10(Icon, { name: sidebarItem.icon }),
|
|
816
|
+
!collapsed && /* @__PURE__ */ jsx10(Text, { as: "span", variant: "caption", children: sidebarItem.label })
|
|
817
|
+
]
|
|
818
|
+
},
|
|
819
|
+
sidebarItem.href
|
|
820
|
+
)) }, i)) }),
|
|
821
|
+
/* @__PURE__ */ jsxs5("div", { className: footer({ collapsed }), children: [
|
|
822
|
+
!collapsed && /* @__PURE__ */ jsxs5(Fragment4, { children: [
|
|
823
|
+
/* @__PURE__ */ jsx10("div", { "aria-hidden": "true", className: avatar(), children: initials }),
|
|
824
|
+
/* @__PURE__ */ jsxs5("div", { className: userInfo(), children: [
|
|
825
|
+
/* @__PURE__ */ jsx10(Text, { as: "span", variant: "caption", children: user.name }),
|
|
826
|
+
/* @__PURE__ */ jsx10(Text, { as: "span", variant: "caption", children: user.email })
|
|
827
|
+
] })
|
|
828
|
+
] }),
|
|
829
|
+
/* @__PURE__ */ jsx10(
|
|
830
|
+
SignOutButton,
|
|
831
|
+
{
|
|
832
|
+
label: logout.label,
|
|
833
|
+
confirmTitle: logout.confirmTitle,
|
|
834
|
+
confirmLabel: logout.confirmLabel,
|
|
835
|
+
cancelLabel: logout.cancelLabel,
|
|
836
|
+
errorMessage: logout.errorMessage,
|
|
837
|
+
onSignOut: onLogout
|
|
838
|
+
}
|
|
839
|
+
)
|
|
840
|
+
] }),
|
|
841
|
+
/* @__PURE__ */ jsx10("div", { className: toggleButton(), children: /* @__PURE__ */ jsx10(
|
|
842
|
+
Button,
|
|
843
|
+
{
|
|
844
|
+
color: "ghost",
|
|
845
|
+
icon: toggleIcon,
|
|
846
|
+
"aria-label": toggleLabel,
|
|
847
|
+
onClick: toggle,
|
|
848
|
+
children: !collapsed && collapseLabel
|
|
849
|
+
}
|
|
850
|
+
) })
|
|
851
|
+
] });
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
// core/top-nav/top-nav.tsx
|
|
855
|
+
import { useState as useState2 } from "react";
|
|
856
|
+
|
|
857
|
+
// core/top-nav/top-nav.styles.ts
|
|
858
|
+
import { tv as tv9 } from "tailwind-variants";
|
|
859
|
+
var topNav = tv9({
|
|
860
|
+
slots: {
|
|
861
|
+
// The panels hang from it, so it is their anchor. The safe area keeps the
|
|
862
|
+
// bar under the notch of a phone.
|
|
863
|
+
base: "relative shrink-0 bg-neutral-800 pt-[env(safe-area-inset-top)] text-neutral-300",
|
|
864
|
+
bar: "flex h-14 items-center gap-1 px-2",
|
|
865
|
+
// Takes what the two buttons leave, with the home link in the middle of it.
|
|
866
|
+
home: "flex min-w-0 flex-1 justify-center",
|
|
867
|
+
// Over the page, under the bar, as wide as the screen. It scrolls when the
|
|
868
|
+
// links don't fit in what is left of the screen.
|
|
869
|
+
menu: "absolute inset-x-0 top-full z-10 max-h-[calc(100dvh-3.5rem)] divide-y divide-neutral-600/50 overflow-y-auto border-t border-neutral-600/50 bg-neutral-800 shadow-lg",
|
|
870
|
+
section: "grid gap-1 p-2",
|
|
871
|
+
account: "absolute inset-x-0 top-full z-10 flex items-center gap-3 border-t border-neutral-600/50 bg-neutral-800 p-3 shadow-lg",
|
|
872
|
+
// Text takes no className, so the cut of a long name or email is set from here.
|
|
873
|
+
user: "flex min-w-0 flex-1 flex-col text-white [&>*]:truncate"
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
// core/top-nav/top-nav.tsx
|
|
878
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
879
|
+
var TopNav = ({
|
|
880
|
+
sections,
|
|
881
|
+
user,
|
|
882
|
+
activeHref,
|
|
883
|
+
homeHref = "/",
|
|
884
|
+
homeLabel,
|
|
885
|
+
navLabel = "Main navigation",
|
|
886
|
+
menuLabel = "Menu",
|
|
887
|
+
accountLabel = "Account",
|
|
888
|
+
logout = {},
|
|
889
|
+
onLogout
|
|
890
|
+
}) => {
|
|
891
|
+
const [open, setOpen] = useState2(null);
|
|
892
|
+
const styles = topNav();
|
|
893
|
+
const menuOpen = open === "menu";
|
|
894
|
+
const accountOpen = open === "account";
|
|
895
|
+
const menuIcon = menuOpen ? "X" : "Menu";
|
|
896
|
+
const toggleMenu = () => {
|
|
897
|
+
setOpen(menuOpen ? null : "menu");
|
|
898
|
+
};
|
|
899
|
+
const toggleAccount = () => {
|
|
900
|
+
setOpen(accountOpen ? null : "account");
|
|
901
|
+
};
|
|
902
|
+
const close = () => {
|
|
903
|
+
setOpen(null);
|
|
904
|
+
};
|
|
905
|
+
return /* @__PURE__ */ jsxs6("header", { className: styles.base(), children: [
|
|
906
|
+
/* @__PURE__ */ jsxs6("div", { className: styles.bar(), children: [
|
|
907
|
+
/* @__PURE__ */ jsx11(
|
|
908
|
+
Button,
|
|
909
|
+
{
|
|
910
|
+
color: "ghost",
|
|
911
|
+
size: "lg",
|
|
912
|
+
icon: menuIcon,
|
|
913
|
+
"aria-label": menuLabel,
|
|
914
|
+
"aria-expanded": menuOpen,
|
|
915
|
+
onClick: toggleMenu
|
|
916
|
+
}
|
|
917
|
+
),
|
|
918
|
+
/* @__PURE__ */ jsx11("div", { className: styles.home(), children: homeHref && /* @__PURE__ */ jsxs6(
|
|
919
|
+
Link,
|
|
920
|
+
{
|
|
921
|
+
href: homeHref,
|
|
922
|
+
variant: "nav",
|
|
923
|
+
color: "none",
|
|
924
|
+
active: homeHref === activeHref,
|
|
925
|
+
"aria-label": homeLabel || "Home",
|
|
926
|
+
onClick: close,
|
|
927
|
+
children: [
|
|
928
|
+
/* @__PURE__ */ jsx11(Icon, { name: "Home" }),
|
|
929
|
+
homeLabel && /* @__PURE__ */ jsx11(Text, { as: "span", variant: "caption", children: homeLabel })
|
|
930
|
+
]
|
|
931
|
+
}
|
|
932
|
+
) }),
|
|
933
|
+
/* @__PURE__ */ jsx11(
|
|
934
|
+
Button,
|
|
935
|
+
{
|
|
936
|
+
color: "ghost",
|
|
937
|
+
size: "lg",
|
|
938
|
+
icon: "User",
|
|
939
|
+
"aria-label": accountLabel,
|
|
940
|
+
"aria-expanded": accountOpen,
|
|
941
|
+
onClick: toggleAccount
|
|
942
|
+
}
|
|
943
|
+
)
|
|
944
|
+
] }),
|
|
945
|
+
accountOpen && /* @__PURE__ */ jsxs6("div", { className: styles.account(), children: [
|
|
946
|
+
/* @__PURE__ */ jsxs6("div", { className: styles.user(), children: [
|
|
947
|
+
/* @__PURE__ */ jsx11(Text, { as: "span", variant: "caption", children: user.name }),
|
|
948
|
+
/* @__PURE__ */ jsx11(Text, { as: "span", variant: "caption", children: user.email })
|
|
949
|
+
] }),
|
|
950
|
+
/* @__PURE__ */ jsx11(
|
|
951
|
+
SignOutButton,
|
|
952
|
+
{
|
|
953
|
+
size: "lg",
|
|
954
|
+
label: logout.label,
|
|
955
|
+
confirmTitle: logout.confirmTitle,
|
|
956
|
+
confirmLabel: logout.confirmLabel,
|
|
957
|
+
cancelLabel: logout.cancelLabel,
|
|
958
|
+
errorMessage: logout.errorMessage,
|
|
959
|
+
onSignOut: onLogout
|
|
960
|
+
}
|
|
961
|
+
)
|
|
962
|
+
] }),
|
|
963
|
+
menuOpen && /* @__PURE__ */ jsx11("nav", { "aria-label": navLabel, className: styles.menu(), children: sections.map((section2, i) => /* @__PURE__ */ jsx11("div", { className: styles.section(), children: section2.items.map((item) => /* @__PURE__ */ jsxs6(
|
|
964
|
+
Link,
|
|
965
|
+
{
|
|
966
|
+
href: item.href,
|
|
967
|
+
variant: "nav",
|
|
968
|
+
color: "none",
|
|
969
|
+
active: item.href === activeHref,
|
|
970
|
+
"aria-label": item.label,
|
|
971
|
+
onClick: close,
|
|
972
|
+
children: [
|
|
973
|
+
/* @__PURE__ */ jsx11(Icon, { name: item.icon }),
|
|
974
|
+
/* @__PURE__ */ jsx11(Text, { as: "span", variant: "caption", children: item.label })
|
|
975
|
+
]
|
|
976
|
+
},
|
|
977
|
+
item.href
|
|
978
|
+
)) }, i)) })
|
|
979
|
+
] });
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
// features/toaster/components/toaster/toaster.tsx
|
|
983
|
+
import { useEffect } from "react";
|
|
984
|
+
import { Toaster as SonnerToaster, toast } from "sonner";
|
|
985
|
+
|
|
986
|
+
// features/toaster/components/toaster/toaster.styles.ts
|
|
987
|
+
import { tv as tv10 } from "tailwind-variants";
|
|
988
|
+
var focusOutline = "focus-visible:outline-2! focus-visible:outline-offset-2! focus-visible:outline-current!";
|
|
989
|
+
var toaster = tv10({
|
|
990
|
+
slots: {
|
|
991
|
+
toast: focusOutline,
|
|
992
|
+
closeButton: focusOutline
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
var toasterColors = {
|
|
996
|
+
"--success-text": "var(--color-zl-success-strong)",
|
|
997
|
+
"--success-bg": "color-mix(in oklab, var(--color-zl-success) 15%, white)",
|
|
998
|
+
"--success-border": "color-mix(in oklab, var(--color-zl-success) 30%, white)",
|
|
999
|
+
"--info-text": "var(--color-zl-info-strong)",
|
|
1000
|
+
"--info-bg": "color-mix(in oklab, var(--color-zl-info) 15%, white)",
|
|
1001
|
+
"--info-border": "color-mix(in oklab, var(--color-zl-info) 30%, white)",
|
|
1002
|
+
"--warning-text": "var(--color-zl-warning-strong)",
|
|
1003
|
+
"--warning-bg": "color-mix(in oklab, var(--color-zl-warning) 15%, white)",
|
|
1004
|
+
"--warning-border": "color-mix(in oklab, var(--color-zl-warning) 30%, white)",
|
|
1005
|
+
"--error-text": "var(--color-zl-danger-strong)",
|
|
1006
|
+
"--error-bg": "color-mix(in oklab, var(--color-zl-danger) 15%, white)",
|
|
1007
|
+
"--error-border": "color-mix(in oklab, var(--color-zl-danger) 30%, white)"
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
// features/toaster/components/toaster/toaster.tsx
|
|
1011
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1012
|
+
var Toaster = () => {
|
|
1013
|
+
const toasts = useToastStore((s) => s.toasts);
|
|
1014
|
+
const removeToast = useToastStore((s) => s.removeToast);
|
|
1015
|
+
const { toast: toastStyles, closeButton } = toaster();
|
|
1016
|
+
useEffect(() => {
|
|
1017
|
+
toasts.forEach((t) => {
|
|
1018
|
+
toast[t.type](t.message, { id: `store-${t.id}` });
|
|
1019
|
+
removeToast(t.id);
|
|
1020
|
+
});
|
|
1021
|
+
}, [toasts, removeToast]);
|
|
1022
|
+
return /* @__PURE__ */ jsx12(
|
|
1023
|
+
SonnerToaster,
|
|
549
1024
|
{
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
1025
|
+
position: "bottom-right",
|
|
1026
|
+
richColors: true,
|
|
1027
|
+
closeButton: true,
|
|
1028
|
+
duration: 4e3,
|
|
1029
|
+
expand: true,
|
|
1030
|
+
visibleToasts: 5,
|
|
1031
|
+
style: toasterColors,
|
|
1032
|
+
toastOptions: {
|
|
1033
|
+
classNames: { toast: toastStyles(), closeButton: closeButton() }
|
|
1034
|
+
}
|
|
557
1035
|
}
|
|
558
1036
|
);
|
|
559
1037
|
};
|
|
560
1038
|
|
|
1039
|
+
// features/toaster/components/toaster/index.ts
|
|
1040
|
+
import { toast as toast2 } from "sonner";
|
|
1041
|
+
|
|
561
1042
|
// core/spinner/spinner.const.ts
|
|
562
1043
|
var spinnerIcons = {
|
|
563
1044
|
circle: "LoaderCircle",
|
|
@@ -566,44 +1047,120 @@ var spinnerIcons = {
|
|
|
566
1047
|
};
|
|
567
1048
|
|
|
568
1049
|
// core/spinner/spinner.styles.ts
|
|
569
|
-
import { tv as
|
|
570
|
-
var spinner =
|
|
1050
|
+
import { tv as tv11 } from "tailwind-variants";
|
|
1051
|
+
var spinner = tv11({
|
|
571
1052
|
base: "inline-flex animate-spin"
|
|
572
1053
|
});
|
|
573
1054
|
|
|
574
1055
|
// core/spinner/spinner.tsx
|
|
575
|
-
import { jsx as
|
|
1056
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
576
1057
|
var Spinner = ({
|
|
577
1058
|
variant = "circle",
|
|
578
1059
|
size = "md",
|
|
579
1060
|
label = "Loading"
|
|
580
|
-
}) => /* @__PURE__ */
|
|
1061
|
+
}) => /* @__PURE__ */ jsx13(
|
|
581
1062
|
"span",
|
|
582
1063
|
{
|
|
583
1064
|
"data-testid": "spinner",
|
|
584
1065
|
role: "status",
|
|
585
1066
|
"aria-label": label,
|
|
586
1067
|
className: spinner(),
|
|
587
|
-
children: /* @__PURE__ */
|
|
1068
|
+
children: /* @__PURE__ */ jsx13(Icon, { name: spinnerIcons[variant], size })
|
|
588
1069
|
}
|
|
589
1070
|
);
|
|
590
1071
|
|
|
591
1072
|
// features/app/components/loader/loader.styles.ts
|
|
592
|
-
import { tv as
|
|
593
|
-
var loader =
|
|
1073
|
+
import { tv as tv12 } from "tailwind-variants";
|
|
1074
|
+
var loader = tv12({
|
|
594
1075
|
base: "flex fixed inset-0 justify-center items-center bg-black/20 text-zl-primary z-50"
|
|
595
1076
|
});
|
|
596
1077
|
|
|
597
1078
|
// features/app/components/loader/loader.tsx
|
|
598
|
-
import { jsx as
|
|
1079
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
599
1080
|
var Loader = ({ label = "Loading" }) => {
|
|
600
1081
|
const fetching = useAppStore((s) => s.fetching);
|
|
601
1082
|
if (!fetching) return null;
|
|
602
|
-
return /* @__PURE__ */
|
|
1083
|
+
return /* @__PURE__ */ jsx14("div", { className: loader(), children: /* @__PURE__ */ jsx14(Spinner, { size: "lg", label }) });
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1086
|
+
// features/app/hooks/use-is-desktop/use-is-desktop.ts
|
|
1087
|
+
import { useSyncExternalStore } from "react";
|
|
1088
|
+
|
|
1089
|
+
// features/app/hooks/use-is-desktop/use-is-desktop.const.ts
|
|
1090
|
+
var DESKTOP_QUERY = "(min-width: 768px)";
|
|
1091
|
+
|
|
1092
|
+
// features/app/hooks/use-is-desktop/use-is-desktop.ts
|
|
1093
|
+
var subscribe = (onChange) => {
|
|
1094
|
+
const media = window.matchMedia(DESKTOP_QUERY);
|
|
1095
|
+
media.addEventListener("change", onChange);
|
|
1096
|
+
return () => {
|
|
1097
|
+
media.removeEventListener("change", onChange);
|
|
1098
|
+
};
|
|
1099
|
+
};
|
|
1100
|
+
var isDesktop = () => window.matchMedia(DESKTOP_QUERY).matches;
|
|
1101
|
+
var unknown = () => null;
|
|
1102
|
+
var useIsDesktop = () => useSyncExternalStore(subscribe, isDesktop, unknown);
|
|
1103
|
+
|
|
1104
|
+
// features/app/components/navigation/navigation.tsx
|
|
1105
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1106
|
+
var Navigation = ({
|
|
1107
|
+
mode = "auto",
|
|
1108
|
+
sections,
|
|
1109
|
+
user,
|
|
1110
|
+
activeHref,
|
|
1111
|
+
defaultCollapsed,
|
|
1112
|
+
collapseLabel,
|
|
1113
|
+
expandLabel,
|
|
1114
|
+
homeHref,
|
|
1115
|
+
homeLabel,
|
|
1116
|
+
navLabel,
|
|
1117
|
+
menuLabel,
|
|
1118
|
+
accountLabel,
|
|
1119
|
+
logout,
|
|
1120
|
+
onLogout
|
|
1121
|
+
}) => {
|
|
1122
|
+
const fitsSidebar = useIsDesktop();
|
|
1123
|
+
const desktop = mode === "auto" ? fitsSidebar : mode === "desktop";
|
|
1124
|
+
if (desktop === null) {
|
|
1125
|
+
return null;
|
|
1126
|
+
}
|
|
1127
|
+
if (desktop) {
|
|
1128
|
+
return /* @__PURE__ */ jsx15(
|
|
1129
|
+
Sidebar,
|
|
1130
|
+
{
|
|
1131
|
+
sections,
|
|
1132
|
+
user,
|
|
1133
|
+
activeHref,
|
|
1134
|
+
defaultCollapsed,
|
|
1135
|
+
collapseLabel,
|
|
1136
|
+
expandLabel,
|
|
1137
|
+
homeHref,
|
|
1138
|
+
homeLabel,
|
|
1139
|
+
navLabel,
|
|
1140
|
+
logout,
|
|
1141
|
+
onLogout
|
|
1142
|
+
}
|
|
1143
|
+
);
|
|
1144
|
+
}
|
|
1145
|
+
return /* @__PURE__ */ jsx15(
|
|
1146
|
+
TopNav,
|
|
1147
|
+
{
|
|
1148
|
+
sections,
|
|
1149
|
+
user,
|
|
1150
|
+
activeHref,
|
|
1151
|
+
homeHref,
|
|
1152
|
+
homeLabel,
|
|
1153
|
+
navLabel,
|
|
1154
|
+
menuLabel,
|
|
1155
|
+
accountLabel,
|
|
1156
|
+
logout,
|
|
1157
|
+
onLogout
|
|
1158
|
+
}
|
|
1159
|
+
);
|
|
603
1160
|
};
|
|
604
1161
|
|
|
605
1162
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
606
|
-
import { useState } from "react";
|
|
1163
|
+
import { useState as useState3 } from "react";
|
|
607
1164
|
import { Provider } from "react-redux";
|
|
608
1165
|
|
|
609
1166
|
// core/state/redux/store/store.ts
|
|
@@ -636,7 +1193,7 @@ var createReduxStore = ({
|
|
|
636
1193
|
};
|
|
637
1194
|
|
|
638
1195
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
639
|
-
import { jsx as
|
|
1196
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
640
1197
|
var ReduxProvider = ({
|
|
641
1198
|
children,
|
|
642
1199
|
reducers = {},
|
|
@@ -644,7 +1201,7 @@ var ReduxProvider = ({
|
|
|
644
1201
|
preloadedState = {},
|
|
645
1202
|
coreReducers = {}
|
|
646
1203
|
}) => {
|
|
647
|
-
const [store] =
|
|
1204
|
+
const [store] = useState3(
|
|
648
1205
|
() => createReduxStore({
|
|
649
1206
|
reducers,
|
|
650
1207
|
middlewares,
|
|
@@ -652,7 +1209,7 @@ var ReduxProvider = ({
|
|
|
652
1209
|
coreReducers
|
|
653
1210
|
})
|
|
654
1211
|
);
|
|
655
|
-
return /* @__PURE__ */
|
|
1212
|
+
return /* @__PURE__ */ jsx16(Provider, { store, children });
|
|
656
1213
|
};
|
|
657
1214
|
|
|
658
1215
|
// core/state/zustand/router/router.utils.ts
|
|
@@ -670,8 +1227,8 @@ var splitURLasPath = (urlAsPath) => {
|
|
|
670
1227
|
};
|
|
671
1228
|
|
|
672
1229
|
// core/state/zustand/router/router.store.ts
|
|
673
|
-
import { create as
|
|
674
|
-
import { devtools as
|
|
1230
|
+
import { create as create4 } from "zustand";
|
|
1231
|
+
import { devtools as devtools4 } from "zustand/middleware";
|
|
675
1232
|
|
|
676
1233
|
// core/state/zustand/router/router.const.ts
|
|
677
1234
|
var routerInitialState = {
|
|
@@ -681,8 +1238,8 @@ var routerInitialState = {
|
|
|
681
1238
|
var routerDevtools = { name: "zljs", store: "router" };
|
|
682
1239
|
|
|
683
1240
|
// core/state/zustand/router/router.store.ts
|
|
684
|
-
var useRouterStore =
|
|
685
|
-
|
|
1241
|
+
var useRouterStore = create4()(
|
|
1242
|
+
devtools4(
|
|
686
1243
|
(set) => ({
|
|
687
1244
|
...routerInitialState,
|
|
688
1245
|
setRoute: (urlAsPath) => set({ urlAsPath, query: splitURLasPath(urlAsPath) }, false, "setRoute")
|
|
@@ -692,8 +1249,8 @@ var useRouterStore = create3()(
|
|
|
692
1249
|
);
|
|
693
1250
|
|
|
694
1251
|
// core/state/zustand/page/page.store.ts
|
|
695
|
-
import { create as
|
|
696
|
-
import { devtools as
|
|
1252
|
+
import { create as create5 } from "zustand";
|
|
1253
|
+
import { devtools as devtools5 } from "zustand/middleware";
|
|
697
1254
|
|
|
698
1255
|
// core/state/zustand/page/page.const.ts
|
|
699
1256
|
var pageInitialState = {
|
|
@@ -702,8 +1259,8 @@ var pageInitialState = {
|
|
|
702
1259
|
var pageDevtools = { name: "zljs", store: "page" };
|
|
703
1260
|
|
|
704
1261
|
// core/state/zustand/page/page.store.ts
|
|
705
|
-
var usePageStore =
|
|
706
|
-
|
|
1262
|
+
var usePageStore = create5()(
|
|
1263
|
+
devtools5(
|
|
707
1264
|
(set) => ({
|
|
708
1265
|
...pageInitialState,
|
|
709
1266
|
setTitle: (title2) => set({ title: title2 }, false, "setTitle")
|
|
@@ -713,8 +1270,8 @@ var usePageStore = create4()(
|
|
|
713
1270
|
);
|
|
714
1271
|
|
|
715
1272
|
// core/card/card.styles.ts
|
|
716
|
-
import { tv as
|
|
717
|
-
var card =
|
|
1273
|
+
import { tv as tv13 } from "tailwind-variants";
|
|
1274
|
+
var card = tv13({
|
|
718
1275
|
slots: {
|
|
719
1276
|
// A soft, wide shadow in the color of the card. shadow-sm only spreads 1 to
|
|
720
1277
|
// 3px and reads as part of the border on a white page.
|
|
@@ -744,7 +1301,7 @@ var card = tv9({
|
|
|
744
1301
|
});
|
|
745
1302
|
|
|
746
1303
|
// core/card/card.tsx
|
|
747
|
-
import { jsx as
|
|
1304
|
+
import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
748
1305
|
var Card = ({
|
|
749
1306
|
children,
|
|
750
1307
|
title: title2,
|
|
@@ -752,169 +1309,27 @@ var Card = ({
|
|
|
752
1309
|
message,
|
|
753
1310
|
color = "none"
|
|
754
1311
|
}) => {
|
|
755
|
-
const { base, header:
|
|
1312
|
+
const { base, header: header3 } = card({ color });
|
|
756
1313
|
const messageColor = color === "none" ? "muted" : "none";
|
|
757
|
-
return /* @__PURE__ */
|
|
758
|
-
(title2 || message) && /* @__PURE__ */
|
|
759
|
-
title2 && /* @__PURE__ */
|
|
760
|
-
message && /* @__PURE__ */
|
|
1314
|
+
return /* @__PURE__ */ jsxs7("div", { "data-testid": "card", className: base(), children: [
|
|
1315
|
+
(title2 || message) && /* @__PURE__ */ jsxs7("div", { className: header3(), children: [
|
|
1316
|
+
title2 && /* @__PURE__ */ jsx17(Heading, { level: titleLevel, children: title2 }),
|
|
1317
|
+
message && /* @__PURE__ */ jsx17(Text, { color: messageColor, children: message })
|
|
761
1318
|
] }),
|
|
762
1319
|
children
|
|
763
1320
|
] });
|
|
764
1321
|
};
|
|
765
1322
|
|
|
766
|
-
// features/auth/state/auth.store.ts
|
|
767
|
-
import { create as create5 } from "zustand";
|
|
768
|
-
import { devtools as devtools5 } from "zustand/middleware";
|
|
769
|
-
|
|
770
|
-
// features/auth/state/auth.const.ts
|
|
771
|
-
var authInitialState = {
|
|
772
|
-
status: "loading",
|
|
773
|
-
session: null,
|
|
774
|
-
adapter: null,
|
|
775
|
-
appId: null
|
|
776
|
-
};
|
|
777
|
-
var authDevtools = { name: "zljs", store: "auth" };
|
|
778
|
-
|
|
779
|
-
// features/auth/state/auth.store.ts
|
|
780
|
-
var useAuthStore = create5()(
|
|
781
|
-
devtools5(
|
|
782
|
-
(set) => ({
|
|
783
|
-
...authInitialState,
|
|
784
|
-
setSession: (session) => set(
|
|
785
|
-
{
|
|
786
|
-
session,
|
|
787
|
-
status: session ? "authenticated" : "unauthenticated"
|
|
788
|
-
},
|
|
789
|
-
false,
|
|
790
|
-
"setSession"
|
|
791
|
-
),
|
|
792
|
-
configure: (adapter, appId) => set({ adapter, appId }, false, "configure"),
|
|
793
|
-
reset: () => set(authInitialState, false, "reset")
|
|
794
|
-
}),
|
|
795
|
-
authDevtools
|
|
796
|
-
)
|
|
797
|
-
);
|
|
798
|
-
|
|
799
|
-
// features/auth/state/get-auth-session/get-auth-session.ts
|
|
800
|
-
var getAuthSession = () => useAuthStore.getState().session;
|
|
801
|
-
|
|
802
|
-
// features/auth/hooks/use-auth/use-auth.ts
|
|
803
|
-
var requireAdapter = () => {
|
|
804
|
-
const { adapter } = useAuthStore.getState();
|
|
805
|
-
if (!adapter) {
|
|
806
|
-
throw new Error("useAuth must be used inside <AuthProvider>");
|
|
807
|
-
}
|
|
808
|
-
return adapter;
|
|
809
|
-
};
|
|
810
|
-
var useAuth = () => {
|
|
811
|
-
const status = useAuthStore((s) => s.status);
|
|
812
|
-
const session = useAuthStore((s) => s.session);
|
|
813
|
-
const appId = useAuthStore((s) => s.appId);
|
|
814
|
-
const user = session?.user ?? null;
|
|
815
|
-
return {
|
|
816
|
-
status,
|
|
817
|
-
user,
|
|
818
|
-
role: (appId && user?.roles[appId]) ?? null,
|
|
819
|
-
signInWithOAuth: (provider) => requireAdapter().signInWithOAuth(provider),
|
|
820
|
-
signInWithPassword: (credentials) => requireAdapter().signInWithPassword(credentials),
|
|
821
|
-
signInWithMagicLink: (email) => requireAdapter().signInWithMagicLink(email),
|
|
822
|
-
signOut: () => requireAdapter().signOut()
|
|
823
|
-
};
|
|
824
|
-
};
|
|
825
|
-
|
|
826
|
-
// features/auth/components/sign-out/sign-out-modal.const.ts
|
|
827
|
-
var SIGN_OUT_MODAL_ID = "zljs-sign-out";
|
|
828
|
-
|
|
829
|
-
// features/auth/components/sign-out/sign-out-modal.styles.ts
|
|
830
|
-
import { tv as tv10 } from "tailwind-variants";
|
|
831
|
-
var signOutModal = tv10({
|
|
832
|
-
slots: {
|
|
833
|
-
actions: "flex justify-end gap-2"
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
|
|
837
|
-
// features/auth/components/sign-out/sign-out-modal.tsx
|
|
838
|
-
import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
839
|
-
var SignOutModal = ({
|
|
840
|
-
title: title2 = "Sign out?",
|
|
841
|
-
confirmLabel = "Sign out",
|
|
842
|
-
cancelLabel = "Cancel",
|
|
843
|
-
errorMessage = "Could not sign out. Try again."
|
|
844
|
-
}) => {
|
|
845
|
-
const { signOut } = useAuth();
|
|
846
|
-
const closeModal = useAppStore((s) => s.closeModal);
|
|
847
|
-
const { actions } = signOutModal();
|
|
848
|
-
const stay = () => {
|
|
849
|
-
closeModal(SIGN_OUT_MODAL_ID);
|
|
850
|
-
};
|
|
851
|
-
const leave = () => {
|
|
852
|
-
closeModal(SIGN_OUT_MODAL_ID);
|
|
853
|
-
signOut().catch(() => {
|
|
854
|
-
useToastStore.getState().error(errorMessage);
|
|
855
|
-
});
|
|
856
|
-
};
|
|
857
|
-
return /* @__PURE__ */ jsx12(
|
|
858
|
-
ConnectedModal,
|
|
859
|
-
{
|
|
860
|
-
modalId: SIGN_OUT_MODAL_ID,
|
|
861
|
-
title: title2,
|
|
862
|
-
size: "xs",
|
|
863
|
-
color: "danger",
|
|
864
|
-
children: /* @__PURE__ */ jsxs4("div", { className: actions(), children: [
|
|
865
|
-
/* @__PURE__ */ jsx12(Button, { color: "ghost", onClick: stay, children: cancelLabel }),
|
|
866
|
-
/* @__PURE__ */ jsx12(Button, { color: "danger", onClick: leave, children: confirmLabel })
|
|
867
|
-
] })
|
|
868
|
-
}
|
|
869
|
-
);
|
|
870
|
-
};
|
|
871
|
-
|
|
872
|
-
// features/auth/components/sign-out/sign-out-button.tsx
|
|
873
|
-
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
874
|
-
var SignOutButton = ({
|
|
875
|
-
label = "Sign out",
|
|
876
|
-
confirmTitle,
|
|
877
|
-
confirmLabel,
|
|
878
|
-
cancelLabel,
|
|
879
|
-
errorMessage
|
|
880
|
-
}) => {
|
|
881
|
-
const openModal = useAppStore((s) => s.openModal);
|
|
882
|
-
const ask = () => {
|
|
883
|
-
openModal(SIGN_OUT_MODAL_ID);
|
|
884
|
-
};
|
|
885
|
-
return /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
886
|
-
/* @__PURE__ */ jsx13(
|
|
887
|
-
Button,
|
|
888
|
-
{
|
|
889
|
-
variant: "icon",
|
|
890
|
-
color: "none",
|
|
891
|
-
icon: "LogOut",
|
|
892
|
-
"aria-label": label,
|
|
893
|
-
onClick: ask
|
|
894
|
-
}
|
|
895
|
-
),
|
|
896
|
-
/* @__PURE__ */ jsx13(
|
|
897
|
-
SignOutModal,
|
|
898
|
-
{
|
|
899
|
-
title: confirmTitle,
|
|
900
|
-
confirmLabel,
|
|
901
|
-
cancelLabel,
|
|
902
|
-
errorMessage
|
|
903
|
-
}
|
|
904
|
-
)
|
|
905
|
-
] });
|
|
906
|
-
};
|
|
907
|
-
|
|
908
1323
|
// features/auth/components/access-pending/access-pending.styles.ts
|
|
909
|
-
import { tv as
|
|
910
|
-
var accessPending =
|
|
1324
|
+
import { tv as tv14 } from "tailwind-variants";
|
|
1325
|
+
var accessPending = tv14({
|
|
911
1326
|
slots: {
|
|
912
1327
|
account: "flex items-center justify-between gap-3"
|
|
913
1328
|
}
|
|
914
1329
|
});
|
|
915
1330
|
|
|
916
1331
|
// features/auth/components/access-pending/access-pending.tsx
|
|
917
|
-
import { jsx as
|
|
1332
|
+
import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
918
1333
|
var AccessPending = ({
|
|
919
1334
|
title: title2 = "Waiting for approval",
|
|
920
1335
|
message = "Your access to this app has not been approved yet.",
|
|
@@ -929,9 +1344,9 @@ var AccessPending = ({
|
|
|
929
1344
|
if (!user) {
|
|
930
1345
|
return null;
|
|
931
1346
|
}
|
|
932
|
-
return /* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
1347
|
+
return /* @__PURE__ */ jsx18(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsxs8("div", { className: account(), children: [
|
|
1348
|
+
/* @__PURE__ */ jsx18(Text, { variant: "caption", color: "muted", children: user.email }),
|
|
1349
|
+
/* @__PURE__ */ jsx18(
|
|
935
1350
|
SignOutButton,
|
|
936
1351
|
{
|
|
937
1352
|
label: signOutLabel,
|
|
@@ -946,7 +1361,7 @@ var AccessPending = ({
|
|
|
946
1361
|
|
|
947
1362
|
// features/auth/components/auth-provider/auth-provider.tsx
|
|
948
1363
|
import { useEffect as useEffect2 } from "react";
|
|
949
|
-
import { Fragment as
|
|
1364
|
+
import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
|
|
950
1365
|
var AuthProvider = ({
|
|
951
1366
|
adapter,
|
|
952
1367
|
appId,
|
|
@@ -963,7 +1378,7 @@ var AuthProvider = ({
|
|
|
963
1378
|
reset();
|
|
964
1379
|
};
|
|
965
1380
|
}, [adapter, appId, configure, setSession, reset]);
|
|
966
|
-
return /* @__PURE__ */
|
|
1381
|
+
return /* @__PURE__ */ jsx19(Fragment5, { children });
|
|
967
1382
|
};
|
|
968
1383
|
|
|
969
1384
|
// features/auth/components/login/login.const.ts
|
|
@@ -977,15 +1392,15 @@ var loginVendors = {
|
|
|
977
1392
|
};
|
|
978
1393
|
|
|
979
1394
|
// features/auth/components/login/login.styles.ts
|
|
980
|
-
import { tv as
|
|
981
|
-
var login =
|
|
1395
|
+
import { tv as tv15 } from "tailwind-variants";
|
|
1396
|
+
var login = tv15({
|
|
982
1397
|
slots: {
|
|
983
1398
|
options: "flex flex-col gap-3"
|
|
984
1399
|
}
|
|
985
1400
|
});
|
|
986
1401
|
|
|
987
1402
|
// features/auth/components/login/login.tsx
|
|
988
|
-
import { jsx as
|
|
1403
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
989
1404
|
var LoginProviderButton = ({
|
|
990
1405
|
id,
|
|
991
1406
|
label,
|
|
@@ -994,7 +1409,7 @@ var LoginProviderButton = ({
|
|
|
994
1409
|
const signIn = () => {
|
|
995
1410
|
onSignIn(id);
|
|
996
1411
|
};
|
|
997
|
-
return /* @__PURE__ */
|
|
1412
|
+
return /* @__PURE__ */ jsx20(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
|
|
998
1413
|
};
|
|
999
1414
|
var Login = ({
|
|
1000
1415
|
vendor,
|
|
@@ -1012,9 +1427,9 @@ var Login = ({
|
|
|
1012
1427
|
useToastStore.getState().error(errorMessage);
|
|
1013
1428
|
});
|
|
1014
1429
|
};
|
|
1015
|
-
return /* @__PURE__ */
|
|
1430
|
+
return /* @__PURE__ */ jsx20(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx20("div", { className: options(), children: providers.map((provider) => {
|
|
1016
1431
|
const id = String(provider);
|
|
1017
|
-
return /* @__PURE__ */
|
|
1432
|
+
return /* @__PURE__ */ jsx20(
|
|
1018
1433
|
LoginProviderButton,
|
|
1019
1434
|
{
|
|
1020
1435
|
id,
|
|
@@ -1027,7 +1442,7 @@ var Login = ({
|
|
|
1027
1442
|
};
|
|
1028
1443
|
|
|
1029
1444
|
// features/auth/components/authorized/authorized.tsx
|
|
1030
|
-
import { Fragment as
|
|
1445
|
+
import { Fragment as Fragment6, jsx as jsx21 } from "react/jsx-runtime";
|
|
1031
1446
|
var Authorized = ({
|
|
1032
1447
|
children,
|
|
1033
1448
|
roles,
|
|
@@ -1036,18 +1451,18 @@ var Authorized = ({
|
|
|
1036
1451
|
}) => {
|
|
1037
1452
|
const { status, user, role } = useAuth();
|
|
1038
1453
|
if (status === "loading") return null;
|
|
1039
|
-
if (!user) return /* @__PURE__ */
|
|
1454
|
+
if (!user) return /* @__PURE__ */ jsx21(Login, { ...login2 });
|
|
1040
1455
|
const hasRole = !roles || role !== null && roles.includes(role);
|
|
1041
|
-
if (!user.hasAccess || !hasRole) return /* @__PURE__ */
|
|
1042
|
-
return /* @__PURE__ */
|
|
1456
|
+
if (!user.hasAccess || !hasRole) return /* @__PURE__ */ jsx21(AccessPending, { ...accessPending2 });
|
|
1457
|
+
return /* @__PURE__ */ jsx21(Fragment6, { children });
|
|
1043
1458
|
};
|
|
1044
1459
|
|
|
1045
1460
|
// features/providers/components/zustand-providers/zustand-providers.tsx
|
|
1046
|
-
import { Fragment as
|
|
1047
|
-
var ZustandProviders = ({ children, auth }) => /* @__PURE__ */
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
1050
|
-
auth ? /* @__PURE__ */
|
|
1461
|
+
import { Fragment as Fragment7, jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1462
|
+
var ZustandProviders = ({ children, auth }) => /* @__PURE__ */ jsxs9(Fragment7, { children: [
|
|
1463
|
+
/* @__PURE__ */ jsx22(Loader, {}),
|
|
1464
|
+
/* @__PURE__ */ jsx22(Toaster, {}),
|
|
1465
|
+
auth ? /* @__PURE__ */ jsx22(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
|
|
1051
1466
|
] });
|
|
1052
1467
|
|
|
1053
1468
|
export {
|
|
@@ -1056,22 +1471,27 @@ export {
|
|
|
1056
1471
|
Text,
|
|
1057
1472
|
Modal,
|
|
1058
1473
|
Heading,
|
|
1059
|
-
useToastStore,
|
|
1060
|
-
Toaster,
|
|
1061
|
-
toast2 as toast,
|
|
1062
1474
|
appInitialState,
|
|
1063
1475
|
useAppStore,
|
|
1064
1476
|
ConnectedModal,
|
|
1477
|
+
useToastStore,
|
|
1478
|
+
getAuthSession,
|
|
1479
|
+
useAuth,
|
|
1480
|
+
SignOutButton,
|
|
1481
|
+
Link,
|
|
1482
|
+
Sidebar,
|
|
1483
|
+
TopNav,
|
|
1484
|
+
Toaster,
|
|
1485
|
+
toast2 as toast,
|
|
1065
1486
|
Spinner,
|
|
1066
1487
|
Loader,
|
|
1488
|
+
useIsDesktop,
|
|
1489
|
+
Navigation,
|
|
1067
1490
|
ReduxProvider,
|
|
1068
1491
|
splitURLasPath,
|
|
1069
1492
|
useRouterStore,
|
|
1070
1493
|
usePageStore,
|
|
1071
1494
|
Card,
|
|
1072
|
-
getAuthSession,
|
|
1073
|
-
useAuth,
|
|
1074
|
-
SignOutButton,
|
|
1075
1495
|
AccessPending,
|
|
1076
1496
|
AuthProvider,
|
|
1077
1497
|
Login,
|