@cerberus-design/react 0.14.2-next-6531b4c → 0.14.2-next-58af9c8
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/build/legacy/_tsup-dts-rollup.d.cts +77 -1
- package/build/legacy/components/Notification.cjs +1 -0
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/context/notification-center/store.cjs +66 -0
- package/build/legacy/context/notification-center/store.cjs.map +1 -0
- package/build/legacy/context/notification-center/types.cjs +19 -0
- package/build/legacy/context/notification-center/types.cjs.map +1 -0
- package/build/legacy/context/notification-center.cjs +102 -58
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/index.cjs +102 -58
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +77 -1
- package/build/modern/{chunk-JQCRDZNI.js → chunk-BAWZBF5Q.js} +4 -4
- package/build/modern/{chunk-UMF2TWZN.js → chunk-D252JE4V.js} +7 -7
- package/build/modern/{chunk-KF35CYT4.js → chunk-RDRD6ACD.js} +2 -1
- package/build/modern/{chunk-KF35CYT4.js.map → chunk-RDRD6ACD.js.map} +1 -1
- package/build/modern/{chunk-EMNBMH7Z.js → chunk-USYM6XU6.js} +4 -4
- package/build/modern/chunk-V3M3ZOQI.js +38 -0
- package/build/modern/chunk-V3M3ZOQI.js.map +1 -0
- package/build/modern/{chunk-Z64YZ5IH.js → chunk-XDDLXEFV.js} +13 -13
- package/build/modern/{chunk-CCTLGF5U.js → chunk-YJI4Y7BH.js} +13 -13
- package/build/modern/chunk-YLMGZAKU.js +180 -0
- package/build/modern/chunk-YLMGZAKU.js.map +1 -0
- package/build/modern/{chunk-QKZZHZL4.js → chunk-ZHBHPMTP.js} +16 -16
- package/build/modern/components/AccordionItemGroup.js +3 -3
- package/build/modern/components/DatePicker.client.js +3 -3
- package/build/modern/components/FileStatus.js +2 -2
- package/build/modern/components/Notification.js +1 -1
- package/build/modern/context/confirm-modal.js +5 -5
- package/build/modern/context/cta-modal.js +5 -5
- package/build/modern/context/notification-center/store.js +15 -0
- package/build/modern/context/notification-center/store.js.map +1 -0
- package/build/modern/context/notification-center/types.js +1 -0
- package/build/modern/context/notification-center/types.js.map +1 -0
- package/build/modern/context/notification-center.js +4 -3
- package/build/modern/context/prompt-modal.js +6 -6
- package/build/modern/index.js +82 -81
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Notification.tsx +2 -0
- package/src/context/notification-center/store.ts +88 -0
- package/src/context/notification-center/types.ts +28 -0
- package/src/context/notification-center.tsx +81 -46
- package/build/modern/chunk-N3L3PEMF.js +0 -162
- package/build/modern/chunk-N3L3PEMF.js.map +0 -1
- /package/build/modern/{chunk-JQCRDZNI.js.map → chunk-BAWZBF5Q.js.map} +0 -0
- /package/build/modern/{chunk-UMF2TWZN.js.map → chunk-D252JE4V.js.map} +0 -0
- /package/build/modern/{chunk-EMNBMH7Z.js.map → chunk-USYM6XU6.js.map} +0 -0
- /package/build/modern/{chunk-Z64YZ5IH.js.map → chunk-XDDLXEFV.js.map} +0 -0
- /package/build/modern/{chunk-CCTLGF5U.js.map → chunk-YJI4Y7BH.js.map} +0 -0
- /package/build/modern/{chunk-QKZZHZL4.js.map → chunk-ZHBHPMTP.js.map} +0 -0
package/build/legacy/index.cjs
CHANGED
|
@@ -1895,6 +1895,7 @@ function Notification(props) {
|
|
|
1895
1895
|
"dialog",
|
|
1896
1896
|
{
|
|
1897
1897
|
...nativeProps,
|
|
1898
|
+
"data-placement": "left",
|
|
1898
1899
|
className: (0, import_css30.cx)(
|
|
1899
1900
|
nativeProps.className,
|
|
1900
1901
|
(0, import_patterns11.hstack)({
|
|
@@ -2816,33 +2817,86 @@ var import_react22 = require("react");
|
|
|
2816
2817
|
var import_patterns16 = require("@cerberus/styled-system/patterns");
|
|
2817
2818
|
var import_recipes38 = require("@cerberus/styled-system/recipes");
|
|
2818
2819
|
var import_css47 = require("@cerberus/styled-system/css");
|
|
2820
|
+
|
|
2821
|
+
// src/context/notification-center/store.ts
|
|
2822
|
+
function notificationCenterReducer(state, action) {
|
|
2823
|
+
switch (action.type) {
|
|
2824
|
+
case "ADD_NOTIFICATION":
|
|
2825
|
+
return [...state, action.payload];
|
|
2826
|
+
case "REMOVE_NOTIFICATION":
|
|
2827
|
+
return state.filter((n) => n.id !== action.payload.id);
|
|
2828
|
+
case "UPDATE_NOTIFICATION":
|
|
2829
|
+
return state.map(
|
|
2830
|
+
(n) => n.id === action.payload.id ? { ...n, ...action.payload } : n
|
|
2831
|
+
);
|
|
2832
|
+
case "CLEAR_NOTIFICATIONS":
|
|
2833
|
+
return [];
|
|
2834
|
+
default:
|
|
2835
|
+
return state;
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
function addNotification(dispatch, options) {
|
|
2839
|
+
dispatch({ type: "ADD_NOTIFICATION", payload: { ...options } });
|
|
2840
|
+
}
|
|
2841
|
+
function removeNotification(dispatch, id) {
|
|
2842
|
+
dispatch({ type: "REMOVE_NOTIFICATION", payload: { id } });
|
|
2843
|
+
}
|
|
2844
|
+
function updateNotificationState(dispatch, options) {
|
|
2845
|
+
dispatch({ type: "UPDATE_NOTIFICATION", payload: { ...options } });
|
|
2846
|
+
}
|
|
2847
|
+
function clearNotificationState(dispatch) {
|
|
2848
|
+
dispatch({ type: "CLEAR_NOTIFICATIONS" });
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
// src/context/notification-center.tsx
|
|
2819
2852
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
2820
2853
|
var NotificationsContext = (0, import_react22.createContext)(null);
|
|
2821
2854
|
function NotificationCenter(props) {
|
|
2822
|
-
const [
|
|
2855
|
+
const [state, dispatch] = (0, import_react22.useReducer)(notificationCenterReducer, []);
|
|
2823
2856
|
const styles = (0, import_recipes38.notification)();
|
|
2824
|
-
const
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
const item = prev.find((option) => option.id === target.value);
|
|
2834
|
-
if (item == null ? void 0 : item.onClose) item.onClose();
|
|
2835
|
-
return prev.filter((option) => option.id !== target.value);
|
|
2836
|
-
});
|
|
2837
|
-
}, []);
|
|
2838
|
-
const handleCloseAll = (0, import_react22.useCallback)(() => {
|
|
2839
|
-
setActiveNotifications((prev) => {
|
|
2840
|
-
prev.forEach((item) => {
|
|
2841
|
-
if (item.onClose) item.onClose();
|
|
2857
|
+
const timeout = (0, import_react22.useMemo)(
|
|
2858
|
+
() => props.duration || 6e3,
|
|
2859
|
+
[props.duration]
|
|
2860
|
+
);
|
|
2861
|
+
const closeNotification = (0, import_react22.useCallback)(
|
|
2862
|
+
(id) => {
|
|
2863
|
+
updateNotificationState(dispatch, {
|
|
2864
|
+
id,
|
|
2865
|
+
state: "closed"
|
|
2842
2866
|
});
|
|
2843
|
-
|
|
2867
|
+
setTimeout(() => {
|
|
2868
|
+
removeNotification(dispatch, id);
|
|
2869
|
+
}, 150);
|
|
2870
|
+
},
|
|
2871
|
+
[dispatch]
|
|
2872
|
+
);
|
|
2873
|
+
const handleNotify = (0, import_react22.useCallback)(
|
|
2874
|
+
(options) => {
|
|
2875
|
+
const id = `${options.palette}:${state.length + 1}`;
|
|
2876
|
+
addNotification(dispatch, {
|
|
2877
|
+
...options,
|
|
2878
|
+
id,
|
|
2879
|
+
state: "open"
|
|
2880
|
+
});
|
|
2881
|
+
setTimeout(() => {
|
|
2882
|
+
closeNotification(id);
|
|
2883
|
+
}, timeout);
|
|
2884
|
+
},
|
|
2885
|
+
[dispatch, state, timeout, closeNotification]
|
|
2886
|
+
);
|
|
2887
|
+
const handleClose = (0, import_react22.useCallback)(
|
|
2888
|
+
(e) => {
|
|
2889
|
+
const target = e.currentTarget;
|
|
2890
|
+
closeNotification(target.value);
|
|
2891
|
+
},
|
|
2892
|
+
[closeNotification]
|
|
2893
|
+
);
|
|
2894
|
+
const handleCloseAll = (0, import_react22.useCallback)(() => {
|
|
2895
|
+
state.forEach((item) => {
|
|
2896
|
+
if (item.onClose) item.onClose();
|
|
2844
2897
|
});
|
|
2845
|
-
|
|
2898
|
+
clearNotificationState(dispatch);
|
|
2899
|
+
}, [state, dispatch]);
|
|
2846
2900
|
const value = (0, import_react22.useMemo)(
|
|
2847
2901
|
() => ({
|
|
2848
2902
|
notify: handleNotify
|
|
@@ -2851,8 +2905,8 @@ function NotificationCenter(props) {
|
|
|
2851
2905
|
);
|
|
2852
2906
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(NotificationsContext.Provider, { value, children: [
|
|
2853
2907
|
props.children,
|
|
2854
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Show, { when:
|
|
2855
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Show, { when:
|
|
2908
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Show, { when: state.length > 0, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Portal, { container: props.container, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: styles.center, children: [
|
|
2909
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(Show, { when: state.length >= 4, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
2856
2910
|
Button,
|
|
2857
2911
|
{
|
|
2858
2912
|
className: (0, import_css47.cx)(styles.closeAll, (0, import_patterns16.animateIn)()),
|
|
@@ -2874,11 +2928,12 @@ function NotificationCenter(props) {
|
|
|
2874
2928
|
style: {
|
|
2875
2929
|
alignItems: "flex-end"
|
|
2876
2930
|
},
|
|
2877
|
-
children:
|
|
2931
|
+
children: state.map((option) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
2878
2932
|
MatchNotification,
|
|
2879
2933
|
{
|
|
2880
2934
|
...option,
|
|
2881
|
-
onClose: handleClose
|
|
2935
|
+
onClose: handleClose,
|
|
2936
|
+
open: option.state
|
|
2882
2937
|
},
|
|
2883
2938
|
option.id
|
|
2884
2939
|
))
|
|
@@ -2888,49 +2943,38 @@ function NotificationCenter(props) {
|
|
|
2888
2943
|
] });
|
|
2889
2944
|
}
|
|
2890
2945
|
function MatchNotification(props) {
|
|
2891
|
-
const { palette, id, onClose, heading, description } = props;
|
|
2946
|
+
const { palette, id, onClose, heading, description, open } = props;
|
|
2947
|
+
const sharedProps = (0, import_react22.useMemo)(
|
|
2948
|
+
() => ({
|
|
2949
|
+
id,
|
|
2950
|
+
open: true,
|
|
2951
|
+
onClose,
|
|
2952
|
+
"data-state": open
|
|
2953
|
+
}),
|
|
2954
|
+
[id, open, onClose]
|
|
2955
|
+
);
|
|
2892
2956
|
switch (palette) {
|
|
2893
2957
|
case "success":
|
|
2894
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
2895
|
-
|
|
2896
|
-
{
|
|
2897
|
-
|
|
2898
|
-
onClose,
|
|
2899
|
-
open: true,
|
|
2900
|
-
palette: "success",
|
|
2901
|
-
children: [
|
|
2902
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationHeading, { palette: "success", children: heading }),
|
|
2903
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationDescription, { palette: "success", children: description })
|
|
2904
|
-
]
|
|
2905
|
-
},
|
|
2906
|
-
id
|
|
2907
|
-
);
|
|
2958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Notification, { ...sharedProps, palette: "success", children: [
|
|
2959
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationHeading, { palette: "success", children: heading }),
|
|
2960
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationDescription, { palette: "success", children: description })
|
|
2961
|
+
] });
|
|
2908
2962
|
case "warning":
|
|
2909
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
2910
|
-
|
|
2911
|
-
{
|
|
2912
|
-
|
|
2913
|
-
onClose,
|
|
2914
|
-
open: true,
|
|
2915
|
-
palette: "warning",
|
|
2916
|
-
children: [
|
|
2917
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationHeading, { palette: "warning", children: heading }),
|
|
2918
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationDescription, { palette: "warning", children: description })
|
|
2919
|
-
]
|
|
2920
|
-
},
|
|
2921
|
-
id
|
|
2922
|
-
);
|
|
2963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Notification, { ...sharedProps, palette: "warning", children: [
|
|
2964
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationHeading, { palette: "warning", children: heading }),
|
|
2965
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationDescription, { palette: "warning", children: description })
|
|
2966
|
+
] });
|
|
2923
2967
|
case "danger":
|
|
2924
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Notification, {
|
|
2968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Notification, { ...sharedProps, palette: "danger", children: [
|
|
2925
2969
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationHeading, { palette: "danger", children: heading }),
|
|
2926
2970
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationDescription, { palette: "danger", children: description })
|
|
2927
|
-
] }
|
|
2971
|
+
] });
|
|
2928
2972
|
case "info":
|
|
2929
2973
|
default:
|
|
2930
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Notification, {
|
|
2974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Notification, { ...sharedProps, palette: "info", children: [
|
|
2931
2975
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationHeading, { palette: "info", children: heading }),
|
|
2932
2976
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NotificationDescription, { palette: "info", children: description })
|
|
2933
|
-
] }
|
|
2977
|
+
] });
|
|
2934
2978
|
}
|
|
2935
2979
|
}
|
|
2936
2980
|
function useNotificationCenter() {
|