@alfadocs/ui-kit-debug 1.11.0 → 1.12.4
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/_chunks/{actions-cell-renderer-xfSYiTXQ.js → actions-cell-renderer-BCEjn3-f.js} +2 -2
- package/dist/_chunks/{actions-cell-renderer-xfSYiTXQ.js.map → actions-cell-renderer-BCEjn3-f.js.map} +1 -1
- package/dist/_chunks/{anamnesis-summary-rows-d44s_whc.js → anamnesis-summary-rows-BfhxWPO3.js} +1421 -1418
- package/dist/_chunks/anamnesis-summary-rows-BfhxWPO3.js.map +1 -0
- package/dist/_chunks/appointment-card-Dzr3GeVz.js.map +1 -1
- package/dist/_chunks/appointment-timeline-DCn0Jx55.js +403 -0
- package/dist/_chunks/appointment-timeline-DCn0Jx55.js.map +1 -0
- package/dist/_chunks/{balance-badge-cell-C_Qz76x7.js → balance-badge-cell-BrlikHfT.js} +317 -290
- package/dist/_chunks/balance-badge-cell-BrlikHfT.js.map +1 -0
- package/dist/_chunks/{chart-Bkr1Sh4o.js → chart-C6eHTxkO.js} +2 -2
- package/dist/_chunks/{chart-Bkr1Sh4o.js.map → chart-C6eHTxkO.js.map} +1 -1
- package/dist/_chunks/{control-room-rail-Cj2iX9h_.js → control-room-rail-iO_BCaq1.js} +2 -2
- package/dist/_chunks/{control-room-rail-Cj2iX9h_.js.map → control-room-rail-iO_BCaq1.js.map} +1 -1
- package/dist/_chunks/{editable-currency-cell-renderer-zLf_bXvL.js → editable-currency-cell-renderer-B7TVZ5ZJ.js} +2 -2
- package/dist/_chunks/{editable-currency-cell-renderer-zLf_bXvL.js.map → editable-currency-cell-renderer-B7TVZ5ZJ.js.map} +1 -1
- package/dist/_chunks/{face-scheme-BfDi4YkW.js → face-scheme-CZaKm6fG.js} +2 -2
- package/dist/_chunks/{face-scheme-BfDi4YkW.js.map → face-scheme-CZaKm6fG.js.map} +1 -1
- package/dist/_chunks/{file-manager-Df6hyUYg.js → file-manager-Moc7sUFj.js} +3 -3
- package/dist/_chunks/{file-manager-Df6hyUYg.js.map → file-manager-Moc7sUFj.js.map} +1 -1
- package/dist/_chunks/{header-settings-CVC_davE.js → header-settings-J-ZCAfir.js} +2 -2
- package/dist/_chunks/{header-settings-CVC_davE.js.map → header-settings-J-ZCAfir.js.map} +1 -1
- package/dist/_chunks/{icon-button-group-D6SVMteH.js → icon-button-group-VCCod3Hz.js} +154 -145
- package/dist/_chunks/icon-button-group-VCCod3Hz.js.map +1 -0
- package/dist/_chunks/{link-cell-renderer-Cp2MSlJl.js → link-cell-renderer-CenJx-_7.js} +197 -181
- package/dist/_chunks/link-cell-renderer-CenJx-_7.js.map +1 -0
- package/dist/_chunks/{marketplace-app-shell-Chfdia7m.js → marketplace-app-shell-DDQXQ8hX.js} +2 -2
- package/dist/_chunks/{marketplace-app-shell-Chfdia7m.js.map → marketplace-app-shell-DDQXQ8hX.js.map} +1 -1
- package/dist/_chunks/{notes-panel-e9cJWVRg.js → notes-panel-CymneXtl.js} +93 -91
- package/dist/_chunks/notes-panel-CymneXtl.js.map +1 -0
- package/dist/_chunks/{signature-request-CW30B77U.js → signature-request-DVDTKLjM.js} +2 -2
- package/dist/_chunks/{signature-request-CW30B77U.js.map → signature-request-DVDTKLjM.js.map} +1 -1
- package/dist/_chunks/{theme-toggle-DuMhQNFS.js → theme-toggle-uEwoKjl3.js} +2 -2
- package/dist/_chunks/{theme-toggle-DuMhQNFS.js.map → theme-toggle-uEwoKjl3.js.map} +1 -1
- package/dist/_chunks/{tool-rail-CHyUmulN.js → tool-rail-8Scslq3X.js} +2 -2
- package/dist/_chunks/tool-rail-8Scslq3X.js.map +1 -0
- package/dist/_chunks/{whatsapp-button-Ca9towA4.js → whatsapp-button-CuFIHJzG.js} +27 -19
- package/dist/_chunks/{whatsapp-button-Ca9towA4.js.map → whatsapp-button-CuFIHJzG.js.map} +1 -1
- package/dist/agent-catalog.json +2 -2
- package/dist/agent-i18n/en.json +1 -1
- package/dist/components/appointment-card/appointment-card.d.ts +1 -1
- package/dist/components/appointment-card/appointment-card.d.ts.map +1 -1
- package/dist/components/appointment-timeline/appointment-timeline.agent.d.ts.map +1 -1
- package/dist/components/appointment-timeline/appointment-timeline.d.ts +8 -0
- package/dist/components/appointment-timeline/appointment-timeline.d.ts.map +1 -1
- package/dist/components/appointment-timeline/index.js +1 -1
- package/dist/components/chart/index.js +1 -1
- package/dist/components/control-room-rail/index.js +1 -1
- package/dist/components/data-table/filters/date-range-filter.d.ts +22 -0
- package/dist/components/data-table/filters/date-range-filter.d.ts.map +1 -1
- package/dist/components/data-table/index.js +3 -3
- package/dist/components/face-scheme/index.js +1 -1
- package/dist/components/file-manager/index.js +1 -1
- package/dist/components/header-settings/index.js +1 -1
- package/dist/components/icon-button-group/icon-button-group.d.ts.map +1 -1
- package/dist/components/icon-button-group/index.js +1 -1
- package/dist/components/notes-panel/index.js +1 -1
- package/dist/components/notes-panel/notes-panel.agent.d.ts.map +1 -1
- package/dist/components/notes-panel/notes-panel.d.ts +6 -0
- package/dist/components/notes-panel/notes-panel.d.ts.map +1 -1
- package/dist/components/patient-table/columns.d.ts.map +1 -1
- package/dist/components/patient-table/index.js +1 -1
- package/dist/components/theme-toggle/index.js +1 -1
- package/dist/components/tool-rail/index.js +1 -1
- package/dist/components/tool-rail/tool-rail.d.ts +1 -1
- package/dist/components/tool-rail/tool-rail.d.ts.map +1 -1
- package/dist/components/whatsapp-button/index.js +1 -1
- package/dist/components/whatsapp-button/whatsapp-button.d.ts.map +1 -1
- package/dist/host-compat.css +7 -1
- package/dist/index.js +16 -16
- package/dist/patterns/anamnesis/anamnesis-catalogue.d.ts.map +1 -1
- package/dist/patterns/anamnesis/anamnesis-compile.d.ts.map +1 -1
- package/dist/patterns/anamnesis/anamnesis-config.d.ts +18 -7
- package/dist/patterns/anamnesis/anamnesis-config.d.ts.map +1 -1
- package/dist/patterns/anamnesis/anamnesis-types.d.ts +8 -0
- package/dist/patterns/anamnesis/anamnesis-types.d.ts.map +1 -1
- package/dist/patterns/anamnesis/index.js +1 -1
- package/dist/patterns/marketplace-app-shell/index.js +1 -1
- package/dist/patterns/signature-request/index.js +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/anamnesis-summary-rows-d44s_whc.js.map +0 -1
- package/dist/_chunks/appointment-timeline-0mwtpErq.js +0 -388
- package/dist/_chunks/appointment-timeline-0mwtpErq.js.map +0 -1
- package/dist/_chunks/balance-badge-cell-C_Qz76x7.js.map +0 -1
- package/dist/_chunks/icon-button-group-D6SVMteH.js.map +0 -1
- package/dist/_chunks/link-cell-renderer-Cp2MSlJl.js.map +0 -1
- package/dist/_chunks/notes-panel-e9cJWVRg.js.map +0 -1
- package/dist/_chunks/tool-rail-CHyUmulN.js.map +0 -1
package/dist/_chunks/{signature-request-CW30B77U.js.map → signature-request-DVDTKLjM.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-request-CW30B77U.js","sources":["../../node_modules/lucide-react/dist/esm/icons/tablet.mjs","../../node_modules/lucide-react/dist/esm/icons/user-plus.mjs","../../src/patterns/signature-request/signature-request.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"rect\", { width: \"16\", height: \"20\", x: \"4\", y: \"2\", rx: \"2\", ry: \"2\", key: \"76otgf\" }],\n [\"line\", { x1: \"12\", x2: \"12.01\", y1: \"18\", y2: \"18\", key: \"1dp563\" }]\n];\nconst Tablet = createLucideIcon(\"tablet\", __iconNode);\n\nexport { __iconNode, Tablet as default };\n//# sourceMappingURL=tablet.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\", key: \"1yyitq\" }],\n [\"circle\", { cx: \"9\", cy: \"7\", r: \"4\", key: \"nufk8\" }],\n [\"line\", { x1: \"19\", x2: \"19\", y1: \"8\", y2: \"14\", key: \"1bvyxn\" }],\n [\"line\", { x1: \"22\", x2: \"16\", y1: \"11\", y2: \"11\", key: \"1shjgl\" }]\n];\nconst UserPlus = createLucideIcon(\"user-plus\", __iconNode);\n\nexport { __iconNode, UserPlus as default };\n//# sourceMappingURL=user-plus.mjs.map\n","/**\n * SignatureRequestModal — the practice-side \"Documenti firmati\" modal that\n * dispatches a document-signature request: assign the operator who must\n * counter-sign (or leave the request unassigned) and how their request is\n * delivered (their system-defined default channel arrives pre-checked),\n * build the patient-side signer roster (up to `maxSigners`, each with their\n * own delivery channel and, for on-device signing, an OTP waiver), and send.\n *\n * Runtime pattern: real consuming apps mount this in production (surfaced via\n * `src/patterns/index.ts` and the `./patterns/signature-request` subpath).\n * The component owns the form state — re-seeded from the `initial*` props\n * every time `open` flips back to `true` — while the host owns `open`, the\n * option lists, and what happens on submit. Multiple on-device signers sign\n * sequentially in roster order — the execution side is the Signing pattern's\n * multi-signer flow; this modal only encodes the intents.\n */\nimport {\n forwardRef,\n useEffect,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport {\n Mail,\n MessageSquare,\n PenLine,\n Plus,\n Tablet,\n UserPlus,\n X,\n} from 'lucide-react';\nimport { Dialog } from '../../components/dialog';\nimport { Button } from '../../components/button';\nimport { IconButton } from '../../components/icon-button';\nimport { Checkbox } from '../../components/checkbox';\nimport { WhatsAppGlyph } from '../../components/whatsapp-button';\nimport { Select } from '../../components/select';\nimport { Switch } from '../../components/switch';\nimport { Alert } from '../../components/alert';\nimport { InfoTip } from '../../components/info-tip';\nimport { Separator } from '../../components/separator';\nimport { Avatar } from '../../components/avatar';\n\n/** Delivery channel for one signer's signature request. */\nexport type SignatureChannel = 'sms' | 'email' | 'whatsapp' | 'on-device';\n\n/**\n * Delivery channel for the operator's counter-sign request. The default is\n * system defined — the assigned operator's own `defaultChannel` (e-mail or\n * SMS) arrives pre-checked; `'on-device'` is offerable only while a roster\n * signer also signs on this device.\n */\nexport type OperatorChannel = 'sms' | 'email' | 'on-device';\n\n/** One selectable person/role for the operator or signer selects. */\nexport interface SignerOption {\n value: string;\n label: string;\n /**\n * Delivery channels this person can actually receive. Omit (or pass an\n * empty list) to offer every channel. Hosts gate this from per-patient\n * capability flags — e.g. a patient with no mobile number drops `'sms'`\n * and `'whatsapp'`. Only meaningful for signer options, not operators.\n */\n availableChannels?: SignatureChannel[];\n /**\n * The delivery channel this operator's own settings resolve to — the\n * system-defined default, pre-checked when the operator is assigned.\n * Falls back to `'email'` when omitted. Only meaningful for operator\n * options, not signers.\n */\n defaultChannel?: 'sms' | 'email';\n}\n\n/** One patient-side signer row in the submission. */\nexport interface SignerRequest {\n signerId: string;\n channel: SignatureChannel;\n /** Only meaningful when `channel` is `'on-device'`. */\n skipOtp?: boolean;\n}\n\n/** Payload handed to `onRequestSignature`. */\nexport interface SignatureRequestSubmission {\n /** `null` when the counter-signing operator is left unassigned. */\n operatorId: string | null;\n /**\n * How the operator's counter-sign request is delivered. `null` while the\n * operator is unassigned. Defaults to the operator's own system-defined\n * channel unless explicitly changed in the modal.\n */\n operatorChannel: OperatorChannel | null;\n /** 1..N signers; on-device signers sign sequentially in this order. */\n signers: SignerRequest[];\n}\n\nexport interface SignatureRequestModalProps {\n /** Controlled open state. Reopening re-seeds the form from `initial*`. */\n open: boolean;\n /**\n * Fires when the dialog requests a state change (<kbd>Esc</kbd> or the\n * footer Close button). `false` is the dismiss signal — hosts typically\n * persist a \"dismissed this session\" flag there.\n */\n onOpenChange: (open: boolean) => void;\n /** Operators offered as the counter-signing signer. */\n operators: SignerOption[];\n /** Patient-side people/roles offered in each signer row. */\n signerOptions: SignerOption[];\n /** Enables the \"Assign to me\" shortcut targeting this operator. */\n currentOperatorId?: string;\n /** Offer an \"Assign later\" option in the operator select. Default `true`. */\n allowAssignLater?: boolean;\n /**\n * Preselected operator; `null` preselects \"Assign later\" (honoured only\n * while `allowAssignLater` — otherwise the first operator is seeded).\n */\n initialOperatorId?: string | null;\n /**\n * Preselected operator delivery channel. Defaults to the seeded operator's\n * system-defined `defaultChannel`. `'on-device'` is honoured only while a\n * seeded roster signer also signs on this device.\n */\n initialOperatorChannel?: OperatorChannel;\n /** Seed the signer roster. Defaults to the first option, on-device. */\n initialSigners?: SignerRequest[];\n /** Cap on roster size. Default `2`. */\n maxSigners?: number;\n /**\n * Whether an operator must counter-sign. `false` drops the operator\n * section entirely and submits `operatorId: null` — a host whose document\n * does not require a counter-signature must not be asked for one. Default\n * `true`.\n */\n requireOperator?: boolean;\n /**\n * Whether the patient side signs at all. `false` drops the signer roster\n * and submits an empty `signers` array — for documents only an operator\n * signs. Default `true`. Setting BOTH this and `requireOperator` to false\n * leaves nothing to request, so the primary action stays disabled.\n */\n requirePatient?: boolean;\n /** Disables all inputs and shows the primary action as loading. */\n busy?: boolean;\n /** Consumer-translated error shown above the footer (e.g. server failure). */\n error?: string;\n /** Override the dialog title. Defaults to the `ui.*` string. */\n title?: string;\n /** Override the dialog description. Defaults to the `ui.*` string. */\n description?: string;\n /** Receives the completed submission. The host closes via `onOpenChange`. */\n onRequestSignature: (submission: SignatureRequestSubmission) => void;\n /**\n * Extra attributes for the portaled dialog surface (e.g. `dir`/`lang`\n * when the host pins a locale below `<html>`, or a test id).\n */\n contentProps?: ComponentPropsWithoutRef<'div'>;\n}\n\nconst ASSIGN_LATER = '__assign-later__';\n\n/** Canonical channel display order; per-signer availability filters this. */\nconst CHANNEL_ORDER: SignatureChannel[] = [\n 'sms',\n 'email',\n 'whatsapp',\n 'on-device',\n];\n\n/** Internal roster row — `rowId` keys the DOM so editing a row's person\n * never remounts the row (which would drop keyboard focus). */\ninterface RosterRow extends SignerRequest {\n rowId: number;\n}\n\nfunction labelFor(options: SignerOption[], value: string): string {\n return options.find((option) => option.value === value)?.label ?? '';\n}\n\nexport const SignatureRequestModal = forwardRef<\n HTMLDivElement,\n SignatureRequestModalProps\n>(\n (\n {\n open,\n onOpenChange,\n operators,\n signerOptions,\n currentOperatorId,\n allowAssignLater = true,\n requireOperator = true,\n requirePatient = true,\n initialOperatorId,\n initialOperatorChannel,\n initialSigners,\n maxSigners = 2,\n busy = false,\n error,\n title,\n description,\n onRequestSignature,\n contentProps,\n },\n ref,\n ) => {\n const { t } = useTranslation();\n\n const nextRowId = useRef(0);\n const addButtonRef = useRef<HTMLButtonElement>(null);\n\n // Channels a given signer can receive on — the person's `availableChannels`\n // filtered into canonical order; omitted/empty means every channel.\n const channelsFor = (signerId: string): SignatureChannel[] => {\n const allowed = signerOptions.find(\n (option) => option.value === signerId,\n )?.availableChannels;\n return allowed && allowed.length > 0\n ? CHANNEL_ORDER.filter((channel) => allowed.includes(channel))\n : CHANNEL_ORDER;\n };\n\n // First available channel for a signer, preferring `preferred` when offered.\n const resolveChannel = (\n signerId: string,\n preferred: SignatureChannel,\n ): SignatureChannel => {\n const available = channelsFor(signerId);\n return available.includes(preferred) ? preferred : available[0];\n };\n\n const seedOperator = () => {\n if (initialOperatorId === null) {\n return allowAssignLater\n ? ASSIGN_LATER\n : (operators[0]?.value ?? ASSIGN_LATER);\n }\n return (\n initialOperatorId ??\n operators[0]?.value ??\n (allowAssignLater ? ASSIGN_LATER : '')\n );\n };\n const seedRows = (): RosterRow[] => {\n const seed =\n initialSigners && initialSigners.length > 0\n ? initialSigners\n : signerOptions.length > 0\n ? [\n {\n signerId: signerOptions[0].value,\n channel: resolveChannel(signerOptions[0].value, 'on-device'),\n },\n ]\n : [];\n return seed.map((signer) => ({ ...signer, rowId: nextRowId.current++ }));\n };\n\n // System-defined default for one operator — the channel their own\n // settings resolve to.\n const operatorDefaultChannel = (operatorId: string): OperatorChannel =>\n operators.find((option) => option.value === operatorId)?.defaultChannel ??\n 'email';\n\n // Seed clamp: `'on-device'` is honoured only when the seeded roster\n // makes it available, so the option is never checked-and-disabled, not\n // even for a frame.\n const seedOperatorChannel = (\n operatorId: string,\n rows: RosterRow[],\n ): OperatorChannel => {\n if (initialOperatorChannel === 'on-device') {\n return rows.some((signer) => signer.channel === 'on-device')\n ? 'on-device'\n : operatorDefaultChannel(operatorId);\n }\n return initialOperatorChannel ?? operatorDefaultChannel(operatorId);\n };\n\n const [operator, setOperator] = useState<string>(seedOperator);\n const [signers, setSigners] = useState<RosterRow[]>(seedRows);\n const [operatorChannel, setOperatorChannel] = useState<OperatorChannel>(\n () => seedOperatorChannel(operator, signers),\n );\n // Feeds the sr-only live region announcing the automatic channel\n // fallback below; any explicit choice clears it.\n const [revertedTo, setRevertedTo] = useState<OperatorChannel | null>(null);\n\n // Re-seed the form whenever the host reopens the (still-mounted) modal,\n // so a previous request's choices never leak into the next one.\n const wasOpen = useRef(open);\n useEffect(() => {\n if (open && !wasOpen.current) {\n const nextOperator = seedOperator();\n const nextRows = seedRows();\n setOperator(nextOperator);\n setSigners(nextRows);\n setOperatorChannel(seedOperatorChannel(nextOperator, nextRows));\n setRevertedTo(null);\n }\n wasOpen.current = open;\n // The seeds intentionally read the render-time props on the rising\n // edge only — prop changes while open (or closed) don't reset input.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n // Operator on-device signing piggybacks on a patient handover: it is\n // offerable only while a roster signer signs on this device, and falls\n // back to the operator's system default the moment the last on-device\n // row leaves. The fallback is announced via the live region — the\n // trigger lives in the roster section, far from the checkbox it moves.\n const anySignerOnDevice = signers.some(\n (signer) => signer.channel === 'on-device',\n );\n useEffect(() => {\n if (operatorChannel === 'on-device' && !anySignerOnDevice) {\n const fallback = operatorDefaultChannel(operator);\n setOperatorChannel(fallback);\n setRevertedTo(fallback);\n }\n // `operatorDefaultChannel` reads the render-time `operators` prop.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [operatorChannel, anySignerOnDevice, operator]);\n\n const operatorSelectOptions = allowAssignLater\n ? [\n ...operators,\n { value: ASSIGN_LATER, label: t('signatureRequest.assignLater') },\n ]\n : operators;\n const isUnassigned = operator === ASSIGN_LATER;\n\n const channelMeta: Record<\n SignatureChannel,\n { label: string; icon: React.ReactNode }\n > = {\n sms: {\n label: t('signatureRequest.viaSms'),\n icon: <MessageSquare className=\"ds:size-4\" aria-hidden />,\n },\n email: {\n label: t('signatureRequest.viaEmail'),\n icon: <Mail className=\"ds:size-4\" aria-hidden />,\n },\n whatsapp: {\n label: t('signatureRequest.viaWhatsapp'),\n icon: <WhatsAppGlyph className=\"ds:size-4\" aria-hidden />,\n },\n 'on-device': {\n label: t('signatureRequest.onThisDevice'),\n icon: <Tablet className=\"ds:size-4\" aria-hidden />,\n },\n };\n\n // Operator delivery — same checkbox visuals as the signer rows, minus\n // WhatsApp. No \"system defined\" option: the operator's own default\n // (e-mail or SMS per their settings) arrives pre-checked instead.\n // On-device greys out while no patient signer signs on this device;\n // an InfoTip explains why.\n const operatorChannelOptions: Array<{\n value: OperatorChannel;\n label: string;\n icon: React.ReactNode;\n disabled?: boolean;\n hint?: string;\n }> = [\n { value: 'sms', ...channelMeta.sms },\n { value: 'email', ...channelMeta.email },\n {\n value: 'on-device',\n ...channelMeta['on-device'],\n disabled: !anySignerOnDevice,\n hint: anySignerOnDevice\n ? undefined\n : t('signatureRequest.onDeviceUnavailableHint'),\n },\n ];\n\n const chosenIds = signers.map((signer) => signer.signerId);\n const nextFreeOption = signerOptions.find(\n (option) => !chosenIds.includes(option.value),\n );\n const canAddSigner =\n !busy && signers.length < maxSigners && nextFreeOption !== undefined;\n\n const patchSigner = (rowId: number, patch: Partial<SignerRequest>) => {\n setSigners((current) =>\n current.map((signer) =>\n signer.rowId === rowId ? { ...signer, ...patch } : signer,\n ),\n );\n };\n\n const addSigner = () => {\n if (!nextFreeOption) return;\n setSigners((current) => [\n ...current,\n {\n signerId: nextFreeOption.value,\n channel: resolveChannel(nextFreeOption.value, 'sms'),\n rowId: nextRowId.current++,\n },\n ]);\n };\n\n const removeSigner = (rowId: number) => {\n // Move focus BEFORE the row (and the focused remove button) unmounts —\n // otherwise Radix's focus scope dumps focus on the dialog container.\n addButtonRef.current?.focus();\n setSigners((current) =>\n current.filter((signer) => signer.rowId !== rowId),\n );\n };\n\n const handleRequest = () => {\n onRequestSignature({\n operatorId: !requireOperator || isUnassigned ? null : operator,\n operatorChannel:\n !requireOperator || isUnassigned ? null : operatorChannel,\n signers: requirePatient\n ? signers.map(({ rowId: _rowId, ...signer }) => signer)\n : [],\n });\n };\n\n return (\n <div ref={ref} className=\"ds:contents\" data-component=\"signature-request\">\n <Dialog open={open} onOpenChange={onOpenChange}>\n <Dialog.Content size=\"lg\" hideCloseButton {...contentProps}>\n <Dialog.Header>\n <Dialog.Title>\n {title ?? t('signatureRequest.title')}\n </Dialog.Title>\n <Dialog.Description>\n {description ?? t('signatureRequest.noSignedVersions')}\n </Dialog.Description>\n </Dialog.Header>\n\n <Dialog.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n {requireOperator ? (\n <section className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\">\n <div className=\"ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <p className=\"type-eyebrow ds:text-start ds:text-[color:var(--muted-foreground)]\">\n {t('signatureRequest.operatorSection')}\n </p>\n {currentOperatorId !== undefined ? (\n <Button\n intent=\"primary\"\n size=\"sm\"\n startIcon={<UserPlus />}\n disabled={busy}\n onClick={() => {\n setOperator(currentOperatorId);\n setOperatorChannel(\n operatorDefaultChannel(currentOperatorId),\n );\n setRevertedTo(null);\n }}\n >\n {t('signatureRequest.assignToMe')}\n </Button>\n ) : null}\n </div>\n\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n {/* Mirrors the select value — decorative for AT. No name →\n Avatar's built-in placeholder-icon fallback. */}\n <Avatar\n aria-hidden=\"true\"\n name={\n isUnassigned ? undefined : labelFor(operators, operator)\n }\n size=\"sm\"\n />\n <div className=\"ds:min-w-0 ds:flex-1 ds:text-start\">\n <Select\n options={operatorSelectOptions}\n value={operator}\n onValueChange={(value) => {\n if (!value) return;\n setOperator(value);\n // A different operator brings their own system\n // default along.\n setOperatorChannel(\n value === ASSIGN_LATER\n ? 'email'\n : operatorDefaultChannel(value),\n );\n setRevertedTo(null);\n }}\n required\n disabled={busy}\n placeholder={t('signatureRequest.operatorPlaceholder')}\n aria-label={t('signatureRequest.operatorSection')}\n />\n </div>\n </div>\n\n {/* One channel for the operator too — same mutually exclusive\n checkbox visuals as the signer rows. Hidden while the\n request is unassigned: there is nobody to deliver to. */}\n {isUnassigned ? null : (\n <div\n role=\"group\"\n aria-label={t('signatureRequest.operatorChannelLabel')}\n className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-lg)] ds:gap-y-[var(--spacing-sm)] ds:ps-[var(--spacing-xl)]\"\n >\n {operatorChannelOptions.map((option) => (\n <span\n key={option.value}\n className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]\"\n >\n <Checkbox\n checked={operatorChannel === option.value}\n disabled={busy || option.disabled}\n onCheckedChange={(checked) => {\n if (checked !== true) return;\n setOperatorChannel(option.value);\n setRevertedTo(null);\n }}\n label={\n <span className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n <span\n aria-hidden=\"true\"\n className=\"ds:text-[var(--accent)]\"\n >\n {option.icon}\n </span>\n {option.label}\n </span>\n }\n />\n {/* Sibling of the checkbox, never inside its label —\n the tip is its own interactive control. The wider\n gap keeps the tip's touch hit-area off the label. */}\n {option.hint ? (\n <InfoTip size=\"sm\" content={option.hint} />\n ) : null}\n </span>\n ))}\n </div>\n )}\n\n {/* Announces the automatic on-device → default fallback: the\n trigger (the patient's channel change) sits in another\n section, so the moved checkmark alone is not enough. */}\n <span role=\"status\" className=\"ds:sr-only\">\n {revertedTo\n ? t('signatureRequest.operatorChannelReverted', {\n channel: channelMeta[revertedTo].label,\n })\n : null}\n </span>\n </section>\n ) : null}\n\n {/* The rule only separates two sections that are both there. */}\n {requireOperator && requirePatient ? (\n <Separator decorative />\n ) : null}\n\n {requirePatient ? (\n <section className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:text-start\">\n <div className=\"ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <p className=\"type-eyebrow ds:text-[color:var(--muted-foreground)]\">\n {t('signatureRequest.signersSection')}\n </p>\n {/* Offered only when the roster holds more than one\n person. A patient with nobody else to sign for them saw\n a permanently greyed action — a promise the modal could\n never keep. With two or more it stays, greying (not\n hiding) once every seat is taken so the cap reads. */}\n {signerOptions.length > 1 ? (\n <Button\n ref={addButtonRef}\n intent=\"primary\"\n size=\"sm\"\n startIcon={<Plus />}\n disabled={!canAddSigner}\n onClick={addSigner}\n >\n {t('signatureRequest.addSigner')}\n </Button>\n ) : null}\n </div>\n\n {signers.map((signer) => {\n const rowOptions = signerOptions.filter(\n (option) =>\n option.value === signer.signerId ||\n !chosenIds.includes(option.value),\n );\n const rowLabel = labelFor(signerOptions, signer.signerId);\n const rowChannelOptions = channelsFor(signer.signerId).map(\n (channel) => ({\n value: channel,\n ...channelMeta[channel],\n }),\n );\n return (\n <div\n key={signer.rowId}\n role=\"group\"\n aria-label={rowLabel}\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\"\n >\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n {/* Mirrors the select value — decorative for AT. */}\n <Avatar\n aria-hidden=\"true\"\n name={rowLabel}\n size=\"sm\"\n />\n <div className=\"ds:min-w-0 ds:flex-1\">\n <Select\n options={rowOptions}\n value={signer.signerId}\n onValueChange={(value) => {\n if (!value) return;\n const channel = resolveChannel(\n value,\n signer.channel,\n );\n patchSigner(signer.rowId, {\n signerId: value,\n channel,\n skipOtp:\n channel === 'on-device'\n ? signer.skipOtp\n : undefined,\n });\n }}\n required\n disabled={busy}\n placeholder={t(\n 'signatureRequest.signerPlaceholder',\n )}\n aria-label={t(\n 'signatureRequest.signerPlaceholder',\n )}\n />\n </div>\n {signers.length > 1 ? (\n <IconButton\n intent=\"ghost\"\n size=\"sm\"\n icon={<X />}\n disabled={busy}\n aria-label={t('signatureRequest.removeSigner')}\n onClick={() => removeSigner(signer.rowId)}\n />\n ) : null}\n </div>\n\n {/* One channel per signer — checkbox visuals, but the\n choice is mutually exclusive: checking a channel\n unchecks the others, and the active one can't be\n unchecked. */}\n <div\n role=\"group\"\n aria-label={t('signatureRequest.channelLabel')}\n className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-lg)] ds:gap-y-[var(--spacing-sm)] ds:ps-[var(--spacing-xl)]\"\n >\n {rowChannelOptions.map((option) => (\n <Checkbox\n key={option.value}\n checked={signer.channel === option.value}\n disabled={busy}\n onCheckedChange={(checked) =>\n checked === true &&\n patchSigner(signer.rowId, {\n channel: option.value,\n skipOtp: undefined,\n })\n }\n label={\n <span className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n <span\n aria-hidden=\"true\"\n className=\"ds:text-[var(--accent)]\"\n >\n {option.icon}\n </span>\n {option.label}\n </span>\n }\n />\n ))}\n </div>\n\n {signer.channel === 'on-device' ? (\n <div className=\"ds:ps-[var(--spacing-xl)]\">\n <Switch\n label={t('signatureRequest.noOtp')}\n checked={signer.skipOtp === true}\n disabled={busy}\n onCheckedChange={(checked) =>\n patchSigner(signer.rowId, { skipOtp: checked })\n }\n />\n </div>\n ) : null}\n </div>\n );\n })}\n </section>\n ) : null}\n\n {/* Dedicated alert area — one warning regardless of how many\n signers waive OTP, stacked with any submission error, all at\n the same full width as the operator hint. */}\n {signers.some(\n (signer) =>\n signer.channel === 'on-device' && signer.skipOtp === true,\n ) ? (\n <Alert variant=\"warning\">\n <Alert.Description>\n {t('signatureRequest.noOtpWarning')}\n </Alert.Description>\n </Alert>\n ) : null}\n {error ? (\n <Alert variant=\"error\">\n <Alert.Description>{error}</Alert.Description>\n </Alert>\n ) : null}\n </Dialog.Body>\n\n <Dialog.Footer>\n <Button\n intent=\"primary\"\n startIcon={<PenLine />}\n onClick={handleRequest}\n disabled={\n busy ||\n (requirePatient && signers.length === 0) ||\n (!requirePatient && !requireOperator)\n }\n loading={busy}\n >\n {t('signatureRequest.requestSignature')}\n </Button>\n <Dialog.Close asChild>\n <Button intent=\"outline\" disabled={busy}>\n {t('signatureRequest.close')}\n </Button>\n </Dialog.Close>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n </div>\n );\n },\n);\nSignatureRequestModal.displayName = 'SignatureRequestModal';\n"],"names":["__iconNode","Tablet","createLucideIcon","UserPlus","ASSIGN_LATER","CHANNEL_ORDER","labelFor","options","value","_a","option","SignatureRequestModal","forwardRef","open","onOpenChange","operators","signerOptions","currentOperatorId","allowAssignLater","requireOperator","requirePatient","initialOperatorId","initialOperatorChannel","initialSigners","maxSigners","busy","error","title","description","onRequestSignature","contentProps","ref","t","useTranslation","nextRowId","useRef","addButtonRef","channelsFor","signerId","allowed","channel","resolveChannel","preferred","available","seedOperator","_b","seedRows","signer","operatorDefaultChannel","operatorId","seedOperatorChannel","rows","operator","setOperator","useState","signers","setSigners","operatorChannel","setOperatorChannel","revertedTo","setRevertedTo","wasOpen","useEffect","nextOperator","nextRows","anySignerOnDevice","fallback","operatorSelectOptions","isUnassigned","channelMeta","jsx","MessageSquare","Mail","WhatsAppGlyph","operatorChannelOptions","chosenIds","nextFreeOption","canAddSigner","patchSigner","rowId","patch","current","addSigner","removeSigner","handleRequest","_rowId","Dialog","jsxs","Button","Avatar","Select","Checkbox","checked","InfoTip","Separator","Plus","rowOptions","rowLabel","rowChannelOptions","IconButton","X","Switch","Alert","PenLine"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,OAAO,MAAM,Q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D;AAAA,YAEvB,SAASM;AAAA,YAER,YAAE,mCAAmC;AAAA,UAAA;AAAA,QAAA;AAAA,QAExC,gBAAA6C,EAACgB,EAAO,OAAP,EAAa,SAAO,IACnB,UAAA,gBAAAhB,EAACkB,GAAA,EAAO,QAAO,WAAU,UAAU/D,GAChC,UAAAO,EAAE,wBAAwB,GAC7B,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,EAAA,CACF,GACF,GACF;AAAA,EAEJ;AACF;AACArB,GAAsB,cAAc;","x_google_ignoreList":[0,1]}
|
|
1
|
+
{"version":3,"file":"signature-request-DVDTKLjM.js","sources":["../../node_modules/lucide-react/dist/esm/icons/tablet.mjs","../../node_modules/lucide-react/dist/esm/icons/user-plus.mjs","../../src/patterns/signature-request/signature-request.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"rect\", { width: \"16\", height: \"20\", x: \"4\", y: \"2\", rx: \"2\", ry: \"2\", key: \"76otgf\" }],\n [\"line\", { x1: \"12\", x2: \"12.01\", y1: \"18\", y2: \"18\", key: \"1dp563\" }]\n];\nconst Tablet = createLucideIcon(\"tablet\", __iconNode);\n\nexport { __iconNode, Tablet as default };\n//# sourceMappingURL=tablet.mjs.map\n","/**\n * @license lucide-react v1.22.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\", key: \"1yyitq\" }],\n [\"circle\", { cx: \"9\", cy: \"7\", r: \"4\", key: \"nufk8\" }],\n [\"line\", { x1: \"19\", x2: \"19\", y1: \"8\", y2: \"14\", key: \"1bvyxn\" }],\n [\"line\", { x1: \"22\", x2: \"16\", y1: \"11\", y2: \"11\", key: \"1shjgl\" }]\n];\nconst UserPlus = createLucideIcon(\"user-plus\", __iconNode);\n\nexport { __iconNode, UserPlus as default };\n//# sourceMappingURL=user-plus.mjs.map\n","/**\n * SignatureRequestModal — the practice-side \"Documenti firmati\" modal that\n * dispatches a document-signature request: assign the operator who must\n * counter-sign (or leave the request unassigned) and how their request is\n * delivered (their system-defined default channel arrives pre-checked),\n * build the patient-side signer roster (up to `maxSigners`, each with their\n * own delivery channel and, for on-device signing, an OTP waiver), and send.\n *\n * Runtime pattern: real consuming apps mount this in production (surfaced via\n * `src/patterns/index.ts` and the `./patterns/signature-request` subpath).\n * The component owns the form state — re-seeded from the `initial*` props\n * every time `open` flips back to `true` — while the host owns `open`, the\n * option lists, and what happens on submit. Multiple on-device signers sign\n * sequentially in roster order — the execution side is the Signing pattern's\n * multi-signer flow; this modal only encodes the intents.\n */\nimport {\n forwardRef,\n useEffect,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport {\n Mail,\n MessageSquare,\n PenLine,\n Plus,\n Tablet,\n UserPlus,\n X,\n} from 'lucide-react';\nimport { Dialog } from '../../components/dialog';\nimport { Button } from '../../components/button';\nimport { IconButton } from '../../components/icon-button';\nimport { Checkbox } from '../../components/checkbox';\nimport { WhatsAppGlyph } from '../../components/whatsapp-button';\nimport { Select } from '../../components/select';\nimport { Switch } from '../../components/switch';\nimport { Alert } from '../../components/alert';\nimport { InfoTip } from '../../components/info-tip';\nimport { Separator } from '../../components/separator';\nimport { Avatar } from '../../components/avatar';\n\n/** Delivery channel for one signer's signature request. */\nexport type SignatureChannel = 'sms' | 'email' | 'whatsapp' | 'on-device';\n\n/**\n * Delivery channel for the operator's counter-sign request. The default is\n * system defined — the assigned operator's own `defaultChannel` (e-mail or\n * SMS) arrives pre-checked; `'on-device'` is offerable only while a roster\n * signer also signs on this device.\n */\nexport type OperatorChannel = 'sms' | 'email' | 'on-device';\n\n/** One selectable person/role for the operator or signer selects. */\nexport interface SignerOption {\n value: string;\n label: string;\n /**\n * Delivery channels this person can actually receive. Omit (or pass an\n * empty list) to offer every channel. Hosts gate this from per-patient\n * capability flags — e.g. a patient with no mobile number drops `'sms'`\n * and `'whatsapp'`. Only meaningful for signer options, not operators.\n */\n availableChannels?: SignatureChannel[];\n /**\n * The delivery channel this operator's own settings resolve to — the\n * system-defined default, pre-checked when the operator is assigned.\n * Falls back to `'email'` when omitted. Only meaningful for operator\n * options, not signers.\n */\n defaultChannel?: 'sms' | 'email';\n}\n\n/** One patient-side signer row in the submission. */\nexport interface SignerRequest {\n signerId: string;\n channel: SignatureChannel;\n /** Only meaningful when `channel` is `'on-device'`. */\n skipOtp?: boolean;\n}\n\n/** Payload handed to `onRequestSignature`. */\nexport interface SignatureRequestSubmission {\n /** `null` when the counter-signing operator is left unassigned. */\n operatorId: string | null;\n /**\n * How the operator's counter-sign request is delivered. `null` while the\n * operator is unassigned. Defaults to the operator's own system-defined\n * channel unless explicitly changed in the modal.\n */\n operatorChannel: OperatorChannel | null;\n /** 1..N signers; on-device signers sign sequentially in this order. */\n signers: SignerRequest[];\n}\n\nexport interface SignatureRequestModalProps {\n /** Controlled open state. Reopening re-seeds the form from `initial*`. */\n open: boolean;\n /**\n * Fires when the dialog requests a state change (<kbd>Esc</kbd> or the\n * footer Close button). `false` is the dismiss signal — hosts typically\n * persist a \"dismissed this session\" flag there.\n */\n onOpenChange: (open: boolean) => void;\n /** Operators offered as the counter-signing signer. */\n operators: SignerOption[];\n /** Patient-side people/roles offered in each signer row. */\n signerOptions: SignerOption[];\n /** Enables the \"Assign to me\" shortcut targeting this operator. */\n currentOperatorId?: string;\n /** Offer an \"Assign later\" option in the operator select. Default `true`. */\n allowAssignLater?: boolean;\n /**\n * Preselected operator; `null` preselects \"Assign later\" (honoured only\n * while `allowAssignLater` — otherwise the first operator is seeded).\n */\n initialOperatorId?: string | null;\n /**\n * Preselected operator delivery channel. Defaults to the seeded operator's\n * system-defined `defaultChannel`. `'on-device'` is honoured only while a\n * seeded roster signer also signs on this device.\n */\n initialOperatorChannel?: OperatorChannel;\n /** Seed the signer roster. Defaults to the first option, on-device. */\n initialSigners?: SignerRequest[];\n /** Cap on roster size. Default `2`. */\n maxSigners?: number;\n /**\n * Whether an operator must counter-sign. `false` drops the operator\n * section entirely and submits `operatorId: null` — a host whose document\n * does not require a counter-signature must not be asked for one. Default\n * `true`.\n */\n requireOperator?: boolean;\n /**\n * Whether the patient side signs at all. `false` drops the signer roster\n * and submits an empty `signers` array — for documents only an operator\n * signs. Default `true`. Setting BOTH this and `requireOperator` to false\n * leaves nothing to request, so the primary action stays disabled.\n */\n requirePatient?: boolean;\n /** Disables all inputs and shows the primary action as loading. */\n busy?: boolean;\n /** Consumer-translated error shown above the footer (e.g. server failure). */\n error?: string;\n /** Override the dialog title. Defaults to the `ui.*` string. */\n title?: string;\n /** Override the dialog description. Defaults to the `ui.*` string. */\n description?: string;\n /** Receives the completed submission. The host closes via `onOpenChange`. */\n onRequestSignature: (submission: SignatureRequestSubmission) => void;\n /**\n * Extra attributes for the portaled dialog surface (e.g. `dir`/`lang`\n * when the host pins a locale below `<html>`, or a test id).\n */\n contentProps?: ComponentPropsWithoutRef<'div'>;\n}\n\nconst ASSIGN_LATER = '__assign-later__';\n\n/** Canonical channel display order; per-signer availability filters this. */\nconst CHANNEL_ORDER: SignatureChannel[] = [\n 'sms',\n 'email',\n 'whatsapp',\n 'on-device',\n];\n\n/** Internal roster row — `rowId` keys the DOM so editing a row's person\n * never remounts the row (which would drop keyboard focus). */\ninterface RosterRow extends SignerRequest {\n rowId: number;\n}\n\nfunction labelFor(options: SignerOption[], value: string): string {\n return options.find((option) => option.value === value)?.label ?? '';\n}\n\nexport const SignatureRequestModal = forwardRef<\n HTMLDivElement,\n SignatureRequestModalProps\n>(\n (\n {\n open,\n onOpenChange,\n operators,\n signerOptions,\n currentOperatorId,\n allowAssignLater = true,\n requireOperator = true,\n requirePatient = true,\n initialOperatorId,\n initialOperatorChannel,\n initialSigners,\n maxSigners = 2,\n busy = false,\n error,\n title,\n description,\n onRequestSignature,\n contentProps,\n },\n ref,\n ) => {\n const { t } = useTranslation();\n\n const nextRowId = useRef(0);\n const addButtonRef = useRef<HTMLButtonElement>(null);\n\n // Channels a given signer can receive on — the person's `availableChannels`\n // filtered into canonical order; omitted/empty means every channel.\n const channelsFor = (signerId: string): SignatureChannel[] => {\n const allowed = signerOptions.find(\n (option) => option.value === signerId,\n )?.availableChannels;\n return allowed && allowed.length > 0\n ? CHANNEL_ORDER.filter((channel) => allowed.includes(channel))\n : CHANNEL_ORDER;\n };\n\n // First available channel for a signer, preferring `preferred` when offered.\n const resolveChannel = (\n signerId: string,\n preferred: SignatureChannel,\n ): SignatureChannel => {\n const available = channelsFor(signerId);\n return available.includes(preferred) ? preferred : available[0];\n };\n\n const seedOperator = () => {\n if (initialOperatorId === null) {\n return allowAssignLater\n ? ASSIGN_LATER\n : (operators[0]?.value ?? ASSIGN_LATER);\n }\n return (\n initialOperatorId ??\n operators[0]?.value ??\n (allowAssignLater ? ASSIGN_LATER : '')\n );\n };\n const seedRows = (): RosterRow[] => {\n const seed =\n initialSigners && initialSigners.length > 0\n ? initialSigners\n : signerOptions.length > 0\n ? [\n {\n signerId: signerOptions[0].value,\n channel: resolveChannel(signerOptions[0].value, 'on-device'),\n },\n ]\n : [];\n return seed.map((signer) => ({ ...signer, rowId: nextRowId.current++ }));\n };\n\n // System-defined default for one operator — the channel their own\n // settings resolve to.\n const operatorDefaultChannel = (operatorId: string): OperatorChannel =>\n operators.find((option) => option.value === operatorId)?.defaultChannel ??\n 'email';\n\n // Seed clamp: `'on-device'` is honoured only when the seeded roster\n // makes it available, so the option is never checked-and-disabled, not\n // even for a frame.\n const seedOperatorChannel = (\n operatorId: string,\n rows: RosterRow[],\n ): OperatorChannel => {\n if (initialOperatorChannel === 'on-device') {\n return rows.some((signer) => signer.channel === 'on-device')\n ? 'on-device'\n : operatorDefaultChannel(operatorId);\n }\n return initialOperatorChannel ?? operatorDefaultChannel(operatorId);\n };\n\n const [operator, setOperator] = useState<string>(seedOperator);\n const [signers, setSigners] = useState<RosterRow[]>(seedRows);\n const [operatorChannel, setOperatorChannel] = useState<OperatorChannel>(\n () => seedOperatorChannel(operator, signers),\n );\n // Feeds the sr-only live region announcing the automatic channel\n // fallback below; any explicit choice clears it.\n const [revertedTo, setRevertedTo] = useState<OperatorChannel | null>(null);\n\n // Re-seed the form whenever the host reopens the (still-mounted) modal,\n // so a previous request's choices never leak into the next one.\n const wasOpen = useRef(open);\n useEffect(() => {\n if (open && !wasOpen.current) {\n const nextOperator = seedOperator();\n const nextRows = seedRows();\n setOperator(nextOperator);\n setSigners(nextRows);\n setOperatorChannel(seedOperatorChannel(nextOperator, nextRows));\n setRevertedTo(null);\n }\n wasOpen.current = open;\n // The seeds intentionally read the render-time props on the rising\n // edge only — prop changes while open (or closed) don't reset input.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n // Operator on-device signing piggybacks on a patient handover: it is\n // offerable only while a roster signer signs on this device, and falls\n // back to the operator's system default the moment the last on-device\n // row leaves. The fallback is announced via the live region — the\n // trigger lives in the roster section, far from the checkbox it moves.\n const anySignerOnDevice = signers.some(\n (signer) => signer.channel === 'on-device',\n );\n useEffect(() => {\n if (operatorChannel === 'on-device' && !anySignerOnDevice) {\n const fallback = operatorDefaultChannel(operator);\n setOperatorChannel(fallback);\n setRevertedTo(fallback);\n }\n // `operatorDefaultChannel` reads the render-time `operators` prop.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [operatorChannel, anySignerOnDevice, operator]);\n\n const operatorSelectOptions = allowAssignLater\n ? [\n ...operators,\n { value: ASSIGN_LATER, label: t('signatureRequest.assignLater') },\n ]\n : operators;\n const isUnassigned = operator === ASSIGN_LATER;\n\n const channelMeta: Record<\n SignatureChannel,\n { label: string; icon: React.ReactNode }\n > = {\n sms: {\n label: t('signatureRequest.viaSms'),\n icon: <MessageSquare className=\"ds:size-4\" aria-hidden />,\n },\n email: {\n label: t('signatureRequest.viaEmail'),\n icon: <Mail className=\"ds:size-4\" aria-hidden />,\n },\n whatsapp: {\n label: t('signatureRequest.viaWhatsapp'),\n icon: <WhatsAppGlyph className=\"ds:size-4\" aria-hidden />,\n },\n 'on-device': {\n label: t('signatureRequest.onThisDevice'),\n icon: <Tablet className=\"ds:size-4\" aria-hidden />,\n },\n };\n\n // Operator delivery — same checkbox visuals as the signer rows, minus\n // WhatsApp. No \"system defined\" option: the operator's own default\n // (e-mail or SMS per their settings) arrives pre-checked instead.\n // On-device greys out while no patient signer signs on this device;\n // an InfoTip explains why.\n const operatorChannelOptions: Array<{\n value: OperatorChannel;\n label: string;\n icon: React.ReactNode;\n disabled?: boolean;\n hint?: string;\n }> = [\n { value: 'sms', ...channelMeta.sms },\n { value: 'email', ...channelMeta.email },\n {\n value: 'on-device',\n ...channelMeta['on-device'],\n disabled: !anySignerOnDevice,\n hint: anySignerOnDevice\n ? undefined\n : t('signatureRequest.onDeviceUnavailableHint'),\n },\n ];\n\n const chosenIds = signers.map((signer) => signer.signerId);\n const nextFreeOption = signerOptions.find(\n (option) => !chosenIds.includes(option.value),\n );\n const canAddSigner =\n !busy && signers.length < maxSigners && nextFreeOption !== undefined;\n\n const patchSigner = (rowId: number, patch: Partial<SignerRequest>) => {\n setSigners((current) =>\n current.map((signer) =>\n signer.rowId === rowId ? { ...signer, ...patch } : signer,\n ),\n );\n };\n\n const addSigner = () => {\n if (!nextFreeOption) return;\n setSigners((current) => [\n ...current,\n {\n signerId: nextFreeOption.value,\n channel: resolveChannel(nextFreeOption.value, 'sms'),\n rowId: nextRowId.current++,\n },\n ]);\n };\n\n const removeSigner = (rowId: number) => {\n // Move focus BEFORE the row (and the focused remove button) unmounts —\n // otherwise Radix's focus scope dumps focus on the dialog container.\n addButtonRef.current?.focus();\n setSigners((current) =>\n current.filter((signer) => signer.rowId !== rowId),\n );\n };\n\n const handleRequest = () => {\n onRequestSignature({\n operatorId: !requireOperator || isUnassigned ? null : operator,\n operatorChannel:\n !requireOperator || isUnassigned ? null : operatorChannel,\n signers: requirePatient\n ? signers.map(({ rowId: _rowId, ...signer }) => signer)\n : [],\n });\n };\n\n return (\n <div ref={ref} className=\"ds:contents\" data-component=\"signature-request\">\n <Dialog open={open} onOpenChange={onOpenChange}>\n <Dialog.Content size=\"lg\" hideCloseButton {...contentProps}>\n <Dialog.Header>\n <Dialog.Title>\n {title ?? t('signatureRequest.title')}\n </Dialog.Title>\n <Dialog.Description>\n {description ?? t('signatureRequest.noSignedVersions')}\n </Dialog.Description>\n </Dialog.Header>\n\n <Dialog.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n {requireOperator ? (\n <section className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\">\n <div className=\"ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <p className=\"type-eyebrow ds:text-start ds:text-[color:var(--muted-foreground)]\">\n {t('signatureRequest.operatorSection')}\n </p>\n {currentOperatorId !== undefined ? (\n <Button\n intent=\"primary\"\n size=\"sm\"\n startIcon={<UserPlus />}\n disabled={busy}\n onClick={() => {\n setOperator(currentOperatorId);\n setOperatorChannel(\n operatorDefaultChannel(currentOperatorId),\n );\n setRevertedTo(null);\n }}\n >\n {t('signatureRequest.assignToMe')}\n </Button>\n ) : null}\n </div>\n\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n {/* Mirrors the select value — decorative for AT. No name →\n Avatar's built-in placeholder-icon fallback. */}\n <Avatar\n aria-hidden=\"true\"\n name={\n isUnassigned ? undefined : labelFor(operators, operator)\n }\n size=\"sm\"\n />\n <div className=\"ds:min-w-0 ds:flex-1 ds:text-start\">\n <Select\n options={operatorSelectOptions}\n value={operator}\n onValueChange={(value) => {\n if (!value) return;\n setOperator(value);\n // A different operator brings their own system\n // default along.\n setOperatorChannel(\n value === ASSIGN_LATER\n ? 'email'\n : operatorDefaultChannel(value),\n );\n setRevertedTo(null);\n }}\n required\n disabled={busy}\n placeholder={t('signatureRequest.operatorPlaceholder')}\n aria-label={t('signatureRequest.operatorSection')}\n />\n </div>\n </div>\n\n {/* One channel for the operator too — same mutually exclusive\n checkbox visuals as the signer rows. Hidden while the\n request is unassigned: there is nobody to deliver to. */}\n {isUnassigned ? null : (\n <div\n role=\"group\"\n aria-label={t('signatureRequest.operatorChannelLabel')}\n className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-lg)] ds:gap-y-[var(--spacing-sm)] ds:ps-[var(--spacing-xl)]\"\n >\n {operatorChannelOptions.map((option) => (\n <span\n key={option.value}\n className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]\"\n >\n <Checkbox\n checked={operatorChannel === option.value}\n disabled={busy || option.disabled}\n onCheckedChange={(checked) => {\n if (checked !== true) return;\n setOperatorChannel(option.value);\n setRevertedTo(null);\n }}\n label={\n <span className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n <span\n aria-hidden=\"true\"\n className=\"ds:text-[var(--accent)]\"\n >\n {option.icon}\n </span>\n {option.label}\n </span>\n }\n />\n {/* Sibling of the checkbox, never inside its label —\n the tip is its own interactive control. The wider\n gap keeps the tip's touch hit-area off the label. */}\n {option.hint ? (\n <InfoTip size=\"sm\" content={option.hint} />\n ) : null}\n </span>\n ))}\n </div>\n )}\n\n {/* Announces the automatic on-device → default fallback: the\n trigger (the patient's channel change) sits in another\n section, so the moved checkmark alone is not enough. */}\n <span role=\"status\" className=\"ds:sr-only\">\n {revertedTo\n ? t('signatureRequest.operatorChannelReverted', {\n channel: channelMeta[revertedTo].label,\n })\n : null}\n </span>\n </section>\n ) : null}\n\n {/* The rule only separates two sections that are both there. */}\n {requireOperator && requirePatient ? (\n <Separator decorative />\n ) : null}\n\n {requirePatient ? (\n <section className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:text-start\">\n <div className=\"ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <p className=\"type-eyebrow ds:text-[color:var(--muted-foreground)]\">\n {t('signatureRequest.signersSection')}\n </p>\n {/* Offered only when the roster holds more than one\n person. A patient with nobody else to sign for them saw\n a permanently greyed action — a promise the modal could\n never keep. With two or more it stays, greying (not\n hiding) once every seat is taken so the cap reads. */}\n {signerOptions.length > 1 ? (\n <Button\n ref={addButtonRef}\n intent=\"primary\"\n size=\"sm\"\n startIcon={<Plus />}\n disabled={!canAddSigner}\n onClick={addSigner}\n >\n {t('signatureRequest.addSigner')}\n </Button>\n ) : null}\n </div>\n\n {signers.map((signer) => {\n const rowOptions = signerOptions.filter(\n (option) =>\n option.value === signer.signerId ||\n !chosenIds.includes(option.value),\n );\n const rowLabel = labelFor(signerOptions, signer.signerId);\n const rowChannelOptions = channelsFor(signer.signerId).map(\n (channel) => ({\n value: channel,\n ...channelMeta[channel],\n }),\n );\n return (\n <div\n key={signer.rowId}\n role=\"group\"\n aria-label={rowLabel}\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\"\n >\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n {/* Mirrors the select value — decorative for AT. */}\n <Avatar\n aria-hidden=\"true\"\n name={rowLabel}\n size=\"sm\"\n />\n <div className=\"ds:min-w-0 ds:flex-1\">\n <Select\n options={rowOptions}\n value={signer.signerId}\n onValueChange={(value) => {\n if (!value) return;\n const channel = resolveChannel(\n value,\n signer.channel,\n );\n patchSigner(signer.rowId, {\n signerId: value,\n channel,\n skipOtp:\n channel === 'on-device'\n ? signer.skipOtp\n : undefined,\n });\n }}\n required\n disabled={busy}\n placeholder={t(\n 'signatureRequest.signerPlaceholder',\n )}\n aria-label={t(\n 'signatureRequest.signerPlaceholder',\n )}\n />\n </div>\n {signers.length > 1 ? (\n <IconButton\n intent=\"ghost\"\n size=\"sm\"\n icon={<X />}\n disabled={busy}\n aria-label={t('signatureRequest.removeSigner')}\n onClick={() => removeSigner(signer.rowId)}\n />\n ) : null}\n </div>\n\n {/* One channel per signer — checkbox visuals, but the\n choice is mutually exclusive: checking a channel\n unchecks the others, and the active one can't be\n unchecked. */}\n <div\n role=\"group\"\n aria-label={t('signatureRequest.channelLabel')}\n className=\"ds:flex ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-lg)] ds:gap-y-[var(--spacing-sm)] ds:ps-[var(--spacing-xl)]\"\n >\n {rowChannelOptions.map((option) => (\n <Checkbox\n key={option.value}\n checked={signer.channel === option.value}\n disabled={busy}\n onCheckedChange={(checked) =>\n checked === true &&\n patchSigner(signer.rowId, {\n channel: option.value,\n skipOtp: undefined,\n })\n }\n label={\n <span className=\"ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]\">\n <span\n aria-hidden=\"true\"\n className=\"ds:text-[var(--accent)]\"\n >\n {option.icon}\n </span>\n {option.label}\n </span>\n }\n />\n ))}\n </div>\n\n {signer.channel === 'on-device' ? (\n <div className=\"ds:ps-[var(--spacing-xl)]\">\n <Switch\n label={t('signatureRequest.noOtp')}\n checked={signer.skipOtp === true}\n disabled={busy}\n onCheckedChange={(checked) =>\n patchSigner(signer.rowId, { skipOtp: checked })\n }\n />\n </div>\n ) : null}\n </div>\n );\n })}\n </section>\n ) : null}\n\n {/* Dedicated alert area — one warning regardless of how many\n signers waive OTP, stacked with any submission error, all at\n the same full width as the operator hint. */}\n {signers.some(\n (signer) =>\n signer.channel === 'on-device' && signer.skipOtp === true,\n ) ? (\n <Alert variant=\"warning\">\n <Alert.Description>\n {t('signatureRequest.noOtpWarning')}\n </Alert.Description>\n </Alert>\n ) : null}\n {error ? (\n <Alert variant=\"error\">\n <Alert.Description>{error}</Alert.Description>\n </Alert>\n ) : null}\n </Dialog.Body>\n\n <Dialog.Footer>\n <Button\n intent=\"primary\"\n startIcon={<PenLine />}\n onClick={handleRequest}\n disabled={\n busy ||\n (requirePatient && signers.length === 0) ||\n (!requirePatient && !requireOperator)\n }\n loading={busy}\n >\n {t('signatureRequest.requestSignature')}\n </Button>\n <Dialog.Close asChild>\n <Button intent=\"outline\" disabled={busy}>\n {t('signatureRequest.close')}\n </Button>\n </Dialog.Close>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n </div>\n );\n },\n);\nSignatureRequestModal.displayName = 'SignatureRequestModal';\n"],"names":["__iconNode","Tablet","createLucideIcon","UserPlus","ASSIGN_LATER","CHANNEL_ORDER","labelFor","options","value","_a","option","SignatureRequestModal","forwardRef","open","onOpenChange","operators","signerOptions","currentOperatorId","allowAssignLater","requireOperator","requirePatient","initialOperatorId","initialOperatorChannel","initialSigners","maxSigners","busy","error","title","description","onRequestSignature","contentProps","ref","t","useTranslation","nextRowId","useRef","addButtonRef","channelsFor","signerId","allowed","channel","resolveChannel","preferred","available","seedOperator","_b","seedRows","signer","operatorDefaultChannel","operatorId","seedOperatorChannel","rows","operator","setOperator","useState","signers","setSigners","operatorChannel","setOperatorChannel","revertedTo","setRevertedTo","wasOpen","useEffect","nextOperator","nextRows","anySignerOnDevice","fallback","operatorSelectOptions","isUnassigned","channelMeta","jsx","MessageSquare","Mail","WhatsAppGlyph","operatorChannelOptions","chosenIds","nextFreeOption","canAddSigner","patchSigner","rowId","patch","current","addSigner","removeSigner","handleRequest","_rowId","Dialog","jsxs","Button","Avatar","Select","Checkbox","checked","InfoTip","Separator","Plus","rowOptions","rowLabel","rowChannelOptions","IconButton","X","Switch","Alert","PenLine"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB,CAAC,QAAQ,EAAE,OAAO,MAAM,QAAQ,MAAM,GAAG,KAAK,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,KAAK,UAAU;AAAA,EACvF,CAAC,QAAQ,EAAE,IAAI,MAAM,IAAI,SAAS,IAAI,MAAM,IAAI,MAAM,KAAK,SAAQ,CAAE;AACvE,GACMC,KAASC,GAAiB,UAAUF,EAAU;ACbpD;AAAA;AAA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CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,EAAA,CACF,GACF,GACF;AAAA,EAEJ;AACF;AACArB,GAAsB,cAAc;","x_google_ignoreList":[0,1]}
|
|
@@ -3,7 +3,7 @@ import { forwardRef as M, useRef as k, useImperativeHandle as N, useMemo as _, u
|
|
|
3
3
|
import { c as P } from "./index-D2ZczOXr.js";
|
|
4
4
|
import { useTranslation as g } from "react-i18next";
|
|
5
5
|
import { I as y } from "./icon-button-DA2CAGHZ.js";
|
|
6
|
-
import { I as j } from "./icon-button-group-
|
|
6
|
+
import { I as j } from "./icon-button-group-VCCod3Hz.js";
|
|
7
7
|
import { S as K } from "./switch-OILsBLWo.js";
|
|
8
8
|
import { D as o } from "./dropdown-menu-DU-Hrf33.js";
|
|
9
9
|
import { u as x } from "./use-theme-CAuo6EYT.js";
|
|
@@ -364,4 +364,4 @@ export {
|
|
|
364
364
|
F as T,
|
|
365
365
|
D as t
|
|
366
366
|
};
|
|
367
|
-
//# sourceMappingURL=theme-toggle-
|
|
367
|
+
//# sourceMappingURL=theme-toggle-uEwoKjl3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-toggle-DuMhQNFS.js","sources":["../../src/components/theme-toggle/theme-toggle.agent.ts","../../src/components/theme-toggle/theme-toggle.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — ThemeToggle. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { ThemeToggleHandle } from './theme-toggle';\n\nexport const themeToggleAgent: AgentAdapter<ThemeToggleHandle> = {\n id: 'theme-toggle',\n capabilities: ['set_value'],\n state: {\n currentTheme: {\n type: 'ThemePreference',\n descriptionKey: 'ui.agent.themeToggle.state.currentTheme',\n description: 'Active theme preference: light, dark, or system.',\n read: (handle) => handle.getCurrentTheme(),\n },\n currentAccessibility: {\n type: 'AccessibilityPreference',\n descriptionKey: 'ui.agent.themeToggle.state.currentAccessibility',\n description: 'Active accessibility preference: default or accessible.',\n read: (handle) => handle.getCurrentAccessibility(),\n },\n },\n actions: {\n set_theme: {\n safety: 'write',\n argsType: '{ theme: \"light\" | \"dark\" | \"system\" }',\n argsSchema: {\n type: 'object',\n properties: { theme: { enum: ['light', 'dark', 'system'] } },\n required: ['theme'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.themeToggle.actions.setTheme',\n description: 'Switch the theme preference.',\n invoke: (handle, args: { theme: 'light' | 'dark' | 'system' }) => {\n handle.setTheme(args.theme);\n },\n },\n set_accessibility: {\n safety: 'write',\n argsType: '{ accessibility: \"default\" | \"accessible\" }',\n argsSchema: {\n type: 'object',\n properties: { accessibility: { enum: ['default', 'accessible'] } },\n required: ['accessibility'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.themeToggle.actions.setAccessibility',\n description: 'Switch the accessibility preference.',\n invoke: (handle, args: { accessibility: 'default' | 'accessible' }) => {\n handle.setAccessibility(args.accessibility);\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'theme-toggle',\n description: 'Marks the ThemeToggle wrapper.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n type HTMLAttributes,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { Monitor, Moon, Sun } from 'lucide-react';\nimport { IconButton } from '../button/icon-button';\nimport { IconButtonGroup } from '../icon-button-group/icon-button-group';\nimport { Switch } from '../switch/switch';\nimport { DropdownMenu } from '../dropdown-menu/dropdown-menu';\nimport {\n useTheme,\n type AccessibilityPreference,\n type ThemePreference,\n type UseThemeReturn,\n} from '../../hooks';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { themeToggleAgent } from './theme-toggle.agent';\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst wrapperVariants = cva('ds:inline-flex ds:items-center', {\n variants: {\n variant: {\n menu: '',\n compact: '',\n split: 'ds:gap-[var(--spacing-md)]',\n },\n },\n defaultVariants: { variant: 'menu' },\n});\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport type ThemeToggleVariant = 'menu' | 'compact' | 'split';\n\ninterface ThemeToggleBaseProps\n extends\n Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>,\n VariantProps<typeof wrapperVariants> {\n /**\n * Visual form factor.\n * - `menu` (default) — single trigger that opens a dropdown with both\n * Appearance and Accessibility controls. Best for headers / nav rails.\n * - `compact` — segmented Appearance control only. Use when accessibility\n * lives on a separate settings surface.\n * - `split` — segmented Appearance control plus an inline Accessibility\n * switch. Best for full-width settings panels.\n */\n variant?: ThemeToggleVariant;\n /** Hide the accessibility control. Ignored on `compact`, which never renders it. */\n showAccessibility?: boolean;\n /**\n * Controlled escape hatch — when omitted the component reads/writes\n * `useTheme()` directly so it can drop into any header with no wiring.\n * Pass all four to opt into controlled mode.\n */\n theme?: ThemePreference;\n accessibility?: AccessibilityPreference;\n onThemeChange?: (next: ThemePreference) => void;\n onAccessibilityChange?: (next: AccessibilityPreference) => void;\n}\n\nexport type ThemeToggleProps = ThemeToggleBaseProps;\n\n/** Curated imperative handle for agent / external automation. */\nexport interface ThemeToggleHandle {\n getCurrentTheme: () => ThemePreference;\n getCurrentAccessibility: () => AccessibilityPreference;\n setTheme: (next: ThemePreference) => void;\n setAccessibility: (next: AccessibilityPreference) => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* Hook adapter */\n/* ------------------------------------------------------------------ */\n\n/**\n * Resolves controlled props against the store. When the consumer passes\n * `theme` / `onThemeChange` (etc.) we honour those; otherwise we fall\n * through to the singleton `useTheme()` hook so a bare `<ThemeToggle />`\n * works with zero wiring.\n */\nfunction useResolvedTheme(props: ThemeToggleBaseProps): UseThemeReturn {\n const {\n theme: themeProp,\n accessibility: accessibilityProp,\n onThemeChange,\n onAccessibilityChange,\n } = props;\n const store = useTheme();\n const theme = themeProp ?? store.theme;\n const accessibility = accessibilityProp ?? store.accessibility;\n\n const storeSetTheme = store.setTheme;\n const storeSetAccessibility = store.setAccessibility;\n\n const setTheme = useCallback(\n (next: ThemePreference) => {\n if (onThemeChange) {\n onThemeChange(next);\n return;\n }\n storeSetTheme(next);\n },\n [onThemeChange, storeSetTheme],\n );\n\n const setAccessibility = useCallback(\n (next: AccessibilityPreference) => {\n if (onAccessibilityChange) {\n onAccessibilityChange(next);\n return;\n }\n storeSetAccessibility(next);\n },\n [onAccessibilityChange, storeSetAccessibility],\n );\n\n return {\n theme,\n accessibility,\n resolvedTheme: store.resolvedTheme,\n setTheme,\n setAccessibility,\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* Sub-pieces */\n/* ------------------------------------------------------------------ */\n\ninterface AppearanceSegmentProps {\n value: ThemePreference;\n onValueChange: (next: ThemePreference) => void;\n ariaLabel: string;\n size?: 'sm' | 'md' | 'lg';\n}\n\nfunction AppearanceSegment({\n value,\n onValueChange,\n ariaLabel,\n size = 'md',\n}: AppearanceSegmentProps) {\n const { t } = useTranslation();\n return (\n <IconButtonGroup\n aria-label={ariaLabel}\n role=\"radiogroup\"\n mode=\"toggle-single\"\n size={size}\n value={value}\n onValueChange={(next) => onValueChange(next as ThemePreference)}\n >\n <IconButton\n icon={<Sun aria-hidden />}\n aria-label={t('navigation.themeToggle.appearance.light')}\n value=\"light\"\n />\n <IconButton\n icon={<Moon aria-hidden />}\n aria-label={t('navigation.themeToggle.appearance.dark')}\n value=\"dark\"\n />\n <IconButton\n icon={<Monitor aria-hidden />}\n aria-label={t('navigation.themeToggle.appearance.system')}\n value=\"system\"\n />\n </IconButtonGroup>\n );\n}\n\ninterface AccessibilitySwitchProps {\n value: AccessibilityPreference;\n onValueChange: (next: AccessibilityPreference) => void;\n size?: 'sm' | 'md' | 'lg';\n}\n\nfunction AccessibilitySwitch({\n value,\n onValueChange,\n size = 'md',\n}: AccessibilitySwitchProps) {\n const { t } = useTranslation();\n // 'system' is treated as \"off\" visually — the OS preference flows through\n // automatically. Flipping the switch on creates an explicit override.\n const checked = value === 'accessible';\n return (\n <Switch\n label={t('navigation.themeToggle.accessibility.label')}\n labelSide=\"start\"\n size={size}\n checked={checked}\n onCheckedChange={(next) => onValueChange(next ? 'accessible' : 'default')}\n />\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Variants */\n/* ------------------------------------------------------------------ */\n\ninterface VariantRenderProps {\n state: UseThemeReturn;\n className?: string;\n rest: HTMLAttributes<HTMLDivElement>;\n forwardedRef: React.Ref<HTMLDivElement>;\n showAccessibility: boolean;\n}\n\nfunction MenuVariant({\n state,\n className,\n rest,\n forwardedRef,\n showAccessibility,\n}: VariantRenderProps) {\n const { t } = useTranslation();\n const triggerIcon =\n state.resolvedTheme === 'dark' ||\n state.resolvedTheme === 'dark-accessible' ? (\n <Moon aria-hidden />\n ) : (\n <Sun aria-hidden />\n );\n\n const accessibleChecked = state.accessibility === 'accessible';\n\n return (\n <div\n ref={forwardedRef}\n data-component=\"theme-toggle\"\n data-component-id={rest.id}\n className={wrapperVariants({ variant: 'menu', className })}\n {...rest}\n >\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <IconButton\n icon={triggerIcon}\n aria-label={t('navigation.themeToggle.trigger')}\n />\n </DropdownMenu.Trigger>\n <DropdownMenu.Portal>\n <DropdownMenu.Content align=\"end\" sideOffset={8}>\n <DropdownMenu.Label>\n {t('navigation.themeToggle.appearance.label')}\n </DropdownMenu.Label>\n <DropdownMenu.RadioGroup\n value={state.theme}\n onValueChange={(next) => state.setTheme(next as ThemePreference)}\n >\n <DropdownMenu.RadioItem value=\"light\">\n <Sun aria-hidden className=\"ds:size-4\" />\n {t('navigation.themeToggle.appearance.light')}\n </DropdownMenu.RadioItem>\n <DropdownMenu.RadioItem value=\"dark\">\n <Moon aria-hidden className=\"ds:size-4\" />\n {t('navigation.themeToggle.appearance.dark')}\n </DropdownMenu.RadioItem>\n <DropdownMenu.RadioItem value=\"system\">\n <Monitor aria-hidden className=\"ds:size-4\" />\n {t('navigation.themeToggle.appearance.system')}\n </DropdownMenu.RadioItem>\n </DropdownMenu.RadioGroup>\n {showAccessibility ? (\n <>\n <DropdownMenu.Separator />\n {/* CheckboxItem keeps the accessibility toggle inside the\n Radix menu collection so ArrowDown reaches it and Space\n activates it; `onSelect={preventDefault}` prevents the\n menu from closing on toggle. */}\n <DropdownMenu.CheckboxItem\n checked={accessibleChecked}\n onCheckedChange={(next) =>\n state.setAccessibility(next ? 'accessible' : 'default')\n }\n onSelect={(event) => event.preventDefault()}\n >\n {t('navigation.themeToggle.accessibility.label')}\n </DropdownMenu.CheckboxItem>\n </>\n ) : null}\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n </DropdownMenu.Root>\n </div>\n );\n}\n\nfunction CompactVariant({\n state,\n className,\n rest,\n forwardedRef,\n}: VariantRenderProps) {\n const { t } = useTranslation();\n return (\n <div\n ref={forwardedRef}\n data-component=\"theme-toggle\"\n data-component-id={rest.id}\n className={wrapperVariants({ variant: 'compact', className })}\n {...rest}\n >\n <AppearanceSegment\n value={state.theme}\n onValueChange={state.setTheme}\n ariaLabel={t('navigation.themeToggle.appearance.label')}\n />\n </div>\n );\n}\n\nfunction SplitVariant({\n state,\n className,\n rest,\n forwardedRef,\n showAccessibility,\n}: VariantRenderProps) {\n const { t } = useTranslation();\n return (\n <div\n ref={forwardedRef}\n data-component=\"theme-toggle\"\n data-component-id={rest.id}\n className={wrapperVariants({ variant: 'split', className })}\n {...rest}\n >\n <AppearanceSegment\n value={state.theme}\n onValueChange={state.setTheme}\n ariaLabel={t('navigation.themeToggle.appearance.label')}\n />\n {showAccessibility ? (\n <AccessibilitySwitch\n value={state.accessibility}\n onValueChange={state.setAccessibility}\n />\n ) : null}\n </div>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* ThemeToggle */\n/* ------------------------------------------------------------------ */\n\nexport const ThemeToggle = forwardRef<HTMLDivElement, ThemeToggleProps>(\n (props, ref) => {\n const {\n variant = 'menu',\n showAccessibility = true,\n className,\n id,\n // Strip controlled props from the spread — they are read by the\n // adapter, not by the DOM element.\n theme: _theme,\n accessibility: _accessibility,\n onThemeChange: _onThemeChange,\n onAccessibilityChange: _onAccessibilityChange,\n ...rest\n } = props as ThemeToggleProps & { id?: string };\n\n const state = useResolvedTheme(props);\n const stateRef = useRef(state);\n stateRef.current = state;\n\n // Internal variant wrappers attach refs to <div> elements; we forward that\n // DOM node as the public ref (Pattern B). The agent handle is registered\n // separately via useAgentRegistration.\n const forwardedRef = useRef<HTMLDivElement | null>(null);\n useImperativeHandle(ref, () => forwardedRef.current as HTMLDivElement, []);\n\n const agentHandle = useMemo<ThemeToggleHandle>(\n () => ({\n getCurrentTheme: () => stateRef.current.theme,\n getCurrentAccessibility: () => stateRef.current.accessibility,\n setTheme: (next) => stateRef.current.setTheme(next),\n setAccessibility: (next) => stateRef.current.setAccessibility(next),\n }),\n [],\n );\n useAgentRegistration(themeToggleAgent, agentHandle, id);\n\n if (variant === 'compact') {\n return (\n <CompactVariant\n state={state}\n className={className}\n rest={rest}\n forwardedRef={forwardedRef}\n showAccessibility={showAccessibility}\n />\n );\n }\n if (variant === 'split') {\n return (\n <SplitVariant\n state={state}\n className={className}\n rest={rest}\n forwardedRef={forwardedRef}\n showAccessibility={showAccessibility}\n />\n );\n }\n return (\n <MenuVariant\n state={state}\n className={className}\n rest={rest}\n forwardedRef={forwardedRef}\n showAccessibility={showAccessibility}\n />\n );\n },\n);\n\nThemeToggle.displayName = 'ThemeToggle';\n"],"names":["themeToggleAgent","handle","args","wrapperVariants","cva","useResolvedTheme","props","themeProp","accessibilityProp","onThemeChange","onAccessibilityChange","store","useTheme","theme","accessibility","storeSetTheme","storeSetAccessibility","setTheme","useCallback","next","setAccessibility","AppearanceSegment","value","onValueChange","ariaLabel","size","t","useTranslation","jsxs","IconButtonGroup","jsx","IconButton","Sun","Moon","Monitor","AccessibilitySwitch","checked","Switch","MenuVariant","state","className","rest","forwardedRef","showAccessibility","triggerIcon","accessibleChecked","DropdownMenu","Fragment","event","CompactVariant","SplitVariant","ThemeToggle","forwardRef","ref","variant","id","_theme","_accessibility","_onThemeChange","_onAccessibilityChange","stateRef","useRef","useImperativeHandle","agentHandle","useMemo","useAgentRegistration"],"mappings":";;;;;;;;;;;;AAOO,MAAMA,IAAoD;AAAA,EAC/D,IAAI;AAAA,EACJ,cAAc,CAAC,WAAW;AAAA,EAC1B,OAAO;AAAA,IACL,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACC,MAAWA,EAAO,gBAAA;AAAA,IAAgB;AAAA,IAE3C,sBAAsB;AAAA,MACpB,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACA,MAAWA,EAAO,wBAAA;AAAA,IAAwB;AAAA,EACnD;AAAA,EAEF,SAAS;AAAA,IACP,WAAW;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,QAAQ,QAAQ,IAAE;AAAA,QACzD,UAAU,CAAC,OAAO;AAAA,MAAA;AAAA,MAEpB,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,QAAQ,CAACA,GAAQC,MAAiD;AAChE,QAAAD,EAAO,SAASC,EAAK,KAAK;AAAA,MAC5B;AAAA,IAAA;AAAA,IAEF,mBAAmB;AAAA,MACjB,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC,WAAW,YAAY,IAAE;AAAA,QAC/D,UAAU,CAAC,eAAe;AAAA,MAAA;AAAA,MAE5B,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,aAA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ent.ts","../../src/components/theme-toggle/theme-toggle.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — ThemeToggle. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { ThemeToggleHandle } from './theme-toggle';\n\nexport const themeToggleAgent: AgentAdapter<ThemeToggleHandle> = {\n id: 'theme-toggle',\n capabilities: ['set_value'],\n state: {\n currentTheme: {\n type: 'ThemePreference',\n descriptionKey: 'ui.agent.themeToggle.state.currentTheme',\n description: 'Active theme preference: light, dark, or system.',\n read: (handle) => handle.getCurrentTheme(),\n },\n currentAccessibility: {\n type: 'AccessibilityPreference',\n descriptionKey: 'ui.agent.themeToggle.state.currentAccessibility',\n description: 'Active accessibility preference: default or accessible.',\n read: (handle) => handle.getCurrentAccessibility(),\n },\n },\n actions: {\n set_theme: {\n safety: 'write',\n argsType: '{ theme: \"light\" | \"dark\" | \"system\" }',\n argsSchema: {\n type: 'object',\n properties: { theme: { enum: ['light', 'dark', 'system'] } },\n required: ['theme'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.themeToggle.actions.setTheme',\n description: 'Switch the theme preference.',\n invoke: (handle, args: { theme: 'light' | 'dark' | 'system' }) => {\n handle.setTheme(args.theme);\n },\n },\n set_accessibility: {\n safety: 'write',\n argsType: '{ accessibility: \"default\" | \"accessible\" }',\n argsSchema: {\n type: 'object',\n properties: { accessibility: { enum: ['default', 'accessible'] } },\n required: ['accessibility'],\n },\n idempotent: true,\n descriptionKey: 'ui.agent.themeToggle.actions.setAccessibility',\n description: 'Switch the accessibility preference.',\n invoke: (handle, args: { accessibility: 'default' | 'accessible' }) => {\n handle.setAccessibility(args.accessibility);\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'theme-toggle',\n description: 'Marks the ThemeToggle wrapper.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","import {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n type HTMLAttributes,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { Monitor, Moon, Sun } from 'lucide-react';\nimport { IconButton } from '../button/icon-button';\nimport { IconButtonGroup } from '../icon-button-group/icon-button-group';\nimport { Switch } from '../switch/switch';\nimport { DropdownMenu } from '../dropdown-menu/dropdown-menu';\nimport {\n useTheme,\n type AccessibilityPreference,\n type ThemePreference,\n type UseThemeReturn,\n} from '../../hooks';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { themeToggleAgent } from './theme-toggle.agent';\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst wrapperVariants = cva('ds:inline-flex ds:items-center', {\n variants: {\n variant: {\n menu: '',\n compact: '',\n split: 'ds:gap-[var(--spacing-md)]',\n },\n },\n defaultVariants: { variant: 'menu' },\n});\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport type ThemeToggleVariant = 'menu' | 'compact' | 'split';\n\ninterface ThemeToggleBaseProps\n extends\n Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>,\n VariantProps<typeof wrapperVariants> {\n /**\n * Visual form factor.\n * - `menu` (default) — single trigger that opens a dropdown with both\n * Appearance and Accessibility controls. Best for headers / nav rails.\n * - `compact` — segmented Appearance control only. Use when accessibility\n * lives on a separate settings surface.\n * - `split` — segmented Appearance control plus an inline Accessibility\n * switch. Best for full-width settings panels.\n */\n variant?: ThemeToggleVariant;\n /** Hide the accessibility control. Ignored on `compact`, which never renders it. */\n showAccessibility?: boolean;\n /**\n * Controlled escape hatch — when omitted the component reads/writes\n * `useTheme()` directly so it can drop into any header with no wiring.\n * Pass all four to opt into controlled mode.\n */\n theme?: ThemePreference;\n accessibility?: AccessibilityPreference;\n onThemeChange?: (next: ThemePreference) => void;\n onAccessibilityChange?: (next: AccessibilityPreference) => void;\n}\n\nexport type ThemeToggleProps = ThemeToggleBaseProps;\n\n/** Curated imperative handle for agent / external automation. */\nexport interface ThemeToggleHandle {\n getCurrentTheme: () => ThemePreference;\n getCurrentAccessibility: () => AccessibilityPreference;\n setTheme: (next: ThemePreference) => void;\n setAccessibility: (next: AccessibilityPreference) => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* Hook adapter */\n/* ------------------------------------------------------------------ */\n\n/**\n * Resolves controlled props against the store. When the consumer passes\n * `theme` / `onThemeChange` (etc.) we honour those; otherwise we fall\n * through to the singleton `useTheme()` hook so a bare `<ThemeToggle />`\n * works with zero wiring.\n */\nfunction useResolvedTheme(props: ThemeToggleBaseProps): UseThemeReturn {\n const {\n theme: themeProp,\n accessibility: accessibilityProp,\n onThemeChange,\n onAccessibilityChange,\n } = props;\n const store = useTheme();\n const theme = themeProp ?? store.theme;\n const accessibility = accessibilityProp ?? store.accessibility;\n\n const storeSetTheme = store.setTheme;\n const storeSetAccessibility = store.setAccessibility;\n\n const setTheme = useCallback(\n (next: ThemePreference) => {\n if (onThemeChange) {\n onThemeChange(next);\n return;\n }\n storeSetTheme(next);\n },\n [onThemeChange, storeSetTheme],\n );\n\n const setAccessibility = useCallback(\n (next: AccessibilityPreference) => {\n if (onAccessibilityChange) {\n onAccessibilityChange(next);\n return;\n }\n storeSetAccessibility(next);\n },\n [onAccessibilityChange, storeSetAccessibility],\n );\n\n return {\n theme,\n accessibility,\n resolvedTheme: store.resolvedTheme,\n setTheme,\n setAccessibility,\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* Sub-pieces */\n/* ------------------------------------------------------------------ */\n\ninterface AppearanceSegmentProps {\n value: ThemePreference;\n onValueChange: (next: ThemePreference) => void;\n ariaLabel: string;\n size?: 'sm' | 'md' | 'lg';\n}\n\nfunction AppearanceSegment({\n value,\n onValueChange,\n ariaLabel,\n size = 'md',\n}: AppearanceSegmentProps) {\n const { t } = useTranslation();\n return (\n <IconButtonGroup\n aria-label={ariaLabel}\n role=\"radiogroup\"\n mode=\"toggle-single\"\n size={size}\n value={value}\n onValueChange={(next) => onValueChange(next as ThemePreference)}\n >\n <IconButton\n icon={<Sun aria-hidden />}\n aria-label={t('navigation.themeToggle.appearance.light')}\n value=\"light\"\n />\n <IconButton\n icon={<Moon aria-hidden />}\n aria-label={t('navigation.themeToggle.appearance.dark')}\n value=\"dark\"\n />\n <IconButton\n icon={<Monitor aria-hidden />}\n aria-label={t('navigation.themeToggle.appearance.system')}\n value=\"system\"\n />\n </IconButtonGroup>\n );\n}\n\ninterface AccessibilitySwitchProps {\n value: AccessibilityPreference;\n onValueChange: (next: AccessibilityPreference) => void;\n size?: 'sm' | 'md' | 'lg';\n}\n\nfunction AccessibilitySwitch({\n value,\n onValueChange,\n size = 'md',\n}: AccessibilitySwitchProps) {\n const { t } = useTranslation();\n // 'system' is treated as \"off\" visually — the OS preference flows through\n // automatically. Flipping the switch on creates an explicit override.\n const checked = value === 'accessible';\n return (\n <Switch\n label={t('navigation.themeToggle.accessibility.label')}\n labelSide=\"start\"\n size={size}\n checked={checked}\n onCheckedChange={(next) => onValueChange(next ? 'accessible' : 'default')}\n />\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Variants */\n/* ------------------------------------------------------------------ */\n\ninterface VariantRenderProps {\n state: UseThemeReturn;\n className?: string;\n rest: HTMLAttributes<HTMLDivElement>;\n forwardedRef: React.Ref<HTMLDivElement>;\n showAccessibility: boolean;\n}\n\nfunction MenuVariant({\n state,\n className,\n rest,\n forwardedRef,\n showAccessibility,\n}: VariantRenderProps) {\n const { t } = useTranslation();\n const triggerIcon =\n state.resolvedTheme === 'dark' ||\n state.resolvedTheme === 'dark-accessible' ? (\n <Moon aria-hidden />\n ) : (\n <Sun aria-hidden />\n );\n\n const accessibleChecked = state.accessibility === 'accessible';\n\n return (\n <div\n ref={forwardedRef}\n data-component=\"theme-toggle\"\n data-component-id={rest.id}\n className={wrapperVariants({ variant: 'menu', className })}\n {...rest}\n >\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <IconButton\n icon={triggerIcon}\n aria-label={t('navigation.themeToggle.trigger')}\n />\n </DropdownMenu.Trigger>\n <DropdownMenu.Portal>\n <DropdownMenu.Content align=\"end\" sideOffset={8}>\n <DropdownMenu.Label>\n {t('navigation.themeToggle.appearance.label')}\n </DropdownMenu.Label>\n <DropdownMenu.RadioGroup\n value={state.theme}\n onValueChange={(next) => state.setTheme(next as ThemePreference)}\n >\n <DropdownMenu.RadioItem value=\"light\">\n <Sun aria-hidden className=\"ds:size-4\" />\n {t('navigation.themeToggle.appearance.light')}\n </DropdownMenu.RadioItem>\n <DropdownMenu.RadioItem value=\"dark\">\n <Moon aria-hidden className=\"ds:size-4\" />\n {t('navigation.themeToggle.appearance.dark')}\n </DropdownMenu.RadioItem>\n <DropdownMenu.RadioItem value=\"system\">\n <Monitor aria-hidden className=\"ds:size-4\" />\n {t('navigation.themeToggle.appearance.system')}\n </DropdownMenu.RadioItem>\n </DropdownMenu.RadioGroup>\n {showAccessibility ? (\n <>\n <DropdownMenu.Separator />\n {/* CheckboxItem keeps the accessibility toggle inside the\n Radix menu collection so ArrowDown reaches it and Space\n activates it; `onSelect={preventDefault}` prevents the\n menu from closing on toggle. */}\n <DropdownMenu.CheckboxItem\n checked={accessibleChecked}\n onCheckedChange={(next) =>\n state.setAccessibility(next ? 'accessible' : 'default')\n }\n onSelect={(event) => event.preventDefault()}\n >\n {t('navigation.themeToggle.accessibility.label')}\n </DropdownMenu.CheckboxItem>\n </>\n ) : null}\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n </DropdownMenu.Root>\n </div>\n );\n}\n\nfunction CompactVariant({\n state,\n className,\n rest,\n forwardedRef,\n}: VariantRenderProps) {\n const { t } = useTranslation();\n return (\n <div\n ref={forwardedRef}\n data-component=\"theme-toggle\"\n data-component-id={rest.id}\n className={wrapperVariants({ variant: 'compact', className })}\n {...rest}\n >\n <AppearanceSegment\n value={state.theme}\n onValueChange={state.setTheme}\n ariaLabel={t('navigation.themeToggle.appearance.label')}\n />\n </div>\n );\n}\n\nfunction SplitVariant({\n state,\n className,\n rest,\n forwardedRef,\n showAccessibility,\n}: VariantRenderProps) {\n const { t } = useTranslation();\n return (\n <div\n ref={forwardedRef}\n data-component=\"theme-toggle\"\n data-component-id={rest.id}\n className={wrapperVariants({ variant: 'split', className })}\n {...rest}\n >\n <AppearanceSegment\n value={state.theme}\n onValueChange={state.setTheme}\n ariaLabel={t('navigation.themeToggle.appearance.label')}\n />\n {showAccessibility ? (\n <AccessibilitySwitch\n value={state.accessibility}\n onValueChange={state.setAccessibility}\n />\n ) : null}\n </div>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* ThemeToggle */\n/* ------------------------------------------------------------------ */\n\nexport const ThemeToggle = forwardRef<HTMLDivElement, ThemeToggleProps>(\n (props, ref) => {\n const {\n variant = 'menu',\n showAccessibility = true,\n className,\n id,\n // Strip controlled props from the spread — they are read by the\n // adapter, not by the DOM element.\n theme: _theme,\n accessibility: _accessibility,\n onThemeChange: _onThemeChange,\n onAccessibilityChange: _onAccessibilityChange,\n ...rest\n } = props as ThemeToggleProps & { id?: string };\n\n const state = useResolvedTheme(props);\n const stateRef = useRef(state);\n stateRef.current = state;\n\n // Internal variant wrappers attach refs to <div> elements; we forward that\n // DOM node as the public ref (Pattern B). The agent handle is registered\n // separately via useAgentRegistration.\n const forwardedRef = useRef<HTMLDivElement | null>(null);\n useImperativeHandle(ref, () => forwardedRef.current as HTMLDivElement, []);\n\n const agentHandle = useMemo<ThemeToggleHandle>(\n () => ({\n getCurrentTheme: () => stateRef.current.theme,\n getCurrentAccessibility: () => stateRef.current.accessibility,\n setTheme: (next) => stateRef.current.setTheme(next),\n setAccessibility: (next) => stateRef.current.setAccessibility(next),\n }),\n [],\n );\n useAgentRegistration(themeToggleAgent, agentHandle, id);\n\n if (variant === 'compact') {\n return (\n <CompactVariant\n state={state}\n className={className}\n rest={rest}\n forwardedRef={forwardedRef}\n showAccessibility={showAccessibility}\n />\n );\n }\n if (variant === 'split') {\n return (\n <SplitVariant\n state={state}\n className={className}\n rest={rest}\n forwardedRef={forwardedRef}\n showAccessibility={showAccessibility}\n />\n );\n }\n return (\n <MenuVariant\n state={state}\n className={className}\n rest={rest}\n forwardedRef={forwardedRef}\n showAccessibility={showAccessibility}\n />\n );\n },\n);\n\nThemeToggle.displayName = 'ThemeToggle';\n"],"names":["themeToggleAgent","handle","args","wrapperVariants","cva","useResolvedTheme","props","themeProp","accessibilityProp","onThemeChange","onAccessibilityChange","store","useTheme","theme","accessibility","storeSetTheme","storeSetAccessibility","setTheme","useCallback","next","setAccessibility","AppearanceSegment","value","onValueChange","ariaLabel","size","t","useTranslation","jsxs","IconButtonGroup","jsx","IconButton","Sun","Moon","Monitor","AccessibilitySwitch","checked","Switch","MenuVariant","state","className","rest","forwardedRef","showAccessibility","triggerIcon","accessibleChecked","DropdownMenu","Fragment","event","CompactVariant","SplitVariant","ThemeToggle","forwardRef","ref","variant","id","_theme","_accessibility","_onThemeChange","_onAccessibilityChange","stateRef","useRef","useImperativeHandle","agentHandle","useMemo","useAgentRegistration"],"mappings":";;;;;;;;;;;;AAOO,MAAMA,IAAoD;AAAA,EAC/D,IAAI;AAAA,EACJ,cAAc,CAAC,WAAW;AAAA,EAC1B,OAAO;AAAA,IACL,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACC,MAAWA,EAAO,gBAAA;AAAA,IAAgB;AAAA,IAE3C,sBAAsB;AAAA,MACpB,MAAM;AAAA,MACN,gBAAgB;AAAA,MAChB,aAAa;AAAA,MACb,MAAM,CAACA,MAAWA,EAAO,wBAAA;AAAA,IAAwB;AAAA,EACnD;AAAA,EAEF,SAAS;AAAA,IACP,WAAW;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,QAAQ,QAAQ,IAAE;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AAA,IAAA,IAIFW,MAAY,UAEZ,gBAAAxB;AAAA,MAACoB;AAAA,MAAA;AAAA,QACC,OAAAX;AAAA,QACA,WAAAC;AAAA,QACA,MAAAC;AAAA,QACA,cAAAC;AAAA,QACA,mBAAAC;AAAA,MAAA;AAAA,IAAA,IAKJ,gBAAAb;AAAA,MAACQ;AAAA,MAAA;AAAA,QACC,OAAAC;AAAA,QACA,WAAAC;AAAA,QACA,MAAAC;AAAA,QACA,cAAAC;AAAA,QACA,mBAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEAQ,EAAY,cAAc;"}
|
|
@@ -81,7 +81,7 @@ const Le = {
|
|
|
81
81
|
description: "Stable tool id emitted on each strip IconButton. The active icon also carries data-active set to its id."
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
}, Ke = "ds:[inline-size:3rem]", je = "ds:[inline-size:var(--tool-rail-panel-inline-size,var(--ai-tools-rail-panel-inline-size,22rem))]", ae = "--tool-rail-panel-inline-size", Pe = 288, Me =
|
|
84
|
+
}, Ke = "ds:[inline-size:3rem]", je = "ds:[inline-size:var(--tool-rail-panel-inline-size,var(--ai-tools-rail-panel-inline-size,22rem))]", ae = "--tool-rail-panel-inline-size", Pe = 288, Me = 880, qe = 352, Be = w(
|
|
85
85
|
["ds:flex ds:shrink-0 ds:h-full", "ds:bg-[var(--background)]"].join(" "),
|
|
86
86
|
{
|
|
87
87
|
variants: {
|
|
@@ -521,4 +521,4 @@ export {
|
|
|
521
521
|
Ze as T,
|
|
522
522
|
Le as t
|
|
523
523
|
};
|
|
524
|
-
//# sourceMappingURL=tool-rail-
|
|
524
|
+
//# sourceMappingURL=tool-rail-8Scslq3X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-rail-8Scslq3X.js","sources":["../../src/components/tool-rail/tool-rail.agent.ts","../../src/components/tool-rail/tool-rail.tsx"],"sourcesContent":["/* -------------------------------------------------------------------- */\n/* Agent adapter — ToolRail. */\n/* */\n/* Rail-level surface: open / close a tool's panel and read which tool */\n/* is active. State is strictly the active tool id — never any tool's */\n/* panel CONTENT (which may carry PHI). Tool ids + badge counts are */\n/* supplied by the host via props, not derived from panel bodies. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { ToolRailHandle } from './tool-rail';\n\nexport const toolRailAgent: AgentAdapter<ToolRailHandle> = {\n id: 'tool-rail',\n capabilities: ['open', 'close', 'select_single'],\n state: {\n activeToolId: {\n type: 'string | null',\n descriptionKey: 'ui.toolRail.agent.state.activeToolId',\n description:\n 'Id of the tool whose panel is currently open, or null when the rail is collapsed to its strip. No panel content is ever exposed.',\n read: (handle) => handle.getActiveToolId(),\n },\n },\n actions: {\n open: {\n // Pure ephemeral panel state (open) — no data loss, no external effect.\n safety: 'read',\n argsType: '{ id: string }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: 'string' } },\n required: ['id'],\n },\n idempotent: true,\n // descriptionKey shape is intentionally pre-existing — already resolves to\n // real multi-locale translations; do not canonicalise.\n descriptionKey: 'ui.toolRail.agent.actions.open',\n description: \"Open the given tool's panel.\",\n examples: [{ args: { id: 'inbox' }, note: 'Open the inbox tool panel.' }],\n invoke: (handle, args: { id: string }) => {\n handle.open(args.id);\n },\n },\n close: {\n safety: 'read',\n idempotent: true,\n descriptionKey: 'ui.toolRail.agent.actions.close',\n description: 'Collapse the rail to its strip (no active tool).',\n invoke: (handle) => {\n handle.close();\n },\n },\n select_tool: {\n safety: 'read',\n argsType: '{ id: string | null }',\n argsSchema: {\n type: 'object',\n properties: { id: { type: ['string', 'null'] } },\n required: ['id'],\n },\n idempotent: true,\n descriptionKey: 'ui.toolRail.agent.actions.selectTool',\n description:\n 'Set the active tool by id (opens its panel), or pass null to collapse.',\n invoke: (handle, args: { id: string | null }) => {\n handle.setActiveTool(args.id);\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'tool-rail',\n description: 'Marks the ToolRail wrapper.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description:\n 'Sourced from the id prop. Required to address a specific rail from the agent.',\n },\n item: {\n attr: 'data-tool-id',\n description:\n 'Stable tool id emitted on each strip IconButton. The active icon also carries data-active set to its id.',\n },\n },\n};\n","import {\n forwardRef,\n Fragment,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type KeyboardEvent as ReactKeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { IconButton } from '../button/icon-button';\nimport { ScrollArea } from '../scroll-area/scroll-area';\nimport { TooltipProvider } from '../tooltip/tooltip';\nimport { useControllableState } from '../../hooks/use-controllable-state';\nimport { useEdgeResize } from '../../hooks/use-edge-resize';\nimport { useIsomorphicLayoutEffect } from '../../hooks/use-isomorphic-layout-effect';\nimport { useAgentRegistration } from '../../agent/registry';\nimport type { AgentAdapter } from '../../agent/types';\nimport { toolRailAgent } from './tool-rail.agent';\n\n/* ------------------------------------------------------------------ */\n/* Tokenised widths */\n/* */\n/* Fixed + tokenised so the rail stays constraint-compliant — no */\n/* prop-driven inline styles. Bare `[inline-size:…]` is NOT a */\n/* recognised utility under the `ds:` prefix; it must carry the */\n/* prefix or Tailwind emits no rule. Consumers needing a different */\n/* size wrap the rail and override via CSS. */\n/* ------------------------------------------------------------------ */\nconst RAIL_WIDTH = 'ds:[inline-size:3rem]';\n// Panel width rides a consumer-overridable custom property (set\n// `--tool-rail-panel-inline-size` on the rail or a wrapper) so\n// content-heavy tools (e.g. an inbox feed) can widen their panel\n// without inline styles. Defaults to the 22rem tray-family width.\n// `--ai-tools-rail-panel-inline-size` is the deprecated alias var read\n// here as a fallback so external consumers that set the pre-rename name\n// keep working for one release; the resize hook only ever writes the new\n// `--tool-rail-panel-inline-size`.\nconst PANEL_WIDTH =\n 'ds:[inline-size:var(--tool-rail-panel-inline-size,var(--ai-tools-rail-panel-inline-size,22rem))]';\n// The custom property PANEL_WIDTH reads. The resize hook writes the\n// committed px width here (on the panel element, so it beats consumer\n// class overrides on the root) and removes it on reset.\nconst PANEL_SIZE_PROPERTY = '--tool-rail-panel-inline-size';\n// Resize clamp + nominal default, px (352px = the 22rem token default).\n// The ceiling is 880 so a form panel can reach a three-column layout:\n// pairing fields is the only way to shorten a long form without\n// shrinking a 44px target, and that needs real inline size.\nconst PANEL_MIN_SIZE = 288;\nconst PANEL_MAX_SIZE = 880;\nconst PANEL_DEFAULT_SIZE = 352;\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport interface ToolRailTool {\n /** Stable tool id — used in `data-active`, the imperative handle, and\n * to label the open panel region. */\n id: string;\n /** Accessible name for the strip icon + tooltip, and the open panel's\n * region label. Never rendered as visible body text. */\n label: string;\n /** lucide-react glyph (rendered `aria-hidden` inside the IconButton). */\n icon: ReactNode;\n /** Panel body for this tool. Rendered inline-start of the strip when\n * `side='end'` (mirrored for `'start'`). The consumer composes it. */\n panel: ReactNode;\n /**\n * Optional non-scrolling header for this tool's panel. Rendered pinned at\n * the top of the open panel — above the scroll region — so a tool's title /\n * filters stay visible as the body scrolls. This is the rail-level home for\n * a sticky tool header; every tool gets it for free.\n */\n header?: ReactNode;\n /**\n * When true the panel body is NOT wrapped in the rail's `ScrollArea` — the\n * tool fills the (height-bounded) panel and owns its own scroll/layout.\n * Use for self-scrolling tools (e.g. `AppointmentTimeline`, whose infinite\n * scroll + today-anchoring + edge fades require it to be the scroll\n * container). Default `false` (the rail scrolls the body).\n */\n fill?: boolean;\n /** Optional unseen / notification count shown on the strip icon. */\n badgeCount?: number;\n /** When true the icon is non-interactive and skipped by roving focus. */\n disabled?: boolean;\n /**\n * Scope tier (drives the two-group divider). The two scope values render in\n * array order with a divider at the boundary between them — order the array\n * so the groups stay contiguous. A divider only appears when BOTH groups are\n * present; omit `scope` on every tool for an ungrouped strip (legacy). The\n * rail attaches no meaning beyond grouping — the host decides which value\n * leads (e.g. the Control Room pins favourites first).\n */\n scope?: 'global' | 'contextual';\n /**\n * When true this icon joins the drag-and-drop / `Alt`+Arrow reorder run.\n * The host supplies `onReorder` and owns the resulting order. Moves are\n * confined to the contiguous run of `reorderable` tools — so if EVERY tool\n * is `reorderable` the run is the whole strip and a tool can be dragged\n * across the scope divider; the host's `onReorder` decides what crossing it\n * means (e.g. the Control Room reads it as pin / unpin). Reordering never\n * changes focus roving — focus follows the moved tool to its new slot.\n */\n reorderable?: boolean;\n}\n\n/**\n * Curated imperative handle for ToolRail. Exposed as the forwardRef\n * target so a future agent / MCP UI bridge can drive the rail without\n * touching the DOM. See `tool-rail.agent.ts`.\n *\n * State surfaced here is strictly identifiers + counts — never any\n * tool's panel content (which may carry PHI).\n */\nexport interface ToolRailHandle {\n /** Currently-active tool id, or null when collapsed to strip-only. */\n getActiveToolId: () => string | null;\n /** Activate a tool by id (opens its panel), or null to collapse. */\n setActiveTool: (id: string | null) => void;\n /** Activate a tool by id (opens its panel). */\n open: (id: string) => void;\n /** Collapse to strip-only (no active tool). */\n close: () => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* CVA — `side` drives the dock edge + which shadow faces main content */\n/* ------------------------------------------------------------------ */\n\nconst railVariants = cva(\n ['ds:flex ds:shrink-0 ds:h-full', 'ds:bg-[var(--background)]'].join(' '),\n {\n variants: {\n side: {\n // Strip docks inline-end; the panel mounts inline-start of it\n // (flex-row, panel rendered first). Shadow faces the main area —\n // no border against main (the rail stays line-free; the only seam\n // is the strip↔panel divider on the open panel, see render).\n // Accessible (AAA) theme swaps the soft chrome shadow for a solid 1px\n // border on the content-facing edge (border-s for end-docked).\n end: 'ds:flex-row ds:shadow-[var(--shadow-chrome-start)] ds:[.theme-accessible_&]:border-s ds:[.theme-accessible_&]:border-[var(--border)] ds:[.theme-accessible_&]:shadow-none',\n // Strip docks inline-start; the panel mounts inline-end of it.\n start:\n 'ds:flex-row-reverse ds:shadow-[var(--shadow-chrome-end)] ds:[.theme-accessible_&]:border-e ds:[.theme-accessible_&]:border-[var(--border)] ds:[.theme-accessible_&]:shadow-none',\n },\n },\n defaultVariants: { side: 'end' },\n },\n);\n\nconst stripVariants = cva(\n [\n 'ds:flex ds:shrink-0 ds:flex-col ds:items-center',\n 'ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]',\n 'ds:gap-[var(--spacing-xs)]',\n RAIL_WIDTH,\n ].join(' '),\n);\n\nconst panelVariants = cva(\n [\n 'ds:relative ds:flex ds:min-h-0 ds:flex-col ds:h-full',\n 'ds:bg-[var(--background)]',\n PANEL_WIDTH,\n // Defensive: the panel doesn't animate its width today, but if a\n // consumer adds a transition on the var, suppress it mid-drag.\n 'ds:data-[resizing]:transition-none',\n ].join(' '),\n);\n\n// Resize handle on the panel's inner edge — mirrors Resizable's Handle\n// (::before hit area to --min-target-size, hover/focus/drag accent, token\n// focus ring) but absolutely positioned over the panel edge. Like the\n// Sidebar's handle it stays TRANSPARENT at rest: the rail root's\n// `shadow-chrome-*` (which faces the main content) carries the resting seam,\n// exactly as the start-docked Sidebar leans on its own shadow — so the rail\n// never shows the constant coloured bar it used to. The strip only tints\n// accent on hover / focus / drag.\nconst panelResizeHandleVariants = cva(\n [\n 'ds:absolute ds:[inset-block:0] ds:z-[1] ds:select-none ds:touch-none',\n 'ds:[inline-size:var(--resizable-handle-size)] ds:cursor-col-resize',\n 'ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n 'ds:hover:bg-[var(--accent)] ds:focus-visible:bg-[var(--accent)] ds:data-[resizing]:bg-[var(--accent)]',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n \"ds:before:absolute ds:before:content-['']\",\n 'ds:before:[block-size:100%]',\n 'ds:before:[inline-size:var(--min-target-size)]',\n 'ds:before:[inset-block:0]',\n 'ds:before:[inset-inline:calc(0px_-_(var(--min-target-size)_-_var(--resizable-handle-size))_/_2)]',\n ],\n {\n variants: {\n edge: {\n 'inline-start': 'ds:start-0',\n 'inline-end': 'ds:end-0',\n },\n },\n defaultVariants: { edge: 'inline-start' },\n },\n);\n\n// Hand-rolled overlay count chip — mirrors the AliaSidebar / MessageTray\n// badge markup. A <Badge> would re-introduce its own landmark/role; the\n// strip icon already carries the count in its accessible name, so this\n// span is purely decorative (`aria-hidden`).\nconst badgeVariants = cva(\n [\n 'ds:absolute ds:-top-[var(--spacing-xs)] ds:-end-[var(--spacing-xs)]',\n 'ds:inline-flex ds:items-center ds:justify-center',\n 'ds:min-w-[calc(var(--spacing-md)+var(--spacing-xs))]',\n 'ds:h-[calc(var(--spacing-md)+var(--spacing-xs))]',\n 'ds:ps-[calc(var(--spacing-xs)/1.5)] ds:pe-[calc(var(--spacing-xs)/1.5)]',\n 'ds:rounded-[var(--radius-full)]',\n 'ds:bg-[color:var(--destructive)] ds:text-[color:var(--destructive-foreground)]',\n 'ds:text-[length:var(--font-size-xs)] ds:font-semibold ds:leading-none',\n 'ds:pointer-events-none ds:select-none',\n 'ds:forced-colors:outline ds:forced-colors:outline-1 ds:forced-colors:outline-[CanvasText]',\n ].join(' '),\n);\n\n// Per-icon slot — the positioned box that hosts the IconButton, its badge and\n// the optional affordance overlay. CVA carries the drag states: the dragged\n// icon dims; a hovered drop target shows a dashed accent ring (logical offset),\n// mirroring the Sidebar's favourite-row affordance.\nconst toolSlotVariants = cva(\n // `group/rail-tool` lets an affordance overlay (e.g. a pin star) reveal on\n // hover / focus-within of the whole slot.\n ['ds:group/rail-tool ds:relative', 'ds:rounded-[var(--radius-sm)]'],\n {\n variants: {\n dragging: { true: 'ds:opacity-60', false: '' },\n dropTarget: {\n true: 'ds:outline-[length:var(--focus-ring-width)] ds:outline-dashed ds:outline-[var(--accent)] ds:outline-offset-[length:var(--focus-ring-offset)]',\n false: '',\n },\n reorderable: {\n true: 'ds:cursor-grab ds:active:cursor-grabbing',\n false: '',\n },\n },\n defaultVariants: {\n dragging: false,\n dropTarget: false,\n reorderable: false,\n },\n },\n);\n\n/* ------------------------------------------------------------------ */\n/* Props */\n/* ------------------------------------------------------------------ */\n\nexport interface ToolRailProps extends VariantProps<typeof railVariants> {\n /** Stable instance id, surfaced on the root as `data-component-id`. */\n id?: string;\n /** The tools shown as icons on the strip. */\n tools: ToolRailTool[];\n /** Controlled active tool id (null = collapsed / strip-only). */\n activeToolId?: string | null;\n /** Uncontrolled initial active tool id (default null). */\n defaultActiveToolId?: string | null;\n /** Fires whenever the active tool changes (incl. → null on collapse). */\n onActiveToolChange?: (id: string | null) => void;\n /** Which edge the rail docks to. Default `'end'` (inline-end). */\n side?: 'start' | 'end';\n /** Accessible label for the toolbar strip. */\n railLabel?: string;\n /**\n * Opt-in resize affordance for the open tool panel. Renders a\n * `role=\"separator\"` drag handle on the panel's inner edge (the edge\n * facing the main content). The committed width is written to\n * `--tool-rail-panel-inline-size` on the panel element (288–880px);\n * Enter / double-click resets to the token-driven default. Default `false`.\n */\n resizablePanel?: boolean;\n /**\n * Fires when the user reorders the `reorderable` run (drag-drop or\n * `Alt`+Arrow). `from` / `to` are indices into `tools`; the host applies the\n * move to the array it passes back. Reordering is enabled when this callback\n * is supplied AND at least one tool is `reorderable`. When the whole strip is\n * reorderable, `to` may land in the other scope group — the host interprets\n * the crossing (and may treat it as a no-op, e.g. reordering within a\n * host-ordered group).\n */\n onReorder?: (from: number, to: number) => void;\n /**\n * Optional override for the polite live-region message announced after a\n * reorder. Lets the host phrase membership-aware moves (e.g. \"Pinned X to\n * favourites\") instead of the generic \"moved to position N\". Return an empty\n * string to stay silent (e.g. for a move the host treats as a no-op). When\n * omitted, the rail announces the generic run-relative position.\n */\n formatReorderAnnouncement?: (args: {\n tool: ToolRailTool;\n from: number;\n to: number;\n }) => string;\n /**\n * Optional per-icon overlay control, rendered as a sibling of each strip\n * IconButton (the same positioned box the notification badge uses). Use for\n * a small affordance such as a pin toggle — the rail attaches no meaning to\n * what it renders. Receives the tool and its index / active state.\n */\n renderToolAffordance?: (\n tool: ToolRailTool,\n context: { index: number; isActive: boolean; isRovingTarget: boolean },\n ) => ReactNode;\n /**\n * Optional non-scrolling header rendered at the top of the OPEN tool panel,\n * above its scroll region. Host-owned content (e.g. a pin / unpin control) —\n * the rail attaches no meaning. Receives the active tool.\n */\n renderPanelHeader?: (\n tool: ToolRailTool,\n context: { isActive: boolean },\n ) => ReactNode;\n /**\n * Identity override for the root's `data-component` attribute. Defaults to\n * `'tool-rail'`. A product wrapper (e.g. ControlRoomRail) passes its own\n * kebab id so the DOM / cascade boundary — and an agent's `domHooks.root` —\n * can tell its surface apart from a bare ToolRail, without the engine ever\n * importing the wrapper.\n */\n dataComponent?: string;\n /**\n * Agent adapter registered for this rail instance. Defaults to\n * `toolRailAgent`. A wrapper passes its own adapter (matching\n * `dataComponent`) so the rail registers under the wrapper's identity. The\n * instance id is sourced from the `id` prop (also stamped as\n * `data-component-id`).\n */\n agentAdapter?: AgentAdapter<ToolRailHandle>;\n className?: string;\n}\n\n/* ------------------------------------------------------------------ */\n/* Helpers */\n/* ------------------------------------------------------------------ */\n\nfunction formatBadgeCount(count: number, overflowLabel: string): string {\n return count > 99 ? overflowLabel : String(count);\n}\n\n/* ------------------------------------------------------------------ */\n/* Root */\n/* ------------------------------------------------------------------ */\n\nexport const ToolRail = forwardRef<ToolRailHandle, ToolRailProps>(\n (\n {\n id,\n tools,\n activeToolId,\n defaultActiveToolId = null,\n onActiveToolChange,\n side = 'end',\n railLabel,\n resizablePanel = false,\n onReorder,\n formatReorderAnnouncement,\n renderToolAffordance,\n renderPanelHeader,\n dataComponent = 'tool-rail',\n agentAdapter = toolRailAgent,\n className,\n },\n ref,\n ) => {\n const { t } = useTranslation();\n\n // Controlled / uncontrolled bridge — the same hook MessageTray uses.\n const [activeRaw, setActiveRaw] = useControllableState<string | null>({\n value: activeToolId,\n defaultValue: defaultActiveToolId,\n onChange: onActiveToolChange,\n });\n const activeId = activeRaw ?? null;\n\n // Roving-tabindex bookkeeping for the vertical toolbar strip.\n const buttonsRef = useRef<Array<HTMLButtonElement | null>>([]);\n const panelRef = useRef<HTMLElement | null>(null);\n const [focusIndex, setFocusIndex] = useState(0);\n // Distinguishes keyboard activation (auto-focus into the panel) from\n // pointer activation (focus stays on the icon — less jarring).\n const activatedByKeyboardRef = useRef(false);\n // Set on Enter/Space keydown, read by the click handler that follows,\n // cleared on keyup — so a subsequent mouse click never inherits it.\n const keyboardActivateRef = useRef(false);\n\n const activeIndex = useMemo(\n () => tools.findIndex((tl) => tl.id === activeId),\n [tools, activeId],\n );\n const activeTool = activeIndex >= 0 ? tools[activeIndex] : null;\n\n // First non-disabled index — the resting roving stop when none active.\n const firstEnabledIndex = useMemo(\n () => tools.findIndex((tl) => !tl.disabled),\n [tools],\n );\n\n // Scope grouping: a divider marks the boundary between the two scope groups,\n // whichever order they appear in. The array is always grouped (all of one\n // scope, then the other); the divider precedes the first tool whose scope\n // differs from the lead tool's. `boundary > 0` guarantees both groups are\n // present. Render-only (not a `tools[]` member) so roving focus is untouched;\n // a legacy strip with no `scope` set stays ungrouped.\n const scopeDividerIndex = useMemo(() => {\n const lead = tools[0]?.scope;\n if (!lead) return -1;\n return tools.findIndex((tl) => tl.scope && tl.scope !== lead);\n }, [tools]);\n const showScopeDivider = scopeDividerIndex > 0;\n\n /* ---- Reorder (drag-and-drop + Alt+Arrow keyboard) ------------- */\n // The contiguous run of `reorderable` tools — a tool only moves within it.\n const reorderRun = useMemo(() => {\n const first = tools.findIndex((tl) => tl.reorderable);\n if (first < 0) return null;\n let last = first;\n while (last + 1 < tools.length && tools[last + 1]?.reorderable) last += 1;\n return { first, last };\n }, [tools]);\n const reorderEnabled = !!onReorder && reorderRun !== null;\n const reorderInstructionsId = useId();\n\n const [dragIndex, setDragIndex] = useState<number | null>(null);\n const [dropIndex, setDropIndex] = useState<number | null>(null);\n\n // sr-only announcement. The zero-width-space toggle forces a re-announce of\n // an identical message (e.g. moving the same item twice) — same technique\n // the Sidebar uses for its reorder live region.\n const [reorderMessage, setReorderMessage] = useState('');\n const announceToggle = useRef(false);\n const commitReorder = useCallback(\n (from: number, to: number) => {\n if (!onReorder || !reorderRun) return;\n const clamped = Math.max(\n reorderRun.first,\n Math.min(reorderRun.last, to),\n );\n if (clamped === from) return;\n onReorder(from, clamped);\n const moved = tools[from];\n if (moved) {\n // The host can phrase membership-aware moves (e.g. pin / unpin) and\n // can return '' to stay silent for a move it treats as a no-op.\n const text = formatReorderAnnouncement\n ? formatReorderAnnouncement({ tool: moved, from, to: clamped })\n : t('toolRail.reorderAnnounce', {\n tool: moved.label,\n to: clamped - reorderRun.first + 1,\n total: reorderRun.last - reorderRun.first + 1,\n defaultValue: '{{tool}} moved to position {{to}} of {{total}}',\n });\n if (text) {\n announceToggle.current = !announceToggle.current;\n setReorderMessage(announceToggle.current ? text : `${text}\\u200b`);\n }\n }\n },\n [onReorder, reorderRun, tools, t, formatReorderAnnouncement],\n );\n\n // The roving tab stop: the active icon when a tool is open, else the\n // index the user last focused, else the first enabled icon.\n const rovingIndex =\n activeIndex >= 0\n ? activeIndex\n : focusIndex >= 0 && !tools[focusIndex]?.disabled\n ? focusIndex\n : firstEnabledIndex;\n\n const selectTool = useCallback(\n (toolId: string, fromKeyboard: boolean) => {\n const tool = tools.find((tl) => tl.id === toolId);\n if (!tool || tool.disabled) return;\n activatedByKeyboardRef.current = fromKeyboard;\n // Clicking / activating the active tool collapses to strip-only.\n setActiveRaw(activeId === toolId ? null : toolId);\n },\n [tools, activeId, setActiveRaw],\n );\n\n /* ---- Roving arrow-key navigation (vertical toolbar) ----------- */\n const handleStripKeyDown = useCallback(\n (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const count = tools.length;\n if (count === 0) return;\n // Alt+Arrow is reserved for reordering (handled on the icon); never\n // let it move focus roving as well.\n if (event.altKey) return;\n\n let next: number | null = null;\n if (event.key === 'ArrowDown') next = (rovingIndex + 1) % count;\n else if (event.key === 'ArrowUp')\n next = (rovingIndex - 1 + count) % count;\n else if (event.key === 'Home') next = 0;\n else if (event.key === 'End') next = count - 1;\n if (next === null) return;\n\n // Skip disabled icons in the travel direction.\n const goingBack = event.key === 'ArrowUp' || event.key === 'End';\n let candidate = next;\n let attempts = 0;\n while (attempts < count && tools[candidate]?.disabled) {\n candidate = goingBack\n ? (candidate - 1 + count) % count\n : (candidate + 1) % count;\n attempts += 1;\n }\n if (tools[candidate]?.disabled) return;\n\n event.preventDefault();\n setFocusIndex(candidate);\n buttonsRef.current[candidate]?.focus();\n },\n [tools, rovingIndex],\n );\n\n /* ---- Esc collapses + returns focus to the active tool's icon -- */\n // Attached imperatively via the root ref (not a JSX onKeyDown on the\n // static container) so the Escape shortcut works from anywhere inside the\n // open panel without an interaction handler on a non-interactive element.\n const rootRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const node = rootRef.current;\n if (!node) return undefined;\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return;\n if (activeIndex < 0) return;\n event.preventDefault();\n const returnIndex = activeIndex;\n setActiveRaw(null);\n setFocusIndex(returnIndex);\n // Defer until after the panel unmounts so focus lands cleanly.\n requestAnimationFrame(() => {\n buttonsRef.current[returnIndex]?.focus();\n });\n };\n node.addEventListener('keydown', onKeyDown);\n return () => node.removeEventListener('keydown', onKeyDown);\n }, [activeIndex, setActiveRaw]);\n\n /* ---- Move focus into the panel when opened by keyboard -------- */\n useIsomorphicLayoutEffect(() => {\n if (activeTool && activatedByKeyboardRef.current) {\n panelRef.current?.focus();\n }\n activatedByKeyboardRef.current = false;\n }, [activeTool]);\n\n /* ---- Opt-in panel resize (inner edge) -------------------------- */\n // The handle sits on the edge facing the main content: the panel's\n // inline-start edge for an end-docked rail, inline-end for start.\n const panelEdge = side === 'end' ? 'inline-start' : 'inline-end';\n const { separatorProps, isResizing, isResized } = useEdgeResize({\n edge: panelEdge,\n targetRef: panelRef,\n cssProperty: PANEL_SIZE_PROPERTY,\n minSize: PANEL_MIN_SIZE,\n maxSize: PANEL_MAX_SIZE,\n defaultSize: PANEL_DEFAULT_SIZE,\n disabled: !resizablePanel,\n });\n\n // The aside unmounts on collapse, dropping the hook's inline override.\n // Re-assert the committed width when a panel (re)mounts so a reopened\n // panel keeps the user's chosen size.\n const committedPanelWidth = separatorProps['aria-valuenow'];\n useIsomorphicLayoutEffect(() => {\n if (!resizablePanel || !isResized || !activeTool) return;\n panelRef.current?.style.setProperty(\n PANEL_SIZE_PROPERTY,\n `${committedPanelWidth}px`,\n );\n }, [activeTool, resizablePanel, isResized, committedPanelWidth]);\n\n /* ---- Curated imperative handle for agent integration ---------- */\n const activeIdRef = useRef<string | null>(activeId);\n activeIdRef.current = activeId;\n\n const handle = useMemo<ToolRailHandle>(\n () => ({\n getActiveToolId: () => activeIdRef.current,\n setActiveTool: (toolId) => {\n activatedByKeyboardRef.current = false;\n setActiveRaw(toolId);\n },\n open: (toolId) => {\n const tool = tools.find((tl) => tl.id === toolId);\n if (!tool || tool.disabled) return;\n activatedByKeyboardRef.current = false;\n setActiveRaw(toolId);\n },\n close: () => {\n const returnId = activeIdRef.current;\n activatedByKeyboardRef.current = false;\n setActiveRaw(null);\n // Return focus to the closed tool's strip icon (mirrors Escape) so a\n // close-button / pointer collapse never drops focus to <body>.\n if (returnId != null) {\n requestAnimationFrame(() => {\n rootRef.current\n ?.querySelector<HTMLButtonElement>(\n `[data-tool-id=\"${CSS.escape(returnId)}\"]`,\n )\n ?.focus();\n });\n }\n },\n }),\n [tools, setActiveRaw],\n );\n\n useImperativeHandle(ref, () => handle, [handle]);\n useAgentRegistration(agentAdapter, handle, id);\n\n const overflowLabel = t('toolRail.badgeCountOverflow', {\n defaultValue: '99+',\n });\n\n return (\n <div\n ref={rootRef}\n data-component={dataComponent}\n data-component-id={id}\n data-side={side}\n className={[railVariants({ side }), className]\n .filter(Boolean)\n .join(' ')}\n >\n {/* Reorder a11y: a polite live region announcing each move. Each\n reorderable icon carries its own keyboard instruction (rendered in\n its slot, referenced via aria-describedby). */}\n {reorderEnabled ? (\n <span role=\"status\" aria-live=\"polite\" className=\"ds:sr-only\">\n {reorderMessage}\n </span>\n ) : null}\n {/* The OPEN panel is the single complementary landmark, named by\n the active tool. Rendered only while a tool is active so two\n unnamed regions never coexist. */}\n {activeTool ? (\n <aside\n ref={panelRef}\n tabIndex={-1}\n aria-label={t('toolRail.panelLabel', {\n tool: activeTool.label,\n defaultValue: '{{tool}} panel',\n })}\n data-tool-rail-state=\"expanded\"\n data-active-tool={activeTool.id}\n data-resizing={isResizing ? '' : undefined}\n className={[\n panelVariants(),\n // Subtle shadow — not a line — separating the panel from the\n // icon strip (the tab row). The panel casts a soft chrome\n // shadow toward the strip on its strip-facing edge. `z-[1]`\n // lifts it above the adjacent strip (the panel is already\n // `relative`) so the shadow paints at the seam instead of being\n // covered by the strip's opaque background. Only renders while\n // the panel is open (the aside is unmounted when collapsed), so\n // it never doubles as a rail↔main seam. In the accessible (AAA)\n // theme the soft shadow becomes a solid 1px border on that same\n // strip-facing edge.\n 'ds:z-[1]',\n side === 'end'\n ? 'ds:shadow-[var(--shadow-chrome-end)] ds:[.theme-accessible_&]:border-e ds:[.theme-accessible_&]:border-[var(--border)] ds:[.theme-accessible_&]:shadow-none'\n : 'ds:shadow-[var(--shadow-chrome-start)] ds:[.theme-accessible_&]:border-s ds:[.theme-accessible_&]:border-[var(--border)] ds:[.theme-accessible_&]:shadow-none',\n 'ds:focus-visible:outline-none',\n ].join(' ')}\n >\n {/* Optional host-owned, non-scrolling panel header (e.g. the\n Control Room's add / remove favourite control). Sits above the\n scroll region so it stays put as the panel body scrolls. */}\n {renderPanelHeader\n ? renderPanelHeader(activeTool, { isActive: true })\n : null}\n {/* Optional per-tool pinned header — the rail-level home for a\n sticky tool header (title / filters). Non-scrolling, above the\n body, so it stays visible for every tool. */}\n {activeTool.header ? (\n <div className=\"ds:shrink-0\">{activeTool.header}</div>\n ) : null}\n {/* Body: a self-scrolling `fill` tool owns its own scroll inside\n the height-bounded panel; otherwise the rail scrolls it. */}\n {activeTool.fill ? (\n // data-tool-fill: a self-scrolling panel owns its own native\n // scroll (it can't use the rail's ScrollArea), so a token rule\n // paints its scrollbar to match the 8px overlay. See tokens/index.css.\n <div data-tool-fill=\"\" className=\"ds:flex-1 ds:min-h-0\">\n {activeTool.panel}\n </div>\n ) : (\n <ScrollArea\n orientation=\"vertical\"\n className=\"ds:flex-1 ds:min-h-0\"\n >\n {activeTool.panel}\n </ScrollArea>\n )}\n {/* Inside the aside (so it belongs to the complementary\n landmark) and outside the toolbar strip — the strip's\n roving handlers never see its key events, and Escape\n still bubbles to the root to collapse, as everywhere\n else in the panel. No stopPropagation needed. */}\n {resizablePanel ? (\n <div\n {...separatorProps}\n aria-label={t('toolRail.resizePanel', {\n defaultValue: 'Resize tool panel',\n })}\n data-resizing={isResizing ? '' : undefined}\n className={panelResizeHandleVariants({ edge: panelEdge })}\n />\n ) : null}\n </aside>\n ) : null}\n\n {/* The 3rem icon strip — a vertical toolbar with roving tabindex.\n Self-contained TooltipProvider so consumers needn't mount one;\n Radix providers compose, so a host-level provider still works. */}\n <TooltipProvider>\n <div\n role=\"toolbar\"\n aria-orientation=\"vertical\"\n aria-label={\n railLabel ?? t('toolRail.railLabel', { defaultValue: 'Tools' })\n }\n className={stripVariants()}\n onKeyDown={handleStripKeyDown}\n >\n {tools.map((tool, index) => {\n const isActive = tool.id === activeId;\n const showBadge =\n typeof tool.badgeCount === 'number' && tool.badgeCount > 0;\n // Fold the count into the accessible name so SR users hear it\n // without relying on the decorative chip.\n const accessibleName = showBadge\n ? t('toolRail.toolWithCount', {\n tool: tool.label,\n count: tool.badgeCount,\n defaultValue: '{{tool}}, {{count}} updates',\n })\n : tool.label;\n const canReorderTool =\n reorderEnabled && !!tool.reorderable && !tool.disabled;\n const reorderDescId = canReorderTool\n ? `${reorderInstructionsId}-${tool.id}`\n : undefined;\n return (\n <Fragment key={tool.id}>\n {showScopeDivider && index === scopeDividerIndex ? (\n <div\n role=\"separator\"\n aria-orientation=\"horizontal\"\n className=\"ds:my-[var(--spacing-2xs)] ds:h-px ds:w-[var(--spacing-lg)] ds:shrink-0 ds:bg-[var(--border)] ds:forced-colors:bg-[CanvasText]\"\n />\n ) : null}\n <div\n className={toolSlotVariants({\n dragging: dragIndex === index,\n dropTarget: dropIndex === index && dragIndex !== index,\n reorderable: canReorderTool,\n })}\n data-dragging={dragIndex === index ? '' : undefined}\n // Drag the whole slot — the icon button is an unreliable\n // HTML5 drag source across browsers. The button keeps its\n // click + Alt+Arrow keyboard reorder; drag is pointer-only.\n draggable={canReorderTool || undefined}\n onDragStart={\n canReorderTool\n ? (event) => {\n setDragIndex(index);\n event.dataTransfer.effectAllowed = 'move';\n // Firefox needs data set to initiate a drag.\n event.dataTransfer.setData(\n 'text/plain',\n String(index),\n );\n }\n : undefined\n }\n onDragOver={\n canReorderTool\n ? (event) => {\n if (dragIndex === null) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = 'move';\n if (dropIndex !== index) setDropIndex(index);\n }\n : undefined\n }\n onDragLeave={\n canReorderTool\n ? () =>\n setDropIndex((cur) => (cur === index ? null : cur))\n : undefined\n }\n onDrop={\n canReorderTool\n ? (event) => {\n event.preventDefault();\n const from = dragIndex;\n setDropIndex(null);\n setDragIndex(null);\n if (from === null || from === index) return;\n commitReorder(from, index);\n }\n : undefined\n }\n onDragEnd={\n canReorderTool\n ? () => {\n setDragIndex(null);\n setDropIndex(null);\n }\n : undefined\n }\n >\n <IconButton\n ref={(el) => {\n buttonsRef.current[index] = el;\n }}\n icon={tool.icon}\n tooltip={tool.label}\n aria-label={accessibleName}\n intent=\"ghost\"\n size=\"sm\"\n disabled={tool.disabled}\n aria-pressed={isActive}\n aria-expanded={isActive}\n data-active={isActive ? tool.id : undefined}\n data-tool-id={tool.id}\n aria-describedby={reorderDescId}\n aria-keyshortcuts={\n canReorderTool ? 'Alt+ArrowUp Alt+ArrowDown' : undefined\n }\n tabIndex={index === rovingIndex ? 0 : -1}\n onFocus={() => {\n if (!tool.disabled) setFocusIndex(index);\n }}\n onClick={() =>\n selectTool(tool.id, keyboardActivateRef.current)\n }\n onKeyDown={(event) => {\n // Enter/Space activate via the native button's click,\n // which fires AFTER this keydown. Flag the upcoming\n // click as keyboard-driven so focus moves into the\n // panel; reset on keyup so a later mouse click doesn't\n // inherit the flag.\n if (event.key === 'Enter' || event.key === ' ') {\n keyboardActivateRef.current = true;\n return;\n }\n // Alt+Arrow / Alt+Home / Alt+End reorder within the run.\n // Focus follows the moved icon to its new index; roving\n // ignores Alt (see handleStripKeyDown).\n if (canReorderTool && event.altKey && reorderRun) {\n let target: number | null = null;\n if (event.key === 'ArrowUp') target = index - 1;\n else if (event.key === 'ArrowDown')\n target = index + 1;\n else if (event.key === 'Home')\n target = reorderRun.first;\n else if (event.key === 'End')\n target = reorderRun.last;\n if (target !== null) {\n event.preventDefault();\n const dest = Math.max(\n reorderRun.first,\n Math.min(reorderRun.last, target),\n );\n // Focus follows the moved TOOL (by id), not the\n // slot index — so it lands correctly however the\n // host reinterprets the move (reorder, cross-group\n // pin / unpin, or a no-op that leaves it in place).\n const movedId = tool.id;\n commitReorder(index, dest);\n requestAnimationFrame(() => {\n rootRef.current\n ?.querySelector<HTMLButtonElement>(\n `[data-tool-id=\"${CSS.escape(movedId)}\"]`,\n )\n ?.focus();\n });\n }\n }\n }}\n onKeyUp={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n keyboardActivateRef.current = false;\n }\n }}\n />\n {showBadge ? (\n <span aria-hidden=\"true\" className={badgeVariants()}>\n {formatBadgeCount(\n tool.badgeCount as number,\n overflowLabel,\n )}\n </span>\n ) : null}\n {renderToolAffordance?.(tool, {\n index,\n isActive,\n isRovingTarget: index === rovingIndex,\n })}\n {reorderDescId ? (\n <span id={reorderDescId} className=\"ds:sr-only\">\n {t('toolRail.reorderInstructions', {\n tool: tool.label,\n defaultValue:\n 'Reorder {{tool}}. Press Alt + Up or Alt + Down to move.',\n })}\n </span>\n ) : null}\n </div>\n </Fragment>\n );\n })}\n </div>\n </TooltipProvider>\n </div>\n );\n },\n);\n\nToolRail.displayName = 'ToolRail';\n"],"names":["toolRailAgent","handle","args","RAIL_WIDTH","PANEL_WIDTH","PANEL_SIZE_PROPERTY","PANEL_MIN_SIZE","PANEL_MAX_SIZE","PANEL_DEFAULT_SIZE","railVariants","cva","stripVariants","panelVariants","panelResizeHandleVariants","badgeVariants","toolSlotVariants","formatBadgeCount","count","overflowLabel","ToolRail","forwardRef","id","tools","activeToolId","defaultActiveToolId","onActiveToolChange","side","railLabel","resizablePanel","onReorder","formatReorderAnnouncement","renderToolAffordance","renderPanelHeader","dataComponent","agentAdapter","className","ref","t","useTranslation","activeRaw","setActiveRaw","useControllableState","activeId","buttonsRef","useRef","panelRef","focusIndex","setFocusIndex","useState","activatedByKeyboardRef","keyboardActivateRef","activeIndex","useMemo","tl","activeTool","firstEnabledIndex","scopeDividerIndex","lead","_a","showScopeDivider","reorderRun","first","last","reorderEnabled","reorderInstructionsId","useId","dragIndex","setDragIndex","dropIndex","setDropIndex","reorderMessage","setReorderMessage","announceToggle","commitReorder","useCallback","from","to","clamped","moved","text","rovingIndex","selectTool","toolId","fromKeyboard","tool","handleStripKeyDown","event","next","goingBack","candidate","attempts","_b","_c","rootRef","useEffect","node","onKeyDown","returnIndex","useIsomorphicLayoutEffect","panelEdge","separatorProps","isResizing","isResized","useEdgeResize","committedPanelWidth","activeIdRef","returnId","useImperativeHandle","useAgentRegistration","jsxs","jsx","ScrollArea","TooltipProvider","index","isActive","showBadge","accessibleName","canReorderTool","reorderDescId","Fragment","cur","IconButton","el","target","dest","movedId"],"mappings":";;;;;;;;;;;AAYO,MAAMA,KAA8C;AAAA,EACzD,IAAI;AAAA,EACJ,cAAc,CAAC,QAAQ,SAAS,eAAe;AAAA,EAC/C,OAAO;AAAA,IACL,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,gBAA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