@alexandregme/zljs 3.10.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 CHANGED
@@ -8,6 +8,35 @@ A change that needs action in an app has a **Migration** note. When updating, re
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [3.11.0] - 2026-11-12
12
+
13
+ ### Added
14
+
15
+ - `variant` on `Link`: `inline`, the default, is the link as it was, and `nav` is a row of a menu, 40px tall, with no underline and a translucent background on hover that works on a light or a dark surface
16
+ - `active` on `Link`, which marks the link to the current page with `aria-current="page"`, and gives a `nav` link a background
17
+ - `aria-label` on `Link`, the name of a link whose children have no text, such as only an icon
18
+ - The type `LinkVariant`
19
+ - `onSignOut` on `SignOutButton`: the app's own function, called when the user confirms in the modal, instead of the adapter of `AuthProvider`. With it the button needs no `AuthProvider`, so an app whose auth doesn't come from zljs can use it. A function that throws or rejects shows the `errorMessage` toast
20
+ - `logout` on `Sidebar`, the texts of its logout button and of the modal it opens: `label`, `confirmTitle`, `confirmLabel`, `cancelLabel` and `errorMessage`, all with English defaults
21
+ - `navLabel` and `expandLabel` on `Sidebar`, the accessible names of the navigation and of the collapse button while collapsed. They were fixed in English, and those are now the defaults: `Main navigation` and `Expand sidebar`
22
+
23
+ ### Changed
24
+
25
+ - The logout button of `Sidebar` is a `SignOutButton`. A click opens a modal that asks first, and `onLogout` is called only when the user confirms. `onLogout` may return a promise, and one that rejects shows an error toast, so the app needs a `Toaster`. The default name of the button is `Sign out`, it was `Logout`
26
+ - The links of `Sidebar` are `Link` with `variant="nav"`. Their text takes the color of the sidebar, also on hover and when active, where it was gray and turned white. Collapsed, the labels are no longer rendered, where they faded out, and each link keeps its name
27
+ - `SignOutButton` takes the color of the text around it, so it works on a dark surface. It was gray
28
+ - The collapse button of `Sidebar` always has an `aria-label`: `collapseLabel` while expanded, `expandLabel` while collapsed
29
+
30
+ #### Migration
31
+
32
+ - A test of the app that finds the logout button of `Sidebar` by the name `Logout`: the name is now `Sign out`, or what the app passes in `logout.label`. To keep the old name, pass `logout={{ label: "Logout" }}`
33
+ - A test that clicks the logout button and expects `onLogout` to be called: also click the confirm button of the modal, named `Sign out` by default
34
+ - An `onLogout` that asks for confirmation on its own, such as with `window.confirm`: remove the question, the modal already asks
35
+
36
+ ### Fixed
37
+
38
+ - `Sidebar` is as tall as the visible part of the screen (`100dvh`). It was `100vh`, which on a phone is taller than what the browser shows, so the collapse button ended up under the browser's bar
39
+
11
40
  ## [3.10.0] - 2026-11-12
12
41
 
13
42
  ### Added
@@ -479,7 +508,8 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
479
508
 
480
509
  The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
481
510
 
482
- [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.10.0...HEAD
511
+ [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.11.0...HEAD
512
+ [3.11.0]: https://github.com/alexandregme/zljs/compare/v3.10.0...v3.11.0
483
513
  [3.10.0]: https://github.com/alexandregme/zljs/compare/v3.9.0...v3.10.0
484
514
  [3.9.0]: https://github.com/alexandregme/zljs/compare/v3.8.0...v3.9.0
485
515
  [3.8.0]: https://github.com/alexandregme/zljs/compare/v3.7.0...v3.8.0
@@ -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/toaster/state/toast.store.ts
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 = create()(
389
- devtools(
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 tv6 } from "tailwind-variants";
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 = tv6({
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 jsx6 } from "react/jsx-runtime";
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__ */ jsx6(
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 tv7 } from "tailwind-variants";
570
- var spinner = tv7({
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 jsx8 } from "react/jsx-runtime";
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__ */ jsx8(
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__ */ jsx8(Icon, { name: spinnerIcons[variant], size })
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 tv8 } from "tailwind-variants";
593
- var loader = tv8({
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 jsx9 } from "react/jsx-runtime";
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__ */ jsx9("div", { className: loader(), children: /* @__PURE__ */ jsx9(Spinner, { size: "lg", label }) });
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 jsx10 } from "react/jsx-runtime";
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__ */ jsx10(Provider, { store, children });
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 create3 } from "zustand";
674
- import { devtools as devtools3 } from "zustand/middleware";
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 = create3()(
685
- devtools3(
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 create4 } from "zustand";
696
- import { devtools as devtools4 } from "zustand/middleware";
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 = create4()(
706
- devtools4(
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 tv9 } from "tailwind-variants";
717
- var card = tv9({
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 jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
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__ */ jsxs3("div", { "data-testid": "card", className: base(), children: [
758
- (title2 || message) && /* @__PURE__ */ jsxs3("div", { className: header2(), children: [
759
- title2 && /* @__PURE__ */ jsx11(Heading, { level: titleLevel, children: title2 }),
760
- message && /* @__PURE__ */ jsx11(Text, { color: messageColor, children: message })
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 tv11 } from "tailwind-variants";
910
- var accessPending = tv11({
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 jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
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__ */ jsx14(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsxs6("div", { className: account(), children: [
933
- /* @__PURE__ */ jsx14(Text, { variant: "caption", color: "muted", children: user.email }),
934
- /* @__PURE__ */ jsx14(
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 jsx15 } from "react/jsx-runtime";
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__ */ jsx15(Fragment4, { children });
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 tv12 } from "tailwind-variants";
981
- var login = tv12({
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 jsx16 } from "react/jsx-runtime";
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__ */ jsx16(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
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__ */ jsx16(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx16("div", { className: options(), children: providers.map((provider) => {
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__ */ jsx16(
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 jsx17 } from "react/jsx-runtime";
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__ */ jsx17(Login, { ...login2 });
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__ */ jsx17(AccessPending, { ...accessPending2 });
1042
- return /* @__PURE__ */ jsx17(Fragment5, { children });
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 jsx18, jsxs as jsxs7 } from "react/jsx-runtime";
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__ */ jsx18(Loader, {}),
1049
- /* @__PURE__ */ jsx18(Toaster, {}),
1050
- auth ? /* @__PURE__ */ jsx18(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
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,
package/dist/index.d.ts CHANGED
@@ -241,6 +241,27 @@ interface TextProps {
241
241
 
242
242
  declare const Text: ({ children, as: Tag, variant, color, }: TextProps) => react.JSX.Element;
243
243
 
244
+ interface SignOutButtonProps {
245
+ /** The accessible name of the icon button. */
246
+ label?: string;
247
+ /** The question of the modal a click opens. */
248
+ confirmTitle?: string;
249
+ /** The button of the modal that signs out. */
250
+ confirmLabel?: string;
251
+ /** The button of the modal that keeps the user signed in. */
252
+ cancelLabel?: string;
253
+ /** The toast when signing out fails. */
254
+ errorMessage?: string;
255
+ /**
256
+ * Signs the user out, for an app with no `AuthProvider`. It is called when
257
+ * the user confirms in the modal. Without it, the button signs out through
258
+ * the adapter of `AuthProvider`.
259
+ */
260
+ onSignOut?: () => void | Promise<void>;
261
+ }
262
+
263
+ declare const SignOutButton: ({ label, confirmTitle, confirmLabel, cancelLabel, errorMessage, onSignOut, }: SignOutButtonProps) => react.JSX.Element;
264
+
244
265
  interface SidebarItem {
245
266
  icon: IconName;
246
267
  label: string;
@@ -259,12 +280,25 @@ interface SidebarProps {
259
280
  activeHref?: string;
260
281
  defaultCollapsed?: boolean;
261
282
  collapseLabel: string;
283
+ /** The accessible name of the collapse button while collapsed. */
284
+ expandLabel?: string;
262
285
  homeHref?: string | false;
263
286
  homeLabel?: string;
264
- onLogout: () => void;
287
+ /** The accessible name of the navigation. */
288
+ navLabel?: string;
289
+ /**
290
+ * The texts of the logout button and of the modal it opens: `label`,
291
+ * `confirmTitle`, `confirmLabel`, `cancelLabel` and `errorMessage`.
292
+ */
293
+ logout?: Omit<SignOutButtonProps, "onSignOut">;
294
+ /**
295
+ * Logs the user out. It is called when the user confirms in the modal, never
296
+ * on the first click. A rejected promise shows the error toast.
297
+ */
298
+ onLogout: () => void | Promise<void>;
265
299
  }
266
300
 
267
- declare const Sidebar: ({ sections, user, activeHref, defaultCollapsed, collapseLabel, homeHref, homeLabel, onLogout, }: SidebarProps) => react.JSX.Element;
301
+ declare const Sidebar: ({ sections, user, activeHref, defaultCollapsed, collapseLabel, expandLabel, homeHref, homeLabel, navLabel, logout, onLogout, }: SidebarProps) => react.JSX.Element;
268
302
 
269
303
  interface TabsItem {
270
304
  /** Unique among the tabs. `defaultTab` and `onChange` use it. */
@@ -571,21 +605,6 @@ interface AuthorizedProps<V extends LoginVendor = LoginVendor> {
571
605
 
572
606
  declare const Authorized: <V extends LoginVendor>({ children, roles, login, accessPending, }: AuthorizedProps<V>) => react.JSX.Element | null;
573
607
 
574
- interface SignOutButtonProps {
575
- /** The accessible name of the icon button. */
576
- label?: string;
577
- /** The question of the modal a click opens. */
578
- confirmTitle?: string;
579
- /** The button of the modal that signs out. */
580
- confirmLabel?: string;
581
- /** The button of the modal that keeps the user signed in. */
582
- cancelLabel?: string;
583
- /** The toast when signing out fails. */
584
- errorMessage?: string;
585
- }
586
-
587
- declare const SignOutButton: ({ label, confirmTitle, confirmLabel, cancelLabel, errorMessage, }: SignOutButtonProps) => react.JSX.Element;
588
-
589
608
  interface UseAuthResult extends Omit<AuthAdapter, "onSessionChange"> {
590
609
  status: AuthStatus;
591
610
  user: AuthUser | null;
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  ConnectedModal,
9
9
  Heading,
10
10
  Icon,
11
+ Link,
11
12
  Loader,
12
13
  Login,
13
14
  Modal,
@@ -26,7 +27,7 @@ import {
26
27
  usePageStore,
27
28
  useRouterStore,
28
29
  useToastStore
29
- } from "./chunk-JMEGXQKC.js";
30
+ } from "./chunk-XRJCFNLC.js";
30
31
  import {
31
32
  Error,
32
33
  FormInput,
@@ -638,20 +639,16 @@ var WhatsAppButton = ({
638
639
 
639
640
  // core/sidebar/sidebar.tsx
640
641
  import { useState as useState2 } from "react";
641
- import Link from "next/link.js";
642
642
 
643
643
  // core/sidebar/sidebar.styles.ts
644
644
  import { tv as tv9 } from "tailwind-variants";
645
645
  var sidebar = tv9({
646
- base: "h-screen bg-neutral-800 text-neutral-300 flex flex-col overflow-hidden transition-all duration-200 divide-y divide-neutral-600/50",
646
+ base: "h-dvh bg-neutral-800 text-neutral-300 flex flex-col overflow-hidden transition-[width] duration-200 divide-y divide-neutral-600/50",
647
647
  variants: {
648
648
  collapsed: {
649
649
  true: "w-14",
650
650
  false: "w-64"
651
651
  }
652
- },
653
- defaultVariants: {
654
- collapsed: false
655
652
  }
656
653
  });
657
654
  var nav = tv9({
@@ -663,24 +660,6 @@ var header = tv9({
663
660
  var section = tv9({
664
661
  base: "grid gap-1 p-2"
665
662
  });
666
- var item = tv9({
667
- // [&>*+*] is the label: Text takes no className, and the icon comes first, so a link with no label has nothing to hide.
668
- base: "flex items-center rounded-md transition-colors h-10 px-3 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current [&>*+*]:truncate [&>*+*]:transition-all [&>*+*]:duration-200",
669
- variants: {
670
- active: {
671
- true: "bg-neutral-700 text-white",
672
- false: "text-neutral-400 hover:bg-neutral-700/50 hover:text-white"
673
- },
674
- collapsed: {
675
- true: "[&>*+*]:w-0 [&>*+*]:opacity-0",
676
- false: "[&>*+*]:ml-2 [&>*+*]:opacity-100"
677
- }
678
- },
679
- defaultVariants: {
680
- active: false,
681
- collapsed: false
682
- }
683
- });
684
663
  var footer = tv9({
685
664
  base: "shrink-0 h-16 p-3 flex items-center gap-3",
686
665
  variants: {
@@ -714,42 +693,50 @@ var Sidebar = ({
714
693
  activeHref,
715
694
  defaultCollapsed = false,
716
695
  collapseLabel,
696
+ expandLabel = "Expand sidebar",
717
697
  homeHref = "/",
718
698
  homeLabel,
699
+ navLabel = "Main navigation",
700
+ logout = {},
719
701
  onLogout
720
702
  }) => {
721
703
  const [collapsed, setCollapsed] = useState2(defaultCollapsed);
722
704
  const initials = getInitials(user.name);
705
+ const toggleLabel = collapsed ? expandLabel : collapseLabel;
706
+ const toggleIcon = collapsed ? "ChevronRight" : "ChevronLeft";
707
+ const toggle = () => {
708
+ setCollapsed(!collapsed);
709
+ };
723
710
  return /* @__PURE__ */ jsxs10("aside", { className: sidebar({ collapsed }), children: [
724
711
  homeHref && /* @__PURE__ */ jsx12("div", { className: header(), children: /* @__PURE__ */ jsxs10(
725
712
  Link,
726
713
  {
727
714
  href: homeHref,
728
- className: item({ active: homeHref === activeHref, collapsed }),
715
+ variant: "nav",
716
+ color: "none",
717
+ active: homeHref === activeHref,
729
718
  "aria-label": homeLabel || "Home",
730
- ...homeHref === activeHref && { "aria-current": "page" },
731
719
  children: [
732
720
  /* @__PURE__ */ jsx12(Icon, { name: "Home" }),
733
- homeLabel && /* @__PURE__ */ jsx12(Text, { as: "span", variant: "caption", children: homeLabel })
721
+ homeLabel && !collapsed && /* @__PURE__ */ jsx12(Text, { as: "span", variant: "caption", children: homeLabel })
734
722
  ]
735
723
  }
736
724
  ) }),
737
- /* @__PURE__ */ jsx12("nav", { "aria-label": "Main navigation", className: nav(), children: sections.map((sectionData, i) => /* @__PURE__ */ jsx12("div", { className: section(), children: sectionData.items.map((sidebarItem) => {
738
- const isActive = sidebarItem.href === activeHref;
739
- return /* @__PURE__ */ jsxs10(
740
- Link,
741
- {
742
- href: sidebarItem.href,
743
- className: item({ active: isActive, collapsed }),
744
- ...isActive && { "aria-current": "page" },
745
- children: [
746
- /* @__PURE__ */ jsx12(Icon, { name: sidebarItem.icon }),
747
- /* @__PURE__ */ jsx12(Text, { as: "span", variant: "caption", children: sidebarItem.label })
748
- ]
749
- },
750
- sidebarItem.href
751
- );
752
- }) }, i)) }),
725
+ /* @__PURE__ */ jsx12("nav", { "aria-label": navLabel, className: nav(), children: sections.map((sectionData, i) => /* @__PURE__ */ jsx12("div", { className: section(), children: sectionData.items.map((sidebarItem) => /* @__PURE__ */ jsxs10(
726
+ Link,
727
+ {
728
+ href: sidebarItem.href,
729
+ variant: "nav",
730
+ color: "none",
731
+ active: sidebarItem.href === activeHref,
732
+ "aria-label": sidebarItem.label,
733
+ children: [
734
+ /* @__PURE__ */ jsx12(Icon, { name: sidebarItem.icon }),
735
+ !collapsed && /* @__PURE__ */ jsx12(Text, { as: "span", variant: "caption", children: sidebarItem.label })
736
+ ]
737
+ },
738
+ sidebarItem.href
739
+ )) }, i)) }),
753
740
  /* @__PURE__ */ jsxs10("div", { className: footer({ collapsed }), children: [
754
741
  !collapsed && /* @__PURE__ */ jsxs10(Fragment2, { children: [
755
742
  /* @__PURE__ */ jsx12("div", { "aria-hidden": "true", className: avatar(), children: initials }),
@@ -759,24 +746,25 @@ var Sidebar = ({
759
746
  ] })
760
747
  ] }),
761
748
  /* @__PURE__ */ jsx12(
762
- Button,
749
+ SignOutButton,
763
750
  {
764
- color: "ghost",
765
- icon: "LogOut",
766
- "aria-label": "Logout",
767
- onClick: onLogout
751
+ label: logout.label,
752
+ confirmTitle: logout.confirmTitle,
753
+ confirmLabel: logout.confirmLabel,
754
+ cancelLabel: logout.cancelLabel,
755
+ errorMessage: logout.errorMessage,
756
+ onSignOut: onLogout
768
757
  }
769
758
  )
770
759
  ] }),
771
760
  /* @__PURE__ */ jsx12("div", { className: toggleButton(), children: /* @__PURE__ */ jsx12(
772
761
  Button,
773
762
  {
774
- variant: "default",
775
763
  color: "ghost",
776
- icon: collapsed ? "ChevronRight" : "ChevronLeft",
777
- "aria-label": collapsed ? "Expand sidebar" : void 0,
778
- onClick: () => setCollapsed(!collapsed),
779
- children: collapsed ? void 0 : collapseLabel
764
+ icon: toggleIcon,
765
+ "aria-label": toggleLabel,
766
+ onClick: toggle,
767
+ children: !collapsed && collapseLabel
780
768
  }
781
769
  ) })
782
770
  ] });
@@ -25,13 +25,20 @@ interface PageWrapperProps {
25
25
 
26
26
  declare const PageWrapper: ({ children }: PageWrapperProps) => react.JSX.Element;
27
27
 
28
+ type LinkVariant = "inline" | "nav";
28
29
  interface LinkProps {
29
30
  children: ReactNode;
30
31
  href: string;
32
+ /** `inline` is a link in a text. `nav` is a row of a menu, with no underline. */
33
+ variant?: LinkVariant;
31
34
  color?: SemanticColor;
35
+ /** The link to the current page: it gets `aria-current="page"`. */
36
+ active?: boolean;
37
+ /** The accessible name, for a link whose children have no text. */
38
+ "aria-label"?: string;
32
39
  }
33
40
 
34
- declare const Link: ({ children, href, color }: LinkProps) => react.JSX.Element;
41
+ declare const Link: ({ children, href, variant, color, active, "aria-label": ariaLabel, }: LinkProps) => react.JSX.Element;
35
42
 
36
43
  type AppProvidersProps = ReduxProviderProps & Pick<ZustandProvidersProps, "auth">;
37
44
 
@@ -48,4 +55,4 @@ interface PageConfigProps {
48
55
  declare const PageConfig: ({ children, title, reducers, initPage, }: PageConfigProps) => react.JSX.Element;
49
56
 
50
57
  export { AppProviders, Link, NotFound, PageConfig, PageWrapper, RootLayout };
51
- export type { AppProvidersProps, InitPageFunction, LinkProps, NotFoundProps, PageConfigProps, PageWrapperProps, RootLayoutProps };
58
+ export type { AppProvidersProps, InitPageFunction, LinkProps, LinkVariant, NotFoundProps, PageConfigProps, PageWrapperProps, RootLayoutProps };
@@ -1,12 +1,13 @@
1
1
  "use client";
2
2
  import {
3
3
  Heading,
4
+ Link,
4
5
  ReduxProvider,
5
6
  Text,
6
7
  ZustandProviders,
7
8
  usePageStore,
8
9
  useRouterStore
9
- } from "../chunk-JMEGXQKC.js";
10
+ } from "../chunk-XRJCFNLC.js";
10
11
 
11
12
  // core/next/root-layout/root-layout.styles.ts
12
13
  import { tv } from "tailwind-variants";
@@ -20,39 +21,9 @@ var RootLayout = ({ children }) => {
20
21
  return /* @__PURE__ */ jsx("main", { className: rootLayout(), children });
21
22
  };
22
23
 
23
- // core/next/link/link.tsx
24
- import NextLink from "next/link.js";
25
-
26
- // core/next/link/link.styles.ts
27
- import { tv as tv2 } from "tailwind-variants";
28
- var link = tv2({
29
- // outline-current draws the focus in the text color. The invisible ::after grows the touch target to 44px without changing the layout.
30
- base: "relative rounded-sm underline underline-offset-2 hover:decoration-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current 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",
31
- variants: {
32
- color: {
33
- primary: "text-zl-primary hover:text-zl-primary-strong",
34
- success: "text-zl-success hover:text-zl-success-strong",
35
- danger: "text-zl-danger hover:text-zl-danger-strong",
36
- warning: "text-zl-warning hover:text-zl-warning-strong",
37
- info: "text-zl-info hover:text-zl-info-strong",
38
- muted: "text-zl-muted hover:text-zl-muted-strong",
39
- none: ""
40
- }
41
- },
42
- defaultVariants: {
43
- color: "primary"
44
- }
45
- });
46
-
47
- // core/next/link/link.tsx
48
- import { jsx as jsx2 } from "react/jsx-runtime";
49
- var Link = ({ children, href, color = "primary" }) => {
50
- return /* @__PURE__ */ jsx2(NextLink, { href, className: link({ color }), children });
51
- };
52
-
53
24
  // core/next/not-found/not-found.styles.ts
54
- import { tv as tv3 } from "tailwind-variants";
55
- var notFound = tv3({
25
+ import { tv as tv2 } from "tailwind-variants";
26
+ var notFound = tv2({
56
27
  slots: {
57
28
  base: "flex flex-col items-center justify-center gap-6 min-h-dvh p-4 text-center",
58
29
  code: "text-6xl font-bold text-zl-muted",
@@ -61,7 +32,7 @@ var notFound = tv3({
61
32
  });
62
33
 
63
34
  // core/next/not-found/not-found.tsx
64
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
35
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
65
36
  var NotFound = ({
66
37
  title = "Page not found",
67
38
  message = "The page you are looking for does not exist.",
@@ -70,18 +41,18 @@ var NotFound = ({
70
41
  }) => {
71
42
  const { base, code, content } = notFound();
72
43
  return /* @__PURE__ */ jsxs("div", { className: base(), children: [
73
- /* @__PURE__ */ jsx3("span", { className: code(), children: "404" }),
44
+ /* @__PURE__ */ jsx2("span", { className: code(), children: "404" }),
74
45
  /* @__PURE__ */ jsxs("div", { className: content(), children: [
75
- /* @__PURE__ */ jsx3(Heading, { children: title }),
76
- /* @__PURE__ */ jsx3(Text, { color: "muted", children: message })
46
+ /* @__PURE__ */ jsx2(Heading, { children: title }),
47
+ /* @__PURE__ */ jsx2(Text, { color: "muted", children: message })
77
48
  ] }),
78
- /* @__PURE__ */ jsx3(Link, { href: backHref, children: backLabel })
49
+ /* @__PURE__ */ jsx2(Link, { href: backHref, children: backLabel })
79
50
  ] });
80
51
  };
81
52
 
82
53
  // core/next/page-wrapper/page-wrapper.styles.ts
83
- import { tv as tv4 } from "tailwind-variants";
84
- var pageWrapper = tv4({
54
+ import { tv as tv3 } from "tailwind-variants";
55
+ var pageWrapper = tv3({
85
56
  slots: {
86
57
  base: "flex items-center justify-center min-h-dvh p-4",
87
58
  content: "w-full max-w-sm"
@@ -89,16 +60,16 @@ var pageWrapper = tv4({
89
60
  });
90
61
 
91
62
  // core/next/page-wrapper/page-wrapper.tsx
92
- import { jsx as jsx4 } from "react/jsx-runtime";
63
+ import { jsx as jsx3 } from "react/jsx-runtime";
93
64
  var PageWrapper = ({ children }) => {
94
65
  const { base, content } = pageWrapper();
95
- return /* @__PURE__ */ jsx4("div", { className: base(), children: /* @__PURE__ */ jsx4("div", { className: content(), children }) });
66
+ return /* @__PURE__ */ jsx3("div", { className: base(), children: /* @__PURE__ */ jsx3("div", { className: content(), children }) });
96
67
  };
97
68
 
98
69
  // core/next/app-providers/app-providers.tsx
99
70
  import { useEffect } from "react";
100
71
  import { usePathname } from "next/navigation.js";
101
- import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
72
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
102
73
  var RouteSync = () => {
103
74
  const pathname = usePathname();
104
75
  const setRoute = useRouterStore((s) => s.setRoute);
@@ -114,14 +85,14 @@ var AppProviders = ({
114
85
  auth,
115
86
  ...store
116
87
  }) => /* @__PURE__ */ jsxs2(ReduxProvider, { ...store, children: [
117
- /* @__PURE__ */ jsx5(RouteSync, {}),
118
- /* @__PURE__ */ jsx5(ZustandProviders, { auth, children })
88
+ /* @__PURE__ */ jsx4(RouteSync, {}),
89
+ /* @__PURE__ */ jsx4(ZustandProviders, { auth, children })
119
90
  ] });
120
91
 
121
92
  // core/next/page-config/page-config.tsx
122
93
  import { useEffect as useEffect2 } from "react";
123
94
  import { useDispatch, useStore } from "react-redux";
124
- import { Fragment, jsx as jsx6 } from "react/jsx-runtime";
95
+ import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
125
96
  var PageConfig = ({
126
97
  children,
127
98
  title,
@@ -144,7 +115,7 @@ var PageConfig = ({
144
115
  initPage(dispatch);
145
116
  }
146
117
  }, []);
147
- return /* @__PURE__ */ jsx6(Fragment, { children });
118
+ return /* @__PURE__ */ jsx5(Fragment, { children });
148
119
  };
149
120
  export {
150
121
  AppProviders,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexandregme/zljs",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "Opinionated, accessible React component library for enterprise apps (Next.js, Tailwind CSS v4).",
5
5
  "keywords": [
6
6
  "react",