@alexandregme/zljs 3.4.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
@@ -18,7 +31,6 @@ A change that needs action in an app has a **Migration** note. When updating, re
18
31
  - The types `AuthAdapter` and `AuthSession`, the contract an app implements to connect its provider
19
32
  - `auth` on `ZustandProviders` and `AppProviders`, with the `adapter` and `appId` of `AuthProvider`, which mounts `AuthProvider` so the app doesn't. Without `auth`, nothing of auth is mounted
20
33
  - `color` on `Modal` and `ConnectedModal`, a semantic color for the title and a light background in that color, such as `danger` for a question that can't be undone. `none`, the default, keeps the modal as it was
21
- - `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`
22
34
 
23
35
  ## [3.2.0] - 2026-11-10
24
36
 
@@ -435,7 +447,8 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
435
447
 
436
448
  The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
437
449
 
438
- [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
439
452
  [3.3.0]: https://github.com/alexandregme/zljs/compare/v3.2.0...v3.3.0
440
453
  [3.2.0]: https://github.com/alexandregme/zljs/compare/v3.1.0...v3.2.0
441
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,19 +735,79 @@ 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
+
687
798
  // features/auth/components/sign-out/sign-out-modal.const.ts
688
799
  var SIGN_OUT_MODAL_ID = "zljs-sign-out";
689
800
 
690
801
  // features/auth/components/sign-out/sign-out-modal.styles.ts
691
- import { tv as tv9 } from "tailwind-variants";
692
- var signOutModal = tv9({
802
+ import { tv as tv11 } from "tailwind-variants";
803
+ var signOutModal = tv11({
693
804
  slots: {
694
805
  actions: "flex justify-end gap-2"
695
806
  }
696
807
  });
697
808
 
698
809
  // features/auth/components/sign-out/sign-out-modal.tsx
699
- import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
810
+ import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
700
811
  var SignOutModal = ({
701
812
  title: title2 = "Sign out?",
702
813
  confirmLabel = "Sign out",
@@ -715,23 +826,23 @@ var SignOutModal = ({
715
826
  useToastStore.getState().error(errorMessage);
716
827
  });
717
828
  };
718
- return /* @__PURE__ */ jsx11(
829
+ return /* @__PURE__ */ jsx13(
719
830
  ConnectedModal,
720
831
  {
721
832
  modalId: SIGN_OUT_MODAL_ID,
722
833
  title: title2,
723
834
  size: "xs",
724
835
  color: "danger",
725
- children: /* @__PURE__ */ jsxs3("div", { className: actions(), children: [
726
- /* @__PURE__ */ jsx11(Button, { color: "ghost", onClick: stay, children: cancelLabel }),
727
- /* @__PURE__ */ jsx11(Button, { color: "danger", onClick: leave, children: confirmLabel })
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 })
728
839
  ] })
729
840
  }
730
841
  );
731
842
  };
732
843
 
733
844
  // features/auth/components/sign-out/sign-out-button.tsx
734
- import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
845
+ import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
735
846
  var SignOutButton = ({
736
847
  label = "Sign out",
737
848
  confirmTitle,
@@ -743,8 +854,8 @@ var SignOutButton = ({
743
854
  const ask = () => {
744
855
  openModal(SIGN_OUT_MODAL_ID);
745
856
  };
746
- return /* @__PURE__ */ jsxs4(Fragment4, { children: [
747
- /* @__PURE__ */ jsx12(
857
+ return /* @__PURE__ */ jsxs5(Fragment4, { children: [
858
+ /* @__PURE__ */ jsx14(
748
859
  Button,
749
860
  {
750
861
  variant: "icon",
@@ -754,7 +865,7 @@ var SignOutButton = ({
754
865
  onClick: ask
755
866
  }
756
867
  ),
757
- /* @__PURE__ */ jsx12(
868
+ /* @__PURE__ */ jsx14(
758
869
  SignOutModal,
759
870
  {
760
871
  title: confirmTitle,
@@ -767,11 +878,11 @@ var SignOutButton = ({
767
878
  };
768
879
 
769
880
  // features/providers/components/zustand-providers/zustand-providers.tsx
770
- import { Fragment as Fragment5, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
771
- var ZustandProviders = ({ children, auth }) => /* @__PURE__ */ jsxs5(Fragment5, { children: [
772
- /* @__PURE__ */ jsx13(Loader, {}),
773
- /* @__PURE__ */ jsx13(Toaster, {}),
774
- auth ? /* @__PURE__ */ jsx13(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
775
886
  ] });
776
887
 
777
888
  // core/state/redux/redux-provider/redux-provider.tsx
@@ -808,7 +919,7 @@ var createReduxStore = ({
808
919
  };
809
920
 
810
921
  // core/state/redux/redux-provider/redux-provider.tsx
811
- import { jsx as jsx14 } from "react/jsx-runtime";
922
+ import { jsx as jsx16 } from "react/jsx-runtime";
812
923
  var ReduxProvider = ({
813
924
  children,
814
925
  reducers = {},
@@ -824,7 +935,7 @@ var ReduxProvider = ({
824
935
  coreReducers
825
936
  })
826
937
  );
827
- return /* @__PURE__ */ jsx14(Provider, { store, children });
938
+ return /* @__PURE__ */ jsx16(Provider, { store, children });
828
939
  };
829
940
 
830
941
  // core/state/zustand/router/router.utils.ts
@@ -900,7 +1011,9 @@ export {
900
1011
  Loader,
901
1012
  getAuthSession,
902
1013
  AuthProvider,
1014
+ Card,
903
1015
  useAuth,
1016
+ Login,
904
1017
  SignOutButton,
905
1018
  ZustandProviders,
906
1019
  ReduxProvider,
package/dist/index.d.ts CHANGED
@@ -382,6 +382,36 @@ 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
+
385
415
  interface SignOutButtonProps {
386
416
  /** The accessible name of the icon button. */
387
417
  label?: string;
@@ -509,5 +539,5 @@ declare class HTTPClient {
509
539
  patch<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T | undefined>;
510
540
  }
511
541
 
512
- 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, SignOutButton, Spinner, StatsCard, Tag, Text, TextArea, Toaster, WhatsAppButton, ZustandProviders, ZustandProvidersProps, appInitialState, getAuthSession, splitURLasPath, useAppStore, useAuth, usePageStore, useRouterStore, useToastStore };
513
- 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,10 +2,12 @@
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,
11
13
  SignOutButton,
@@ -22,7 +24,7 @@ import {
22
24
  usePageStore,
23
25
  useRouterStore,
24
26
  useToastStore
25
- } from "./chunk-TYN56WKD.js";
27
+ } from "./chunk-Y453WAGC.js";
26
28
  import {
27
29
  Error,
28
30
  FormInput,
@@ -771,57 +773,6 @@ var Sidebar = ({
771
773
  ] });
772
774
  };
773
775
 
774
- // core/card/card.styles.ts
775
- import { tv as tv10 } from "tailwind-variants";
776
- var card = tv10({
777
- slots: {
778
- // A soft, wide shadow in the color of the card. shadow-sm only spreads 1 to
779
- // 3px and reads as part of the border on a white page.
780
- base: "flex flex-col gap-6 w-full p-6 rounded-2xl border shadow-lg",
781
- header: "flex flex-col gap-1"
782
- },
783
- variants: {
784
- color: {
785
- primary: {
786
- base: "border-zl-primary bg-zl-primary/15 shadow-zl-primary/20"
787
- },
788
- success: {
789
- base: "border-zl-success bg-zl-success/15 shadow-zl-success/20"
790
- },
791
- danger: { base: "border-zl-danger bg-zl-danger/15 shadow-zl-danger/20" },
792
- warning: {
793
- base: "border-zl-warning bg-zl-warning/15 shadow-zl-warning/20"
794
- },
795
- info: { base: "border-zl-info bg-zl-info/15 shadow-zl-info/20" },
796
- muted: { base: "border-zl-muted bg-zl-muted/15 shadow-zl-muted/20" },
797
- none: { base: "border-gray-200 bg-white shadow-black/12" }
798
- }
799
- },
800
- defaultVariants: {
801
- color: "none"
802
- }
803
- });
804
-
805
- // core/card/card.tsx
806
- import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
807
- var Card = ({
808
- children,
809
- title,
810
- titleLevel = 2,
811
- message,
812
- color = "none"
813
- }) => {
814
- const { base, header: header2 } = card({ color });
815
- const messageColor = color === "none" ? "muted" : "none";
816
- return /* @__PURE__ */ jsxs11("div", { "data-testid": "card", className: base(), children: [
817
- (title || message) && /* @__PURE__ */ jsxs11("div", { className: header2(), children: [
818
- title && /* @__PURE__ */ jsx13(Heading, { level: titleLevel, children: title }),
819
- message && /* @__PURE__ */ jsx13(Text, { color: messageColor, children: message })
820
- ] }),
821
- children
822
- ] });
823
- };
824
-
825
776
  // core/http/http.client.ts
826
777
  import axios from "axios";
827
778
  var HTTPClient = class {
@@ -909,6 +860,7 @@ export {
909
860
  Icon,
910
861
  Input,
911
862
  Loader,
863
+ Login,
912
864
  Modal,
913
865
  Radio,
914
866
  ReduxProvider,
@@ -6,7 +6,7 @@ import {
6
6
  ZustandProviders,
7
7
  usePageStore,
8
8
  useRouterStore
9
- } from "../chunk-TYN56WKD.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.4.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",