@alexandregme/zljs 3.1.0 → 3.3.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 +20 -1
- package/dist/{chunk-ZIY5NUGA.js → chunk-PAZK5RXI.js} +135 -21
- package/dist/index.d.ts +30 -8
- package/dist/index.js +7 -1
- package/dist/next/index.d.ts +12 -5
- package/dist/next/index.js +28 -7
- package/dist/redux-provider.interface-D6qhg7ND.d.ts +77 -0
- package/package.json +1 -1
- package/dist/redux-provider.interface-DXOZKAMA.d.ts +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,23 @@ A change that needs action in an app has a **Migration** note. When updating, re
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [3.3.0] - 2026-11-10
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Authentication that doesn't depend on a provider. `AuthProvider` takes an `adapter` (`AuthAdapter`), which connects to the app's auth provider, and an `appId`, the key of the app in each user's `roles`, so the same users sign in to several apps with a role in each
|
|
16
|
+
- `useAuth`, which returns `status` (`loading`, `authenticated` or `unauthenticated`), `user`, `role` in this app, and the sign-in methods: `signInWithOAuth`, `signInWithPassword`, `signInWithMagicLink` and `signOut`
|
|
17
|
+
- `getAuthSession`, which returns the session to code outside React, such as a thunk
|
|
18
|
+
- The types `AuthAdapter` and `AuthSession`, the contract an app implements to connect its provider
|
|
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
|
+
- `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
|
+
|
|
22
|
+
## [3.2.0] - 2026-11-10
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- `PageWrapper`, in `@alexandregme/zljs/next`, the frame of a page with a single block in the middle, such as a sign-in card: it takes the height of the screen, centers its children and keeps them narrow
|
|
27
|
+
|
|
11
28
|
## [3.1.0] - 2026-11-10
|
|
12
29
|
|
|
13
30
|
### Added
|
|
@@ -417,7 +434,9 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
|
|
|
417
434
|
|
|
418
435
|
The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
|
|
419
436
|
|
|
420
|
-
[Unreleased]: https://github.com/alexandregme/zljs/compare/v3.
|
|
437
|
+
[Unreleased]: https://github.com/alexandregme/zljs/compare/v3.3.0...HEAD
|
|
438
|
+
[3.3.0]: https://github.com/alexandregme/zljs/compare/v3.2.0...v3.3.0
|
|
439
|
+
[3.2.0]: https://github.com/alexandregme/zljs/compare/v3.1.0...v3.2.0
|
|
421
440
|
[3.1.0]: https://github.com/alexandregme/zljs/compare/v3.0.0...v3.1.0
|
|
422
441
|
[3.0.0]: https://github.com/alexandregme/zljs/compare/v2.3.0...v3.0.0
|
|
423
442
|
[2.3.0]: https://github.com/alexandregme/zljs/compare/v2.2.0...v2.3.0
|
|
@@ -252,7 +252,7 @@ var overlay = tv4({
|
|
|
252
252
|
base: "fixed inset-0 bg-black/50"
|
|
253
253
|
});
|
|
254
254
|
var content = tv4({
|
|
255
|
-
base: "fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2
|
|
255
|
+
base: "fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-lg shadow-lg p-6 w-full focus:outline-none max-h-[90vh] overflow-y-auto",
|
|
256
256
|
variants: {
|
|
257
257
|
size: {
|
|
258
258
|
xs: "max-w-xs",
|
|
@@ -261,17 +261,43 @@ var content = tv4({
|
|
|
261
261
|
lg: "max-w-2xl",
|
|
262
262
|
xl: "max-w-4xl",
|
|
263
263
|
full: "max-w-6xl"
|
|
264
|
+
},
|
|
265
|
+
// An opaque tint: a translucent one, as Card has, would show the dark overlay behind the modal.
|
|
266
|
+
color: {
|
|
267
|
+
primary: "bg-[color-mix(in_srgb,var(--color-zl-primary)_15%,white)]",
|
|
268
|
+
success: "bg-[color-mix(in_srgb,var(--color-zl-success)_15%,white)]",
|
|
269
|
+
danger: "bg-[color-mix(in_srgb,var(--color-zl-danger)_15%,white)]",
|
|
270
|
+
warning: "bg-[color-mix(in_srgb,var(--color-zl-warning)_15%,white)]",
|
|
271
|
+
info: "bg-[color-mix(in_srgb,var(--color-zl-info)_15%,white)]",
|
|
272
|
+
muted: "bg-[color-mix(in_srgb,var(--color-zl-muted)_15%,white)]",
|
|
273
|
+
none: "bg-white"
|
|
264
274
|
}
|
|
265
275
|
},
|
|
266
276
|
defaultVariants: {
|
|
267
|
-
size: "md"
|
|
277
|
+
size: "md",
|
|
278
|
+
color: "none"
|
|
268
279
|
}
|
|
269
280
|
});
|
|
270
281
|
var header = tv4({
|
|
271
282
|
base: "flex items-start justify-between"
|
|
272
283
|
});
|
|
273
284
|
var title = tv4({
|
|
274
|
-
base: "text-lg font-semibold
|
|
285
|
+
base: "text-lg font-semibold m-0",
|
|
286
|
+
variants: {
|
|
287
|
+
// The strong value, as the colored toasts use: the plain one is too light on the tint.
|
|
288
|
+
color: {
|
|
289
|
+
primary: "text-zl-primary-strong",
|
|
290
|
+
success: "text-zl-success-strong",
|
|
291
|
+
danger: "text-zl-danger-strong",
|
|
292
|
+
warning: "text-zl-warning-strong",
|
|
293
|
+
info: "text-zl-info-strong",
|
|
294
|
+
muted: "text-zl-muted-strong",
|
|
295
|
+
none: "text-gray-900"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
defaultVariants: {
|
|
299
|
+
color: "none"
|
|
300
|
+
}
|
|
275
301
|
});
|
|
276
302
|
var description = tv4({
|
|
277
303
|
base: "text-sm text-gray-600 mt-2"
|
|
@@ -288,18 +314,19 @@ var Modal = ({
|
|
|
288
314
|
title: title2,
|
|
289
315
|
description: description2,
|
|
290
316
|
children,
|
|
291
|
-
size = "md"
|
|
317
|
+
size = "md",
|
|
318
|
+
color = "none"
|
|
292
319
|
}) => {
|
|
293
320
|
return /* @__PURE__ */ jsx4(Dialog.Root, { open, onOpenChange: (isOpen) => !isOpen && onClose(), children: /* @__PURE__ */ jsxs2(Dialog.Portal, { children: [
|
|
294
321
|
/* @__PURE__ */ jsx4(Dialog.Overlay, { className: overlay() }),
|
|
295
322
|
/* @__PURE__ */ jsxs2(
|
|
296
323
|
Dialog.Content,
|
|
297
324
|
{
|
|
298
|
-
className: content({ size }),
|
|
325
|
+
className: content({ size, color }),
|
|
299
326
|
...!description2 && { "aria-describedby": void 0 },
|
|
300
327
|
children: [
|
|
301
328
|
/* @__PURE__ */ jsxs2("div", { className: header(), children: [
|
|
302
|
-
/* @__PURE__ */ jsx4(Dialog.Title, { className: title(), children: title2 }),
|
|
329
|
+
/* @__PURE__ */ jsx4(Dialog.Title, { className: title({ color }), children: title2 }),
|
|
303
330
|
/* @__PURE__ */ jsx4(Button, { icon: "X", "aria-label": "Close", onClick: onClose })
|
|
304
331
|
] }),
|
|
305
332
|
description2 && /* @__PURE__ */ jsx4(Dialog.Description, { className: description(), children: description2 }),
|
|
@@ -509,6 +536,7 @@ var ConnectedModal = ({
|
|
|
509
536
|
title: title2,
|
|
510
537
|
description: description2,
|
|
511
538
|
size,
|
|
539
|
+
color,
|
|
512
540
|
children
|
|
513
541
|
}) => {
|
|
514
542
|
const open = useAppStore((s) => s.isModalOpen(modalId));
|
|
@@ -524,6 +552,7 @@ var ConnectedModal = ({
|
|
|
524
552
|
title: title2,
|
|
525
553
|
description: description2,
|
|
526
554
|
size,
|
|
555
|
+
color,
|
|
527
556
|
children
|
|
528
557
|
}
|
|
529
558
|
);
|
|
@@ -573,12 +602,94 @@ var Loader = ({ label = "Loading" }) => {
|
|
|
573
602
|
return /* @__PURE__ */ jsx9("div", { className: loader(), children: /* @__PURE__ */ jsx9(Spinner, { size: "lg", label }) });
|
|
574
603
|
};
|
|
575
604
|
|
|
576
|
-
// features/
|
|
577
|
-
import {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
605
|
+
// features/auth/state/auth.store.ts
|
|
606
|
+
import { create as create3 } from "zustand";
|
|
607
|
+
import { devtools as devtools3 } from "zustand/middleware";
|
|
608
|
+
|
|
609
|
+
// features/auth/state/auth.const.ts
|
|
610
|
+
var authInitialState = {
|
|
611
|
+
status: "loading",
|
|
612
|
+
session: null,
|
|
613
|
+
adapter: null,
|
|
614
|
+
appId: null
|
|
615
|
+
};
|
|
616
|
+
var authDevtools = { name: "zljs", store: "auth" };
|
|
617
|
+
|
|
618
|
+
// features/auth/state/auth.store.ts
|
|
619
|
+
var useAuthStore = create3()(
|
|
620
|
+
devtools3(
|
|
621
|
+
(set) => ({
|
|
622
|
+
...authInitialState,
|
|
623
|
+
setSession: (session) => set(
|
|
624
|
+
{
|
|
625
|
+
session,
|
|
626
|
+
status: session ? "authenticated" : "unauthenticated"
|
|
627
|
+
},
|
|
628
|
+
false,
|
|
629
|
+
"setSession"
|
|
630
|
+
),
|
|
631
|
+
configure: (adapter, appId) => set({ adapter, appId }, false, "configure"),
|
|
632
|
+
reset: () => set(authInitialState, false, "reset")
|
|
633
|
+
}),
|
|
634
|
+
authDevtools
|
|
635
|
+
)
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
// features/auth/state/get-auth-session/get-auth-session.ts
|
|
639
|
+
var getAuthSession = () => useAuthStore.getState().session;
|
|
640
|
+
|
|
641
|
+
// features/auth/components/auth-provider/auth-provider.tsx
|
|
642
|
+
import { useEffect as useEffect2 } from "react";
|
|
643
|
+
import { Fragment as Fragment3, jsx as jsx10 } from "react/jsx-runtime";
|
|
644
|
+
var AuthProvider = ({
|
|
645
|
+
adapter,
|
|
646
|
+
appId,
|
|
581
647
|
children
|
|
648
|
+
}) => {
|
|
649
|
+
const configure = useAuthStore((s) => s.configure);
|
|
650
|
+
const setSession = useAuthStore((s) => s.setSession);
|
|
651
|
+
const reset = useAuthStore((s) => s.reset);
|
|
652
|
+
useEffect2(() => {
|
|
653
|
+
configure(adapter, appId);
|
|
654
|
+
const unsubscribe = adapter.onSessionChange(setSession);
|
|
655
|
+
return () => {
|
|
656
|
+
unsubscribe();
|
|
657
|
+
reset();
|
|
658
|
+
};
|
|
659
|
+
}, [adapter, appId, configure, setSession, reset]);
|
|
660
|
+
return /* @__PURE__ */ jsx10(Fragment3, { children });
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
// features/auth/hooks/use-auth/use-auth.ts
|
|
664
|
+
var requireAdapter = () => {
|
|
665
|
+
const { adapter } = useAuthStore.getState();
|
|
666
|
+
if (!adapter) {
|
|
667
|
+
throw new Error("useAuth must be used inside <AuthProvider>");
|
|
668
|
+
}
|
|
669
|
+
return adapter;
|
|
670
|
+
};
|
|
671
|
+
var useAuth = () => {
|
|
672
|
+
const status = useAuthStore((s) => s.status);
|
|
673
|
+
const session = useAuthStore((s) => s.session);
|
|
674
|
+
const appId = useAuthStore((s) => s.appId);
|
|
675
|
+
const user = session?.user ?? null;
|
|
676
|
+
return {
|
|
677
|
+
status,
|
|
678
|
+
user,
|
|
679
|
+
role: (appId && user?.roles[appId]) ?? null,
|
|
680
|
+
signInWithOAuth: (provider) => requireAdapter().signInWithOAuth(provider),
|
|
681
|
+
signInWithPassword: (credentials) => requireAdapter().signInWithPassword(credentials),
|
|
682
|
+
signInWithMagicLink: (email) => requireAdapter().signInWithMagicLink(email),
|
|
683
|
+
signOut: () => requireAdapter().signOut()
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
// 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
|
|
582
693
|
] });
|
|
583
694
|
|
|
584
695
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
@@ -615,7 +726,7 @@ var createReduxStore = ({
|
|
|
615
726
|
};
|
|
616
727
|
|
|
617
728
|
// core/state/redux/redux-provider/redux-provider.tsx
|
|
618
|
-
import { jsx as
|
|
729
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
619
730
|
var ReduxProvider = ({
|
|
620
731
|
children,
|
|
621
732
|
reducers = {},
|
|
@@ -631,7 +742,7 @@ var ReduxProvider = ({
|
|
|
631
742
|
coreReducers
|
|
632
743
|
})
|
|
633
744
|
);
|
|
634
|
-
return /* @__PURE__ */
|
|
745
|
+
return /* @__PURE__ */ jsx12(Provider, { store, children });
|
|
635
746
|
};
|
|
636
747
|
|
|
637
748
|
// core/state/zustand/router/router.utils.ts
|
|
@@ -649,8 +760,8 @@ var splitURLasPath = (urlAsPath) => {
|
|
|
649
760
|
};
|
|
650
761
|
|
|
651
762
|
// core/state/zustand/router/router.store.ts
|
|
652
|
-
import { create as
|
|
653
|
-
import { devtools as
|
|
763
|
+
import { create as create4 } from "zustand";
|
|
764
|
+
import { devtools as devtools4 } from "zustand/middleware";
|
|
654
765
|
|
|
655
766
|
// core/state/zustand/router/router.const.ts
|
|
656
767
|
var routerInitialState = {
|
|
@@ -660,8 +771,8 @@ var routerInitialState = {
|
|
|
660
771
|
var routerDevtools = { name: "zljs", store: "router" };
|
|
661
772
|
|
|
662
773
|
// core/state/zustand/router/router.store.ts
|
|
663
|
-
var useRouterStore =
|
|
664
|
-
|
|
774
|
+
var useRouterStore = create4()(
|
|
775
|
+
devtools4(
|
|
665
776
|
(set) => ({
|
|
666
777
|
...routerInitialState,
|
|
667
778
|
setRoute: (urlAsPath) => set({ urlAsPath, query: splitURLasPath(urlAsPath) }, false, "setRoute")
|
|
@@ -671,8 +782,8 @@ var useRouterStore = create3()(
|
|
|
671
782
|
);
|
|
672
783
|
|
|
673
784
|
// core/state/zustand/page/page.store.ts
|
|
674
|
-
import { create as
|
|
675
|
-
import { devtools as
|
|
785
|
+
import { create as create5 } from "zustand";
|
|
786
|
+
import { devtools as devtools5 } from "zustand/middleware";
|
|
676
787
|
|
|
677
788
|
// core/state/zustand/page/page.const.ts
|
|
678
789
|
var pageInitialState = {
|
|
@@ -681,8 +792,8 @@ var pageInitialState = {
|
|
|
681
792
|
var pageDevtools = { name: "zljs", store: "page" };
|
|
682
793
|
|
|
683
794
|
// core/state/zustand/page/page.store.ts
|
|
684
|
-
var usePageStore =
|
|
685
|
-
|
|
795
|
+
var usePageStore = create5()(
|
|
796
|
+
devtools5(
|
|
686
797
|
(set) => ({
|
|
687
798
|
...pageInitialState,
|
|
688
799
|
setTitle: (title2) => set({ title: title2 }, false, "setTitle")
|
|
@@ -705,6 +816,9 @@ export {
|
|
|
705
816
|
ConnectedModal,
|
|
706
817
|
Spinner,
|
|
707
818
|
Loader,
|
|
819
|
+
getAuthSession,
|
|
820
|
+
AuthProvider,
|
|
821
|
+
useAuth,
|
|
708
822
|
ZustandProviders,
|
|
709
823
|
ReduxProvider,
|
|
710
824
|
splitURLasPath,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, ChangeEvent, FormEvent, HTMLInputAutoCompleteAttribute, FocusEvent, KeyboardEvent, Ref } from 'react';
|
|
3
|
-
import { S as SemanticColor, D as DataColor, A as AuxiliaryColor, R as ReduxProviderProps } from './redux-provider.interface-
|
|
3
|
+
import { S as SemanticColor, D as DataColor, A as AuxiliaryColor, a as AuthSession, b as AuthConfig, c as AuthAdapter, d as AuthStatus, e as AuthUser, Z as ZustandProvidersProps, R as ReduxProviderProps } from './redux-provider.interface-D6qhg7ND.js';
|
|
4
4
|
export { FormInput, FormInputProps, FormProvider, FormProviderProps } from './rhf/index.js';
|
|
5
5
|
export { toast } from 'sonner';
|
|
6
6
|
import * as zustand from 'zustand';
|
|
@@ -208,9 +208,11 @@ interface ModalProps {
|
|
|
208
208
|
children?: ReactNode;
|
|
209
209
|
/** The width. `xs` is the smallest, for a short question and its buttons. */
|
|
210
210
|
size?: ModalSize;
|
|
211
|
+
/** The color of the title and a light background in that color. `none`, the default, is white. */
|
|
212
|
+
color?: SemanticColor;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
|
-
declare const Modal: ({ open, onClose, title, description, children, size, }: ModalProps) => react.JSX.Element;
|
|
215
|
+
declare const Modal: ({ open, onClose, title, description, children, size, color, }: ModalProps) => react.JSX.Element;
|
|
214
216
|
|
|
215
217
|
interface WhatsAppButtonProps {
|
|
216
218
|
phone: string;
|
|
@@ -315,11 +317,12 @@ interface ConnectedModalProps {
|
|
|
315
317
|
modalId: string;
|
|
316
318
|
title: string;
|
|
317
319
|
description?: string;
|
|
318
|
-
size?:
|
|
320
|
+
size?: ModalProps["size"];
|
|
321
|
+
color?: ModalProps["color"];
|
|
319
322
|
children?: ReactNode;
|
|
320
323
|
}
|
|
321
324
|
|
|
322
|
-
declare const ConnectedModal: ({ modalId, title, description, size, children, }: ConnectedModalProps) => react.JSX.Element;
|
|
325
|
+
declare const ConnectedModal: ({ modalId, title, description, size, color, children, }: ConnectedModalProps) => react.JSX.Element;
|
|
323
326
|
|
|
324
327
|
interface LoaderProps {
|
|
325
328
|
label?: string;
|
|
@@ -365,11 +368,30 @@ declare const useAppStore: zustand.UseBoundStore<Omit<zustand.StoreApi<AppState>
|
|
|
365
368
|
};
|
|
366
369
|
}>;
|
|
367
370
|
|
|
368
|
-
|
|
371
|
+
/** The current session, for code outside React, such as a thunk. */
|
|
372
|
+
declare const getAuthSession: () => AuthSession | null;
|
|
373
|
+
|
|
374
|
+
interface AuthProviderProps extends AuthConfig {
|
|
369
375
|
children: ReactNode;
|
|
370
376
|
}
|
|
371
377
|
|
|
372
|
-
|
|
378
|
+
/**
|
|
379
|
+
* Keeps the adapter, the appId and the session in `useAuthStore`, the one
|
|
380
|
+
* place `useAuth` and `getAuthSession` read from. It runs in an effect, so on
|
|
381
|
+
* the first render the status is still `loading`.
|
|
382
|
+
*/
|
|
383
|
+
declare const AuthProvider: ({ adapter, appId, children, }: AuthProviderProps) => react.JSX.Element;
|
|
384
|
+
|
|
385
|
+
interface UseAuthResult extends Omit<AuthAdapter, "onSessionChange"> {
|
|
386
|
+
status: AuthStatus;
|
|
387
|
+
user: AuthUser | null;
|
|
388
|
+
/** The user's role in this app, or `null` when they have none. */
|
|
389
|
+
role: string | null;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
declare const useAuth: () => UseAuthResult;
|
|
393
|
+
|
|
394
|
+
declare const ZustandProviders: ({ children, auth }: ZustandProvidersProps) => react.JSX.Element;
|
|
373
395
|
|
|
374
396
|
declare const ReduxProvider: ({ children, reducers, middlewares, preloadedState, coreReducers, }: ReduxProviderProps) => react.JSX.Element;
|
|
375
397
|
|
|
@@ -472,5 +494,5 @@ declare class HTTPClient {
|
|
|
472
494
|
patch<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T | undefined>;
|
|
473
495
|
}
|
|
474
496
|
|
|
475
|
-
export { 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, appInitialState, splitURLasPath, useAppStore, usePageStore, useRouterStore, useToastStore };
|
|
476
|
-
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
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
AuthProvider,
|
|
3
4
|
Button,
|
|
4
5
|
ConnectedModal,
|
|
5
6
|
Heading,
|
|
@@ -12,13 +13,15 @@ import {
|
|
|
12
13
|
Toaster,
|
|
13
14
|
ZustandProviders,
|
|
14
15
|
appInitialState,
|
|
16
|
+
getAuthSession,
|
|
15
17
|
splitURLasPath,
|
|
16
18
|
toast,
|
|
17
19
|
useAppStore,
|
|
20
|
+
useAuth,
|
|
18
21
|
usePageStore,
|
|
19
22
|
useRouterStore,
|
|
20
23
|
useToastStore
|
|
21
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-PAZK5RXI.js";
|
|
22
25
|
import {
|
|
23
26
|
Error,
|
|
24
27
|
FormInput,
|
|
@@ -890,6 +893,7 @@ var HTTPClient = class {
|
|
|
890
893
|
}
|
|
891
894
|
};
|
|
892
895
|
export {
|
|
896
|
+
AuthProvider,
|
|
893
897
|
Button,
|
|
894
898
|
Card,
|
|
895
899
|
Checkbox,
|
|
@@ -918,9 +922,11 @@ export {
|
|
|
918
922
|
WhatsAppButton,
|
|
919
923
|
ZustandProviders,
|
|
920
924
|
appInitialState,
|
|
925
|
+
getAuthSession,
|
|
921
926
|
splitURLasPath,
|
|
922
927
|
toast,
|
|
923
928
|
useAppStore,
|
|
929
|
+
useAuth,
|
|
924
930
|
usePageStore,
|
|
925
931
|
useRouterStore,
|
|
926
932
|
useToastStore
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { SemanticColor, ReduxProviderProps } from '../index.js';
|
|
3
|
+
import { SemanticColor, ReduxProviderProps, ZustandProvidersProps } from '../index.js';
|
|
4
4
|
import { ThunkDispatch, UnknownAction, Reducer } from '@reduxjs/toolkit';
|
|
5
5
|
|
|
6
6
|
interface RootLayoutProps {
|
|
@@ -18,6 +18,13 @@ interface NotFoundProps {
|
|
|
18
18
|
|
|
19
19
|
declare const NotFound: ({ title, message, backHref, backLabel, }: NotFoundProps) => react.JSX.Element;
|
|
20
20
|
|
|
21
|
+
interface PageWrapperProps {
|
|
22
|
+
/** The content of the page, such as a sign-in card. */
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const PageWrapper: ({ children }: PageWrapperProps) => react.JSX.Element;
|
|
27
|
+
|
|
21
28
|
interface LinkProps {
|
|
22
29
|
children: ReactNode;
|
|
23
30
|
href: string;
|
|
@@ -26,9 +33,9 @@ interface LinkProps {
|
|
|
26
33
|
|
|
27
34
|
declare const Link: ({ children, href, color }: LinkProps) => react.JSX.Element;
|
|
28
35
|
|
|
29
|
-
type AppProvidersProps = ReduxProviderProps
|
|
36
|
+
type AppProvidersProps = ReduxProviderProps & Pick<ZustandProvidersProps, "auth">;
|
|
30
37
|
|
|
31
|
-
declare const AppProviders: ({ children, ...store }: AppProvidersProps) => react.JSX.Element;
|
|
38
|
+
declare const AppProviders: ({ children, auth, ...store }: AppProvidersProps) => react.JSX.Element;
|
|
32
39
|
|
|
33
40
|
type InitPageFunction = (dispatch: ThunkDispatch<any, undefined, UnknownAction>) => void;
|
|
34
41
|
interface PageConfigProps {
|
|
@@ -40,5 +47,5 @@ interface PageConfigProps {
|
|
|
40
47
|
|
|
41
48
|
declare const PageConfig: ({ children, title, reducers, initPage, }: PageConfigProps) => react.JSX.Element;
|
|
42
49
|
|
|
43
|
-
export { AppProviders, Link, NotFound, PageConfig, RootLayout };
|
|
44
|
-
export type { AppProvidersProps, InitPageFunction, LinkProps, NotFoundProps, PageConfigProps, RootLayoutProps };
|
|
50
|
+
export { AppProviders, Link, NotFound, PageConfig, PageWrapper, RootLayout };
|
|
51
|
+
export type { AppProvidersProps, InitPageFunction, LinkProps, NotFoundProps, PageConfigProps, PageWrapperProps, RootLayoutProps };
|
package/dist/next/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
ZustandProviders,
|
|
7
7
|
usePageStore,
|
|
8
8
|
useRouterStore
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-PAZK5RXI.js";
|
|
10
10
|
|
|
11
11
|
// core/next/root-layout/root-layout.styles.ts
|
|
12
12
|
import { tv } from "tailwind-variants";
|
|
@@ -79,10 +79,26 @@ var NotFound = ({
|
|
|
79
79
|
] });
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
// core/next/page-wrapper/page-wrapper.styles.ts
|
|
83
|
+
import { tv as tv4 } from "tailwind-variants";
|
|
84
|
+
var pageWrapper = tv4({
|
|
85
|
+
slots: {
|
|
86
|
+
base: "flex items-center justify-center min-h-dvh p-4",
|
|
87
|
+
content: "w-full max-w-sm"
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// core/next/page-wrapper/page-wrapper.tsx
|
|
92
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
93
|
+
var PageWrapper = ({ children }) => {
|
|
94
|
+
const { base, content } = pageWrapper();
|
|
95
|
+
return /* @__PURE__ */ jsx4("div", { className: base(), children: /* @__PURE__ */ jsx4("div", { className: content(), children }) });
|
|
96
|
+
};
|
|
97
|
+
|
|
82
98
|
// core/next/app-providers/app-providers.tsx
|
|
83
99
|
import { useEffect } from "react";
|
|
84
100
|
import { usePathname } from "next/navigation.js";
|
|
85
|
-
import { jsx as
|
|
101
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
86
102
|
var RouteSync = () => {
|
|
87
103
|
const pathname = usePathname();
|
|
88
104
|
const setRoute = useRouterStore((s) => s.setRoute);
|
|
@@ -93,15 +109,19 @@ var RouteSync = () => {
|
|
|
93
109
|
}, [pathname, setRoute]);
|
|
94
110
|
return null;
|
|
95
111
|
};
|
|
96
|
-
var AppProviders = ({
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
var AppProviders = ({
|
|
113
|
+
children,
|
|
114
|
+
auth,
|
|
115
|
+
...store
|
|
116
|
+
}) => /* @__PURE__ */ jsxs2(ReduxProvider, { ...store, children: [
|
|
117
|
+
/* @__PURE__ */ jsx5(RouteSync, {}),
|
|
118
|
+
/* @__PURE__ */ jsx5(ZustandProviders, { auth, children })
|
|
99
119
|
] });
|
|
100
120
|
|
|
101
121
|
// core/next/page-config/page-config.tsx
|
|
102
122
|
import { useEffect as useEffect2 } from "react";
|
|
103
123
|
import { useDispatch, useStore } from "react-redux";
|
|
104
|
-
import { Fragment, jsx as
|
|
124
|
+
import { Fragment, jsx as jsx6 } from "react/jsx-runtime";
|
|
105
125
|
var PageConfig = ({
|
|
106
126
|
children,
|
|
107
127
|
title,
|
|
@@ -124,12 +144,13 @@ var PageConfig = ({
|
|
|
124
144
|
initPage(dispatch);
|
|
125
145
|
}
|
|
126
146
|
}, []);
|
|
127
|
-
return /* @__PURE__ */
|
|
147
|
+
return /* @__PURE__ */ jsx6(Fragment, { children });
|
|
128
148
|
};
|
|
129
149
|
export {
|
|
130
150
|
AppProviders,
|
|
131
151
|
Link,
|
|
132
152
|
NotFound,
|
|
133
153
|
PageConfig,
|
|
154
|
+
PageWrapper,
|
|
134
155
|
RootLayout
|
|
135
156
|
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Reducer, Middleware } from '@reduxjs/toolkit';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Semantic colors for action-oriented components (Button, Heading, etc.)
|
|
6
|
+
*/
|
|
7
|
+
type SemanticColor = "primary" | "success" | "danger" | "warning" | "info" | "muted" | "none";
|
|
8
|
+
/**
|
|
9
|
+
* Literal colors for data visualization components (StatsCard, etc.)
|
|
10
|
+
*/
|
|
11
|
+
type DataColor = "blue" | "red" | "yellow" | "green" | "gray" | "orange";
|
|
12
|
+
/**
|
|
13
|
+
* Extra colors with no meaning of their own, to tell categories apart (Tag)
|
|
14
|
+
*/
|
|
15
|
+
type AuxiliaryColor = "orange" | "pink" | "purple";
|
|
16
|
+
|
|
17
|
+
type AuthStatus = "loading" | "authenticated" | "unauthenticated";
|
|
18
|
+
interface AuthUser {
|
|
19
|
+
id: string;
|
|
20
|
+
email: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
avatarUrl?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the user may use this app, such as approved by an admin. It is
|
|
25
|
+
* separate from the role: a user can have access and no role.
|
|
26
|
+
*/
|
|
27
|
+
hasAccess: boolean;
|
|
28
|
+
/** The user's role in each app, by app id: `{ entregas: "admin" }`. */
|
|
29
|
+
roles: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
interface AuthSession {
|
|
32
|
+
accessToken: string;
|
|
33
|
+
user: AuthUser;
|
|
34
|
+
}
|
|
35
|
+
interface AuthCredentials {
|
|
36
|
+
email: string;
|
|
37
|
+
password: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* What an auth provider must do for zljs. Each sign-in rejects
|
|
41
|
+
* on failure, so the caller can show the error.
|
|
42
|
+
*/
|
|
43
|
+
interface AuthAdapter {
|
|
44
|
+
/**
|
|
45
|
+
* Calls `listener` right away with the current session, then on every
|
|
46
|
+
* change (sign in, sign out, token refresh). Returns the unsubscribe.
|
|
47
|
+
*/
|
|
48
|
+
onSessionChange: (listener: (session: AuthSession | null) => void) => () => void;
|
|
49
|
+
signInWithOAuth: (provider: string) => Promise<void>;
|
|
50
|
+
signInWithPassword: (credentials: AuthCredentials) => Promise<void>;
|
|
51
|
+
/** Sends a sign-in link by email. The session comes when the link is opened. */
|
|
52
|
+
signInWithMagicLink: (email: string) => Promise<void>;
|
|
53
|
+
signOut: () => Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/** What an app gives zljs to turn auth on. */
|
|
56
|
+
interface AuthConfig {
|
|
57
|
+
/** Connects zljs to the app's auth provider. */
|
|
58
|
+
adapter: AuthAdapter;
|
|
59
|
+
/** The key of this app in each user's `roles`. */
|
|
60
|
+
appId: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ZustandProvidersProps {
|
|
64
|
+
children: ReactNode;
|
|
65
|
+
/** Turns on `AuthProvider`. Without it, nothing of auth is mounted. */
|
|
66
|
+
auth?: AuthConfig;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface ReduxProviderProps {
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
reducers?: Record<string, Reducer>;
|
|
72
|
+
middlewares?: Middleware[];
|
|
73
|
+
preloadedState?: Record<string, unknown>;
|
|
74
|
+
coreReducers?: Record<string, Reducer>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type { AuxiliaryColor as A, DataColor as D, ReduxProviderProps as R, SemanticColor as S, ZustandProvidersProps as Z, AuthSession as a, AuthConfig as b, AuthAdapter as c, AuthStatus as d, AuthUser as e };
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { Reducer, Middleware } from '@reduxjs/toolkit';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Semantic colors for action-oriented components (Button, Heading, etc.)
|
|
6
|
-
*/
|
|
7
|
-
type SemanticColor = "primary" | "success" | "danger" | "warning" | "info" | "muted" | "none";
|
|
8
|
-
/**
|
|
9
|
-
* Literal colors for data visualization components (StatsCard, etc.)
|
|
10
|
-
*/
|
|
11
|
-
type DataColor = "blue" | "red" | "yellow" | "green" | "gray" | "orange";
|
|
12
|
-
/**
|
|
13
|
-
* Extra colors with no meaning of their own, to tell categories apart (Tag)
|
|
14
|
-
*/
|
|
15
|
-
type AuxiliaryColor = "orange" | "pink" | "purple";
|
|
16
|
-
|
|
17
|
-
interface ReduxProviderProps {
|
|
18
|
-
children: ReactNode;
|
|
19
|
-
reducers?: Record<string, Reducer>;
|
|
20
|
-
middlewares?: Middleware[];
|
|
21
|
-
preloadedState?: Record<string, unknown>;
|
|
22
|
-
coreReducers?: Record<string, Reducer>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type { AuxiliaryColor as A, DataColor as D, ReduxProviderProps as R, SemanticColor as S };
|