@burdenoff/microfe-notification 2026.1129.2 → 2026.1129.3
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/NotificationRoutes.js +73 -72
- package/dist/NotificationRoutes.js.map +1 -1
- package/dist/hooks/useSendNotification.d.ts +1 -1
- package/dist/hooks/useSendNotification.js.map +1 -1
- package/dist/translations/en.d.ts +55 -0
- package/dist/v2/InboxPage.js +113 -97
- package/dist/v2/InboxPage.js.map +1 -1
- package/dist/v2/NotificationDetailPanel.d.ts +9 -5
- package/dist/v2/NotificationDetailPanel.js +66 -51
- package/dist/v2/NotificationDetailPanel.js.map +1 -1
- package/dist/v2/admin/TemplateFields.js +1 -1
- package/dist/v2/admin/TemplateFields.js.map +1 -1
- package/dist/v2/admin/templateText.js +22 -17
- package/dist/v2/admin/templateText.js.map +1 -1
- package/dist/v2/send/MessageTab.d.ts +4 -0
- package/dist/v2/send/MessageTab.js +152 -0
- package/dist/v2/send/MessageTab.js.map +1 -0
- package/dist/v2/send/PeopleTab.d.ts +4 -0
- package/dist/v2/send/PeopleTab.js +156 -0
- package/dist/v2/send/PeopleTab.js.map +1 -0
- package/dist/v2/send/SendNotificationDialog.d.ts +4 -0
- package/dist/v2/send/SendNotificationDialog.js +98 -0
- package/dist/v2/send/SendNotificationDialog.js.map +1 -0
- package/dist/v2/send/SendRedirect.d.ts +1 -0
- package/dist/v2/send/SendRedirect.js +20 -0
- package/dist/v2/send/SendRedirect.js.map +1 -0
- package/dist/v2/send/WhenTab.d.ts +4 -0
- package/dist/v2/send/WhenTab.js +64 -0
- package/dist/v2/send/WhenTab.js.map +1 -0
- package/dist/v2/send/sendModel.d.ts +47 -0
- package/dist/v2/send/sendModel.js +90 -0
- package/dist/v2/send/sendModel.js.map +1 -0
- package/dist/v2/send/useSendDraft.d.ts +24 -0
- package/dist/v2/send/useSendDraft.js +120 -0
- package/dist/v2/send/useSendDraft.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationDetailPanel.js","names":["follow","navigateInApp","url","NotificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","onMarkUnread","onArchive","onRestore","Button","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","actions","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport { useNotificationDetail, type NotificationDetailData } from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n onMarkUnread,\n onArchive,\n onRestore,\n}: {\n id: string | null;\n onClose: () => void;\n /** The person's own inbox: absent in the admins' delivery log, which only reads. */\n onMarkUnread?: (id: string) => void;\n onArchive?: (id: string) => void;\n onRestore?: (id: string) => void;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={\n notification && onMarkUnread && onArchive && onRestore ? (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => onMarkUnread(notification.id)}>\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button variant=\"ghost\" onClick={() => onRestore(notification.id)}>\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button variant=\"ghost\" onClick={() => onArchive(notification.id)}>\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n ) : undefined\n }\n >\n {state.status === 'loading' ? (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n ) : state.status === 'failed' ? (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n ) : state.status === 'missing' || !ready || !notification ? (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n ) : (\n <PanelBody notification={notification} data={ready} />\n )}\n </DetailPanel>\n );\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=\"text-xs text-text-muted\" dateTime={event.at}>\n {when.moment(event.at)}\n </time>\n </li>\n );\n })}\n </ol>\n </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otificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","footer","inboxActions","PanelFooter","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","PanelContent","Button","actions","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot, in\n * the person's own inbox only.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport {\n useNotificationDetail,\n type DetailState,\n type NotificationDetailData,\n} from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\n/** What the person can do with their own notification: absent in the admins' delivery log. */\nexport interface InboxActions {\n markUnread: (id: string) => void;\n archive: (id: string) => void;\n restore: (id: string) => void;\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n inboxActions,\n}: {\n id: string | null;\n onClose: () => void;\n /** The person's own inbox; the delivery log only reads, so it leaves these out. */\n inboxActions?: InboxActions;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n const footer =\n notification && inboxActions ? (\n <PanelFooter notification={notification} actions={inboxActions} />\n ) : undefined;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={footer}\n >\n <PanelContent state={state} retry={retry} notification={notification} />\n </DetailPanel>\n );\n}\n\n/** Mark as unread, and Archive or Move back to the inbox. */\nfunction PanelFooter({\n notification,\n actions,\n}: {\n notification: Notification;\n actions: InboxActions;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => actions.markUnread(notification.id)}>\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button variant=\"ghost\" onClick={() => actions.restore(notification.id)}>\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button variant=\"ghost\" onClick={() => actions.archive(notification.id)}>\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n );\n}\n\n/** Loading, couldn't load, gone, or the notification itself. */\nfunction PanelContent({\n state,\n retry,\n notification,\n}: {\n state: DetailState;\n retry: () => void;\n notification: Notification | null;\n}) {\n const tr = useTr();\n if (state.status === 'loading') {\n return (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n );\n }\n if (state.status === 'failed') {\n return (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n );\n }\n if (state.status !== 'ready' || !notification) {\n return (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n );\n }\n return <PanelBody notification={notification} data={state.notification} />;\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=\"text-xs text-text-muted\" dateTime={event.at}>\n {when.moment(event.at)}\n </time>\n </li>\n );\n })}\n </ol>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAASA,EAAO,GAAa;CAC3B,AAAKC,EAAcC,CAAG,KAAG,OAAO,KAAKA,GAAK,UAAU,qBAAqB;AAC3E;AASA,SAAgBC,EAAwB,EACtC,OACA,YACA,mBAMC;CACD,IAAMC,IAAKC,EAAM,GACX,EAAE,UAAO,aAAUC,EAAsBC,CAAE,GAC3CC,IAAQC,EAAM,WAAW,UAAUA,EAAM,eAAe,MACxDC,IAAeF,IAAQG,EAA4BH,CAAK,IAAI,MAC5DI,IACJF,KAAgBG,IACd,kBAACC,GAAD;EAA2B;EAAc,SAASD;CAAe,CAAA,IAC/D,KAAA;CAEN,OACE,kBAACE,GAAD;EACE,MAAM,EAAQR;EACd,eAAe,MAAUS,IAAO,KAAA,IAAYC,EAAQ;EACpD,OAAOP,GAAc,SAASN,EAAG,kCAAkC,cAAc;EACjF,KAAKM,IAAe,kBAACQ,GAAD,EAAwB,gBAAe,CAAA,IAAI,KAAA;EAC/D,MACER,IACE,kBAACS,GAAD;GAAU,MAAK;GACb,UAAA,kBAACC,GAAD,EAAwB,gBAAe,CAAA;EAC/B,CAAA,IACR,KAAA;EAEN,YAAYhB,EAAG,gCAAgC,OAAO;EACtD,eAAY;EACJ;EAER,UAAA,kBAACiB,GAAD;GAAqB;GAAc;GAAqB;EAAe,CAAA;CAC5D,CAAA;AAEjB;AAGA,SAASP,EAAY,EACnB,iBACA,cAIC;CACD,IAAMV,IAAKC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Ae;EAC9C,CAAA,GACJ,kBAAC,MAAD;GAAI,WAAU;GAAwC,eAAY;GAC/D,UAAA8C,EAAM,KAAK,MAAU;IACpB,IAAMG,IAAOR,EAAWS,EAAM;IAC9B,OACE,kBAAC,MAAD;KAAmB,WAAU;KAA7B,UAAA;MACE,kBAACD,GAAD;OAAM,WAAW,UAAUJ,EAAWK,EAAM;OAAS,eAAY;MAAQ,CAAA;MACzE,kBAAC,QAAD;OAAM,WAAU;OAA4B,UAAAA,EAAM;MAAY,CAAA;MAC9D,kBAAC,QAAD;OAAM,WAAU;OAA0B,UAAUA,EAAM;OACvD,UAAA1B,EAAK,OAAO0B,EAAM,EAAE;MACjB,CAAA;KACJ;IANK,GAAAA,EAAM,EAMX;GAER,CAAC;EACC,CAAA,CACG;;AAEb"}
|
|
@@ -115,7 +115,7 @@ function g({ template: n, draft: r, titleRef: a, messageRef: g }) {
|
|
|
115
115
|
"data-testid": "template-message"
|
|
116
116
|
}), /* @__PURE__ */ c("p", {
|
|
117
117
|
className: "m-0 text-xs text-text-muted",
|
|
118
|
-
children: _("notifications.v3.template.detailsHelp", "Details in brackets, like [First name], are filled in
|
|
118
|
+
children: _("notifications.v3.template.detailsHelp", "Details in brackets, like [First name], are filled in when it’s sent.")
|
|
119
119
|
})]
|
|
120
120
|
}),
|
|
121
121
|
n?.htmlTemplate ? /* @__PURE__ */ c(f, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateFields.js","names":["TextField","Label","id","label","InsertDetail","onInsert","field","detail","children","ChannelField","tr","useTr","template","channelWord","ChoiceSelect","draft","TEMPLATE_CHANNELS","option","TemplateFields","useId","Input","event","TEMPLATE_KINDS","kindWord","titleRef","Textarea","messageRef","Notice"],"sources":["../../../src/v2/admin/TemplateFields.tsx"],"sourcesContent":["/**\n * The template form (BOFF-16785, C2): name, what it's about, channel, title and message. Title\n * and message are edited as people read them (`[First name]`); Insert puts a detail at the cursor.\n */\nimport { useId, type ReactNode, type RefObject } from 'react';\nimport { Input, Label, Notice, Textarea } from '@burdenoff/fe-libs/ui';\nimport type { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { ChoiceSelect } from './ChoiceSelect';\nimport { InsertDetail } from './InsertDetail';\nimport type { TemplateDetail } from './templateText';\nimport type { DraftField, TemplateDraft } from './useTemplateDraft';\nimport { channelWord, kindWord, TEMPLATE_CHANNELS, TEMPLATE_KINDS } from './words';\n\nfunction TextField({\n id,\n label,\n field,\n details,\n onInsert,\n children,\n}: {\n id: string;\n label: string;\n field: DraftField;\n details: TemplateDetail[];\n onInsert: (field: DraftField, detail: TemplateDetail) => void;\n children: ReactNode;\n}) {\n return (\n <div className=\"flex flex-col gap-1.5\">\n <div className=\"flex items-end justify-between gap-2\">\n <Label htmlFor={id}>{label}</Label>\n <InsertDetail\n details={details}\n onInsert={(detail) => onInsert(field, detail)}\n testId={`insert-${field}`}\n />\n </div>\n {children}\n </div>\n );\n}\n\nfunction ChannelField({\n id,\n template,\n draft,\n}: {\n id: string;\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={id}>{tr('notifications.v3.template.channel', 'Sent by')}</Label>\n {template ? (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.template.channelFixed',\n '{{channel}}. A template’s channel is set when it’s made.',\n { channel: channelWord(template.channel, tr) }\n )}\n </p>\n ) : (\n <ChoiceSelect\n id={id}\n value={draft.channel}\n options={TEMPLATE_CHANNELS}\n word={(option) => channelWord(option, tr)}\n onChange={draft.setChannel}\n className=\"max-w-xs\"\n />\n )}\n </div>\n );\n}\n\nexport function TemplateFields({\n template,\n draft,\n titleRef,\n messageRef,\n}: {\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n titleRef: RefObject<HTMLInputElement | null>;\n messageRef: RefObject<HTMLTextAreaElement | null>;\n}) {\n const tr = useTr();\n const id = useId();\n return (\n <section\n className=\"flex flex-col gap-4\"\n aria-label={tr('notifications.v3.template.form', 'Message')}\n >\n <div className=\"grid grid-cols-2 gap-3 max-sm:grid-cols-1\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-name`}>{tr('notifications.v3.template.name', 'Name')}</Label>\n <Input\n id={`${id}-name`}\n value={draft.name}\n placeholder={tr('notifications.v3.template.namePlaceholder', 'For example: Run failed')}\n onChange={(event) => draft.setName(event.target.value)}\n data-testid=\"template-name\"\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-kind`}>{tr('notifications.v3.template.kind', 'About')}</Label>\n <ChoiceSelect\n id={`${id}-kind`}\n value={draft.kind}\n options={TEMPLATE_KINDS}\n word={(option) => kindWord(option, tr)}\n onChange={draft.setKind}\n disabled={Boolean(template)}\n />\n </div>\n </div>\n <ChannelField id={`${id}-channel`} template={template} draft={draft} />\n <TextField\n id={`${id}-title`}\n label={tr('notifications.v3.template.title', 'Title')}\n field=\"title\"\n details={draft.details}\n onInsert={draft.insertInto}\n >\n <Input\n ref={titleRef}\n id={`${id}-title`}\n value={draft.title}\n placeholder={tr('notifications.v3.template.titlePlaceholder', 'What people see first')}\n onFocus={() => draft.rememberField('title')}\n onChange={(event) => draft.setTitle(event.target.value)}\n data-testid=\"template-title\"\n />\n </TextField>\n <TextField\n id={`${id}-message`}\n label={tr('notifications.v3.template.message', 'Message')}\n field=\"message\"\n details={draft.details}\n onInsert={draft.insertInto}\n >\n <Textarea\n ref={messageRef}\n id={`${id}-message`}\n rows={6}\n value={draft.message}\n placeholder={tr(\n 'notifications.v3.template.messagePlaceholder',\n 'Write the message. Insert adds a person’s name, the workflow or a link.'\n )}\n onFocus={() => draft.rememberField('message')}\n onChange={(event) => draft.setMessage(event.target.value)}\n data-testid=\"template-message\"\n />\n <p className=\"m-0 text-xs text-text-muted\">\n {tr(\n 'notifications.v3.template.detailsHelp',\n 'Details in brackets, like [First name], are filled in
|
|
1
|
+
{"version":3,"file":"TemplateFields.js","names":["TextField","Label","id","label","InsertDetail","onInsert","field","detail","children","ChannelField","tr","useTr","template","channelWord","ChoiceSelect","draft","TEMPLATE_CHANNELS","option","TemplateFields","useId","Input","event","TEMPLATE_KINDS","kindWord","titleRef","Textarea","messageRef","Notice"],"sources":["../../../src/v2/admin/TemplateFields.tsx"],"sourcesContent":["/**\n * The template form (BOFF-16785, C2): name, what it's about, channel, title and message. Title\n * and message are edited as people read them (`[First name]`); Insert puts a detail at the cursor.\n */\nimport { useId, type ReactNode, type RefObject } from 'react';\nimport { Input, Label, Notice, Textarea } from '@burdenoff/fe-libs/ui';\nimport type { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { ChoiceSelect } from './ChoiceSelect';\nimport { InsertDetail } from './InsertDetail';\nimport type { TemplateDetail } from './templateText';\nimport type { DraftField, TemplateDraft } from './useTemplateDraft';\nimport { channelWord, kindWord, TEMPLATE_CHANNELS, TEMPLATE_KINDS } from './words';\n\nfunction TextField({\n id,\n label,\n field,\n details,\n onInsert,\n children,\n}: {\n id: string;\n label: string;\n field: DraftField;\n details: TemplateDetail[];\n onInsert: (field: DraftField, detail: TemplateDetail) => void;\n children: ReactNode;\n}) {\n return (\n <div className=\"flex flex-col gap-1.5\">\n <div className=\"flex items-end justify-between gap-2\">\n <Label htmlFor={id}>{label}</Label>\n <InsertDetail\n details={details}\n onInsert={(detail) => onInsert(field, detail)}\n testId={`insert-${field}`}\n />\n </div>\n {children}\n </div>\n );\n}\n\nfunction ChannelField({\n id,\n template,\n draft,\n}: {\n id: string;\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={id}>{tr('notifications.v3.template.channel', 'Sent by')}</Label>\n {template ? (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.template.channelFixed',\n '{{channel}}. A template’s channel is set when it’s made.',\n { channel: channelWord(template.channel, tr) }\n )}\n </p>\n ) : (\n <ChoiceSelect\n id={id}\n value={draft.channel}\n options={TEMPLATE_CHANNELS}\n word={(option) => channelWord(option, tr)}\n onChange={draft.setChannel}\n className=\"max-w-xs\"\n />\n )}\n </div>\n );\n}\n\nexport function TemplateFields({\n template,\n draft,\n titleRef,\n messageRef,\n}: {\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n titleRef: RefObject<HTMLInputElement | null>;\n messageRef: RefObject<HTMLTextAreaElement | null>;\n}) {\n const tr = useTr();\n const id = useId();\n return (\n <section\n className=\"flex flex-col gap-4\"\n aria-label={tr('notifications.v3.template.form', 'Message')}\n >\n <div className=\"grid grid-cols-2 gap-3 max-sm:grid-cols-1\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-name`}>{tr('notifications.v3.template.name', 'Name')}</Label>\n <Input\n id={`${id}-name`}\n value={draft.name}\n placeholder={tr('notifications.v3.template.namePlaceholder', 'For example: Run failed')}\n onChange={(event) => draft.setName(event.target.value)}\n data-testid=\"template-name\"\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-kind`}>{tr('notifications.v3.template.kind', 'About')}</Label>\n <ChoiceSelect\n id={`${id}-kind`}\n value={draft.kind}\n options={TEMPLATE_KINDS}\n word={(option) => kindWord(option, tr)}\n onChange={draft.setKind}\n disabled={Boolean(template)}\n />\n </div>\n </div>\n <ChannelField id={`${id}-channel`} template={template} draft={draft} />\n <TextField\n id={`${id}-title`}\n label={tr('notifications.v3.template.title', 'Title')}\n field=\"title\"\n details={draft.details}\n onInsert={draft.insertInto}\n >\n <Input\n ref={titleRef}\n id={`${id}-title`}\n value={draft.title}\n placeholder={tr('notifications.v3.template.titlePlaceholder', 'What people see first')}\n onFocus={() => draft.rememberField('title')}\n onChange={(event) => draft.setTitle(event.target.value)}\n data-testid=\"template-title\"\n />\n </TextField>\n <TextField\n id={`${id}-message`}\n label={tr('notifications.v3.template.message', 'Message')}\n field=\"message\"\n details={draft.details}\n onInsert={draft.insertInto}\n >\n <Textarea\n ref={messageRef}\n id={`${id}-message`}\n rows={6}\n value={draft.message}\n placeholder={tr(\n 'notifications.v3.template.messagePlaceholder',\n 'Write the message. Insert adds a person’s name, the workflow or a link.'\n )}\n onFocus={() => draft.rememberField('message')}\n onChange={(event) => draft.setMessage(event.target.value)}\n data-testid=\"template-message\"\n />\n <p className=\"m-0 text-xs text-text-muted\">\n {tr(\n 'notifications.v3.template.detailsHelp',\n 'Details in brackets, like [First name], are filled in when it’s sent.'\n )}\n </p>\n </TextField>\n {template?.htmlTemplate ? (\n <Notice tone=\"info\">\n {tr(\n 'notifications.v3.template.htmlKept',\n 'This template also has a designed email version. It stays as it is.'\n )}\n </Notice>\n ) : null}\n </section>\n );\n}\n"],"mappings":";;;;;;;;AAcA,SAASA,EAAU,EACjB,OACA,UACA,UACA,YACA,aACA,eAQC;CACD,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACC,GAAD;IAAO,SAASC;IAAK,UAAAC;GAAa,CAAA,GAClC,kBAACC,GAAD;IACW;IACT,WAAW,MAAWC,EAASC,GAAOC,CAAM;IAC5C,QAAQ,UAAUD;GACnB,CAAA,CACE;EACJ,CAAA,GAAAE,CACE;;AAET;AAEA,SAASC,EAAa,EACpB,OACA,aACA,YAKC;CACD,IAAMC,IAAKC,EAAM;CACjB,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACV,GAAD;GAAO,SAASC;GAAK,UAAAQ,EAAG,qCAAqC,SAAS;EAAS,CAAA,GAC9EE,IACC,kBAAC,KAAD;GAAG,WAAU;GACV,UAAAF,EACC,0CACA,4DACA,EAAE,SAASG,EAAYD,EAAS,SAASF,CAAE,EAAE,CAC/C;EACC,CAAA,IAEH,kBAACI,GAAD;GACM;GACJ,OAAO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OAAOa,EAAM;KACb,aAAaL,EAAG,8CAA8C,uBAAuB;KACrF,eAAeK,EAAM,cAAc,OAAO;KAC1C,WAAW,MAAUA,EAAM,SAASM,EAAM,OAAO,KAAK;KACtD,eAAY;IACb,CAAA;GACQ,CAAA;GACX,kBAACrB,GAAD;IACE,IAAI,GAAGE,EAAG;IACV,OAAOQ,EAAG,qCAAqC,SAAS;IACxD,OAAM;IACN,SAASK,EAAM;IACf,UAAUA,EAAM;IALlB,UAAA,CAOE,kBAACU,GAAD;KACE,KAAKC;KACL,IAAI,GAAGxB,EAAG;KACV,MAAM;KACN,OAAOa,EAAM;KACb,aAAaL,EACX,gDACA,yEACF;KACA,eAAeK,EAAM,cAAc,SAAS;KAC5C,WAAW,MAAUA,EAAM,WAAWM,EAAM,OAAO,KAAK;KACxD,eAAY;IACb,CAAA,GACD,kBAAC,KAAD;KAAG,WAAU;KACV,UAAAX,EACC,yCACA,uEACF;IACC,CAAA,CACM;;GACVE,GAAU,eACT,kBAACe,GAAD;IAAQ,MAAK;IACV,UAAAjB,EACC,sCACA,qEACF;GACM,CAAA,IACN;EACG;;AAEb"}
|
|
@@ -19,7 +19,12 @@ function i(t, n) {
|
|
|
19
19
|
return n ? `{{${n}}}` : e;
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
function a(e) {
|
|
23
|
+
let t = /* @__PURE__ */ new Set();
|
|
24
|
+
for (let r of e.matchAll(n)) t.add(r[1]);
|
|
25
|
+
return [...t];
|
|
26
|
+
}
|
|
27
|
+
var o = {
|
|
23
28
|
firstname: "Maya",
|
|
24
29
|
lastname: "Fernandes",
|
|
25
30
|
name: "Maya Fernandes",
|
|
@@ -35,9 +40,9 @@ var a = {
|
|
|
35
40
|
link: "https://app.example/runs/81",
|
|
36
41
|
url: "https://app.example/runs/81"
|
|
37
42
|
};
|
|
38
|
-
function
|
|
43
|
+
function s(t, n) {
|
|
39
44
|
if (t.defaultValue) return t.defaultValue;
|
|
40
|
-
let r =
|
|
45
|
+
let r = o[t.name.toLowerCase()];
|
|
41
46
|
if (r) return r;
|
|
42
47
|
switch (t.type) {
|
|
43
48
|
case "number": return "3";
|
|
@@ -46,31 +51,31 @@ function o(t, n) {
|
|
|
46
51
|
default: return e(t.name);
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
function
|
|
54
|
+
function c(e, t, r) {
|
|
50
55
|
let i = new Map(t.map((e) => [e.name, e]));
|
|
51
56
|
return e.replace(n, (e, t) => {
|
|
52
57
|
let n = i.get(t);
|
|
53
|
-
return n ?
|
|
58
|
+
return n ? s(n, r) : e;
|
|
54
59
|
});
|
|
55
60
|
}
|
|
56
|
-
function
|
|
61
|
+
function l(e) {
|
|
57
62
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
58
63
|
}
|
|
59
|
-
function
|
|
64
|
+
function u(e) {
|
|
60
65
|
return e === "number" || e === "boolean" || e === "date" ? e : "string";
|
|
61
66
|
}
|
|
62
|
-
function
|
|
63
|
-
return Array.isArray(e) ? e.filter(
|
|
67
|
+
function d(e) {
|
|
68
|
+
return Array.isArray(e) ? e.filter(l).flatMap((e) => typeof e.name == "string" && e.name ? [{
|
|
64
69
|
name: e.name,
|
|
65
|
-
type:
|
|
70
|
+
type: u(e.type),
|
|
66
71
|
defaultValue: e.defaultValue ? String(e.defaultValue) : ""
|
|
67
|
-
}] : []) :
|
|
72
|
+
}] : []) : l(e) ? Object.entries(e).map(([e, t]) => ({
|
|
68
73
|
name: e,
|
|
69
|
-
type: l(
|
|
70
|
-
defaultValue:
|
|
74
|
+
type: u(l(t) ? t.type : void 0),
|
|
75
|
+
defaultValue: l(t) && t.defaultValue ? String(t.defaultValue) : ""
|
|
71
76
|
})) : [];
|
|
72
77
|
}
|
|
73
|
-
function
|
|
78
|
+
function f(e) {
|
|
74
79
|
let t = {};
|
|
75
80
|
for (let n of e) t[n.name] = {
|
|
76
81
|
type: n.type,
|
|
@@ -79,10 +84,10 @@ function d(e) {
|
|
|
79
84
|
};
|
|
80
85
|
return t;
|
|
81
86
|
}
|
|
82
|
-
function
|
|
87
|
+
function p(e) {
|
|
83
88
|
return e.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
|
|
84
89
|
}
|
|
85
|
-
var
|
|
90
|
+
var m = [
|
|
86
91
|
{
|
|
87
92
|
name: "firstName",
|
|
88
93
|
type: "string",
|
|
@@ -104,6 +109,6 @@ var p = [
|
|
|
104
109
|
defaultValue: ""
|
|
105
110
|
}
|
|
106
111
|
];
|
|
107
|
-
export {
|
|
112
|
+
export { m as COMMON_DETAILS, e as detailLabel, t as detailName, c as fillSamples, d as readDetails, s as sampleValue, p as templateSlug, r as toReadable, i as toStored, a as usedDetailNames, f as writeDetails };
|
|
108
113
|
|
|
109
114
|
//# sourceMappingURL=templateText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateText.js","names":["detailLabel","words","name","detailName","label","index","word","STORED","toReadable","known","details","detail","text","match","toStored","byLabel","SAMPLES","sampleValue","locale","fillSamples","byName","stored","isRecord","value","asType","readDetails","json","item","writeDetails","out","templateSlug","COMMON_DETAILS"],"sources":["../../../src/v2/admin/templateText.ts"],"sourcesContent":["/**\n * A template's text as people read it (BOFF-16785, C2; the mockup's `ntemplate`): the stored\n * `{{firstName}}` shows as the detail `[First name]`, and Insert adds details, so nobody types\n * braces. Saving turns each known `[Label]` back into `{{name}}`; anything else in brackets stays\n * as written. The template's details are its `variables`, stored as today\n * (`{name: {type, required, defaultValue}}`).\n */\n\nexport type DetailType = 'string' | 'number' | 'boolean' | 'date';\n\nexport interface TemplateDetail {\n name: string;\n type: DetailType;\n defaultValue: string;\n}\n\n/** \"firstName\" → \"First name\", \"workflow_name\" → \"Workflow name\", \"url\" → \"Url\". */\nexport function detailLabel(name: string): string {\n const words = name\n .replace(/[_-]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim()\n .toLowerCase();\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : name;\n}\n\n/** \"First name\" → \"firstName\": the stored name for a detail someone adds. */\nexport function detailName(label: string): string {\n const words = label\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .trim()\n .split(' ')\n .filter(Boolean);\n const name = words\n .map((word, index) =>\n index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n )\n .join('');\n return /^[A-Za-z]/.test(name) ? name : name ? `detail${name}` : '';\n}\n\nconst STORED = /\\{\\{\\s*([A-Za-z_][\\w.]*)\\s*\\}\\}/g;\n\n/** Stored text as people read it: each `{{name}}` of a known detail becomes `[Label]`. */\nexport function toReadable(text: string, details: readonly Pick<TemplateDetail, 'name'>[]): string {\n const known = new Set(details.map((detail) => detail.name));\n return text.replace(STORED, (match, name: string) =>\n known.has(name) ? `[${detailLabel(name)}]` : match\n );\n}\n\n/** Text as people wrote it, ready to store: each `[Label]` of a known detail becomes `{{name}}`. */\nexport function toStored(text: string, details: readonly Pick<TemplateDetail, 'name'>[]): string {\n const byLabel = new Map(details.map((detail) => [detailLabel(detail.name), detail.name]));\n return text.replace(/\\[([^[\\]\\n]+)\\]/g, (match, label: string) => {\n const name = byLabel.get(label.trim());\n return name ? `{{${name}}}` : match;\n });\n}\n\n/** The details a stored text uses (`{{name}}`), in order, once each. */\nexport function usedDetailNames(stored: string): string[] {\n const names = new Set<string>();\n for (const match of stored.matchAll(STORED)) names.add(match[1]);\n return [...names];\n}\n\nconst SAMPLES: Record<string, string> = {\n firstname: 'Maya',\n lastname: 'Fernandes',\n name: 'Maya Fernandes',\n fullname: 'Maya Fernandes',\n email: 'maya@northwind.example',\n workflow: 'Lead routing',\n workflowname: 'Lead routing',\n step: 'New lead',\n stepname: 'New lead',\n workspace: 'Northwind',\n workspacename: 'Northwind',\n organization: 'Northwind Labs',\n link: 'https://app.example/runs/81',\n url: 'https://app.example/runs/81',\n};\n\n/** A sample for the preview: the detail's default, else a likely value, else its label. */\nexport function sampleValue(detail: TemplateDetail, locale?: string): string {\n if (detail.defaultValue) return detail.defaultValue;\n const known = SAMPLES[detail.name.toLowerCase()];\n if (known) return known;\n switch (detail.type) {\n case 'number':\n return '3';\n case 'boolean':\n return 'yes';\n case 'date':\n return new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(\n new Date(2026, 10, 28)\n );\n default:\n return detailLabel(detail.name);\n }\n}\n\n/** Stored text with samples filled in, for the preview. Unknown `{{x}}` stay as they are. */\nexport function fillSamples(\n stored: string,\n details: readonly TemplateDetail[],\n locale?: string\n): string {\n const byName = new Map(details.map((detail) => [detail.name, detail]));\n return stored.replace(STORED, (match, name: string) => {\n const detail = byName.get(name);\n return detail ? sampleValue(detail, locale) : match;\n });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asType(value: unknown): DetailType {\n return value === 'number' || value === 'boolean' || value === 'date' ? value : 'string';\n}\n\n/** The stored `variables` (object, or the older array) as details. */\nexport function readDetails(json: unknown): TemplateDetail[] {\n if (Array.isArray(json)) {\n return json.filter(isRecord).flatMap((item) =>\n typeof item.name === 'string' && item.name\n ? [\n {\n name: item.name,\n type: asType(item.type),\n defaultValue: item.defaultValue ? String(item.defaultValue) : '',\n },\n ]\n : []\n );\n }\n if (!isRecord(json)) return [];\n return Object.entries(json).map(([name, value]) => ({\n name,\n type: asType(isRecord(value) ? value.type : undefined),\n defaultValue: isRecord(value) && value.defaultValue ? String(value.defaultValue) : '',\n }));\n}\n\n/** Details as stored today: `{name: {type, required, defaultValue?}}`. */\nexport function writeDetails(details: readonly TemplateDetail[]): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const detail of details) {\n out[detail.name] = {\n type: detail.type,\n required: true,\n ...(detail.defaultValue ? { defaultValue: detail.defaultValue } : {}),\n };\n }\n return out;\n}\n\n/** \"Hi there, Maya\" → \"hi-there-maya\": a template's web-safe key from its name. */\nexport function templateSlug(name: string): string {\n return name\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 60)\n .replace(/-+$/g, '');\n}\n\n/** Details most messages need, offered when the template doesn't have them yet. */\nexport const COMMON_DETAILS: readonly TemplateDetail[] = [\n { name: 'firstName', type: 'string', defaultValue: '' },\n { name: 'workflowName', type: 'string', defaultValue: '' },\n { name: 'stepName', type: 'string', defaultValue: '' },\n { name: 'link', type: 'string', defaultValue: '' },\n];\n"],"mappings":";AAiBA,SAAgBA,EAAY,GAAsB;CAChD,IAAMC,IAAQC,EACX,QAAQ,UAAU,GAAG,CAAC,CACtB,QAAQ,sBAAsB,OAAO,CAAC,CACtC,KAAK,CAAC,CACN,YAAY;CACf,OAAOD,IAAQA,EAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAIA,EAAM,MAAM,CAAC,IAAIC;AAClE;AAGA,SAAgBC,EAAW,GAAuB;CAQhD,IAAMD,IAPQE,EACX,UAAU,MAAM,CAAC,CACjB,QAAQ,UAAU,EAAE,CAAC,CACrB,QAAQ,kBAAkB,GAAG,CAAC,CAC9B,KAAK,CAAC,CACN,MAAM,GAAG,CAAC,CACV,OAAO,OACG,CAAA,CACV,KAAK,GAAM,MACVC,MAAU,IAAIC,EAAK,YAAY,IAAIA,EAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAIA,EAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAC9F,CAAC,CACA,KAAK,EAAE;CACV,OAAO,YAAY,KAAKJ,CAAI,IAAIA,IAAOA,IAAO,SAASA,MAAS;AAClE;AAEA,IAAMK,IAAS;AAGf,SAAgBC,EAAW,GAAc,GAA0D;CACjG,IAAMC,IAAQ,IAAI,IAAIC,EAAQ,KAAK,MAAWC,EAAO,IAAI,CAAC;CA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IAA4C;CACvD;EAAE,MAAM;EAAa,MAAM;EAAU,cAAc;CAAG;CACtD;EAAE,MAAM;EAAgB,MAAM;EAAU,cAAc;CAAG;CACzD;EAAE,MAAM;EAAY,MAAM;EAAU,cAAc;CAAG;CACrD;EAAE,MAAM;EAAQ,MAAM;EAAU,cAAc;CAAG;AACnD"}
|
|
1
|
+
{"version":3,"file":"templateText.js","names":["detailLabel","words","name","detailName","label","index","word","STORED","toReadable","known","details","detail","text","match","toStored","byLabel","usedDetailNames","names","stored","SAMPLES","sampleValue","locale","fillSamples","byName","isRecord","value","asType","readDetails","json","item","writeDetails","out","templateSlug","COMMON_DETAILS"],"sources":["../../../src/v2/admin/templateText.ts"],"sourcesContent":["/**\n * A template's text as people read it (BOFF-16785, C2; the mockup's `ntemplate`): the stored\n * `{{firstName}}` shows as the detail `[First name]`, and Insert adds details, so nobody types\n * braces. Saving turns each known `[Label]` back into `{{name}}`; anything else in brackets stays\n * as written. The template's details are its `variables`, stored as today\n * (`{name: {type, required, defaultValue}}`).\n */\n\nexport type DetailType = 'string' | 'number' | 'boolean' | 'date';\n\nexport interface TemplateDetail {\n name: string;\n type: DetailType;\n defaultValue: string;\n}\n\n/** \"firstName\" → \"First name\", \"workflow_name\" → \"Workflow name\", \"url\" → \"Url\". */\nexport function detailLabel(name: string): string {\n const words = name\n .replace(/[_-]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim()\n .toLowerCase();\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : name;\n}\n\n/** \"First name\" → \"firstName\": the stored name for a detail someone adds. */\nexport function detailName(label: string): string {\n const words = label\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .trim()\n .split(' ')\n .filter(Boolean);\n const name = words\n .map((word, index) =>\n index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n )\n .join('');\n return /^[A-Za-z]/.test(name) ? name : name ? `detail${name}` : '';\n}\n\nconst STORED = /\\{\\{\\s*([A-Za-z_][\\w.]*)\\s*\\}\\}/g;\n\n/** Stored text as people read it: each `{{name}}` of a known detail becomes `[Label]`. */\nexport function toReadable(text: string, details: readonly Pick<TemplateDetail, 'name'>[]): string {\n const known = new Set(details.map((detail) => detail.name));\n return text.replace(STORED, (match, name: string) =>\n known.has(name) ? `[${detailLabel(name)}]` : match\n );\n}\n\n/** Text as people wrote it, ready to store: each `[Label]` of a known detail becomes `{{name}}`. */\nexport function toStored(text: string, details: readonly Pick<TemplateDetail, 'name'>[]): string {\n const byLabel = new Map(details.map((detail) => [detailLabel(detail.name), detail.name]));\n return text.replace(/\\[([^[\\]\\n]+)\\]/g, (match, label: string) => {\n const name = byLabel.get(label.trim());\n return name ? `{{${name}}}` : match;\n });\n}\n\n/** The details a stored text uses (`{{name}}`), in order, once each. */\nexport function usedDetailNames(stored: string): string[] {\n const names = new Set<string>();\n for (const match of stored.matchAll(STORED)) names.add(match[1]);\n return [...names];\n}\n\nconst SAMPLES: Record<string, string> = {\n firstname: 'Maya',\n lastname: 'Fernandes',\n name: 'Maya Fernandes',\n fullname: 'Maya Fernandes',\n email: 'maya@northwind.example',\n workflow: 'Lead routing',\n workflowname: 'Lead routing',\n step: 'New lead',\n stepname: 'New lead',\n workspace: 'Northwind',\n workspacename: 'Northwind',\n organization: 'Northwind Labs',\n link: 'https://app.example/runs/81',\n url: 'https://app.example/runs/81',\n};\n\n/** A sample for the preview: the detail's default, else a likely value, else its label. */\nexport function sampleValue(detail: TemplateDetail, locale?: string): string {\n if (detail.defaultValue) return detail.defaultValue;\n const known = SAMPLES[detail.name.toLowerCase()];\n if (known) return known;\n switch (detail.type) {\n case 'number':\n return '3';\n case 'boolean':\n return 'yes';\n case 'date':\n return new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(\n new Date(2026, 10, 28)\n );\n default:\n return detailLabel(detail.name);\n }\n}\n\n/** Stored text with samples filled in, for the preview. Unknown `{{x}}` stay as they are. */\nexport function fillSamples(\n stored: string,\n details: readonly TemplateDetail[],\n locale?: string\n): string {\n const byName = new Map(details.map((detail) => [detail.name, detail]));\n return stored.replace(STORED, (match, name: string) => {\n const detail = byName.get(name);\n return detail ? sampleValue(detail, locale) : match;\n });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asType(value: unknown): DetailType {\n return value === 'number' || value === 'boolean' || value === 'date' ? value : 'string';\n}\n\n/** The stored `variables` (object, or the older array) as details. */\nexport function readDetails(json: unknown): TemplateDetail[] {\n if (Array.isArray(json)) {\n return json.filter(isRecord).flatMap((item) =>\n typeof item.name === 'string' && item.name\n ? [\n {\n name: item.name,\n type: asType(item.type),\n defaultValue: item.defaultValue ? String(item.defaultValue) : '',\n },\n ]\n : []\n );\n }\n if (!isRecord(json)) return [];\n return Object.entries(json).map(([name, value]) => ({\n name,\n type: asType(isRecord(value) ? value.type : undefined),\n defaultValue: isRecord(value) && value.defaultValue ? String(value.defaultValue) : '',\n }));\n}\n\n/** Details as stored today: `{name: {type, required, defaultValue?}}`. */\nexport function writeDetails(details: readonly TemplateDetail[]): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const detail of details) {\n out[detail.name] = {\n type: detail.type,\n required: true,\n ...(detail.defaultValue ? { defaultValue: detail.defaultValue } : {}),\n };\n }\n return out;\n}\n\n/** \"Hi there, Maya\" → \"hi-there-maya\": a template's web-safe key from its name. */\nexport function templateSlug(name: string): string {\n return name\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 60)\n .replace(/-+$/g, '');\n}\n\n/** Details most messages need, offered when the template doesn't have them yet. */\nexport const COMMON_DETAILS: readonly TemplateDetail[] = [\n { name: 'firstName', type: 'string', defaultValue: '' },\n { name: 'workflowName', type: 'string', defaultValue: '' },\n { name: 'st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,cAAc;CAAG;AACnD"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { useNotificationTemplates as e } from "../../hooks/useNotificationTemplates.js";
|
|
2
|
+
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
|
+
import { ChoiceSelect as n } from "../admin/ChoiceSelect.js";
|
|
4
|
+
import { detailLabel as r } from "../admin/templateText.js";
|
|
5
|
+
import { TEMPLATE_KINDS as i, channelWord as a, kindWord as o } from "../admin/words.js";
|
|
6
|
+
import { SEND_CHANNELS as s, detailsInUse as c } from "./sendModel.js";
|
|
7
|
+
import { useId as l } from "react";
|
|
8
|
+
import { Check as u } from "lucide-react";
|
|
9
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
10
|
+
import { Button as p, Input as m, Label as h, Textarea as g } from "@burdenoff/fe-libs/ui";
|
|
11
|
+
// src/v2/send/MessageTab.tsx
|
|
12
|
+
var _ = "blank", v = { enabled: !0 };
|
|
13
|
+
function y({ id: r, draft: i }) {
|
|
14
|
+
let a = t(), { templates: o } = e(v), s = new Map(o.map((e) => [e.id, e.name]));
|
|
15
|
+
return /* @__PURE__ */ f("div", {
|
|
16
|
+
className: "flex flex-col gap-1.5",
|
|
17
|
+
children: [/* @__PURE__ */ d(h, {
|
|
18
|
+
htmlFor: r,
|
|
19
|
+
children: a("notifications.v3.send.startFrom", "Start from")
|
|
20
|
+
}), /* @__PURE__ */ d(n, {
|
|
21
|
+
id: r,
|
|
22
|
+
value: i.templateId ?? _,
|
|
23
|
+
options: [_, ...o.map((e) => e.id)],
|
|
24
|
+
word: (e) => e === _ ? a("notifications.v3.send.blank", "A blank message") : s.get(e) ?? e,
|
|
25
|
+
onChange: (e) => i.startFrom(o.find((t) => t.id === e) ?? null),
|
|
26
|
+
className: "max-w-sm"
|
|
27
|
+
})]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function b({ id: e, draft: n }) {
|
|
31
|
+
let i = t(), { title: a, message: o, details: s, values: l } = n.draft, u = c(a, o, s);
|
|
32
|
+
return u.length === 0 ? null : /* @__PURE__ */ f("fieldset", {
|
|
33
|
+
className: "m-0 flex flex-col gap-3 border-0 p-0",
|
|
34
|
+
"data-testid": "send-details",
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ d("legend", {
|
|
37
|
+
className: "mb-1 p-0 text-sm font-medium text-text-primary",
|
|
38
|
+
children: i("notifications.v3.send.details", "Fill in the details")
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ d("p", {
|
|
41
|
+
className: "m-0 -mt-2 text-xs text-text-muted",
|
|
42
|
+
children: i("notifications.v3.send.detailsHelp", "Each one is the same for everyone who gets it.")
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ d("div", {
|
|
45
|
+
className: "grid grid-cols-2 gap-3 max-sm:grid-cols-1",
|
|
46
|
+
children: u.map((t) => /* @__PURE__ */ f("div", {
|
|
47
|
+
className: "flex flex-col gap-1.5",
|
|
48
|
+
children: [/* @__PURE__ */ d(h, {
|
|
49
|
+
htmlFor: `${e}-${t.name}`,
|
|
50
|
+
children: r(t.name)
|
|
51
|
+
}), /* @__PURE__ */ d(m, {
|
|
52
|
+
id: `${e}-${t.name}`,
|
|
53
|
+
value: l[t.name] ?? "",
|
|
54
|
+
onChange: (e) => n.setValue(t.name, e.target.value)
|
|
55
|
+
})]
|
|
56
|
+
}, t.name))
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function x({ id: e, draft: n }) {
|
|
62
|
+
let r = t(), i = n.draft.channels;
|
|
63
|
+
return /* @__PURE__ */ f("div", {
|
|
64
|
+
className: "flex flex-col gap-1.5",
|
|
65
|
+
children: [/* @__PURE__ */ d("span", {
|
|
66
|
+
className: "text-sm font-medium text-text-primary",
|
|
67
|
+
id: e,
|
|
68
|
+
children: r("notifications.v3.template.channel", "Sent by")
|
|
69
|
+
}), /* @__PURE__ */ d("div", {
|
|
70
|
+
className: "flex flex-wrap gap-2",
|
|
71
|
+
role: "group",
|
|
72
|
+
"aria-labelledby": e,
|
|
73
|
+
children: s.map((e) => {
|
|
74
|
+
let t = i.includes(e);
|
|
75
|
+
return /* @__PURE__ */ f(p, {
|
|
76
|
+
type: "button",
|
|
77
|
+
size: "sm",
|
|
78
|
+
variant: t ? "secondary" : "outline",
|
|
79
|
+
"aria-pressed": t,
|
|
80
|
+
onClick: () => n.toggleChannel(e),
|
|
81
|
+
"data-testid": `send-by-${e}`,
|
|
82
|
+
children: [t ? /* @__PURE__ */ d(u, { "aria-hidden": "true" }) : null, a(e, r)]
|
|
83
|
+
}, e);
|
|
84
|
+
})
|
|
85
|
+
})]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function S({ draft: e }) {
|
|
89
|
+
let r = t(), a = l();
|
|
90
|
+
return /* @__PURE__ */ f("div", {
|
|
91
|
+
className: "flex flex-col gap-4",
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ d(y, {
|
|
94
|
+
id: `${a}-start`,
|
|
95
|
+
draft: e
|
|
96
|
+
}),
|
|
97
|
+
/* @__PURE__ */ f("div", {
|
|
98
|
+
className: "flex flex-col gap-1.5",
|
|
99
|
+
children: [/* @__PURE__ */ d(h, {
|
|
100
|
+
htmlFor: `${a}-title`,
|
|
101
|
+
children: r("notifications.v3.template.title", "Title")
|
|
102
|
+
}), /* @__PURE__ */ d(m, {
|
|
103
|
+
id: `${a}-title`,
|
|
104
|
+
value: e.draft.title,
|
|
105
|
+
placeholder: r("notifications.v3.send.titlePlaceholder", "What it’s about"),
|
|
106
|
+
onChange: (t) => e.setTitle(t.target.value),
|
|
107
|
+
"data-testid": "send-title"
|
|
108
|
+
})]
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ f("div", {
|
|
111
|
+
className: "flex flex-col gap-1.5",
|
|
112
|
+
children: [/* @__PURE__ */ d(h, {
|
|
113
|
+
htmlFor: `${a}-message`,
|
|
114
|
+
children: r("notifications.v3.template.message", "Message")
|
|
115
|
+
}), /* @__PURE__ */ d(g, {
|
|
116
|
+
id: `${a}-message`,
|
|
117
|
+
rows: 4,
|
|
118
|
+
value: e.draft.message,
|
|
119
|
+
placeholder: r("notifications.v3.send.messagePlaceholder", "Write the message"),
|
|
120
|
+
onChange: (t) => e.setMessage(t.target.value),
|
|
121
|
+
"data-testid": "send-message"
|
|
122
|
+
})]
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ d(b, {
|
|
125
|
+
id: `${a}-detail`,
|
|
126
|
+
draft: e
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ f("div", {
|
|
129
|
+
className: "grid grid-cols-2 gap-3 max-sm:grid-cols-1",
|
|
130
|
+
children: [/* @__PURE__ */ f("div", {
|
|
131
|
+
className: "flex flex-col gap-1.5",
|
|
132
|
+
children: [/* @__PURE__ */ d(h, {
|
|
133
|
+
htmlFor: `${a}-kind`,
|
|
134
|
+
children: r("notifications.v3.template.kind", "About")
|
|
135
|
+
}), /* @__PURE__ */ d(n, {
|
|
136
|
+
id: `${a}-kind`,
|
|
137
|
+
value: e.draft.kind,
|
|
138
|
+
options: i,
|
|
139
|
+
word: (e) => o(e, r),
|
|
140
|
+
onChange: e.setKind
|
|
141
|
+
})]
|
|
142
|
+
}), /* @__PURE__ */ d(x, {
|
|
143
|
+
id: `${a}-by`,
|
|
144
|
+
draft: e
|
|
145
|
+
})]
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
export { S as MessageTab };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=MessageTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageTab.js","names":["BLANK","TEMPLATE_FILTER","StartFrom","tr","useTr","useNotificationTemplates","names","templates","template","Label","id","ChoiceSelect","draft","option","DetailValues","used","detailsInUse","title","message","details","detail","detailLabel","Input","values","event","SendBy","chosen","SEND_CHANNELS","on","channel","Button","Check","channelWord","MessageTab","useId","Textarea","TEMPLATE_KINDS","kindWord"],"sources":["../../../src/v2/send/MessageTab.tsx"],"sourcesContent":["/**\n * The send dialog's Message tab (BOFF-16785, C2b): start from a blank message or a template, the\n * title and message, a value for each of the template's details still in the words, what it's\n * about, and the ways it's sent (In app · Email · Push).\n */\nimport { useId } from 'react';\nimport { Check } from 'lucide-react';\nimport { Button, Input, Label, Textarea } from '@burdenoff/fe-libs/ui';\nimport { useNotificationTemplates } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { ChoiceSelect } from '../admin/ChoiceSelect';\nimport { detailLabel } from '../admin/templateText';\nimport { channelWord, kindWord, TEMPLATE_KINDS } from '../admin/words';\nimport { detailsInUse, SEND_CHANNELS } from './sendModel';\nimport type { SendDraft } from './useSendDraft';\n\nconst BLANK = 'blank';\nconst TEMPLATE_FILTER = { enabled: true };\n\nfunction StartFrom({ id, draft }: { id: string; draft: SendDraft }) {\n const tr = useTr();\n const { templates } = useNotificationTemplates(TEMPLATE_FILTER);\n const names = new Map(templates.map((template) => [template.id, template.name]));\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={id}>{tr('notifications.v3.send.startFrom', 'Start from')}</Label>\n <ChoiceSelect\n id={id}\n value={draft.templateId ?? BLANK}\n options={[BLANK, ...templates.map((template) => template.id)]}\n word={(option) =>\n option === BLANK\n ? tr('notifications.v3.send.blank', 'A blank message')\n : (names.get(option) ?? option)\n }\n onChange={(option) =>\n draft.startFrom(templates.find((template) => template.id === option) ?? null)\n }\n className=\"max-w-sm\"\n />\n </div>\n );\n}\n\nfunction DetailValues({ id, draft }: { id: string; draft: SendDraft }) {\n const tr = useTr();\n const { title, message, details, values } = draft.draft;\n const used = detailsInUse(title, message, details);\n if (used.length === 0) return null;\n return (\n <fieldset className=\"m-0 flex flex-col gap-3 border-0 p-0\" data-testid=\"send-details\">\n <legend className=\"mb-1 p-0 text-sm font-medium text-text-primary\">\n {tr('notifications.v3.send.details', 'Fill in the details')}\n </legend>\n <p className=\"m-0 -mt-2 text-xs text-text-muted\">\n {tr('notifications.v3.send.detailsHelp', 'Each one is the same for everyone who gets it.')}\n </p>\n <div className=\"grid grid-cols-2 gap-3 max-sm:grid-cols-1\">\n {used.map((detail) => (\n <div key={detail.name} className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-${detail.name}`}>{detailLabel(detail.name)}</Label>\n <Input\n id={`${id}-${detail.name}`}\n value={values[detail.name] ?? ''}\n onChange={(event) => draft.setValue(detail.name, event.target.value)}\n />\n </div>\n ))}\n </div>\n </fieldset>\n );\n}\n\nfunction SendBy({ id, draft }: { id: string; draft: SendDraft }) {\n const tr = useTr();\n const chosen = draft.draft.channels;\n return (\n <div className=\"flex flex-col gap-1.5\">\n <span className=\"text-sm font-medium text-text-primary\" id={id}>\n {tr('notifications.v3.template.channel', 'Sent by')}\n </span>\n <div className=\"flex flex-wrap gap-2\" role=\"group\" aria-labelledby={id}>\n {SEND_CHANNELS.map((channel) => {\n const on = chosen.includes(channel);\n return (\n <Button\n key={channel}\n type=\"button\"\n size=\"sm\"\n variant={on ? 'secondary' : 'outline'}\n aria-pressed={on}\n onClick={() => draft.toggleChannel(channel)}\n data-testid={`send-by-${channel}`}\n >\n {on ? <Check aria-hidden=\"true\" /> : null}\n {channelWord(channel, tr)}\n </Button>\n );\n })}\n </div>\n </div>\n );\n}\n\nexport function MessageTab({ draft }: { draft: SendDraft }) {\n const tr = useTr();\n const id = useId();\n return (\n <div className=\"flex flex-col gap-4\">\n <StartFrom id={`${id}-start`} draft={draft} />\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-title`}>{tr('notifications.v3.template.title', 'Title')}</Label>\n <Input\n id={`${id}-title`}\n value={draft.draft.title}\n placeholder={tr('notifications.v3.send.titlePlaceholder', 'What it’s about')}\n onChange={(event) => draft.setTitle(event.target.value)}\n data-testid=\"send-title\"\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-message`}>\n {tr('notifications.v3.template.message', 'Message')}\n </Label>\n <Textarea\n id={`${id}-message`}\n rows={4}\n value={draft.draft.message}\n placeholder={tr('notifications.v3.send.messagePlaceholder', 'Write the message')}\n onChange={(event) => draft.setMessage(event.target.value)}\n data-testid=\"send-message\"\n />\n </div>\n <DetailValues id={`${id}-detail`} draft={draft} />\n <div className=\"grid grid-cols-2 gap-3 max-sm:grid-cols-1\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-kind`}>{tr('notifications.v3.template.kind', 'About')}</Label>\n <ChoiceSelect\n id={`${id}-kind`}\n value={draft.draft.kind}\n options={TEMPLATE_KINDS}\n word={(option) => kindWord(option, tr)}\n onChange={draft.setKind}\n />\n </div>\n <SendBy id={`${id}-by`} draft={draft} />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAMA,IAAQ,SACRC,IAAkB,EAAE,SAAS,GAAK;AAExC,SAASC,EAAU,EAAE,OAAI,YAA2C;CAClE,IAAMC,IAAKC,EAAM,GACX,EAAE,iBAAcC,EAAyBJ,CAAe,GACxDK,IAAQ,IAAI,IAAIC,EAAU,KAAK,MAAa,CAACC,EAAS,IAAIA,EAAS,IAAI,CAAC,CAAC;CAC/E,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACC,GAAD;GAAO,SAASC;GAAK,UAAAP,EAAG,mCAAmC,YAAY;EAAS,CAAA,GAChF,kBAACQ,GAAD;GACM;GACJ,OAAOC,EAAM,cAAcZ;GAC3B,SAAS,CAACA,GAAO,GAAGO,EAAU,KAAK,MAAaC,EAAS,EAAE,CAAC;GAC5D,OAAO,MACLK,MAAWb,IACPG,EAAG,+BAA+B,iBAAiB,IAClDG,EAAM,IAAIO,CAAM,KAAKA;GAE5B,WAAW,MACTD,EAAM,UAAUL,EAAU,MAAM,MAAaC,EAAS,OAAOK,CAAM,KAAK,IAAI;GAE9E,WAAU;EACX,CAAA,CACE;;AA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;KAAf,UAAA,CACE,kBAACD,GAAD;MAAO,SAAS,GAAGC,EAAG;MAAS,UAAAP,EAAG,kCAAkC,OAAO;KAAS,CAAA,GACpF,kBAACQ,GAAD;MACE,IAAI,GAAGD,EAAG;MACV,OAAOE,EAAM,MAAM;MACnB,SAASwB;MACT,OAAO,MAAWC,EAASxB,GAAQV,CAAE;MACrC,UAAUS,EAAM;KACjB,CAAA,CACE;IACL,CAAA,GAAA,kBAACa,GAAD;KAAQ,IAAI,GAAGf,EAAG;KAAa;IAAQ,CAAA,CACpC;;EACF;;AAET"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { useUserSearch as e } from "../../hooks/useUserSearch.js";
|
|
2
|
+
import { useNotificationTopics as t } from "../../hooks/useNotificationTopics.js";
|
|
3
|
+
import { useTr as n } from "../../shared/hooks/useTr.js";
|
|
4
|
+
import { ChoiceSelect as r } from "../admin/ChoiceSelect.js";
|
|
5
|
+
import { useId as i, useState as a } from "react";
|
|
6
|
+
import { Check as o, Plus as s, Search as c, X as l } from "lucide-react";
|
|
7
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
|
+
import { Button as f, EmptyState as p, Input as m, Label as h, Notice as g, Skeleton as _ } from "@burdenoff/fe-libs/ui";
|
|
9
|
+
// src/v2/send/PeopleTab.tsx
|
|
10
|
+
var v = "none", y = { isActive: !0 };
|
|
11
|
+
function b({ person: e, action: t }) {
|
|
12
|
+
return /* @__PURE__ */ d("li", {
|
|
13
|
+
className: "flex items-center gap-3 px-3 py-2",
|
|
14
|
+
children: [/* @__PURE__ */ d("span", {
|
|
15
|
+
className: "min-w-0 flex-1",
|
|
16
|
+
children: [/* @__PURE__ */ u("span", {
|
|
17
|
+
className: "block truncate text-sm text-text-primary",
|
|
18
|
+
children: e.name || e.email
|
|
19
|
+
}), e.name ? /* @__PURE__ */ u("span", {
|
|
20
|
+
className: "block truncate text-xs text-text-secondary",
|
|
21
|
+
children: e.email
|
|
22
|
+
}) : null]
|
|
23
|
+
}), t]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function x({ id: t, draft: r }) {
|
|
27
|
+
let i = n(), l = e(), [v, y] = a(""), x = new Set(r.draft.people.map((e) => e.id)), S = null;
|
|
28
|
+
return l.isLoading ? S = /* @__PURE__ */ d("div", {
|
|
29
|
+
className: "flex flex-col gap-2",
|
|
30
|
+
"aria-busy": "true",
|
|
31
|
+
children: [/* @__PURE__ */ u(_, { className: "h-10 w-full rounded-lg" }), /* @__PURE__ */ u(_, { className: "h-10 w-full rounded-lg" })]
|
|
32
|
+
}) : l.error ? S = /* @__PURE__ */ u(g, {
|
|
33
|
+
tone: "bad",
|
|
34
|
+
children: i("notifications.v3.send.searchFailed", "Couldn’t search people. Try again.")
|
|
35
|
+
}) : v.trim() && l.results.length === 0 ? S = /* @__PURE__ */ u(p, {
|
|
36
|
+
kind: "no-results",
|
|
37
|
+
compact: !0,
|
|
38
|
+
title: i("notifications.v3.send.nobody", "Nobody matches “{{query}}”", { query: v.trim() })
|
|
39
|
+
}) : l.results.length > 0 && (S = /* @__PURE__ */ u("ul", {
|
|
40
|
+
className: "m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle p-0",
|
|
41
|
+
"data-testid": "send-found",
|
|
42
|
+
children: l.results.map((e) => {
|
|
43
|
+
let t = {
|
|
44
|
+
id: e.id,
|
|
45
|
+
name: e.name,
|
|
46
|
+
email: e.email
|
|
47
|
+
}, n = x.has(e.id);
|
|
48
|
+
return /* @__PURE__ */ u(b, {
|
|
49
|
+
person: t,
|
|
50
|
+
action: /* @__PURE__ */ d(f, {
|
|
51
|
+
size: "sm",
|
|
52
|
+
variant: "outline",
|
|
53
|
+
disabled: n,
|
|
54
|
+
onClick: () => r.addPerson(t),
|
|
55
|
+
children: [u(n ? o : s, { "aria-hidden": "true" }), n ? i("notifications.v3.send.added", "Added") : i("notifications.v3.send.add", "Add")]
|
|
56
|
+
})
|
|
57
|
+
}, e.id);
|
|
58
|
+
})
|
|
59
|
+
})), /* @__PURE__ */ d("div", {
|
|
60
|
+
className: "flex flex-col gap-2",
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ u(h, {
|
|
63
|
+
htmlFor: t,
|
|
64
|
+
children: i("notifications.v3.send.find", "Find people")
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ d("div", {
|
|
67
|
+
className: "relative",
|
|
68
|
+
children: [/* @__PURE__ */ u(c, {
|
|
69
|
+
className: "pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2 text-text-muted",
|
|
70
|
+
"aria-hidden": "true"
|
|
71
|
+
}), /* @__PURE__ */ u(m, {
|
|
72
|
+
id: t,
|
|
73
|
+
type: "search",
|
|
74
|
+
className: "ps-9",
|
|
75
|
+
value: v,
|
|
76
|
+
placeholder: i("notifications.v3.send.findPlaceholder", "Name or email"),
|
|
77
|
+
onChange: (e) => {
|
|
78
|
+
y(e.target.value), l.searchUsers(e.target.value);
|
|
79
|
+
},
|
|
80
|
+
"data-testid": "send-find"
|
|
81
|
+
})]
|
|
82
|
+
}),
|
|
83
|
+
S
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function S({ draft: e }) {
|
|
88
|
+
let t = n(), r = e.draft.people;
|
|
89
|
+
return /* @__PURE__ */ d("section", {
|
|
90
|
+
className: "flex flex-col gap-2",
|
|
91
|
+
"data-testid": "send-chosen",
|
|
92
|
+
children: [/* @__PURE__ */ u("h3", {
|
|
93
|
+
className: "m-0 text-sm font-medium text-text-primary",
|
|
94
|
+
children: r.length === 1 ? t("notifications.v3.send.chosenOne", "1 person gets it") : t("notifications.v3.send.chosenMany", "{{count}} people get it", { count: r.length })
|
|
95
|
+
}), r.length === 0 ? /* @__PURE__ */ u("p", {
|
|
96
|
+
className: "m-0 text-sm text-text-secondary",
|
|
97
|
+
children: t("notifications.v3.send.chosenNone", "Find people above and add them.")
|
|
98
|
+
}) : /* @__PURE__ */ u("ul", {
|
|
99
|
+
className: "m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle p-0",
|
|
100
|
+
children: r.map((n) => /* @__PURE__ */ u(b, {
|
|
101
|
+
person: n,
|
|
102
|
+
action: /* @__PURE__ */ u(f, {
|
|
103
|
+
size: "icon",
|
|
104
|
+
variant: "ghost",
|
|
105
|
+
"aria-label": t("notifications.v3.send.remove", "Remove {{name}}", { name: n.name || n.email }),
|
|
106
|
+
onClick: () => e.removePerson(n.id),
|
|
107
|
+
children: /* @__PURE__ */ u(l, { "aria-hidden": "true" })
|
|
108
|
+
})
|
|
109
|
+
}, n.id))
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function C({ id: e, draft: i }) {
|
|
114
|
+
let a = n(), { topics: o } = t(y), s = new Map(o.map((e) => [e.id, e.name]));
|
|
115
|
+
return /* @__PURE__ */ d("div", {
|
|
116
|
+
className: "flex flex-col gap-1.5",
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ u(h, {
|
|
119
|
+
htmlFor: e,
|
|
120
|
+
children: i.draft.kind === "MARKETING" ? a("notifications.v3.send.topic", "Topic") : a("notifications.v3.send.topicOptional", "Topic (optional)")
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ u(r, {
|
|
123
|
+
id: e,
|
|
124
|
+
value: i.draft.topicId ?? v,
|
|
125
|
+
options: [v, ...o.map((e) => e.id)],
|
|
126
|
+
word: (e) => e === v ? a("notifications.v3.send.noTopic", "No topic") : s.get(e) ?? e,
|
|
127
|
+
onChange: (e) => i.setTopicId(e === v ? null : e),
|
|
128
|
+
className: "max-w-sm"
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ u("p", {
|
|
131
|
+
className: "m-0 text-xs text-text-muted",
|
|
132
|
+
children: a("notifications.v3.send.topicHelp", "People who turned the topic off don’t get it.")
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function w({ draft: e }) {
|
|
138
|
+
let t = i();
|
|
139
|
+
return /* @__PURE__ */ d("div", {
|
|
140
|
+
className: "flex flex-col gap-5",
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ u(x, {
|
|
143
|
+
id: `${t}-find`,
|
|
144
|
+
draft: e
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ u(S, { draft: e }),
|
|
147
|
+
/* @__PURE__ */ u(C, {
|
|
148
|
+
id: `${t}-topic`,
|
|
149
|
+
draft: e
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
export { w as PeopleTab };
|
|
155
|
+
|
|
156
|
+
//# sourceMappingURL=PeopleTab.js.map
|