@alexandregme/zljs 3.9.0 → 3.11.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 +40 -1
- package/dist/{chunk-JMEGXQKC.js → chunk-XRJCFNLC.js} +354 -289
- package/dist/index.d.ts +61 -19
- package/dist/index.js +98 -53
- package/dist/next/index.d.ts +9 -2
- package/dist/next/index.js +18 -47
- package/package.json +2 -1
|
@@ -373,9 +373,95 @@ var Heading = ({ children, level = 1, color }) => {
|
|
|
373
373
|
return /* @__PURE__ */ jsx5(Tag, { className: heading({ level, color }), children });
|
|
374
374
|
};
|
|
375
375
|
|
|
376
|
-
// features/
|
|
376
|
+
// features/app/state/app.const.ts
|
|
377
|
+
var appInitialState = {
|
|
378
|
+
fetchingCalls: 0,
|
|
379
|
+
fetching: false,
|
|
380
|
+
modals: {}
|
|
381
|
+
};
|
|
382
|
+
var appDevtools = { name: "zljs", store: "app" };
|
|
383
|
+
|
|
384
|
+
// features/app/state/app.store.ts
|
|
377
385
|
import { create } from "zustand";
|
|
378
386
|
import { devtools } from "zustand/middleware";
|
|
387
|
+
var useAppStore = create()(
|
|
388
|
+
devtools(
|
|
389
|
+
(set, get) => ({
|
|
390
|
+
...appInitialState,
|
|
391
|
+
startFetching: () => set(
|
|
392
|
+
(s) => {
|
|
393
|
+
const fetchingCalls = s.fetchingCalls + 1;
|
|
394
|
+
return { fetchingCalls, fetching: true };
|
|
395
|
+
},
|
|
396
|
+
false,
|
|
397
|
+
"startFetching"
|
|
398
|
+
),
|
|
399
|
+
finishFetching: () => set(
|
|
400
|
+
(s) => {
|
|
401
|
+
const fetchingCalls = Math.max(0, s.fetchingCalls - 1);
|
|
402
|
+
return { fetchingCalls, fetching: fetchingCalls > 0 };
|
|
403
|
+
},
|
|
404
|
+
false,
|
|
405
|
+
"finishFetching"
|
|
406
|
+
),
|
|
407
|
+
openModal: (id) => set(
|
|
408
|
+
(s) => ({ modals: { ...s.modals, [id]: void 0 } }),
|
|
409
|
+
false,
|
|
410
|
+
"openModal"
|
|
411
|
+
),
|
|
412
|
+
openModalWithPayload: (id, payload) => set(
|
|
413
|
+
(s) => ({ modals: { ...s.modals, [id]: payload } }),
|
|
414
|
+
false,
|
|
415
|
+
"openModalWithPayload"
|
|
416
|
+
),
|
|
417
|
+
closeModal: (id) => set(
|
|
418
|
+
(s) => {
|
|
419
|
+
const modals = { ...s.modals };
|
|
420
|
+
delete modals[id];
|
|
421
|
+
return { modals };
|
|
422
|
+
},
|
|
423
|
+
false,
|
|
424
|
+
"closeModal"
|
|
425
|
+
),
|
|
426
|
+
isModalOpen: (id) => Object.keys(get().modals).includes(id),
|
|
427
|
+
getModalPayload: (id) => get().modals[id]
|
|
428
|
+
}),
|
|
429
|
+
appDevtools
|
|
430
|
+
)
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
// features/app/components/connected-modal/connected-modal.tsx
|
|
434
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
435
|
+
var ConnectedModal = ({
|
|
436
|
+
modalId,
|
|
437
|
+
title: title2,
|
|
438
|
+
description: description2,
|
|
439
|
+
size,
|
|
440
|
+
color,
|
|
441
|
+
children
|
|
442
|
+
}) => {
|
|
443
|
+
const open = useAppStore((s) => s.isModalOpen(modalId));
|
|
444
|
+
const closeModal = useAppStore((s) => s.closeModal);
|
|
445
|
+
const close = () => {
|
|
446
|
+
closeModal(modalId);
|
|
447
|
+
};
|
|
448
|
+
return /* @__PURE__ */ jsx6(
|
|
449
|
+
Modal,
|
|
450
|
+
{
|
|
451
|
+
open,
|
|
452
|
+
onClose: close,
|
|
453
|
+
title: title2,
|
|
454
|
+
description: description2,
|
|
455
|
+
size,
|
|
456
|
+
color,
|
|
457
|
+
children
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
// features/toaster/state/toast.store.ts
|
|
463
|
+
import { create as create2 } from "zustand";
|
|
464
|
+
import { devtools as devtools2 } from "zustand/middleware";
|
|
379
465
|
|
|
380
466
|
// features/toaster/state/toast.const.ts
|
|
381
467
|
var toastInitialState = {
|
|
@@ -385,8 +471,8 @@ var toastDevtools = { name: "zljs", store: "toast" };
|
|
|
385
471
|
|
|
386
472
|
// features/toaster/state/toast.store.ts
|
|
387
473
|
var toastId = 0;
|
|
388
|
-
var useToastStore =
|
|
389
|
-
|
|
474
|
+
var useToastStore = create2()(
|
|
475
|
+
devtools2(
|
|
390
476
|
(set, get) => ({
|
|
391
477
|
...toastInitialState,
|
|
392
478
|
addToast: (message, type = "error") => {
|
|
@@ -412,14 +498,220 @@ var useToastStore = create()(
|
|
|
412
498
|
)
|
|
413
499
|
);
|
|
414
500
|
|
|
501
|
+
// features/auth/state/auth.store.ts
|
|
502
|
+
import { create as create3 } from "zustand";
|
|
503
|
+
import { devtools as devtools3 } from "zustand/middleware";
|
|
504
|
+
|
|
505
|
+
// features/auth/state/auth.const.ts
|
|
506
|
+
var authInitialState = {
|
|
507
|
+
status: "loading",
|
|
508
|
+
session: null,
|
|
509
|
+
adapter: null,
|
|
510
|
+
appId: null
|
|
511
|
+
};
|
|
512
|
+
var authDevtools = { name: "zljs", store: "auth" };
|
|
513
|
+
|
|
514
|
+
// features/auth/state/auth.store.ts
|
|
515
|
+
var useAuthStore = create3()(
|
|
516
|
+
devtools3(
|
|
517
|
+
(set) => ({
|
|
518
|
+
...authInitialState,
|
|
519
|
+
setSession: (session) => set(
|
|
520
|
+
{
|
|
521
|
+
session,
|
|
522
|
+
status: session ? "authenticated" : "unauthenticated"
|
|
523
|
+
},
|
|
524
|
+
false,
|
|
525
|
+
"setSession"
|
|
526
|
+
),
|
|
527
|
+
configure: (adapter, appId) => set({ adapter, appId }, false, "configure"),
|
|
528
|
+
reset: () => set(authInitialState, false, "reset")
|
|
529
|
+
}),
|
|
530
|
+
authDevtools
|
|
531
|
+
)
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
// features/auth/state/get-auth-session/get-auth-session.ts
|
|
535
|
+
var getAuthSession = () => useAuthStore.getState().session;
|
|
536
|
+
|
|
537
|
+
// features/auth/hooks/use-auth/use-auth.ts
|
|
538
|
+
var requireAdapter = () => {
|
|
539
|
+
const { adapter } = useAuthStore.getState();
|
|
540
|
+
if (!adapter) {
|
|
541
|
+
throw new Error("useAuth must be used inside <AuthProvider>");
|
|
542
|
+
}
|
|
543
|
+
return adapter;
|
|
544
|
+
};
|
|
545
|
+
var useAuth = () => {
|
|
546
|
+
const status = useAuthStore((s) => s.status);
|
|
547
|
+
const session = useAuthStore((s) => s.session);
|
|
548
|
+
const appId = useAuthStore((s) => s.appId);
|
|
549
|
+
const user = session?.user ?? null;
|
|
550
|
+
return {
|
|
551
|
+
status,
|
|
552
|
+
user,
|
|
553
|
+
role: (appId && user?.roles[appId]) ?? null,
|
|
554
|
+
signInWithOAuth: (provider) => requireAdapter().signInWithOAuth(provider),
|
|
555
|
+
signInWithPassword: (credentials) => requireAdapter().signInWithPassword(credentials),
|
|
556
|
+
signInWithMagicLink: (email) => requireAdapter().signInWithMagicLink(email),
|
|
557
|
+
signOut: () => requireAdapter().signOut()
|
|
558
|
+
};
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
// features/auth/components/sign-out/sign-out-modal.const.ts
|
|
562
|
+
var SIGN_OUT_MODAL_ID = "zljs-sign-out";
|
|
563
|
+
|
|
564
|
+
// features/auth/components/sign-out/sign-out-modal.styles.ts
|
|
565
|
+
import { tv as tv6 } from "tailwind-variants";
|
|
566
|
+
var signOutModal = tv6({
|
|
567
|
+
slots: {
|
|
568
|
+
actions: "flex justify-end gap-2"
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
// features/auth/components/sign-out/sign-out-modal.tsx
|
|
573
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
574
|
+
var SignOutModal = ({
|
|
575
|
+
title: title2 = "Sign out?",
|
|
576
|
+
confirmLabel = "Sign out",
|
|
577
|
+
cancelLabel = "Cancel",
|
|
578
|
+
errorMessage = "Could not sign out. Try again.",
|
|
579
|
+
onSignOut
|
|
580
|
+
}) => {
|
|
581
|
+
const { signOut } = useAuth();
|
|
582
|
+
const closeModal = useAppStore((s) => s.closeModal);
|
|
583
|
+
const { actions } = signOutModal();
|
|
584
|
+
const stay = () => {
|
|
585
|
+
closeModal(SIGN_OUT_MODAL_ID);
|
|
586
|
+
};
|
|
587
|
+
const signOutOfApp = async () => {
|
|
588
|
+
if (onSignOut) {
|
|
589
|
+
await onSignOut();
|
|
590
|
+
} else {
|
|
591
|
+
await signOut();
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
const showError = () => {
|
|
595
|
+
useToastStore.getState().error(errorMessage);
|
|
596
|
+
};
|
|
597
|
+
const leave = () => {
|
|
598
|
+
closeModal(SIGN_OUT_MODAL_ID);
|
|
599
|
+
signOutOfApp().catch(showError);
|
|
600
|
+
};
|
|
601
|
+
return /* @__PURE__ */ jsx7(
|
|
602
|
+
ConnectedModal,
|
|
603
|
+
{
|
|
604
|
+
modalId: SIGN_OUT_MODAL_ID,
|
|
605
|
+
title: title2,
|
|
606
|
+
size: "xs",
|
|
607
|
+
color: "danger",
|
|
608
|
+
children: /* @__PURE__ */ jsxs3("div", { className: actions(), children: [
|
|
609
|
+
/* @__PURE__ */ jsx7(Button, { color: "ghost", onClick: stay, children: cancelLabel }),
|
|
610
|
+
/* @__PURE__ */ jsx7(Button, { color: "danger", onClick: leave, children: confirmLabel })
|
|
611
|
+
] })
|
|
612
|
+
}
|
|
613
|
+
);
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
// features/auth/components/sign-out/sign-out-button.tsx
|
|
617
|
+
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
618
|
+
var SignOutButton = ({
|
|
619
|
+
label = "Sign out",
|
|
620
|
+
confirmTitle,
|
|
621
|
+
confirmLabel,
|
|
622
|
+
cancelLabel,
|
|
623
|
+
errorMessage,
|
|
624
|
+
onSignOut
|
|
625
|
+
}) => {
|
|
626
|
+
const openModal = useAppStore((s) => s.openModal);
|
|
627
|
+
const ask = () => {
|
|
628
|
+
openModal(SIGN_OUT_MODAL_ID);
|
|
629
|
+
};
|
|
630
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
631
|
+
/* @__PURE__ */ jsx8(Button, { color: "ghost", icon: "LogOut", "aria-label": label, onClick: ask }),
|
|
632
|
+
/* @__PURE__ */ jsx8(
|
|
633
|
+
SignOutModal,
|
|
634
|
+
{
|
|
635
|
+
title: confirmTitle,
|
|
636
|
+
confirmLabel,
|
|
637
|
+
cancelLabel,
|
|
638
|
+
errorMessage,
|
|
639
|
+
onSignOut
|
|
640
|
+
}
|
|
641
|
+
)
|
|
642
|
+
] });
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
// core/next/link/link.tsx
|
|
646
|
+
import NextLink from "next/link.js";
|
|
647
|
+
|
|
648
|
+
// core/next/link/link.styles.ts
|
|
649
|
+
import { tv as tv7 } from "tailwind-variants";
|
|
650
|
+
var link = tv7({
|
|
651
|
+
// outline-current draws the focus in the text color.
|
|
652
|
+
base: "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current",
|
|
653
|
+
variants: {
|
|
654
|
+
variant: {
|
|
655
|
+
// The invisible ::after grows the touch target to 44px without changing the layout.
|
|
656
|
+
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",
|
|
657
|
+
// A row of a menu. The translucent backgrounds work on a light or a dark surface.
|
|
658
|
+
nav: "flex h-10 items-center gap-2 overflow-hidden rounded-md px-3 whitespace-nowrap transition-colors"
|
|
659
|
+
},
|
|
660
|
+
active: {
|
|
661
|
+
true: "",
|
|
662
|
+
false: ""
|
|
663
|
+
},
|
|
664
|
+
color: {
|
|
665
|
+
primary: "text-zl-primary hover:text-zl-primary-strong",
|
|
666
|
+
success: "text-zl-success hover:text-zl-success-strong",
|
|
667
|
+
danger: "text-zl-danger hover:text-zl-danger-strong",
|
|
668
|
+
warning: "text-zl-warning hover:text-zl-warning-strong",
|
|
669
|
+
info: "text-zl-info hover:text-zl-info-strong",
|
|
670
|
+
muted: "text-zl-muted hover:text-zl-muted-strong",
|
|
671
|
+
none: ""
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
compoundVariants: [
|
|
675
|
+
{ variant: "nav", active: true, class: "bg-neutral-500/30" },
|
|
676
|
+
{ variant: "nav", active: false, class: "hover:bg-neutral-500/20" }
|
|
677
|
+
],
|
|
678
|
+
defaultVariants: {
|
|
679
|
+
variant: "inline",
|
|
680
|
+
active: false,
|
|
681
|
+
color: "primary"
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
// core/next/link/link.tsx
|
|
686
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
687
|
+
var Link = ({
|
|
688
|
+
children,
|
|
689
|
+
href,
|
|
690
|
+
variant = "inline",
|
|
691
|
+
color = "primary",
|
|
692
|
+
active = false,
|
|
693
|
+
"aria-label": ariaLabel
|
|
694
|
+
}) => {
|
|
695
|
+
return /* @__PURE__ */ jsx9(
|
|
696
|
+
NextLink,
|
|
697
|
+
{
|
|
698
|
+
href,
|
|
699
|
+
"aria-label": ariaLabel,
|
|
700
|
+
className: link({ variant, color, active }),
|
|
701
|
+
...active && { "aria-current": "page" },
|
|
702
|
+
children
|
|
703
|
+
}
|
|
704
|
+
);
|
|
705
|
+
};
|
|
706
|
+
|
|
415
707
|
// features/toaster/components/toaster/toaster.tsx
|
|
416
708
|
import { useEffect } from "react";
|
|
417
709
|
import { Toaster as SonnerToaster, toast } from "sonner";
|
|
418
710
|
|
|
419
711
|
// features/toaster/components/toaster/toaster.styles.ts
|
|
420
|
-
import { tv as
|
|
712
|
+
import { tv as tv8 } from "tailwind-variants";
|
|
421
713
|
var focusOutline = "focus-visible:outline-2! focus-visible:outline-offset-2! focus-visible:outline-current!";
|
|
422
|
-
var toaster =
|
|
714
|
+
var toaster = tv8({
|
|
423
715
|
slots: {
|
|
424
716
|
toast: focusOutline,
|
|
425
717
|
closeButton: focusOutline
|
|
@@ -441,7 +733,7 @@ var toasterColors = {
|
|
|
441
733
|
};
|
|
442
734
|
|
|
443
735
|
// features/toaster/components/toaster/toaster.tsx
|
|
444
|
-
import { jsx as
|
|
736
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
445
737
|
var Toaster = () => {
|
|
446
738
|
const toasts = useToastStore((s) => s.toasts);
|
|
447
739
|
const removeToast = useToastStore((s) => s.removeToast);
|
|
@@ -452,7 +744,7 @@ var Toaster = () => {
|
|
|
452
744
|
removeToast(t.id);
|
|
453
745
|
});
|
|
454
746
|
}, [toasts, removeToast]);
|
|
455
|
-
return /* @__PURE__ */
|
|
747
|
+
return /* @__PURE__ */ jsx10(
|
|
456
748
|
SonnerToaster,
|
|
457
749
|
{
|
|
458
750
|
position: "bottom-right",
|
|
@@ -472,92 +764,6 @@ var Toaster = () => {
|
|
|
472
764
|
// features/toaster/components/toaster/index.ts
|
|
473
765
|
import { toast as toast2 } from "sonner";
|
|
474
766
|
|
|
475
|
-
// features/app/state/app.const.ts
|
|
476
|
-
var appInitialState = {
|
|
477
|
-
fetchingCalls: 0,
|
|
478
|
-
fetching: false,
|
|
479
|
-
modals: {}
|
|
480
|
-
};
|
|
481
|
-
var appDevtools = { name: "zljs", store: "app" };
|
|
482
|
-
|
|
483
|
-
// features/app/state/app.store.ts
|
|
484
|
-
import { create as create2 } from "zustand";
|
|
485
|
-
import { devtools as devtools2 } from "zustand/middleware";
|
|
486
|
-
var useAppStore = create2()(
|
|
487
|
-
devtools2(
|
|
488
|
-
(set, get) => ({
|
|
489
|
-
...appInitialState,
|
|
490
|
-
startFetching: () => set(
|
|
491
|
-
(s) => {
|
|
492
|
-
const fetchingCalls = s.fetchingCalls + 1;
|
|
493
|
-
return { fetchingCalls, fetching: true };
|
|
494
|
-
},
|
|
495
|
-
false,
|
|
496
|
-
"startFetching"
|
|
497
|
-
),
|
|
498
|
-
finishFetching: () => set(
|
|
499
|
-
(s) => {
|
|
500
|
-
const fetchingCalls = Math.max(0, s.fetchingCalls - 1);
|
|
501
|
-
return { fetchingCalls, fetching: fetchingCalls > 0 };
|
|
502
|
-
},
|
|
503
|
-
false,
|
|
504
|
-
"finishFetching"
|
|
505
|
-
),
|
|
506
|
-
openModal: (id) => set(
|
|
507
|
-
(s) => ({ modals: { ...s.modals, [id]: void 0 } }),
|
|
508
|
-
false,
|
|
509
|
-
"openModal"
|
|
510
|
-
),
|
|
511
|
-
openModalWithPayload: (id, payload) => set(
|
|
512
|
-
(s) => ({ modals: { ...s.modals, [id]: payload } }),
|
|
513
|
-
false,
|
|
514
|
-
"openModalWithPayload"
|
|
515
|
-
),
|
|
516
|
-
closeModal: (id) => set(
|
|
517
|
-
(s) => {
|
|
518
|
-
const modals = { ...s.modals };
|
|
519
|
-
delete modals[id];
|
|
520
|
-
return { modals };
|
|
521
|
-
},
|
|
522
|
-
false,
|
|
523
|
-
"closeModal"
|
|
524
|
-
),
|
|
525
|
-
isModalOpen: (id) => Object.keys(get().modals).includes(id),
|
|
526
|
-
getModalPayload: (id) => get().modals[id]
|
|
527
|
-
}),
|
|
528
|
-
appDevtools
|
|
529
|
-
)
|
|
530
|
-
);
|
|
531
|
-
|
|
532
|
-
// features/app/components/connected-modal/connected-modal.tsx
|
|
533
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
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__ */ jsx7(
|
|
548
|
-
Modal,
|
|
549
|
-
{
|
|
550
|
-
open,
|
|
551
|
-
onClose: close,
|
|
552
|
-
title: title2,
|
|
553
|
-
description: description2,
|
|
554
|
-
size,
|
|
555
|
-
color,
|
|
556
|
-
children
|
|
557
|
-
}
|
|
558
|
-
);
|
|
559
|
-
};
|
|
560
|
-
|
|
561
767
|
// core/spinner/spinner.const.ts
|
|
562
768
|
var spinnerIcons = {
|
|
563
769
|
circle: "LoaderCircle",
|
|
@@ -566,40 +772,40 @@ var spinnerIcons = {
|
|
|
566
772
|
};
|
|
567
773
|
|
|
568
774
|
// core/spinner/spinner.styles.ts
|
|
569
|
-
import { tv as
|
|
570
|
-
var spinner =
|
|
775
|
+
import { tv as tv9 } from "tailwind-variants";
|
|
776
|
+
var spinner = tv9({
|
|
571
777
|
base: "inline-flex animate-spin"
|
|
572
778
|
});
|
|
573
779
|
|
|
574
780
|
// core/spinner/spinner.tsx
|
|
575
|
-
import { jsx as
|
|
781
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
576
782
|
var Spinner = ({
|
|
577
783
|
variant = "circle",
|
|
578
784
|
size = "md",
|
|
579
785
|
label = "Loading"
|
|
580
|
-
}) => /* @__PURE__ */
|
|
786
|
+
}) => /* @__PURE__ */ jsx11(
|
|
581
787
|
"span",
|
|
582
788
|
{
|
|
583
789
|
"data-testid": "spinner",
|
|
584
790
|
role: "status",
|
|
585
791
|
"aria-label": label,
|
|
586
792
|
className: spinner(),
|
|
587
|
-
children: /* @__PURE__ */
|
|
793
|
+
children: /* @__PURE__ */ jsx11(Icon, { name: spinnerIcons[variant], size })
|
|
588
794
|
}
|
|
589
795
|
);
|
|
590
796
|
|
|
591
797
|
// features/app/components/loader/loader.styles.ts
|
|
592
|
-
import { tv as
|
|
593
|
-
var loader =
|
|
798
|
+
import { tv as tv10 } from "tailwind-variants";
|
|
799
|
+
var loader = tv10({
|
|
594
800
|
base: "flex fixed inset-0 justify-center items-center bg-black/20 text-zl-primary z-50"
|
|
595
801
|
});
|
|
596
802
|
|
|
597
803
|
// features/app/components/loader/loader.tsx
|
|
598
|
-
import { jsx as
|
|
804
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
599
805
|
var Loader = ({ label = "Loading" }) => {
|
|
600
806
|
const fetching = useAppStore((s) => s.fetching);
|
|
601
807
|
if (!fetching) return null;
|
|
602
|
-
return /* @__PURE__ */
|
|
808
|
+
return /* @__PURE__ */ jsx12("div", { className: loader(), children: /* @__PURE__ */ jsx12(Spinner, { size: "lg", label }) });
|
|
603
809
|
};
|
|
604
810
|
|
|
605
811
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
@@ -636,7 +842,7 @@ var createReduxStore = ({
|
|
|
636
842
|
};
|
|
637
843
|
|
|
638
844
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
639
|
-
import { jsx as
|
|
845
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
640
846
|
var ReduxProvider = ({
|
|
641
847
|
children,
|
|
642
848
|
reducers = {},
|
|
@@ -652,7 +858,7 @@ var ReduxProvider = ({
|
|
|
652
858
|
coreReducers
|
|
653
859
|
})
|
|
654
860
|
);
|
|
655
|
-
return /* @__PURE__ */
|
|
861
|
+
return /* @__PURE__ */ jsx13(Provider, { store, children });
|
|
656
862
|
};
|
|
657
863
|
|
|
658
864
|
// core/state/zustand/router/router.utils.ts
|
|
@@ -670,8 +876,8 @@ var splitURLasPath = (urlAsPath) => {
|
|
|
670
876
|
};
|
|
671
877
|
|
|
672
878
|
// core/state/zustand/router/router.store.ts
|
|
673
|
-
import { create as
|
|
674
|
-
import { devtools as
|
|
879
|
+
import { create as create4 } from "zustand";
|
|
880
|
+
import { devtools as devtools4 } from "zustand/middleware";
|
|
675
881
|
|
|
676
882
|
// core/state/zustand/router/router.const.ts
|
|
677
883
|
var routerInitialState = {
|
|
@@ -681,8 +887,8 @@ var routerInitialState = {
|
|
|
681
887
|
var routerDevtools = { name: "zljs", store: "router" };
|
|
682
888
|
|
|
683
889
|
// core/state/zustand/router/router.store.ts
|
|
684
|
-
var useRouterStore =
|
|
685
|
-
|
|
890
|
+
var useRouterStore = create4()(
|
|
891
|
+
devtools4(
|
|
686
892
|
(set) => ({
|
|
687
893
|
...routerInitialState,
|
|
688
894
|
setRoute: (urlAsPath) => set({ urlAsPath, query: splitURLasPath(urlAsPath) }, false, "setRoute")
|
|
@@ -692,8 +898,8 @@ var useRouterStore = create3()(
|
|
|
692
898
|
);
|
|
693
899
|
|
|
694
900
|
// core/state/zustand/page/page.store.ts
|
|
695
|
-
import { create as
|
|
696
|
-
import { devtools as
|
|
901
|
+
import { create as create5 } from "zustand";
|
|
902
|
+
import { devtools as devtools5 } from "zustand/middleware";
|
|
697
903
|
|
|
698
904
|
// core/state/zustand/page/page.const.ts
|
|
699
905
|
var pageInitialState = {
|
|
@@ -702,8 +908,8 @@ var pageInitialState = {
|
|
|
702
908
|
var pageDevtools = { name: "zljs", store: "page" };
|
|
703
909
|
|
|
704
910
|
// core/state/zustand/page/page.store.ts
|
|
705
|
-
var usePageStore =
|
|
706
|
-
|
|
911
|
+
var usePageStore = create5()(
|
|
912
|
+
devtools5(
|
|
707
913
|
(set) => ({
|
|
708
914
|
...pageInitialState,
|
|
709
915
|
setTitle: (title2) => set({ title: title2 }, false, "setTitle")
|
|
@@ -713,8 +919,8 @@ var usePageStore = create4()(
|
|
|
713
919
|
);
|
|
714
920
|
|
|
715
921
|
// core/card/card.styles.ts
|
|
716
|
-
import { tv as
|
|
717
|
-
var card =
|
|
922
|
+
import { tv as tv11 } from "tailwind-variants";
|
|
923
|
+
var card = tv11({
|
|
718
924
|
slots: {
|
|
719
925
|
// A soft, wide shadow in the color of the card. shadow-sm only spreads 1 to
|
|
720
926
|
// 3px and reads as part of the border on a white page.
|
|
@@ -744,7 +950,7 @@ var card = tv9({
|
|
|
744
950
|
});
|
|
745
951
|
|
|
746
952
|
// core/card/card.tsx
|
|
747
|
-
import { jsx as
|
|
953
|
+
import { jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
748
954
|
var Card = ({
|
|
749
955
|
children,
|
|
750
956
|
title: title2,
|
|
@@ -754,167 +960,25 @@ var Card = ({
|
|
|
754
960
|
}) => {
|
|
755
961
|
const { base, header: header2 } = card({ color });
|
|
756
962
|
const messageColor = color === "none" ? "muted" : "none";
|
|
757
|
-
return /* @__PURE__ */
|
|
758
|
-
(title2 || message) && /* @__PURE__ */
|
|
759
|
-
title2 && /* @__PURE__ */
|
|
760
|
-
message && /* @__PURE__ */
|
|
963
|
+
return /* @__PURE__ */ jsxs5("div", { "data-testid": "card", className: base(), children: [
|
|
964
|
+
(title2 || message) && /* @__PURE__ */ jsxs5("div", { className: header2(), children: [
|
|
965
|
+
title2 && /* @__PURE__ */ jsx14(Heading, { level: titleLevel, children: title2 }),
|
|
966
|
+
message && /* @__PURE__ */ jsx14(Text, { color: messageColor, children: message })
|
|
761
967
|
] }),
|
|
762
968
|
children
|
|
763
969
|
] });
|
|
764
970
|
};
|
|
765
971
|
|
|
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
972
|
// features/auth/components/access-pending/access-pending.styles.ts
|
|
909
|
-
import { tv as
|
|
910
|
-
var accessPending =
|
|
973
|
+
import { tv as tv12 } from "tailwind-variants";
|
|
974
|
+
var accessPending = tv12({
|
|
911
975
|
slots: {
|
|
912
976
|
account: "flex items-center justify-between gap-3"
|
|
913
977
|
}
|
|
914
978
|
});
|
|
915
979
|
|
|
916
980
|
// features/auth/components/access-pending/access-pending.tsx
|
|
917
|
-
import { jsx as
|
|
981
|
+
import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
918
982
|
var AccessPending = ({
|
|
919
983
|
title: title2 = "Waiting for approval",
|
|
920
984
|
message = "Your access to this app has not been approved yet.",
|
|
@@ -929,9 +993,9 @@ var AccessPending = ({
|
|
|
929
993
|
if (!user) {
|
|
930
994
|
return null;
|
|
931
995
|
}
|
|
932
|
-
return /* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
996
|
+
return /* @__PURE__ */ jsx15(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsxs6("div", { className: account(), children: [
|
|
997
|
+
/* @__PURE__ */ jsx15(Text, { variant: "caption", color: "muted", children: user.email }),
|
|
998
|
+
/* @__PURE__ */ jsx15(
|
|
935
999
|
SignOutButton,
|
|
936
1000
|
{
|
|
937
1001
|
label: signOutLabel,
|
|
@@ -946,7 +1010,7 @@ var AccessPending = ({
|
|
|
946
1010
|
|
|
947
1011
|
// features/auth/components/auth-provider/auth-provider.tsx
|
|
948
1012
|
import { useEffect as useEffect2 } from "react";
|
|
949
|
-
import { Fragment as Fragment4, jsx as
|
|
1013
|
+
import { Fragment as Fragment4, jsx as jsx16 } from "react/jsx-runtime";
|
|
950
1014
|
var AuthProvider = ({
|
|
951
1015
|
adapter,
|
|
952
1016
|
appId,
|
|
@@ -963,7 +1027,7 @@ var AuthProvider = ({
|
|
|
963
1027
|
reset();
|
|
964
1028
|
};
|
|
965
1029
|
}, [adapter, appId, configure, setSession, reset]);
|
|
966
|
-
return /* @__PURE__ */
|
|
1030
|
+
return /* @__PURE__ */ jsx16(Fragment4, { children });
|
|
967
1031
|
};
|
|
968
1032
|
|
|
969
1033
|
// features/auth/components/login/login.const.ts
|
|
@@ -977,15 +1041,15 @@ var loginVendors = {
|
|
|
977
1041
|
};
|
|
978
1042
|
|
|
979
1043
|
// features/auth/components/login/login.styles.ts
|
|
980
|
-
import { tv as
|
|
981
|
-
var login =
|
|
1044
|
+
import { tv as tv13 } from "tailwind-variants";
|
|
1045
|
+
var login = tv13({
|
|
982
1046
|
slots: {
|
|
983
1047
|
options: "flex flex-col gap-3"
|
|
984
1048
|
}
|
|
985
1049
|
});
|
|
986
1050
|
|
|
987
1051
|
// features/auth/components/login/login.tsx
|
|
988
|
-
import { jsx as
|
|
1052
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
989
1053
|
var LoginProviderButton = ({
|
|
990
1054
|
id,
|
|
991
1055
|
label,
|
|
@@ -994,7 +1058,7 @@ var LoginProviderButton = ({
|
|
|
994
1058
|
const signIn = () => {
|
|
995
1059
|
onSignIn(id);
|
|
996
1060
|
};
|
|
997
|
-
return /* @__PURE__ */
|
|
1061
|
+
return /* @__PURE__ */ jsx17(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
|
|
998
1062
|
};
|
|
999
1063
|
var Login = ({
|
|
1000
1064
|
vendor,
|
|
@@ -1012,9 +1076,9 @@ var Login = ({
|
|
|
1012
1076
|
useToastStore.getState().error(errorMessage);
|
|
1013
1077
|
});
|
|
1014
1078
|
};
|
|
1015
|
-
return /* @__PURE__ */
|
|
1079
|
+
return /* @__PURE__ */ jsx17(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx17("div", { className: options(), children: providers.map((provider) => {
|
|
1016
1080
|
const id = String(provider);
|
|
1017
|
-
return /* @__PURE__ */
|
|
1081
|
+
return /* @__PURE__ */ jsx17(
|
|
1018
1082
|
LoginProviderButton,
|
|
1019
1083
|
{
|
|
1020
1084
|
id,
|
|
@@ -1027,7 +1091,7 @@ var Login = ({
|
|
|
1027
1091
|
};
|
|
1028
1092
|
|
|
1029
1093
|
// features/auth/components/authorized/authorized.tsx
|
|
1030
|
-
import { Fragment as Fragment5, jsx as
|
|
1094
|
+
import { Fragment as Fragment5, jsx as jsx18 } from "react/jsx-runtime";
|
|
1031
1095
|
var Authorized = ({
|
|
1032
1096
|
children,
|
|
1033
1097
|
roles,
|
|
@@ -1036,18 +1100,18 @@ var Authorized = ({
|
|
|
1036
1100
|
}) => {
|
|
1037
1101
|
const { status, user, role } = useAuth();
|
|
1038
1102
|
if (status === "loading") return null;
|
|
1039
|
-
if (!user) return /* @__PURE__ */
|
|
1103
|
+
if (!user) return /* @__PURE__ */ jsx18(Login, { ...login2 });
|
|
1040
1104
|
const hasRole = !roles || role !== null && roles.includes(role);
|
|
1041
|
-
if (!user.hasAccess || !hasRole) return /* @__PURE__ */
|
|
1042
|
-
return /* @__PURE__ */
|
|
1105
|
+
if (!user.hasAccess || !hasRole) return /* @__PURE__ */ jsx18(AccessPending, { ...accessPending2 });
|
|
1106
|
+
return /* @__PURE__ */ jsx18(Fragment5, { children });
|
|
1043
1107
|
};
|
|
1044
1108
|
|
|
1045
1109
|
// features/providers/components/zustand-providers/zustand-providers.tsx
|
|
1046
|
-
import { Fragment as Fragment6, jsx as
|
|
1110
|
+
import { Fragment as Fragment6, jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1047
1111
|
var ZustandProviders = ({ children, auth }) => /* @__PURE__ */ jsxs7(Fragment6, { children: [
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
1050
|
-
auth ? /* @__PURE__ */
|
|
1112
|
+
/* @__PURE__ */ jsx19(Loader, {}),
|
|
1113
|
+
/* @__PURE__ */ jsx19(Toaster, {}),
|
|
1114
|
+
auth ? /* @__PURE__ */ jsx19(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
|
|
1051
1115
|
] });
|
|
1052
1116
|
|
|
1053
1117
|
export {
|
|
@@ -1056,12 +1120,16 @@ export {
|
|
|
1056
1120
|
Text,
|
|
1057
1121
|
Modal,
|
|
1058
1122
|
Heading,
|
|
1059
|
-
useToastStore,
|
|
1060
|
-
Toaster,
|
|
1061
|
-
toast2 as toast,
|
|
1062
1123
|
appInitialState,
|
|
1063
1124
|
useAppStore,
|
|
1064
1125
|
ConnectedModal,
|
|
1126
|
+
useToastStore,
|
|
1127
|
+
getAuthSession,
|
|
1128
|
+
useAuth,
|
|
1129
|
+
SignOutButton,
|
|
1130
|
+
Link,
|
|
1131
|
+
Toaster,
|
|
1132
|
+
toast2 as toast,
|
|
1065
1133
|
Spinner,
|
|
1066
1134
|
Loader,
|
|
1067
1135
|
ReduxProvider,
|
|
@@ -1069,9 +1137,6 @@ export {
|
|
|
1069
1137
|
useRouterStore,
|
|
1070
1138
|
usePageStore,
|
|
1071
1139
|
Card,
|
|
1072
|
-
getAuthSession,
|
|
1073
|
-
useAuth,
|
|
1074
|
-
SignOutButton,
|
|
1075
1140
|
AccessPending,
|
|
1076
1141
|
AuthProvider,
|
|
1077
1142
|
Login,
|