@ttt-productions/notification-core 0.13.0 → 0.14.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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react/components/NotificationHistoryList.d.ts +9 -0
- package/dist/react/components/NotificationHistoryList.d.ts.map +1 -0
- package/dist/react/components/NotificationHistoryList.js +41 -0
- package/dist/react/components/NotificationHistoryList.js.map +1 -0
- package/dist/react/components/NotificationList.d.ts +1 -1
- package/dist/react/components/NotificationList.d.ts.map +1 -1
- package/dist/react/components/NotificationList.js +2 -2
- package/dist/react/components/NotificationList.js.map +1 -1
- package/dist/react/components/index.d.ts +1 -0
- package/dist/react/components/index.d.ts.map +1 -1
- package/dist/react/components/index.js +1 -0
- package/dist/react/components/index.js.map +1 -1
- package/dist/react/hooks/index.d.ts +1 -0
- package/dist/react/hooks/index.d.ts.map +1 -1
- package/dist/react/hooks/index.js +1 -0
- package/dist/react/hooks/index.js.map +1 -1
- package/dist/react/hooks/useNotificationHistory.d.ts +17 -0
- package/dist/react/hooks/useNotificationHistory.d.ts.map +1 -0
- package/dist/react/hooks/useNotificationHistory.js +46 -0
- package/dist/react/hooks/useNotificationHistory.js.map +1 -0
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/styles/notifications.css +8 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { NotificationDoc, PendingNotification, NotificationCategoryConfig, NotificationTypeConfig, NotificationSystemConfig, UseActiveNotificationsOptions, UseUnreadCountOptions, UseArchiveNotificationOptions, UseArchiveAllNotificationsOptions, ArchiveAllJobStatus, EnqueueArchiveAllResult, ArchiveAllJobSnapshot, ArchiveAllPollResult, NotificationListProps, NotificationEmptyStateProps, NotificationUnreadBadgeProps, } from './types.js';
|
|
1
|
+
export type { NotificationDoc, PendingNotification, NotificationCategoryConfig, NotificationTypeConfig, NotificationSystemConfig, UseActiveNotificationsOptions, UseNotificationHistoryOptions, NotificationHistoryItem, UseUnreadCountOptions, UseArchiveNotificationOptions, UseArchiveAllNotificationsOptions, ArchiveAllJobStatus, EnqueueArchiveAllResult, ArchiveAllJobSnapshot, ArchiveAllPollResult, NotificationListProps, NotificationHistoryListProps, NotificationEmptyStateProps, NotificationUnreadBadgeProps, } from './types.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,6BAA6B,EAC7B,qBAAqB,EACrB,6BAA6B,EAC7B,iCAAiC,EACjC,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,iCAAiC,EACjC,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NotificationHistoryListProps } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Read-only, paginated list of ARCHIVED notifications (the history tier). Rows do
|
|
4
|
+
* not mutate state on click — archive is one-way; there is no re-archive. When
|
|
5
|
+
* `onNotificationClick` is supplied, rows are interactive (e.g. navigate to
|
|
6
|
+
* `targetPath`); otherwise they render non-interactive.
|
|
7
|
+
*/
|
|
8
|
+
export declare function NotificationHistoryList({ config, userId, category, onNotificationClick, pageSize, staleTime, emptyText, renderRowAction, }: NotificationHistoryListProps): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=NotificationHistoryList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationHistoryList.d.ts","sourceRoot":"","sources":["../../../src/react/components/NotificationHistoryList.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAA2B,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAE5F;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACT,SAAS,EACT,eAAe,GAChB,EAAE,4BAA4B,+BAuF9B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { Badge, Button } from '@ttt-productions/ui-core/react';
|
|
5
|
+
import { useNotificationHistory } from '../hooks/useNotificationHistory.js';
|
|
6
|
+
import { NotificationEmptyState } from './NotificationEmptyState.js';
|
|
7
|
+
import { formatRelativeTime } from './relative-time.js';
|
|
8
|
+
/**
|
|
9
|
+
* Read-only, paginated list of ARCHIVED notifications (the history tier). Rows do
|
|
10
|
+
* not mutate state on click — archive is one-way; there is no re-archive. When
|
|
11
|
+
* `onNotificationClick` is supplied, rows are interactive (e.g. navigate to
|
|
12
|
+
* `targetPath`); otherwise they render non-interactive.
|
|
13
|
+
*/
|
|
14
|
+
export function NotificationHistoryList({ config, userId, category, onNotificationClick, pageSize, staleTime, emptyText, renderRowAction, }) {
|
|
15
|
+
const { data: notifications, isLoading, hasNextPage, nextPage, } = useNotificationHistory({
|
|
16
|
+
config,
|
|
17
|
+
userId,
|
|
18
|
+
category,
|
|
19
|
+
pageSize,
|
|
20
|
+
staleTime,
|
|
21
|
+
});
|
|
22
|
+
const getTypeIcon = useCallback((type) => config.types[type]?.icon ?? '🔔', [config]);
|
|
23
|
+
const interactive = typeof onNotificationClick === 'function';
|
|
24
|
+
return (_jsx("div", { className: "ntf-list ntf-list-history", children: _jsx("div", { className: "ntf-list-body", children: isLoading ? (_jsx("div", { className: "ntf-loading", children: "Loading..." })) : !notifications || notifications.length === 0 ? (_jsx(NotificationEmptyState, { text: emptyText })) : (_jsxs(_Fragment, { children: [notifications.map((notification) => {
|
|
25
|
+
const interactiveProps = interactive
|
|
26
|
+
? {
|
|
27
|
+
role: 'button',
|
|
28
|
+
tabIndex: 0,
|
|
29
|
+
onClick: () => onNotificationClick?.(notification),
|
|
30
|
+
onKeyDown: (e) => {
|
|
31
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
onNotificationClick?.(notification);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
: {};
|
|
38
|
+
return (_jsxs("div", { className: "ntf-item ntf-item-archived", ...interactiveProps, children: [_jsx("div", { className: "ntf-item-icon", children: getTypeIcon(notification.type) }), _jsxs("div", { className: "ntf-item-content", children: [_jsx("div", { className: "ntf-item-title", children: notification.title }), _jsx("div", { className: "ntf-item-message", children: notification.message }), _jsx("div", { className: "ntf-item-timestamp", children: formatRelativeTime(notification.archivedAt) })] }), notification.count > 1 && (_jsx("div", { className: "ntf-item-count", children: _jsxs(Badge, { variant: "secondary", children: ["\u00D7", notification.count] }) })), renderRowAction && (_jsx("div", { className: "ntf-item-row-action", onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), children: renderRowAction(notification) }))] }, notification.archiveOccurrenceId));
|
|
39
|
+
}), hasNextPage && (_jsx("div", { className: "ntf-list-footer", children: _jsx(Button, { variant: "ghost", size: "sm", onClick: nextPage, children: "Load more" }) }))] })) }) }));
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=NotificationHistoryList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationHistoryList.js","sourceRoot":"","sources":["../../../src/react/components/NotificationHistoryList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACT,SAAS,EACT,eAAe,GACc;IAC7B,MAAM,EACJ,IAAI,EAAE,aAAa,EACnB,SAAS,EACT,WAAW,EACX,QAAQ,GACT,GAAG,sBAAsB,CAAC;QACzB,MAAM;QACN,MAAM;QACN,QAAQ;QACR,QAAQ;QACR,SAAS;KACV,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,IAAI,EAClD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,WAAW,GAAG,OAAO,mBAAmB,KAAK,UAAU,CAAC;IAE9D,OAAO,CACL,cAAK,SAAS,EAAC,2BAA2B,YAC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AgB,YAC7B,MAAC,KAAK,IAAC,OAAO,EAAC,WAAW,uBAAG,YAAY,CAAC,KAAK,IAAS,GACpD,CACP,EACA,eAAe,IAAI,CAClB,cACE,SAAS,EAAC,qBAAqB,EAC/B,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EACnC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,YAEpC,eAAe,CAAC,YAAY,CAAC,GAC1B,CACP,KAzBI,YAAY,CAAC,mBAAmB,CA0BjC,CACP,CAAC;oBACJ,CAAC,CAAC,EACD,WAAW,IAAI,CACd,cAAK,SAAS,EAAC,iBAAiB,YAC9B,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,QAAQ,0BAE1C,GACL,CACP,IACA,CACJ,GACG,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -2,5 +2,5 @@ import type { NotificationListProps } from '../../types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Scrollable list of active notifications with click-to-archive and clear-all.
|
|
4
4
|
*/
|
|
5
|
-
export declare function NotificationList({ config, userId, category, onNotificationClick, archiveFn, enqueueArchiveAllFn, getArchiveAllStatusFn, onClearAll, refetchInterval, emptyText, }: NotificationListProps): import("react").JSX.Element;
|
|
5
|
+
export declare function NotificationList({ config, userId, category, onNotificationClick, archiveFn, enqueueArchiveAllFn, getArchiveAllStatusFn, onClearAll, refetchInterval, emptyText, renderRowAction, }: NotificationListProps): import("react").JSX.Element;
|
|
6
6
|
//# sourceMappingURL=NotificationList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationList.d.ts","sourceRoot":"","sources":["../../../src/react/components/NotificationList.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAmB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,SAAS,
|
|
1
|
+
{"version":3,"file":"NotificationList.d.ts","sourceRoot":"","sources":["../../../src/react/components/NotificationList.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAmB,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,SAAS,EACT,eAAe,GAChB,EAAE,qBAAqB,+BAwJvB"}
|
|
@@ -10,7 +10,7 @@ import { formatRelativeTime } from './relative-time.js';
|
|
|
10
10
|
/**
|
|
11
11
|
* Scrollable list of active notifications with click-to-archive and clear-all.
|
|
12
12
|
*/
|
|
13
|
-
export function NotificationList({ config, userId, category, onNotificationClick, archiveFn, enqueueArchiveAllFn, getArchiveAllStatusFn, onClearAll, refetchInterval, emptyText, }) {
|
|
13
|
+
export function NotificationList({ config, userId, category, onNotificationClick, archiveFn, enqueueArchiveAllFn, getArchiveAllStatusFn, onClearAll, refetchInterval, emptyText, renderRowAction, }) {
|
|
14
14
|
const { data: notifications, isLoading, hasNextPage, nextPage, } = useActiveNotifications({
|
|
15
15
|
config,
|
|
16
16
|
userId,
|
|
@@ -72,6 +72,6 @@ export function NotificationList({ config, userId, category, onNotificationClick
|
|
|
72
72
|
e.preventDefault();
|
|
73
73
|
handleNotificationClick(notification);
|
|
74
74
|
}
|
|
75
|
-
}, children: [_jsx("div", { className: "ntf-item-icon", children: getTypeIcon(notification.type) }), _jsxs("div", { className: "ntf-item-content", children: [_jsx("div", { className: "ntf-item-title", children: notification.title }), _jsx("div", { className: "ntf-item-message", children: notification.message }), _jsx("div", { className: "ntf-item-timestamp", children: formatRelativeTime(notification.updatedAt) })] }), notification.count > 1 && (_jsx("div", { className: "ntf-item-count", children: _jsxs(Badge, { variant: "secondary", children: ["\u00D7", notification.count] }) }))] }, notification.id))), hasNextPage && (_jsx("div", { className: "ntf-list-footer", children: _jsx(Button, { variant: "ghost", size: "sm", onClick: nextPage, children: "Load more" }) }))] })) })] }));
|
|
75
|
+
}, children: [_jsx("div", { className: "ntf-item-icon", children: getTypeIcon(notification.type) }), _jsxs("div", { className: "ntf-item-content", children: [_jsx("div", { className: "ntf-item-title", children: notification.title }), _jsx("div", { className: "ntf-item-message", children: notification.message }), _jsx("div", { className: "ntf-item-timestamp", children: formatRelativeTime(notification.updatedAt) })] }), notification.count > 1 && (_jsx("div", { className: "ntf-item-count", children: _jsxs(Badge, { variant: "secondary", children: ["\u00D7", notification.count] }) })), renderRowAction && (_jsx("div", { className: "ntf-item-row-action", onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), children: renderRowAction(notification) }))] }, notification.id))), hasNextPage && (_jsx("div", { className: "ntf-list-footer", children: _jsx(Button, { variant: "ghost", size: "sm", onClick: nextPage, children: "Load more" }) }))] })) })] }));
|
|
76
76
|
}
|
|
77
77
|
//# sourceMappingURL=NotificationList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationList.js","sourceRoot":"","sources":["../../../src/react/components/NotificationList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,SAAS,
|
|
1
|
+
{"version":3,"file":"NotificationList.js","sourceRoot":"","sources":["../../../src/react/components/NotificationList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,MAAM,EACN,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,SAAS,EACT,eAAe,GACO;IACtB,MAAM,EACJ,IAAI,EAAE,aAAa,EACnB,SAAS,EACT,WAAW,EACX,QAAQ,GACT,GAAG,sBAAsB,CAAC;QACzB,MAAM;QACN,MAAM;QACN,QAAQ;QACR,eAAe;KAChB,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,sBAAsB,CAAC;QAC7C,MAAM;QACN,QAAQ;QACR,SAAS;KACV,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;Q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B,uBAAuB,CAAC,YAAY,CAAC,CAAC;gCACxC,CAAC;4BACH,CAAC,aAED,cAAK,SAAS,EAAC,eAAe,YAC3B,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAC3B,EACN,eAAK,SAAS,EAAC,kBAAkB,aAC/B,cAAK,SAAS,EAAC,gBAAgB,YAAE,YAAY,CAAC,KAAK,GAAO,EAC1D,cAAK,SAAS,EAAC,kBAAkB,YAAE,YAAY,CAAC,OAAO,GAAO,EAC9D,cAAK,SAAS,EAAC,oBAAoB,YAChC,kBAAkB,CAAC,YAAY,CAAC,SAAS,CAAC,GACvC,IACF,EACL,YAAY,CAAC,KAAK,GAAG,CAAC,IAAI,CACzB,cAAK,SAAS,EAAC,gBAAgB,YAC7B,MAAC,KAAK,IAAC,OAAO,EAAC,WAAW,uBAAG,YAAY,CAAC,KAAK,IAAS,GACpD,CACP,EACA,eAAe,IAAI,CAClB,cACE,SAAS,EAAC,qBAAqB,EAC/B,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EACnC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,YAEpC,eAAe,CAAC,YAAY,CAAC,GAC1B,CACP,KAnCI,YAAY,CAAC,EAAE,CAoChB,CACP,CAAC,EACD,WAAW,IAAI,CACd,cAAK,SAAS,EAAC,iBAAiB,YAC9B,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,QAAQ,0BAE1C,GACL,CACP,IACA,CACJ,GACK,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { NotificationList } from './NotificationList.js';
|
|
2
|
+
export { NotificationHistoryList } from './NotificationHistoryList.js';
|
|
2
3
|
export { NotificationEmptyState } from './NotificationEmptyState.js';
|
|
3
4
|
export { NotificationUnreadBadge } from './NotificationUnreadBadge.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { NotificationList } from './NotificationList.js';
|
|
2
|
+
export { NotificationHistoryList } from './NotificationHistoryList.js';
|
|
2
3
|
export { NotificationEmptyState } from './NotificationEmptyState.js';
|
|
3
4
|
export { NotificationUnreadBadge } from './NotificationUnreadBadge.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useActiveNotifications } from './useActiveNotifications.js';
|
|
2
|
+
export { useNotificationHistory } from './useNotificationHistory.js';
|
|
2
3
|
export { useUnreadCount } from './useUnreadCount.js';
|
|
3
4
|
export { useArchiveNotification } from './useArchiveNotification.js';
|
|
4
5
|
export { useArchiveAllNotifications } from './useArchiveAllNotifications.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useActiveNotifications } from './useActiveNotifications.js';
|
|
2
|
+
export { useNotificationHistory } from './useNotificationHistory.js';
|
|
2
3
|
export { useUnreadCount } from './useUnreadCount.js';
|
|
3
4
|
export { useArchiveNotification } from './useArchiveNotification.js';
|
|
4
5
|
export { useArchiveAllNotifications } from './useArchiveAllNotifications.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { NotificationHistoryItem, UseNotificationHistoryOptions } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Paginated read of ARCHIVED notification history (the two-tier system's history
|
|
4
|
+
* tier). Personal history lives under a per-user path
|
|
5
|
+
* (`userProfiles/{uid}/notificationHistory`) and shared/admin history under a
|
|
6
|
+
* top-level collection (`adminNotificationHistory`) — both resolved from the
|
|
7
|
+
* category's `historyPath`, so no `where` clause is needed either way. Rows are
|
|
8
|
+
* immutable and ordered newest-first by `archivedAt`.
|
|
9
|
+
*
|
|
10
|
+
* Each history doc is a wrapper (`archivedSnapshot` + archive metadata + a
|
|
11
|
+
* native-TTL `expireAt`); the `select` mapper flattens it into a
|
|
12
|
+
* {@link NotificationHistoryItem} so the read surface renders like the active
|
|
13
|
+
* list. Owner-only (user) / admin-only (admin) reads are enforced by Firestore
|
|
14
|
+
* rules — this hook performs no writes.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useNotificationHistory({ config, userId, category, enabled, pageSize, staleTime, }: UseNotificationHistoryOptions): import("@ttt-productions/query-core/react").UseFirestorePaginatedResult<NotificationHistoryItem>;
|
|
17
|
+
//# sourceMappingURL=useNotificationHistory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotificationHistory.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useNotificationHistory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,uBAAuB,EACvB,6BAA6B,EAC9B,MAAM,gBAAgB,CAAC;AAKxB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAc,EACd,QAA4B,EAC5B,SAA8B,GAC/B,EAAE,6BAA6B,oGA4B/B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useFirestorePaginated } from '@ttt-productions/query-core/react';
|
|
3
|
+
import { orderBy } from 'firebase/firestore';
|
|
4
|
+
const DEFAULT_PAGE_SIZE = 20;
|
|
5
|
+
const DEFAULT_STALE_TIME = 60_000;
|
|
6
|
+
/**
|
|
7
|
+
* Paginated read of ARCHIVED notification history (the two-tier system's history
|
|
8
|
+
* tier). Personal history lives under a per-user path
|
|
9
|
+
* (`userProfiles/{uid}/notificationHistory`) and shared/admin history under a
|
|
10
|
+
* top-level collection (`adminNotificationHistory`) — both resolved from the
|
|
11
|
+
* category's `historyPath`, so no `where` clause is needed either way. Rows are
|
|
12
|
+
* immutable and ordered newest-first by `archivedAt`.
|
|
13
|
+
*
|
|
14
|
+
* Each history doc is a wrapper (`archivedSnapshot` + archive metadata + a
|
|
15
|
+
* native-TTL `expireAt`); the `select` mapper flattens it into a
|
|
16
|
+
* {@link NotificationHistoryItem} so the read surface renders like the active
|
|
17
|
+
* list. Owner-only (user) / admin-only (admin) reads are enforced by Firestore
|
|
18
|
+
* rules — this hook performs no writes.
|
|
19
|
+
*/
|
|
20
|
+
export function useNotificationHistory({ config, userId, category, enabled = true, pageSize = DEFAULT_PAGE_SIZE, staleTime = DEFAULT_STALE_TIME, }) {
|
|
21
|
+
const categoryConfig = config.categories[category];
|
|
22
|
+
if (!categoryConfig) {
|
|
23
|
+
throw new Error(`[notification-core] Unknown category: ${category}`);
|
|
24
|
+
}
|
|
25
|
+
const collectionPath = categoryConfig.historyPath(userId);
|
|
26
|
+
const constraints = [orderBy('archivedAt', 'desc')];
|
|
27
|
+
return useFirestorePaginated({
|
|
28
|
+
collectionPath,
|
|
29
|
+
queryKey: ['notifications', 'history', category, userId, { pageSize }],
|
|
30
|
+
constraints,
|
|
31
|
+
pageSize,
|
|
32
|
+
enabled: enabled && !!userId,
|
|
33
|
+
staleTime,
|
|
34
|
+
select: (data) => {
|
|
35
|
+
const snapshot = (data.archivedSnapshot ?? {});
|
|
36
|
+
return {
|
|
37
|
+
...snapshot,
|
|
38
|
+
// The archive occurrence id is the stable history-doc key; expose
|
|
39
|
+
// archivedAt for ordering/display.
|
|
40
|
+
archiveOccurrenceId: data.id,
|
|
41
|
+
archivedAt: data.archivedAt ?? snapshot.updatedAt ?? 0,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=useNotificationHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNotificationHistory.js","sourceRoot":"","sources":["../../../src/react/hooks/useNotificationHistory.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAwB,MAAM,oBAAoB,CAAC;AAOnE,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,GAAG,IAAI,EACd,QAAQ,GAAG,iBAAiB,EAC5B,SAAS,GAAG,kBAAkB,GACA;IAC9B,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,QAAQ,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAE1D,MAAM,WAAW,GAAsB,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvE,OAAO,qBAAqB,CAA0B;QACpD,cAAc;QACd,QAAQ,EAAE,CAAC,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC;QACtE,WAAW;QACX,QAAQ;QACR,OAAO,EAAE,OAAO,IAAI,CAAC,CAAC,MAAM;QAC5B,SAAS;QACT,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAAoB,CAAC;YAClE,OAAO;gBACL,GAAG,QAAQ;gBACX,kEAAkE;gBAClE,mCAAmC;gBACnC,mBAAmB,EAAE,IAAI,CAAC,EAAE;gBAC5B,UAAU,EAAG,IAAI,CAAC,UAAiC,IAAI,QAAQ,CAAC,SAAS,IAAI,CAAC;aAC/E,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { useActiveNotifications, useUnreadCount, useArchiveNotification, useArchiveAllNotifications, } from './hooks/index.js';
|
|
2
|
-
export { NotificationList, NotificationEmptyState, NotificationUnreadBadge, } from './components/index.js';
|
|
1
|
+
export { useActiveNotifications, useNotificationHistory, useUnreadCount, useArchiveNotification, useArchiveAllNotifications, } from './hooks/index.js';
|
|
2
|
+
export { NotificationList, NotificationHistoryList, NotificationEmptyState, NotificationUnreadBadge, } from './components/index.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
// Hooks
|
|
3
|
-
export { useActiveNotifications, useUnreadCount, useArchiveNotification, useArchiveAllNotifications, } from './hooks/index.js';
|
|
3
|
+
export { useActiveNotifications, useNotificationHistory, useUnreadCount, useArchiveNotification, useArchiveAllNotifications, } from './hooks/index.js';
|
|
4
4
|
// Components
|
|
5
|
-
export { NotificationList, NotificationEmptyState, NotificationUnreadBadge, } from './components/index.js';
|
|
5
|
+
export { NotificationList, NotificationHistoryList, NotificationEmptyState, NotificationUnreadBadge, } from './components/index.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,QAAQ;AACR,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAE1B,aAAa;AACb,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,QAAQ;AACR,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAE1B,aAAa;AACb,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Two-tier notification system: active (unread) → history (archived).
|
|
5
5
|
* No `isRead` flag — existence in the active collection means unread.
|
|
6
6
|
*/
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
7
8
|
/**
|
|
8
9
|
* Active notification document stored in Firestore.
|
|
9
10
|
* Same shape for both user and admin collections.
|
|
@@ -147,6 +148,28 @@ export interface UseActiveNotificationsOptions {
|
|
|
147
148
|
pageSize?: number;
|
|
148
149
|
refetchInterval?: number;
|
|
149
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* A flattened archived-history item for the read surface. The history doc is a
|
|
153
|
+
* wrapper (`archivedSnapshot` + archive metadata + TTL); this shape lifts the
|
|
154
|
+
* snapshot's display fields to the top level so the history list renders exactly
|
|
155
|
+
* like the active list, plus `archivedAt` for ordering/display and
|
|
156
|
+
* `archiveOccurrenceId` as the stable React key.
|
|
157
|
+
*/
|
|
158
|
+
export interface NotificationHistoryItem extends NotificationDoc {
|
|
159
|
+
/** The history doc id (stable key — the `archiveOccurrenceId`). */
|
|
160
|
+
archiveOccurrenceId: string;
|
|
161
|
+
/** Epoch ms the notification was archived (history docs order by this). */
|
|
162
|
+
archivedAt: number;
|
|
163
|
+
}
|
|
164
|
+
export interface UseNotificationHistoryOptions {
|
|
165
|
+
config: NotificationSystemConfig;
|
|
166
|
+
userId: string;
|
|
167
|
+
category: string;
|
|
168
|
+
enabled?: boolean;
|
|
169
|
+
pageSize?: number;
|
|
170
|
+
/** Read-freshness stale time in ms (archived rows are immutable; default 60s). */
|
|
171
|
+
staleTime?: number;
|
|
172
|
+
}
|
|
150
173
|
export interface UseUnreadCountOptions {
|
|
151
174
|
config: NotificationSystemConfig;
|
|
152
175
|
userId: string;
|
|
@@ -268,6 +291,37 @@ export interface NotificationListProps {
|
|
|
268
291
|
onClearAll?: () => void;
|
|
269
292
|
refetchInterval?: number;
|
|
270
293
|
emptyText?: string;
|
|
294
|
+
/**
|
|
295
|
+
* Optional per-row action slot rendered alongside the existing archive control.
|
|
296
|
+
* Purely additive: the package renders exactly as today when omitted. The
|
|
297
|
+
* consumer decides what the action does (e.g. an explicit "go to" button) —
|
|
298
|
+
* this package has no opinion on it and takes no dependency on its shape.
|
|
299
|
+
* The rendered node is wrapped so clicks inside it do not bubble to the row's
|
|
300
|
+
* own click handler (`onNotificationClick` / archive-on-click).
|
|
301
|
+
*/
|
|
302
|
+
renderRowAction?: (notification: NotificationDoc) => ReactNode;
|
|
303
|
+
}
|
|
304
|
+
export interface NotificationHistoryListProps {
|
|
305
|
+
config: NotificationSystemConfig;
|
|
306
|
+
userId: string;
|
|
307
|
+
category: string;
|
|
308
|
+
/**
|
|
309
|
+
* Optional click handler for an archived row (e.g. navigate to `targetPath`).
|
|
310
|
+
* Archived rows are read-only — there is no re-archive; the row does not mutate
|
|
311
|
+
* state on click. Omit to render non-interactive rows.
|
|
312
|
+
*/
|
|
313
|
+
onNotificationClick?: (notification: NotificationHistoryItem) => void;
|
|
314
|
+
pageSize?: number;
|
|
315
|
+
staleTime?: number;
|
|
316
|
+
emptyText?: string;
|
|
317
|
+
/**
|
|
318
|
+
* Optional per-row action slot rendered alongside each history row. Purely
|
|
319
|
+
* additive: the package renders exactly as today when omitted. The consumer
|
|
320
|
+
* decides what the action does — this package has no opinion on it and takes
|
|
321
|
+
* no dependency on its shape. The rendered node is wrapped so clicks inside it
|
|
322
|
+
* do not bubble to the row's own click handler (when `onNotificationClick` is set).
|
|
323
|
+
*/
|
|
324
|
+
renderRowAction?: (notification: NotificationHistoryItem) => ReactNode;
|
|
271
325
|
}
|
|
272
326
|
export interface NotificationEmptyStateProps {
|
|
273
327
|
text?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IAGjB,4DAA4D;IAC5D,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAGhB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAGzB,iEAAiE;IACjE,UAAU,EAAE,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,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC5E;;;;OAIG;IACH,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACzE,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,KAAK,SAAS,CAAC;CAChE;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,CAAC,YAAY,EAAE,uBAAuB,KAAK,IAAI,CAAC;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,uBAAuB,KAAK,SAAS,CAAC;CACxE;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/notification-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Shared notification system for TTT Productions apps — active/history two-tier architecture with dedup, batch processing, and themed UI components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -107,6 +107,14 @@
|
|
|
107
107
|
align-self: center;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/* Sibling action slot next to the archive control — consumer-supplied via
|
|
111
|
+
* `renderRowAction`. Purely a layout/isolation wrapper; the consumer's node
|
|
112
|
+
* supplies its own visual treatment. */
|
|
113
|
+
.ntf-item-row-action {
|
|
114
|
+
flex-shrink: 0;
|
|
115
|
+
align-self: center;
|
|
116
|
+
}
|
|
117
|
+
|
|
110
118
|
/* === EMPTY STATE === */
|
|
111
119
|
.ntf-empty {
|
|
112
120
|
display: flex;
|