@alexandregme/zljs 3.6.0 → 3.7.1
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 +8 -1
- package/dist/{chunk-FAJRJZWI.js → chunk-JMEGXQKC.js} +159 -142
- package/dist/index.d.ts +106 -90
- package/dist/index.js +3 -1
- package/dist/next/index.js +1 -1
- package/dist/{redux-provider.interface-D6qhg7ND.d.ts → zustand-providers.interface-CeC8U2hM.d.ts} +9 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,12 @@ A change that needs action in an app has a **Migration** note. When updating, re
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [3.7.0] - 2026-11-11
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `Authorized`, the wall in front of an app: a signed-out user sees `Login`, a signed-in user without access to this app (`hasAccess` on `AuthUser`, set by the adapter, such as after an admin approves) sees `AccessPending`, and a user with access sees the app. `login` and `accessPending` take the props of the two screens. Roles are a separate check: with `roles`, the user also needs one of them in this app. The type `AuthorizedProps` types what an app passes to it
|
|
16
|
+
|
|
11
17
|
## [3.6.0] - 2026-11-11
|
|
12
18
|
|
|
13
19
|
### Added
|
|
@@ -453,7 +459,8 @@ Replace the shade with the class of the `color` being tested, for example `/(^|\
|
|
|
453
459
|
|
|
454
460
|
The message of `Error` is `text-zl-danger`. `none` and `ghost` didn't change.
|
|
455
461
|
|
|
456
|
-
[Unreleased]: https://github.com/alexandregme/zljs/compare/v3.
|
|
462
|
+
[Unreleased]: https://github.com/alexandregme/zljs/compare/v3.7.0...HEAD
|
|
463
|
+
[3.7.0]: https://github.com/alexandregme/zljs/compare/v3.6.0...v3.7.0
|
|
457
464
|
[3.6.0]: https://github.com/alexandregme/zljs/compare/v3.5.0...v3.6.0
|
|
458
465
|
[3.5.0]: https://github.com/alexandregme/zljs/compare/v3.3.0...v3.5.0
|
|
459
466
|
[3.3.0]: https://github.com/alexandregme/zljs/compare/v3.2.0...v3.3.0
|
|
@@ -602,6 +602,116 @@ var Loader = ({ label = "Loading" }) => {
|
|
|
602
602
|
return /* @__PURE__ */ jsx9("div", { className: loader(), children: /* @__PURE__ */ jsx9(Spinner, { size: "lg", label }) });
|
|
603
603
|
};
|
|
604
604
|
|
|
605
|
+
// core/state/redux/redux-provider/redux-provider.tsx
|
|
606
|
+
import { useState } from "react";
|
|
607
|
+
import { Provider } from "react-redux";
|
|
608
|
+
|
|
609
|
+
// core/state/redux/store/store.ts
|
|
610
|
+
import {
|
|
611
|
+
combineReducers,
|
|
612
|
+
configureStore
|
|
613
|
+
} from "@reduxjs/toolkit";
|
|
614
|
+
var emptyReducer = (state = {}) => state;
|
|
615
|
+
var createReduxStore = ({
|
|
616
|
+
reducers,
|
|
617
|
+
middlewares,
|
|
618
|
+
preloadedState,
|
|
619
|
+
coreReducers
|
|
620
|
+
}) => {
|
|
621
|
+
let dynamicReducers = {};
|
|
622
|
+
const createReducer = () => {
|
|
623
|
+
const all = { ...dynamicReducers, ...reducers, ...coreReducers };
|
|
624
|
+
return Object.keys(all).length ? combineReducers(all) : emptyReducer;
|
|
625
|
+
};
|
|
626
|
+
const store = configureStore({
|
|
627
|
+
reducer: createReducer(),
|
|
628
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(middlewares),
|
|
629
|
+
preloadedState
|
|
630
|
+
});
|
|
631
|
+
store.setDynamicReducers = (newDynamicReducers = {}) => {
|
|
632
|
+
dynamicReducers = newDynamicReducers;
|
|
633
|
+
store.replaceReducer(createReducer());
|
|
634
|
+
};
|
|
635
|
+
return store;
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
// core/state/redux/redux-provider/redux-provider.tsx
|
|
639
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
640
|
+
var ReduxProvider = ({
|
|
641
|
+
children,
|
|
642
|
+
reducers = {},
|
|
643
|
+
middlewares = [],
|
|
644
|
+
preloadedState = {},
|
|
645
|
+
coreReducers = {}
|
|
646
|
+
}) => {
|
|
647
|
+
const [store] = useState(
|
|
648
|
+
() => createReduxStore({
|
|
649
|
+
reducers,
|
|
650
|
+
middlewares,
|
|
651
|
+
preloadedState,
|
|
652
|
+
coreReducers
|
|
653
|
+
})
|
|
654
|
+
);
|
|
655
|
+
return /* @__PURE__ */ jsx10(Provider, { store, children });
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// core/state/zustand/router/router.utils.ts
|
|
659
|
+
var splitURLasPath = (urlAsPath) => {
|
|
660
|
+
const [pathAndQuery = ""] = urlAsPath?.split("#") ?? [];
|
|
661
|
+
const [, query = ""] = pathAndQuery.split("?");
|
|
662
|
+
const parametersAsObject = {};
|
|
663
|
+
query.split("&").forEach((p) => {
|
|
664
|
+
const [parameter, value] = p.split("=");
|
|
665
|
+
if (parameter) {
|
|
666
|
+
parametersAsObject[parameter] = value ?? "";
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
return parametersAsObject;
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
// core/state/zustand/router/router.store.ts
|
|
673
|
+
import { create as create3 } from "zustand";
|
|
674
|
+
import { devtools as devtools3 } from "zustand/middleware";
|
|
675
|
+
|
|
676
|
+
// core/state/zustand/router/router.const.ts
|
|
677
|
+
var routerInitialState = {
|
|
678
|
+
urlAsPath: "/",
|
|
679
|
+
query: {}
|
|
680
|
+
};
|
|
681
|
+
var routerDevtools = { name: "zljs", store: "router" };
|
|
682
|
+
|
|
683
|
+
// core/state/zustand/router/router.store.ts
|
|
684
|
+
var useRouterStore = create3()(
|
|
685
|
+
devtools3(
|
|
686
|
+
(set) => ({
|
|
687
|
+
...routerInitialState,
|
|
688
|
+
setRoute: (urlAsPath) => set({ urlAsPath, query: splitURLasPath(urlAsPath) }, false, "setRoute")
|
|
689
|
+
}),
|
|
690
|
+
routerDevtools
|
|
691
|
+
)
|
|
692
|
+
);
|
|
693
|
+
|
|
694
|
+
// core/state/zustand/page/page.store.ts
|
|
695
|
+
import { create as create4 } from "zustand";
|
|
696
|
+
import { devtools as devtools4 } from "zustand/middleware";
|
|
697
|
+
|
|
698
|
+
// core/state/zustand/page/page.const.ts
|
|
699
|
+
var pageInitialState = {
|
|
700
|
+
title: ""
|
|
701
|
+
};
|
|
702
|
+
var pageDevtools = { name: "zljs", store: "page" };
|
|
703
|
+
|
|
704
|
+
// core/state/zustand/page/page.store.ts
|
|
705
|
+
var usePageStore = create4()(
|
|
706
|
+
devtools4(
|
|
707
|
+
(set) => ({
|
|
708
|
+
...pageInitialState,
|
|
709
|
+
setTitle: (title2) => set({ title: title2 }, false, "setTitle")
|
|
710
|
+
}),
|
|
711
|
+
pageDevtools
|
|
712
|
+
)
|
|
713
|
+
);
|
|
714
|
+
|
|
605
715
|
// core/card/card.styles.ts
|
|
606
716
|
import { tv as tv9 } from "tailwind-variants";
|
|
607
717
|
var card = tv9({
|
|
@@ -634,7 +744,7 @@ var card = tv9({
|
|
|
634
744
|
});
|
|
635
745
|
|
|
636
746
|
// core/card/card.tsx
|
|
637
|
-
import { jsx as
|
|
747
|
+
import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
638
748
|
var Card = ({
|
|
639
749
|
children,
|
|
640
750
|
title: title2,
|
|
@@ -646,16 +756,16 @@ var Card = ({
|
|
|
646
756
|
const messageColor = color === "none" ? "muted" : "none";
|
|
647
757
|
return /* @__PURE__ */ jsxs3("div", { "data-testid": "card", className: base(), children: [
|
|
648
758
|
(title2 || message) && /* @__PURE__ */ jsxs3("div", { className: header2(), children: [
|
|
649
|
-
title2 && /* @__PURE__ */
|
|
650
|
-
message && /* @__PURE__ */
|
|
759
|
+
title2 && /* @__PURE__ */ jsx11(Heading, { level: titleLevel, children: title2 }),
|
|
760
|
+
message && /* @__PURE__ */ jsx11(Text, { color: messageColor, children: message })
|
|
651
761
|
] }),
|
|
652
762
|
children
|
|
653
763
|
] });
|
|
654
764
|
};
|
|
655
765
|
|
|
656
766
|
// features/auth/state/auth.store.ts
|
|
657
|
-
import { create as
|
|
658
|
-
import { devtools as
|
|
767
|
+
import { create as create5 } from "zustand";
|
|
768
|
+
import { devtools as devtools5 } from "zustand/middleware";
|
|
659
769
|
|
|
660
770
|
// features/auth/state/auth.const.ts
|
|
661
771
|
var authInitialState = {
|
|
@@ -667,8 +777,8 @@ var authInitialState = {
|
|
|
667
777
|
var authDevtools = { name: "zljs", store: "auth" };
|
|
668
778
|
|
|
669
779
|
// features/auth/state/auth.store.ts
|
|
670
|
-
var useAuthStore =
|
|
671
|
-
|
|
780
|
+
var useAuthStore = create5()(
|
|
781
|
+
devtools5(
|
|
672
782
|
(set) => ({
|
|
673
783
|
...authInitialState,
|
|
674
784
|
setSession: (session) => set(
|
|
@@ -725,7 +835,7 @@ var signOutModal = tv10({
|
|
|
725
835
|
});
|
|
726
836
|
|
|
727
837
|
// features/auth/components/sign-out/sign-out-modal.tsx
|
|
728
|
-
import { jsx as
|
|
838
|
+
import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
729
839
|
var SignOutModal = ({
|
|
730
840
|
title: title2 = "Sign out?",
|
|
731
841
|
confirmLabel = "Sign out",
|
|
@@ -744,7 +854,7 @@ var SignOutModal = ({
|
|
|
744
854
|
useToastStore.getState().error(errorMessage);
|
|
745
855
|
});
|
|
746
856
|
};
|
|
747
|
-
return /* @__PURE__ */
|
|
857
|
+
return /* @__PURE__ */ jsx12(
|
|
748
858
|
ConnectedModal,
|
|
749
859
|
{
|
|
750
860
|
modalId: SIGN_OUT_MODAL_ID,
|
|
@@ -752,15 +862,15 @@ var SignOutModal = ({
|
|
|
752
862
|
size: "xs",
|
|
753
863
|
color: "danger",
|
|
754
864
|
children: /* @__PURE__ */ jsxs4("div", { className: actions(), children: [
|
|
755
|
-
/* @__PURE__ */
|
|
756
|
-
/* @__PURE__ */
|
|
865
|
+
/* @__PURE__ */ jsx12(Button, { color: "ghost", onClick: stay, children: cancelLabel }),
|
|
866
|
+
/* @__PURE__ */ jsx12(Button, { color: "danger", onClick: leave, children: confirmLabel })
|
|
757
867
|
] })
|
|
758
868
|
}
|
|
759
869
|
);
|
|
760
870
|
};
|
|
761
871
|
|
|
762
872
|
// features/auth/components/sign-out/sign-out-button.tsx
|
|
763
|
-
import { Fragment as Fragment3, jsx as
|
|
873
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
764
874
|
var SignOutButton = ({
|
|
765
875
|
label = "Sign out",
|
|
766
876
|
confirmTitle,
|
|
@@ -773,7 +883,7 @@ var SignOutButton = ({
|
|
|
773
883
|
openModal(SIGN_OUT_MODAL_ID);
|
|
774
884
|
};
|
|
775
885
|
return /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
776
|
-
/* @__PURE__ */
|
|
886
|
+
/* @__PURE__ */ jsx13(
|
|
777
887
|
Button,
|
|
778
888
|
{
|
|
779
889
|
variant: "icon",
|
|
@@ -783,7 +893,7 @@ var SignOutButton = ({
|
|
|
783
893
|
onClick: ask
|
|
784
894
|
}
|
|
785
895
|
),
|
|
786
|
-
/* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ jsx13(
|
|
787
897
|
SignOutModal,
|
|
788
898
|
{
|
|
789
899
|
title: confirmTitle,
|
|
@@ -804,7 +914,7 @@ var accessPending = tv11({
|
|
|
804
914
|
});
|
|
805
915
|
|
|
806
916
|
// features/auth/components/access-pending/access-pending.tsx
|
|
807
|
-
import { jsx as
|
|
917
|
+
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
808
918
|
var AccessPending = ({
|
|
809
919
|
title: title2 = "Waiting for approval",
|
|
810
920
|
message = "Your access to this app has not been approved yet.",
|
|
@@ -819,9 +929,9 @@ var AccessPending = ({
|
|
|
819
929
|
if (!user) {
|
|
820
930
|
return null;
|
|
821
931
|
}
|
|
822
|
-
return /* @__PURE__ */
|
|
823
|
-
/* @__PURE__ */
|
|
824
|
-
/* @__PURE__ */
|
|
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(
|
|
825
935
|
SignOutButton,
|
|
826
936
|
{
|
|
827
937
|
label: signOutLabel,
|
|
@@ -836,7 +946,7 @@ var AccessPending = ({
|
|
|
836
946
|
|
|
837
947
|
// features/auth/components/auth-provider/auth-provider.tsx
|
|
838
948
|
import { useEffect as useEffect2 } from "react";
|
|
839
|
-
import { Fragment as Fragment4, jsx as
|
|
949
|
+
import { Fragment as Fragment4, jsx as jsx15 } from "react/jsx-runtime";
|
|
840
950
|
var AuthProvider = ({
|
|
841
951
|
adapter,
|
|
842
952
|
appId,
|
|
@@ -853,7 +963,7 @@ var AuthProvider = ({
|
|
|
853
963
|
reset();
|
|
854
964
|
};
|
|
855
965
|
}, [adapter, appId, configure, setSession, reset]);
|
|
856
|
-
return /* @__PURE__ */
|
|
966
|
+
return /* @__PURE__ */ jsx15(Fragment4, { children });
|
|
857
967
|
};
|
|
858
968
|
|
|
859
969
|
// features/auth/components/login/login.const.ts
|
|
@@ -875,7 +985,7 @@ var login = tv12({
|
|
|
875
985
|
});
|
|
876
986
|
|
|
877
987
|
// features/auth/components/login/login.tsx
|
|
878
|
-
import { jsx as
|
|
988
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
879
989
|
var LoginProviderButton = ({
|
|
880
990
|
id,
|
|
881
991
|
label,
|
|
@@ -884,7 +994,7 @@ var LoginProviderButton = ({
|
|
|
884
994
|
const signIn = () => {
|
|
885
995
|
onSignIn(id);
|
|
886
996
|
};
|
|
887
|
-
return /* @__PURE__ */
|
|
997
|
+
return /* @__PURE__ */ jsx16(Button, { size: "lg", fullWidth: true, onClick: signIn, children: label });
|
|
888
998
|
};
|
|
889
999
|
var Login = ({
|
|
890
1000
|
vendor,
|
|
@@ -902,9 +1012,9 @@ var Login = ({
|
|
|
902
1012
|
useToastStore.getState().error(errorMessage);
|
|
903
1013
|
});
|
|
904
1014
|
};
|
|
905
|
-
return /* @__PURE__ */
|
|
1015
|
+
return /* @__PURE__ */ jsx16(Card, { title: title2, titleLevel: 1, message, children: /* @__PURE__ */ jsx16("div", { className: options(), children: providers.map((provider) => {
|
|
906
1016
|
const id = String(provider);
|
|
907
|
-
return /* @__PURE__ */
|
|
1017
|
+
return /* @__PURE__ */ jsx16(
|
|
908
1018
|
LoginProviderButton,
|
|
909
1019
|
{
|
|
910
1020
|
id,
|
|
@@ -916,123 +1026,29 @@ var Login = ({
|
|
|
916
1026
|
}) }) });
|
|
917
1027
|
};
|
|
918
1028
|
|
|
919
|
-
// features/
|
|
920
|
-
import { Fragment as Fragment5, jsx as
|
|
921
|
-
var
|
|
922
|
-
/* @__PURE__ */ jsx16(Loader, {}),
|
|
923
|
-
/* @__PURE__ */ jsx16(Toaster, {}),
|
|
924
|
-
auth ? /* @__PURE__ */ jsx16(AuthProvider, { adapter: auth.adapter, appId: auth.appId, children }) : children
|
|
925
|
-
] });
|
|
926
|
-
|
|
927
|
-
// core/state/redux/redux-provider/redux-provider.tsx
|
|
928
|
-
import { useState } from "react";
|
|
929
|
-
import { Provider } from "react-redux";
|
|
930
|
-
|
|
931
|
-
// core/state/redux/store/store.ts
|
|
932
|
-
import {
|
|
933
|
-
combineReducers,
|
|
934
|
-
configureStore
|
|
935
|
-
} from "@reduxjs/toolkit";
|
|
936
|
-
var emptyReducer = (state = {}) => state;
|
|
937
|
-
var createReduxStore = ({
|
|
938
|
-
reducers,
|
|
939
|
-
middlewares,
|
|
940
|
-
preloadedState,
|
|
941
|
-
coreReducers
|
|
942
|
-
}) => {
|
|
943
|
-
let dynamicReducers = {};
|
|
944
|
-
const createReducer = () => {
|
|
945
|
-
const all = { ...dynamicReducers, ...reducers, ...coreReducers };
|
|
946
|
-
return Object.keys(all).length ? combineReducers(all) : emptyReducer;
|
|
947
|
-
};
|
|
948
|
-
const store = configureStore({
|
|
949
|
-
reducer: createReducer(),
|
|
950
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(middlewares),
|
|
951
|
-
preloadedState
|
|
952
|
-
});
|
|
953
|
-
store.setDynamicReducers = (newDynamicReducers = {}) => {
|
|
954
|
-
dynamicReducers = newDynamicReducers;
|
|
955
|
-
store.replaceReducer(createReducer());
|
|
956
|
-
};
|
|
957
|
-
return store;
|
|
958
|
-
};
|
|
959
|
-
|
|
960
|
-
// core/state/redux/redux-provider/redux-provider.tsx
|
|
961
|
-
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
962
|
-
var ReduxProvider = ({
|
|
1029
|
+
// features/auth/components/authorized/authorized.tsx
|
|
1030
|
+
import { Fragment as Fragment5, jsx as jsx17 } from "react/jsx-runtime";
|
|
1031
|
+
var Authorized = ({
|
|
963
1032
|
children,
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
coreReducers = {}
|
|
1033
|
+
roles,
|
|
1034
|
+
login: login2,
|
|
1035
|
+
accessPending: accessPending2
|
|
968
1036
|
}) => {
|
|
969
|
-
const
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
})
|
|
976
|
-
);
|
|
977
|
-
return /* @__PURE__ */ jsx17(Provider, { store, children });
|
|
1037
|
+
const { status, user, role } = useAuth();
|
|
1038
|
+
if (status === "loading") return null;
|
|
1039
|
+
if (!user) return /* @__PURE__ */ jsx17(Login, { ...login2 });
|
|
1040
|
+
const hasRole = !roles || role !== null && roles.includes(role);
|
|
1041
|
+
if (!user.hasAccess || !hasRole) return /* @__PURE__ */ jsx17(AccessPending, { ...accessPending2 });
|
|
1042
|
+
return /* @__PURE__ */ jsx17(Fragment5, { children });
|
|
978
1043
|
};
|
|
979
1044
|
|
|
980
|
-
//
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
if (parameter) {
|
|
988
|
-
parametersAsObject[parameter] = value ?? "";
|
|
989
|
-
}
|
|
990
|
-
});
|
|
991
|
-
return parametersAsObject;
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
// core/state/zustand/router/router.store.ts
|
|
995
|
-
import { create as create4 } from "zustand";
|
|
996
|
-
import { devtools as devtools4 } from "zustand/middleware";
|
|
997
|
-
|
|
998
|
-
// core/state/zustand/router/router.const.ts
|
|
999
|
-
var routerInitialState = {
|
|
1000
|
-
urlAsPath: "/",
|
|
1001
|
-
query: {}
|
|
1002
|
-
};
|
|
1003
|
-
var routerDevtools = { name: "zljs", store: "router" };
|
|
1004
|
-
|
|
1005
|
-
// core/state/zustand/router/router.store.ts
|
|
1006
|
-
var useRouterStore = create4()(
|
|
1007
|
-
devtools4(
|
|
1008
|
-
(set) => ({
|
|
1009
|
-
...routerInitialState,
|
|
1010
|
-
setRoute: (urlAsPath) => set({ urlAsPath, query: splitURLasPath(urlAsPath) }, false, "setRoute")
|
|
1011
|
-
}),
|
|
1012
|
-
routerDevtools
|
|
1013
|
-
)
|
|
1014
|
-
);
|
|
1015
|
-
|
|
1016
|
-
// core/state/zustand/page/page.store.ts
|
|
1017
|
-
import { create as create5 } from "zustand";
|
|
1018
|
-
import { devtools as devtools5 } from "zustand/middleware";
|
|
1019
|
-
|
|
1020
|
-
// core/state/zustand/page/page.const.ts
|
|
1021
|
-
var pageInitialState = {
|
|
1022
|
-
title: ""
|
|
1023
|
-
};
|
|
1024
|
-
var pageDevtools = { name: "zljs", store: "page" };
|
|
1025
|
-
|
|
1026
|
-
// core/state/zustand/page/page.store.ts
|
|
1027
|
-
var usePageStore = create5()(
|
|
1028
|
-
devtools5(
|
|
1029
|
-
(set) => ({
|
|
1030
|
-
...pageInitialState,
|
|
1031
|
-
setTitle: (title2) => set({ title: title2 }, false, "setTitle")
|
|
1032
|
-
}),
|
|
1033
|
-
pageDevtools
|
|
1034
|
-
)
|
|
1035
|
-
);
|
|
1045
|
+
// features/providers/components/zustand-providers/zustand-providers.tsx
|
|
1046
|
+
import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1047
|
+
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
|
|
1051
|
+
] });
|
|
1036
1052
|
|
|
1037
1053
|
export {
|
|
1038
1054
|
Icon,
|
|
@@ -1048,6 +1064,10 @@ export {
|
|
|
1048
1064
|
ConnectedModal,
|
|
1049
1065
|
Spinner,
|
|
1050
1066
|
Loader,
|
|
1067
|
+
ReduxProvider,
|
|
1068
|
+
splitURLasPath,
|
|
1069
|
+
useRouterStore,
|
|
1070
|
+
usePageStore,
|
|
1051
1071
|
Card,
|
|
1052
1072
|
getAuthSession,
|
|
1053
1073
|
useAuth,
|
|
@@ -1055,9 +1075,6 @@ export {
|
|
|
1055
1075
|
AccessPending,
|
|
1056
1076
|
AuthProvider,
|
|
1057
1077
|
Login,
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
splitURLasPath,
|
|
1061
|
-
useRouterStore,
|
|
1062
|
-
usePageStore
|
|
1078
|
+
Authorized,
|
|
1079
|
+
ZustandProviders
|
|
1063
1080
|
};
|
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, a as AuthSession, b as AuthConfig, c as AuthAdapter, d as AuthStatus, e as AuthUser, Z as ZustandProvidersProps
|
|
3
|
+
import { S as SemanticColor, D as DataColor, A as AuxiliaryColor, R as ReduxProviderProps, a as AuthSession, b as AuthConfig, c as AuthAdapter, d as AuthStatus, e as AuthUser, Z as ZustandProvidersProps } from './zustand-providers.interface-CeC8U2hM.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';
|
|
@@ -368,93 +368,6 @@ declare const useAppStore: zustand.UseBoundStore<Omit<zustand.StoreApi<AppState>
|
|
|
368
368
|
};
|
|
369
369
|
}>;
|
|
370
370
|
|
|
371
|
-
interface AccessPendingProps {
|
|
372
|
-
title?: string;
|
|
373
|
-
message?: string;
|
|
374
|
-
/** The accessible name of the sign-out button. */
|
|
375
|
-
signOutLabel?: string;
|
|
376
|
-
/** The question of the modal the button opens. */
|
|
377
|
-
confirmTitle?: string;
|
|
378
|
-
/** The button of the modal that signs out. */
|
|
379
|
-
confirmLabel?: string;
|
|
380
|
-
/** The button of the modal that keeps the user signed in. */
|
|
381
|
-
cancelLabel?: string;
|
|
382
|
-
/** The toast when signing out fails. */
|
|
383
|
-
errorMessage?: string;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
declare const AccessPending: ({ title, message, signOutLabel, confirmTitle, confirmLabel, cancelLabel, errorMessage, }: AccessPendingProps) => react.JSX.Element | null;
|
|
387
|
-
|
|
388
|
-
/** The current session, for code outside React, such as a thunk. */
|
|
389
|
-
declare const getAuthSession: () => AuthSession | null;
|
|
390
|
-
|
|
391
|
-
interface AuthProviderProps extends AuthConfig {
|
|
392
|
-
children: ReactNode;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Keeps the adapter, the appId and the session in `useAuthStore`, the one
|
|
397
|
-
* place `useAuth` and `getAuthSession` read from. It runs in an effect, so on
|
|
398
|
-
* the first render the status is still `loading`.
|
|
399
|
-
*/
|
|
400
|
-
declare const AuthProvider: ({ adapter, appId, children, }: AuthProviderProps) => react.JSX.Element;
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* The OAuth providers of each auth vendor, by the id the vendor knows, with
|
|
404
|
-
* the name each one shows on its button. A new vendor is a new key here.
|
|
405
|
-
*/
|
|
406
|
-
declare const loginVendors: {
|
|
407
|
-
readonly supabase: {
|
|
408
|
-
readonly google: "Google";
|
|
409
|
-
readonly apple: "Apple";
|
|
410
|
-
readonly github: "GitHub";
|
|
411
|
-
readonly facebook: "Facebook";
|
|
412
|
-
};
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
type LoginVendor = keyof typeof loginVendors;
|
|
416
|
-
type LoginProvider<V extends LoginVendor = LoginVendor> = keyof (typeof loginVendors)[V];
|
|
417
|
-
interface LoginProps<V extends LoginVendor = LoginVendor> {
|
|
418
|
-
/** The auth vendor behind the app's `AuthAdapter`. It sets which providers exist. */
|
|
419
|
-
vendor: V;
|
|
420
|
-
/** One button per provider, in this order. */
|
|
421
|
-
providers: LoginProvider<V>[];
|
|
422
|
-
title?: string;
|
|
423
|
-
message?: string;
|
|
424
|
-
/** Comes before the name of each provider, on its button. */
|
|
425
|
-
providerLabel?: string;
|
|
426
|
-
/** The toast when a sign-in fails. */
|
|
427
|
-
errorMessage?: string;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
declare const Login: <V extends LoginVendor>({ vendor, providers, title, message, providerLabel, errorMessage, }: LoginProps<V>) => react.JSX.Element;
|
|
431
|
-
|
|
432
|
-
interface SignOutButtonProps {
|
|
433
|
-
/** The accessible name of the icon button. */
|
|
434
|
-
label?: string;
|
|
435
|
-
/** The question of the modal a click opens. */
|
|
436
|
-
confirmTitle?: string;
|
|
437
|
-
/** The button of the modal that signs out. */
|
|
438
|
-
confirmLabel?: string;
|
|
439
|
-
/** The button of the modal that keeps the user signed in. */
|
|
440
|
-
cancelLabel?: string;
|
|
441
|
-
/** The toast when signing out fails. */
|
|
442
|
-
errorMessage?: string;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
declare const SignOutButton: ({ label, confirmTitle, confirmLabel, cancelLabel, errorMessage, }: SignOutButtonProps) => react.JSX.Element;
|
|
446
|
-
|
|
447
|
-
interface UseAuthResult extends Omit<AuthAdapter, "onSessionChange"> {
|
|
448
|
-
status: AuthStatus;
|
|
449
|
-
user: AuthUser | null;
|
|
450
|
-
/** The user's role in this app, or `null` when they have none. */
|
|
451
|
-
role: string | null;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
declare const useAuth: () => UseAuthResult;
|
|
455
|
-
|
|
456
|
-
declare const ZustandProviders: ({ children, auth }: ZustandProvidersProps) => react.JSX.Element;
|
|
457
|
-
|
|
458
371
|
declare const ReduxProvider: ({ children, reducers, middlewares, preloadedState, coreReducers, }: ReduxProviderProps) => react.JSX.Element;
|
|
459
372
|
|
|
460
373
|
interface ReduxStore extends Store {
|
|
@@ -556,5 +469,108 @@ declare class HTTPClient {
|
|
|
556
469
|
patch<T = unknown>(url: string, config?: HttpRequestConfig): Promise<T | undefined>;
|
|
557
470
|
}
|
|
558
471
|
|
|
559
|
-
|
|
560
|
-
|
|
472
|
+
interface AccessPendingProps {
|
|
473
|
+
title?: string;
|
|
474
|
+
message?: string;
|
|
475
|
+
/** The accessible name of the sign-out button. */
|
|
476
|
+
signOutLabel?: string;
|
|
477
|
+
/** The question of the modal the button opens. */
|
|
478
|
+
confirmTitle?: string;
|
|
479
|
+
/** The button of the modal that signs out. */
|
|
480
|
+
confirmLabel?: string;
|
|
481
|
+
/** The button of the modal that keeps the user signed in. */
|
|
482
|
+
cancelLabel?: string;
|
|
483
|
+
/** The toast when signing out fails. */
|
|
484
|
+
errorMessage?: string;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
declare const AccessPending: ({ title, message, signOutLabel, confirmTitle, confirmLabel, cancelLabel, errorMessage, }: AccessPendingProps) => react.JSX.Element | null;
|
|
488
|
+
|
|
489
|
+
/** The current session, for code outside React, such as a thunk. */
|
|
490
|
+
declare const getAuthSession: () => AuthSession | null;
|
|
491
|
+
|
|
492
|
+
interface AuthProviderProps extends AuthConfig {
|
|
493
|
+
children: ReactNode;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Keeps the adapter, the appId and the session in `useAuthStore`, the one
|
|
498
|
+
* place `useAuth` and `getAuthSession` read from. It runs in an effect, so on
|
|
499
|
+
* the first render the status is still `loading`.
|
|
500
|
+
*/
|
|
501
|
+
declare const AuthProvider: ({ adapter, appId, children, }: AuthProviderProps) => react.JSX.Element;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* The OAuth providers of each auth vendor, by the id the vendor knows, with
|
|
505
|
+
* the name each one shows on its button. A new vendor is a new key here.
|
|
506
|
+
*/
|
|
507
|
+
declare const loginVendors: {
|
|
508
|
+
readonly supabase: {
|
|
509
|
+
readonly google: "Google";
|
|
510
|
+
readonly apple: "Apple";
|
|
511
|
+
readonly github: "GitHub";
|
|
512
|
+
readonly facebook: "Facebook";
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
type LoginVendor = keyof typeof loginVendors;
|
|
517
|
+
type LoginProvider<V extends LoginVendor = LoginVendor> = keyof (typeof loginVendors)[V];
|
|
518
|
+
interface LoginProps<V extends LoginVendor = LoginVendor> {
|
|
519
|
+
/** The auth vendor behind the app's `AuthAdapter`. It sets which providers exist. */
|
|
520
|
+
vendor: V;
|
|
521
|
+
/** One button per provider, in this order. */
|
|
522
|
+
providers: LoginProvider<V>[];
|
|
523
|
+
title?: string;
|
|
524
|
+
message?: string;
|
|
525
|
+
/** Comes before the name of each provider, on its button. */
|
|
526
|
+
providerLabel?: string;
|
|
527
|
+
/** The toast when a sign-in fails. */
|
|
528
|
+
errorMessage?: string;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
declare const Login: <V extends LoginVendor>({ vendor, providers, title, message, providerLabel, errorMessage, }: LoginProps<V>) => react.JSX.Element;
|
|
532
|
+
|
|
533
|
+
interface AuthorizedProps<V extends LoginVendor = LoginVendor> {
|
|
534
|
+
/** The app, shown only to a signed-in user with access to it. */
|
|
535
|
+
children: ReactNode;
|
|
536
|
+
/**
|
|
537
|
+
* Roles that may see `children`, on top of access. Without it, access is
|
|
538
|
+
* enough, with or without a role.
|
|
539
|
+
*/
|
|
540
|
+
roles?: string[];
|
|
541
|
+
/** The props of the `Login` a signed-out user sees. */
|
|
542
|
+
login: LoginProps<V>;
|
|
543
|
+
/** The props of the `AccessPending` a user who can't see `children` sees. */
|
|
544
|
+
accessPending?: AccessPendingProps;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
declare const Authorized: <V extends LoginVendor>({ children, roles, login, accessPending, }: AuthorizedProps<V>) => react.JSX.Element | null;
|
|
548
|
+
|
|
549
|
+
interface SignOutButtonProps {
|
|
550
|
+
/** The accessible name of the icon button. */
|
|
551
|
+
label?: string;
|
|
552
|
+
/** The question of the modal a click opens. */
|
|
553
|
+
confirmTitle?: string;
|
|
554
|
+
/** The button of the modal that signs out. */
|
|
555
|
+
confirmLabel?: string;
|
|
556
|
+
/** The button of the modal that keeps the user signed in. */
|
|
557
|
+
cancelLabel?: string;
|
|
558
|
+
/** The toast when signing out fails. */
|
|
559
|
+
errorMessage?: string;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
declare const SignOutButton: ({ label, confirmTitle, confirmLabel, cancelLabel, errorMessage, }: SignOutButtonProps) => react.JSX.Element;
|
|
563
|
+
|
|
564
|
+
interface UseAuthResult extends Omit<AuthAdapter, "onSessionChange"> {
|
|
565
|
+
status: AuthStatus;
|
|
566
|
+
user: AuthUser | null;
|
|
567
|
+
/** The user's role in this app, or `null` when they have none. */
|
|
568
|
+
role: string | null;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
declare const useAuth: () => UseAuthResult;
|
|
572
|
+
|
|
573
|
+
declare const ZustandProviders: ({ children, auth }: ZustandProvidersProps) => react.JSX.Element;
|
|
574
|
+
|
|
575
|
+
export { AccessPending, AuthAdapter, AuthProvider, AuthSession, Authorized, 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 };
|
|
576
|
+
export type { AppState, AuthorizedProps, 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,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
AccessPending,
|
|
4
4
|
AuthProvider,
|
|
5
|
+
Authorized,
|
|
5
6
|
Button,
|
|
6
7
|
Card,
|
|
7
8
|
ConnectedModal,
|
|
@@ -25,7 +26,7 @@ import {
|
|
|
25
26
|
usePageStore,
|
|
26
27
|
useRouterStore,
|
|
27
28
|
useToastStore
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-JMEGXQKC.js";
|
|
29
30
|
import {
|
|
30
31
|
Error,
|
|
31
32
|
FormInput,
|
|
@@ -848,6 +849,7 @@ var HTTPClient = class {
|
|
|
848
849
|
export {
|
|
849
850
|
AccessPending,
|
|
850
851
|
AuthProvider,
|
|
852
|
+
Authorized,
|
|
851
853
|
Button,
|
|
852
854
|
Card,
|
|
853
855
|
Checkbox,
|
package/dist/next/index.js
CHANGED
package/dist/{redux-provider.interface-D6qhg7ND.d.ts → zustand-providers.interface-CeC8U2hM.d.ts}
RENAMED
|
@@ -14,6 +14,14 @@ type DataColor = "blue" | "red" | "yellow" | "green" | "gray" | "orange";
|
|
|
14
14
|
*/
|
|
15
15
|
type AuxiliaryColor = "orange" | "pink" | "purple";
|
|
16
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
|
+
|
|
17
25
|
type AuthStatus = "loading" | "authenticated" | "unauthenticated";
|
|
18
26
|
interface AuthUser {
|
|
19
27
|
id: string;
|
|
@@ -22,7 +30,7 @@ interface AuthUser {
|
|
|
22
30
|
avatarUrl?: string;
|
|
23
31
|
/**
|
|
24
32
|
* Whether the user may use this app, such as approved by an admin. It is
|
|
25
|
-
*
|
|
33
|
+
* the only thing `Authorized` checks unless it gets `roles`.
|
|
26
34
|
*/
|
|
27
35
|
hasAccess: boolean;
|
|
28
36
|
/** The user's role in each app, by app id: `{ entregas: "admin" }`. */
|
|
@@ -66,12 +74,4 @@ interface ZustandProvidersProps {
|
|
|
66
74
|
auth?: AuthConfig;
|
|
67
75
|
}
|
|
68
76
|
|
|
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
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 };
|