@alexandregme/zljs 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,19 @@ A change that needs action in an app has a **Migration** note. When updating, re
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [3.5.0] - 2026-11-11
12
+
13
+ ### Added
14
+
15
+ - `Login`, the sign-in screen of an app, shared like `NotFound`. It takes `vendor`, the auth vendor behind the app's adapter (today only `supabase`), and `providers`, the OAuth providers the app turned on, and shows one button for each. A click calls `signInWithOAuth` of the adapter, and a failed sign-in fires an error toast. Every text has an English default: `title`, `message`, `providerLabel` and `errorMessage`
16
+ - The types `LoginVendor` and `LoginProvider`, to type the `vendor` and `providers` an app passes to `Login`
17
+
18
+ ## [3.4.0] - 2026-11-10
19
+
20
+ ### Added
21
+
22
+ - `SignOutButton`, an icon button that signs the user out through the adapter. A click opens a `danger` modal that asks first, with the texts the button gets: `confirmTitle`, `confirmLabel` and `cancelLabel`. A failed sign-out fires an error toast with `errorMessage`
23
+
11
24
  ## [3.3.0] - 2026-11-10
12
25
 
13
26
  ### Added
@@ -434,7 +447,8 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
434
447
 
435
448
  The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
436
449
 
437
- [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.3.0...HEAD
450
+ [Unreleased]: https://github.com/alexandregme/zljs/compare/v3.5.0...HEAD
451
+ [3.5.0]: https://github.com/alexandregme/zljs/compare/v3.3.0...v3.5.0
438
452
  [3.3.0]: https://github.com/alexandregme/zljs/compare/v3.2.0...v3.3.0
439
453
  [3.2.0]: https://github.com/alexandregme/zljs/compare/v3.1.0...v3.2.0
440
454
  [3.1.0]: https://github.com/alexandregme/zljs/compare/v3.0.0...v3.1.0
@@ -660,6 +660,57 @@ var AuthProvider = ({
660
660
  return /* @__PURE__ */ jsx10(Fragment3, { children });
661
661
  };
662
662
 
663
+ // core/card/card.styles.ts
664
+ import { tv as tv9 } from "tailwind-variants";
665
+ var card = tv9({
666
+ slots: {
667
+ // A soft, wide shadow in the color of the card. shadow-sm only spreads 1 to
668
+ // 3px and reads as part of the border on a white page.
669
+ base: "flex flex-col gap-6 w-full p-6 rounded-2xl border shadow-lg",
670
+ header: "flex flex-col gap-1"
671
+ },
672
+ variants: {
673
+ color: {
674
+ primary: {
675
+ base: "border-zl-primary bg-zl-primary/15 shadow-zl-primary/20"
676
+ },
677
+ success: {
678
+ base: "border-zl-success bg-zl-success/15 shadow-zl-success/20"
679
+ },
680
+ danger: { base: "border-zl-danger bg-zl-danger/15 shadow-zl-danger/20" },
681
+ warning: {
682
+ base: "border-zl-warning bg-zl-warning/15 shadow-zl-warning/20"
683
+ },
684
+ info: { base: "border-zl-info bg-zl-info/15 shadow-zl-info/20" },
685
+ muted: { base: "border-zl-muted bg-zl-muted/15 shadow-zl-muted/20" },
686
+ none: { base: "border-gray-200 bg-white shadow-black/12" }
687
+ }
688
+ },
689
+ defaultVariants: {
690
+ color: "none"
691
+ }
692
+ });
693
+
694
+ // core/card/card.tsx
695
+ import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
696
+ var Card = ({
697
+ children,
698
+ title: title2,
699
+ titleLevel = 2,
700
+ message,
701
+ color = "none"
702
+ }) => {
703
+ const { base, header: header2 } = card({ color });
704
+ const messageColor = color === "none" ? "muted" : "none";
705
+ return /* @__PURE__ */ jsxs3("div", { "data-testid": "card", className: base(), children: [
706
+ (title2 || message) && /* @__PURE__ */ jsxs3("div", { className: header2(), children: [
707
+ title2 && /* @__PURE__ */ jsx11(Heading, { level: titleLevel, children: title2 }),
708
+ message && /* @__PURE__ */ jsx11(Text, { color: messageColor, children: message })
709
+ ] }),
710
+ children
711
+ ] });
712
+ };
713
+
663
714
  // features/auth/hooks/use-auth/use-auth.ts
664
715
  var requireAdapter = () => {
665
716
  const { adapter } = useAuthStore.getState();
@@ -684,12 +735,154 @@ var useAuth = () => {
684
735
  };
685
736
  };
686
737
 
738
+ // features/auth/components/login/login.const.ts
739
+ var loginVendors = {
740
+ supabase: {
741
+ google: "Google",
742
+ apple: "Apple",
743
+ github: "GitHub",
744
+ facebook: "Facebook"
745
+ }
746
+ };
747
+
748
+ // features/auth/components/login/login.styles.ts
749
+ import { tv as tv10 } from "tailwind-variants";
750
+ var login = tv10({
751
+ slots: {
752
+ options: "flex flex-col gap-3"
753
+ }
754
+ });
755
+
756
+ // features/auth/components/login/login.tsx
757
+ import { jsx as jsx12 } from "react/jsx-runtime";
758
+ var LoginProviderButton = ({
759
+ id,
760
+ label,
761
+ onSignIn
762
+ }) => {
763
+ const signIn = () => {
764
+ onSignIn(id);
765
+ };
766
+ return /* @__PURE__ */ jsx12(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
767
+ };
768
+ var Login = ({
769
+ vendor,
770
+ providers,
771
+ title: title2 = "Sign in",
772
+ message = "Choose how to sign in",
773
+ providerLabel = "Continue with",
774
+ errorMessage = "Could not sign in. Try again."
775
+ }) => {
776
+ const { signInWithOAuth } = useAuth();
777
+ const { options } = login();
778
+ const names = loginVendors[vendor];
779
+ const signIn = (id) => {
780
+ signInWithOAuth(id).catch(() => {
781
+ useToastStore.getState().error(errorMessage);
782
+ });
783
+ };
784
+ return /* @__PURE__ */ jsx12(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx12("div", { className: options(), children: providers.map((provider) => {
785
+ const id = String(provider);
786
+ return /* @__PURE__ */ jsx12(
787
+ LoginProviderButton,
788
+ {
789
+ id,
790
+ label: `${providerLabel} ${names[id]}`,
791
+ onSignIn: signIn
792
+ },
793
+ id
794
+ );
795
+ }) }) });
796
+ };
797
+
798
+ // features/auth/components/sign-out/sign-out-modal.const.ts
799
+ var SIGN_OUT_MODAL_ID = "zljs-sign-out";
800
+
801
+ // features/auth/components/sign-out/sign-out-modal.styles.ts
802
+ import { tv as tv11 } from "tailwind-variants";
803
+ var signOutModal = tv11({
804
+ slots: {
805
+ actions: "flex justify-end gap-2"
806
+ }
807
+ });
808
+
809
+ // features/auth/components/sign-out/sign-out-modal.tsx
810
+ import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
811
+ var SignOutModal = ({
812
+ title: title2 = "Sign out?",
813
+ confirmLabel = "Sign out",
814
+ cancelLabel = "Cancel",
815
+ errorMessage = "Could not sign out. Try again."
816
+ }) => {
817
+ const { signOut } = useAuth();
818
+ const closeModal = useAppStore((s) => s.closeModal);
819
+ const { actions } = signOutModal();
820
+ const stay = () => {
821
+ closeModal(SIGN_OUT_MODAL_ID);
822
+ };
823
+ const leave = () => {
824
+ closeModal(SIGN_OUT_MODAL_ID);
825
+ signOut().catch(() => {
826
+ useToastStore.getState().error(errorMessage);
827
+ });
828
+ };
829
+ return /* @__PURE__ */ jsx13(
830
+ ConnectedModal,
831
+ {
832
+ modalId: SIGN_OUT_MODAL_ID,
833
+ title: title2,
834
+ size: "xs",
835
+ color: "danger",
836
+ children: /* @__PURE__ */ jsxs4("div", { className: actions(), children: [
837
+ /* @__PURE__ */ jsx13(Button, { color: "ghost", onClick: stay, children: cancelLabel }),
838
+ /* @__PURE__ */ jsx13(Button, { color: "danger", onClick: leave, children: confirmLabel })
839
+ ] })
840
+ }
841
+ );
842
+ };
843
+
844
+ // features/auth/components/sign-out/sign-out-button.tsx
845
+ import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
846
+ var SignOutButton = ({
847
+ label = "Sign out",
848
+ confirmTitle,
849
+ confirmLabel,
850
+ cancelLabel,
851
+ errorMessage
852
+ }) => {
853
+ const openModal = useAppStore((s) => s.openModal);
854
+ const ask = () => {
855
+ openModal(SIGN_OUT_MODAL_ID);
856
+ };
857
+ return /* @__PURE__ */ jsxs5(Fragment4, { children: [
858
+ /* @__PURE__ */ jsx14(
859
+ Button,
860
+ {
861
+ variant: "icon",
862
+ color: "none",
863
+ icon: "LogOut",
864
+ "aria-label": label,
865
+ onClick: ask
866
+ }
867
+ ),
868
+ /* @__PURE__ */ jsx14(
869
+ SignOutModal,
870
+ {
871
+ title: confirmTitle,
872
+ confirmLabel,
873
+ cancelLabel,
874
+ errorMessage
875
+ }
876
+ )
877
+ ] });
878
+ };
879
+
687
880
  // features/providers/components/zustand-providers/zustand-providers.tsx
688
- import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
689
- var ZustandProviders = ({ children, auth }) => /* @__PURE__ */ jsxs3(Fragment4, { children: [
690
- /* @__PURE__ */ jsx11(Loader, {}),
691
- /* @__PURE__ */ jsx11(Toaster, {}),
692
- auth ? /* @__PURE__ */ jsx11(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
881
+ import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
882
+ var ZustandProviders = ({ children, auth }) => /* @__PURE__ */ jsxs6(Fragment5, { children: [
883
+ /* @__PURE__ */ jsx15(Loader, {}),
884
+ /* @__PURE__ */ jsx15(Toaster, {}),
885
+ auth ? /* @__PURE__ */ jsx15(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
693
886
  ] });
694
887
 
695
888
  // core/state/redux/redux-provider/redux-provider.tsx
@@ -726,7 +919,7 @@ var createReduxStore = ({
726
919
  };
727
920
 
728
921
  // core/state/redux/redux-provider/redux-provider.tsx
729
- import { jsx as jsx12 } from "react/jsx-runtime";
922
+ import { jsx as jsx16 } from "react/jsx-runtime";
730
923
  var ReduxProvider = ({
731
924
  children,
732
925
  reducers = {},
@@ -742,7 +935,7 @@ var ReduxProvider = ({
742
935
  coreReducers
743
936
  })
744
937
  );
745
- return /* @__PURE__ */ jsx12(Provider, { store, children });
938
+ return /* @__PURE__ */ jsx16(Provider, { store, children });
746
939
  };
747
940
 
748
941
  // core/state/zustand/router/router.utils.ts
@@ -818,7 +1011,10 @@ export {
818
1011
  Loader,
819
1012
  getAuthSession,
820
1013
  AuthProvider,
1014
+ Card,
821
1015
  useAuth,
1016
+ Login,
1017
+ SignOutButton,
822
1018
  ZustandProviders,
823
1019
  ReduxProvider,
824
1020
  splitURLasPath,
package/dist/index.d.ts CHANGED
@@ -382,6 +382,51 @@ interface AuthProviderProps extends AuthConfig {
382
382
  */
383
383
  declare const AuthProvider: ({ adapter, appId, children, }: AuthProviderProps) => react.JSX.Element;
384
384
 
385
+ /**
386
+ * The OAuth providers of each auth vendor, by the id the vendor knows, with
387
+ * the name each one shows on its button. A new vendor is a new key here.
388
+ */
389
+ declare const loginVendors: {
390
+ readonly supabase: {
391
+ readonly google: "Google";
392
+ readonly apple: "Apple";
393
+ readonly github: "GitHub";
394
+ readonly facebook: "Facebook";
395
+ };
396
+ };
397
+
398
+ type LoginVendor = keyof typeof loginVendors;
399
+ type LoginProvider<V extends LoginVendor = LoginVendor> = keyof (typeof loginVendors)[V];
400
+ interface LoginProps<V extends LoginVendor = LoginVendor> {
401
+ /** The auth vendor behind the app's `AuthAdapter`. It sets which providers exist. */
402
+ vendor: V;
403
+ /** One button per provider, in this order. */
404
+ providers: LoginProvider<V>[];
405
+ title?: string;
406
+ message?: string;
407
+ /** Comes before the name of each provider, on its button. */
408
+ providerLabel?: string;
409
+ /** The toast when a sign-in fails. */
410
+ errorMessage?: string;
411
+ }
412
+
413
+ declare const Login: <V extends LoginVendor>({ vendor, providers, title, message, providerLabel, errorMessage, }: LoginProps<V>) => react.JSX.Element;
414
+
415
+ interface SignOutButtonProps {
416
+ /** The accessible name of the icon button. */
417
+ label?: string;
418
+ /** The question of the modal a click opens. */
419
+ confirmTitle?: string;
420
+ /** The button of the modal that signs out. */
421
+ confirmLabel?: string;
422
+ /** The button of the modal that keeps the user signed in. */
423
+ cancelLabel?: string;
424
+ /** The toast when signing out fails. */
425
+ errorMessage?: string;
426
+ }
427
+
428
+ declare const SignOutButton: ({ label, confirmTitle, confirmLabel, cancelLabel, errorMessage, }: SignOutButtonProps) => react.JSX.Element;
429
+
385
430
  interface UseAuthResult extends Omit<AuthAdapter, "onSessionChange"> {
386
431
  status: AuthStatus;
387
432
  user: AuthUser | null;
@@ -494,5 +539,5 @@ declare class HTTPClient {
494
539
  patch<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T | undefined>;
495
540
  }
496
541
 
497
- export { AuthAdapter, AuthProvider, AuthSession, AuxiliaryColor, Button, Card, Checkbox, ConnectedModal, DataColor, DataGrid, Error, Form, HTTPClient, Heading, Icon, Input, Loader, Modal, Radio, ReduxProvider, ReduxProviderProps, Select, SemanticColor, Sidebar, Spinner, StatsCard, Tag, Text, TextArea, Toaster, WhatsAppButton, ZustandProviders, ZustandProvidersProps, appInitialState, getAuthSession, splitURLasPath, useAppStore, useAuth, usePageStore, useRouterStore, useToastStore };
498
- export type { AppState, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InputProps, LoaderProps, ModalProps, PageState, RadioProps, ReduxStore, RouterState, SelectOption, SelectProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TagColor, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, WhatsAppButtonProps };
542
+ export { AuthAdapter, AuthProvider, AuthSession, AuxiliaryColor, Button, Card, Checkbox, ConnectedModal, DataColor, DataGrid, Error, Form, HTTPClient, Heading, Icon, Input, Loader, Login, Modal, Radio, ReduxProvider, ReduxProviderProps, Select, SemanticColor, Sidebar, SignOutButton, Spinner, StatsCard, Tag, Text, TextArea, Toaster, WhatsAppButton, ZustandProviders, ZustandProvidersProps, appInitialState, getAuthSession, splitURLasPath, useAppStore, useAuth, usePageStore, useRouterStore, useToastStore };
543
+ export type { AppState, ButtonColor, ButtonProps, ButtonVariant, CardProps, CheckboxProps, CheckboxVariant, ConnectedModalProps, DataGridColumn, DataGridProps, ErrorProps, FormProps, HeadingProps, HttpClientConfig, HttpRequestConfig, IconName, IconProps, InputProps, LoaderProps, LoginProvider, LoginVendor, ModalProps, PageState, RadioProps, ReduxStore, RouterState, SelectOption, SelectProps, SidebarItem, SidebarProps, SidebarSection, SidebarUser, Size, SpinnerProps, SpinnerVariant, StatsCardProps, TagColor, TagProps, TextAreaProps, TextProps, TextVariant, Toast, ToastState, ToastType, WhatsAppButtonProps };
package/dist/index.js CHANGED
@@ -2,12 +2,15 @@
2
2
  import {
3
3
  AuthProvider,
4
4
  Button,
5
+ Card,
5
6
  ConnectedModal,
6
7
  Heading,
7
8
  Icon,
8
9
  Loader,
10
+ Login,
9
11
  Modal,
10
12
  ReduxProvider,
13
+ SignOutButton,
11
14
  Spinner,
12
15
  Text,
13
16
  Toaster,
@@ -21,7 +24,7 @@ import {
21
24
  usePageStore,
22
25
  useRouterStore,
23
26
  useToastStore
24
- } from "./chunk-PAZK5RXI.js";
27
+ } from "./chunk-Y453WAGC.js";
25
28
  import {
26
29
  Error,
27
30
  FormInput,
@@ -770,57 +773,6 @@ var Sidebar = ({
770
773
  ] });
771
774
  };
772
775
 
773
- // core/card/card.styles.ts
774
- import { tv as tv10 } from "tailwind-variants";
775
- var card = tv10({
776
- slots: {
777
- // A soft, wide shadow in the color of the card. shadow-sm only spreads 1 to
778
- // 3px and reads as part of the border on a white page.
779
- base: "flex flex-col gap-6 w-full p-6 rounded-2xl border shadow-lg",
780
- header: "flex flex-col gap-1"
781
- },
782
- variants: {
783
- color: {
784
- primary: {
785
- base: "border-zl-primary bg-zl-primary/15 shadow-zl-primary/20"
786
- },
787
- success: {
788
- base: "border-zl-success bg-zl-success/15 shadow-zl-success/20"
789
- },
790
- danger: { base: "border-zl-danger bg-zl-danger/15 shadow-zl-danger/20" },
791
- warning: {
792
- base: "border-zl-warning bg-zl-warning/15 shadow-zl-warning/20"
793
- },
794
- info: { base: "border-zl-info bg-zl-info/15 shadow-zl-info/20" },
795
- muted: { base: "border-zl-muted bg-zl-muted/15 shadow-zl-muted/20" },
796
- none: { base: "border-gray-200 bg-white shadow-black/12" }
797
- }
798
- },
799
- defaultVariants: {
800
- color: "none"
801
- }
802
- });
803
-
804
- // core/card/card.tsx
805
- import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
806
- var Card = ({
807
- children,
808
- title,
809
- titleLevel = 2,
810
- message,
811
- color = "none"
812
- }) => {
813
- const { base, header: header2 } = card({ color });
814
- const messageColor = color === "none" ? "muted" : "none";
815
- return /* @__PURE__ */ jsxs11("div", { "data-testid": "card", className: base(), children: [
816
- (title || message) && /* @__PURE__ */ jsxs11("div", { className: header2(), children: [
817
- title && /* @__PURE__ */ jsx13(Heading, { level: titleLevel, children: title }),
818
- message && /* @__PURE__ */ jsx13(Text, { color: messageColor, children: message })
819
- ] }),
820
- children
821
- ] });
822
- };
823
-
824
776
  // core/http/http.client.ts
825
777
  import axios from "axios";
826
778
  var HTTPClient = class {
@@ -908,11 +860,13 @@ export {
908
860
  Icon,
909
861
  Input,
910
862
  Loader,
863
+ Login,
911
864
  Modal,
912
865
  Radio,
913
866
  ReduxProvider,
914
867
  Select,
915
868
  Sidebar,
869
+ SignOutButton,
916
870
  Spinner,
917
871
  StatsCard,
918
872
  Tag,
@@ -6,7 +6,7 @@ import {
6
6
  ZustandProviders,
7
7
  usePageStore,
8
8
  useRouterStore
9
- } from "../chunk-PAZK5RXI.js";
9
+ } from "../chunk-Y453WAGC.js";
10
10
 
11
11
  // core/next/root-layout/root-layout.styles.ts
12
12
  import { tv } from "tailwind-variants";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexandregme/zljs",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "Opinionated, accessible React component library for enterprise apps (Next.js, Tailwind CSS v4).",
5
5
  "keywords": [
6
6
  "react",