@handijitcom/ui 3.5.1 → 3.6.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/README.md +3 -1
- package/build/components/Chip/style.css +1 -1
- package/build/components/NotificationCenter/index.cjs +1 -1
- package/build/components/NotificationCenter/index.cjs.map +1 -1
- package/build/components/NotificationCenter/index.d.cts +6 -1
- package/build/components/NotificationCenter/index.d.ts +6 -1
- package/build/components/NotificationCenter/index.js +64 -63
- package/build/components/NotificationCenter/index.js.map +1 -1
- package/build/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -815,7 +815,9 @@ Escape closes, the focus returns to the trigger. Trigger props: `placeholder`,
|
|
|
815
815
|
**`NotificationCenter`** — bell with an unread badge and a panel grouped by
|
|
816
816
|
day (today, yesterday, then the date in `labels.locale`). Presentational:
|
|
817
817
|
`items`, `onItemSelect`, `onMarkRead`, `onMarkAllRead`, optional `isOpen` /
|
|
818
|
-
`onOpenChange`, `formatDay` / `formatTime
|
|
818
|
+
`onOpenChange`, `formatDay` / `formatTime`, and `unreadCount` (3.6) when
|
|
819
|
+
`items` holds only the latest page: the true count drives the badge, the
|
|
820
|
+
bell's label and "mark all read".
|
|
819
821
|
|
|
820
822
|
**`BulkPasteInput`** and **`parseBulkPaste(text, { defaultQuantity, isMergingDuplicates })`**
|
|
821
823
|
— rows `{ code, quantity, line }` and invalid lines `{ line, text, reason }`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";@layer ui{.ui-chip--NLgU{position:relative}.ui-chip--NLgU:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:max(100%,44px);height:max(100%,44px)}.ui-chip--NLgU{display:inline-flex;align-items:center;justify-content:center;gap:var(--hd-space-2);background-color:var(--ui-chip-bg, var(--hd-bg-surface));border:1px solid var(--ui-chip-line, var(--hd-border));border-radius:var(--ui-chip-radius, var(--hd-radius-sm));color:var(--ui-chip-fg, var(--hd-text-2));font-family:var(--hd-font-body);font-weight:var(--ui-chip-weight, var(--hd-font-weight-medium));line-height:1;white-space:nowrap;cursor:pointer;text-decoration:none;transition:border-color var(--hd-duration-fast) var(--hd-ease-standard),color var(--hd-duration-fast) var(--hd-ease-standard),background-color var(--hd-duration-fast) var(--hd-ease-standard)}.ui-chip--NLgU:focus-visible{outline:var(--ui-ring-width, 2px) solid var(--ui-ring-color, var(--hd-focus));outline-offset:var(--ui-ring-offset, 2px)}.ui-chip--NLgU:hover:not(:disabled){border-color:var(--hd-border-strong);color:var(--hd-text)}.ui-chip--NLgU:disabled{background-color:var(--hd-bg-raised);border-color:var(--hd-border);cursor:not-allowed;color:var(--hd-text-3)}@media (forced-colors: active){.ui-chip--NLgU:disabled{color:GrayText;border-color:GrayText}}.ui-chip--NLgU:disabled .ui-chip__icon-IjjSb,.ui-chip--NLgU:disabled .ui-chip__count-MBGO3{color:var(--hd-text-3)}@media (forced-colors: active){.ui-chip--NLgU:disabled .ui-chip__icon-IjjSb,.ui-chip--NLgU:disabled .ui-chip__count-MBGO3{color:GrayText}}@media (prefers-reduced-motion: reduce){.ui-chip--NLgU{transition:none}}.ui-chip__icon-IjjSb{display:inline-flex;align-items:center;flex-shrink:0;font-size:.92em;color:var(--hd-text-2);transition:color var(--hd-duration-fast) var(--hd-ease-standard)}@media (prefers-reduced-motion: reduce){.ui-chip__icon-IjjSb{transition:none}}.ui-chip__label-cT4hw{overflow:hidden;text-overflow:ellipsis}.ui-chip__count-MBGO3{font-size:var(--hd-type-caption-size);font-weight:var(--hd-font-weight-semibold);color:var(--hd-text-3);font-variant-numeric:tabular-nums;flex-shrink:0}.ui-chip--sm-60H-S{font-size:var(--hd-type-caption-size);padding:var(--hd-space-2) var(--hd-space-3);min-height:32px}.ui-chip--md--yAlm{font-size:var(--hd-type-small-size);padding:var(--hd-space-2) var(--hd-space-4);min-height:40px}.ui-chip--iconOnly-5LT1h{gap:0}.ui-chip--iconOnly-5LT1h.ui-chip--sm-60H-S{width:32px;padding:0}.ui-chip--iconOnly-5LT1h.ui-chip--md--yAlm{width:40px;padding:0}.ui-chip--iconOnly-5LT1h .ui-chip__icon-IjjSb{font-size:1em}.ui-chip--selected-FdpCr{border-color:var(--ui-chip-selected-line, var(--hd-primary));color:var(--ui-chip-selected-fg, var(--hd-primary-text));background-color:var(--ui-chip-selected-bg, var(--hd-primary-soft));font-weight:var(--ui-chip-selected-weight, var(--hd-font-weight-semibold))}.ui-chip--selected-FdpCr .ui-chip__icon-IjjSb,.ui-chip--selected-FdpCr .ui-chip__count-MBGO3{color:var(--ui-chip-selected-fg, var(--hd-primary-text))}.ui-chip--selected-FdpCr:hover:not(:disabled){border-color:var(--ui-chip-selected-line, var(--hd-primary-hover));color:var(--ui-chip-selected-fg, var(--hd-primary-text));background-color:var(--ui-chip-selected-bg, var(--hd-primary-soft-hover))}.ui-chip--selected-FdpCr:disabled{border-color:var(--hd-text-3)}}
|
|
1
|
+
@charset "UTF-8";@layer ui{.ui-chip--NLgU{position:relative}.ui-chip--NLgU:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:max(100%,44px);height:max(100%,44px)}.ui-chip--NLgU{display:inline-flex;align-items:center;justify-content:center;gap:var(--hd-space-2);background-color:var(--ui-chip-bg, var(--hd-bg-surface));border:1px solid var(--ui-chip-line, var(--hd-border));border-radius:var(--ui-chip-radius, var(--hd-radius-sm));color:var(--ui-chip-fg, var(--hd-text-2));font-family:var(--hd-font-body);font-weight:var(--ui-chip-weight, var(--hd-font-weight-medium));line-height:1;white-space:nowrap;cursor:pointer;text-decoration:none;transition:border-color var(--hd-duration-fast) var(--hd-ease-standard),color var(--hd-duration-fast) var(--hd-ease-standard),background-color var(--hd-duration-fast) var(--hd-ease-standard)}.ui-chip--NLgU:focus-visible{outline:var(--ui-ring-width, 2px) solid var(--ui-ring-color, var(--hd-focus));outline-offset:var(--ui-ring-offset, 2px)}.ui-chip--NLgU:hover:not(:disabled){border-color:var(--hd-border-strong);color:var(--hd-text)}.ui-chip--NLgU:disabled{background-color:var(--hd-bg-raised);border-color:var(--hd-border);cursor:not-allowed;color:var(--hd-text-3)}@media (forced-colors: active){.ui-chip--NLgU:disabled{color:GrayText;border-color:GrayText}}.ui-chip--NLgU:disabled .ui-chip__icon-IjjSb,.ui-chip--NLgU:disabled .ui-chip__count-MBGO3{color:var(--hd-text-3)}@media (forced-colors: active){.ui-chip--NLgU:disabled .ui-chip__icon-IjjSb,.ui-chip--NLgU:disabled .ui-chip__count-MBGO3{color:GrayText}}@media (prefers-reduced-motion: reduce){.ui-chip--NLgU{transition:none}}.ui-chip__icon-IjjSb{display:inline-flex;align-items:center;flex-shrink:0;font-size:.92em;color:var(--hd-text-2);transition:color var(--hd-duration-fast) var(--hd-ease-standard)}@media (prefers-reduced-motion: reduce){.ui-chip__icon-IjjSb{transition:none}}.ui-chip__label-cT4hw{overflow:hidden;text-overflow:ellipsis;padding-block:.25em;margin-block:-.25em}.ui-chip__count-MBGO3{font-size:var(--hd-type-caption-size);font-weight:var(--hd-font-weight-semibold);color:var(--hd-text-3);font-variant-numeric:tabular-nums;flex-shrink:0}.ui-chip--sm-60H-S{font-size:var(--hd-type-caption-size);padding:var(--hd-space-2) var(--hd-space-3);min-height:32px}.ui-chip--md--yAlm{font-size:var(--hd-type-small-size);padding:var(--hd-space-2) var(--hd-space-4);min-height:40px}.ui-chip--iconOnly-5LT1h{gap:0}.ui-chip--iconOnly-5LT1h.ui-chip--sm-60H-S{width:32px;padding:0}.ui-chip--iconOnly-5LT1h.ui-chip--md--yAlm{width:40px;padding:0}.ui-chip--iconOnly-5LT1h .ui-chip__icon-IjjSb{font-size:1em}.ui-chip--selected-FdpCr{border-color:var(--ui-chip-selected-line, var(--hd-primary));color:var(--ui-chip-selected-fg, var(--hd-primary-text));background-color:var(--ui-chip-selected-bg, var(--hd-primary-soft));font-weight:var(--ui-chip-selected-weight, var(--hd-font-weight-semibold))}.ui-chip--selected-FdpCr .ui-chip__icon-IjjSb,.ui-chip--selected-FdpCr .ui-chip__count-MBGO3{color:var(--ui-chip-selected-fg, var(--hd-primary-text))}.ui-chip--selected-FdpCr:hover:not(:disabled){border-color:var(--ui-chip-selected-line, var(--hd-primary-hover));color:var(--ui-chip-selected-fg, var(--hd-primary-text));background-color:var(--ui-chip-selected-bg, var(--hd-primary-soft-hover))}.ui-chip--selected-FdpCr:disabled{border-color:var(--hd-text-3)}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),k=require("react"),N=require("react-bootstrap-icons"),S=require("../../enums/ui-size.enum.cjs"),$=require("../../enums/ui-variant.enum.cjs"),j=require("../../helpers/class-name.helper.cjs"),D=require("../../helpers/component.helper.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),k=require("react"),N=require("react-bootstrap-icons"),S=require("../../enums/ui-size.enum.cjs"),$=require("../../enums/ui-variant.enum.cjs"),j=require("../../helpers/class-name.helper.cjs"),D=require("../../helpers/component.helper.cjs"),d=require("../../helpers/label.helper.cjs"),A=require("../../theme/context.cjs"),O=require("../Button/index.cjs"),C=require("../IconButton/index.cjs"),z=require("../Popover/index.cjs"),a={default:{"panel":"ui-panel-5SyKG","srOnly":"ui-srOnly-RIBgB","bell":"ui-bell-eoWEW","badge":"ui-badge-f-M5o","header":"ui-header-XVQsI","heading":"ui-heading-coSaJ","list":"ui-list-qhaa9","day":"ui-day-q8cob","items":"ui-items-Cy4JF","item":"ui-item-Gx5xM","item__main":"ui-item__main-YzJ2w","item__main--button":"ui-item__main--button-0gQh7","item--unread":"ui-item--unread-LYQ9H","title":"ui-title-vMVcE","icon":"ui-icon-xOfOg","body":"ui-body-xDRoI","description":"ui-description-SuXFu","time":"ui-time-k0R6i","empty":"ui-empty-WTfI4","empty__icon":"ui-empty__icon-03css"}},q=99,h=l=>`${l.getFullYear()}-${l.getMonth()}-${l.getDate()}`,T=l=>{const o=new Map,x=l.map(s=>({item:s,date:new Date(s.date)})).sort((s,r)=>r.date.getTime()-s.date.getTime());for(const s of x){const r=h(s.date),f=o.get(r)??{key:r,date:s.date,items:[]};f.items.push(s),o.set(r,f)}return[...o.values()]},G=({items:l,unreadCount:o,onItemSelect:x,onMarkRead:s,onMarkAllRead:r,isOpen:f,onOpenChange:L,formatDay:p,formatTime:b,labels:F,className:B,testId:I})=>{const{labels:u}=A.useUi(),M=k.useId(),m=o===void 0?l.filter(t=>!t.isRead).length:Math.max(0,Math.floor(o)),c={...u==null?void 0:u.notificationCenter,...F},g=d.resolveLabel("NotificationCenter.labels.title",c.title),y=u==null?void 0:u.locale,R=t=>{const n=new Date,i=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1);return h(t)===h(n)?d.resolveLabel("NotificationCenter.labels.today",c.today):h(t)===h(i)?d.resolveLabel("NotificationCenter.labels.yesterday",c.yesterday):(p==null?void 0:p(t))??new Intl.DateTimeFormat(y,{day:"numeric",month:"long",year:"numeric"}).format(t)},w=t=>(b==null?void 0:b(t))??new Intl.DateTimeFormat(y,{hour:"2-digit",minute:"2-digit"}).format(t),_=(t,n)=>e.jsxs(e.Fragment,{children:[t.icon&&e.jsx("span",{"aria-hidden":!0,className:a.default.icon,children:t.icon}),e.jsxs("span",{className:a.default.body,children:[e.jsxs("span",{className:a.default.title,children:[!t.isRead&&e.jsxs("span",{className:a.default.srOnly,children:[d.resolveLabel("NotificationCenter.labels.unread",c.unread),":"," "]}),t.title]}),t.description&&e.jsx("span",{className:a.default.description,children:t.description}),e.jsx("time",{className:a.default.time,dateTime:n.toISOString(),children:w(n)})]})]});return e.jsxs(z.default,{label:g,align:"end",isOpen:f,onOpenChange:L,className:j.cx(a.default.panel,B),testId:I,trigger:e.jsx(C.default,{icon:e.jsxs("span",{className:a.default.bell,children:[e.jsx(N.BellFill,{"aria-hidden":!0}),m>0&&e.jsx("span",{"aria-hidden":!0,className:a.default.badge,children:m>q?`${q}+`:m})]}),label:d.resolveFormatter("NotificationCenter.labels.trigger",c.trigger,m)}),children:[e.jsxs("div",{className:a.default.header,children:[e.jsx("p",{className:a.default.heading,children:g}),m>0&&r&&e.jsx(O.default,{variant:$.default.GHOST,size:S.default.SMALL,onClick:r,children:d.resolveLabel("NotificationCenter.labels.markAllRead",c.markAllRead)})]}),l.length===0?e.jsxs("p",{className:a.default.empty,children:[e.jsx(N.BellFill,{"aria-hidden":!0,className:a.default.empty__icon}),d.resolveLabel("NotificationCenter.labels.empty",c.empty)]}):e.jsx("div",{className:a.default.list,children:T(l).map(t=>{const n=`${M}-${t.key}`;return e.jsxs("div",{role:"group","aria-labelledby":n,children:[e.jsx("p",{id:n,className:a.default.day,children:R(t.date)}),e.jsx("ul",{className:a.default.items,children:t.items.map(({item:i,date:v})=>e.jsxs("li",{className:j.cx(a.default.item,!i.isRead&&a.default["item--unread"]),children:[x?e.jsx("button",{type:"button",className:j.cx(a.default.item__main,a.default["item__main--button"]),onClick:()=>x(i),children:_(i,v)}):e.jsx("div",{className:a.default.item__main,children:_(i,v)}),!i.isRead&&s&&e.jsx(C.default,{icon:e.jsx(N.Check2,{"aria-hidden":!0}),label:d.resolveLabel("NotificationCenter.labels.markRead",c.markRead),size:"sm",onClick:()=>s(i)})]},i.id))})]},t.key)})})]})},H=k.memo(D.named(G,"NotificationCenter"));exports.default=H;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/NotificationCenter/index.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type ReactNode, useId } from 'react';\n\nimport { BellFill, Check2 } from 'react-bootstrap-icons';\n\nimport UISize from '../../enums/ui-size.enum';\nimport UIVariant from '../../enums/ui-variant.enum';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\nimport Button from '../Button';\nimport IconButton from '../IconButton';\nimport Popover from '../Popover';\n\nimport styles from './index.module.scss';\n\nexport type NotificationItem = {\n id: string;\n title: string;\n description?: ReactNode;\n /** When it happened: a `Date`, an ISO string or epoch milliseconds. */\n date: Date | string | number;\n isRead?: boolean;\n /** A leading icon (the kind of notification). */\n icon?: ReactNode;\n};\n\nexport type NotificationCenterLabels = {\n trigger: Formatter<[unread: number]>;\n title: string;\n markAllRead: string;\n markRead: string;\n empty: string;\n unread: string;\n today: string;\n yesterday: string;\n};\n\ntype Props = {\n items: NotificationItem[];\n /** A notification was opened. Without it the rows are plain text. */\n onItemSelect?: (item: NotificationItem) => void;\n /** Shows a \"mark read\" button on each unread notification. */\n onMarkRead?: (item: NotificationItem) => void;\n /** Shows \"mark all read\" while something is unread. */\n onMarkAllRead?: () => void;\n /** Controlled panel; uncontrolled when omitted. */\n isOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n /** Heading of a day older than yesterday; the day and month in `labels.locale` by default. */\n formatDay?: (date: Date) => string;\n /** Time of one notification; hours and minutes in `labels.locale` by default. */\n formatTime?: (date: Date) => string;\n labels?: Partial<NotificationCenterLabels>;\n className?: string;\n testId?: string;\n};\n\n/* Above this the badge reads \"99+\": a wider badge would cover the bell. */\nconst BADGE_MAX = 99;\n\nconst dayKey = (date: Date): string => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;\n\ntype DayGroup = { key: string; date: Date; items: { item: NotificationItem; date: Date }[] };\n\n/** Newest first, one group per local calendar day. */\nconst groupByDay = (items: NotificationItem[]): DayGroup[] => {\n const groups = new Map<string, DayGroup>();\n const dated = items\n .map(item => ({ item, date: new Date(item.date) }))\n .sort((a, b) => b.date.getTime() - a.date.getTime());\n\n for (const entry of dated) {\n const key = dayKey(entry.date);\n const group = groups.get(key) ?? { key, date: entry.date, items: [] };\n group.items.push(entry);\n groups.set(key, group);\n }\n\n return [...groups.values()];\n};\n\n/** Bell with an unread badge and a panel of notifications grouped by day (3.1). Presentational. */\nconst NotificationCenter = ({\n items,\n onItemSelect,\n onMarkRead,\n onMarkAllRead,\n isOpen,\n onOpenChange,\n formatDay,\n formatTime,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const baseId = useId();\n const unread = items.filter(item => !item.isRead).length;\n const text = { ...config?.notificationCenter, ...labelProps };\n\n const title = resolveLabel('NotificationCenter.labels.title', text.title);\n const locale = config?.locale;\n\n const dayHeading = (date: Date): string => {\n const today = new Date();\n const yesterday = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1);\n if (dayKey(date) === dayKey(today))\n return resolveLabel('NotificationCenter.labels.today', text.today);\n if (dayKey(date) === dayKey(yesterday))\n return resolveLabel('NotificationCenter.labels.yesterday', text.yesterday);\n\n return (\n formatDay?.(date) ??\n new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' }).format(\n date,\n )\n );\n };\n\n const time = (date: Date): string =>\n formatTime?.(date) ??\n new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit' }).format(date);\n\n const renderContent = (item: NotificationItem, date: Date) => (\n <>\n {item.icon && (\n <span aria-hidden className={styles.icon}>\n {item.icon}\n </span>\n )}\n <span className={styles.body}>\n <span className={styles.title}>\n {!item.isRead && (\n <span className={styles.srOnly}>\n {resolveLabel('NotificationCenter.labels.unread', text.unread)}:{' '}\n </span>\n )}\n {item.title}\n </span>\n {item.description && <span className={styles.description}>{item.description}</span>}\n <time className={styles.time} dateTime={date.toISOString()}>\n {time(date)}\n </time>\n </span>\n </>\n );\n\n return (\n <Popover\n label={title}\n align=\"end\"\n isOpen={isOpen}\n onOpenChange={onOpenChange}\n className={cx(styles.panel, className)}\n testId={testId}\n trigger={\n <IconButton\n icon={\n <span className={styles.bell}>\n <BellFill aria-hidden />\n {unread > 0 && (\n <span aria-hidden className={styles.badge}>\n {unread > BADGE_MAX ? `${BADGE_MAX}+` : unread}\n </span>\n )}\n </span>\n }\n label={resolveFormatter('NotificationCenter.labels.trigger', text.trigger, unread)}\n />\n }\n >\n <div className={styles.header}>\n <p className={styles.heading}>{title}</p>\n {unread > 0 && onMarkAllRead && (\n <Button variant={UIVariant.GHOST} size={UISize.SMALL} onClick={onMarkAllRead}>\n {resolveLabel('NotificationCenter.labels.markAllRead', text.markAllRead)}\n </Button>\n )}\n </div>\n\n {items.length === 0 ? (\n <p className={styles.empty}>\n <BellFill aria-hidden className={styles.empty__icon} />\n {resolveLabel('NotificationCenter.labels.empty', text.empty)}\n </p>\n ) : (\n <div className={styles.list}>\n {groupByDay(items).map(group => {\n const headingId = `${baseId}-${group.key}`;\n\n return (\n <div key={group.key} role=\"group\" aria-labelledby={headingId}>\n <p id={headingId} className={styles.day}>\n {dayHeading(group.date)}\n </p>\n <ul className={styles.items}>\n {group.items.map(({ item, date }) => (\n <li\n key={item.id}\n className={cx(styles.item, !item.isRead && styles['item--unread'])}\n >\n {onItemSelect ? (\n <button\n type=\"button\"\n className={cx(styles.item__main, styles['item__main--button'])}\n onClick={() => onItemSelect(item)}\n >\n {renderContent(item, date)}\n </button>\n ) : (\n <div className={styles.item__main}>{renderContent(item, date)}</div>\n )}\n {!item.isRead && onMarkRead && (\n <IconButton\n icon={<Check2 aria-hidden />}\n label={resolveLabel('NotificationCenter.labels.markRead', text.markRead)}\n size=\"sm\"\n onClick={() => onMarkRead(item)}\n />\n )}\n </li>\n ))}\n </ul>\n </div>\n );\n })}\n </div>\n )}\n </Popover>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(NotificationCenter, 'NotificationCenter'),\n) as typeof NotificationCenter;\n"],"names":["BADGE_MAX","dayKey","date","groupByDay","items","groups","dated","item","a","b","entry","key","group","NotificationCenter","onItemSelect","onMarkRead","onMarkAllRead","isOpen","onOpenChange","formatDay","formatTime","labelProps","className","testId","config","useUi","baseId","useId","unread","text","title","resolveLabel","locale","dayHeading","today","yesterday","time","renderContent","jsxs","Fragment","styles","jsx","Popover","cx","IconButton","BellFill","resolveFormatter","Button","UIVariant","UISize","headingId","Check2","index","memo","named"],"mappings":"0mBA6DMA,EAAY,GAEZC,EAAUC,GAAuB,GAAGA,EAAK,YAAA,CAAa,IAAIA,EAAK,SAAA,CAAU,IAAIA,EAAK,SAAS,GAK3FC,EAAcC,GAA0C,CAC5D,MAAMC,MAAa,IACbC,EAAQF,EACX,IAAIG,IAAS,CAAE,KAAAA,EAAM,KAAM,IAAI,KAAKA,EAAK,IAAI,CAAA,EAAI,EACjD,KAAK,CAACC,EAAGC,IAAMA,EAAE,KAAK,UAAYD,EAAE,KAAK,QAAA,CAAS,EAErD,UAAWE,KAASJ,EAAO,CACzB,MAAMK,EAAMV,EAAOS,EAAM,IAAI,EACvBE,EAAQP,EAAO,IAAIM,CAAG,GAAK,CAAE,IAAAA,EAAK,KAAMD,EAAM,KAAM,MAAO,CAAA,CAAC,EAClEE,EAAM,MAAM,KAAKF,CAAK,EACtBL,EAAO,IAAIM,EAAKC,CAAK,CACvB,CAEA,MAAO,CAAC,GAAGP,EAAO,QAAQ,CAC5B,EAGMQ,EAAqB,CAAC,CAC1B,MAAAT,EACA,aAAAU,EACA,WAAAC,EACA,cAAAC,EACA,OAAAC,EACA,aAAAC,EACA,UAAAC,EACA,WAAAC,EACA,OAAQC,EACR,UAAAC,EACA,OAAAC,CACF,IAAa,CACX,KAAM,CAAE,OAAQC,CAAA,EAAWC,QAAA,EACrBC,EAASC,EAAAA,MAAA,EACTC,EAASxB,EAAM,UAAe,CAACG,EAAK,MAAM,EAAE,OAC5CsB,EAAO,CAAE,GAAGL,GAAA,YAAAA,EAAQ,mBAAoB,GAAGH,CAAA,EAE3CS,EAAQC,EAAAA,aAAa,kCAAmCF,EAAK,KAAK,EAClEG,EAASR,GAAA,YAAAA,EAAQ,OAEjBS,EAAc/B,GAAuB,CACzC,MAAMgC,MAAY,KACZC,EAAY,IAAI,KAA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QAAQ,kBAAiBY,EACjD,SAAA,CAAAT,EAAAA,IAAC,IAAA,CAAE,GAAIS,EAAW,UAAWV,EAAAA,QAAO,IACjC,SAAAP,EAAWrB,EAAM,IAAI,CAAA,CACxB,EACA6B,EAAAA,IAAC,KAAA,CAAG,UAAWD,EAAAA,QAAO,MACnB,SAAA5B,EAAM,MAAM,IAAI,CAAC,CAAE,KAAAL,EAAM,KAAAL,CAAA,IACxBoC,EAAAA,KAAC,KAAA,CAEC,UAAWK,EAAAA,GAAGH,EAAAA,QAAO,KAAM,CAACjC,EAAK,QAAUiC,UAAO,cAAc,CAAC,EAEhE,SAAA,CAAA1B,EACC2B,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAWE,EAAAA,GAAGH,EAAAA,QAAO,WAAYA,EAAAA,QAAO,oBAAoB,CAAC,EAC7D,QAAS,IAAM1B,EAAaP,CAAI,EAE/B,SAAA8B,EAAc9B,EAAML,CAAI,CAAA,CAAA,QAG1B,MAAA,CAAI,UAAWsC,EAAAA,QAAO,WAAa,SAAAH,EAAc9B,EAAML,CAAI,CAAA,CAAE,EAE/D,CAACK,EAAK,QAAUQ,GACf0B,EAAAA,IAACG,EAAAA,QAAA,CACC,KAAMH,EAAAA,IAACU,EAAAA,OAAA,CAAO,cAAW,EAAA,CAAC,EAC1B,MAAOpB,EAAAA,aAAa,qCAAsCF,EAAK,QAAQ,EACvE,KAAK,KACL,QAAS,IAAMd,EAAWR,CAAI,CAAA,CAAA,CAChC,CAAA,EApBGA,EAAK,EAAA,CAuBb,CAAA,CACH,CAAA,CAAA,EA/BQK,EAAM,GAgChB,CAEJ,CAAC,CAAA,CACH,CAAA,CAAA,CAAA,CAIR,EAEAwC,EAA6BC,EAAAA,KACbC,EAAAA,MAAMzC,EAAoB,oBAAoB,CAC9D"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/NotificationCenter/index.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type ReactNode, useId } from 'react';\n\nimport { BellFill, Check2 } from 'react-bootstrap-icons';\n\nimport UISize from '../../enums/ui-size.enum';\nimport UIVariant from '../../enums/ui-variant.enum';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\nimport Button from '../Button';\nimport IconButton from '../IconButton';\nimport Popover from '../Popover';\n\nimport styles from './index.module.scss';\n\nexport type NotificationItem = {\n id: string;\n title: string;\n description?: ReactNode;\n /** When it happened: a `Date`, an ISO string or epoch milliseconds. */\n date: Date | string | number;\n isRead?: boolean;\n /** A leading icon (the kind of notification). */\n icon?: ReactNode;\n};\n\nexport type NotificationCenterLabels = {\n trigger: Formatter<[unread: number]>;\n title: string;\n markAllRead: string;\n markRead: string;\n empty: string;\n unread: string;\n today: string;\n yesterday: string;\n};\n\ntype Props = {\n items: NotificationItem[];\n /**\n * The true unread count (3.6), for a list that holds only the latest page: it drives the badge,\n * the bell's label and \"mark all read\". Counted from `items` when omitted.\n */\n unreadCount?: number;\n /** A notification was opened. Without it the rows are plain text. */\n onItemSelect?: (item: NotificationItem) => void;\n /** Shows a \"mark read\" button on each unread notification. */\n onMarkRead?: (item: NotificationItem) => void;\n /** Shows \"mark all read\" while something is unread. */\n onMarkAllRead?: () => void;\n /** Controlled panel; uncontrolled when omitted. */\n isOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n /** Heading of a day older than yesterday; the day and month in `labels.locale` by default. */\n formatDay?: (date: Date) => string;\n /** Time of one notification; hours and minutes in `labels.locale` by default. */\n formatTime?: (date: Date) => string;\n labels?: Partial<NotificationCenterLabels>;\n className?: string;\n testId?: string;\n};\n\n/* Above this the badge reads \"99+\": a wider badge would cover the bell. */\nconst BADGE_MAX = 99;\n\nconst dayKey = (date: Date): string => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;\n\ntype DayGroup = { key: string; date: Date; items: { item: NotificationItem; date: Date }[] };\n\n/** Newest first, one group per local calendar day. */\nconst groupByDay = (items: NotificationItem[]): DayGroup[] => {\n const groups = new Map<string, DayGroup>();\n const dated = items\n .map(item => ({ item, date: new Date(item.date) }))\n .sort((a, b) => b.date.getTime() - a.date.getTime());\n\n for (const entry of dated) {\n const key = dayKey(entry.date);\n const group = groups.get(key) ?? { key, date: entry.date, items: [] };\n group.items.push(entry);\n groups.set(key, group);\n }\n\n return [...groups.values()];\n};\n\n/** Bell with an unread badge and a panel of notifications grouped by day (3.1). Presentational. */\nconst NotificationCenter = ({\n items,\n unreadCount,\n onItemSelect,\n onMarkRead,\n onMarkAllRead,\n isOpen,\n onOpenChange,\n formatDay,\n formatTime,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const baseId = useId();\n const unread =\n unreadCount === undefined\n ? items.filter(item => !item.isRead).length\n : Math.max(0, Math.floor(unreadCount));\n const text = { ...config?.notificationCenter, ...labelProps };\n\n const title = resolveLabel('NotificationCenter.labels.title', text.title);\n const locale = config?.locale;\n\n const dayHeading = (date: Date): string => {\n const today = new Date();\n const yesterday = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1);\n if (dayKey(date) === dayKey(today))\n return resolveLabel('NotificationCenter.labels.today', text.today);\n if (dayKey(date) === dayKey(yesterday))\n return resolveLabel('NotificationCenter.labels.yesterday', text.yesterday);\n\n return (\n formatDay?.(date) ??\n new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' }).format(\n date,\n )\n );\n };\n\n const time = (date: Date): string =>\n formatTime?.(date) ??\n new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit' }).format(date);\n\n const renderContent = (item: NotificationItem, date: Date) => (\n <>\n {item.icon && (\n <span aria-hidden className={styles.icon}>\n {item.icon}\n </span>\n )}\n <span className={styles.body}>\n <span className={styles.title}>\n {!item.isRead && (\n <span className={styles.srOnly}>\n {resolveLabel('NotificationCenter.labels.unread', text.unread)}:{' '}\n </span>\n )}\n {item.title}\n </span>\n {item.description && <span className={styles.description}>{item.description}</span>}\n <time className={styles.time} dateTime={date.toISOString()}>\n {time(date)}\n </time>\n </span>\n </>\n );\n\n return (\n <Popover\n label={title}\n align=\"end\"\n isOpen={isOpen}\n onOpenChange={onOpenChange}\n className={cx(styles.panel, className)}\n testId={testId}\n trigger={\n <IconButton\n icon={\n <span className={styles.bell}>\n <BellFill aria-hidden />\n {unread > 0 && (\n <span aria-hidden className={styles.badge}>\n {unread > BADGE_MAX ? `${BADGE_MAX}+` : unread}\n </span>\n )}\n </span>\n }\n label={resolveFormatter('NotificationCenter.labels.trigger', text.trigger, unread)}\n />\n }\n >\n <div className={styles.header}>\n <p className={styles.heading}>{title}</p>\n {unread > 0 && onMarkAllRead && (\n <Button variant={UIVariant.GHOST} size={UISize.SMALL} onClick={onMarkAllRead}>\n {resolveLabel('NotificationCenter.labels.markAllRead', text.markAllRead)}\n </Button>\n )}\n </div>\n\n {items.length === 0 ? (\n <p className={styles.empty}>\n <BellFill aria-hidden className={styles.empty__icon} />\n {resolveLabel('NotificationCenter.labels.empty', text.empty)}\n </p>\n ) : (\n <div className={styles.list}>\n {groupByDay(items).map(group => {\n const headingId = `${baseId}-${group.key}`;\n\n return (\n <div key={group.key} role=\"group\" aria-labelledby={headingId}>\n <p id={headingId} className={styles.day}>\n {dayHeading(group.date)}\n </p>\n <ul className={styles.items}>\n {group.items.map(({ item, date }) => (\n <li\n key={item.id}\n className={cx(styles.item, !item.isRead && styles['item--unread'])}\n >\n {onItemSelect ? (\n <button\n type=\"button\"\n className={cx(styles.item__main, styles['item__main--button'])}\n onClick={() => onItemSelect(item)}\n >\n {renderContent(item, date)}\n </button>\n ) : (\n <div className={styles.item__main}>{renderContent(item, date)}</div>\n )}\n {!item.isRead && onMarkRead && (\n <IconButton\n icon={<Check2 aria-hidden />}\n label={resolveLabel('NotificationCenter.labels.markRead', text.markRead)}\n size=\"sm\"\n onClick={() => onMarkRead(item)}\n />\n )}\n </li>\n ))}\n </ul>\n </div>\n );\n })}\n </div>\n )}\n </Popover>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(NotificationCenter, 'NotificationCenter'),\n) as typeof NotificationCenter;\n"],"names":["BADGE_MAX","dayKey","date","groupByDay","items","groups","dated","item","a","b","entry","key","group","NotificationCenter","unreadCount","onItemSelect","onMarkRead","onMarkAllRead","isOpen","onOpenChange","formatDay","formatTime","labelProps","className","testId","config","useUi","baseId","useId","unread","text","title","resolveLabel","locale","dayHeading","today","yesterday","time","renderContent","jsxs","Fragment","styles","jsx","Popover","cx","IconButton","BellFill","resolveFormatter","Button","UIVariant","UISize","headingId","Check2","index","memo","named"],"mappings":"0mBAkEMA,EAAY,GAEZC,EAAUC,GAAuB,GAAGA,EAAK,YAAA,CAAa,IAAIA,EAAK,SAAA,CAAU,IAAIA,EAAK,SAAS,GAK3FC,EAAcC,GAA0C,CAC5D,MAAMC,MAAa,IACbC,EAAQF,EACX,IAAIG,IAAS,CAAE,KAAAA,EAAM,KAAM,IAAI,KAAKA,EAAK,IAAI,CAAA,EAAI,EACjD,KAAK,CAACC,EAAGC,IAAMA,EAAE,KAAK,UAAYD,EAAE,KAAK,QAAA,CAAS,EAErD,UAAWE,KAASJ,EAAO,CACzB,MAAMK,EAAMV,EAAOS,EAAM,IAAI,EACvBE,EAAQP,EAAO,IAAIM,CAAG,GAAK,CAAE,IAAAA,EAAK,KAAMD,EAAM,KAAM,MAAO,CAAA,CAAC,EAClEE,EAAM,MAAM,KAAKF,CAAK,EACtBL,EAAO,IAAIM,EAAKC,CAAK,CACvB,CAEA,MAAO,CAAC,GAAGP,EAAO,QAAQ,CAC5B,EAGMQ,EAAqB,CAAC,CAC1B,MAAAT,EACA,YAAAU,EACA,aAAAC,EACA,WAAAC,EACA,cAAAC,EACA,OAAAC,EACA,aAAAC,EACA,UAAAC,EACA,WAAAC,EACA,OAAQC,EACR,UAAAC,EACA,OAAAC,CACF,IAAa,CACX,KAAM,CA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,EAAK,QAAQ,EACvE,KAAK,KACL,QAAS,IAAMd,EAAWT,CAAI,CAAA,CAAA,CAChC,CAAA,EApBGA,EAAK,EAAA,CAuBb,CAAA,CACH,CAAA,CAAA,EA/BQK,EAAM,GAgChB,CAEJ,CAAC,CAAA,CACH,CAAA,CAAA,CAAA,CAIR,EAEAyC,EAA6BC,EAAAA,KACbC,EAAAA,MAAM1C,EAAoB,oBAAoB,CAC9D"}
|
|
@@ -22,6 +22,11 @@ export type NotificationCenterLabels = {
|
|
|
22
22
|
};
|
|
23
23
|
type Props = {
|
|
24
24
|
items: NotificationItem[];
|
|
25
|
+
/**
|
|
26
|
+
* The true unread count (3.6), for a list that holds only the latest page: it drives the badge,
|
|
27
|
+
* the bell's label and "mark all read". Counted from `items` when omitted.
|
|
28
|
+
*/
|
|
29
|
+
unreadCount?: number;
|
|
25
30
|
/** A notification was opened. Without it the rows are plain text. */
|
|
26
31
|
onItemSelect?: (item: NotificationItem) => void;
|
|
27
32
|
/** Shows a "mark read" button on each unread notification. */
|
|
@@ -40,6 +45,6 @@ type Props = {
|
|
|
40
45
|
testId?: string;
|
|
41
46
|
};
|
|
42
47
|
/** Bell with an unread badge and a panel of notifications grouped by day (3.1). Presentational. */
|
|
43
|
-
declare const NotificationCenter: ({ items, onItemSelect, onMarkRead, onMarkAllRead, isOpen, onOpenChange, formatDay, formatTime, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element;
|
|
48
|
+
declare const NotificationCenter: ({ items, unreadCount, onItemSelect, onMarkRead, onMarkAllRead, isOpen, onOpenChange, formatDay, formatTime, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element;
|
|
44
49
|
declare const _default: typeof NotificationCenter;
|
|
45
50
|
export default _default;
|
|
@@ -22,6 +22,11 @@ export type NotificationCenterLabels = {
|
|
|
22
22
|
};
|
|
23
23
|
type Props = {
|
|
24
24
|
items: NotificationItem[];
|
|
25
|
+
/**
|
|
26
|
+
* The true unread count (3.6), for a list that holds only the latest page: it drives the badge,
|
|
27
|
+
* the bell's label and "mark all read". Counted from `items` when omitted.
|
|
28
|
+
*/
|
|
29
|
+
unreadCount?: number;
|
|
25
30
|
/** A notification was opened. Without it the rows are plain text. */
|
|
26
31
|
onItemSelect?: (item: NotificationItem) => void;
|
|
27
32
|
/** Shows a "mark read" button on each unread notification. */
|
|
@@ -40,6 +45,6 @@ type Props = {
|
|
|
40
45
|
testId?: string;
|
|
41
46
|
};
|
|
42
47
|
/** Bell with an unread badge and a panel of notifications grouped by day (3.1). Presentational. */
|
|
43
|
-
declare const NotificationCenter: ({ items, onItemSelect, onMarkRead, onMarkAllRead, isOpen, onOpenChange, formatDay, formatTime, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element;
|
|
48
|
+
declare const NotificationCenter: ({ items, unreadCount, onItemSelect, onMarkRead, onMarkAllRead, isOpen, onOpenChange, formatDay, formatTime, labels: labelProps, className, testId, }: Props) => import("react").JSX.Element;
|
|
44
49
|
declare const _default: typeof NotificationCenter;
|
|
45
50
|
export default _default;
|
|
@@ -1,109 +1,110 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as r, jsx as
|
|
2
|
+
import { jsxs as r, jsx as a, Fragment as S } from "react/jsx-runtime";
|
|
3
3
|
import { memo as z, useId as L } from "react";
|
|
4
|
-
import { BellFill as I, Check2 as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import { BellFill as I, Check2 as O } from "react-bootstrap-icons";
|
|
5
|
+
import U from "../../enums/ui-size.enum.js";
|
|
6
|
+
import j from "../../enums/ui-variant.enum.js";
|
|
7
7
|
import { cx as f } from "../../helpers/class-name.helper.js";
|
|
8
|
-
import { named as
|
|
9
|
-
import { resolveLabel as d, resolveFormatter as
|
|
10
|
-
import { useUi as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
8
|
+
import { named as G } from "../../helpers/component.helper.js";
|
|
9
|
+
import { resolveLabel as d, resolveFormatter as H } from "../../helpers/label.helper.js";
|
|
10
|
+
import { useUi as T } from "../../theme/context.js";
|
|
11
|
+
import Y from "../Button/index.js";
|
|
12
|
+
import x from "../IconButton/index.js";
|
|
13
|
+
import E from "../Popover/index.js";
|
|
14
14
|
const t = {"panel":"ui-panel-5SyKG","srOnly":"ui-srOnly-RIBgB","bell":"ui-bell-eoWEW","badge":"ui-badge-f-M5o","header":"ui-header-XVQsI","heading":"ui-heading-coSaJ","list":"ui-list-qhaa9","day":"ui-day-q8cob","items":"ui-items-Cy4JF","item":"ui-item-Gx5xM","item__main":"ui-item__main-YzJ2w","item__main--button":"ui-item__main--button-0gQh7","item--unread":"ui-item--unread-LYQ9H","title":"ui-title-vMVcE","icon":"ui-icon-xOfOg","body":"ui-body-xDRoI","description":"ui-description-SuXFu","time":"ui-time-k0R6i","empty":"ui-empty-WTfI4","empty__icon":"ui-empty__icon-03css"};
|
|
15
|
-
const
|
|
16
|
-
const m = /* @__PURE__ */ new Map(), N = l.map((
|
|
17
|
-
for (const
|
|
18
|
-
const
|
|
19
|
-
y.items.push(
|
|
15
|
+
const F = 99, u = (l) => `${l.getFullYear()}-${l.getMonth()}-${l.getDate()}`, K = (l) => {
|
|
16
|
+
const m = /* @__PURE__ */ new Map(), N = l.map((i) => ({ item: i, date: new Date(i.date) })).sort((i, o) => o.date.getTime() - i.date.getTime());
|
|
17
|
+
for (const i of N) {
|
|
18
|
+
const o = u(i.date), y = m.get(o) ?? { key: o, date: i.date, items: [] };
|
|
19
|
+
y.items.push(i), m.set(o, y);
|
|
20
20
|
}
|
|
21
21
|
return [...m.values()];
|
|
22
|
-
},
|
|
22
|
+
}, P = ({
|
|
23
23
|
items: l,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
unreadCount: m,
|
|
25
|
+
onItemSelect: N,
|
|
26
|
+
onMarkRead: i,
|
|
27
|
+
onMarkAllRead: o,
|
|
28
|
+
isOpen: y,
|
|
29
|
+
onOpenChange: w,
|
|
29
30
|
formatDay: g,
|
|
30
31
|
formatTime: b,
|
|
31
|
-
labels:
|
|
32
|
-
className:
|
|
33
|
-
testId:
|
|
32
|
+
labels: R,
|
|
33
|
+
className: $,
|
|
34
|
+
testId: B
|
|
34
35
|
}) => {
|
|
35
|
-
const { labels: p } =
|
|
36
|
-
const
|
|
37
|
-
return u(e) === u(
|
|
36
|
+
const { labels: p } = T(), D = L(), h = m === void 0 ? l.filter((e) => !e.isRead).length : Math.max(0, Math.floor(m)), c = { ...p == null ? void 0 : p.notificationCenter, ...R }, C = d("NotificationCenter.labels.title", c.title), v = p == null ? void 0 : p.locale, M = (e) => {
|
|
37
|
+
const n = /* @__PURE__ */ new Date(), s = new Date(n.getFullYear(), n.getMonth(), n.getDate() - 1);
|
|
38
|
+
return u(e) === u(n) ? d("NotificationCenter.labels.today", c.today) : u(e) === u(s) ? d("NotificationCenter.labels.yesterday", c.yesterday) : (g == null ? void 0 : g(e)) ?? new Intl.DateTimeFormat(v, { day: "numeric", month: "long", year: "numeric" }).format(
|
|
38
39
|
e
|
|
39
40
|
);
|
|
40
|
-
}, A = (e) => (b == null ? void 0 : b(e)) ?? new Intl.DateTimeFormat(
|
|
41
|
-
e.icon && /* @__PURE__ */
|
|
41
|
+
}, A = (e) => (b == null ? void 0 : b(e)) ?? new Intl.DateTimeFormat(v, { hour: "2-digit", minute: "2-digit" }).format(e), k = (e, n) => /* @__PURE__ */ r(S, { children: [
|
|
42
|
+
e.icon && /* @__PURE__ */ a("span", { "aria-hidden": !0, className: t.icon, children: e.icon }),
|
|
42
43
|
/* @__PURE__ */ r("span", { className: t.body, children: [
|
|
43
44
|
/* @__PURE__ */ r("span", { className: t.title, children: [
|
|
44
45
|
!e.isRead && /* @__PURE__ */ r("span", { className: t.srOnly, children: [
|
|
45
|
-
d("NotificationCenter.labels.unread",
|
|
46
|
+
d("NotificationCenter.labels.unread", c.unread),
|
|
46
47
|
":",
|
|
47
48
|
" "
|
|
48
49
|
] }),
|
|
49
50
|
e.title
|
|
50
51
|
] }),
|
|
51
|
-
e.description && /* @__PURE__ */
|
|
52
|
-
/* @__PURE__ */
|
|
52
|
+
e.description && /* @__PURE__ */ a("span", { className: t.description, children: e.description }),
|
|
53
|
+
/* @__PURE__ */ a("time", { className: t.time, dateTime: n.toISOString(), children: A(n) })
|
|
53
54
|
] })
|
|
54
55
|
] });
|
|
55
56
|
return /* @__PURE__ */ r(
|
|
56
|
-
|
|
57
|
+
E,
|
|
57
58
|
{
|
|
58
59
|
label: C,
|
|
59
60
|
align: "end",
|
|
60
|
-
isOpen:
|
|
61
|
-
onOpenChange:
|
|
62
|
-
className: f(t.panel,
|
|
63
|
-
testId:
|
|
64
|
-
trigger: /* @__PURE__ */
|
|
65
|
-
|
|
61
|
+
isOpen: y,
|
|
62
|
+
onOpenChange: w,
|
|
63
|
+
className: f(t.panel, $),
|
|
64
|
+
testId: B,
|
|
65
|
+
trigger: /* @__PURE__ */ a(
|
|
66
|
+
x,
|
|
66
67
|
{
|
|
67
68
|
icon: /* @__PURE__ */ r("span", { className: t.bell, children: [
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
h > 0 && /* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ a(I, { "aria-hidden": !0 }),
|
|
70
|
+
h > 0 && /* @__PURE__ */ a("span", { "aria-hidden": !0, className: t.badge, children: h > F ? `${F}+` : h })
|
|
70
71
|
] }),
|
|
71
|
-
label:
|
|
72
|
+
label: H("NotificationCenter.labels.trigger", c.trigger, h)
|
|
72
73
|
}
|
|
73
74
|
),
|
|
74
75
|
children: [
|
|
75
76
|
/* @__PURE__ */ r("div", { className: t.header, children: [
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
h > 0 &&
|
|
77
|
+
/* @__PURE__ */ a("p", { className: t.heading, children: C }),
|
|
78
|
+
h > 0 && o && /* @__PURE__ */ a(Y, { variant: j.GHOST, size: U.SMALL, onClick: o, children: d("NotificationCenter.labels.markAllRead", c.markAllRead) })
|
|
78
79
|
] }),
|
|
79
80
|
l.length === 0 ? /* @__PURE__ */ r("p", { className: t.empty, children: [
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
d("NotificationCenter.labels.empty",
|
|
82
|
-
] }) : /* @__PURE__ */
|
|
83
|
-
const
|
|
84
|
-
return /* @__PURE__ */ r("div", { role: "group", "aria-labelledby":
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ a(I, { "aria-hidden": !0, className: t.empty__icon }),
|
|
82
|
+
d("NotificationCenter.labels.empty", c.empty)
|
|
83
|
+
] }) : /* @__PURE__ */ a("div", { className: t.list, children: K(l).map((e) => {
|
|
84
|
+
const n = `${D}-${e.key}`;
|
|
85
|
+
return /* @__PURE__ */ r("div", { role: "group", "aria-labelledby": n, children: [
|
|
86
|
+
/* @__PURE__ */ a("p", { id: n, className: t.day, children: M(e.date) }),
|
|
87
|
+
/* @__PURE__ */ a("ul", { className: t.items, children: e.items.map(({ item: s, date: _ }) => /* @__PURE__ */ r(
|
|
87
88
|
"li",
|
|
88
89
|
{
|
|
89
90
|
className: f(t.item, !s.isRead && t["item--unread"]),
|
|
90
91
|
children: [
|
|
91
|
-
|
|
92
|
+
N ? /* @__PURE__ */ a(
|
|
92
93
|
"button",
|
|
93
94
|
{
|
|
94
95
|
type: "button",
|
|
95
96
|
className: f(t.item__main, t["item__main--button"]),
|
|
96
|
-
onClick: () =>
|
|
97
|
-
children:
|
|
97
|
+
onClick: () => N(s),
|
|
98
|
+
children: k(s, _)
|
|
98
99
|
}
|
|
99
|
-
) : /* @__PURE__ */
|
|
100
|
-
!s.isRead &&
|
|
101
|
-
|
|
100
|
+
) : /* @__PURE__ */ a("div", { className: t.item__main, children: k(s, _) }),
|
|
101
|
+
!s.isRead && i && /* @__PURE__ */ a(
|
|
102
|
+
x,
|
|
102
103
|
{
|
|
103
|
-
icon: /* @__PURE__ */
|
|
104
|
-
label: d("NotificationCenter.labels.markRead",
|
|
104
|
+
icon: /* @__PURE__ */ a(O, { "aria-hidden": !0 }),
|
|
105
|
+
label: d("NotificationCenter.labels.markRead", c.markRead),
|
|
105
106
|
size: "sm",
|
|
106
|
-
onClick: () =>
|
|
107
|
+
onClick: () => i(s)
|
|
107
108
|
}
|
|
108
109
|
)
|
|
109
110
|
]
|
|
@@ -115,10 +116,10 @@ const w = 99, u = (l) => `${l.getFullYear()}-${l.getMonth()}-${l.getDate()}`, E
|
|
|
115
116
|
]
|
|
116
117
|
}
|
|
117
118
|
);
|
|
118
|
-
},
|
|
119
|
-
/* @__PURE__ */
|
|
119
|
+
}, le = /* @__PURE__ */ z(
|
|
120
|
+
/* @__PURE__ */ G(P, "NotificationCenter")
|
|
120
121
|
);
|
|
121
122
|
export {
|
|
122
|
-
|
|
123
|
+
le as default
|
|
123
124
|
};
|
|
124
125
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/NotificationCenter/index.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type ReactNode, useId } from 'react';\n\nimport { BellFill, Check2 } from 'react-bootstrap-icons';\n\nimport UISize from '../../enums/ui-size.enum';\nimport UIVariant from '../../enums/ui-variant.enum';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\nimport Button from '../Button';\nimport IconButton from '../IconButton';\nimport Popover from '../Popover';\n\nimport styles from './index.module.scss';\n\nexport type NotificationItem = {\n id: string;\n title: string;\n description?: ReactNode;\n /** When it happened: a `Date`, an ISO string or epoch milliseconds. */\n date: Date | string | number;\n isRead?: boolean;\n /** A leading icon (the kind of notification). */\n icon?: ReactNode;\n};\n\nexport type NotificationCenterLabels = {\n trigger: Formatter<[unread: number]>;\n title: string;\n markAllRead: string;\n markRead: string;\n empty: string;\n unread: string;\n today: string;\n yesterday: string;\n};\n\ntype Props = {\n items: NotificationItem[];\n /** A notification was opened. Without it the rows are plain text. */\n onItemSelect?: (item: NotificationItem) => void;\n /** Shows a \"mark read\" button on each unread notification. */\n onMarkRead?: (item: NotificationItem) => void;\n /** Shows \"mark all read\" while something is unread. */\n onMarkAllRead?: () => void;\n /** Controlled panel; uncontrolled when omitted. */\n isOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n /** Heading of a day older than yesterday; the day and month in `labels.locale` by default. */\n formatDay?: (date: Date) => string;\n /** Time of one notification; hours and minutes in `labels.locale` by default. */\n formatTime?: (date: Date) => string;\n labels?: Partial<NotificationCenterLabels>;\n className?: string;\n testId?: string;\n};\n\n/* Above this the badge reads \"99+\": a wider badge would cover the bell. */\nconst BADGE_MAX = 99;\n\nconst dayKey = (date: Date): string => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;\n\ntype DayGroup = { key: string; date: Date; items: { item: NotificationItem; date: Date }[] };\n\n/** Newest first, one group per local calendar day. */\nconst groupByDay = (items: NotificationItem[]): DayGroup[] => {\n const groups = new Map<string, DayGroup>();\n const dated = items\n .map(item => ({ item, date: new Date(item.date) }))\n .sort((a, b) => b.date.getTime() - a.date.getTime());\n\n for (const entry of dated) {\n const key = dayKey(entry.date);\n const group = groups.get(key) ?? { key, date: entry.date, items: [] };\n group.items.push(entry);\n groups.set(key, group);\n }\n\n return [...groups.values()];\n};\n\n/** Bell with an unread badge and a panel of notifications grouped by day (3.1). Presentational. */\nconst NotificationCenter = ({\n items,\n onItemSelect,\n onMarkRead,\n onMarkAllRead,\n isOpen,\n onOpenChange,\n formatDay,\n formatTime,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const baseId = useId();\n const unread = items.filter(item => !item.isRead).length;\n const text = { ...config?.notificationCenter, ...labelProps };\n\n const title = resolveLabel('NotificationCenter.labels.title', text.title);\n const locale = config?.locale;\n\n const dayHeading = (date: Date): string => {\n const today = new Date();\n const yesterday = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1);\n if (dayKey(date) === dayKey(today))\n return resolveLabel('NotificationCenter.labels.today', text.today);\n if (dayKey(date) === dayKey(yesterday))\n return resolveLabel('NotificationCenter.labels.yesterday', text.yesterday);\n\n return (\n formatDay?.(date) ??\n new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' }).format(\n date,\n )\n );\n };\n\n const time = (date: Date): string =>\n formatTime?.(date) ??\n new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit' }).format(date);\n\n const renderContent = (item: NotificationItem, date: Date) => (\n <>\n {item.icon && (\n <span aria-hidden className={styles.icon}>\n {item.icon}\n </span>\n )}\n <span className={styles.body}>\n <span className={styles.title}>\n {!item.isRead && (\n <span className={styles.srOnly}>\n {resolveLabel('NotificationCenter.labels.unread', text.unread)}:{' '}\n </span>\n )}\n {item.title}\n </span>\n {item.description && <span className={styles.description}>{item.description}</span>}\n <time className={styles.time} dateTime={date.toISOString()}>\n {time(date)}\n </time>\n </span>\n </>\n );\n\n return (\n <Popover\n label={title}\n align=\"end\"\n isOpen={isOpen}\n onOpenChange={onOpenChange}\n className={cx(styles.panel, className)}\n testId={testId}\n trigger={\n <IconButton\n icon={\n <span className={styles.bell}>\n <BellFill aria-hidden />\n {unread > 0 && (\n <span aria-hidden className={styles.badge}>\n {unread > BADGE_MAX ? `${BADGE_MAX}+` : unread}\n </span>\n )}\n </span>\n }\n label={resolveFormatter('NotificationCenter.labels.trigger', text.trigger, unread)}\n />\n }\n >\n <div className={styles.header}>\n <p className={styles.heading}>{title}</p>\n {unread > 0 && onMarkAllRead && (\n <Button variant={UIVariant.GHOST} size={UISize.SMALL} onClick={onMarkAllRead}>\n {resolveLabel('NotificationCenter.labels.markAllRead', text.markAllRead)}\n </Button>\n )}\n </div>\n\n {items.length === 0 ? (\n <p className={styles.empty}>\n <BellFill aria-hidden className={styles.empty__icon} />\n {resolveLabel('NotificationCenter.labels.empty', text.empty)}\n </p>\n ) : (\n <div className={styles.list}>\n {groupByDay(items).map(group => {\n const headingId = `${baseId}-${group.key}`;\n\n return (\n <div key={group.key} role=\"group\" aria-labelledby={headingId}>\n <p id={headingId} className={styles.day}>\n {dayHeading(group.date)}\n </p>\n <ul className={styles.items}>\n {group.items.map(({ item, date }) => (\n <li\n key={item.id}\n className={cx(styles.item, !item.isRead && styles['item--unread'])}\n >\n {onItemSelect ? (\n <button\n type=\"button\"\n className={cx(styles.item__main, styles['item__main--button'])}\n onClick={() => onItemSelect(item)}\n >\n {renderContent(item, date)}\n </button>\n ) : (\n <div className={styles.item__main}>{renderContent(item, date)}</div>\n )}\n {!item.isRead && onMarkRead && (\n <IconButton\n icon={<Check2 aria-hidden />}\n label={resolveLabel('NotificationCenter.labels.markRead', text.markRead)}\n size=\"sm\"\n onClick={() => onMarkRead(item)}\n />\n )}\n </li>\n ))}\n </ul>\n </div>\n );\n })}\n </div>\n )}\n </Popover>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(NotificationCenter, 'NotificationCenter'),\n) as typeof NotificationCenter;\n"],"names":["BADGE_MAX","dayKey","date","groupByDay","items","groups","dated","item","b","entry","key","group","NotificationCenter","onItemSelect","onMarkRead","onMarkAllRead","isOpen","onOpenChange","formatDay","formatTime","labelProps","className","testId","config","useUi","baseId","useId","unread","text","title","resolveLabel","locale","dayHeading","today","yesterday","time","renderContent","jsxs","Fragment","styles","jsx","Popover","cx","IconButton","BellFill","resolveFormatter","Button","UIVariant","UISize","headingId","Check2","index","memo","named"],"mappings":";;;;;;;;;;;;;;AA6DA,MAAMA,IAAY,IAEZC,IAAS,CAACC,MAAuB,GAAGA,EAAK,YAAA,CAAa,IAAIA,EAAK,SAAA,CAAU,IAAIA,EAAK,SAAS,IAK3FC,IAAa,CAACC,MAA0C;AAC5D,QAAMC,wBAAa,IAAA,GACbC,IAAQF,EACX,IAAI,CAAAG,OAAS,EAAE,MAAAA,GAAM,MAAM,IAAI,KAAKA,EAAK,IAAI,EAAA,EAA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,YACA,gBAAA6B,EAAC,MAAA,EAAG,WAAWD,EAAO,OACnB,UAAA5B,EAAM,MAAM,IAAI,CAAC,EAAE,MAAAJ,GAAM,MAAAL,EAAA,MACxB,gBAAAmC;AAAA,cAAC;AAAA,cAAA;AAAA,gBAEC,WAAWK,EAAGH,EAAO,MAAM,CAAChC,EAAK,UAAUgC,EAAO,cAAc,CAAC;AAAA,gBAEhE,UAAA;AAAA,kBAAA1B,IACC,gBAAA2B;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC,MAAK;AAAA,sBACL,WAAWE,EAAGH,EAAO,YAAYA,EAAO,oBAAoB,CAAC;AAAA,sBAC7D,SAAS,MAAM1B,EAAaN,CAAI;AAAA,sBAE/B,UAAA6B,EAAc7B,GAAML,CAAI;AAAA,oBAAA;AAAA,kBAAA,sBAG1B,OAAA,EAAI,WAAWqC,EAAO,YAAa,UAAAH,EAAc7B,GAAML,CAAI,EAAA,CAAE;AAAA,kBAE/D,CAACK,EAAK,UAAUO,KACf,gBAAA0B;AAAA,oBAACG;AAAA,oBAAA;AAAA,sBACC,MAAM,gBAAAH,EAACU,GAAA,EAAO,eAAW,GAAA,CAAC;AAAA,sBAC1B,OAAOpB,EAAa,sCAAsCF,EAAK,QAAQ;AAAA,sBACvE,MAAK;AAAA,sBACL,SAAS,MAAMd,EAAWP,CAAI;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAChC;AAAA,cAAA;AAAA,cApBGA,EAAK;AAAA,YAAA,CAuBb,EAAA,CACH;AAAA,UAAA,EAAA,GA/BQI,EAAM,GAgChB;AAAA,QAEJ,CAAC,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,GAEAwC,KAA6B,gBAAAC;AAAA,EACb,gBAAAC,EAAMzC,GAAoB,oBAAoB;AAC9D;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/NotificationCenter/index.tsx"],"sourcesContent":["'use client';\n\nimport { memo, type ReactNode, useId } from 'react';\n\nimport { BellFill, Check2 } from 'react-bootstrap-icons';\n\nimport UISize from '../../enums/ui-size.enum';\nimport UIVariant from '../../enums/ui-variant.enum';\nimport { cx } from '../../helpers/class-name.helper';\nimport { named } from '../../helpers/component.helper';\nimport { resolveFormatter, resolveLabel } from '../../helpers/label.helper';\nimport { useUi } from '../../theme/context';\nimport type { Formatter } from '../../types/theme.type';\nimport Button from '../Button';\nimport IconButton from '../IconButton';\nimport Popover from '../Popover';\n\nimport styles from './index.module.scss';\n\nexport type NotificationItem = {\n id: string;\n title: string;\n description?: ReactNode;\n /** When it happened: a `Date`, an ISO string or epoch milliseconds. */\n date: Date | string | number;\n isRead?: boolean;\n /** A leading icon (the kind of notification). */\n icon?: ReactNode;\n};\n\nexport type NotificationCenterLabels = {\n trigger: Formatter<[unread: number]>;\n title: string;\n markAllRead: string;\n markRead: string;\n empty: string;\n unread: string;\n today: string;\n yesterday: string;\n};\n\ntype Props = {\n items: NotificationItem[];\n /**\n * The true unread count (3.6), for a list that holds only the latest page: it drives the badge,\n * the bell's label and \"mark all read\". Counted from `items` when omitted.\n */\n unreadCount?: number;\n /** A notification was opened. Without it the rows are plain text. */\n onItemSelect?: (item: NotificationItem) => void;\n /** Shows a \"mark read\" button on each unread notification. */\n onMarkRead?: (item: NotificationItem) => void;\n /** Shows \"mark all read\" while something is unread. */\n onMarkAllRead?: () => void;\n /** Controlled panel; uncontrolled when omitted. */\n isOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n /** Heading of a day older than yesterday; the day and month in `labels.locale` by default. */\n formatDay?: (date: Date) => string;\n /** Time of one notification; hours and minutes in `labels.locale` by default. */\n formatTime?: (date: Date) => string;\n labels?: Partial<NotificationCenterLabels>;\n className?: string;\n testId?: string;\n};\n\n/* Above this the badge reads \"99+\": a wider badge would cover the bell. */\nconst BADGE_MAX = 99;\n\nconst dayKey = (date: Date): string => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;\n\ntype DayGroup = { key: string; date: Date; items: { item: NotificationItem; date: Date }[] };\n\n/** Newest first, one group per local calendar day. */\nconst groupByDay = (items: NotificationItem[]): DayGroup[] => {\n const groups = new Map<string, DayGroup>();\n const dated = items\n .map(item => ({ item, date: new Date(item.date) }))\n .sort((a, b) => b.date.getTime() - a.date.getTime());\n\n for (const entry of dated) {\n const key = dayKey(entry.date);\n const group = groups.get(key) ?? { key, date: entry.date, items: [] };\n group.items.push(entry);\n groups.set(key, group);\n }\n\n return [...groups.values()];\n};\n\n/** Bell with an unread badge and a panel of notifications grouped by day (3.1). Presentational. */\nconst NotificationCenter = ({\n items,\n unreadCount,\n onItemSelect,\n onMarkRead,\n onMarkAllRead,\n isOpen,\n onOpenChange,\n formatDay,\n formatTime,\n labels: labelProps,\n className,\n testId,\n}: Props) => {\n const { labels: config } = useUi();\n const baseId = useId();\n const unread =\n unreadCount === undefined\n ? items.filter(item => !item.isRead).length\n : Math.max(0, Math.floor(unreadCount));\n const text = { ...config?.notificationCenter, ...labelProps };\n\n const title = resolveLabel('NotificationCenter.labels.title', text.title);\n const locale = config?.locale;\n\n const dayHeading = (date: Date): string => {\n const today = new Date();\n const yesterday = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1);\n if (dayKey(date) === dayKey(today))\n return resolveLabel('NotificationCenter.labels.today', text.today);\n if (dayKey(date) === dayKey(yesterday))\n return resolveLabel('NotificationCenter.labels.yesterday', text.yesterday);\n\n return (\n formatDay?.(date) ??\n new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric' }).format(\n date,\n )\n );\n };\n\n const time = (date: Date): string =>\n formatTime?.(date) ??\n new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit' }).format(date);\n\n const renderContent = (item: NotificationItem, date: Date) => (\n <>\n {item.icon && (\n <span aria-hidden className={styles.icon}>\n {item.icon}\n </span>\n )}\n <span className={styles.body}>\n <span className={styles.title}>\n {!item.isRead && (\n <span className={styles.srOnly}>\n {resolveLabel('NotificationCenter.labels.unread', text.unread)}:{' '}\n </span>\n )}\n {item.title}\n </span>\n {item.description && <span className={styles.description}>{item.description}</span>}\n <time className={styles.time} dateTime={date.toISOString()}>\n {time(date)}\n </time>\n </span>\n </>\n );\n\n return (\n <Popover\n label={title}\n align=\"end\"\n isOpen={isOpen}\n onOpenChange={onOpenChange}\n className={cx(styles.panel, className)}\n testId={testId}\n trigger={\n <IconButton\n icon={\n <span className={styles.bell}>\n <BellFill aria-hidden />\n {unread > 0 && (\n <span aria-hidden className={styles.badge}>\n {unread > BADGE_MAX ? `${BADGE_MAX}+` : unread}\n </span>\n )}\n </span>\n }\n label={resolveFormatter('NotificationCenter.labels.trigger', text.trigger, unread)}\n />\n }\n >\n <div className={styles.header}>\n <p className={styles.heading}>{title}</p>\n {unread > 0 && onMarkAllRead && (\n <Button variant={UIVariant.GHOST} size={UISize.SMALL} onClick={onMarkAllRead}>\n {resolveLabel('NotificationCenter.labels.markAllRead', text.markAllRead)}\n </Button>\n )}\n </div>\n\n {items.length === 0 ? (\n <p className={styles.empty}>\n <BellFill aria-hidden className={styles.empty__icon} />\n {resolveLabel('NotificationCenter.labels.empty', text.empty)}\n </p>\n ) : (\n <div className={styles.list}>\n {groupByDay(items).map(group => {\n const headingId = `${baseId}-${group.key}`;\n\n return (\n <div key={group.key} role=\"group\" aria-labelledby={headingId}>\n <p id={headingId} className={styles.day}>\n {dayHeading(group.date)}\n </p>\n <ul className={styles.items}>\n {group.items.map(({ item, date }) => (\n <li\n key={item.id}\n className={cx(styles.item, !item.isRead && styles['item--unread'])}\n >\n {onItemSelect ? (\n <button\n type=\"button\"\n className={cx(styles.item__main, styles['item__main--button'])}\n onClick={() => onItemSelect(item)}\n >\n {renderContent(item, date)}\n </button>\n ) : (\n <div className={styles.item__main}>{renderContent(item, date)}</div>\n )}\n {!item.isRead && onMarkRead && (\n <IconButton\n icon={<Check2 aria-hidden />}\n label={resolveLabel('NotificationCenter.labels.markRead', text.markRead)}\n size=\"sm\"\n onClick={() => onMarkRead(item)}\n />\n )}\n </li>\n ))}\n </ul>\n </div>\n );\n })}\n </div>\n )}\n </Popover>\n );\n};\n\nexport default /*#__PURE__*/ memo(\n /*#__PURE__*/ named(NotificationCenter, 'NotificationCenter'),\n) as typeof NotificationCenter;\n"],"names":["BADGE_MAX","dayKey","date","groupByDay","items","groups","dated","item","a","b","entry","key","group","NotificationCenter","unreadCount","onItemSelect","onMarkRead","onMarkAllRead","isOpen","onOpenChange","formatDay","formatTime","labelProps","className","testId","config","useUi","baseId","useId","unread","text","title","resolveLabel","locale","dayHeading","today","yesterday","time","renderContent","jsxs","Fragment","styles","jsx","Popover","cx","IconButton","BellFill","resolveFormatter","Button","UIVariant","UISize","headingId","Check2","index","memo","named"],"mappings":";;;;;;;;;;;;;;AAkEA,MAAMA,IAAY,IAEZC,IAAS,CAACC,MAAuB,GAAGA,EAAK,YAAA,CAAa,IAAIA,EAAK,SAAA,CAAU,IAAIA,EAAK,SAAS,IAK3FC,IAAa,CAACC,MAA0C;AAC5D,QAAMC,wBAAa,IAAA,GACbC,IAAQF,EACX,IAAI,CAAAG,OAAS,EAAE,MAAAA,GAAM,MAAM,IAAI,KAAKA,EAAK,IAAI,EAAA,EAAI,EACjD,KAAK,CAACC,GAAGC,MAAMA,EAAE,KAAK,YAAYD,EAAE,KAAK,QAAA,CAAS;AAErD,aAAWE,KAASJ,GAAO;AACzB,UAAMK,IAAMV,EAAOS,EAAM,IAAI,GACvBE,IAAQP,EAAO,IAAIM,CAAG,KAAK,EAAE,KAAAA,GAAK,MAAMD,EAAM,MAAM,OAAO,CAAA,EAAC;AAClE,IAAAE,EAAM,MAAM,KAAKF,CAAK,GACtBL,EAAO,IAAIM,GAAKC,CAAK;AAAA,EACvB;AAEA,SAAO,CAAC,GAAGP,EAAO,QAAQ;AAC5B,GAGMQ,IAAqB,CAAC;AAAA,EAC1B,OAAAT;AAAA,EACA,aAAAU;AAAA,EACA,cAAAC;AAAA,EACA,YAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;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,EAAaR,CAAI;AAAA,sBAE/B,UAAA+B,EAAc/B,GAAML,CAAI;AAAA,oBAAA;AAAA,kBAAA,sBAG1B,OAAA,EAAI,WAAWuC,EAAO,YAAa,UAAAH,EAAc/B,GAAML,CAAI,EAAA,CAAE;AAAA,kBAE/D,CAACK,EAAK,UAAUS,KACf,gBAAA0B;AAAA,oBAACG;AAAA,oBAAA;AAAA,sBACC,MAAM,gBAAAH,EAACU,GAAA,EAAO,eAAW,GAAA,CAAC;AAAA,sBAC1B,OAAOpB,EAAa,sCAAsCF,EAAK,QAAQ;AAAA,sBACvE,MAAK;AAAA,sBACL,SAAS,MAAMd,EAAWT,CAAI;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAChC;AAAA,cAAA;AAAA,cApBGA,EAAK;AAAA,YAAA,CAuBb,EAAA,CACH;AAAA,UAAA,EAAA,GA/BQK,EAAM,GAgChB;AAAA,QAEJ,CAAC,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,GAEAyC,KAA6B,gBAAAC;AAAA,EACb,gBAAAC,EAAM1C,GAAoB,oBAAoB;AAC9D;"}
|
package/build/styles.css
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
@layer ui{.ui-checkbox-FaFCj{display:flex;align-items:flex-start;gap:var(--hd-space-3);cursor:pointer}.ui-checkbox__input-nTHne{-webkit-appearance:none;-moz-appearance:none;appearance:none;display:inline-grid;place-content:center;flex-shrink:0;width:18px;height:18px;margin:0;border:1.5px solid var(--hd-border-control);border-radius:var(--hd-radius-xs);background-color:var(--hd-bg-surface);cursor:pointer;transition:background-color var(--hd-duration-fast) var(--hd-ease-standard),border-color var(--hd-duration-fast) var(--hd-ease-standard)}.ui-checkbox__input-nTHne:before{content:"";width:10px;height:10px;background-color:var(--hd-on-primary);scale:0;transition:scale var(--hd-duration-fast) var(--hd-ease-standard);clip-path:polygon(14% 44%,0 65%,50% 100%,100% 16%,80% 0%,43% 62%)}.ui-checkbox__input-nTHne:hover:not(:disabled){border-color:var(--hd-text-2)}.ui-checkbox__input-nTHne[aria-invalid=true]:not(:disabled){border-color:var(--hd-danger-solid)}.ui-checkbox__input-nTHne:checked,.ui-checkbox__input-nTHne:indeterminate{background-color:var(--hd-primary);border-color:var(--hd-primary)}.ui-checkbox__input-nTHne:checked:before,.ui-checkbox__input-nTHne:indeterminate:before{scale:1}.ui-checkbox__input-nTHne:checked:hover:not(:disabled),.ui-checkbox__input-nTHne:indeterminate:hover:not(:disabled){background-color:var(--hd-primary-hover);border-color:var(--hd-primary-hover)}.ui-checkbox__input-nTHne:indeterminate:before{clip-path:inset(40% 5%)}.ui-checkbox__input-nTHne:disabled{background-color:var(--hd-bg-disabled);border-color:var(--hd-border-strong);cursor:not-allowed}.ui-checkbox__input-nTHne:checked:disabled,.ui-checkbox__input-nTHne:indeterminate:disabled{background-color:var(--hd-text-disabled);border-color:transparent}.ui-checkbox__input-nTHne:checked:disabled:before,.ui-checkbox__input-nTHne:indeterminate:disabled:before{background-color:var(--hd-bg-surface)}@media (prefers-reduced-motion: reduce){.ui-checkbox__input-nTHne{transition:none}.ui-checkbox__input-nTHne:before{transition:none}}@media (forced-colors: active){.ui-checkbox__input-nTHne{-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}.ui-checkbox__input-nTHne:before{display:none}}.ui-checkbox__input-nTHne{margin-top:2px}.ui-checkbox__input-nTHne:focus-visible{outline:var(--ui-ring-width, 2px) solid var(--ui-ring-color, var(--hd-focus));outline-offset:var(--ui-ring-offset, 2px)}.ui-checkbox__body-VAEW2{display:flex;flex-direction:column;gap:var(--hd-space-1);flex:1;min-width:0}.ui-checkbox__label-sSNZY{font-size:var(--hd-type-small-size);line-height:var(--hd-type-body-line-height);color:var(--hd-text)}.ui-checkbox__hint-ish-J{font-size:var(--hd-type-caption-size);color:var(--hd-text-2);line-height:var(--hd-type-body-line-height)}.ui-checkbox__error-J6StW{display:flex;align-items:center;gap:var(--hd-space-1);margin:0;font-size:var(--hd-type-caption-size);font-weight:var(--hd-font-weight-medium);line-height:var(--hd-type-body-line-height);color:var(--hd-danger-fg)}.ui-checkbox__error-J6StW>svg{flex-shrink:0;font-size:14px}}
|
|
34
34
|
|
|
35
|
-
@charset "UTF-8";@layer ui{.ui-chip--NLgU{position:relative}.ui-chip--NLgU:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:max(100%,44px);height:max(100%,44px)}.ui-chip--NLgU{display:inline-flex;align-items:center;justify-content:center;gap:var(--hd-space-2);background-color:var(--ui-chip-bg, var(--hd-bg-surface));border:1px solid var(--ui-chip-line, var(--hd-border));border-radius:var(--ui-chip-radius, var(--hd-radius-sm));color:var(--ui-chip-fg, var(--hd-text-2));font-family:var(--hd-font-body);font-weight:var(--ui-chip-weight, var(--hd-font-weight-medium));line-height:1;white-space:nowrap;cursor:pointer;text-decoration:none;transition:border-color var(--hd-duration-fast) var(--hd-ease-standard),color var(--hd-duration-fast) var(--hd-ease-standard),background-color var(--hd-duration-fast) var(--hd-ease-standard)}.ui-chip--NLgU:focus-visible{outline:var(--ui-ring-width, 2px) solid var(--ui-ring-color, var(--hd-focus));outline-offset:var(--ui-ring-offset, 2px)}.ui-chip--NLgU:hover:not(:disabled){border-color:var(--hd-border-strong);color:var(--hd-text)}.ui-chip--NLgU:disabled{background-color:var(--hd-bg-raised);border-color:var(--hd-border);cursor:not-allowed;color:var(--hd-text-3)}@media (forced-colors: active){.ui-chip--NLgU:disabled{color:GrayText;border-color:GrayText}}.ui-chip--NLgU:disabled .ui-chip__icon-IjjSb,.ui-chip--NLgU:disabled .ui-chip__count-MBGO3{color:var(--hd-text-3)}@media (forced-colors: active){.ui-chip--NLgU:disabled .ui-chip__icon-IjjSb,.ui-chip--NLgU:disabled .ui-chip__count-MBGO3{color:GrayText}}@media (prefers-reduced-motion: reduce){.ui-chip--NLgU{transition:none}}.ui-chip__icon-IjjSb{display:inline-flex;align-items:center;flex-shrink:0;font-size:.92em;color:var(--hd-text-2);transition:color var(--hd-duration-fast) var(--hd-ease-standard)}@media (prefers-reduced-motion: reduce){.ui-chip__icon-IjjSb{transition:none}}.ui-chip__label-cT4hw{overflow:hidden;text-overflow:ellipsis}.ui-chip__count-MBGO3{font-size:var(--hd-type-caption-size);font-weight:var(--hd-font-weight-semibold);color:var(--hd-text-3);font-variant-numeric:tabular-nums;flex-shrink:0}.ui-chip--sm-60H-S{font-size:var(--hd-type-caption-size);padding:var(--hd-space-2) var(--hd-space-3);min-height:32px}.ui-chip--md--yAlm{font-size:var(--hd-type-small-size);padding:var(--hd-space-2) var(--hd-space-4);min-height:40px}.ui-chip--iconOnly-5LT1h{gap:0}.ui-chip--iconOnly-5LT1h.ui-chip--sm-60H-S{width:32px;padding:0}.ui-chip--iconOnly-5LT1h.ui-chip--md--yAlm{width:40px;padding:0}.ui-chip--iconOnly-5LT1h .ui-chip__icon-IjjSb{font-size:1em}.ui-chip--selected-FdpCr{border-color:var(--ui-chip-selected-line, var(--hd-primary));color:var(--ui-chip-selected-fg, var(--hd-primary-text));background-color:var(--ui-chip-selected-bg, var(--hd-primary-soft));font-weight:var(--ui-chip-selected-weight, var(--hd-font-weight-semibold))}.ui-chip--selected-FdpCr .ui-chip__icon-IjjSb,.ui-chip--selected-FdpCr .ui-chip__count-MBGO3{color:var(--ui-chip-selected-fg, var(--hd-primary-text))}.ui-chip--selected-FdpCr:hover:not(:disabled){border-color:var(--ui-chip-selected-line, var(--hd-primary-hover));color:var(--ui-chip-selected-fg, var(--hd-primary-text));background-color:var(--ui-chip-selected-bg, var(--hd-primary-soft-hover))}.ui-chip--selected-FdpCr:disabled{border-color:var(--hd-text-3)}}
|
|
35
|
+
@charset "UTF-8";@layer ui{.ui-chip--NLgU{position:relative}.ui-chip--NLgU:after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:max(100%,44px);height:max(100%,44px)}.ui-chip--NLgU{display:inline-flex;align-items:center;justify-content:center;gap:var(--hd-space-2);background-color:var(--ui-chip-bg, var(--hd-bg-surface));border:1px solid var(--ui-chip-line, var(--hd-border));border-radius:var(--ui-chip-radius, var(--hd-radius-sm));color:var(--ui-chip-fg, var(--hd-text-2));font-family:var(--hd-font-body);font-weight:var(--ui-chip-weight, var(--hd-font-weight-medium));line-height:1;white-space:nowrap;cursor:pointer;text-decoration:none;transition:border-color var(--hd-duration-fast) var(--hd-ease-standard),color var(--hd-duration-fast) var(--hd-ease-standard),background-color var(--hd-duration-fast) var(--hd-ease-standard)}.ui-chip--NLgU:focus-visible{outline:var(--ui-ring-width, 2px) solid var(--ui-ring-color, var(--hd-focus));outline-offset:var(--ui-ring-offset, 2px)}.ui-chip--NLgU:hover:not(:disabled){border-color:var(--hd-border-strong);color:var(--hd-text)}.ui-chip--NLgU:disabled{background-color:var(--hd-bg-raised);border-color:var(--hd-border);cursor:not-allowed;color:var(--hd-text-3)}@media (forced-colors: active){.ui-chip--NLgU:disabled{color:GrayText;border-color:GrayText}}.ui-chip--NLgU:disabled .ui-chip__icon-IjjSb,.ui-chip--NLgU:disabled .ui-chip__count-MBGO3{color:var(--hd-text-3)}@media (forced-colors: active){.ui-chip--NLgU:disabled .ui-chip__icon-IjjSb,.ui-chip--NLgU:disabled .ui-chip__count-MBGO3{color:GrayText}}@media (prefers-reduced-motion: reduce){.ui-chip--NLgU{transition:none}}.ui-chip__icon-IjjSb{display:inline-flex;align-items:center;flex-shrink:0;font-size:.92em;color:var(--hd-text-2);transition:color var(--hd-duration-fast) var(--hd-ease-standard)}@media (prefers-reduced-motion: reduce){.ui-chip__icon-IjjSb{transition:none}}.ui-chip__label-cT4hw{overflow:hidden;text-overflow:ellipsis;padding-block:.25em;margin-block:-.25em}.ui-chip__count-MBGO3{font-size:var(--hd-type-caption-size);font-weight:var(--hd-font-weight-semibold);color:var(--hd-text-3);font-variant-numeric:tabular-nums;flex-shrink:0}.ui-chip--sm-60H-S{font-size:var(--hd-type-caption-size);padding:var(--hd-space-2) var(--hd-space-3);min-height:32px}.ui-chip--md--yAlm{font-size:var(--hd-type-small-size);padding:var(--hd-space-2) var(--hd-space-4);min-height:40px}.ui-chip--iconOnly-5LT1h{gap:0}.ui-chip--iconOnly-5LT1h.ui-chip--sm-60H-S{width:32px;padding:0}.ui-chip--iconOnly-5LT1h.ui-chip--md--yAlm{width:40px;padding:0}.ui-chip--iconOnly-5LT1h .ui-chip__icon-IjjSb{font-size:1em}.ui-chip--selected-FdpCr{border-color:var(--ui-chip-selected-line, var(--hd-primary));color:var(--ui-chip-selected-fg, var(--hd-primary-text));background-color:var(--ui-chip-selected-bg, var(--hd-primary-soft));font-weight:var(--ui-chip-selected-weight, var(--hd-font-weight-semibold))}.ui-chip--selected-FdpCr .ui-chip__icon-IjjSb,.ui-chip--selected-FdpCr .ui-chip__count-MBGO3{color:var(--ui-chip-selected-fg, var(--hd-primary-text))}.ui-chip--selected-FdpCr:hover:not(:disabled){border-color:var(--ui-chip-selected-line, var(--hd-primary-hover));color:var(--ui-chip-selected-fg, var(--hd-primary-text));background-color:var(--ui-chip-selected-bg, var(--hd-primary-soft-hover))}.ui-chip--selected-FdpCr:disabled{border-color:var(--hd-text-3)}}
|
|
36
36
|
|
|
37
37
|
@layer ui{.ui-group-0tnVf{display:flex;flex-wrap:wrap;gap:var(--hd-space-2)}.ui-group--scrollable-PMu6V{display:flex;gap:var(--hd-space-2);position:relative;overflow-x:auto;scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch;padding-block:var(--hd-space-1) var(--hd-space-3);scrollbar-width:none;-ms-overflow-style:none}.ui-group--scrollable-PMu6V::-webkit-scrollbar{display:none}.ui-group--scrollable-PMu6V>*{scroll-snap-align:start;flex-shrink:0}.ui-group--scrollable-PMu6V{flex-wrap:nowrap;padding-block:2px}.ui-group-0tnVf.ui-group--readOnly-uqpPV>*{cursor:default}}
|
|
38
38
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handijitcom/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "Accessible React component library on SCSS Modules, themed by its own design tokens (@handijitcom/ui/design): light and dark from one set of --hd-* tokens, a CSP-ready theme boot script, and Bootstrap Icons for iconography.",
|
|
5
5
|
"author": "Ahmet ilhan <ahmetilhan.dev@gmail.com>",
|
|
6
6
|
"license": "MIT",
|