@alexandregme/zljs 3.3.0 → 3.4.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 +1 -0
- package/dist/{chunk-PAZK5RXI.js → chunk-TYN56WKD.js} +90 -7
- package/dist/index.d.ts +16 -1
- package/dist/index.js +3 -1
- package/dist/next/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,7 @@ A change that needs action in an app has a **Migration** note. When updating, re
|
|
|
18
18
|
- The types `AuthAdapter` and `AuthSession`, the contract an app implements to connect its provider
|
|
19
19
|
- `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
20
|
- `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`
|
|
21
22
|
|
|
22
23
|
## [3.2.0] - 2026-11-10
|
|
23
24
|
|
|
@@ -684,12 +684,94 @@ var useAuth = () => {
|
|
|
684
684
|
};
|
|
685
685
|
};
|
|
686
686
|
|
|
687
|
+
// features/auth/components/sign-out/sign-out-modal.const.ts
|
|
688
|
+
var SIGN_OUT_MODAL_ID = "zljs-sign-out";
|
|
689
|
+
|
|
690
|
+
// features/auth/components/sign-out/sign-out-modal.styles.ts
|
|
691
|
+
import { tv as tv9 } from "tailwind-variants";
|
|
692
|
+
var signOutModal = tv9({
|
|
693
|
+
slots: {
|
|
694
|
+
actions: "flex justify-end gap-2"
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
// features/auth/components/sign-out/sign-out-modal.tsx
|
|
699
|
+
import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
700
|
+
var SignOutModal = ({
|
|
701
|
+
title: title2 = "Sign out?",
|
|
702
|
+
confirmLabel = "Sign out",
|
|
703
|
+
cancelLabel = "Cancel",
|
|
704
|
+
errorMessage = "Could not sign out. Try again."
|
|
705
|
+
}) => {
|
|
706
|
+
const { signOut } = useAuth();
|
|
707
|
+
const closeModal = useAppStore((s) => s.closeModal);
|
|
708
|
+
const { actions } = signOutModal();
|
|
709
|
+
const stay = () => {
|
|
710
|
+
closeModal(SIGN_OUT_MODAL_ID);
|
|
711
|
+
};
|
|
712
|
+
const leave = () => {
|
|
713
|
+
closeModal(SIGN_OUT_MODAL_ID);
|
|
714
|
+
signOut().catch(() => {
|
|
715
|
+
useToastStore.getState().error(errorMessage);
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
return /* @__PURE__ */ jsx11(
|
|
719
|
+
ConnectedModal,
|
|
720
|
+
{
|
|
721
|
+
modalId: SIGN_OUT_MODAL_ID,
|
|
722
|
+
title: title2,
|
|
723
|
+
size: "xs",
|
|
724
|
+
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 })
|
|
728
|
+
] })
|
|
729
|
+
}
|
|
730
|
+
);
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// features/auth/components/sign-out/sign-out-button.tsx
|
|
734
|
+
import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
735
|
+
var SignOutButton = ({
|
|
736
|
+
label = "Sign out",
|
|
737
|
+
confirmTitle,
|
|
738
|
+
confirmLabel,
|
|
739
|
+
cancelLabel,
|
|
740
|
+
errorMessage
|
|
741
|
+
}) => {
|
|
742
|
+
const openModal = useAppStore((s) => s.openModal);
|
|
743
|
+
const ask = () => {
|
|
744
|
+
openModal(SIGN_OUT_MODAL_ID);
|
|
745
|
+
};
|
|
746
|
+
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
747
|
+
/* @__PURE__ */ jsx12(
|
|
748
|
+
Button,
|
|
749
|
+
{
|
|
750
|
+
variant: "icon",
|
|
751
|
+
color: "none",
|
|
752
|
+
icon: "LogOut",
|
|
753
|
+
"aria-label": label,
|
|
754
|
+
onClick: ask
|
|
755
|
+
}
|
|
756
|
+
),
|
|
757
|
+
/* @__PURE__ */ jsx12(
|
|
758
|
+
SignOutModal,
|
|
759
|
+
{
|
|
760
|
+
title: confirmTitle,
|
|
761
|
+
confirmLabel,
|
|
762
|
+
cancelLabel,
|
|
763
|
+
errorMessage
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
] });
|
|
767
|
+
};
|
|
768
|
+
|
|
687
769
|
// features/providers/components/zustand-providers/zustand-providers.tsx
|
|
688
|
-
import { Fragment as
|
|
689
|
-
var ZustandProviders = ({ children, auth }) => /* @__PURE__ */
|
|
690
|
-
/* @__PURE__ */
|
|
691
|
-
/* @__PURE__ */
|
|
692
|
-
auth ? /* @__PURE__ */
|
|
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
|
|
693
775
|
] });
|
|
694
776
|
|
|
695
777
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
@@ -726,7 +808,7 @@ var createReduxStore = ({
|
|
|
726
808
|
};
|
|
727
809
|
|
|
728
810
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
729
|
-
import { jsx as
|
|
811
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
730
812
|
var ReduxProvider = ({
|
|
731
813
|
children,
|
|
732
814
|
reducers = {},
|
|
@@ -742,7 +824,7 @@ var ReduxProvider = ({
|
|
|
742
824
|
coreReducers
|
|
743
825
|
})
|
|
744
826
|
);
|
|
745
|
-
return /* @__PURE__ */
|
|
827
|
+
return /* @__PURE__ */ jsx14(Provider, { store, children });
|
|
746
828
|
};
|
|
747
829
|
|
|
748
830
|
// core/state/zustand/router/router.utils.ts
|
|
@@ -819,6 +901,7 @@ export {
|
|
|
819
901
|
getAuthSession,
|
|
820
902
|
AuthProvider,
|
|
821
903
|
useAuth,
|
|
904
|
+
SignOutButton,
|
|
822
905
|
ZustandProviders,
|
|
823
906
|
ReduxProvider,
|
|
824
907
|
splitURLasPath,
|
package/dist/index.d.ts
CHANGED
|
@@ -382,6 +382,21 @@ interface AuthProviderProps extends AuthConfig {
|
|
|
382
382
|
*/
|
|
383
383
|
declare const AuthProvider: ({ adapter, appId, children, }: AuthProviderProps) => react.JSX.Element;
|
|
384
384
|
|
|
385
|
+
interface SignOutButtonProps {
|
|
386
|
+
/** The accessible name of the icon button. */
|
|
387
|
+
label?: string;
|
|
388
|
+
/** The question of the modal a click opens. */
|
|
389
|
+
confirmTitle?: string;
|
|
390
|
+
/** The button of the modal that signs out. */
|
|
391
|
+
confirmLabel?: string;
|
|
392
|
+
/** The button of the modal that keeps the user signed in. */
|
|
393
|
+
cancelLabel?: string;
|
|
394
|
+
/** The toast when signing out fails. */
|
|
395
|
+
errorMessage?: string;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
declare const SignOutButton: ({ label, confirmTitle, confirmLabel, cancelLabel, errorMessage, }: SignOutButtonProps) => react.JSX.Element;
|
|
399
|
+
|
|
385
400
|
interface UseAuthResult extends Omit<AuthAdapter, "onSessionChange"> {
|
|
386
401
|
status: AuthStatus;
|
|
387
402
|
user: AuthUser | null;
|
|
@@ -494,5 +509,5 @@ declare class HTTPClient {
|
|
|
494
509
|
patch<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T | undefined>;
|
|
495
510
|
}
|
|
496
511
|
|
|
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 };
|
|
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 };
|
|
498
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 };
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Loader,
|
|
9
9
|
Modal,
|
|
10
10
|
ReduxProvider,
|
|
11
|
+
SignOutButton,
|
|
11
12
|
Spinner,
|
|
12
13
|
Text,
|
|
13
14
|
Toaster,
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
usePageStore,
|
|
22
23
|
useRouterStore,
|
|
23
24
|
useToastStore
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-TYN56WKD.js";
|
|
25
26
|
import {
|
|
26
27
|
Error,
|
|
27
28
|
FormInput,
|
|
@@ -913,6 +914,7 @@ export {
|
|
|
913
914
|
ReduxProvider,
|
|
914
915
|
Select,
|
|
915
916
|
Sidebar,
|
|
917
|
+
SignOutButton,
|
|
916
918
|
Spinner,
|
|
917
919
|
StatsCard,
|
|
918
920
|
Tag,
|
package/dist/next/index.js
CHANGED