@cerberus-design/react 0.14.2-next-3837068 → 0.14.2-next-d5ed509
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 +76 -75
- 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
|
@@ -42,6 +42,7 @@ import { defaultDropAnimation } from '@dnd-kit/core';
|
|
|
42
42
|
import { defaultDropAnimationSideEffects } from '@dnd-kit/core';
|
|
43
43
|
import { defaultScreenReaderInstructions } from '@dnd-kit/core';
|
|
44
44
|
import { DialogHTMLAttributes } from 'react';
|
|
45
|
+
import type { Dispatch } from 'react';
|
|
45
46
|
import { DistanceMeasurement } from '@dnd-kit/core';
|
|
46
47
|
import { DndContext } from '@dnd-kit/core';
|
|
47
48
|
import { DndContextDescriptor } from '@dnd-kit/core';
|
|
@@ -319,6 +320,18 @@ export { Activators }
|
|
|
319
320
|
|
|
320
321
|
export { Active }
|
|
321
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Adds a notification to the notification center.
|
|
325
|
+
* @param dispatch The dispatch function.
|
|
326
|
+
* @param options The notification options.
|
|
327
|
+
*/
|
|
328
|
+
export declare function addNotification(dispatch: Dispatch<AddNotifyAction>, options: AddNotifyAction['payload']): void;
|
|
329
|
+
|
|
330
|
+
export declare type AddNotifyAction = {
|
|
331
|
+
type: 'ADD_NOTIFICATION';
|
|
332
|
+
payload: NotificationOption;
|
|
333
|
+
};
|
|
334
|
+
|
|
322
335
|
/**
|
|
323
336
|
* The `Admonition` component is used to create an admonition.
|
|
324
337
|
* @example
|
|
@@ -630,6 +643,16 @@ declare interface CircularProgressProps extends SVGProps<SVGSVGElement> {
|
|
|
630
643
|
export { CircularProgressProps }
|
|
631
644
|
export { CircularProgressProps as CircularProgressProps_alias_1 }
|
|
632
645
|
|
|
646
|
+
/**
|
|
647
|
+
* Clears the notification state.
|
|
648
|
+
* @param dispatch The dispatch function.
|
|
649
|
+
*/
|
|
650
|
+
export declare function clearNotificationState(dispatch: Dispatch<ClearNotifyAction>): void;
|
|
651
|
+
|
|
652
|
+
export declare type ClearNotifyAction = {
|
|
653
|
+
type: 'CLEAR_NOTIFICATIONS';
|
|
654
|
+
};
|
|
655
|
+
|
|
633
656
|
declare type ClickableTagProps = HTMLAttributes<HTMLSpanElement> & {
|
|
634
657
|
/**
|
|
635
658
|
* The gradient to apply to the tag. Not available when the onClick prop is
|
|
@@ -2304,6 +2327,19 @@ declare function NotificationCenter(props: PropsWithChildren<NotificationsProvid
|
|
|
2304
2327
|
export { NotificationCenter }
|
|
2305
2328
|
export { NotificationCenter as NotificationCenter_alias_1 }
|
|
2306
2329
|
|
|
2330
|
+
/**
|
|
2331
|
+
* This module contains the reducer store and actions for the notification
|
|
2332
|
+
* center.
|
|
2333
|
+
* @module notification-center/store
|
|
2334
|
+
*/
|
|
2335
|
+
/**
|
|
2336
|
+
* The reducer for the notification center.
|
|
2337
|
+
* @param state An array of notifications.
|
|
2338
|
+
* @param action An action to take on the notifications.
|
|
2339
|
+
* @returns The new state of the notifications.
|
|
2340
|
+
*/
|
|
2341
|
+
export declare function notificationCenterReducer(state: NotificationsStore, action: AddNotifyAction | RemoveNotifyAction | UpdateNotifyAction | ClearNotifyAction): NotificationsStore;
|
|
2342
|
+
|
|
2307
2343
|
/**
|
|
2308
2344
|
* Used to render the description of a notification.
|
|
2309
2345
|
* @see https://cerberus.digitalu.design/react/notification
|
|
@@ -2332,14 +2368,26 @@ declare type NotificationHeadingProps = BaseNotificationHeadingProps & Notificat
|
|
|
2332
2368
|
export { NotificationHeadingProps }
|
|
2333
2369
|
export { NotificationHeadingProps as NotificationHeadingProps_alias_1 }
|
|
2334
2370
|
|
|
2371
|
+
export declare type NotificationOption = NotifyOptions & {
|
|
2372
|
+
state: 'open' | 'closed';
|
|
2373
|
+
};
|
|
2374
|
+
|
|
2335
2375
|
declare type NotificationProps = NotificationBaseProps & NotificationVariantProps;
|
|
2336
2376
|
export { NotificationProps }
|
|
2337
2377
|
export { NotificationProps as NotificationProps_alias_1 }
|
|
2338
2378
|
|
|
2339
|
-
declare type NotificationsProviderProps = PortalProps
|
|
2379
|
+
declare type NotificationsProviderProps = PortalProps & {
|
|
2380
|
+
/**
|
|
2381
|
+
* The duration in milliseconds to show the notification.
|
|
2382
|
+
* @default 6000
|
|
2383
|
+
*/
|
|
2384
|
+
duration?: number;
|
|
2385
|
+
};
|
|
2340
2386
|
export { NotificationsProviderProps }
|
|
2341
2387
|
export { NotificationsProviderProps as NotificationsProviderProps_alias_1 }
|
|
2342
2388
|
|
|
2389
|
+
export declare type NotificationsStore = NotificationOption[];
|
|
2390
|
+
|
|
2343
2391
|
declare interface NotificationsValue {
|
|
2344
2392
|
notify: (options: NotifyOptions) => void;
|
|
2345
2393
|
}
|
|
@@ -2607,6 +2655,20 @@ export { RangePickerInput as RangePickerInput_alias_1 }
|
|
|
2607
2655
|
|
|
2608
2656
|
export { rectIntersection }
|
|
2609
2657
|
|
|
2658
|
+
/**
|
|
2659
|
+
* Removes a notification from the notification center.
|
|
2660
|
+
* @param dispatch The dispatch function.
|
|
2661
|
+
* @param id The id of the notification to remove.
|
|
2662
|
+
*/
|
|
2663
|
+
export declare function removeNotification(dispatch: Dispatch<RemoveNotifyAction>, id: RemoveNotifyAction['payload']['id']): void;
|
|
2664
|
+
|
|
2665
|
+
export declare type RemoveNotifyAction = {
|
|
2666
|
+
type: 'REMOVE_NOTIFICATION';
|
|
2667
|
+
payload: {
|
|
2668
|
+
id: Required<NotificationOption['id']>;
|
|
2669
|
+
};
|
|
2670
|
+
};
|
|
2671
|
+
|
|
2610
2672
|
/**
|
|
2611
2673
|
* This module provides a hook to get Cerberus colors from the document root.
|
|
2612
2674
|
* @module useRootColors
|
|
@@ -3413,6 +3475,20 @@ export { TrProps as TrProps_alias_1 }
|
|
|
3413
3475
|
|
|
3414
3476
|
export { UniqueIdentifier }
|
|
3415
3477
|
|
|
3478
|
+
/**
|
|
3479
|
+
* Updates a notification in the notification center.
|
|
3480
|
+
* @param dispatch The dispatch function.
|
|
3481
|
+
* @param options The notification options.
|
|
3482
|
+
*/
|
|
3483
|
+
export declare function updateNotificationState(dispatch: Dispatch<UpdateNotifyAction>, options: UpdateNotifyAction['payload']): void;
|
|
3484
|
+
|
|
3485
|
+
export declare type UpdateNotifyAction = {
|
|
3486
|
+
type: 'UPDATE_NOTIFICATION';
|
|
3487
|
+
payload: {
|
|
3488
|
+
id: Required<NotificationOption['id']>;
|
|
3489
|
+
} & Partial<NotificationOption>;
|
|
3490
|
+
};
|
|
3491
|
+
|
|
3416
3492
|
/**
|
|
3417
3493
|
* Returns the Cerberus configuration context.
|
|
3418
3494
|
* @returns The Cerberus configuration context.
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Show
|
|
3
|
-
} from "./chunk-BUVVRQLZ.js";
|
|
4
1
|
import {
|
|
5
2
|
AccordionItemIndicator
|
|
6
3
|
} from "./chunk-XZGXRRSQ.js";
|
|
@@ -9,6 +6,9 @@ import {
|
|
|
9
6
|
AccordionItemContent,
|
|
10
7
|
AccordionItemTrigger
|
|
11
8
|
} from "./chunk-IGHMP4WA.js";
|
|
9
|
+
import {
|
|
10
|
+
Show
|
|
11
|
+
} from "./chunk-BUVVRQLZ.js";
|
|
12
12
|
|
|
13
13
|
// src/components/AccordionItemGroup.tsx
|
|
14
14
|
import { css } from "@cerberus/styled-system/css";
|
|
@@ -38,4 +38,4 @@ function AccordionItemGroup(props) {
|
|
|
38
38
|
export {
|
|
39
39
|
AccordionItemGroup
|
|
40
40
|
};
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
41
|
+
//# sourceMappingURL=chunk-BAWZBF5Q.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Portal
|
|
3
3
|
} from "./chunk-IQJDVFPP.js";
|
|
4
|
+
import {
|
|
5
|
+
IconButton
|
|
6
|
+
} from "./chunk-APD6IX5R.js";
|
|
4
7
|
import {
|
|
5
8
|
DatePickerContext,
|
|
6
9
|
DatePickerTable,
|
|
@@ -10,18 +13,15 @@ import {
|
|
|
10
13
|
DatePickerView,
|
|
11
14
|
DatePickerViewControl
|
|
12
15
|
} from "./chunk-5EWCH7AI.js";
|
|
13
|
-
import {
|
|
14
|
-
IconButton
|
|
15
|
-
} from "./chunk-APD6IX5R.js";
|
|
16
|
-
import {
|
|
17
|
-
Button
|
|
18
|
-
} from "./chunk-EXGKZGML.js";
|
|
19
16
|
import {
|
|
20
17
|
useFieldContext
|
|
21
18
|
} from "./chunk-UZDVOIW5.js";
|
|
22
19
|
import {
|
|
23
20
|
useCerberusContext
|
|
24
21
|
} from "./chunk-GITT5645.js";
|
|
22
|
+
import {
|
|
23
|
+
Button
|
|
24
|
+
} from "./chunk-EXGKZGML.js";
|
|
25
25
|
|
|
26
26
|
// src/components/DatePicker.client.tsx
|
|
27
27
|
import {
|
|
@@ -208,4 +208,4 @@ export {
|
|
|
208
208
|
DatePickerYearView,
|
|
209
209
|
DatePickerCalendar
|
|
210
210
|
};
|
|
211
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-D252JE4V.js.map
|
|
@@ -33,6 +33,7 @@ function Notification(props) {
|
|
|
33
33
|
"dialog",
|
|
34
34
|
{
|
|
35
35
|
...nativeProps,
|
|
36
|
+
"data-placement": "left",
|
|
36
37
|
className: cx(
|
|
37
38
|
nativeProps.className,
|
|
38
39
|
hstack({
|
|
@@ -74,4 +75,4 @@ function Notification(props) {
|
|
|
74
75
|
export {
|
|
75
76
|
Notification
|
|
76
77
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
78
|
+
//# sourceMappingURL=chunk-RDRD6ACD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Notification.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { hstack, vstack } from '@cerberus/styled-system/patterns'\nimport {\n notification,\n type NotificationVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport {\n useRef,\n type DialogHTMLAttributes,\n type PropsWithChildren,\n type MouseEvent,\n} from 'react'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module exports the Notification component.\n * @module\n */\n\nfunction MatchNotificationIcon(props: NotificationVariantProps) {\n const { icons } = useCerberusContext()\n const palette = (props.palette || 'info') as\n | 'info'\n | 'success'\n | 'warning'\n | 'danger'\n const key = `${palette}Notification` as keyof typeof icons\n const Icon = icons[key]\n return <Icon />\n}\n\nexport interface NotificationBaseProps\n extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'onClose'> {\n /**\n * The unique id of the notification. Required for the onClose callback.\n */\n id: string\n /**\n * Called when the close button is clicked.\n */\n onClose?: (e: MouseEvent<HTMLButtonElement>) => void\n}\nexport type NotificationProps = NotificationBaseProps & NotificationVariantProps\n\n/**\n * A static Notification component that displays a message to the user. This\n * is typically only used when not utilizing the NotificationCenter.\n * @see https://cerberus.digitalu.design/react/notification\n * @memberof module:NotificationCenter\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 const { icons } = useCerberusContext()\n const { close: CloseIcon } = icons\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 >\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 <CloseIcon />\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;AAkBE,
|
|
1
|
+
{"version":3,"sources":["../../src/components/Notification.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { hstack, vstack } from '@cerberus/styled-system/patterns'\nimport {\n notification,\n type NotificationVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport {\n useRef,\n type DialogHTMLAttributes,\n type PropsWithChildren,\n type MouseEvent,\n} from 'react'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module exports the Notification component.\n * @module\n */\n\nfunction MatchNotificationIcon(props: NotificationVariantProps) {\n const { icons } = useCerberusContext()\n const palette = (props.palette || 'info') as\n | 'info'\n | 'success'\n | 'warning'\n | 'danger'\n const key = `${palette}Notification` as keyof typeof icons\n const Icon = icons[key]\n return <Icon />\n}\n\nexport interface NotificationBaseProps\n extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'onClose'> {\n /**\n * The unique id of the notification. Required for the onClose callback.\n */\n id: string\n /**\n * Called when the close button is clicked.\n */\n onClose?: (e: MouseEvent<HTMLButtonElement>) => void\n}\nexport type NotificationProps = NotificationBaseProps & NotificationVariantProps\n\n/**\n * A static Notification component that displays a message to the user. This\n * is typically only used when not utilizing the NotificationCenter.\n * @see https://cerberus.digitalu.design/react/notification\n * @memberof module:NotificationCenter\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\n const onKeyDown = trapFocus(ref)\n const styles = notification({ palette })\n\n const { icons } = useCerberusContext()\n const { close: CloseIcon } = icons\n\n return (\n <dialog\n {...nativeProps}\n data-placement=\"left\"\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 >\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 <CloseIcon />\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;AAkBE,c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-
Avatar
|
|
12
|
-
} from "./chunk-GCQMH4QA.js";
|
|
13
10
|
import {
|
|
14
11
|
Field
|
|
15
12
|
} from "./chunk-UZDVOIW5.js";
|
|
13
|
+
import {
|
|
14
|
+
Avatar
|
|
15
|
+
} from "./chunk-GCQMH4QA.js";
|
|
16
16
|
import {
|
|
17
17
|
useCerberusContext
|
|
18
18
|
} from "./chunk-GITT5645.js";
|
|
@@ -227,4 +227,4 @@ export {
|
|
|
227
227
|
processStatus,
|
|
228
228
|
FileStatus
|
|
229
229
|
};
|
|
230
|
-
//# sourceMappingURL=chunk-
|
|
230
|
+
//# sourceMappingURL=chunk-USYM6XU6.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/context/notification-center/store.ts
|
|
2
|
+
function notificationCenterReducer(state, action) {
|
|
3
|
+
switch (action.type) {
|
|
4
|
+
case "ADD_NOTIFICATION":
|
|
5
|
+
return [...state, action.payload];
|
|
6
|
+
case "REMOVE_NOTIFICATION":
|
|
7
|
+
return state.filter((n) => n.id !== action.payload.id);
|
|
8
|
+
case "UPDATE_NOTIFICATION":
|
|
9
|
+
return state.map(
|
|
10
|
+
(n) => n.id === action.payload.id ? { ...n, ...action.payload } : n
|
|
11
|
+
);
|
|
12
|
+
case "CLEAR_NOTIFICATIONS":
|
|
13
|
+
return [];
|
|
14
|
+
default:
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function addNotification(dispatch, options) {
|
|
19
|
+
dispatch({ type: "ADD_NOTIFICATION", payload: { ...options } });
|
|
20
|
+
}
|
|
21
|
+
function removeNotification(dispatch, id) {
|
|
22
|
+
dispatch({ type: "REMOVE_NOTIFICATION", payload: { id } });
|
|
23
|
+
}
|
|
24
|
+
function updateNotificationState(dispatch, options) {
|
|
25
|
+
dispatch({ type: "UPDATE_NOTIFICATION", payload: { ...options } });
|
|
26
|
+
}
|
|
27
|
+
function clearNotificationState(dispatch) {
|
|
28
|
+
dispatch({ type: "CLEAR_NOTIFICATIONS" });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
notificationCenterReducer,
|
|
33
|
+
addNotification,
|
|
34
|
+
removeNotification,
|
|
35
|
+
updateNotificationState,
|
|
36
|
+
clearNotificationState
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-V3M3ZOQI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/notification-center/store.ts"],"sourcesContent":["import type { Dispatch } from 'react'\nimport type {\n AddNotifyAction,\n ClearNotifyAction,\n NotificationsStore,\n RemoveNotifyAction,\n UpdateNotifyAction,\n} from './types'\n\n/**\n * This module contains the reducer store and actions for the notification\n * center.\n * @module notification-center/store\n */\n\n/**\n * The reducer for the notification center.\n * @param state An array of notifications.\n * @param action An action to take on the notifications.\n * @returns The new state of the notifications.\n */\nexport function notificationCenterReducer(\n state: NotificationsStore,\n action:\n | AddNotifyAction\n | RemoveNotifyAction\n | UpdateNotifyAction\n | ClearNotifyAction,\n): NotificationsStore {\n switch (action.type) {\n case 'ADD_NOTIFICATION':\n return [...state, action.payload]\n case 'REMOVE_NOTIFICATION':\n return state.filter((n) => n.id !== action.payload.id)\n case 'UPDATE_NOTIFICATION':\n return state.map((n) =>\n n.id === action.payload.id ? { ...n, ...action.payload } : n,\n )\n case 'CLEAR_NOTIFICATIONS':\n return []\n default:\n return state\n }\n}\n\n/**\n * Adds a notification to the notification center.\n * @param dispatch The dispatch function.\n * @param options The notification options.\n */\nexport function addNotification(\n dispatch: Dispatch<AddNotifyAction>,\n options: AddNotifyAction['payload'],\n) {\n dispatch({ type: 'ADD_NOTIFICATION', payload: { ...options } })\n}\n\n/**\n * Removes a notification from the notification center.\n * @param dispatch The dispatch function.\n * @param id The id of the notification to remove.\n */\nexport function removeNotification(\n dispatch: Dispatch<RemoveNotifyAction>,\n id: RemoveNotifyAction['payload']['id'],\n) {\n dispatch({ type: 'REMOVE_NOTIFICATION', payload: { id } })\n}\n\n/**\n * Updates a notification in the notification center.\n * @param dispatch The dispatch function.\n * @param options The notification options.\n */\nexport function updateNotificationState(\n dispatch: Dispatch<UpdateNotifyAction>,\n options: UpdateNotifyAction['payload'],\n) {\n dispatch({ type: 'UPDATE_NOTIFICATION', payload: { ...options } })\n}\n\n/**\n * Clears the notification state.\n * @param dispatch The dispatch function.\n */\nexport function clearNotificationState(dispatch: Dispatch<ClearNotifyAction>) {\n dispatch({ type: 'CLEAR_NOTIFICATIONS' })\n}\n"],"mappings":";AAqBO,SAAS,0BACd,OACA,QAKoB;AACpB,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO,CAAC,GAAG,OAAO,OAAO,OAAO;AAAA,IAClC,KAAK;AACH,aAAO,MAAM,OAAO,CAAC,MAAM,EAAE,OAAO,OAAO,QAAQ,EAAE;AAAA,IACvD,KAAK;AACH,aAAO,MAAM;AAAA,QAAI,CAAC,MAChB,EAAE,OAAO,OAAO,QAAQ,KAAK,EAAE,GAAG,GAAG,GAAG,OAAO,QAAQ,IAAI;AAAA,MAC7D;AAAA,IACF,KAAK;AACH,aAAO,CAAC;AAAA,IACV;AACE,aAAO;AAAA,EACX;AACF;AAOO,SAAS,gBACd,UACA,SACA;AACA,WAAS,EAAE,MAAM,oBAAoB,SAAS,EAAE,GAAG,QAAQ,EAAE,CAAC;AAChE;AAOO,SAAS,mBACd,UACA,IACA;AACA,WAAS,EAAE,MAAM,uBAAuB,SAAS,EAAE,GAAG,EAAE,CAAC;AAC3D;AAOO,SAAS,wBACd,UACA,SACA;AACA,WAAS,EAAE,MAAM,uBAAuB,SAAS,EAAE,GAAG,QAAQ,EAAE,CAAC;AACnE;AAMO,SAAS,uBAAuB,UAAuC;AAC5E,WAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1C;","names":[]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ModalHeader
|
|
3
|
-
} from "./chunk-XY6WL55R.js";
|
|
4
|
-
import {
|
|
5
|
-
ModalHeading
|
|
6
|
-
} from "./chunk-2UXE5PDG.js";
|
|
7
1
|
import {
|
|
8
2
|
Modal
|
|
9
3
|
} from "./chunk-BE4EOU2P.js";
|
|
10
4
|
import {
|
|
11
5
|
ModalDescription
|
|
12
6
|
} from "./chunk-Q7BRMIBR.js";
|
|
7
|
+
import {
|
|
8
|
+
ModalHeader
|
|
9
|
+
} from "./chunk-XY6WL55R.js";
|
|
10
|
+
import {
|
|
11
|
+
ModalHeading
|
|
12
|
+
} from "./chunk-2UXE5PDG.js";
|
|
13
13
|
import {
|
|
14
14
|
Portal
|
|
15
15
|
} from "./chunk-IQJDVFPP.js";
|
|
@@ -19,18 +19,18 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
Avatar
|
|
21
21
|
} from "./chunk-GCQMH4QA.js";
|
|
22
|
-
import {
|
|
23
|
-
Button
|
|
24
|
-
} from "./chunk-EXGKZGML.js";
|
|
25
22
|
import {
|
|
26
23
|
Show
|
|
27
24
|
} from "./chunk-BUVVRQLZ.js";
|
|
28
|
-
import {
|
|
29
|
-
useModal
|
|
30
|
-
} from "./chunk-KGQG5JGW.js";
|
|
31
25
|
import {
|
|
32
26
|
useCerberusContext
|
|
33
27
|
} from "./chunk-GITT5645.js";
|
|
28
|
+
import {
|
|
29
|
+
Button
|
|
30
|
+
} from "./chunk-EXGKZGML.js";
|
|
31
|
+
import {
|
|
32
|
+
useModal
|
|
33
|
+
} from "./chunk-KGQG5JGW.js";
|
|
34
34
|
import {
|
|
35
35
|
trapFocus
|
|
36
36
|
} from "./chunk-JIZQFTW6.js";
|
|
@@ -151,4 +151,4 @@ export {
|
|
|
151
151
|
CTAModal,
|
|
152
152
|
useCTAModal
|
|
153
153
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
//# sourceMappingURL=chunk-XDDLXEFV.js.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ModalHeader
|
|
3
|
-
} from "./chunk-XY6WL55R.js";
|
|
4
|
-
import {
|
|
5
|
-
ModalHeading
|
|
6
|
-
} from "./chunk-2UXE5PDG.js";
|
|
7
1
|
import {
|
|
8
2
|
Modal
|
|
9
3
|
} from "./chunk-BE4EOU2P.js";
|
|
10
4
|
import {
|
|
11
5
|
ModalDescription
|
|
12
6
|
} from "./chunk-Q7BRMIBR.js";
|
|
7
|
+
import {
|
|
8
|
+
ModalHeader
|
|
9
|
+
} from "./chunk-XY6WL55R.js";
|
|
10
|
+
import {
|
|
11
|
+
ModalHeading
|
|
12
|
+
} from "./chunk-2UXE5PDG.js";
|
|
13
13
|
import {
|
|
14
14
|
Portal
|
|
15
15
|
} from "./chunk-IQJDVFPP.js";
|
|
16
16
|
import {
|
|
17
17
|
Avatar
|
|
18
18
|
} from "./chunk-GCQMH4QA.js";
|
|
19
|
-
import {
|
|
20
|
-
Button
|
|
21
|
-
} from "./chunk-EXGKZGML.js";
|
|
22
19
|
import {
|
|
23
20
|
Show
|
|
24
21
|
} from "./chunk-BUVVRQLZ.js";
|
|
25
|
-
import {
|
|
26
|
-
useModal
|
|
27
|
-
} from "./chunk-KGQG5JGW.js";
|
|
28
22
|
import {
|
|
29
23
|
useCerberusContext
|
|
30
24
|
} from "./chunk-GITT5645.js";
|
|
25
|
+
import {
|
|
26
|
+
Button
|
|
27
|
+
} from "./chunk-EXGKZGML.js";
|
|
28
|
+
import {
|
|
29
|
+
useModal
|
|
30
|
+
} from "./chunk-KGQG5JGW.js";
|
|
31
31
|
import {
|
|
32
32
|
trapFocus
|
|
33
33
|
} from "./chunk-JIZQFTW6.js";
|
|
@@ -171,4 +171,4 @@ export {
|
|
|
171
171
|
ConfirmModal,
|
|
172
172
|
useConfirmModal
|
|
173
173
|
};
|
|
174
|
-
//# sourceMappingURL=chunk-
|
|
174
|
+
//# sourceMappingURL=chunk-YJI4Y7BH.js.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NotificationDescription
|
|
3
|
+
} from "./chunk-UXY3KCC3.js";
|
|
4
|
+
import {
|
|
5
|
+
NotificationHeading
|
|
6
|
+
} from "./chunk-SLHYBPJ5.js";
|
|
7
|
+
import {
|
|
8
|
+
Notification
|
|
9
|
+
} from "./chunk-RDRD6ACD.js";
|
|
10
|
+
import {
|
|
11
|
+
Portal
|
|
12
|
+
} from "./chunk-IQJDVFPP.js";
|
|
13
|
+
import {
|
|
14
|
+
Show
|
|
15
|
+
} from "./chunk-BUVVRQLZ.js";
|
|
16
|
+
import {
|
|
17
|
+
Button
|
|
18
|
+
} from "./chunk-EXGKZGML.js";
|
|
19
|
+
import {
|
|
20
|
+
addNotification,
|
|
21
|
+
clearNotificationState,
|
|
22
|
+
notificationCenterReducer,
|
|
23
|
+
removeNotification,
|
|
24
|
+
updateNotificationState
|
|
25
|
+
} from "./chunk-V3M3ZOQI.js";
|
|
26
|
+
|
|
27
|
+
// src/context/notification-center.tsx
|
|
28
|
+
import {
|
|
29
|
+
createContext,
|
|
30
|
+
useCallback,
|
|
31
|
+
useContext,
|
|
32
|
+
useMemo,
|
|
33
|
+
useReducer
|
|
34
|
+
} from "react";
|
|
35
|
+
import { animateIn, vstack } from "@cerberus/styled-system/patterns";
|
|
36
|
+
import { notification } from "@cerberus/styled-system/recipes";
|
|
37
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
38
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
39
|
+
var NotificationsContext = createContext(null);
|
|
40
|
+
function NotificationCenter(props) {
|
|
41
|
+
const [state, dispatch] = useReducer(notificationCenterReducer, []);
|
|
42
|
+
const styles = notification();
|
|
43
|
+
const timeout = useMemo(
|
|
44
|
+
() => props.duration || 6e3,
|
|
45
|
+
[props.duration]
|
|
46
|
+
);
|
|
47
|
+
const closeNotification = useCallback(
|
|
48
|
+
(id) => {
|
|
49
|
+
updateNotificationState(dispatch, {
|
|
50
|
+
id,
|
|
51
|
+
state: "closed"
|
|
52
|
+
});
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
removeNotification(dispatch, id);
|
|
55
|
+
}, 150);
|
|
56
|
+
},
|
|
57
|
+
[dispatch]
|
|
58
|
+
);
|
|
59
|
+
const handleNotify = useCallback(
|
|
60
|
+
(options) => {
|
|
61
|
+
const id = `${options.palette}:${state.length + 1}`;
|
|
62
|
+
addNotification(dispatch, {
|
|
63
|
+
...options,
|
|
64
|
+
id,
|
|
65
|
+
state: "open"
|
|
66
|
+
});
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
closeNotification(id);
|
|
69
|
+
}, timeout);
|
|
70
|
+
},
|
|
71
|
+
[dispatch, state, timeout, closeNotification]
|
|
72
|
+
);
|
|
73
|
+
const handleClose = useCallback(
|
|
74
|
+
(e) => {
|
|
75
|
+
const target = e.currentTarget;
|
|
76
|
+
closeNotification(target.value);
|
|
77
|
+
},
|
|
78
|
+
[closeNotification]
|
|
79
|
+
);
|
|
80
|
+
const handleCloseAll = useCallback(() => {
|
|
81
|
+
state.forEach((item) => {
|
|
82
|
+
if (item.onClose) item.onClose();
|
|
83
|
+
});
|
|
84
|
+
clearNotificationState(dispatch);
|
|
85
|
+
}, [state, dispatch]);
|
|
86
|
+
const value = useMemo(
|
|
87
|
+
() => ({
|
|
88
|
+
notify: handleNotify
|
|
89
|
+
}),
|
|
90
|
+
[handleNotify]
|
|
91
|
+
);
|
|
92
|
+
return /* @__PURE__ */ jsxs(NotificationsContext.Provider, { value, children: [
|
|
93
|
+
props.children,
|
|
94
|
+
/* @__PURE__ */ jsx(Show, { when: state.length > 0, children: /* @__PURE__ */ jsx(Portal, { container: props.container, children: /* @__PURE__ */ jsxs("div", { className: styles.center, children: [
|
|
95
|
+
/* @__PURE__ */ jsx(Show, { when: state.length >= 4, children: /* @__PURE__ */ jsx(
|
|
96
|
+
Button,
|
|
97
|
+
{
|
|
98
|
+
className: cx(styles.closeAll, animateIn()),
|
|
99
|
+
onClick: handleCloseAll,
|
|
100
|
+
palette: "action",
|
|
101
|
+
shape: "rounded",
|
|
102
|
+
size: "sm",
|
|
103
|
+
usage: "ghost",
|
|
104
|
+
children: "Close all"
|
|
105
|
+
}
|
|
106
|
+
) }),
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: vstack({
|
|
111
|
+
alignItems: "flex-end",
|
|
112
|
+
gap: "4"
|
|
113
|
+
}),
|
|
114
|
+
style: {
|
|
115
|
+
alignItems: "flex-end"
|
|
116
|
+
},
|
|
117
|
+
children: state.map((option) => /* @__PURE__ */ jsx(
|
|
118
|
+
MatchNotification,
|
|
119
|
+
{
|
|
120
|
+
...option,
|
|
121
|
+
onClose: handleClose,
|
|
122
|
+
open: option.state
|
|
123
|
+
},
|
|
124
|
+
option.id
|
|
125
|
+
))
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
] }) }) })
|
|
129
|
+
] });
|
|
130
|
+
}
|
|
131
|
+
function MatchNotification(props) {
|
|
132
|
+
const { palette, id, onClose, heading, description, open } = props;
|
|
133
|
+
const sharedProps = useMemo(
|
|
134
|
+
() => ({
|
|
135
|
+
id,
|
|
136
|
+
open: true,
|
|
137
|
+
onClose,
|
|
138
|
+
"data-state": open
|
|
139
|
+
}),
|
|
140
|
+
[id, open, onClose]
|
|
141
|
+
);
|
|
142
|
+
switch (palette) {
|
|
143
|
+
case "success":
|
|
144
|
+
return /* @__PURE__ */ jsxs(Notification, { ...sharedProps, palette: "success", children: [
|
|
145
|
+
/* @__PURE__ */ jsx(NotificationHeading, { palette: "success", children: heading }),
|
|
146
|
+
/* @__PURE__ */ jsx(NotificationDescription, { palette: "success", children: description })
|
|
147
|
+
] });
|
|
148
|
+
case "warning":
|
|
149
|
+
return /* @__PURE__ */ jsxs(Notification, { ...sharedProps, palette: "warning", children: [
|
|
150
|
+
/* @__PURE__ */ jsx(NotificationHeading, { palette: "warning", children: heading }),
|
|
151
|
+
/* @__PURE__ */ jsx(NotificationDescription, { palette: "warning", children: description })
|
|
152
|
+
] });
|
|
153
|
+
case "danger":
|
|
154
|
+
return /* @__PURE__ */ jsxs(Notification, { ...sharedProps, palette: "danger", children: [
|
|
155
|
+
/* @__PURE__ */ jsx(NotificationHeading, { palette: "danger", children: heading }),
|
|
156
|
+
/* @__PURE__ */ jsx(NotificationDescription, { palette: "danger", children: description })
|
|
157
|
+
] });
|
|
158
|
+
case "info":
|
|
159
|
+
default:
|
|
160
|
+
return /* @__PURE__ */ jsxs(Notification, { ...sharedProps, palette: "info", children: [
|
|
161
|
+
/* @__PURE__ */ jsx(NotificationHeading, { palette: "info", children: heading }),
|
|
162
|
+
/* @__PURE__ */ jsx(NotificationDescription, { palette: "info", children: description })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function useNotificationCenter() {
|
|
167
|
+
const context = useContext(NotificationsContext);
|
|
168
|
+
if (!context) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
"useNotificationCenter must be used within a NotificationsProvider"
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return context;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export {
|
|
177
|
+
NotificationCenter,
|
|
178
|
+
useNotificationCenter
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=chunk-YLMGZAKU.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 useReducer,\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/styled-system/patterns'\nimport { Portal, type PortalProps } from '../components/Portal'\nimport { notification } from '@cerberus/styled-system/recipes'\nimport { Button } from '../components/Button'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n addNotification,\n clearNotificationState,\n notificationCenterReducer,\n removeNotification,\n updateNotificationState,\n} from './notification-center/store'\n\n/**\n * This module provides a context and hook for notifications.\n * @module\n */\n\nexport interface NotifyOptions {\n /**\n * The palette of the notification.\n * @default 'info'\n */\n palette: 'info' | 'success' | 'warning' | 'danger'\n /**\n * The heading of the notification.\n */\n heading: string\n /**\n * The unique id of the notification.\n */\n id?: string\n /**\n * The description of the notification.\n */\n description?: ReactNode\n /**\n * The action to take when the notification is closed\n */\n onClose?: () => void\n}\n\nexport interface NotificationsValue {\n notify: (options: NotifyOptions) => void\n}\n\nconst NotificationsContext = createContext<NotificationsValue | null>(null)\n\nexport type NotificationsProviderProps = PortalProps & {\n /**\n * The duration in milliseconds to show the notification.\n * @default 6000\n */\n duration?: number\n}\n\n/**\n * Provides a notification center to the app.\n * @see https://cerberus.digitalu.design/react/notification\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 [state, dispatch] = useReducer(notificationCenterReducer, [])\n const styles = notification()\n\n const timeout = useMemo<number>(\n () => props.duration || 6000,\n [props.duration],\n )\n\n const closeNotification = useCallback(\n (id: string) => {\n updateNotificationState(dispatch, {\n id,\n state: 'closed',\n })\n setTimeout(() => {\n removeNotification(dispatch, id)\n }, 150)\n },\n [dispatch],\n )\n\n const handleNotify = useCallback(\n (options: NotifyOptions) => {\n const id = `${options.palette}:${state.length + 1}`\n addNotification(dispatch, {\n ...options,\n id,\n state: 'open',\n })\n\n setTimeout(() => {\n closeNotification(id)\n }, timeout)\n },\n [dispatch, state, timeout, closeNotification],\n )\n\n const handleClose = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n closeNotification(target.value)\n },\n [closeNotification],\n )\n\n const handleCloseAll = useCallback(() => {\n state.forEach((item) => {\n if (item.onClose) item.onClose()\n })\n // we don't want to animate out for this one\n clearNotificationState(dispatch)\n }, [state, dispatch])\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={state.length > 0}>\n <Portal container={props.container}>\n <div className={styles.center}>\n <Show when={state.length >= 4}>\n <Button\n className={cx(styles.closeAll, animateIn())}\n onClick={handleCloseAll}\n palette=\"action\"\n shape=\"rounded\"\n size=\"sm\"\n usage=\"ghost\"\n >\n Close all\n </Button>\n </Show>\n\n <div\n className={vstack({\n alignItems: 'flex-end',\n gap: '4',\n })}\n style={{\n alignItems: 'flex-end',\n }}\n >\n {state.map((option) => (\n <MatchNotification\n key={option.id}\n {...option}\n onClose={handleClose}\n open={option.state}\n />\n ))}\n </div>\n </div>\n </Portal>\n </Show>\n </NotificationsContext.Provider>\n )\n}\n\ninterface MatchNotificationProps extends Omit<NotifyOptions, 'onClose'> {\n open: 'open' | 'closed'\n onClose: (e: MouseEvent<HTMLButtonElement>) => void\n key: string | undefined\n}\n\nfunction MatchNotification(props: MatchNotificationProps) {\n const { palette, id, onClose, heading, description, open } = props\n const sharedProps = useMemo(\n () => ({\n id: id!,\n open: true,\n onClose,\n 'data-state': open,\n }),\n [id, open, onClose],\n )\n\n switch (palette) {\n case 'success':\n return (\n <Notification {...sharedProps} palette=\"success\">\n <NotificationHeading palette=\"success\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"success\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'warning':\n return (\n <Notification {...sharedProps} palette=\"warning\">\n <NotificationHeading palette=\"warning\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"warning\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'danger':\n return (\n <Notification {...sharedProps} palette=\"danger\">\n <NotificationHeading palette=\"danger\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"danger\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'info':\n default:\n return (\n <Notification {...sharedProps} palette=\"info\">\n <NotificationHeading palette=\"info\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"info\">\n {description}\n </NotificationDescription>\n </Notification>\n )\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;AAkJT,SAEI,KAFJ;AAxGV,IAAM,uBAAuB,cAAyC,IAAI;AAgCnE,SAAS,mBACd,OACA;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,WAAW,2BAA2B,CAAC,CAAC;AAClE,QAAM,SAAS,aAAa;AAE5B,QAAM,UAAU;AAAA,IACd,MAAM,MAAM,YAAY;AAAA,IACxB,CAAC,MAAM,QAAQ;AAAA,EACjB;AAEA,QAAM,oBAAoB;AAAA,IACxB,CAAC,OAAe;AACd,8BAAwB,UAAU;AAAA,QAChC;AAAA,QACA,OAAO;AAAA,MACT,CAAC;AACD,iBAAW,MAAM;AACf,2BAAmB,UAAU,EAAE;AAAA,MACjC,GAAG,GAAG;AAAA,IACR;AAAA,IACA,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B,uBACH;AAAA,SACF;AAAA,EAEN;AACF;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":[]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Modal
|
|
3
|
+
} from "./chunk-BE4EOU2P.js";
|
|
4
|
+
import {
|
|
5
|
+
ModalDescription
|
|
6
|
+
} from "./chunk-Q7BRMIBR.js";
|
|
1
7
|
import {
|
|
2
8
|
ModalHeader
|
|
3
9
|
} from "./chunk-XY6WL55R.js";
|
|
@@ -10,33 +16,27 @@ import {
|
|
|
10
16
|
import {
|
|
11
17
|
Label
|
|
12
18
|
} from "./chunk-NMF2HYWO.js";
|
|
13
|
-
import {
|
|
14
|
-
Modal
|
|
15
|
-
} from "./chunk-BE4EOU2P.js";
|
|
16
|
-
import {
|
|
17
|
-
ModalDescription
|
|
18
|
-
} from "./chunk-Q7BRMIBR.js";
|
|
19
19
|
import {
|
|
20
20
|
Portal
|
|
21
21
|
} from "./chunk-IQJDVFPP.js";
|
|
22
|
-
import {
|
|
23
|
-
Avatar
|
|
24
|
-
} from "./chunk-GCQMH4QA.js";
|
|
25
|
-
import {
|
|
26
|
-
Button
|
|
27
|
-
} from "./chunk-EXGKZGML.js";
|
|
28
22
|
import {
|
|
29
23
|
Field
|
|
30
24
|
} from "./chunk-UZDVOIW5.js";
|
|
25
|
+
import {
|
|
26
|
+
Avatar
|
|
27
|
+
} from "./chunk-GCQMH4QA.js";
|
|
31
28
|
import {
|
|
32
29
|
Show
|
|
33
30
|
} from "./chunk-BUVVRQLZ.js";
|
|
34
|
-
import {
|
|
35
|
-
useModal
|
|
36
|
-
} from "./chunk-KGQG5JGW.js";
|
|
37
31
|
import {
|
|
38
32
|
useCerberusContext
|
|
39
33
|
} from "./chunk-GITT5645.js";
|
|
34
|
+
import {
|
|
35
|
+
Button
|
|
36
|
+
} from "./chunk-EXGKZGML.js";
|
|
37
|
+
import {
|
|
38
|
+
useModal
|
|
39
|
+
} from "./chunk-KGQG5JGW.js";
|
|
40
40
|
import {
|
|
41
41
|
trapFocus
|
|
42
42
|
} from "./chunk-JIZQFTW6.js";
|
|
@@ -241,4 +241,4 @@ export {
|
|
|
241
241
|
PromptModal,
|
|
242
242
|
usePromptModal
|
|
243
243
|
};
|
|
244
|
-
//# sourceMappingURL=chunk-
|
|
244
|
+
//# sourceMappingURL=chunk-ZHBHPMTP.js.map
|