@cerberus-design/react 0.7.4-next-92f76bb → 0.7.4-next-02f723e

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.
Files changed (89) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.ts +144 -5
  2. package/build/legacy/{chunk-7BB66W4A.js → chunk-4EMJR2AY.js} +2 -2
  3. package/build/legacy/{chunk-OLQQB53X.js → chunk-BEYPMC73.js} +2 -2
  4. package/build/legacy/chunk-BYDTAFCU.js +76 -0
  5. package/build/legacy/chunk-BYDTAFCU.js.map +1 -0
  6. package/build/legacy/{chunk-3RZUW5KH.js → chunk-DB2OA5PU.js} +3 -3
  7. package/build/legacy/{chunk-GIHAFJYX.js → chunk-GVNPFXKL.js} +9 -2
  8. package/build/legacy/chunk-GVNPFXKL.js.map +1 -0
  9. package/build/legacy/chunk-I5FPKT7H.js +122 -0
  10. package/build/legacy/chunk-I5FPKT7H.js.map +1 -0
  11. package/build/legacy/{chunk-ANXV7JDK.js → chunk-IL5ELPTT.js} +2 -2
  12. package/build/legacy/chunk-NWMNEJGU.js +16 -0
  13. package/build/legacy/chunk-NWMNEJGU.js.map +1 -0
  14. package/build/legacy/chunk-SINTHADQ.js +22 -0
  15. package/build/legacy/chunk-SINTHADQ.js.map +1 -0
  16. package/build/legacy/{chunk-DCI4IKCI.js → chunk-X5JR5LSC.js} +2 -2
  17. package/build/legacy/{chunk-DED42MIR.js → chunk-XB4ZRAH4.js} +2 -2
  18. package/build/legacy/components/FileUploader.js +3 -3
  19. package/build/legacy/components/Input.js +3 -3
  20. package/build/legacy/components/Notification.js +11 -0
  21. package/build/legacy/components/Notification.js.map +1 -0
  22. package/build/legacy/components/NotificationDescription.js +7 -0
  23. package/build/legacy/components/NotificationDescription.js.map +1 -0
  24. package/build/legacy/components/NotificationHeading.js +7 -0
  25. package/build/legacy/components/NotificationHeading.js.map +1 -0
  26. package/build/legacy/components/Toggle.js +3 -3
  27. package/build/legacy/config/cerbIcons.js +1 -1
  28. package/build/legacy/config/defineIcons.js +2 -2
  29. package/build/legacy/context/confirm-modal.js +3 -3
  30. package/build/legacy/context/notification-center.js +19 -0
  31. package/build/legacy/context/notification-center.js.map +1 -0
  32. package/build/legacy/context/prompt-modal.js +4 -4
  33. package/build/legacy/index.js +37 -19
  34. package/build/legacy/index.js.map +1 -1
  35. package/build/modern/_tsup-dts-rollup.d.ts +144 -5
  36. package/build/modern/{chunk-2NSXMFKX.js → chunk-3YORUZIQ.js} +2 -2
  37. package/build/modern/{chunk-OLQQB53X.js → chunk-BEYPMC73.js} +2 -2
  38. package/build/modern/{chunk-DKHQ5GBY.js → chunk-BMQ7I2PL.js} +3 -3
  39. package/build/modern/{chunk-GIHAFJYX.js → chunk-GVNPFXKL.js} +9 -2
  40. package/build/modern/chunk-GVNPFXKL.js.map +1 -0
  41. package/build/modern/{chunk-ANXV7JDK.js → chunk-IL5ELPTT.js} +2 -2
  42. package/build/modern/chunk-NWMNEJGU.js +16 -0
  43. package/build/modern/chunk-NWMNEJGU.js.map +1 -0
  44. package/build/modern/chunk-NZWANWYC.js +122 -0
  45. package/build/modern/chunk-NZWANWYC.js.map +1 -0
  46. package/build/modern/chunk-SINTHADQ.js +22 -0
  47. package/build/modern/chunk-SINTHADQ.js.map +1 -0
  48. package/build/modern/chunk-U5QWMMKZ.js +76 -0
  49. package/build/modern/chunk-U5QWMMKZ.js.map +1 -0
  50. package/build/modern/{chunk-DED42MIR.js → chunk-XB4ZRAH4.js} +2 -2
  51. package/build/modern/{chunk-SHNZS357.js → chunk-ZPWSMCZ5.js} +2 -2
  52. package/build/modern/components/FileUploader.js +3 -3
  53. package/build/modern/components/Input.js +3 -3
  54. package/build/modern/components/Notification.js +11 -0
  55. package/build/modern/components/Notification.js.map +1 -0
  56. package/build/modern/components/NotificationDescription.js +7 -0
  57. package/build/modern/components/NotificationDescription.js.map +1 -0
  58. package/build/modern/components/NotificationHeading.js +7 -0
  59. package/build/modern/components/NotificationHeading.js.map +1 -0
  60. package/build/modern/components/Toggle.js +3 -3
  61. package/build/modern/config/cerbIcons.js +1 -1
  62. package/build/modern/config/defineIcons.js +2 -2
  63. package/build/modern/context/confirm-modal.js +3 -3
  64. package/build/modern/context/notification-center.js +19 -0
  65. package/build/modern/context/notification-center.js.map +1 -0
  66. package/build/modern/context/prompt-modal.js +4 -4
  67. package/build/modern/index.js +37 -19
  68. package/build/modern/index.js.map +1 -1
  69. package/package.json +2 -2
  70. package/src/components/Notification.tsx +98 -0
  71. package/src/components/NotificationDescription.tsx +31 -0
  72. package/src/components/NotificationHeading.tsx +28 -0
  73. package/src/config/cerbIcons.ts +19 -6
  74. package/src/context/notification-center.tsx +181 -0
  75. package/src/index.ts +4 -0
  76. package/build/legacy/chunk-GIHAFJYX.js.map +0 -1
  77. package/build/modern/chunk-GIHAFJYX.js.map +0 -1
  78. /package/build/legacy/{chunk-7BB66W4A.js.map → chunk-4EMJR2AY.js.map} +0 -0
  79. /package/build/legacy/{chunk-OLQQB53X.js.map → chunk-BEYPMC73.js.map} +0 -0
  80. /package/build/legacy/{chunk-3RZUW5KH.js.map → chunk-DB2OA5PU.js.map} +0 -0
  81. /package/build/legacy/{chunk-ANXV7JDK.js.map → chunk-IL5ELPTT.js.map} +0 -0
  82. /package/build/legacy/{chunk-DCI4IKCI.js.map → chunk-X5JR5LSC.js.map} +0 -0
  83. /package/build/legacy/{chunk-DED42MIR.js.map → chunk-XB4ZRAH4.js.map} +0 -0
  84. /package/build/modern/{chunk-2NSXMFKX.js.map → chunk-3YORUZIQ.js.map} +0 -0
  85. /package/build/modern/{chunk-OLQQB53X.js.map → chunk-BEYPMC73.js.map} +0 -0
  86. /package/build/modern/{chunk-DKHQ5GBY.js.map → chunk-BMQ7I2PL.js.map} +0 -0
  87. /package/build/modern/{chunk-ANXV7JDK.js.map → chunk-IL5ELPTT.js.map} +0 -0
  88. /package/build/modern/{chunk-DED42MIR.js.map → chunk-XB4ZRAH4.js.map} +0 -0
  89. /package/build/modern/{chunk-SHNZS357.js.map → chunk-ZPWSMCZ5.js.map} +0 -0
@@ -0,0 +1,122 @@
1
+ import {
2
+ Notification
3
+ } from "./chunk-U5QWMMKZ.js";
4
+ import {
5
+ NotificationDescription
6
+ } from "./chunk-SINTHADQ.js";
7
+ import {
8
+ NotificationHeading
9
+ } from "./chunk-NWMNEJGU.js";
10
+ import {
11
+ Portal
12
+ } from "./chunk-4CAT3FHV.js";
13
+ import {
14
+ Button
15
+ } from "./chunk-2ATICEW3.js";
16
+ import {
17
+ Show
18
+ } from "./chunk-4O4QFF4S.js";
19
+
20
+ // src/context/notification-center.tsx
21
+ import {
22
+ createContext,
23
+ useCallback,
24
+ useContext,
25
+ useMemo,
26
+ useState
27
+ } from "react";
28
+ import { animateIn, vstack } from "@cerberus-design/styled-system/patterns";
29
+ import { notification } from "@cerberus-design/styled-system/recipes";
30
+ import { cx } from "@cerberus-design/styled-system/css";
31
+ import { jsx, jsxs } from "react/jsx-runtime";
32
+ var NotificationsContext = createContext(null);
33
+ function NotificationCenter(props) {
34
+ const [activeNotifications, setActiveNotifications] = useState([]);
35
+ const styles = notification();
36
+ const handleNotify = useCallback((options) => {
37
+ setActiveNotifications((prev) => {
38
+ const id = `${options.palette}:${prev.length + 1}`;
39
+ return [...prev, { ...options, id }];
40
+ });
41
+ }, []);
42
+ const handleClose = useCallback((e) => {
43
+ const target = e.currentTarget;
44
+ setActiveNotifications((prev) => {
45
+ const item = prev.find((option) => option.id === target.value);
46
+ if (item?.onClose) item.onClose();
47
+ return prev.filter((option) => option.id !== target.value);
48
+ });
49
+ }, []);
50
+ const handleCloseAll = useCallback(() => {
51
+ setActiveNotifications((prev) => {
52
+ prev.forEach((item) => {
53
+ if (item.onClose) item.onClose();
54
+ });
55
+ return [];
56
+ });
57
+ }, []);
58
+ const value = useMemo(
59
+ () => ({
60
+ notify: handleNotify
61
+ }),
62
+ [handleNotify]
63
+ );
64
+ return /* @__PURE__ */ jsxs(NotificationsContext.Provider, { value, children: [
65
+ props.children,
66
+ /* @__PURE__ */ jsx(Show, { when: activeNotifications.length > 0, children: /* @__PURE__ */ jsx(Portal, { container: props.container, children: /* @__PURE__ */ jsxs("div", { className: styles.center, children: [
67
+ /* @__PURE__ */ jsx(Show, { when: activeNotifications.length >= 4, children: /* @__PURE__ */ jsx(
68
+ Button,
69
+ {
70
+ className: cx(styles.closeAll, animateIn()),
71
+ onClick: handleCloseAll,
72
+ palette: "action",
73
+ shape: "rounded",
74
+ size: "sm",
75
+ usage: "text",
76
+ children: "Close all"
77
+ }
78
+ ) }),
79
+ /* @__PURE__ */ jsx(
80
+ "div",
81
+ {
82
+ className: vstack({
83
+ alignItems: "flex-end",
84
+ gap: "4"
85
+ }),
86
+ style: {
87
+ alignItems: "flex-end"
88
+ },
89
+ children: activeNotifications.map((option) => /* @__PURE__ */ jsxs(
90
+ Notification,
91
+ {
92
+ id: option.id,
93
+ onClose: handleClose,
94
+ open: true,
95
+ palette: option.palette,
96
+ children: [
97
+ /* @__PURE__ */ jsx(NotificationHeading, { palette: option.palette, children: option.heading }),
98
+ /* @__PURE__ */ jsx(NotificationDescription, { palette: option.palette, children: option.description })
99
+ ]
100
+ },
101
+ option.id
102
+ ))
103
+ }
104
+ )
105
+ ] }) }) })
106
+ ] });
107
+ }
108
+ function useNotificationCenter() {
109
+ const context = useContext(NotificationsContext);
110
+ if (!context) {
111
+ throw new Error(
112
+ "useNotificationCenter must be used within a NotificationsProvider"
113
+ );
114
+ }
115
+ return context;
116
+ }
117
+
118
+ export {
119
+ NotificationCenter,
120
+ useNotificationCenter
121
+ };
122
+ //# sourceMappingURL=chunk-NZWANWYC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/notification-center.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Show } from '../components/Show'\nimport { NotificationHeading } from '../components/NotificationHeading'\nimport { NotificationDescription } from '../components/NotificationDescription'\nimport { Notification } from '../components/Notification'\nimport { animateIn, vstack } from '@cerberus-design/styled-system/patterns'\nimport { Portal, type PortalProps } from '../components/Portal'\nimport { notification } from '@cerberus-design/styled-system/recipes'\nimport { Button } from '../components/Button'\nimport { cx } from '@cerberus-design/styled-system/css'\n\n/**\n * This module provides a context and hook for notifications.\n * @module\n */\n\nexport interface NotifyOptions {\n palette: 'info' | 'success' | 'warning' | 'danger'\n heading: string\n id?: string\n description?: ReactNode\n onClose?: () => void\n}\n\nexport interface NotificationsValue {\n notify: (options: NotifyOptions) => void\n}\n\nconst NotificationsContext = createContext<NotificationsValue | null>(null)\n\nexport interface NotificationsProviderProps extends PortalProps {}\n\n/**\n * Provides a notification center to the app.\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <Notifications>\n * <SomeFeatureSection />\n * </Notifications>\n *\n * // Use the hook to show a notification.\n * const notify = useNotifications()\n *\n * const handleClick = useCallback(() => {\n * notify({\n * palette: 'info',\n * heading: 'New feature!',\n * description: 'We have added a new feature to the app.',\n * })\n * }, [notify])\n * ```\n */\nexport function NotificationCenter(\n props: PropsWithChildren<NotificationsProviderProps>,\n) {\n const [activeNotifications, setActiveNotifications] = useState<\n NotifyOptions[]\n >([])\n const styles = notification()\n\n const handleNotify = useCallback((options: NotifyOptions) => {\n setActiveNotifications((prev) => {\n const id = `${options.palette}:${prev.length + 1}`\n return [...prev, { ...options, id }]\n })\n }, [])\n\n const handleClose = useCallback((e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n setActiveNotifications((prev) => {\n const item = prev.find((option) => option.id === target.value)\n if (item?.onClose) item.onClose()\n return prev.filter((option) => option.id !== target.value)\n })\n }, [])\n\n const handleCloseAll = useCallback(() => {\n setActiveNotifications((prev) => {\n prev.forEach((item) => {\n if (item.onClose) item.onClose()\n })\n return []\n })\n }, [])\n\n const value = useMemo(\n () => ({\n notify: handleNotify,\n }),\n [handleNotify],\n )\n\n // For some reason, the vstack pattern alignItems is not registering here.\n // So we are forcing it with the style prop.\n\n return (\n <NotificationsContext.Provider value={value}>\n {props.children}\n\n <Show when={activeNotifications.length > 0}>\n <Portal container={props.container}>\n <div className={styles.center}>\n <Show when={activeNotifications.length >= 4}>\n <Button\n className={cx(styles.closeAll, animateIn())}\n onClick={handleCloseAll}\n palette=\"action\"\n shape=\"rounded\"\n size=\"sm\"\n usage=\"text\"\n >\n Close all\n </Button>\n </Show>\n <div\n className={vstack({\n alignItems: 'flex-end',\n gap: '4',\n })}\n style={{\n alignItems: 'flex-end',\n }}\n >\n {activeNotifications.map((option) => (\n <Notification\n id={option.id!}\n key={option.id}\n onClose={handleClose}\n open\n palette={option.palette}\n >\n <NotificationHeading palette={option.palette}>\n {option.heading}\n </NotificationHeading>\n <NotificationDescription palette={option.palette}>\n {option.description}\n </NotificationDescription>\n </Notification>\n ))}\n </div>\n </div>\n </Portal>\n </Show>\n </NotificationsContext.Provider>\n )\n}\n\n/**\n * The hook to use the NotificationCenter.\n * @returns The notify method to trigger a notification.\n * @example\n * ```tsx\n * const {notify} = useNotificationCenter()\n * notify({\n * palette: 'info',\n * heading: 'New feature',\n * description: 'We have added a new feature to the app.',\n * })\n * ```\n */\nexport function useNotificationCenter(): NotificationsValue {\n const context = useContext(NotificationsContext)\n if (!context) {\n throw new Error(\n 'useNotificationCenter must be used within a NotificationsProvider',\n )\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAKP,SAAS,WAAW,cAAc;AAElC,SAAS,oBAAoB;AAE7B,SAAS,UAAU;AA+FL,cAqBE,YArBF;AA5Ed,IAAM,uBAAuB,cAAyC,IAAI;AAyBnE,SAAS,mBACd,OACA;AACA,QAAM,CAAC,qBAAqB,sBAAsB,IAAI,SAEpD,CAAC,CAAC;AACJ,QAAM,SAAS,aAAa;AAE5B,QAAM,eAAe,YAAY,CAAC,YAA2B;AAC3D,2BAAuB,CAAC,SAAS;AAC/B,YAAM,KAAK,GAAG,QAAQ,OAAO,IAAI,KAAK,SAAS,CAAC;AAChD,aAAO,CAAC,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,CAAC;AAAA,IACrC,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,QAAM,cAAc,YAAY,CAAC,MAAqC;AACpE,UAAM,SAAS,EAAE;AACjB,2BAAuB,CAAC,SAAS;AAC/B,YAAM,OAAO,KAAK,KAAK,CAAC,WAAW,OAAO,OAAO,OAAO,KAAK;AAC7D,UAAI,MAAM,QAAS,MAAK,QAAQ;AAChC,aAAO,KAAK,OAAO,CAAC,WAAW,OAAO,OAAO,OAAO,KAAK;AAAA,IAC3D,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,QAAM,iBAAiB,YAAY,MAAM;AACvC,2BAAuB,CAAC,SAAS;AAC/B,WAAK,QAAQ,CAAC,SAAS;AACrB,YAAI,KAAK,QAAS,MAAK,QAAQ;AAAA,MACjC,CAAC;AACD,aAAO,CAAC;AAAA,IACV,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AAKA,SACE,qBAAC,qBAAqB,UAArB,EAA8B,OAC5B;AAAA,UAAM;AAAA,IAEP,oBAAC,QAAK,MAAM,oBAAoB,SAAS,GACvC,8BAAC,UAAO,WAAW,MAAM,WACvB,+BAAC,SAAI,WAAW,OAAO,QACrB;AAAA,0BAAC,QAAK,MAAM,oBAAoB,UAAU,GACxC;AAAA,QAAC;AAAA;AAAA,UACC,WAAW,GAAG,OAAO,UAAU,UAAU,CAAC;AAAA,UAC1C,SAAS;AAAA,UACT,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,MAAK;AAAA,UACL,OAAM;AAAA,UACP;AAAA;AAAA,MAED,GACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW,OAAO;AAAA,YAChB,YAAY;AAAA,YACZ,KAAK;AAAA,UACP,CAAC;AAAA,UACD,OAAO;AAAA,YACL,YAAY;AAAA,UACd;AAAA,UAEC,8BAAoB,IAAI,CAAC,WACxB;AAAA,YAAC;AAAA;AAAA,cACC,IAAI,OAAO;AAAA,cAEX,SAAS;AAAA,cACT,MAAI;AAAA,cACJ,SAAS,OAAO;AAAA,cAEhB;AAAA,oCAAC,uBAAoB,SAAS,OAAO,SAClC,iBAAO,SACV;AAAA,gBACA,oBAAC,2BAAwB,SAAS,OAAO,SACtC,iBAAO,aACV;AAAA;AAAA;AAAA,YAVK,OAAO;AAAA,UAWd,CACD;AAAA;AAAA,MACH;AAAA,OACF,GACF,GACF;AAAA,KACF;AAEJ;AAeO,SAAS,wBAA4C;AAC1D,QAAM,UAAU,WAAW,oBAAoB;AAC/C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,22 @@
1
+ // src/components/NotificationDescription.tsx
2
+ import { cx } from "@cerberus-design/styled-system/css";
3
+ import {
4
+ notification
5
+ } from "@cerberus-design/styled-system/recipes";
6
+ import { jsx } from "react/jsx-runtime";
7
+ function NotificationDescription(props) {
8
+ const { palette, ...nativeProps } = props;
9
+ const styles = notification({ palette });
10
+ return /* @__PURE__ */ jsx(
11
+ "p",
12
+ {
13
+ className: cx(nativeProps.className, styles.description),
14
+ ...nativeProps
15
+ }
16
+ );
17
+ }
18
+
19
+ export {
20
+ NotificationDescription
21
+ };
22
+ //# sourceMappingURL=chunk-SINTHADQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/NotificationDescription.tsx"],"sourcesContent":["/**\n * This module exports the NotificationDescription component.\n * @module\n */\n\nimport { cx } from '@cerberus-design/styled-system/css'\nimport {\n notification,\n type NotificationVariantProps,\n} from '@cerberus-design/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\nexport interface BaseNotificationDescriptionProps\n extends HTMLAttributes<HTMLParagraphElement> {}\nexport type NotificationDescriptionProps = BaseNotificationDescriptionProps &\n NotificationVariantProps\n\n/**\n * The NotificationDescription component is used to render the description of a notification.\n * @param props - The anything a HTMLParagraphElement can accept.\n */\nexport function NotificationDescription(props: NotificationDescriptionProps) {\n const { palette, ...nativeProps } = props\n const styles = notification({ palette })\n return (\n <p\n className={cx(nativeProps.className, styles.description)}\n {...nativeProps}\n />\n )\n}\n"],"mappings":";AAKA,SAAS,UAAU;AACnB;AAAA,EACE;AAAA,OAEK;AAgBH;AAJG,SAAS,wBAAwB,OAAqC;AAC3E,QAAM,EAAE,SAAS,GAAG,YAAY,IAAI;AACpC,QAAM,SAAS,aAAa,EAAE,QAAQ,CAAC;AACvC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,YAAY,WAAW,OAAO,WAAW;AAAA,MACtD,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
@@ -0,0 +1,76 @@
1
+ import {
2
+ trapFocus
3
+ } from "./chunk-JIZQFTW6.js";
4
+ import {
5
+ $cerberusIcons
6
+ } from "./chunk-BEYPMC73.js";
7
+
8
+ // src/components/Notification.tsx
9
+ import { cx } from "@cerberus-design/styled-system/css";
10
+ import { hstack, vstack } from "@cerberus-design/styled-system/patterns";
11
+ import {
12
+ notification
13
+ } from "@cerberus-design/styled-system/recipes";
14
+ import {
15
+ useRef
16
+ } from "react";
17
+ import { Close } from "@cerberus/icons";
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ function MatchNotificationIcon(props) {
20
+ const palette = props.palette || "info";
21
+ const key = `${palette}Notification`;
22
+ const Icon = $cerberusIcons[key];
23
+ return /* @__PURE__ */ jsx(Icon, {});
24
+ }
25
+ function Notification(props) {
26
+ const { children, palette, onClose, ...nativeProps } = props;
27
+ const ref = useRef(null);
28
+ const onKeyDown = trapFocus(ref);
29
+ const styles = notification({ palette });
30
+ return /* @__PURE__ */ jsxs(
31
+ "dialog",
32
+ {
33
+ ...nativeProps,
34
+ className: cx(
35
+ nativeProps.className,
36
+ hstack({
37
+ position: "relative",
38
+ gap: "4"
39
+ }),
40
+ styles.dialog
41
+ ),
42
+ onKeyDown,
43
+ ref,
44
+ role: "alert",
45
+ children: [
46
+ /* @__PURE__ */ jsx("span", { className: styles.icon, children: /* @__PURE__ */ jsx(MatchNotificationIcon, { palette }) }),
47
+ /* @__PURE__ */ jsx(
48
+ "div",
49
+ {
50
+ className: vstack({
51
+ alignItems: "flex-start",
52
+ gap: "0",
53
+ py: "2"
54
+ }),
55
+ children
56
+ }
57
+ ),
58
+ /* @__PURE__ */ jsx(
59
+ "button",
60
+ {
61
+ "aria-label": "Close",
62
+ className: styles.close,
63
+ onClick: onClose,
64
+ value: props.id,
65
+ children: /* @__PURE__ */ jsx(Close, {})
66
+ }
67
+ )
68
+ ]
69
+ }
70
+ );
71
+ }
72
+
73
+ export {
74
+ Notification
75
+ };
76
+ //# sourceMappingURL=chunk-U5QWMMKZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Notification.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus-design/styled-system/css'\nimport { hstack, vstack } from '@cerberus-design/styled-system/patterns'\nimport {\n notification,\n type NotificationVariantProps,\n} from '@cerberus-design/styled-system/recipes'\nimport {\n useRef,\n type DialogHTMLAttributes,\n type PropsWithChildren,\n type MouseEvent,\n} from 'react'\nimport { Close } from '@cerberus/icons'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport type { IconType } from '../config/cerbIcons'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\n\n/**\n * This module exports the Notification component.\n * @module\n */\n\nfunction MatchNotificationIcon(props: NotificationVariantProps) {\n const palette = props.palette || 'info'\n const key = `${palette}Notification` as keyof typeof $cerberusIcons\n const Icon = $cerberusIcons[key] as IconType\n return <Icon />\n}\n\nexport interface NotificationBaseProps\n extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'onClose'> {\n id: string\n onClose?: (e: MouseEvent<HTMLButtonElement>) => void\n}\nexport type NotificationProps = NotificationBaseProps & NotificationVariantProps\n\n/**\n * The info notification component.\n * @param props - The component props.\n * @returns The info notification component.\n * @example\n * ```tsx\n * <Notification id=\"info:1\" open>\n * <NotificationHeading>Info Notification</NotificationHeading>\n * <NotificationDescription>\n * This is a description with a <a href=\"#\">link</a> in the message.\n * </NotificationDescription>\n * </Notification>\n * ```\n */\nexport function Notification(props: PropsWithChildren<NotificationProps>) {\n const { children, palette, onClose, ...nativeProps } = props\n const ref = useRef<HTMLDialogElement>(null)\n const onKeyDown = trapFocus(ref)\n const styles = notification({ palette })\n\n return (\n <dialog\n {...nativeProps}\n className={cx(\n nativeProps.className,\n hstack({\n position: 'relative',\n gap: '4',\n }),\n styles.dialog,\n )}\n onKeyDown={onKeyDown}\n ref={ref}\n role=\"alert\"\n >\n <span className={styles.icon}>\n <MatchNotificationIcon palette={palette} />\n </span>\n\n <div\n className={vstack({\n alignItems: 'flex-start',\n gap: '0',\n py: '2',\n })}\n >\n {children}\n </div>\n\n <button\n aria-label=\"Close\"\n className={styles.close}\n onClick={onClose}\n value={props.id}\n >\n <Close />\n </button>\n </dialog>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,UAAU;AACnB,SAAS,QAAQ,cAAc;AAC/B;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAIK;AACP,SAAS,aAAa;AAcb,cA+BL,YA/BK;AAJT,SAAS,sBAAsB,OAAiC;AAC9D,QAAM,UAAU,MAAM,WAAW;AACjC,QAAM,MAAM,GAAG,OAAO;AACtB,QAAM,OAAO,eAAe,GAAG;AAC/B,SAAO,oBAAC,QAAK;AACf;AAuBO,SAAS,aAAa,OAA6C;AACxE,QAAM,EAAE,UAAU,SAAS,SAAS,GAAG,YAAY,IAAI;AACvD,QAAM,MAAM,OAA0B,IAAI;AAC1C,QAAM,YAAY,UAAU,GAAG;AAC/B,QAAM,SAAS,aAAa,EAAE,QAAQ,CAAC;AAEvC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,OAAO;AAAA,UACL,UAAU;AAAA,UACV,KAAK;AAAA,QACP,CAAC;AAAA,QACD,OAAO;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MAEL;AAAA,4BAAC,UAAK,WAAW,OAAO,MACtB,8BAAC,yBAAsB,SAAkB,GAC3C;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,OAAO;AAAA,cAChB,YAAY;AAAA,cACZ,KAAK;AAAA,cACL,IAAI;AAAA,YACN,CAAC;AAAA,YAEA;AAAA;AAAA,QACH;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW,OAAO;AAAA,YAClB,SAAS;AAAA,YACT,OAAO,MAAM;AAAA,YAEb,8BAAC,SAAM;AAAA;AAAA,QACT;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-4O4QFF4S.js";
7
7
  import {
8
8
  $cerberusIcons
9
- } from "./chunk-OLQQB53X.js";
9
+ } from "./chunk-BEYPMC73.js";
10
10
 
11
11
  // src/components/Input.tsx
12
12
  import { input } from "@cerberus/styled-system/recipes";
@@ -39,4 +39,4 @@ function Input(props) {
39
39
  export {
40
40
  Input
41
41
  };
42
- //# sourceMappingURL=chunk-DED42MIR.js.map
42
+ //# sourceMappingURL=chunk-XB4ZRAH4.js.map
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-JIZQFTW6.js";
28
28
  import {
29
29
  $cerberusIcons
30
- } from "./chunk-OLQQB53X.js";
30
+ } from "./chunk-BEYPMC73.js";
31
31
  import {
32
32
  useModal
33
33
  } from "./chunk-C5HLLGME.js";
@@ -151,4 +151,4 @@ export {
151
151
  ConfirmModal,
152
152
  useConfirmModal
153
153
  };
154
- //# sourceMappingURL=chunk-SHNZS357.js.map
154
+ //# sourceMappingURL=chunk-ZPWSMCZ5.js.map
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import {
3
3
  FileUploader
4
- } from "../chunk-2NSXMFKX.js";
4
+ } from "../chunk-3YORUZIQ.js";
5
5
  import "../chunk-4O4QFF4S.js";
6
- import "../chunk-OLQQB53X.js";
7
- import "../chunk-GIHAFJYX.js";
6
+ import "../chunk-BEYPMC73.js";
7
+ import "../chunk-GVNPFXKL.js";
8
8
  export {
9
9
  FileUploader
10
10
  };
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  Input
4
- } from "../chunk-DED42MIR.js";
4
+ } from "../chunk-XB4ZRAH4.js";
5
5
  import "../chunk-ZAU4JVLL.js";
6
6
  import "../chunk-4O4QFF4S.js";
7
- import "../chunk-OLQQB53X.js";
8
- import "../chunk-GIHAFJYX.js";
7
+ import "../chunk-BEYPMC73.js";
8
+ import "../chunk-GVNPFXKL.js";
9
9
  export {
10
10
  Input
11
11
  };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import {
3
+ Notification
4
+ } from "../chunk-U5QWMMKZ.js";
5
+ import "../chunk-JIZQFTW6.js";
6
+ import "../chunk-BEYPMC73.js";
7
+ import "../chunk-GVNPFXKL.js";
8
+ export {
9
+ Notification
10
+ };
11
+ //# sourceMappingURL=Notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ NotificationDescription
3
+ } from "../chunk-SINTHADQ.js";
4
+ export {
5
+ NotificationDescription
6
+ };
7
+ //# sourceMappingURL=NotificationDescription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ NotificationHeading
3
+ } from "../chunk-NWMNEJGU.js";
4
+ export {
5
+ NotificationHeading
6
+ };
7
+ //# sourceMappingURL=NotificationHeading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import {
3
3
  Toggle
4
- } from "../chunk-ANXV7JDK.js";
4
+ } from "../chunk-IL5ELPTT.js";
5
5
  import "../chunk-ZAU4JVLL.js";
6
- import "../chunk-OLQQB53X.js";
7
- import "../chunk-GIHAFJYX.js";
6
+ import "../chunk-BEYPMC73.js";
7
+ import "../chunk-GVNPFXKL.js";
8
8
  export {
9
9
  Toggle
10
10
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defaultIcons
3
- } from "../chunk-GIHAFJYX.js";
3
+ } from "../chunk-GVNPFXKL.js";
4
4
  export {
5
5
  defaultIcons
6
6
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  $cerberusIcons,
3
3
  defineIcons
4
- } from "../chunk-OLQQB53X.js";
5
- import "../chunk-GIHAFJYX.js";
4
+ } from "../chunk-BEYPMC73.js";
5
+ import "../chunk-GVNPFXKL.js";
6
6
  export {
7
7
  $cerberusIcons,
8
8
  defineIcons
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConfirmModal,
4
4
  useConfirmModal
5
- } from "../chunk-SHNZS357.js";
5
+ } from "../chunk-ZPWSMCZ5.js";
6
6
  import "../chunk-4CAT3FHV.js";
7
7
  import "../chunk-2UFNQM55.js";
8
8
  import "../chunk-4M4LCQ43.js";
@@ -12,8 +12,8 @@ import "../chunk-JJP2TFTU.js";
12
12
  import "../chunk-2ATICEW3.js";
13
13
  import "../chunk-4O4QFF4S.js";
14
14
  import "../chunk-JIZQFTW6.js";
15
- import "../chunk-OLQQB53X.js";
16
- import "../chunk-GIHAFJYX.js";
15
+ import "../chunk-BEYPMC73.js";
16
+ import "../chunk-GVNPFXKL.js";
17
17
  import "../chunk-C5HLLGME.js";
18
18
  export {
19
19
  ConfirmModal,
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import {
3
+ NotificationCenter,
4
+ useNotificationCenter
5
+ } from "../chunk-NZWANWYC.js";
6
+ import "../chunk-U5QWMMKZ.js";
7
+ import "../chunk-SINTHADQ.js";
8
+ import "../chunk-NWMNEJGU.js";
9
+ import "../chunk-4CAT3FHV.js";
10
+ import "../chunk-2ATICEW3.js";
11
+ import "../chunk-4O4QFF4S.js";
12
+ import "../chunk-JIZQFTW6.js";
13
+ import "../chunk-BEYPMC73.js";
14
+ import "../chunk-GVNPFXKL.js";
15
+ export {
16
+ NotificationCenter,
17
+ useNotificationCenter
18
+ };
19
+ //# sourceMappingURL=notification-center.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  PromptModal,
4
4
  usePromptModal
5
- } from "../chunk-DKHQ5GBY.js";
5
+ } from "../chunk-BMQ7I2PL.js";
6
6
  import "../chunk-4CAT3FHV.js";
7
- import "../chunk-DED42MIR.js";
7
+ import "../chunk-XB4ZRAH4.js";
8
8
  import "../chunk-JJGZRBIR.js";
9
9
  import "../chunk-2UFNQM55.js";
10
10
  import "../chunk-4M4LCQ43.js";
@@ -15,8 +15,8 @@ import "../chunk-2ATICEW3.js";
15
15
  import "../chunk-ZAU4JVLL.js";
16
16
  import "../chunk-4O4QFF4S.js";
17
17
  import "../chunk-JIZQFTW6.js";
18
- import "../chunk-OLQQB53X.js";
19
- import "../chunk-GIHAFJYX.js";
18
+ import "../chunk-BEYPMC73.js";
19
+ import "../chunk-GVNPFXKL.js";
20
20
  import "../chunk-C5HLLGME.js";
21
21
  export {
22
22
  PromptModal,
@@ -1,3 +1,20 @@
1
+ import {
2
+ NotificationCenter,
3
+ useNotificationCenter
4
+ } from "./chunk-NZWANWYC.js";
5
+ import {
6
+ PromptModal,
7
+ usePromptModal
8
+ } from "./chunk-BMQ7I2PL.js";
9
+ import {
10
+ Tab
11
+ } from "./chunk-SONHHNYQ.js";
12
+ import {
13
+ TabList
14
+ } from "./chunk-ISPTI4GC.js";
15
+ import {
16
+ TabPanel
17
+ } from "./chunk-U72VPIZA.js";
1
18
  import {
2
19
  Tag
3
20
  } from "./chunk-Z6IWNVPN.js";
@@ -6,15 +23,11 @@ import {
6
23
  } from "./chunk-TCO46FK7.js";
7
24
  import {
8
25
  Toggle
9
- } from "./chunk-ANXV7JDK.js";
26
+ } from "./chunk-IL5ELPTT.js";
10
27
  import {
11
28
  ConfirmModal,
12
29
  useConfirmModal
13
- } from "./chunk-SHNZS357.js";
14
- import {
15
- PromptModal,
16
- usePromptModal
17
- } from "./chunk-DKHQ5GBY.js";
30
+ } from "./chunk-ZPWSMCZ5.js";
18
31
  import {
19
32
  NavMenuList,
20
33
  getPosition
@@ -26,24 +39,24 @@ import {
26
39
  NavMenu,
27
40
  useNavMenuContext
28
41
  } from "./chunk-KJUCHZHV.js";
42
+ import {
43
+ Notification
44
+ } from "./chunk-U5QWMMKZ.js";
45
+ import {
46
+ NotificationDescription
47
+ } from "./chunk-SINTHADQ.js";
48
+ import {
49
+ NotificationHeading
50
+ } from "./chunk-NWMNEJGU.js";
29
51
  import {
30
52
  Portal
31
53
  } from "./chunk-4CAT3FHV.js";
32
54
  import {
33
55
  Radio
34
56
  } from "./chunk-PH64POOB.js";
35
- import {
36
- Tab
37
- } from "./chunk-SONHHNYQ.js";
38
- import {
39
- TabList
40
- } from "./chunk-ISPTI4GC.js";
41
- import {
42
- TabPanel
43
- } from "./chunk-U72VPIZA.js";
44
57
  import {
45
58
  Input
46
- } from "./chunk-DED42MIR.js";
59
+ } from "./chunk-XB4ZRAH4.js";
47
60
  import {
48
61
  Label
49
62
  } from "./chunk-JJGZRBIR.js";
@@ -97,7 +110,7 @@ import {
97
110
  } from "./chunk-ZAU4JVLL.js";
98
111
  import {
99
112
  FileUploader
100
- } from "./chunk-2NSXMFKX.js";
113
+ } from "./chunk-3YORUZIQ.js";
101
114
  import {
102
115
  Show
103
116
  } from "./chunk-4O4QFF4S.js";
@@ -122,8 +135,8 @@ import {
122
135
  import {
123
136
  $cerberusIcons,
124
137
  defineIcons
125
- } from "./chunk-OLQQB53X.js";
126
- import "./chunk-GIHAFJYX.js";
138
+ } from "./chunk-BEYPMC73.js";
139
+ import "./chunk-GVNPFXKL.js";
127
140
  import {
128
141
  useModal
129
142
  } from "./chunk-C5HLLGME.js";
@@ -153,6 +166,10 @@ export {
153
166
  NavMenuLink,
154
167
  NavMenuList,
155
168
  NavMenuTrigger,
169
+ Notification,
170
+ NotificationCenter,
171
+ NotificationDescription,
172
+ NotificationHeading,
156
173
  Portal,
157
174
  PromptModal,
158
175
  Radio,
@@ -176,6 +193,7 @@ export {
176
193
  useFieldContext,
177
194
  useModal,
178
195
  useNavMenuContext,
196
+ useNotificationCenter,
179
197
  usePromptModal,
180
198
  useTabsContext,
181
199
  useTabsKeyboardNavigation,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Button'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/ModalIcon'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Portal'\nexport * from './components/Radio'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Button'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/ModalIcon'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/Radio'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerberus-design/react",
3
- "version": "0.7.4-next-92f76bb",
3
+ "version": "0.7.4-next-02f723e",
4
4
  "description": "The Cerberus Design React component library.",
5
5
  "browserslist": "> 0.25%, not dead",
6
6
  "sideEffects": false,
@@ -26,7 +26,7 @@
26
26
  "react-dom": "^18",
27
27
  "tsup": "^8.1.0",
28
28
  "@cerberus-design/configs": "0.0.0",
29
- "@cerberus-design/styled-system": "0.7.4-next-92f76bb"
29
+ "@cerberus-design/styled-system": "0.7.4-next-02f723e"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"