@stonecrop/aform 0.48.0 → 0.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aform.js.map +1 -1
- package/package.json +18 -20
package/dist/aform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aform.js","names":[],"sources":["../src/utils/deserialize.ts","../src/utils/badge.ts","../src/utils/columns.ts","../src/composables/fieldErrorA11y.ts","../src/components/form/ACheckbox.vue","../src/components/form/ACheckbox.vue","../src/utils/linkValue.ts","../src/utils/currencyValue.ts","../src/utils/emptiedBox.ts","../src/utils/recordNumber.ts","../src/composables/dropdownList.ts","../src/components/form/ADropdownList.vue","../src/components/form/ADropdownList.vue","../src/components/form/ADropdown.vue","../src/components/form/ADropdown.vue","../src/components/form/ACurrencyInput.vue","../src/components/form/ACurrencyInput.vue","../src/utils/typedDay.ts","../src/components/form/ADatePicker.vue","../src/components/form/ADatePicker.vue","../src/components/form/ADateTimeInput.vue","../src/components/form/ADateTimeInput.vue","../src/components/form/ADateSelection.vue","../src/components/form/ADateSelection.vue","../src/utils/fieldCalendar.ts","../src/components/form/ADate.vue","../src/components/form/ADate.vue","../src/components/form/ABadge.vue","../src/components/form/ABadge.vue","../src/components/form/ASegmentedControl.vue","../src/components/form/ASegmentedControl.vue","../src/components/form/ADateTime.vue","../src/components/form/ADateTime.vue","../src/components/form/ADuration.vue","../src/components/form/ADuration.vue","../src/components/form/ADateRange.vue","../src/components/form/ADateRange.vue","../src/components/AForm.vue","../src/components/AForm.vue","../src/components/base/CollapseButton.vue","../src/components/base/CollapseButton.vue","../src/components/form/AFieldset.vue","../src/components/form/AFieldset.vue","../src/components/form/AFileAttach.vue","../src/components/form/AFileAttach.vue","../src/components/form/AFormLink.vue","../src/components/form/AFormLink.vue","../src/components/form/ANumericInput.vue","../src/components/form/ANumericInput.vue","../src/utils/quantityValue.ts","../src/components/form/AQuantityInput.vue","../src/components/form/AQuantityInput.vue","../src/components/form/ASemverInput.vue","../src/components/form/ASemverInput.vue","../src/directives/mask.ts","../src/components/form/ATextInput.vue","../src/components/form/ATextInput.vue","../src/components/form/ATextboxInput.vue","../src/components/form/ATextboxInput.vue","../src/components/utilities/Login.vue","../src/components/utilities/Login.vue","../src/components/AFormLoading.vue","../src/components/base/ExpandButton.vue","../src/components/base/ExpandButton.vue","../src/composables/useTableModalDropdownList.ts","../src/components/table/ATableTupleCurrencyPicker.vue","../src/components/table/ATableTupleCurrencyPicker.vue","../src/components/table/ATableTupleQuantityPicker.vue","../src/components/table/ATableTupleQuantityPicker.vue","../src/components/table/ATupleCellShell.vue","../src/components/table/ATupleCellShell.vue","../src/components/table/ATupleCellEditor.vue","../src/components/table/ATupleCellEditor.vue","../src/index.ts"],"sourcesContent":["/**\n * Deserializes a stringified function expression into a typed callable.\n *\n * Throws if the string cannot be parsed as a function (SyntaxError) or if the\n * resulting expression is not callable (TypeError), or if the expression references\n * an undefined variable (ReferenceError). Callers are responsible for try/catch.\n *\n * @example\n * ```ts\n * const fn = deserializeFunction<(x: number) => number>('(x) => x * 2')\n * fn(5) // 10\n * ```\n * @public\n */\n// T is intentionally a caller-supplied return type — this utility is unsafe by design (Function constructor).\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters\nexport function deserializeFunction<T extends (...args: any[]) => any>(source: string): T {\n\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion, typescript/no-implied-eval\n\treturn Function(`\"use strict\"; return (${source})`)() as T\n}\n","import type { BadgeDescriptor, FieldOptions } from '@stonecrop/schema'\nimport { isBadgeDescriptor, lookupBadge } from '@stonecrop/schema'\n\nimport { deserializeFunction } from './deserialize'\n\n/**\n * Row context passed to badge `format` functions in form fields.\n * @public\n */\nexport type BadgeFormatContext = {\n\trecord?: Record<string, unknown>\n\trow?: Record<string, unknown>\n}\n\n/**\n * Badge-aware field `format` function signature.\n * @public\n */\nexport type BadgeFormatFn = (value: unknown, context: BadgeFormatContext) => string | BadgeDescriptor\n\n/**\n * Resolve a field value to a badge descriptor using format (if present) then options map.\n * @public\n */\nexport function resolveFieldBadge(\n\tvalue: unknown,\n\toptions: FieldOptions | undefined,\n\tformat: string | BadgeFormatFn | undefined,\n\tcontext: BadgeFormatContext = {}\n): BadgeDescriptor | undefined {\n\tif (format) {\n\t\tlet formatted: unknown\n\t\tif (typeof format === 'function') {\n\t\t\tformatted = format(value, context)\n\t\t} else {\n\t\t\tconst formatFn = deserializeFunction<BadgeFormatFn>(format)\n\t\t\tformatted = formatFn(value, context)\n\t\t}\n\t\tif (isBadgeDescriptor(formatted)) {\n\t\t\tconst label = formatted.label.trim()\n\t\t\treturn label ? formatted : undefined\n\t\t}\n\t\tif (typeof formatted === 'string' && formatted !== '') {\n\t\t\treturn lookupBadge(options, formatted) ?? { label: formatted, variant: 'neutral' }\n\t\t}\n\t}\n\n\tconst key = badgeLookupKey(value)\n\tif (key === undefined) return undefined\n\treturn lookupBadge(options, key)\n}\n\n/**\n * Stored choice value as an options-map key. Only primitives can match a declared choice, so\n * anything else yields undefined rather than the '[object Object]' that String() would produce.\n */\nfunction badgeLookupKey(value: unknown): string | undefined {\n\tswitch (typeof value) {\n\t\tcase 'string':\n\t\t\treturn value === '' ? undefined : value\n\t\tcase 'number':\n\t\tcase 'boolean':\n\t\tcase 'bigint':\n\t\t\treturn String(value)\n\t\tdefault:\n\t\t\treturn undefined\n\t}\n}\n\nconst BADGE_VARIANTS = new Set<string>(['neutral', 'success', 'warning', 'danger', 'brand'])\n\n/**\n * CSS custom properties for input-accent styling on a native input.\n * @public\n */\nexport function badgeInputAccentStyle(descriptor: BadgeDescriptor | undefined): Record<string, string> | undefined {\n\tif (!descriptor?.label?.trim()) return undefined\n\tconst variant = descriptor.variant ?? 'neutral'\n\tif (descriptor.color) {\n\t\treturn {\n\t\t\tborderLeftWidth: '4px',\n\t\t\tborderLeftStyle: 'solid',\n\t\t\tborderLeftColor: descriptor.color,\n\t\t\tpaddingLeft: 'calc(1ch - 4px)',\n\t\t}\n\t}\n\tif (!BADGE_VARIANTS.has(variant)) return undefined\n\treturn {\n\t\tborderLeftWidth: '4px',\n\t\tborderLeftStyle: 'solid',\n\t\tborderLeftColor: `var(--sc-badge-${variant}-accent)`,\n\t\tpaddingLeft: 'calc(1ch - 4px)',\n\t}\n}\n","import type { ColumnSchema } from '@stonecrop/schema'\n\nimport type { ResolvedField } from '../types'\n\n/**\n * The resolved fields that can be columns in a list or table view, in declaration order.\n *\n * A cell renders one value, so only `kind: 'field'` qualifies. The other three kinds are\n * containers: a `fieldset` groups fields for layout and has no value of its own, while a `link`\n * and a `table` hold a nested record and an array of them. Neither has a `cellComponent`, so a\n * container reaching `ACell` falls through to plain-text rendering and stringifies its children —\n * no error and no log, just a wrong column.\n *\n * A fieldset's *children* are real columns, so it is flattened rather than dropped; losing them is\n * the same silent defect in the other direction.\n *\n * This is the one definition, for a child table's columns and a records list alike. Call it; never\n * re-derive it at a call site, which produced exactly one of the two failures above at each.\n *\n * @param fields - resolved fields, as produced by `resolveSchema`\n * @returns column definitions, with the `kind` discriminator stripped\n * @public\n */\nexport function resolvedFieldsToColumns(fields: readonly ResolvedField[]): ColumnSchema[] {\n\tconst columns: ColumnSchema[] = []\n\n\tfor (const field of fields) {\n\t\tif (field.kind === 'fieldset') {\n\t\t\tcolumns.push(...resolvedFieldsToColumns(field.schema))\n\t\t} else if (field.kind === 'field') {\n\t\t\tconst { kind: _kind, ...column } = field\n\t\t\tcolumns.push(column)\n\t\t}\n\t}\n\n\treturn columns\n}\n","import { computed, type ComputedRef } from 'vue'\n\nexport function fieldErrorA11y(\n\tuuid: string | undefined,\n\terrorText: ComputedRef<string>,\n\textraDescribedBy?: ComputedRef<string | undefined>\n) {\n\tconst errorId = computed(() => (uuid ? `${uuid}-error` : undefined))\n\tconst hasError = computed(() => Boolean(errorText.value))\n\tconst describedBy = computed(() => {\n\t\tif (hasError.value && errorId.value) return errorId.value\n\t\treturn extraDescribedBy?.value\n\t})\n\tconst invalid = computed(() => (hasError.value ? true : undefined))\n\n\treturn { errorId, hasError, describedBy, invalid }\n}\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t\t<span class=\"aform_display-value\">{{ checkbox ? '✓' : '✗' }}</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<span class=\"aform_checkbox-container aform_input-field\">\n\t\t\t\t<input\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\tv-model=\"checkbox\"\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclass=\"aform_checkbox\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t</span>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, InputHTMLAttributes } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst checkbox = defineModel<InputHTMLAttributes['checked']>()\n</script>\n\n<style scoped>\n.aform_checkbox {\n\tcursor: pointer;\n\twidth: auto;\n\tmargin-top: 0;\n\tdisplay: block;\n}\n\n.aform_checkbox:checked {\n\taccent-color: var(--sc-primary-color);\n\tborder: 1px solid var(--sc-input-active-border-color);\n}\n\n.aform_checkbox-container {\n\twidth: 100%;\n\tdisplay: inline-block;\n\ttext-align: left;\n}\n\n.aform_checkbox-container input {\n\twidth: auto;\n}\n\n.aform_form-element:has(> .aform_checkbox-container:hover) > .aform_field-label {\n\tcolor: var(--sc-input-active-label-color);\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t\t<span class=\"aform_display-value\">{{ checkbox ? '✓' : '✗' }}</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<span class=\"aform_checkbox-container aform_input-field\">\n\t\t\t\t<input\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\tv-model=\"checkbox\"\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclass=\"aform_checkbox\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t</span>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, InputHTMLAttributes } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst checkbox = defineModel<InputHTMLAttributes['checked']>()\n</script>\n\n<style scoped>\n.aform_checkbox {\n\tcursor: pointer;\n\twidth: auto;\n\tmargin-top: 0;\n\tdisplay: block;\n}\n\n.aform_checkbox:checked {\n\taccent-color: var(--sc-primary-color);\n\tborder: 1px solid var(--sc-input-active-border-color);\n}\n\n.aform_checkbox-container {\n\twidth: 100%;\n\tdisplay: inline-block;\n\ttext-align: left;\n}\n\n.aform_checkbox-container input {\n\twidth: auto;\n}\n\n.aform_form-element:has(> .aform_checkbox-container:hover) > .aform_field-label {\n\tcolor: var(--sc-input-active-label-color);\n}\n</style>\n","import type { AFormLinkModelValue, AFormLinkValue } from '../types'\n\nexport function linkId(value: AFormLinkModelValue | null | undefined): string | undefined {\n\tif (value == null) return undefined\n\tif (typeof value === 'string') return value === '' ? undefined : value\n\tif (typeof value === 'number') return String(value)\n\tconst id = value.id\n\tif (id === null || id === undefined || id === '') return undefined\n\treturn String(id)\n}\n\nexport function linkDisplayText(value: AFormLinkModelValue | null | undefined): string | undefined {\n\tif (value == null || typeof value !== 'object') return undefined\n\tconst text = value.displayText\n\tif (typeof text === 'string') return text\n\tif (typeof text === 'number') return String(text)\n\treturn undefined\n}\n\nexport function asLinkValue(value: AFormLinkModelValue | null | undefined): AFormLinkValue {\n\tif (value != null && typeof value === 'object') return value\n\tconst id = linkId(value)\n\treturn id !== undefined ? { id } : { id: '' }\n}\n","import type { AFormLinkValue, CurrencyOptions, CurrencyValue } from '../types'\nimport { linkId } from './linkValue'\n\nconst FLOAT_NOISE_DECIMALS = 6\n\nexport function normalizeBaseCurrency(\n\toptions: CurrencyOptions,\n\tcurrent: CurrencyValue | null | undefined\n): AFormLinkValue {\n\tconst base = options.baseCurrency ?? current?.baseCurrency\n\tif (!base) return { id: '' }\n\treturn typeof base === 'string' ? { id: base } : base\n}\n\nexport function baseAmountDecimals(options: CurrencyOptions): number {\n\tconst { precision } = options\n\tif (precision === undefined) return FLOAT_NOISE_DECIMALS\n\treturn Number.isInteger(precision) && precision >= 0 && precision <= 100 ? precision : FLOAT_NOISE_DECIMALS\n}\n\nexport function resolveCurrencyExchangeRate(\n\tcurrencyId: string | number | undefined,\n\toptions: CurrencyOptions,\n\tbaseCurrency: AFormLinkValue,\n\tcurrent: CurrencyValue | null | undefined\n): number {\n\tconst baseId = baseCurrency.id\n\tif (!currencyId || String(currencyId) === String(baseId)) return 1\n\t// `linkId`, never `.id`: a currency read from a record's own field may be its bare id, and taking it for\n\t// another currency replaces the stored rate.\n\tif (String(currencyId) === linkId(current?.currency)) {\n\t\treturn current?.exchangeRate ?? options.exchangeRates?.[String(currencyId)] ?? 1\n\t}\n\treturn options.exchangeRates?.[String(currencyId)] ?? 1\n}\n\nconst roundAmount = (value: number, decimals: number): number => Number(value.toFixed(decimals))\n\nexport function recomputeCurrencyValue(\n\tamount: number | null,\n\tcurrencyValue: AFormLinkValue,\n\toptions: CurrencyOptions,\n\tbaseCurrency: AFormLinkValue,\n\tcurrent: CurrencyValue | null | undefined\n): CurrencyValue {\n\tconst exchangeRate = resolveCurrencyExchangeRate(currencyValue.id, options, baseCurrency, current)\n\tconst decimals = baseAmountDecimals(options)\n\treturn {\n\t\tamount,\n\t\tcurrency: currencyValue,\n\t\texchangeRate,\n\t\tbaseCurrency,\n\t\tbaseAmount: amount === null ? null : roundAmount(amount * exchangeRate, decimals),\n\t}\n}\n\nexport function patchCurrencyAmount(\n\tcurrent: CurrencyValue | null | undefined,\n\tamount: number | null,\n\toptions: CurrencyOptions,\n\tbaseCurrency: AFormLinkValue\n): CurrencyValue {\n\tif (!current) return recomputeCurrencyValue(amount, { id: '' }, options, baseCurrency, current)\n\t// Currency and rate exactly as given, never re-derived: they are often fields of their own, which\n\t// an order's totals share, so typing one amount must not change them.\n\tconst recomputed = recomputeCurrencyValue(amount, current.currency ?? { id: '' }, options, baseCurrency, current)\n\treturn { ...recomputed, currency: current.currency, exchangeRate: current.exchangeRate }\n}\n\nexport function patchCurrencyCurrency(\n\tcurrent: CurrencyValue | null | undefined,\n\tcurrencyValue: AFormLinkValue,\n\toptions: CurrencyOptions,\n\tbaseCurrency: AFormLinkValue\n): CurrencyValue {\n\treturn recomputeCurrencyValue(current?.amount ?? null, currencyValue, options, baseCurrency, current)\n}\n\n/** Static currency choices when no async filterFunction is configured (base + exchangeRates keys). */\nexport function staticCurrencyChoices(\n\toptions: CurrencyOptions,\n\tcurrent: CurrencyValue | null | undefined\n): AFormLinkValue[] {\n\tconst base = normalizeBaseCurrency(options, current)\n\tconst seen = new Set<string>()\n\tconst choices: AFormLinkValue[] = []\n\tif (base.id) {\n\t\tchoices.push(base)\n\t\tseen.add(String(base.id))\n\t}\n\tconst currentCur = current?.currency\n\tif (currentCur?.id && !seen.has(String(currentCur.id))) {\n\t\tchoices.push(currentCur)\n\t\tseen.add(String(currentCur.id))\n\t}\n\tfor (const id of Object.keys(options.exchangeRates ?? {})) {\n\t\tif (!seen.has(id)) {\n\t\t\tchoices.push({ id, displayText: id })\n\t\t\tseen.add(id)\n\t\t}\n\t}\n\treturn choices\n}\n","/**\n * A date box's day as `v-model` hands it back, or null once any part of the box is empty, which the\n * browser reports as `''`.\n */\nexport function dayFromBox(text: string): string | null {\n\treturn text === '' ? null : text\n}\n\n/**\n * A number box's number as `v-model` hands it back, or null once the box is empty. `v-model` hands\n * back the box's text when it holds no number, and the browser reports an empty box as `''`.\n */\nexport function numberFromBox(value: number | ''): number | null {\n\treturn value === '' ? null : value\n}\n","/**\n * A number part of a box's value as a number, or null when it holds none. A part read from a record's\n * own field holds what the server sent, and Postgres sends a `numeric` column as its decimal text.\n */\nexport function numberFromRecord(value: number | string | null | undefined): number | null {\n\tif (value === null || value === undefined || value === '') return null\n\treturn typeof value === 'number' ? value : Number(value)\n}\n","import { nextTick, onBeforeUnmount, watch, type Ref } from 'vue'\n\n// Left between a shrunk list and the window's bottom.\nconst WINDOW_MARGIN = 8\n// With less room than this below, a list keeps this many rows and runs past the window.\nconst MIN_ROWS = 4\n\ntype DropdownListState = {\n\tisOpen: () => boolean\n\t/** Options arrive after a list opens when its search is async, and each arrival is measured again. */\n\toptionCount: () => number\n\tactiveIndex: () => number | null\n}\n\n/**\n * Keeps an open dropdown list in the window: its height is the smaller of `--sc-dropdown-max-height`\n * (the stylesheet's `max-height`) and the room left below it, never under about four rows, and the\n * option the arrow keys highlight is scrolled into sight.\n */\nexport function fitDropdownList(list: Readonly<Ref<HTMLElement | null>>, state: DropdownListState) {\n\tconst fit = (event?: Event) => {\n\t\tconst element = list.value\n\t\t// The list's own scrolling moves nothing it is measured against.\n\t\tif (!element || !state.isOpen() || event?.target === element) return\n\t\telement.style.maxHeight = ''\n\t\tconst cap = Number.parseFloat(getComputedStyle(element).maxHeight)\n\t\tconst row = element.querySelector('[role=\"option\"]')?.getBoundingClientRect().height ?? 0\n\t\tconst room = window.innerHeight - element.getBoundingClientRect().top - WINDOW_MARGIN\n\t\tconst height = Math.max(room, MIN_ROWS * row)\n\t\t// `none` reads as NaN, and then the room below is the only limit.\n\t\tif (Number.isNaN(cap) || height < cap) element.style.maxHeight = `${Math.floor(height)}px`\n\t}\n\n\tconst listen = () => {\n\t\twindow.addEventListener('scroll', fit, { capture: true, passive: true })\n\t\twindow.addEventListener('resize', fit, { passive: true })\n\t}\n\tconst stopListening = () => {\n\t\twindow.removeEventListener('scroll', fit, { capture: true })\n\t\twindow.removeEventListener('resize', fit)\n\t}\n\n\twatch(\n\t\t() => state.isOpen(),\n\t\topen => {\n\t\t\tif (open) return listen()\n\t\t\tstopListening()\n\t\t\tif (list.value) list.value.style.maxHeight = ''\n\t\t}\n\t)\n\n\t// After the flush, not in it: a `v-show` list is still hidden while post-flush watchers run, and a\n\t// hidden list measures as sitting at the top of the window.\n\twatch(\n\t\t() => state.isOpen() && state.optionCount(),\n\t\t() => void nextTick(() => fit())\n\t)\n\n\twatch(\n\t\t() => state.activeIndex(),\n\t\tindex => {\n\t\t\tif (index === null || index < 0) return\n\t\t\t// jsdom, where hosts test the forms they build, has no scrollIntoView.\n\t\t\tvoid nextTick(() =>\n\t\t\t\tlist.value?.querySelectorAll('[role=\"option\"]')[index]?.scrollIntoView?.({ block: 'nearest' })\n\t\t\t)\n\t\t},\n\t\t{ flush: 'post' }\n\t)\n\n\tonBeforeUnmount(stopListening)\n}\n","<template>\n\t<ul\n\t\tv-show=\"open\"\n\t\t:id=\"listboxId\"\n\t\tref=\"root\"\n\t\tclass=\"autocomplete-results\"\n\t\t:class=\"{\n\t\t\t'autocomplete-results--anchor-group': listAnchor === 'group',\n\t\t\t'autocomplete-results--cell-modal': surface === 'cell-modal',\n\t\t}\"\n\t\trole=\"listbox\"\n\t\t:aria-label=\"ariaLabel\">\n\t\t<slot />\n\t</ul>\n</template>\n\n<script setup lang=\"ts\">\nimport { useTemplateRef } from 'vue'\n\nimport { fitDropdownList } from '../../composables/dropdownList'\n\nconst {\n\tlistboxId,\n\tariaLabel,\n\topen,\n\tlistAnchor = 'field',\n\tsurface = 'field',\n\toptionCount,\n\tactiveIndex,\n} = defineProps<{\n\tlistboxId: string\n\tariaLabel: string\n\topen: boolean\n\tlistAnchor?: 'field' | 'group'\n\t/** `cell-modal`: list fills {@link ATableModal} width (table tuple pickers). */\n\tsurface?: 'field' | 'cell-modal'\n\toptionCount: () => number\n\tactiveIndex: () => number | null\n}>()\n\nconst root = useTemplateRef<HTMLElement>('root')\n\nfitDropdownList(root, {\n\tisOpen: () => open,\n\toptionCount,\n\tactiveIndex,\n})\n\ndefineExpose({ root })\n</script>\n\n<style scoped>\n.autocomplete-results {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\tright: 0;\n\tz-index: 100;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n\tcolor: var(--sc-cell-text-color);\n\tborder: 1px solid var(--sc-row-border-color);\n\tborder-radius: 0 0 var(--sc-border-radius) var(--sc-border-radius);\n\tborder-top: none;\n\tborder-left: none;\n\tbackground-color: var(--sc-overlay-background);\n\tbox-shadow: var(--sc-overlay-shadow);\n\tlist-style: none;\n\tmax-height: var(--sc-dropdown-max-height);\n\toverflow-y: auto;\n}\n\n.autocomplete-results--anchor-group {\n\tleft: -1px;\n\tright: -1px;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.autocomplete-results--cell-modal {\n\tposition: relative;\n\ttop: 0;\n\tleft: 0;\n\tright: 0;\n\twidth: 100%;\n\tmin-width: 100%;\n\tmax-width: none;\n\tborder-top: none;\n}\n\n/* :deep — option rows are slotted from ADropdown / AFormLink; scoped rules do not reach them otherwise. */\n.autocomplete-results :deep(.autocomplete-result) {\n\ttext-align: left;\n\tbox-sizing: border-box;\n\tborder-left: 2px solid transparent;\n\tpadding: 0.35rem 0.75ch 0.35rem 0.25ch;\n\tcursor: pointer;\n\tcolor: var(--sc-cell-text-color);\n}\n\n.autocomplete-results :deep(.autocomplete-result:hover),\n.autocomplete-results :deep(.autocomplete-result.is-active) {\n\tbackground-color: var(--sc-dropdown-option-hover-background);\n\tcolor: var(--sc-cell-text-color);\n}\n\n/* Committed value (v-model): one 2px bar (ATable uses 4px on row cells; no stacked list + inset). */\n.autocomplete-results :deep(.autocomplete-result.is-selected) {\n\tborder-left-color: var(--sc-dropdown-option-selected-accent);\n}\n</style>\n","<template>\n\t<ul\n\t\tv-show=\"open\"\n\t\t:id=\"listboxId\"\n\t\tref=\"root\"\n\t\tclass=\"autocomplete-results\"\n\t\t:class=\"{\n\t\t\t'autocomplete-results--anchor-group': listAnchor === 'group',\n\t\t\t'autocomplete-results--cell-modal': surface === 'cell-modal',\n\t\t}\"\n\t\trole=\"listbox\"\n\t\t:aria-label=\"ariaLabel\">\n\t\t<slot />\n\t</ul>\n</template>\n\n<script setup lang=\"ts\">\nimport { useTemplateRef } from 'vue'\n\nimport { fitDropdownList } from '../../composables/dropdownList'\n\nconst {\n\tlistboxId,\n\tariaLabel,\n\topen,\n\tlistAnchor = 'field',\n\tsurface = 'field',\n\toptionCount,\n\tactiveIndex,\n} = defineProps<{\n\tlistboxId: string\n\tariaLabel: string\n\topen: boolean\n\tlistAnchor?: 'field' | 'group'\n\t/** `cell-modal`: list fills {@link ATableModal} width (table tuple pickers). */\n\tsurface?: 'field' | 'cell-modal'\n\toptionCount: () => number\n\tactiveIndex: () => number | null\n}>()\n\nconst root = useTemplateRef<HTMLElement>('root')\n\nfitDropdownList(root, {\n\tisOpen: () => open,\n\toptionCount,\n\tactiveIndex,\n})\n\ndefineExpose({ root })\n</script>\n\n<style scoped>\n.autocomplete-results {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\tright: 0;\n\tz-index: 100;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n\tcolor: var(--sc-cell-text-color);\n\tborder: 1px solid var(--sc-row-border-color);\n\tborder-radius: 0 0 var(--sc-border-radius) var(--sc-border-radius);\n\tborder-top: none;\n\tborder-left: none;\n\tbackground-color: var(--sc-overlay-background);\n\tbox-shadow: var(--sc-overlay-shadow);\n\tlist-style: none;\n\tmax-height: var(--sc-dropdown-max-height);\n\toverflow-y: auto;\n}\n\n.autocomplete-results--anchor-group {\n\tleft: -1px;\n\tright: -1px;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.autocomplete-results--cell-modal {\n\tposition: relative;\n\ttop: 0;\n\tleft: 0;\n\tright: 0;\n\twidth: 100%;\n\tmin-width: 100%;\n\tmax-width: none;\n\tborder-top: none;\n}\n\n/* :deep — option rows are slotted from ADropdown / AFormLink; scoped rules do not reach them otherwise. */\n.autocomplete-results :deep(.autocomplete-result) {\n\ttext-align: left;\n\tbox-sizing: border-box;\n\tborder-left: 2px solid transparent;\n\tpadding: 0.35rem 0.75ch 0.35rem 0.25ch;\n\tcursor: pointer;\n\tcolor: var(--sc-cell-text-color);\n}\n\n.autocomplete-results :deep(.autocomplete-result:hover),\n.autocomplete-results :deep(.autocomplete-result.is-active) {\n\tbackground-color: var(--sc-dropdown-option-hover-background);\n\tcolor: var(--sc-cell-text-color);\n}\n\n/* Committed value (v-model): one 2px bar (ATable uses 4px on row cells; no stacked list + inset). */\n.autocomplete-results :deep(.autocomplete-result.is-selected) {\n\tborder-left-color: var(--sc-dropdown-option-selected-accent);\n}\n</style>\n","<template>\n\t<div\n\t\t:class=\"[\n\t\t\t'aform_form-element',\n\t\t\t{ 'aform_form-element--embedded': embedded, 'aform_dropdown--anchor-group': listAnchor === 'group' },\n\t\t]\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span v-if=\"!linkPicker && badgeDescriptor\" class=\"aform_display-value\" :style=\"displayAccentStyle\">{{\n\t\t\t\tbadgeDescriptor.label\n\t\t\t}}</span>\n\t\t\t<span v-else-if=\"!linkPicker\" class=\"aform_display-value\">{{ search }}</span>\n\t\t\t<span v-else class=\"aform_display-value\">{{ linkDisplayedText }}</span>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div v-on-click-outside=\"onClickOutside\" class=\"autocomplete\" :class=\"{ isOpen: dropdown.open }\">\n\t\t\t\t<button\n\t\t\t\t\tv-if=\"trigger === 'button'\"\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclass=\"aform_dropdown-button\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:aria-label=\"ariaLabel ?? label\"\n\t\t\t\t\taria-haspopup=\"listbox\"\n\t\t\t\t\t:aria-expanded=\"dropdown.open\"\n\t\t\t\t\t:aria-controls=\"dropdown.open ? listboxId : undefined\"\n\t\t\t\t\t:aria-activedescendant=\"\n\t\t\t\t\t\tdropdown.open && dropdown.activeItemIndex !== null\n\t\t\t\t\t\t\t? `${listboxId}-opt-${dropdown.activeItemIndex}`\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\"\n\t\t\t\t\t@click=\"toggleButtonDropdown\"\n\t\t\t\t\t@keydown.down.prevent=\"selectNextResult\"\n\t\t\t\t\t@keydown.up.prevent=\"selectPrevResult\"\n\t\t\t\t\t@keydown.enter.prevent=\"setCurrentResult\"\n\t\t\t\t\t@keydown.esc=\"onClickOutside\">\n\t\t\t\t\t<span class=\"aform_dropdown-button-value\">{{ search || placeholder || '' }}</span>\n\t\t\t\t\t<span class=\"aform_dropdown-button-caret\" aria-hidden=\"true\"></span>\n\t\t\t\t</button>\n\t\t\t\t<input\n\t\t\t\t\tv-else\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\tv-model=\"search\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\taria-autocomplete=\"list\"\n\t\t\t\t\t:class=\"['aform_input-field', { 'aform_input-field--embedded': embedded }]\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t\t:size=\"embeddedLinkInputSize\"\n\t\t\t\t\t:aria-label=\"ariaLabel\"\n\t\t\t\t\t:style=\"inputAccentStyle\"\n\t\t\t\t\t:aria-expanded=\"dropdown.open\"\n\t\t\t\t\t:aria-controls=\"dropdown.open ? listboxId : undefined\"\n\t\t\t\t\t:aria-activedescendant=\"\n\t\t\t\t\t\tdropdown.activeItemIndex === null ? undefined : `${listboxId}-opt-${dropdown.activeItemIndex}`\n\t\t\t\t\t\"\n\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t@input=\"onComboboxInput\"\n\t\t\t\t\t@focus=\"onComboboxFocus\"\n\t\t\t\t\t@click=\"onEmbeddedComboboxClick\"\n\t\t\t\t\t@pointerdown=\"onEmbeddedComboboxPointerDown\"\n\t\t\t\t\t@keydown.down.prevent=\"selectNextResult\"\n\t\t\t\t\t@keydown.up.prevent=\"selectPrevResult\"\n\t\t\t\t\t@keydown.enter.prevent=\"setCurrentResult\"\n\t\t\t\t\t@keydown.esc=\"onClickOutside\"\n\t\t\t\t\t@keydown.tab=\"onClickOutside\" />\n\n\t\t\t\t<ADropdownList\n\t\t\t\t\t:listbox-id=\"listboxId\"\n\t\t\t\t\t:ariaLabel=\"ariaLabel ?? label ?? ''\"\n\t\t\t\t\t:open=\"dropdown.open\"\n\t\t\t\t\t:list-anchor=\"listAnchor\"\n\t\t\t\t\t:option-count=\"optionCount\"\n\t\t\t\t\t:active-index=\"() => dropdown.activeItemIndex\">\n\t\t\t\t\t<li v-if=\"dropdown.loading\" class=\"loading autocomplete-result\">Loading results...</li>\n\t\t\t\t\t<template v-else-if=\"linkPicker\">\n\t\t\t\t\t\t<li\n\t\t\t\t\t\t\tv-for=\"(option, i) in linkResults\"\n\t\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t:aria-selected=\"isLinkOptionSelected(option)\"\n\t\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'is-active': i === dropdown.activeItemIndex,\n\t\t\t\t\t\t\t\t'is-selected': isLinkOptionSelected(option),\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@mousedown.prevent=\"selectLinkOption(option)\"\n\t\t\t\t\t\t\t@mouseenter=\"dropdown.activeItemIndex = i\">\n\t\t\t\t\t\t\t<slot name=\"option\" :option=\"option\">{{ option.displayText ?? String(option.id) }}</slot>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</template>\n\t\t\t\t\t<template v-else>\n\t\t\t\t\t\t<li\n\t\t\t\t\t\t\tv-for=\"(result, i) in dropdown.results\"\n\t\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t\t:key=\"result\"\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t:aria-selected=\"isChoiceSelected(result)\"\n\t\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'is-active': i === dropdown.activeItemIndex,\n\t\t\t\t\t\t\t\t'is-selected': isChoiceSelected(result),\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@mousedown.prevent=\"setChoiceResult(result)\"\n\t\t\t\t\t\t\t@mouseenter=\"dropdown.activeItemIndex = i\">\n\t\t\t\t\t\t\t{{ result }}\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</template>\n\t\t\t\t</ADropdownList>\n\t\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t</div>\n\t\t\t<p v-if=\"!embedded\" v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { FieldOptions } from '@stonecrop/schema'\nimport { selectChoices } from '@stonecrop/schema'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, inject, reactive, ref, useId, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { AFormLinkModelValue, AFormLinkValue, ComponentProps } from '../../types'\nimport type { BadgeFormatFn } from '../../utils/badge'\nimport { badgeInputAccentStyle, resolveFieldBadge } from '../../utils/badge'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { asLinkValue, linkDisplayText, linkId } from '../../utils/linkValue'\nimport ADropdownList from './ADropdownList.vue'\n\nconst {\n\tlabel,\n\trequired,\n\toptions = [],\n\tformat,\n\tisAsync = false,\n\tfilterFunction = undefined,\n\tlink = false,\n\tlinkFilterFunction = undefined,\n\tformatter = undefined,\n\tdoctype = undefined,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tembedded = false,\n\ttrigger = 'combobox',\n\tlistAnchor = 'field',\n\tplaceholder = undefined,\n\tariaLabel = undefined,\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: FieldOptions\n\t\tformat?: string\n\t\tisAsync?: boolean\n\t\tfilterFunction?: (search: string) => string[] | Promise<string[]>\n\t\t/** Picks a linked record, bound through `v-model:link-value` as an `AFormLinkValue` (embedded currency, etc.). */\n\t\tlink?: boolean\n\t\t/** Searches the records a `link` picker lists. */\n\t\tlinkFilterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>)\n\t\tformatter?: (value: AFormLinkValue) => string\n\t\tdoctype?: string\n\t\tembedded?: boolean\n\t\ttrigger?: 'combobox' | 'button'\n\t\tlistAnchor?: 'field' | 'group'\n\t\tplaceholder?: string\n\t\tariaLabel?: string\n\t}\n>()\n\nconst emit = defineEmits<{\n\t'update:open': [open: boolean]\n}>()\n\nconst linkPicker = computed(() => link)\n\n// The list's own id: `uuid` is already the box's, and `aria-controls` must name the list.\nconst listboxId = `${uuid ?? `aform-dropdown-${useId()}`}-listbox`\n\nconst choiceList = computed(() => selectChoices(options))\n\nconst formatFn = computed(() => (format ? deserializeFunction<BadgeFormatFn>(format) : undefined))\n\nconst badgeDescriptor = computed(() =>\n\tlinkPicker.value ? null : resolveFieldBadge(search.value, options, formatFn.value)\n)\n\nconst inputAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? undefined))\n\nconst displayAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? undefined))\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst modelValue = defineModel<string>()\nconst linkModel = defineModel<AFormLinkModelValue>('linkValue')\n\ntype FilterFn = (search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\n\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\nconst dropdown = reactive({\n\tactiveItemIndex: null as number | null,\n\topen: false,\n\tloading: false,\n\tresults: [] as string[],\n})\n\nwatch(\n\t() => dropdown.open,\n\topen => emit('update:open', open)\n)\n\nconst linkResults = ref<AFormLinkValue[]>([])\n\nconst optionCount = () => (linkPicker.value ? linkResults.value.length : dropdown.results.length)\n\nconst committedValue = ref(modelValue.value ?? '')\n\n// The text a picked record shows: the formatter's, or else its name, or else its id.\nconst linkText = (value: AFormLinkModelValue | undefined) => {\n\tconst record = asLinkValue(value)\n\treturn formatter ? formatter(record) : (linkDisplayText(record) ?? String(record.id))\n}\n\n// The record a link names, as last seen with its text: the value itself, a pick, or the picker's own\n// lookup. Kept here and never written into the record: a lookup is not a pick, and Save's reply hands\n// the id back bare.\nconst knownLink = ref<AFormLinkValue>()\n\nwatch(\n\t() => linkModel.value,\n\tvalue => {\n\t\tif (linkPicker.value && linkDisplayText(value)) knownLink.value = asLinkValue(value)\n\t},\n\t{ immediate: true }\n)\n\nconst shownLink = computed<AFormLinkModelValue | undefined>(() => {\n\tconst value = linkModel.value\n\tif (linkDisplayText(value)) return value\n\tconst id = linkId(value)\n\tconst known = knownLink.value\n\treturn known && id !== undefined && String(known.id) === String(id) ? known : value\n})\n\nconst linkDisplayedText = computed(() => (linkId(shownLink.value) === undefined ? '—' : linkText(shownLink.value)))\n\nconst search = ref('')\n\nwatch(\n\tmodelValue,\n\tvalue => {\n\t\tif (linkPicker.value) return\n\t\tconst next = value ?? ''\n\t\tsearch.value = next\n\t\tif (next === '' || choiceList.value.includes(next)) committedValue.value = next\n\t},\n\t{ immediate: true }\n)\n\nwatch(\n\tshownLink,\n\tvalue => {\n\t\tif (!linkPicker.value) return\n\t\tsearch.value = linkId(value) ? linkText(value) : ''\n\t},\n\t{ immediate: true }\n)\n\nwatch(\n\t() => (linkPicker.value && !linkDisplayText(shownLink.value) ? linkId(linkModel.value) : undefined),\n\tasync id => {\n\t\tif (!linkPicker.value || !id) return\n\t\ttry {\n\t\t\tlet match: AFormLinkValue | undefined\n\t\t\tlet displayText: string | undefined\n\t\t\tif (linkFilterFunction) {\n\t\t\t\tconst fn: FilterFn =\n\t\t\t\t\ttypeof linkFilterFunction === 'string'\n\t\t\t\t\t\t? deserializeFunction<FilterFn>(linkFilterFunction)\n\t\t\t\t\t\t: linkFilterFunction\n\t\t\t\tconst results = await fn(String(id))\n\t\t\t\tmatch = results.find(r => String(r.id) === String(id))\n\t\t\t\tdisplayText = match?.displayText\n\t\t\t} else if (resolver && doctype) {\n\t\t\t\tdisplayText = (await resolver(doctype, id.toString())) ?? undefined\n\t\t\t}\n\t\t\tif (displayText) knownLink.value = { ...asLinkValue(linkModel.value), ...match, id, displayText }\n\t\t} catch {\n\t\t\t// fall back to raw id in the input\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst onClickOutside = () => closeDropdown()\n\nconst isChoiceSelected = (result: string) => !!result && result === (modelValue.value ?? '')\n\nconst isLinkOptionSelected = (option: AFormLinkValue) => {\n\tconst id = linkId(linkModel.value)\n\treturn id !== undefined && String(option.id) === String(id)\n}\n\nconst embeddedLinkDisplayText = computed(() =>\n\tlinkId(shownLink.value) ? linkText(shownLink.value) : (placeholder ?? '')\n)\n\nconst embeddedLinkInputSize = computed(() => {\n\tif (!embedded || !linkPicker.value) return undefined\n\tconst text = embeddedLinkDisplayText.value\n\tconst length = text.length > 0 ? text.length : (placeholder ?? '').length\n\treturn length > 0 ? length : undefined\n})\n\nconst filterResults = () => {\n\tif (!search.value) {\n\t\tdropdown.results = choiceList.value\n\t} else {\n\t\tdropdown.results = choiceList.value.filter(item => item.toLowerCase().includes(search.value.toLowerCase()))\n\t}\n}\n\nconst openLinkDropdown = async (text: string) => {\n\tif (!linkFilterFunction || mode === 'read') return\n\tdropdown.activeItemIndex = null\n\tdropdown.open = true\n\tif (isAsync) dropdown.loading = true\n\ttry {\n\t\tconst fn: FilterFn =\n\t\t\ttypeof linkFilterFunction === 'string' ? deserializeFunction<FilterFn>(linkFilterFunction) : linkFilterFunction\n\t\tlinkResults.value = (await fn(text)) ?? []\n\t} catch {\n\t\tlinkResults.value = []\n\t} finally {\n\t\tdropdown.loading = false\n\t}\n}\n\nconst embeddedLinkFilterQuery = (): string => {\n\tif (!embedded || !linkPicker.value) return search.value\n\tconst id = linkId(shownLink.value)\n\tif (id && formatter) {\n\t\tconst formatted = formatter(asLinkValue(shownLink.value))\n\t\tif (search.value === formatted) return ''\n\t}\n\treturn search.value\n}\n\n// One click fires pointerdown, focus and click here, and the price field's own click: only the first looks the list up.\nconst openEmbeddedList = () => {\n\tif (linkPicker.value && !dropdown.open) openLinkDropdown(embeddedLinkFilterQuery())\n}\n\ndefineExpose({ openCurrencyList: openEmbeddedList })\n\nconst filter = async () => {\n\tdropdown.open = true\n\tdropdown.activeItemIndex = null\n\tif (filterFunction) {\n\t\tif (isAsync) dropdown.loading = true\n\t\ttry {\n\t\t\tconst filteredResults = await filterFunction(search.value || '')\n\t\t\tdropdown.results = filteredResults || []\n\t\t} catch {\n\t\t\tdropdown.results = []\n\t\t} finally {\n\t\t\tif (isAsync) dropdown.loading = false\n\t\t}\n\t} else {\n\t\tfilterResults()\n\t}\n}\n\nconst setChoiceResult = (result: string) => {\n\tmodelValue.value = result\n\tsearch.value = result\n\tcommittedValue.value = result\n\tcloseDropdown(result)\n}\n\nconst selectLinkOption = (option: AFormLinkValue) => {\n\tlinkModel.value = option\n\tsearch.value = linkText(option)\n\tdropdown.open = false\n\tdropdown.activeItemIndex = null\n}\n\nconst openChoiceDropdown = () => {\n\tconst idx = choiceList.value.indexOf(search.value)\n\tdropdown.activeItemIndex = isAsync ? null : idx >= 0 ? idx : null\n\tdropdown.open = true\n\tdropdown.results = isAsync ? [] : choiceList.value\n}\n\nconst closeDropdown = (result?: string) => {\n\tdropdown.activeItemIndex = null\n\tdropdown.open = false\n\tif (linkPicker.value) {\n\t\tsearch.value = linkId(shownLink.value) ? linkText(shownLink.value) : ''\n\t\treturn\n\t}\n\tconst typed = result || search.value || ''\n\tif (choiceList.value.includes(typed)) {\n\t\t// A choice typed out in full is picked, as if from the list. A pick from the list has already been sent.\n\t\tif (typed !== committedValue.value) {\n\t\t\tmodelValue.value = typed\n\t\t\tcommittedValue.value = typed\n\t\t}\n\t} else {\n\t\tsearch.value = committedValue.value\n\t\tmodelValue.value = committedValue.value\n\t}\n}\n\nconst toggleButtonDropdown = () => {\n\tif (dropdown.open) closeDropdown()\n\telse openChoiceDropdown()\n}\n\nconst onComboboxInput = () => {\n\tif (linkPicker.value) openLinkDropdown(embedded ? embeddedLinkFilterQuery() : search.value)\n\telse {\n\t\t// Typing searches the choices; the record changes only when one is picked, or when the box is cleared.\n\t\tif (search.value === '') {\n\t\t\tmodelValue.value = ''\n\t\t\tcommittedValue.value = ''\n\t\t}\n\t\tfilter()\n\t}\n}\n\nconst onComboboxFocus = (event: FocusEvent) => {\n\tif (linkPicker.value && embedded) {\n\t\topenEmbeddedList()\n\t\tconst input = event.target as HTMLInputElement | null\n\t\tif (input) requestAnimationFrame(() => input.select())\n\t\treturn\n\t}\n\tif (linkPicker.value) openLinkDropdown(search.value)\n\telse openChoiceDropdown()\n}\n\nconst onEmbeddedComboboxClick = () => {\n\tif (embedded && linkPicker.value) openEmbeddedList()\n}\n\nconst onEmbeddedComboboxPointerDown = () => {\n\tif (embedded && linkPicker.value) openEmbeddedList()\n}\n\nwatch(\n\tchoiceList,\n\tchoices => {\n\t\tif (!linkPicker.value) dropdown.results = choices\n\t},\n\t{ immediate: true }\n)\n\nconst ensureDropdownOpen = () => {\n\tif (dropdown.open) return\n\tif (linkPicker.value) {\n\t\tif (embedded) openEmbeddedList()\n\t\telse void openLinkDropdown(search.value)\n\t} else {\n\t\topenChoiceDropdown()\n\t}\n}\n\nconst selectNextResult = () => {\n\tconst resultsLength = optionCount()\n\tif (!resultsLength) return\n\tconst wasOpen = dropdown.open\n\tensureDropdownOpen()\n\tif (!wasOpen) {\n\t\t// Opening already highlights the current choice; with none, the first is.\n\t\tif (dropdown.activeItemIndex === null && !isAsync) dropdown.activeItemIndex = 0\n\t\treturn\n\t}\n\tif (dropdown.activeItemIndex != null) {\n\t\tdropdown.activeItemIndex = (dropdown.activeItemIndex + 1) % resultsLength\n\t} else {\n\t\tdropdown.activeItemIndex = 0\n\t}\n}\n\nconst selectPrevResult = () => {\n\tconst resultsLength = optionCount()\n\tif (!resultsLength) return\n\tensureDropdownOpen()\n\tif (dropdown.activeItemIndex != null) {\n\t\tif (dropdown.activeItemIndex === 0) {\n\t\t\tdropdown.activeItemIndex = trigger === 'button' ? resultsLength - 1 : null\n\t\t} else {\n\t\t\tdropdown.activeItemIndex = dropdown.activeItemIndex - 1\n\t\t}\n\t} else {\n\t\tdropdown.activeItemIndex = resultsLength - 1\n\t}\n}\n\nconst setCurrentResult = () => {\n\tif (!dropdown.open) {\n\t\tensureDropdownOpen()\n\t\treturn\n\t}\n\tif (linkPicker.value) {\n\t\tif (dropdown.activeItemIndex !== null && linkResults.value[dropdown.activeItemIndex]) {\n\t\t\tselectLinkOption(linkResults.value[dropdown.activeItemIndex])\n\t\t}\n\t\treturn\n\t}\n\tconst result = dropdown.results[dropdown.activeItemIndex ?? 0]\n\tif (result !== undefined) setChoiceResult(result)\n}\n</script>\n\n<style scoped>\n.autocomplete {\n\tposition: relative;\n}\n\n.aform_form-element--embedded {\n\tmin-width: 0;\n\tflex: 1 1 auto;\n\twidth: 100%;\n\tpadding-top: 0;\n}\n\n.aform_form-element--embedded .autocomplete {\n\tdisplay: flex;\n\tflex: 1;\n\tmin-width: 0;\n\tmin-height: 0;\n\twidth: 100%;\n}\n\n.aform_dropdown--anchor-group .autocomplete {\n\tposition: static;\n}\n\n.aform_input-field--embedded {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0.5rem 1ch;\n}\n\n.aform_dropdown-button {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 0.75ch;\n\tflex: 1;\n\talign-self: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: 100%;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\tbackground: var(--sc-input-addon-background);\n\tborder: none;\n\toutline: none;\n\tborder-radius: 0 var(--sc-border-radius) var(--sc-border-radius) 0;\n\twhite-space: nowrap;\n\tcursor: pointer;\n\t-webkit-tap-highlight-color: transparent;\n}\n\n.aform_dropdown-button:focus,\n.aform_dropdown-button:focus-visible {\n\toutline: none;\n\tbox-shadow: none;\n}\n\n.aform_dropdown-button::-moz-focus-inner {\n\tborder: 0;\n\tpadding: 0;\n}\n\n/* Merged fields (quantity UOM): same surface as the sibling input, not a nested addon chip. */\n.aform_form-element--embedded .aform_dropdown-button {\n\tbackground: transparent;\n}\n\n.aform_dropdown-button:disabled {\n\tcursor: not-allowed;\n\tcolor: var(--sc-gray-50);\n}\n\n.aform_dropdown-button-value {\n\tflex: 1;\n\tmin-width: 0;\n\ttext-align: left;\n}\n\n.aform_dropdown-button-caret {\n\tdisplay: inline-block;\n\twidth: 0;\n\theight: 0;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tborder-top: 0.3em solid currentColor;\n}\n</style>\n","<template>\n\t<div\n\t\t:class=\"[\n\t\t\t'aform_form-element',\n\t\t\t{ 'aform_form-element--embedded': embedded, 'aform_dropdown--anchor-group': listAnchor === 'group' },\n\t\t]\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span v-if=\"!linkPicker && badgeDescriptor\" class=\"aform_display-value\" :style=\"displayAccentStyle\">{{\n\t\t\t\tbadgeDescriptor.label\n\t\t\t}}</span>\n\t\t\t<span v-else-if=\"!linkPicker\" class=\"aform_display-value\">{{ search }}</span>\n\t\t\t<span v-else class=\"aform_display-value\">{{ linkDisplayedText }}</span>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div v-on-click-outside=\"onClickOutside\" class=\"autocomplete\" :class=\"{ isOpen: dropdown.open }\">\n\t\t\t\t<button\n\t\t\t\t\tv-if=\"trigger === 'button'\"\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclass=\"aform_dropdown-button\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:aria-label=\"ariaLabel ?? label\"\n\t\t\t\t\taria-haspopup=\"listbox\"\n\t\t\t\t\t:aria-expanded=\"dropdown.open\"\n\t\t\t\t\t:aria-controls=\"dropdown.open ? listboxId : undefined\"\n\t\t\t\t\t:aria-activedescendant=\"\n\t\t\t\t\t\tdropdown.open && dropdown.activeItemIndex !== null\n\t\t\t\t\t\t\t? `${listboxId}-opt-${dropdown.activeItemIndex}`\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\"\n\t\t\t\t\t@click=\"toggleButtonDropdown\"\n\t\t\t\t\t@keydown.down.prevent=\"selectNextResult\"\n\t\t\t\t\t@keydown.up.prevent=\"selectPrevResult\"\n\t\t\t\t\t@keydown.enter.prevent=\"setCurrentResult\"\n\t\t\t\t\t@keydown.esc=\"onClickOutside\">\n\t\t\t\t\t<span class=\"aform_dropdown-button-value\">{{ search || placeholder || '' }}</span>\n\t\t\t\t\t<span class=\"aform_dropdown-button-caret\" aria-hidden=\"true\"></span>\n\t\t\t\t</button>\n\t\t\t\t<input\n\t\t\t\t\tv-else\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\tv-model=\"search\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\taria-autocomplete=\"list\"\n\t\t\t\t\t:class=\"['aform_input-field', { 'aform_input-field--embedded': embedded }]\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t\t:size=\"embeddedLinkInputSize\"\n\t\t\t\t\t:aria-label=\"ariaLabel\"\n\t\t\t\t\t:style=\"inputAccentStyle\"\n\t\t\t\t\t:aria-expanded=\"dropdown.open\"\n\t\t\t\t\t:aria-controls=\"dropdown.open ? listboxId : undefined\"\n\t\t\t\t\t:aria-activedescendant=\"\n\t\t\t\t\t\tdropdown.activeItemIndex === null ? undefined : `${listboxId}-opt-${dropdown.activeItemIndex}`\n\t\t\t\t\t\"\n\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t@input=\"onComboboxInput\"\n\t\t\t\t\t@focus=\"onComboboxFocus\"\n\t\t\t\t\t@click=\"onEmbeddedComboboxClick\"\n\t\t\t\t\t@pointerdown=\"onEmbeddedComboboxPointerDown\"\n\t\t\t\t\t@keydown.down.prevent=\"selectNextResult\"\n\t\t\t\t\t@keydown.up.prevent=\"selectPrevResult\"\n\t\t\t\t\t@keydown.enter.prevent=\"setCurrentResult\"\n\t\t\t\t\t@keydown.esc=\"onClickOutside\"\n\t\t\t\t\t@keydown.tab=\"onClickOutside\" />\n\n\t\t\t\t<ADropdownList\n\t\t\t\t\t:listbox-id=\"listboxId\"\n\t\t\t\t\t:ariaLabel=\"ariaLabel ?? label ?? ''\"\n\t\t\t\t\t:open=\"dropdown.open\"\n\t\t\t\t\t:list-anchor=\"listAnchor\"\n\t\t\t\t\t:option-count=\"optionCount\"\n\t\t\t\t\t:active-index=\"() => dropdown.activeItemIndex\">\n\t\t\t\t\t<li v-if=\"dropdown.loading\" class=\"loading autocomplete-result\">Loading results...</li>\n\t\t\t\t\t<template v-else-if=\"linkPicker\">\n\t\t\t\t\t\t<li\n\t\t\t\t\t\t\tv-for=\"(option, i) in linkResults\"\n\t\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t:aria-selected=\"isLinkOptionSelected(option)\"\n\t\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'is-active': i === dropdown.activeItemIndex,\n\t\t\t\t\t\t\t\t'is-selected': isLinkOptionSelected(option),\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@mousedown.prevent=\"selectLinkOption(option)\"\n\t\t\t\t\t\t\t@mouseenter=\"dropdown.activeItemIndex = i\">\n\t\t\t\t\t\t\t<slot name=\"option\" :option=\"option\">{{ option.displayText ?? String(option.id) }}</slot>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</template>\n\t\t\t\t\t<template v-else>\n\t\t\t\t\t\t<li\n\t\t\t\t\t\t\tv-for=\"(result, i) in dropdown.results\"\n\t\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t\t:key=\"result\"\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t:aria-selected=\"isChoiceSelected(result)\"\n\t\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'is-active': i === dropdown.activeItemIndex,\n\t\t\t\t\t\t\t\t'is-selected': isChoiceSelected(result),\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@mousedown.prevent=\"setChoiceResult(result)\"\n\t\t\t\t\t\t\t@mouseenter=\"dropdown.activeItemIndex = i\">\n\t\t\t\t\t\t\t{{ result }}\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</template>\n\t\t\t\t</ADropdownList>\n\t\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t</div>\n\t\t\t<p v-if=\"!embedded\" v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { FieldOptions } from '@stonecrop/schema'\nimport { selectChoices } from '@stonecrop/schema'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, inject, reactive, ref, useId, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { AFormLinkModelValue, AFormLinkValue, ComponentProps } from '../../types'\nimport type { BadgeFormatFn } from '../../utils/badge'\nimport { badgeInputAccentStyle, resolveFieldBadge } from '../../utils/badge'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { asLinkValue, linkDisplayText, linkId } from '../../utils/linkValue'\nimport ADropdownList from './ADropdownList.vue'\n\nconst {\n\tlabel,\n\trequired,\n\toptions = [],\n\tformat,\n\tisAsync = false,\n\tfilterFunction = undefined,\n\tlink = false,\n\tlinkFilterFunction = undefined,\n\tformatter = undefined,\n\tdoctype = undefined,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tembedded = false,\n\ttrigger = 'combobox',\n\tlistAnchor = 'field',\n\tplaceholder = undefined,\n\tariaLabel = undefined,\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: FieldOptions\n\t\tformat?: string\n\t\tisAsync?: boolean\n\t\tfilterFunction?: (search: string) => string[] | Promise<string[]>\n\t\t/** Picks a linked record, bound through `v-model:link-value` as an `AFormLinkValue` (embedded currency, etc.). */\n\t\tlink?: boolean\n\t\t/** Searches the records a `link` picker lists. */\n\t\tlinkFilterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>)\n\t\tformatter?: (value: AFormLinkValue) => string\n\t\tdoctype?: string\n\t\tembedded?: boolean\n\t\ttrigger?: 'combobox' | 'button'\n\t\tlistAnchor?: 'field' | 'group'\n\t\tplaceholder?: string\n\t\tariaLabel?: string\n\t}\n>()\n\nconst emit = defineEmits<{\n\t'update:open': [open: boolean]\n}>()\n\nconst linkPicker = computed(() => link)\n\n// The list's own id: `uuid` is already the box's, and `aria-controls` must name the list.\nconst listboxId = `${uuid ?? `aform-dropdown-${useId()}`}-listbox`\n\nconst choiceList = computed(() => selectChoices(options))\n\nconst formatFn = computed(() => (format ? deserializeFunction<BadgeFormatFn>(format) : undefined))\n\nconst badgeDescriptor = computed(() =>\n\tlinkPicker.value ? null : resolveFieldBadge(search.value, options, formatFn.value)\n)\n\nconst inputAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? undefined))\n\nconst displayAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? undefined))\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst modelValue = defineModel<string>()\nconst linkModel = defineModel<AFormLinkModelValue>('linkValue')\n\ntype FilterFn = (search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\n\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\nconst dropdown = reactive({\n\tactiveItemIndex: null as number | null,\n\topen: false,\n\tloading: false,\n\tresults: [] as string[],\n})\n\nwatch(\n\t() => dropdown.open,\n\topen => emit('update:open', open)\n)\n\nconst linkResults = ref<AFormLinkValue[]>([])\n\nconst optionCount = () => (linkPicker.value ? linkResults.value.length : dropdown.results.length)\n\nconst committedValue = ref(modelValue.value ?? '')\n\n// The text a picked record shows: the formatter's, or else its name, or else its id.\nconst linkText = (value: AFormLinkModelValue | undefined) => {\n\tconst record = asLinkValue(value)\n\treturn formatter ? formatter(record) : (linkDisplayText(record) ?? String(record.id))\n}\n\n// The record a link names, as last seen with its text: the value itself, a pick, or the picker's own\n// lookup. Kept here and never written into the record: a lookup is not a pick, and Save's reply hands\n// the id back bare.\nconst knownLink = ref<AFormLinkValue>()\n\nwatch(\n\t() => linkModel.value,\n\tvalue => {\n\t\tif (linkPicker.value && linkDisplayText(value)) knownLink.value = asLinkValue(value)\n\t},\n\t{ immediate: true }\n)\n\nconst shownLink = computed<AFormLinkModelValue | undefined>(() => {\n\tconst value = linkModel.value\n\tif (linkDisplayText(value)) return value\n\tconst id = linkId(value)\n\tconst known = knownLink.value\n\treturn known && id !== undefined && String(known.id) === String(id) ? known : value\n})\n\nconst linkDisplayedText = computed(() => (linkId(shownLink.value) === undefined ? '—' : linkText(shownLink.value)))\n\nconst search = ref('')\n\nwatch(\n\tmodelValue,\n\tvalue => {\n\t\tif (linkPicker.value) return\n\t\tconst next = value ?? ''\n\t\tsearch.value = next\n\t\tif (next === '' || choiceList.value.includes(next)) committedValue.value = next\n\t},\n\t{ immediate: true }\n)\n\nwatch(\n\tshownLink,\n\tvalue => {\n\t\tif (!linkPicker.value) return\n\t\tsearch.value = linkId(value) ? linkText(value) : ''\n\t},\n\t{ immediate: true }\n)\n\nwatch(\n\t() => (linkPicker.value && !linkDisplayText(shownLink.value) ? linkId(linkModel.value) : undefined),\n\tasync id => {\n\t\tif (!linkPicker.value || !id) return\n\t\ttry {\n\t\t\tlet match: AFormLinkValue | undefined\n\t\t\tlet displayText: string | undefined\n\t\t\tif (linkFilterFunction) {\n\t\t\t\tconst fn: FilterFn =\n\t\t\t\t\ttypeof linkFilterFunction === 'string'\n\t\t\t\t\t\t? deserializeFunction<FilterFn>(linkFilterFunction)\n\t\t\t\t\t\t: linkFilterFunction\n\t\t\t\tconst results = await fn(String(id))\n\t\t\t\tmatch = results.find(r => String(r.id) === String(id))\n\t\t\t\tdisplayText = match?.displayText\n\t\t\t} else if (resolver && doctype) {\n\t\t\t\tdisplayText = (await resolver(doctype, id.toString())) ?? undefined\n\t\t\t}\n\t\t\tif (displayText) knownLink.value = { ...asLinkValue(linkModel.value), ...match, id, displayText }\n\t\t} catch {\n\t\t\t// fall back to raw id in the input\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst onClickOutside = () => closeDropdown()\n\nconst isChoiceSelected = (result: string) => !!result && result === (modelValue.value ?? '')\n\nconst isLinkOptionSelected = (option: AFormLinkValue) => {\n\tconst id = linkId(linkModel.value)\n\treturn id !== undefined && String(option.id) === String(id)\n}\n\nconst embeddedLinkDisplayText = computed(() =>\n\tlinkId(shownLink.value) ? linkText(shownLink.value) : (placeholder ?? '')\n)\n\nconst embeddedLinkInputSize = computed(() => {\n\tif (!embedded || !linkPicker.value) return undefined\n\tconst text = embeddedLinkDisplayText.value\n\tconst length = text.length > 0 ? text.length : (placeholder ?? '').length\n\treturn length > 0 ? length : undefined\n})\n\nconst filterResults = () => {\n\tif (!search.value) {\n\t\tdropdown.results = choiceList.value\n\t} else {\n\t\tdropdown.results = choiceList.value.filter(item => item.toLowerCase().includes(search.value.toLowerCase()))\n\t}\n}\n\nconst openLinkDropdown = async (text: string) => {\n\tif (!linkFilterFunction || mode === 'read') return\n\tdropdown.activeItemIndex = null\n\tdropdown.open = true\n\tif (isAsync) dropdown.loading = true\n\ttry {\n\t\tconst fn: FilterFn =\n\t\t\ttypeof linkFilterFunction === 'string' ? deserializeFunction<FilterFn>(linkFilterFunction) : linkFilterFunction\n\t\tlinkResults.value = (await fn(text)) ?? []\n\t} catch {\n\t\tlinkResults.value = []\n\t} finally {\n\t\tdropdown.loading = false\n\t}\n}\n\nconst embeddedLinkFilterQuery = (): string => {\n\tif (!embedded || !linkPicker.value) return search.value\n\tconst id = linkId(shownLink.value)\n\tif (id && formatter) {\n\t\tconst formatted = formatter(asLinkValue(shownLink.value))\n\t\tif (search.value === formatted) return ''\n\t}\n\treturn search.value\n}\n\n// One click fires pointerdown, focus and click here, and the price field's own click: only the first looks the list up.\nconst openEmbeddedList = () => {\n\tif (linkPicker.value && !dropdown.open) openLinkDropdown(embeddedLinkFilterQuery())\n}\n\ndefineExpose({ openCurrencyList: openEmbeddedList })\n\nconst filter = async () => {\n\tdropdown.open = true\n\tdropdown.activeItemIndex = null\n\tif (filterFunction) {\n\t\tif (isAsync) dropdown.loading = true\n\t\ttry {\n\t\t\tconst filteredResults = await filterFunction(search.value || '')\n\t\t\tdropdown.results = filteredResults || []\n\t\t} catch {\n\t\t\tdropdown.results = []\n\t\t} finally {\n\t\t\tif (isAsync) dropdown.loading = false\n\t\t}\n\t} else {\n\t\tfilterResults()\n\t}\n}\n\nconst setChoiceResult = (result: string) => {\n\tmodelValue.value = result\n\tsearch.value = result\n\tcommittedValue.value = result\n\tcloseDropdown(result)\n}\n\nconst selectLinkOption = (option: AFormLinkValue) => {\n\tlinkModel.value = option\n\tsearch.value = linkText(option)\n\tdropdown.open = false\n\tdropdown.activeItemIndex = null\n}\n\nconst openChoiceDropdown = () => {\n\tconst idx = choiceList.value.indexOf(search.value)\n\tdropdown.activeItemIndex = isAsync ? null : idx >= 0 ? idx : null\n\tdropdown.open = true\n\tdropdown.results = isAsync ? [] : choiceList.value\n}\n\nconst closeDropdown = (result?: string) => {\n\tdropdown.activeItemIndex = null\n\tdropdown.open = false\n\tif (linkPicker.value) {\n\t\tsearch.value = linkId(shownLink.value) ? linkText(shownLink.value) : ''\n\t\treturn\n\t}\n\tconst typed = result || search.value || ''\n\tif (choiceList.value.includes(typed)) {\n\t\t// A choice typed out in full is picked, as if from the list. A pick from the list has already been sent.\n\t\tif (typed !== committedValue.value) {\n\t\t\tmodelValue.value = typed\n\t\t\tcommittedValue.value = typed\n\t\t}\n\t} else {\n\t\tsearch.value = committedValue.value\n\t\tmodelValue.value = committedValue.value\n\t}\n}\n\nconst toggleButtonDropdown = () => {\n\tif (dropdown.open) closeDropdown()\n\telse openChoiceDropdown()\n}\n\nconst onComboboxInput = () => {\n\tif (linkPicker.value) openLinkDropdown(embedded ? embeddedLinkFilterQuery() : search.value)\n\telse {\n\t\t// Typing searches the choices; the record changes only when one is picked, or when the box is cleared.\n\t\tif (search.value === '') {\n\t\t\tmodelValue.value = ''\n\t\t\tcommittedValue.value = ''\n\t\t}\n\t\tfilter()\n\t}\n}\n\nconst onComboboxFocus = (event: FocusEvent) => {\n\tif (linkPicker.value && embedded) {\n\t\topenEmbeddedList()\n\t\tconst input = event.target as HTMLInputElement | null\n\t\tif (input) requestAnimationFrame(() => input.select())\n\t\treturn\n\t}\n\tif (linkPicker.value) openLinkDropdown(search.value)\n\telse openChoiceDropdown()\n}\n\nconst onEmbeddedComboboxClick = () => {\n\tif (embedded && linkPicker.value) openEmbeddedList()\n}\n\nconst onEmbeddedComboboxPointerDown = () => {\n\tif (embedded && linkPicker.value) openEmbeddedList()\n}\n\nwatch(\n\tchoiceList,\n\tchoices => {\n\t\tif (!linkPicker.value) dropdown.results = choices\n\t},\n\t{ immediate: true }\n)\n\nconst ensureDropdownOpen = () => {\n\tif (dropdown.open) return\n\tif (linkPicker.value) {\n\t\tif (embedded) openEmbeddedList()\n\t\telse void openLinkDropdown(search.value)\n\t} else {\n\t\topenChoiceDropdown()\n\t}\n}\n\nconst selectNextResult = () => {\n\tconst resultsLength = optionCount()\n\tif (!resultsLength) return\n\tconst wasOpen = dropdown.open\n\tensureDropdownOpen()\n\tif (!wasOpen) {\n\t\t// Opening already highlights the current choice; with none, the first is.\n\t\tif (dropdown.activeItemIndex === null && !isAsync) dropdown.activeItemIndex = 0\n\t\treturn\n\t}\n\tif (dropdown.activeItemIndex != null) {\n\t\tdropdown.activeItemIndex = (dropdown.activeItemIndex + 1) % resultsLength\n\t} else {\n\t\tdropdown.activeItemIndex = 0\n\t}\n}\n\nconst selectPrevResult = () => {\n\tconst resultsLength = optionCount()\n\tif (!resultsLength) return\n\tensureDropdownOpen()\n\tif (dropdown.activeItemIndex != null) {\n\t\tif (dropdown.activeItemIndex === 0) {\n\t\t\tdropdown.activeItemIndex = trigger === 'button' ? resultsLength - 1 : null\n\t\t} else {\n\t\t\tdropdown.activeItemIndex = dropdown.activeItemIndex - 1\n\t\t}\n\t} else {\n\t\tdropdown.activeItemIndex = resultsLength - 1\n\t}\n}\n\nconst setCurrentResult = () => {\n\tif (!dropdown.open) {\n\t\tensureDropdownOpen()\n\t\treturn\n\t}\n\tif (linkPicker.value) {\n\t\tif (dropdown.activeItemIndex !== null && linkResults.value[dropdown.activeItemIndex]) {\n\t\t\tselectLinkOption(linkResults.value[dropdown.activeItemIndex])\n\t\t}\n\t\treturn\n\t}\n\tconst result = dropdown.results[dropdown.activeItemIndex ?? 0]\n\tif (result !== undefined) setChoiceResult(result)\n}\n</script>\n\n<style scoped>\n.autocomplete {\n\tposition: relative;\n}\n\n.aform_form-element--embedded {\n\tmin-width: 0;\n\tflex: 1 1 auto;\n\twidth: 100%;\n\tpadding-top: 0;\n}\n\n.aform_form-element--embedded .autocomplete {\n\tdisplay: flex;\n\tflex: 1;\n\tmin-width: 0;\n\tmin-height: 0;\n\twidth: 100%;\n}\n\n.aform_dropdown--anchor-group .autocomplete {\n\tposition: static;\n}\n\n.aform_input-field--embedded {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0.5rem 1ch;\n}\n\n.aform_dropdown-button {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 0.75ch;\n\tflex: 1;\n\talign-self: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: 100%;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\tbackground: var(--sc-input-addon-background);\n\tborder: none;\n\toutline: none;\n\tborder-radius: 0 var(--sc-border-radius) var(--sc-border-radius) 0;\n\twhite-space: nowrap;\n\tcursor: pointer;\n\t-webkit-tap-highlight-color: transparent;\n}\n\n.aform_dropdown-button:focus,\n.aform_dropdown-button:focus-visible {\n\toutline: none;\n\tbox-shadow: none;\n}\n\n.aform_dropdown-button::-moz-focus-inner {\n\tborder: 0;\n\tpadding: 0;\n}\n\n/* Merged fields (quantity UOM): same surface as the sibling input, not a nested addon chip. */\n.aform_form-element--embedded .aform_dropdown-button {\n\tbackground: transparent;\n}\n\n.aform_dropdown-button:disabled {\n\tcursor: not-allowed;\n\tcolor: var(--sc-gray-50);\n}\n\n.aform_dropdown-button-value {\n\tflex: 1;\n\tmin-width: 0;\n\ttext-align: left;\n}\n\n.aform_dropdown-button-caret {\n\tdisplay: inline-block;\n\twidth: 0;\n\theight: 0;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tborder-top: 0.3em solid currentColor;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element acurrency\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayText }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div class=\"acurrency__row\">\n\t\t\t\t<div class=\"acurrency__field acurrency__field--amount\">\n\t\t\t\t\t<div class=\"acurrency__group\">\n\t\t\t\t\t\t<div class=\"acurrency__currency\" @click=\"focusCurrencyPicker\">\n\t\t\t\t\t\t\t<ADropdown\n\t\t\t\t\t\t\t\tref=\"currencyDropdownRef\"\n\t\t\t\t\t\t\t\tv-model:link-value=\"currency\"\n\t\t\t\t\t\t\t\tlink\n\t\t\t\t\t\t\t\tembedded\n\t\t\t\t\t\t\t\tlist-anchor=\"group\"\n\t\t\t\t\t\t\t\t:mode=\"mode\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:placeholder=\"currencyLabel\"\n\t\t\t\t\t\t\t\t:aria-label=\"currencyLabel\"\n\t\t\t\t\t\t\t\t:formatter=\"formatCurrencySymbol\"\n\t\t\t\t\t\t\t\t:doctype=\"options.doctype\"\n\t\t\t\t\t\t\t\t:link-filter-function=\"options.filterFunction\"\n\t\t\t\t\t\t\t\t:is-async=\"options.isAsync\">\n\t\t\t\t\t\t\t\t<template #option=\"{ option }\"\n\t\t\t\t\t\t\t\t\t>{{ option.symbol ? `${option.symbol} — ` : '' }}{{ option.displayText ?? option.id }}</template\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t</ADropdown>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"acurrency__amount-wrap\">\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tv-if=\"amountMaskEnabled\"\n\t\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\t\t:value=\"amountText\"\n\t\t\t\t\t\t\t\tclass=\"acurrency__amount\"\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tinputmode=\"decimal\"\n\t\t\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t\t@focus=\"onAmountFocus\"\n\t\t\t\t\t\t\t\t@blur=\"onAmountBlur\"\n\t\t\t\t\t\t\t\t@input=\"onAmountInput\"\n\t\t\t\t\t\t\t\t@keydown=\"onAmountKeydownMasked\"\n\t\t\t\t\t\t\t\t@paste=\"onAmountPasteMasked\" />\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\t\tv-model.number=\"amount\"\n\t\t\t\t\t\t\t\tclass=\"acurrency__amount\"\n\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t\t@keydown=\"onAmountKeydown\"\n\t\t\t\t\t\t\t\t@paste=\"onAmountPaste\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"acurrency__field acurrency__field--base-currency\" aria-hidden=\"true\">\n\t\t\t\t\t<input type=\"text\" readonly tabindex=\"-1\" :value=\"baseCurrencyText\" />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<p v-if=\"showBase && !errorText\" :id=\"helperId\" class=\"acurrency__helper\">{{ conversionHelperText }}</p>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport {\n\tcurrencyAmountEntryPattern,\n\tcurrencyInputFractionDigits,\n\tformatCurrencyAmount,\n\tformatCurrencyAmountInput,\n\tformatCurrencySymbol,\n\tparseCurrencyAmountInput,\n} from '@stonecrop/utilities'\nimport { computed, inject, ref, useTemplateRef, watch } from 'vue'\n\nimport type { AFormLinkValue, ComponentProps, CurrencyOptions, CurrencyValue } from '../../types'\nimport {\n\tnormalizeBaseCurrency,\n\tpatchCurrencyAmount,\n\tpatchCurrencyCurrency,\n\trecomputeCurrencyValue,\n} from '../../utils/currencyValue'\nimport { numberFromBox } from '../../utils/emptiedBox'\nimport { asLinkValue, linkId } from '../../utils/linkValue'\nimport { numberFromRecord } from '../../utils/recordNumber'\nimport ADropdown from './ADropdown.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\toptions = {},\n\tcurrencyLabel = 'Currency',\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: CurrencyOptions\n\t\tcurrencyLabel?: string\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst helperId = computed(() => (uuid ? `${uuid}-helper` : undefined))\n\n// No default: a field with no value shows empty, as null does, rather than a rate nobody entered.\nconst modelValue = defineModel<CurrencyValue | null>()\n\n// The base figures are worked out from the amount, currency, rate and options rather than read from\n// the value: when its parts are fields of their own, no field holds them, and those fields hold what the\n// server sent (a bare currency id, decimal text). Only what is shown is read this way; an edit writes\n// back the parts it leaves alone exactly as they came.\nconst shown = computed(() => {\n\tconst boxValue = modelValue.value\n\tif (!boxValue) return null\n\tconst readValue = { ...boxValue, currency: asLinkValue(boxValue.currency) }\n\treturn recomputeCurrencyValue(\n\t\tnumberFromRecord(boxValue.amount),\n\t\treadValue.currency,\n\t\toptions,\n\t\tnormalizeBaseCurrency(options, boxValue),\n\t\treadValue\n\t)\n})\n\nconst showBase = computed(() => {\n\tconst shownValue = shown.value\n\treturn (\n\t\t!!shownValue?.baseCurrency?.id &&\n\t\t(shownValue.currency?.id !== shownValue.baseCurrency?.id || shownValue.amount !== shownValue.baseAmount)\n\t)\n})\n\nconst helperDescribedBy = computed(() => (showBase.value && !errorText.value ? helperId.value : undefined))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText, helperDescribedBy)\n\nconst currencyDropdownRef = useTemplateRef<{ openCurrencyList?: () => void }>('currencyDropdownRef')\n\nconst openCurrencyList = () => {\n\tcurrencyDropdownRef.value?.openCurrencyList?.()\n}\n\nconst focusCurrencyPicker = (event: MouseEvent) => {\n\tconst root = event.currentTarget as HTMLElement\n\tif ((event.target as HTMLElement).closest('input')) {\n\t\topenCurrencyList()\n\t\treturn\n\t}\n\tconst input = root.querySelector<HTMLInputElement>('input[role=\"combobox\"]')\n\tinput?.focus()\n\topenCurrencyList()\n}\n\nconst amountMaskEnabled = computed(() => options.amountMask !== false)\nconst amountFocused = ref(false)\nconst amountText = ref('')\n\nconst selectedCurrencyId = computed(() => linkId(modelValue.value?.currency) ?? '')\n\nconst syncAmountTextFromModel = () => {\n\tamountText.value = formatCurrencyAmountInput(modelValue.value?.amount ?? null, selectedCurrencyId.value)\n}\n\nwatch(selectedCurrencyId, () => {\n\tif (!amountFocused.value) syncAmountTextFromModel()\n})\n\nwatch(\n\t() => modelValue.value?.amount,\n\t() => {\n\t\tif (!amountFocused.value) syncAmountTextFromModel()\n\t},\n\t{ immediate: true }\n)\n\n// The base currency is fixed configuration, not user-editable. It may be supplied as a bare id\n// (resolved to displayText below via the same `aformLinkResolver` injection AFormLink uses) or\n// as a full AFormLinkValue that already carries displayText.\nconst normalizedBaseCurrency = computed<AFormLinkValue>(() => normalizeBaseCurrency(options, modelValue.value))\n\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\nconst resolvedBaseCurrency = ref<AFormLinkValue>(normalizedBaseCurrency.value)\n\nwatch(\n\tnormalizedBaseCurrency,\n\tasync base => {\n\t\tif (!base.id || base.displayText || !resolver || !options.doctype) {\n\t\t\tresolvedBaseCurrency.value = base\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst displayText = await resolver(options.doctype, String(base.id))\n\t\t\tresolvedBaseCurrency.value = displayText ? { ...base, displayText } : base\n\t\t} catch {\n\t\t\tresolvedBaseCurrency.value = base\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst baseCurrencyText = computed(() => {\n\tconst base = resolvedBaseCurrency.value\n\tif (!base?.id) return ''\n\treturn base.displayText ?? String(base.id)\n})\n\nconst amount = computed({\n\tget: () => modelValue.value?.amount ?? null,\n\tset: (value: number | '') =>\n\t\t(modelValue.value = patchCurrencyAmount(\n\t\t\tmodelValue.value,\n\t\t\tnumberFromBox(value),\n\t\t\toptions,\n\t\t\tresolvedBaseCurrency.value\n\t\t)),\n})\n\nconst currency = computed<AFormLinkValue>({\n\tget: () => modelValue.value?.currency ?? { id: '' },\n\tset: (value: AFormLinkValue) =>\n\t\t(modelValue.value = patchCurrencyCurrency(modelValue.value, value, options, resolvedBaseCurrency.value)),\n})\n\nconst amountNavigationKeys = new Set([\n\t'Backspace',\n\t'Delete',\n\t'Tab',\n\t'Escape',\n\t'Enter',\n\t'ArrowLeft',\n\t'ArrowRight',\n\t'ArrowUp',\n\t'ArrowDown',\n\t'Home',\n\t'End',\n])\n\nconst onAmountKeydown = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (amountNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\t// A currency amount is signed — credit notes, refunds and adjustments are negative.\n\t//\n\t// Both dedup checks below are best-effort: a `type=\"number\"` input reports `value` as `''`\n\t// whenever its content isn't a valid number, so mid-entry states like \"1.\" or \"-\" read as\n\t// empty and a second separator can slip through. The browser rejects the resulting value\n\t// anyway; this guard exists to stop the obviously-wrong keys (letters, 'e', '+'), not to be\n\t// the sole arbiter of well-formedness.\n\tconst input = event.target as HTMLInputElement\n\tif (event.key === '.' && !input.value.includes('.')) return\n\tif (event.key === '-' && !input.value.includes('-')) return\n\tevent.preventDefault()\n}\n\nconst onAmountPaste = (event: ClipboardEvent) => {\n\tconst pasted = event.clipboardData?.getData('text') ?? ''\n\tif (!/^-?\\d*\\.?\\d*$/.test(pasted)) event.preventDefault()\n}\n\nconst onAmountFocus = (event: FocusEvent) => {\n\tamountFocused.value = true\n\tconst input = event.target as HTMLInputElement | null\n\tif (input) requestAnimationFrame(() => input.select())\n}\n\nconst onAmountBlur = () => {\n\tamountFocused.value = false\n\tconst parsed = parseCurrencyAmountInput(amountText.value)\n\tmodelValue.value = patchCurrencyAmount(modelValue.value, parsed, options, resolvedBaseCurrency.value)\n\tsyncAmountTextFromModel()\n}\n\nconst onAmountInput = (event: Event) => {\n\tconst input = event.target as HTMLInputElement\n\tamountText.value = input.value\n\tconst parsed = parseCurrencyAmountInput(amountText.value)\n\tif (amountText.value.trim() === '' || amountText.value.trim() === '-' || parsed !== null) {\n\t\tmodelValue.value = patchCurrencyAmount(modelValue.value, parsed, options, resolvedBaseCurrency.value)\n\t}\n}\n\nconst onAmountKeydownMasked = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (amountNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\tif (event.key === '-') {\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('-') && input.selectionStart === 0) return\n\t}\n\tif (event.key === '.' || event.key === ',') {\n\t\tif (currencyInputFractionDigits(selectedCurrencyId.value) === 0) {\n\t\t\tevent.preventDefault()\n\t\t\treturn\n\t\t}\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('.') && !input.value.includes(',')) return\n\t}\n\tconst pattern = currencyAmountEntryPattern(selectedCurrencyId.value)\n\tconst input = event.target as HTMLInputElement\n\tconst { selectionStart, selectionEnd, value } = input\n\tif (selectionStart === null || selectionEnd === null) {\n\t\tevent.preventDefault()\n\t\treturn\n\t}\n\tconst next = value.slice(0, selectionStart) + event.key + value.slice(selectionEnd)\n\tif (event.key.length === 1 && !pattern.test(next)) event.preventDefault()\n}\n\n// The box's text once pasted, as a table cell checks it: \".5\" pasted after \"12.3\" is no amount.\nconst onAmountPasteMasked = (event: ClipboardEvent) => {\n\tconst input = event.target as HTMLInputElement\n\tconst pasted = (event.clipboardData?.getData('text') ?? '').trim()\n\tconst text = input.value.slice(0, input.selectionStart ?? 0) + pasted + input.value.slice(input.selectionEnd ?? 0)\n\tif (!currencyAmountEntryPattern(selectedCurrencyId.value).test(text)) event.preventDefault()\n}\n\nconst conversionHelperText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || shownValue.baseAmount === null || shownValue.amount === null) return ''\n\tconst baseLabel = baseCurrencyText.value || String(shownValue.baseCurrency?.id ?? '')\n\tconst enteredId = String(shownValue.currency?.id ?? '')\n\tconst rate = shownValue.exchangeRate\n\treturn `≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)} · 1 ${enteredId} = ${rate} ${baseLabel}`\n})\n\nconst displayText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || !shownValue.currency?.id || shownValue.amount === null) return '—'\n\tconst base = formatCurrencyAmount(shownValue.amount, shownValue.currency)\n\tif (!showBase.value) return base\n\treturn `${base} (≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)})`\n})\n</script>\n\n<style scoped>\n.acurrency__row {\n\tdisplay: flex;\n\tgap: 1ch;\n}\n\n.acurrency__field {\n\tposition: relative;\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.acurrency__field--base-currency {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.acurrency__group {\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius);\n}\n\n.acurrency__group:focus-within {\n\tborder-color: var(--sc-input-active-border-color);\n}\n\n/* Solid form surface behind long labels; the shared gradient only masks the top half and reads\n poorly over the merged prefix + amount backgrounds. Matches the field's page/form parent. */\n.acurrency__group > .aform_field-label {\n\tbackground: var(--sc-form-background);\n}\n\n.acurrency__amount-wrap {\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.acurrency__amount {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tborder: none;\n\toutline: none;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\tbackground: transparent;\n\tborder-radius: 0 var(--sc-border-radius) var(--sc-border-radius) 0;\n\ttext-align: right;\n\tappearance: textfield;\n\t-moz-appearance: textfield;\n}\n\n.acurrency__amount::-webkit-outer-spin-button,\n.acurrency__amount::-webkit-inner-spin-button {\n\tappearance: none;\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n/* The currency picker reads as a simple prefix addon (like Bootstrap's \"$\" prepend) rather\n than an equal partner to the amount box: fixed compact width (symbol or short code like NZD),\n tinted background, left-rounded to match the group's own\n corner so the tint doesn't overhang the border. The dropdown itself isn't bound by this\n width — ADropdown list spans the group — so search results still show full names. */\n.acurrency__currency {\n\t/* Fixed minimum prefix: 3rem content band + 1ch inset each side (fits NZD without shifting). */\n\tflex: 0 0 calc(3rem + 2ch);\n\twidth: calc(3rem + 2ch);\n\tmin-width: calc(3rem + 2ch);\n\tmax-width: calc(3rem + 2ch);\n\tbox-sizing: border-box;\n\tcursor: pointer;\n\tbackground: var(--sc-input-addon-background);\n\tborder-right: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius) 0 0 var(--sc-border-radius);\n}\n\n.acurrency__currency :deep(.aform_input-field--embedded) {\n\tpadding-left: 1ch;\n\tpadding-right: 1ch;\n\ttext-align: right;\n}\n\n.acurrency__currency :deep(.aform_form-element--embedded),\n.acurrency__currency :deep(.autocomplete) {\n\tposition: static;\n}\n\n.acurrency__group :deep(.autocomplete-results--anchor-group) {\n\tleft: -1px;\n\tright: -1px;\n\tbox-sizing: border-box;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.acurrency__helper {\n\tmargin: 0.5rem 0 0;\n\tfont-size: 0.85rem;\n\tcolor: var(--sc-cell-text-color);\n\topacity: 0.75;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element acurrency\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayText }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div class=\"acurrency__row\">\n\t\t\t\t<div class=\"acurrency__field acurrency__field--amount\">\n\t\t\t\t\t<div class=\"acurrency__group\">\n\t\t\t\t\t\t<div class=\"acurrency__currency\" @click=\"focusCurrencyPicker\">\n\t\t\t\t\t\t\t<ADropdown\n\t\t\t\t\t\t\t\tref=\"currencyDropdownRef\"\n\t\t\t\t\t\t\t\tv-model:link-value=\"currency\"\n\t\t\t\t\t\t\t\tlink\n\t\t\t\t\t\t\t\tembedded\n\t\t\t\t\t\t\t\tlist-anchor=\"group\"\n\t\t\t\t\t\t\t\t:mode=\"mode\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:placeholder=\"currencyLabel\"\n\t\t\t\t\t\t\t\t:aria-label=\"currencyLabel\"\n\t\t\t\t\t\t\t\t:formatter=\"formatCurrencySymbol\"\n\t\t\t\t\t\t\t\t:doctype=\"options.doctype\"\n\t\t\t\t\t\t\t\t:link-filter-function=\"options.filterFunction\"\n\t\t\t\t\t\t\t\t:is-async=\"options.isAsync\">\n\t\t\t\t\t\t\t\t<template #option=\"{ option }\"\n\t\t\t\t\t\t\t\t\t>{{ option.symbol ? `${option.symbol} — ` : '' }}{{ option.displayText ?? option.id }}</template\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t</ADropdown>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"acurrency__amount-wrap\">\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tv-if=\"amountMaskEnabled\"\n\t\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\t\t:value=\"amountText\"\n\t\t\t\t\t\t\t\tclass=\"acurrency__amount\"\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tinputmode=\"decimal\"\n\t\t\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t\t@focus=\"onAmountFocus\"\n\t\t\t\t\t\t\t\t@blur=\"onAmountBlur\"\n\t\t\t\t\t\t\t\t@input=\"onAmountInput\"\n\t\t\t\t\t\t\t\t@keydown=\"onAmountKeydownMasked\"\n\t\t\t\t\t\t\t\t@paste=\"onAmountPasteMasked\" />\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\t\tv-model.number=\"amount\"\n\t\t\t\t\t\t\t\tclass=\"acurrency__amount\"\n\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t\t@keydown=\"onAmountKeydown\"\n\t\t\t\t\t\t\t\t@paste=\"onAmountPaste\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"acurrency__field acurrency__field--base-currency\" aria-hidden=\"true\">\n\t\t\t\t\t<input type=\"text\" readonly tabindex=\"-1\" :value=\"baseCurrencyText\" />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<p v-if=\"showBase && !errorText\" :id=\"helperId\" class=\"acurrency__helper\">{{ conversionHelperText }}</p>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport {\n\tcurrencyAmountEntryPattern,\n\tcurrencyInputFractionDigits,\n\tformatCurrencyAmount,\n\tformatCurrencyAmountInput,\n\tformatCurrencySymbol,\n\tparseCurrencyAmountInput,\n} from '@stonecrop/utilities'\nimport { computed, inject, ref, useTemplateRef, watch } from 'vue'\n\nimport type { AFormLinkValue, ComponentProps, CurrencyOptions, CurrencyValue } from '../../types'\nimport {\n\tnormalizeBaseCurrency,\n\tpatchCurrencyAmount,\n\tpatchCurrencyCurrency,\n\trecomputeCurrencyValue,\n} from '../../utils/currencyValue'\nimport { numberFromBox } from '../../utils/emptiedBox'\nimport { asLinkValue, linkId } from '../../utils/linkValue'\nimport { numberFromRecord } from '../../utils/recordNumber'\nimport ADropdown from './ADropdown.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\toptions = {},\n\tcurrencyLabel = 'Currency',\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: CurrencyOptions\n\t\tcurrencyLabel?: string\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst helperId = computed(() => (uuid ? `${uuid}-helper` : undefined))\n\n// No default: a field with no value shows empty, as null does, rather than a rate nobody entered.\nconst modelValue = defineModel<CurrencyValue | null>()\n\n// The base figures are worked out from the amount, currency, rate and options rather than read from\n// the value: when its parts are fields of their own, no field holds them, and those fields hold what the\n// server sent (a bare currency id, decimal text). Only what is shown is read this way; an edit writes\n// back the parts it leaves alone exactly as they came.\nconst shown = computed(() => {\n\tconst boxValue = modelValue.value\n\tif (!boxValue) return null\n\tconst readValue = { ...boxValue, currency: asLinkValue(boxValue.currency) }\n\treturn recomputeCurrencyValue(\n\t\tnumberFromRecord(boxValue.amount),\n\t\treadValue.currency,\n\t\toptions,\n\t\tnormalizeBaseCurrency(options, boxValue),\n\t\treadValue\n\t)\n})\n\nconst showBase = computed(() => {\n\tconst shownValue = shown.value\n\treturn (\n\t\t!!shownValue?.baseCurrency?.id &&\n\t\t(shownValue.currency?.id !== shownValue.baseCurrency?.id || shownValue.amount !== shownValue.baseAmount)\n\t)\n})\n\nconst helperDescribedBy = computed(() => (showBase.value && !errorText.value ? helperId.value : undefined))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText, helperDescribedBy)\n\nconst currencyDropdownRef = useTemplateRef<{ openCurrencyList?: () => void }>('currencyDropdownRef')\n\nconst openCurrencyList = () => {\n\tcurrencyDropdownRef.value?.openCurrencyList?.()\n}\n\nconst focusCurrencyPicker = (event: MouseEvent) => {\n\tconst root = event.currentTarget as HTMLElement\n\tif ((event.target as HTMLElement).closest('input')) {\n\t\topenCurrencyList()\n\t\treturn\n\t}\n\tconst input = root.querySelector<HTMLInputElement>('input[role=\"combobox\"]')\n\tinput?.focus()\n\topenCurrencyList()\n}\n\nconst amountMaskEnabled = computed(() => options.amountMask !== false)\nconst amountFocused = ref(false)\nconst amountText = ref('')\n\nconst selectedCurrencyId = computed(() => linkId(modelValue.value?.currency) ?? '')\n\nconst syncAmountTextFromModel = () => {\n\tamountText.value = formatCurrencyAmountInput(modelValue.value?.amount ?? null, selectedCurrencyId.value)\n}\n\nwatch(selectedCurrencyId, () => {\n\tif (!amountFocused.value) syncAmountTextFromModel()\n})\n\nwatch(\n\t() => modelValue.value?.amount,\n\t() => {\n\t\tif (!amountFocused.value) syncAmountTextFromModel()\n\t},\n\t{ immediate: true }\n)\n\n// The base currency is fixed configuration, not user-editable. It may be supplied as a bare id\n// (resolved to displayText below via the same `aformLinkResolver` injection AFormLink uses) or\n// as a full AFormLinkValue that already carries displayText.\nconst normalizedBaseCurrency = computed<AFormLinkValue>(() => normalizeBaseCurrency(options, modelValue.value))\n\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\nconst resolvedBaseCurrency = ref<AFormLinkValue>(normalizedBaseCurrency.value)\n\nwatch(\n\tnormalizedBaseCurrency,\n\tasync base => {\n\t\tif (!base.id || base.displayText || !resolver || !options.doctype) {\n\t\t\tresolvedBaseCurrency.value = base\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst displayText = await resolver(options.doctype, String(base.id))\n\t\t\tresolvedBaseCurrency.value = displayText ? { ...base, displayText } : base\n\t\t} catch {\n\t\t\tresolvedBaseCurrency.value = base\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst baseCurrencyText = computed(() => {\n\tconst base = resolvedBaseCurrency.value\n\tif (!base?.id) return ''\n\treturn base.displayText ?? String(base.id)\n})\n\nconst amount = computed({\n\tget: () => modelValue.value?.amount ?? null,\n\tset: (value: number | '') =>\n\t\t(modelValue.value = patchCurrencyAmount(\n\t\t\tmodelValue.value,\n\t\t\tnumberFromBox(value),\n\t\t\toptions,\n\t\t\tresolvedBaseCurrency.value\n\t\t)),\n})\n\nconst currency = computed<AFormLinkValue>({\n\tget: () => modelValue.value?.currency ?? { id: '' },\n\tset: (value: AFormLinkValue) =>\n\t\t(modelValue.value = patchCurrencyCurrency(modelValue.value, value, options, resolvedBaseCurrency.value)),\n})\n\nconst amountNavigationKeys = new Set([\n\t'Backspace',\n\t'Delete',\n\t'Tab',\n\t'Escape',\n\t'Enter',\n\t'ArrowLeft',\n\t'ArrowRight',\n\t'ArrowUp',\n\t'ArrowDown',\n\t'Home',\n\t'End',\n])\n\nconst onAmountKeydown = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (amountNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\t// A currency amount is signed — credit notes, refunds and adjustments are negative.\n\t//\n\t// Both dedup checks below are best-effort: a `type=\"number\"` input reports `value` as `''`\n\t// whenever its content isn't a valid number, so mid-entry states like \"1.\" or \"-\" read as\n\t// empty and a second separator can slip through. The browser rejects the resulting value\n\t// anyway; this guard exists to stop the obviously-wrong keys (letters, 'e', '+'), not to be\n\t// the sole arbiter of well-formedness.\n\tconst input = event.target as HTMLInputElement\n\tif (event.key === '.' && !input.value.includes('.')) return\n\tif (event.key === '-' && !input.value.includes('-')) return\n\tevent.preventDefault()\n}\n\nconst onAmountPaste = (event: ClipboardEvent) => {\n\tconst pasted = event.clipboardData?.getData('text') ?? ''\n\tif (!/^-?\\d*\\.?\\d*$/.test(pasted)) event.preventDefault()\n}\n\nconst onAmountFocus = (event: FocusEvent) => {\n\tamountFocused.value = true\n\tconst input = event.target as HTMLInputElement | null\n\tif (input) requestAnimationFrame(() => input.select())\n}\n\nconst onAmountBlur = () => {\n\tamountFocused.value = false\n\tconst parsed = parseCurrencyAmountInput(amountText.value)\n\tmodelValue.value = patchCurrencyAmount(modelValue.value, parsed, options, resolvedBaseCurrency.value)\n\tsyncAmountTextFromModel()\n}\n\nconst onAmountInput = (event: Event) => {\n\tconst input = event.target as HTMLInputElement\n\tamountText.value = input.value\n\tconst parsed = parseCurrencyAmountInput(amountText.value)\n\tif (amountText.value.trim() === '' || amountText.value.trim() === '-' || parsed !== null) {\n\t\tmodelValue.value = patchCurrencyAmount(modelValue.value, parsed, options, resolvedBaseCurrency.value)\n\t}\n}\n\nconst onAmountKeydownMasked = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (amountNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\tif (event.key === '-') {\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('-') && input.selectionStart === 0) return\n\t}\n\tif (event.key === '.' || event.key === ',') {\n\t\tif (currencyInputFractionDigits(selectedCurrencyId.value) === 0) {\n\t\t\tevent.preventDefault()\n\t\t\treturn\n\t\t}\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('.') && !input.value.includes(',')) return\n\t}\n\tconst pattern = currencyAmountEntryPattern(selectedCurrencyId.value)\n\tconst input = event.target as HTMLInputElement\n\tconst { selectionStart, selectionEnd, value } = input\n\tif (selectionStart === null || selectionEnd === null) {\n\t\tevent.preventDefault()\n\t\treturn\n\t}\n\tconst next = value.slice(0, selectionStart) + event.key + value.slice(selectionEnd)\n\tif (event.key.length === 1 && !pattern.test(next)) event.preventDefault()\n}\n\n// The box's text once pasted, as a table cell checks it: \".5\" pasted after \"12.3\" is no amount.\nconst onAmountPasteMasked = (event: ClipboardEvent) => {\n\tconst input = event.target as HTMLInputElement\n\tconst pasted = (event.clipboardData?.getData('text') ?? '').trim()\n\tconst text = input.value.slice(0, input.selectionStart ?? 0) + pasted + input.value.slice(input.selectionEnd ?? 0)\n\tif (!currencyAmountEntryPattern(selectedCurrencyId.value).test(text)) event.preventDefault()\n}\n\nconst conversionHelperText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || shownValue.baseAmount === null || shownValue.amount === null) return ''\n\tconst baseLabel = baseCurrencyText.value || String(shownValue.baseCurrency?.id ?? '')\n\tconst enteredId = String(shownValue.currency?.id ?? '')\n\tconst rate = shownValue.exchangeRate\n\treturn `≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)} · 1 ${enteredId} = ${rate} ${baseLabel}`\n})\n\nconst displayText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || !shownValue.currency?.id || shownValue.amount === null) return '—'\n\tconst base = formatCurrencyAmount(shownValue.amount, shownValue.currency)\n\tif (!showBase.value) return base\n\treturn `${base} (≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)})`\n})\n</script>\n\n<style scoped>\n.acurrency__row {\n\tdisplay: flex;\n\tgap: 1ch;\n}\n\n.acurrency__field {\n\tposition: relative;\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.acurrency__field--base-currency {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.acurrency__group {\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius);\n}\n\n.acurrency__group:focus-within {\n\tborder-color: var(--sc-input-active-border-color);\n}\n\n/* Solid form surface behind long labels; the shared gradient only masks the top half and reads\n poorly over the merged prefix + amount backgrounds. Matches the field's page/form parent. */\n.acurrency__group > .aform_field-label {\n\tbackground: var(--sc-form-background);\n}\n\n.acurrency__amount-wrap {\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.acurrency__amount {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tborder: none;\n\toutline: none;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\tbackground: transparent;\n\tborder-radius: 0 var(--sc-border-radius) var(--sc-border-radius) 0;\n\ttext-align: right;\n\tappearance: textfield;\n\t-moz-appearance: textfield;\n}\n\n.acurrency__amount::-webkit-outer-spin-button,\n.acurrency__amount::-webkit-inner-spin-button {\n\tappearance: none;\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n/* The currency picker reads as a simple prefix addon (like Bootstrap's \"$\" prepend) rather\n than an equal partner to the amount box: fixed compact width (symbol or short code like NZD),\n tinted background, left-rounded to match the group's own\n corner so the tint doesn't overhang the border. The dropdown itself isn't bound by this\n width — ADropdown list spans the group — so search results still show full names. */\n.acurrency__currency {\n\t/* Fixed minimum prefix: 3rem content band + 1ch inset each side (fits NZD without shifting). */\n\tflex: 0 0 calc(3rem + 2ch);\n\twidth: calc(3rem + 2ch);\n\tmin-width: calc(3rem + 2ch);\n\tmax-width: calc(3rem + 2ch);\n\tbox-sizing: border-box;\n\tcursor: pointer;\n\tbackground: var(--sc-input-addon-background);\n\tborder-right: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius) 0 0 var(--sc-border-radius);\n}\n\n.acurrency__currency :deep(.aform_input-field--embedded) {\n\tpadding-left: 1ch;\n\tpadding-right: 1ch;\n\ttext-align: right;\n}\n\n.acurrency__currency :deep(.aform_form-element--embedded),\n.acurrency__currency :deep(.autocomplete) {\n\tposition: static;\n}\n\n.acurrency__group :deep(.autocomplete-results--anchor-group) {\n\tleft: -1px;\n\tright: -1px;\n\tbox-sizing: border-box;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.acurrency__helper {\n\tmargin: 0.5rem 0 0;\n\tfont-size: 0.85rem;\n\tcolor: var(--sc-cell-text-color);\n\topacity: 0.75;\n}\n</style>\n","import { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\n\n// The locale's numeric day in the Gregorian calendar with Western digits, whatever the locale's own\n// calendar and digits, so that `readTypedDay` reads back what `writeTypedDay` writes.\nconst TYPED_DAY_FORMAT: Intl.DateTimeFormatOptions = { calendar: 'gregory', numberingSystem: 'latn' }\n\n/**\n * A day written as the locale writes it in numbers, for a box a user types days into.\n * @param locale - The browser's own when omitted\n */\nexport function writeTypedDay(day: Temporal.PlainDate, locale?: string): string {\n\treturn day.toLocaleString(locale, TYPED_DAY_FORMAT)\n}\n\n/**\n * Reads a day typed as `writeTypedDay` writes it, or as `YYYY-MM-DD`. Any other text, or a day that does\n * not exist, reads as no day. Not `new Date(text)`, which reads `YYYY-MM-DD` as UTC midnight and rolls an\n * impossible day over.\n * @param locale - The browser's own when omitted\n */\nexport function readTypedDay(text: string, locale?: string): Temporal.PlainDate | undefined {\n\tconst isoDay = fromISODate(text.trim())\n\tif (isoDay) return isoDay\n\n\tconst numbers = text.match(/\\d+/g)\n\tif (numbers?.length !== 3) return undefined\n\tconst order = new Intl.DateTimeFormat(locale, TYPED_DAY_FORMAT)\n\t\t.formatToParts(0)\n\t\t.map(part => part.type)\n\t\t.filter(type => type === 'year' || type === 'month' || type === 'day')\n\tconst typed = Object.fromEntries(order.map((type, index) => [type, numbers[index]]))\n\tif (typed.year?.length !== 4) return undefined\n\n\ttry {\n\t\treturn Temporal.PlainDate.from(\n\t\t\t{ year: Number(typed.year), month: Number(typed.month), day: Number(typed.day) },\n\t\t\t{ overflow: 'reject' }\n\t\t)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n","<template>\n\t<template v-if=\"mode === 'display' || mode === 'read'\">\n\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t<label v-if=\"label\">{{ label }}</label>\n\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t</template>\n\t<template v-else>\n\t\t<div class=\"adatepicker\">\n\t\t\t<table ref=\"grid\" role=\"grid\" :aria-label=\"monthAndYear\" @mousedown=\"preventCellSelection\">\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td id=\"previous-month-btn\" :tabindex=\"-1\" @click=\"previousMonth\"><</td>\n\t\t\t\t\t\t<th colspan=\"5\" :tabindex=\"-1\">{{ monthAndYear }}</th>\n\t\t\t\t\t\t<td id=\"next-month-btn\" :tabindex=\"-1\" @click=\"nextMonth\">></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr v-if=\"selectRange\">\n\t\t\t\t\t\t<td colspan=\"7\" class=\"range-inputs\">\n\t\t\t\t\t\t\t<div class=\"date-input\">\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tref=\"start-date-input\"\n\t\t\t\t\t\t\t\t\t:value=\"getStartDate\"\n\t\t\t\t\t\t\t\t\tclass=\"date-input-start aform_input-field\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"start date\"\n\t\t\t\t\t\t\t\t\t@blur=\"enterInputDate()\"\n\t\t\t\t\t\t\t\t\t@keydown=\"enterDate\" />\n\t\t\t\t\t\t\t\t<div>-</div>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tref=\"end-date-input\"\n\t\t\t\t\t\t\t\t\t:value=\"getEndDate\"\n\t\t\t\t\t\t\t\t\tclass=\"date-input-end aform_input-field\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"end date\"\n\t\t\t\t\t\t\t\t\t@blur=\"enterInputDate()\"\n\t\t\t\t\t\t\t\t\t@keydown=\"enterDate\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<!-- {{ formattedDateRange }} -->\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class=\"days-header\">\n\t\t\t\t\t\t<td v-for=\"(letter, weekdayIndex) in weekdayLetters\" :key=\"weekdayIndex\">{{ letter }}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr v-for=\"rowNo in numberOfRows\" :key=\"rowNo\">\n\t\t\t\t\t\t<!-- the 'ref' key is currently only used for test references -->\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-for=\"colNo in numberOfColumns\"\n\t\t\t\t\t\t\tref=\"celldate\"\n\t\t\t\t\t\t\t:key=\"getCurrentCell(rowNo, colNo)\"\n\t\t\t\t\t\t\tclass=\"date-cell\"\n\t\t\t\t\t\t\t:contenteditable=\"false\"\n\t\t\t\t\t\t\t:spellcheck=\"false\"\n\t\t\t\t\t\t\t:tabindex=\"getCurrentDate(rowNo, colNo).equals(focusedDay) ? 0 : -1\"\n\t\t\t\t\t\t\t:aria-label=\"fullDate(getCurrentDate(rowNo, colNo))\"\n\t\t\t\t\t\t\t:aria-selected=\"isPicked(getCurrentDate(rowNo, colNo))\"\n\t\t\t\t\t\t\t:aria-current=\"isTodaysDate(getCurrentDate(rowNo, colNo)) ? 'date' : undefined\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\ttodaysDate: isTodaysDate(getCurrentDate(rowNo, colNo)),\n\t\t\t\t\t\t\t\tselectedDate: isSelectedDate(getCurrentDate(rowNo, colNo)),\n\t\t\t\t\t\t\t\twithinRange: selectRange ? isInDateRange(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t\tstartDate: selectRange ? isStartDate(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t\tendDate: selectRange ? isEndDate(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@click.prevent.stop=\"selectDate(getCurrentCell(rowNo, colNo))\"\n\t\t\t\t\t\t\t@keydown=\"onDayKeydown($event, getCurrentCell(rowNo, colNo))\"\n\t\t\t\t\t\t\t@mouseover=\"hoverDate(getCurrentCell(rowNo, colNo))\">\n\t\t\t\t\t\t\t{{ getCurrentDate(rowNo, colNo).day }}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t</template>\n</template>\n\n<script setup lang=\"ts\">\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { readTypedDay, writeTypedDay } from '../../utils/typedDay'\n\nconst numberOfRows = 6\nconst numberOfColumns = 7\n\nconst {\n\tmode,\n\tlabel,\n\tselectRange = false,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n} = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId } = fieldErrorA11y(uuid, errorText)\n\n// The calendar holds a `YYYY-MM-DD` day, and opens on today when it holds none it can read. No default\n// value: picking today on an empty calendar must still set it, and a model only reports a change.\nconst date = defineModel<string | null>()\nconst selectedDate = ref<Temporal.PlainDate>(fromISODate(date.value ?? '') ?? Temporal.Now.plainDateISO())\n// 0 for January.\nconst currentMonth = ref<number>(selectedDate.value.month - 1)\nconst currentYear = ref<number>(selectedDate.value.year)\nconst currentDates = ref<Temporal.PlainDate[]>([])\n\n// The day the grid's one Tab stop sits on, where its keys move from. It is always a day the grid shows.\nconst focusedDay = ref<Temporal.PlainDate>(selectedDate.value)\nconst grid = useTemplateRef<HTMLTableElement>('grid')\n\nconst hoveredDate = ref<Temporal.PlainDate>(selectedDate.value)\nconst start_date = ref<Temporal.PlainDate | null>(null)\nconst end_date = ref<Temporal.PlainDate | null>(null)\nconst startDateInput = useTemplateRef<HTMLInputElement>('start-date-input')\nconst endDateInput = useTemplateRef<HTMLInputElement>('end-date-input')\n\n/*******************\nEmits\n*******************/\n\nconst emit = defineEmits<{\n\t'get-date': [{ start: string | null; end: string | null; selected: string }]\n}>()\n\n/*******************\nComputed\n*******************/\n\nconst displayValue = computed(() => (date.value ? (fromISODate(date.value)?.toLocaleString() ?? 'Invalid Date') : ''))\n\nconst firstOfMonth = computed(() =>\n\tTemporal.PlainDate.from({ year: currentYear.value, month: currentMonth.value + 1, day: 1 })\n)\n\n// Not a `PlainYearMonth`: its `toLocaleString` throws for the ISO calendar.\nconst monthAndYear = computed(() => firstOfMonth.value.toLocaleString(undefined, { year: 'numeric', month: 'long' }))\n\n// The grid's first week, so the letters follow its Monday start.\nconst weekdayLetters = computed(() =>\n\tcurrentDates.value.slice(0, numberOfColumns).map(day => day.toLocaleString(undefined, { weekday: 'narrow' }))\n)\n\nconst getStartDate = computed(() => boxText(start_date.value))\n\nconst getEndDate = computed(() => boxText(end_date.value))\n\n/*******************\nFunctions\n*******************/\n\nconst boxText = (day: Temporal.PlainDate | null) => (day ? writeTypedDay(day) : '')\n\nconst isTodaysDate = (day: Temporal.PlainDate): boolean => {\n\tconst today = Temporal.Now.plainDateISO()\n\tif (currentMonth.value !== today.month - 1) return false\n\treturn day.equals(today)\n}\n\nconst isSelectedDate = (day: Temporal.PlainDate) => {\n\treturn day.equals(selectedDate.value)\n}\n\nconst isStartDate = (day: Temporal.PlainDate) => {\n\treturn start_date.value !== null && day.equals(start_date.value)\n}\n\nconst isEndDate = (day: Temporal.PlainDate) => {\n\treturn end_date.value !== null && day.equals(end_date.value)\n}\n\n// Every day the calendar marks as picked, so a screen reader hears the same days marked.\nconst isPicked = (day: Temporal.PlainDate) =>\n\tisSelectedDate(day) || (selectRange && (isStartDate(day) || isEndDate(day)))\n\nconst fullDate = (day: Temporal.PlainDate) =>\n\tday.toLocaleString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })\n\nconst getCurrentCell = (rowNo: number, colNo: number) => {\n\treturn (rowNo - 1) * numberOfColumns + colNo - 1\n}\n\nconst isInDateRange = (day: Temporal.PlainDate) => {\n\tconst start = start_date.value\n\tif (!start) return false\n\n\t//the end is either the selected end date or wherever the user is hovering\n\tconst end = end_date.value ?? hoveredDate.value\n\n\treturn Temporal.PlainDate.compare(day, start) > 0 && Temporal.PlainDate.compare(day, end) < 0\n}\n\nconst getCurrentDate = (rowNo: number, colNo: number) => {\n\treturn currentDates.value[getCurrentCell(rowNo, colNo)]\n}\n\nconst hoverDate = (currentIndex: number) => {\n\thoveredDate.value = currentDates.value[currentIndex]\n}\n\n// browsers (notably Firefox) allow drag-selecting text across table cells even with\n// `user-select: none` on the cells; blocking mousedown is the reliable cross-browser fix.\n// the start/end-date inputs must keep native mousedown behavior so they stay focusable/typable.\nconst preventCellSelection = (event: MouseEvent) => {\n\tif ((event.target as HTMLElement)?.tagName !== 'INPUT') {\n\t\tevent.preventDefault()\n\t}\n}\n\nconst populateMonth = () => {\n\t// The grid starts on the Monday on or before the 1st, matching the header's first column.\n\tconst gridStart = firstOfMonth.value.subtract({ days: firstOfMonth.value.dayOfWeek - 1 })\n\tcurrentDates.value = Array.from({ length: numberOfRows * numberOfColumns }, (_, cellIndex) =>\n\t\tgridStart.add({ days: cellIndex })\n\t)\n}\nconst previousYear = () => (currentYear.value -= 1)\nconst nextYear = () => (currentYear.value += 1)\n\nconst previousMonth = () => {\n\tif (currentMonth.value == 0) {\n\t\tcurrentMonth.value = 11\n\t\tpreviousYear()\n\t} else {\n\t\tcurrentMonth.value -= 1\n\t}\n}\n\nconst nextMonth = () => {\n\tif (currentMonth.value == 11) {\n\t\tcurrentMonth.value = 0\n\t\tnextYear()\n\t} else {\n\t\tcurrentMonth.value += 1\n\t}\n}\n\nconst enterDate = (event: KeyboardEvent) => {\n\tif (event.key === 'Enter') enterInputDate()\n}\n\n// The grid's keys move by day, not by table cell as `useKeyboardNav` does: that one can't cross into\n// another month, and on every cell it took the arrow keys from a range's typed-day boxes.\n/** The day a key moves focus to from `day`, or undefined for a key that moves nothing. */\nconst dayAfterKey = (event: KeyboardEvent, day: Temporal.PlainDate) => {\n\tswitch (event.key) {\n\t\tcase 'ArrowLeft':\n\t\t\treturn day.subtract({ days: 1 })\n\t\tcase 'ArrowRight':\n\t\t\treturn day.add({ days: 1 })\n\t\tcase 'ArrowUp':\n\t\t\treturn day.subtract({ weeks: 1 })\n\t\tcase 'ArrowDown':\n\t\t\treturn day.add({ weeks: 1 })\n\t\tcase 'PageUp':\n\t\t\treturn day.subtract(event.shiftKey ? { years: 1 } : { months: 1 })\n\t\tcase 'PageDown':\n\t\t\treturn day.add(event.shiftKey ? { years: 1 } : { months: 1 })\n\t\t// The grid's weeks run Monday, day 1, to Sunday, day 7.\n\t\tcase 'Home':\n\t\t\treturn day.subtract({ days: day.dayOfWeek - 1 })\n\t\tcase 'End':\n\t\t\treturn day.add({ days: 7 - day.dayOfWeek })\n\t}\n}\n\nconst focusTabStop = async () => {\n\tawait nextTick()\n\tgrid.value?.querySelector<HTMLElement>('[tabindex=\"0\"]')?.focus()\n}\n\nconst onDayKeydown = (event: KeyboardEvent, currentIndex: number) => {\n\tif (event.key === 'Enter' || event.key === ' ') {\n\t\tevent.preventDefault()\n\t\tselectDate(currentIndex)\n\t\treturn\n\t}\n\tconst next = dayAfterKey(event, focusedDay.value)\n\tif (!next) return\n\tevent.preventDefault()\n\tfocusedDay.value = next\n\tcurrentMonth.value = next.month - 1\n\tcurrentYear.value = next.year\n\tvoid focusTabStop()\n}\n\nconst selectDate = (currentIndex: number) => {\n\tconst picked = currentDates.value[currentIndex]\n\tselectedDate.value = picked\n\tfocusedDay.value = picked\n\t// A click leaves focus where it was, so focus follows a pick only when it is on a day already.\n\tif (document.activeElement instanceof HTMLTableCellElement && grid.value?.contains(document.activeElement)) {\n\t\tvoid focusTabStop()\n\t}\n\tdate.value = picked.toString()\n\n\tif (selectRange) {\n\t\tconst start = start_date.value\n\t\tif (start == null || end_date.value != null) {\n\t\t\tstart_date.value = picked\n\t\t\tend_date.value = null\n\t\t} else if (Temporal.PlainDate.compare(picked, start) < 0) {\n\t\t\tend_date.value = null\n\t\t\tstart_date.value = picked\n\t\t} else {\n\t\t\tend_date.value = picked\n\t\t}\n\t\tif (startDateInput.value) startDateInput.value.value = boxText(start_date.value)\n\t\tif (endDateInput.value) endDateInput.value.value = boxText(end_date.value)\n\t}\n\temitData()\n}\n\nconst testDateOrder = () => {\n\tconst start = start_date.value\n\tconst end = end_date.value\n\tif (start && end && Temporal.PlainDate.compare(end, start) < 0) [start_date.value, end_date.value] = [end, start]\n}\n\nconst enterInputDate = () => {\n\tif (startDateInput.value?.value == '') {\n\t\tstart_date.value = null\n\t} else if (startDateInput.value) {\n\t\tstart_date.value = readTypedDay(startDateInput.value.value) ?? null\n\t}\n\n\tif (endDateInput.value?.value == '') {\n\t\tend_date.value = null\n\t} else if (endDateInput.value) {\n\t\tend_date.value = readTypedDay(endDateInput.value.value) ?? null\n\t}\n\n\tif (start_date.value) {\n\t\tif (end_date.value) testDateOrder()\n\t\tselectedDate.value = start_date.value\n\t}\n\n\temitData()\n}\n\nconst emitData = () => {\n\temit('get-date', {\n\t\tstart: selectRange ? (start_date.value?.toString() ?? null) : null,\n\t\tend: selectRange ? (end_date.value?.toString() ?? null) : null,\n\t\tselected: selectedDate.value.toString(),\n\t})\n}\n\n/*******************\nHooks\n*******************/\n\n// The calendar takes no focus when it appears: a field opening it keeps focus in its box, where typing goes.\npopulateMonth()\n\n/*******************\nWatchers\n*******************/\n\nwatch([currentMonth, currentYear], () => {\n\tpopulateMonth()\n\t// The month buttons carry the Tab stop along, to the same day of the month shown.\n\tconst month = currentMonth.value + 1\n\tif (focusedDay.value.month !== month || focusedDay.value.year !== currentYear.value) {\n\t\tfocusedDay.value = focusedDay.value.with({ year: currentYear.value, month })\n\t}\n})\n\n// A day handed in, such as one typed into the field while the calendar is open. A pick here sets\n// `selectedDate` first, so picking a day of the next month in this grid leaves the month shown.\nwatch(date, value => {\n\tconst day = fromISODate(value ?? '')\n\tif (!day || day.equals(selectedDate.value)) return\n\tselectedDate.value = day\n\tfocusedDay.value = day\n\tcurrentMonth.value = day.month - 1\n\tcurrentYear.value = day.year\n})\n\n/*******************\nExpose\n*******************/\n\ndefineExpose({ currentMonth, currentYear, selectedDate: computed(() => selectedDate.value.toString()) })\n</script>\n\n<style scoped>\n.adatepicker,\n.adatepicker table,\n.adatepicker tr,\n.adatepicker td,\n.adatepicker th {\n\t-webkit-user-select: none;\n\t-moz-user-select: none;\n\tuser-select: none;\n}\n\n.adatepicker {\n\tfont-size: var(--sc-table-font-size);\n\tdisplay: inline-table;\n\tcolor: var(--sc-cell-text-color);\n\toutline: none;\n\tborder-collapse: collapse;\n\tmargin-bottom: 10px;\n\t/* width: calc(100% - 4px); */\n}\n\n.adatepicker tr {\n\theight: 1.15rem;\n\theight: 1.15rem;\n\ttext-align: center;\n\tvertical-align: middle;\n}\n\n.adatepicker td {\n\tborder: 2px solid transparent;\n\toutline: 2px solid transparent;\n\tmin-width: 3ch;\n\tmax-width: 3ch;\n\tcursor: pointer;\n}\n.adatepicker td.date-cell:hover {\n\tbackground: var(--sc-gray-10);\n}\n\n.adatepicker td.date-cell:focus-visible {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n\n.adatepicker td:focus,\n.adatepicker td:focus-within {\n\t/* outline: 1px dashed black; */\n\tbox-shadow: none;\n\toverflow: hidden;\n\tmin-height: 1.15em;\n\tmax-height: 1.15em;\n\toverflow: hidden;\n}\n.adatepicker .selectedDate,\n.adatepicker .startDate,\n.adatepicker .endDate {\n\t/* outline: 1px solid black; */\n\tbackground: var(--sc-gray-20);\n\tfont-weight: bolder;\n}\n.adatepicker .startDate {\n\t/* border-radius: 5px 0px 0px 5px; */\n\tborder-left: 1px solid var(--sc-gray-50);\n\tbackground: var(--sc-gray-20) !important;\n}\n.adatepicker .endDate {\n\tborder-right: 1px solid var(--sc-gray-50);\n\t/* border-radius: 0px 5px 5px 0px; */\n\tbackground: var(--sc-gray-20) !important;\n}\n.adatepicker .withinRange {\n\tbackground: var(--sc-gray-5);\n}\n\n.adatepicker .todaysDate {\n\tfont-weight: bolder;\n\t/* text-decoration: underline; */\n\tcolor: var(--sc-cell-text-color);\n}\n.days-header > td {\n\tfont-weight: bold;\n}\n.prev-date {\n\tcolor: var(--sc-gray-20);\n}\n\n.adatepicker .date-input {\n\tdisplay: flex;\n\twidth: 100%;\n\tgap: 5px;\n\talign-items: center;\n}\n/* The boxes' row widens the calendar past its 3ch day columns, so each box fits a day such as `04/09/2026`. */\n.adatepicker td.range-inputs {\n\tmax-width: none;\n}\n.adatepicker .date-input > input {\n\tflex: none;\n\twidth: 11ch;\n\tbox-sizing: border-box;\n\tpadding: 2px;\n}\n\n/* Keep the field error in-flow below the calendar. The shared .aform_error is absolutely\n positioned against a .aform_form-element anchor, which this grid component does not use. */\np.aform_error {\n\tposition: static;\n\tdisplay: block;\n\tcolor: var(--sc-brand-danger);\n\tfont-size: 0.7rem;\n\tmargin: 0.25rem 0 0;\n}\n</style>\n","<template>\n\t<template v-if=\"mode === 'display' || mode === 'read'\">\n\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t<label v-if=\"label\">{{ label }}</label>\n\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t</template>\n\t<template v-else>\n\t\t<div class=\"adatepicker\">\n\t\t\t<table ref=\"grid\" role=\"grid\" :aria-label=\"monthAndYear\" @mousedown=\"preventCellSelection\">\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td id=\"previous-month-btn\" :tabindex=\"-1\" @click=\"previousMonth\"><</td>\n\t\t\t\t\t\t<th colspan=\"5\" :tabindex=\"-1\">{{ monthAndYear }}</th>\n\t\t\t\t\t\t<td id=\"next-month-btn\" :tabindex=\"-1\" @click=\"nextMonth\">></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr v-if=\"selectRange\">\n\t\t\t\t\t\t<td colspan=\"7\" class=\"range-inputs\">\n\t\t\t\t\t\t\t<div class=\"date-input\">\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tref=\"start-date-input\"\n\t\t\t\t\t\t\t\t\t:value=\"getStartDate\"\n\t\t\t\t\t\t\t\t\tclass=\"date-input-start aform_input-field\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"start date\"\n\t\t\t\t\t\t\t\t\t@blur=\"enterInputDate()\"\n\t\t\t\t\t\t\t\t\t@keydown=\"enterDate\" />\n\t\t\t\t\t\t\t\t<div>-</div>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tref=\"end-date-input\"\n\t\t\t\t\t\t\t\t\t:value=\"getEndDate\"\n\t\t\t\t\t\t\t\t\tclass=\"date-input-end aform_input-field\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"end date\"\n\t\t\t\t\t\t\t\t\t@blur=\"enterInputDate()\"\n\t\t\t\t\t\t\t\t\t@keydown=\"enterDate\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<!-- {{ formattedDateRange }} -->\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class=\"days-header\">\n\t\t\t\t\t\t<td v-for=\"(letter, weekdayIndex) in weekdayLetters\" :key=\"weekdayIndex\">{{ letter }}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr v-for=\"rowNo in numberOfRows\" :key=\"rowNo\">\n\t\t\t\t\t\t<!-- the 'ref' key is currently only used for test references -->\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-for=\"colNo in numberOfColumns\"\n\t\t\t\t\t\t\tref=\"celldate\"\n\t\t\t\t\t\t\t:key=\"getCurrentCell(rowNo, colNo)\"\n\t\t\t\t\t\t\tclass=\"date-cell\"\n\t\t\t\t\t\t\t:contenteditable=\"false\"\n\t\t\t\t\t\t\t:spellcheck=\"false\"\n\t\t\t\t\t\t\t:tabindex=\"getCurrentDate(rowNo, colNo).equals(focusedDay) ? 0 : -1\"\n\t\t\t\t\t\t\t:aria-label=\"fullDate(getCurrentDate(rowNo, colNo))\"\n\t\t\t\t\t\t\t:aria-selected=\"isPicked(getCurrentDate(rowNo, colNo))\"\n\t\t\t\t\t\t\t:aria-current=\"isTodaysDate(getCurrentDate(rowNo, colNo)) ? 'date' : undefined\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\ttodaysDate: isTodaysDate(getCurrentDate(rowNo, colNo)),\n\t\t\t\t\t\t\t\tselectedDate: isSelectedDate(getCurrentDate(rowNo, colNo)),\n\t\t\t\t\t\t\t\twithinRange: selectRange ? isInDateRange(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t\tstartDate: selectRange ? isStartDate(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t\tendDate: selectRange ? isEndDate(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@click.prevent.stop=\"selectDate(getCurrentCell(rowNo, colNo))\"\n\t\t\t\t\t\t\t@keydown=\"onDayKeydown($event, getCurrentCell(rowNo, colNo))\"\n\t\t\t\t\t\t\t@mouseover=\"hoverDate(getCurrentCell(rowNo, colNo))\">\n\t\t\t\t\t\t\t{{ getCurrentDate(rowNo, colNo).day }}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t</template>\n</template>\n\n<script setup lang=\"ts\">\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { readTypedDay, writeTypedDay } from '../../utils/typedDay'\n\nconst numberOfRows = 6\nconst numberOfColumns = 7\n\nconst {\n\tmode,\n\tlabel,\n\tselectRange = false,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n} = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId } = fieldErrorA11y(uuid, errorText)\n\n// The calendar holds a `YYYY-MM-DD` day, and opens on today when it holds none it can read. No default\n// value: picking today on an empty calendar must still set it, and a model only reports a change.\nconst date = defineModel<string | null>()\nconst selectedDate = ref<Temporal.PlainDate>(fromISODate(date.value ?? '') ?? Temporal.Now.plainDateISO())\n// 0 for January.\nconst currentMonth = ref<number>(selectedDate.value.month - 1)\nconst currentYear = ref<number>(selectedDate.value.year)\nconst currentDates = ref<Temporal.PlainDate[]>([])\n\n// The day the grid's one Tab stop sits on, where its keys move from. It is always a day the grid shows.\nconst focusedDay = ref<Temporal.PlainDate>(selectedDate.value)\nconst grid = useTemplateRef<HTMLTableElement>('grid')\n\nconst hoveredDate = ref<Temporal.PlainDate>(selectedDate.value)\nconst start_date = ref<Temporal.PlainDate | null>(null)\nconst end_date = ref<Temporal.PlainDate | null>(null)\nconst startDateInput = useTemplateRef<HTMLInputElement>('start-date-input')\nconst endDateInput = useTemplateRef<HTMLInputElement>('end-date-input')\n\n/*******************\nEmits\n*******************/\n\nconst emit = defineEmits<{\n\t'get-date': [{ start: string | null; end: string | null; selected: string }]\n}>()\n\n/*******************\nComputed\n*******************/\n\nconst displayValue = computed(() => (date.value ? (fromISODate(date.value)?.toLocaleString() ?? 'Invalid Date') : ''))\n\nconst firstOfMonth = computed(() =>\n\tTemporal.PlainDate.from({ year: currentYear.value, month: currentMonth.value + 1, day: 1 })\n)\n\n// Not a `PlainYearMonth`: its `toLocaleString` throws for the ISO calendar.\nconst monthAndYear = computed(() => firstOfMonth.value.toLocaleString(undefined, { year: 'numeric', month: 'long' }))\n\n// The grid's first week, so the letters follow its Monday start.\nconst weekdayLetters = computed(() =>\n\tcurrentDates.value.slice(0, numberOfColumns).map(day => day.toLocaleString(undefined, { weekday: 'narrow' }))\n)\n\nconst getStartDate = computed(() => boxText(start_date.value))\n\nconst getEndDate = computed(() => boxText(end_date.value))\n\n/*******************\nFunctions\n*******************/\n\nconst boxText = (day: Temporal.PlainDate | null) => (day ? writeTypedDay(day) : '')\n\nconst isTodaysDate = (day: Temporal.PlainDate): boolean => {\n\tconst today = Temporal.Now.plainDateISO()\n\tif (currentMonth.value !== today.month - 1) return false\n\treturn day.equals(today)\n}\n\nconst isSelectedDate = (day: Temporal.PlainDate) => {\n\treturn day.equals(selectedDate.value)\n}\n\nconst isStartDate = (day: Temporal.PlainDate) => {\n\treturn start_date.value !== null && day.equals(start_date.value)\n}\n\nconst isEndDate = (day: Temporal.PlainDate) => {\n\treturn end_date.value !== null && day.equals(end_date.value)\n}\n\n// Every day the calendar marks as picked, so a screen reader hears the same days marked.\nconst isPicked = (day: Temporal.PlainDate) =>\n\tisSelectedDate(day) || (selectRange && (isStartDate(day) || isEndDate(day)))\n\nconst fullDate = (day: Temporal.PlainDate) =>\n\tday.toLocaleString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })\n\nconst getCurrentCell = (rowNo: number, colNo: number) => {\n\treturn (rowNo - 1) * numberOfColumns + colNo - 1\n}\n\nconst isInDateRange = (day: Temporal.PlainDate) => {\n\tconst start = start_date.value\n\tif (!start) return false\n\n\t//the end is either the selected end date or wherever the user is hovering\n\tconst end = end_date.value ?? hoveredDate.value\n\n\treturn Temporal.PlainDate.compare(day, start) > 0 && Temporal.PlainDate.compare(day, end) < 0\n}\n\nconst getCurrentDate = (rowNo: number, colNo: number) => {\n\treturn currentDates.value[getCurrentCell(rowNo, colNo)]\n}\n\nconst hoverDate = (currentIndex: number) => {\n\thoveredDate.value = currentDates.value[currentIndex]\n}\n\n// browsers (notably Firefox) allow drag-selecting text across table cells even with\n// `user-select: none` on the cells; blocking mousedown is the reliable cross-browser fix.\n// the start/end-date inputs must keep native mousedown behavior so they stay focusable/typable.\nconst preventCellSelection = (event: MouseEvent) => {\n\tif ((event.target as HTMLElement)?.tagName !== 'INPUT') {\n\t\tevent.preventDefault()\n\t}\n}\n\nconst populateMonth = () => {\n\t// The grid starts on the Monday on or before the 1st, matching the header's first column.\n\tconst gridStart = firstOfMonth.value.subtract({ days: firstOfMonth.value.dayOfWeek - 1 })\n\tcurrentDates.value = Array.from({ length: numberOfRows * numberOfColumns }, (_, cellIndex) =>\n\t\tgridStart.add({ days: cellIndex })\n\t)\n}\nconst previousYear = () => (currentYear.value -= 1)\nconst nextYear = () => (currentYear.value += 1)\n\nconst previousMonth = () => {\n\tif (currentMonth.value == 0) {\n\t\tcurrentMonth.value = 11\n\t\tpreviousYear()\n\t} else {\n\t\tcurrentMonth.value -= 1\n\t}\n}\n\nconst nextMonth = () => {\n\tif (currentMonth.value == 11) {\n\t\tcurrentMonth.value = 0\n\t\tnextYear()\n\t} else {\n\t\tcurrentMonth.value += 1\n\t}\n}\n\nconst enterDate = (event: KeyboardEvent) => {\n\tif (event.key === 'Enter') enterInputDate()\n}\n\n// The grid's keys move by day, not by table cell as `useKeyboardNav` does: that one can't cross into\n// another month, and on every cell it took the arrow keys from a range's typed-day boxes.\n/** The day a key moves focus to from `day`, or undefined for a key that moves nothing. */\nconst dayAfterKey = (event: KeyboardEvent, day: Temporal.PlainDate) => {\n\tswitch (event.key) {\n\t\tcase 'ArrowLeft':\n\t\t\treturn day.subtract({ days: 1 })\n\t\tcase 'ArrowRight':\n\t\t\treturn day.add({ days: 1 })\n\t\tcase 'ArrowUp':\n\t\t\treturn day.subtract({ weeks: 1 })\n\t\tcase 'ArrowDown':\n\t\t\treturn day.add({ weeks: 1 })\n\t\tcase 'PageUp':\n\t\t\treturn day.subtract(event.shiftKey ? { years: 1 } : { months: 1 })\n\t\tcase 'PageDown':\n\t\t\treturn day.add(event.shiftKey ? { years: 1 } : { months: 1 })\n\t\t// The grid's weeks run Monday, day 1, to Sunday, day 7.\n\t\tcase 'Home':\n\t\t\treturn day.subtract({ days: day.dayOfWeek - 1 })\n\t\tcase 'End':\n\t\t\treturn day.add({ days: 7 - day.dayOfWeek })\n\t}\n}\n\nconst focusTabStop = async () => {\n\tawait nextTick()\n\tgrid.value?.querySelector<HTMLElement>('[tabindex=\"0\"]')?.focus()\n}\n\nconst onDayKeydown = (event: KeyboardEvent, currentIndex: number) => {\n\tif (event.key === 'Enter' || event.key === ' ') {\n\t\tevent.preventDefault()\n\t\tselectDate(currentIndex)\n\t\treturn\n\t}\n\tconst next = dayAfterKey(event, focusedDay.value)\n\tif (!next) return\n\tevent.preventDefault()\n\tfocusedDay.value = next\n\tcurrentMonth.value = next.month - 1\n\tcurrentYear.value = next.year\n\tvoid focusTabStop()\n}\n\nconst selectDate = (currentIndex: number) => {\n\tconst picked = currentDates.value[currentIndex]\n\tselectedDate.value = picked\n\tfocusedDay.value = picked\n\t// A click leaves focus where it was, so focus follows a pick only when it is on a day already.\n\tif (document.activeElement instanceof HTMLTableCellElement && grid.value?.contains(document.activeElement)) {\n\t\tvoid focusTabStop()\n\t}\n\tdate.value = picked.toString()\n\n\tif (selectRange) {\n\t\tconst start = start_date.value\n\t\tif (start == null || end_date.value != null) {\n\t\t\tstart_date.value = picked\n\t\t\tend_date.value = null\n\t\t} else if (Temporal.PlainDate.compare(picked, start) < 0) {\n\t\t\tend_date.value = null\n\t\t\tstart_date.value = picked\n\t\t} else {\n\t\t\tend_date.value = picked\n\t\t}\n\t\tif (startDateInput.value) startDateInput.value.value = boxText(start_date.value)\n\t\tif (endDateInput.value) endDateInput.value.value = boxText(end_date.value)\n\t}\n\temitData()\n}\n\nconst testDateOrder = () => {\n\tconst start = start_date.value\n\tconst end = end_date.value\n\tif (start && end && Temporal.PlainDate.compare(end, start) < 0) [start_date.value, end_date.value] = [end, start]\n}\n\nconst enterInputDate = () => {\n\tif (startDateInput.value?.value == '') {\n\t\tstart_date.value = null\n\t} else if (startDateInput.value) {\n\t\tstart_date.value = readTypedDay(startDateInput.value.value) ?? null\n\t}\n\n\tif (endDateInput.value?.value == '') {\n\t\tend_date.value = null\n\t} else if (endDateInput.value) {\n\t\tend_date.value = readTypedDay(endDateInput.value.value) ?? null\n\t}\n\n\tif (start_date.value) {\n\t\tif (end_date.value) testDateOrder()\n\t\tselectedDate.value = start_date.value\n\t}\n\n\temitData()\n}\n\nconst emitData = () => {\n\temit('get-date', {\n\t\tstart: selectRange ? (start_date.value?.toString() ?? null) : null,\n\t\tend: selectRange ? (end_date.value?.toString() ?? null) : null,\n\t\tselected: selectedDate.value.toString(),\n\t})\n}\n\n/*******************\nHooks\n*******************/\n\n// The calendar takes no focus when it appears: a field opening it keeps focus in its box, where typing goes.\npopulateMonth()\n\n/*******************\nWatchers\n*******************/\n\nwatch([currentMonth, currentYear], () => {\n\tpopulateMonth()\n\t// The month buttons carry the Tab stop along, to the same day of the month shown.\n\tconst month = currentMonth.value + 1\n\tif (focusedDay.value.month !== month || focusedDay.value.year !== currentYear.value) {\n\t\tfocusedDay.value = focusedDay.value.with({ year: currentYear.value, month })\n\t}\n})\n\n// A day handed in, such as one typed into the field while the calendar is open. A pick here sets\n// `selectedDate` first, so picking a day of the next month in this grid leaves the month shown.\nwatch(date, value => {\n\tconst day = fromISODate(value ?? '')\n\tif (!day || day.equals(selectedDate.value)) return\n\tselectedDate.value = day\n\tfocusedDay.value = day\n\tcurrentMonth.value = day.month - 1\n\tcurrentYear.value = day.year\n})\n\n/*******************\nExpose\n*******************/\n\ndefineExpose({ currentMonth, currentYear, selectedDate: computed(() => selectedDate.value.toString()) })\n</script>\n\n<style scoped>\n.adatepicker,\n.adatepicker table,\n.adatepicker tr,\n.adatepicker td,\n.adatepicker th {\n\t-webkit-user-select: none;\n\t-moz-user-select: none;\n\tuser-select: none;\n}\n\n.adatepicker {\n\tfont-size: var(--sc-table-font-size);\n\tdisplay: inline-table;\n\tcolor: var(--sc-cell-text-color);\n\toutline: none;\n\tborder-collapse: collapse;\n\tmargin-bottom: 10px;\n\t/* width: calc(100% - 4px); */\n}\n\n.adatepicker tr {\n\theight: 1.15rem;\n\theight: 1.15rem;\n\ttext-align: center;\n\tvertical-align: middle;\n}\n\n.adatepicker td {\n\tborder: 2px solid transparent;\n\toutline: 2px solid transparent;\n\tmin-width: 3ch;\n\tmax-width: 3ch;\n\tcursor: pointer;\n}\n.adatepicker td.date-cell:hover {\n\tbackground: var(--sc-gray-10);\n}\n\n.adatepicker td.date-cell:focus-visible {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n\n.adatepicker td:focus,\n.adatepicker td:focus-within {\n\t/* outline: 1px dashed black; */\n\tbox-shadow: none;\n\toverflow: hidden;\n\tmin-height: 1.15em;\n\tmax-height: 1.15em;\n\toverflow: hidden;\n}\n.adatepicker .selectedDate,\n.adatepicker .startDate,\n.adatepicker .endDate {\n\t/* outline: 1px solid black; */\n\tbackground: var(--sc-gray-20);\n\tfont-weight: bolder;\n}\n.adatepicker .startDate {\n\t/* border-radius: 5px 0px 0px 5px; */\n\tborder-left: 1px solid var(--sc-gray-50);\n\tbackground: var(--sc-gray-20) !important;\n}\n.adatepicker .endDate {\n\tborder-right: 1px solid var(--sc-gray-50);\n\t/* border-radius: 0px 5px 5px 0px; */\n\tbackground: var(--sc-gray-20) !important;\n}\n.adatepicker .withinRange {\n\tbackground: var(--sc-gray-5);\n}\n\n.adatepicker .todaysDate {\n\tfont-weight: bolder;\n\t/* text-decoration: underline; */\n\tcolor: var(--sc-cell-text-color);\n}\n.days-header > td {\n\tfont-weight: bold;\n}\n.prev-date {\n\tcolor: var(--sc-gray-20);\n}\n\n.adatepicker .date-input {\n\tdisplay: flex;\n\twidth: 100%;\n\tgap: 5px;\n\talign-items: center;\n}\n/* The boxes' row widens the calendar past its 3ch day columns, so each box fits a day such as `04/09/2026`. */\n.adatepicker td.range-inputs {\n\tmax-width: none;\n}\n.adatepicker .date-input > input {\n\tflex: none;\n\twidth: 11ch;\n\tbox-sizing: border-box;\n\tpadding: 2px;\n}\n\n/* Keep the field error in-flow below the calendar. The shared .aform_error is absolutely\n positioned against a .aform_form-element anchor, which this grid component does not use. */\np.aform_error {\n\tposition: static;\n\tdisplay: block;\n\tcolor: var(--sc-brand-danger);\n\tfont-size: 0.7rem;\n\tmargin: 0.25rem 0 0;\n}\n</style>\n","<template>\n\t<div class=\"adate_time\">\n\t\t<div class=\"adate_time_fields\">\n\t\t\t<input\n\t\t\t\tv-model=\"timeData.hours\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput($event, true)\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('hours')\"\n\t\t\t\t@keydown.down.prevent=\"tick('hours', -1)\" />\n\t\t\t<span class=\"colon\">:</span>\n\t\t\t<input\n\t\t\t\tv-model=\"timeData.minutes\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('minutes')\"\n\t\t\t\t@keydown.down.prevent=\"tick('minutes', -1)\" />\n\t\t\t<span v-if=\"useSeconds\" class=\"colon\">:</span>\n\t\t\t<input\n\t\t\t\tv-if=\"useSeconds\"\n\t\t\t\tv-model=\"timeData.seconds\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('seconds')\"\n\t\t\t\t@keydown.down.prevent=\"tick('seconds', -1)\" />\n\t\t\t<select\n\t\t\t\tv-if=\"!allowMilitaryTime\"\n\t\t\t\tref=\"meridiem-selector\"\n\t\t\t\tv-model=\"meridiem\"\n\t\t\t\tclass=\"aform-select meridiem-selector\"\n\t\t\t\t@change=\"confirmTime\">\n\t\t\t\t<option value=\"AM\">AM</option>\n\t\t\t\t<option value=\"PM\">PM</option>\n\t\t\t</select>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, reactive, useTemplateRef, watch, onMounted } from 'vue'\n\nconst {\n\tallowMilitaryTime = false,\n\tdefaultHours = 12,\n\tdefaultMinutes = 0,\n\tdefaultSeconds = 0,\n\tdefaultMeridiem = 'AM',\n\tuseSeconds = true,\n} = defineProps<{\n\tallowMilitaryTime?: boolean\n\tdefaultHours?: number\n\tdefaultMinutes?: number\n\tdefaultSeconds?: number\n\tdefaultMeridiem?: string\n\tuseSeconds?: boolean\n}>()\n\n// `get-time` carries the widget's CURRENT VALUE, not a commit: it fires once as the widget\n// mounts and again on every blur, Enter, arrow key and meridiem change — five times during one\n// ordinary edit. `source` is what lets a parent tell the start-up announcement apart from a real\n// user edit; without it a parent has nothing to key on and must guess from the value alone.\nconst emit = defineEmits<{\n\t'get-time': [\n\t\t{\n\t\t\thours: number\n\t\t\tminutes: number\n\t\t\tseconds: number\n\t\t\tmeridiem: string\n\t\t\tmilitaryTime: number\n\t\t\tsource: 'init' | 'user'\n\t\t},\n\t]\n}>()\n\nconst meridiemSelector = useTemplateRef<HTMLSelectElement>('meridiem-selector')\n\nconst timeData = reactive({\n\thours: String(defaultHours).padStart(2, '0'),\n\tminutes: String(defaultMinutes).padStart(2, '0'),\n\tseconds: String(defaultSeconds).padStart(2, '0'),\n})\n\nconst meridiem = ref(defaultMeridiem == 'AM' ? 'AM' : 'PM')\n\nonMounted(() => {\n\temitTime('init')\n})\n\nconst confirmTime = () => {\n\tconst maxHours = allowMilitaryTime ? 23 : 12\n\tconst minHours = allowMilitaryTime ? 0 : 1\n\tlet hours = Number(timeData.hours)\n\tlet minutes = Number(timeData.minutes)\n\tlet seconds = Number(timeData.seconds)\n\n\tif (isNaN(hours) || timeData.hours === '' || hours > maxHours) hours = maxHours\n\tif (!allowMilitaryTime && hours < minHours) hours = minHours\n\tif (isNaN(minutes) || timeData.minutes === '' || minutes > 59) minutes = 59\n\tif (isNaN(seconds) || timeData.seconds === '' || seconds > 59) seconds = 59\n\n\ttimeData.hours = String(hours).padStart(2, '0')\n\ttimeData.minutes = String(minutes).padStart(2, '0')\n\ttimeData.seconds = String(seconds).padStart(2, '0')\n\n\temitTime('user')\n}\n\nconst emitTime = (source: 'init' | 'user') => {\n\tconst hours = Number(timeData.hours)\n\tconst minutes = Number(timeData.minutes)\n\tconst seconds = Number(timeData.seconds)\n\temit('get-time', {\n\t\thours,\n\t\tminutes,\n\t\tseconds,\n\t\tsource,\n\t\tmeridiem: meridiem.value,\n\t\tmilitaryTime: allowMilitaryTime ? hours : meridiem.value === 'PM' ? (hours === 12 ? 12 : hours + 12) : hours % 12,\n\t})\n}\n\nconst focusInput = (event: FocusEvent) => {\n\tconst target = event.target\n\tif (target instanceof HTMLInputElement) {\n\t\ttarget.select()\n\t}\n}\n\nconst tick = (target: 'hours' | 'minutes' | 'seconds', amount = 1) => {\n\tconst maxHours = allowMilitaryTime ? 23 : 12\n\tconst minHours = allowMilitaryTime ? 0 : 1\n\n\tif (target == 'hours') {\n\t\tconst oldHours = Number(timeData.hours)\n\t\ttimeData.hours = String(oldHours + amount)\n\t\tif ((oldHours == 11 && Number(timeData.hours) == 12) || (oldHours == 12 && Number(timeData.hours) == 11)) {\n\t\t\tchangeMeridiem()\n\t\t}\n\t} else if (target == 'minutes') {\n\t\ttimeData.minutes = String(Number(timeData.minutes) + amount)\n\t} else if (target == 'seconds') {\n\t\ttimeData.seconds = String(Number(timeData.seconds) + amount)\n\t}\n\n\tconst prevHours = Number(timeData.hours)\n\n\tif (Number(timeData.seconds) < 0) timeData.minutes = String(Number(timeData.minutes) - 1)\n\telse if (Number(timeData.seconds) > 59) timeData.minutes = String(Number(timeData.minutes) + 1)\n\n\tif (Number(timeData.minutes) < 0) timeData.hours = String(prevHours - 1)\n\telse if (Number(timeData.minutes) > 59) timeData.hours = String(prevHours + 1)\n\n\tconst newRawHours = Number(timeData.hours)\n\tif (!allowMilitaryTime && newRawHours !== prevHours) {\n\t\tif ((prevHours === 11 && newRawHours === 12) || (prevHours === 12 && newRawHours === 11)) {\n\t\t\tchangeMeridiem()\n\t\t}\n\t}\n\n\ttimeData.hours = String(formatTime(Number(timeData.hours), minHours, maxHours)).padStart(2, '0')\n\ttimeData.minutes = String(formatTime(Number(timeData.minutes), 0, 59)).padStart(2, '0')\n\ttimeData.seconds = String(formatTime(Number(timeData.seconds), 0, 59)).padStart(2, '0')\n}\n\nwatch(\n\t() => timeData.hours,\n\t(newVal, oldVal) => {\n\t\ttimeData.hours = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\nwatch(\n\t() => timeData.minutes,\n\t(newVal, oldVal) => {\n\t\ttimeData.minutes = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\nwatch(\n\t() => timeData.seconds,\n\t(newVal, oldVal) => {\n\t\ttimeData.seconds = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\n\nconst formatTime = (target: number, min: number, max: number): number => {\n\tif (target > max) return min\n\telse if (target < min) return max\n\treturn target\n}\n\nconst changeMeridiem = () => {\n\tmeridiem.value = meridiem.value == 'PM' ? 'AM' : 'PM'\n\temitTime('user')\n}\n\nconst pasteInput = (event: ClipboardEvent, pasteAllFields = false) => {\n\tevent.stopPropagation()\n\tevent.preventDefault()\n\n\tconst clipboardData = event.clipboardData\n\tif (!clipboardData) return\n\tlet pastedData: string = clipboardData.getData('Text')\n\n\tpastedData = pastedData.replace(/[^0-9]/g, '')\n\n\tif (pasteAllFields) {\n\t\tif (pastedData.length % 2 != 0) pastedData = '0' + pastedData\n\t\tif (pastedData.length < 3) pastedData += '00'\n\t\tif (pastedData.length < 5) pastedData += '00'\n\n\t\tconst timeUnits = pastedData.match(/(..?)/g)\n\t\tif (!timeUnits || timeUnits.length < 3) return\n\n\t\ttimeData.seconds = timeUnits[2]\n\t\ttimeData.minutes = timeUnits[1]\n\t\ttimeData.hours = timeUnits[0]\n\t\tconfirmTime()\n\t\tif (!allowMilitaryTime) meridiemSelector.value?.focus()\n\t} else {\n\t\tif (pastedData.length > 2) pastedData = pastedData.slice(0, 2)\n\t\tconst target = event.target\n\t\tif (target instanceof HTMLInputElement) {\n\t\t\ttarget.value = pastedData\n\t\t\ttarget.dispatchEvent(new Event('input'))\n\t\t}\n\t}\n}\n</script>\n\n<style scoped>\n.adate_time {\n\twidth: auto;\n\tpadding: 10px;\n\tbox-sizing: border-box;\n\tfont-size: 1rem;\n\tbackground: var(--sc-input-field-background);\n}\n.adate_time_fields {\n\tdisplay: flex;\n\talign-items: stretch;\n\tgap: 5px;\n\tjustify-content: flex-start;\n}\n.adate_time_fields > input {\n\twidth: 2.5rem;\n\tmin-width: 2.5rem;\n\tflex: 0 0 auto;\n\tpadding: 0.25rem 0.15rem;\n\ttext-align: center;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-cell-text-color);\n\tborder-radius: var(--sc-border-radius);\n}\n.adate_time_fields > input:focus,\n.meridiem-selector:focus {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n.meridiem-selector {\n\tflex: 0 0 auto;\n\twidth: auto;\n\tmin-width: 5.5rem;\n\tmargin-left: 6px;\n\tpadding: 0.25rem 1.75rem 0.25rem 0.5rem;\n\tcursor: pointer;\n\tuser-select: none;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-cell-text-color);\n\tborder-radius: var(--sc-border-radius);\n\tfont-size: 1rem;\n}\n.adate_time_segment {\n\tdisplay: flex;\n\tflex-direction: column;\n\twidth: 40px;\n}\n.colon {\n\tdisplay: flex;\n\talign-items: normal;\n}\n.aform_form-btn {\n\tcursor: pointer;\n}\n.aform-select {\n\tbox-sizing: border-box;\n\tmin-height: auto;\n}\n</style>\n","<template>\n\t<div class=\"adate_time\">\n\t\t<div class=\"adate_time_fields\">\n\t\t\t<input\n\t\t\t\tv-model=\"timeData.hours\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput($event, true)\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('hours')\"\n\t\t\t\t@keydown.down.prevent=\"tick('hours', -1)\" />\n\t\t\t<span class=\"colon\">:</span>\n\t\t\t<input\n\t\t\t\tv-model=\"timeData.minutes\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('minutes')\"\n\t\t\t\t@keydown.down.prevent=\"tick('minutes', -1)\" />\n\t\t\t<span v-if=\"useSeconds\" class=\"colon\">:</span>\n\t\t\t<input\n\t\t\t\tv-if=\"useSeconds\"\n\t\t\t\tv-model=\"timeData.seconds\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('seconds')\"\n\t\t\t\t@keydown.down.prevent=\"tick('seconds', -1)\" />\n\t\t\t<select\n\t\t\t\tv-if=\"!allowMilitaryTime\"\n\t\t\t\tref=\"meridiem-selector\"\n\t\t\t\tv-model=\"meridiem\"\n\t\t\t\tclass=\"aform-select meridiem-selector\"\n\t\t\t\t@change=\"confirmTime\">\n\t\t\t\t<option value=\"AM\">AM</option>\n\t\t\t\t<option value=\"PM\">PM</option>\n\t\t\t</select>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, reactive, useTemplateRef, watch, onMounted } from 'vue'\n\nconst {\n\tallowMilitaryTime = false,\n\tdefaultHours = 12,\n\tdefaultMinutes = 0,\n\tdefaultSeconds = 0,\n\tdefaultMeridiem = 'AM',\n\tuseSeconds = true,\n} = defineProps<{\n\tallowMilitaryTime?: boolean\n\tdefaultHours?: number\n\tdefaultMinutes?: number\n\tdefaultSeconds?: number\n\tdefaultMeridiem?: string\n\tuseSeconds?: boolean\n}>()\n\n// `get-time` carries the widget's CURRENT VALUE, not a commit: it fires once as the widget\n// mounts and again on every blur, Enter, arrow key and meridiem change — five times during one\n// ordinary edit. `source` is what lets a parent tell the start-up announcement apart from a real\n// user edit; without it a parent has nothing to key on and must guess from the value alone.\nconst emit = defineEmits<{\n\t'get-time': [\n\t\t{\n\t\t\thours: number\n\t\t\tminutes: number\n\t\t\tseconds: number\n\t\t\tmeridiem: string\n\t\t\tmilitaryTime: number\n\t\t\tsource: 'init' | 'user'\n\t\t},\n\t]\n}>()\n\nconst meridiemSelector = useTemplateRef<HTMLSelectElement>('meridiem-selector')\n\nconst timeData = reactive({\n\thours: String(defaultHours).padStart(2, '0'),\n\tminutes: String(defaultMinutes).padStart(2, '0'),\n\tseconds: String(defaultSeconds).padStart(2, '0'),\n})\n\nconst meridiem = ref(defaultMeridiem == 'AM' ? 'AM' : 'PM')\n\nonMounted(() => {\n\temitTime('init')\n})\n\nconst confirmTime = () => {\n\tconst maxHours = allowMilitaryTime ? 23 : 12\n\tconst minHours = allowMilitaryTime ? 0 : 1\n\tlet hours = Number(timeData.hours)\n\tlet minutes = Number(timeData.minutes)\n\tlet seconds = Number(timeData.seconds)\n\n\tif (isNaN(hours) || timeData.hours === '' || hours > maxHours) hours = maxHours\n\tif (!allowMilitaryTime && hours < minHours) hours = minHours\n\tif (isNaN(minutes) || timeData.minutes === '' || minutes > 59) minutes = 59\n\tif (isNaN(seconds) || timeData.seconds === '' || seconds > 59) seconds = 59\n\n\ttimeData.hours = String(hours).padStart(2, '0')\n\ttimeData.minutes = String(minutes).padStart(2, '0')\n\ttimeData.seconds = String(seconds).padStart(2, '0')\n\n\temitTime('user')\n}\n\nconst emitTime = (source: 'init' | 'user') => {\n\tconst hours = Number(timeData.hours)\n\tconst minutes = Number(timeData.minutes)\n\tconst seconds = Number(timeData.seconds)\n\temit('get-time', {\n\t\thours,\n\t\tminutes,\n\t\tseconds,\n\t\tsource,\n\t\tmeridiem: meridiem.value,\n\t\tmilitaryTime: allowMilitaryTime ? hours : meridiem.value === 'PM' ? (hours === 12 ? 12 : hours + 12) : hours % 12,\n\t})\n}\n\nconst focusInput = (event: FocusEvent) => {\n\tconst target = event.target\n\tif (target instanceof HTMLInputElement) {\n\t\ttarget.select()\n\t}\n}\n\nconst tick = (target: 'hours' | 'minutes' | 'seconds', amount = 1) => {\n\tconst maxHours = allowMilitaryTime ? 23 : 12\n\tconst minHours = allowMilitaryTime ? 0 : 1\n\n\tif (target == 'hours') {\n\t\tconst oldHours = Number(timeData.hours)\n\t\ttimeData.hours = String(oldHours + amount)\n\t\tif ((oldHours == 11 && Number(timeData.hours) == 12) || (oldHours == 12 && Number(timeData.hours) == 11)) {\n\t\t\tchangeMeridiem()\n\t\t}\n\t} else if (target == 'minutes') {\n\t\ttimeData.minutes = String(Number(timeData.minutes) + amount)\n\t} else if (target == 'seconds') {\n\t\ttimeData.seconds = String(Number(timeData.seconds) + amount)\n\t}\n\n\tconst prevHours = Number(timeData.hours)\n\n\tif (Number(timeData.seconds) < 0) timeData.minutes = String(Number(timeData.minutes) - 1)\n\telse if (Number(timeData.seconds) > 59) timeData.minutes = String(Number(timeData.minutes) + 1)\n\n\tif (Number(timeData.minutes) < 0) timeData.hours = String(prevHours - 1)\n\telse if (Number(timeData.minutes) > 59) timeData.hours = String(prevHours + 1)\n\n\tconst newRawHours = Number(timeData.hours)\n\tif (!allowMilitaryTime && newRawHours !== prevHours) {\n\t\tif ((prevHours === 11 && newRawHours === 12) || (prevHours === 12 && newRawHours === 11)) {\n\t\t\tchangeMeridiem()\n\t\t}\n\t}\n\n\ttimeData.hours = String(formatTime(Number(timeData.hours), minHours, maxHours)).padStart(2, '0')\n\ttimeData.minutes = String(formatTime(Number(timeData.minutes), 0, 59)).padStart(2, '0')\n\ttimeData.seconds = String(formatTime(Number(timeData.seconds), 0, 59)).padStart(2, '0')\n}\n\nwatch(\n\t() => timeData.hours,\n\t(newVal, oldVal) => {\n\t\ttimeData.hours = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\nwatch(\n\t() => timeData.minutes,\n\t(newVal, oldVal) => {\n\t\ttimeData.minutes = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\nwatch(\n\t() => timeData.seconds,\n\t(newVal, oldVal) => {\n\t\ttimeData.seconds = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\n\nconst formatTime = (target: number, min: number, max: number): number => {\n\tif (target > max) return min\n\telse if (target < min) return max\n\treturn target\n}\n\nconst changeMeridiem = () => {\n\tmeridiem.value = meridiem.value == 'PM' ? 'AM' : 'PM'\n\temitTime('user')\n}\n\nconst pasteInput = (event: ClipboardEvent, pasteAllFields = false) => {\n\tevent.stopPropagation()\n\tevent.preventDefault()\n\n\tconst clipboardData = event.clipboardData\n\tif (!clipboardData) return\n\tlet pastedData: string = clipboardData.getData('Text')\n\n\tpastedData = pastedData.replace(/[^0-9]/g, '')\n\n\tif (pasteAllFields) {\n\t\tif (pastedData.length % 2 != 0) pastedData = '0' + pastedData\n\t\tif (pastedData.length < 3) pastedData += '00'\n\t\tif (pastedData.length < 5) pastedData += '00'\n\n\t\tconst timeUnits = pastedData.match(/(..?)/g)\n\t\tif (!timeUnits || timeUnits.length < 3) return\n\n\t\ttimeData.seconds = timeUnits[2]\n\t\ttimeData.minutes = timeUnits[1]\n\t\ttimeData.hours = timeUnits[0]\n\t\tconfirmTime()\n\t\tif (!allowMilitaryTime) meridiemSelector.value?.focus()\n\t} else {\n\t\tif (pastedData.length > 2) pastedData = pastedData.slice(0, 2)\n\t\tconst target = event.target\n\t\tif (target instanceof HTMLInputElement) {\n\t\t\ttarget.value = pastedData\n\t\t\ttarget.dispatchEvent(new Event('input'))\n\t\t}\n\t}\n}\n</script>\n\n<style scoped>\n.adate_time {\n\twidth: auto;\n\tpadding: 10px;\n\tbox-sizing: border-box;\n\tfont-size: 1rem;\n\tbackground: var(--sc-input-field-background);\n}\n.adate_time_fields {\n\tdisplay: flex;\n\talign-items: stretch;\n\tgap: 5px;\n\tjustify-content: flex-start;\n}\n.adate_time_fields > input {\n\twidth: 2.5rem;\n\tmin-width: 2.5rem;\n\tflex: 0 0 auto;\n\tpadding: 0.25rem 0.15rem;\n\ttext-align: center;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-cell-text-color);\n\tborder-radius: var(--sc-border-radius);\n}\n.adate_time_fields > input:focus,\n.meridiem-selector:focus {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n.meridiem-selector {\n\tflex: 0 0 auto;\n\twidth: auto;\n\tmin-width: 5.5rem;\n\tmargin-left: 6px;\n\tpadding: 0.25rem 1.75rem 0.25rem 0.5rem;\n\tcursor: pointer;\n\tuser-select: none;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-cell-text-color);\n\tborder-radius: var(--sc-border-radius);\n\tfont-size: 1rem;\n}\n.adate_time_segment {\n\tdisplay: flex;\n\tflex-direction: column;\n\twidth: 40px;\n}\n.colon {\n\tdisplay: flex;\n\talign-items: normal;\n}\n.aform_form-btn {\n\tcursor: pointer;\n}\n.aform-select {\n\tbox-sizing: border-box;\n\tmin-height: auto;\n}\n</style>\n","<!-- This serves as a wrapper component for ADatePicker and ADateTimeInput in one component -->\n\n<template>\n\t<div class=\"adate-selection\">\n\t\t<ADatePicker v-if=\"showDate\" :model-value=\"defaultDate\" :select-range=\"selectRange\" @get-date=\"handleDate\" />\n\n\t\t<ADateTimeInput\n\t\t\tv-if=\"showTime\"\n\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t:default-hours=\"defaultHours\"\n\t\t\t:default-minutes=\"defaultMinutes\"\n\t\t\t:default-seconds=\"defaultSeconds\"\n\t\t\t:default-meridiem=\"defaultMeridiem\"\n\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t@get-time=\"handleStartTime\" />\n\n\t\t<template v-if=\"selectRange && showTime && showEndTime\">\n\t\t\t<div class=\"adate-selection__end-label\">End time</div>\n\t\t\t<ADateTimeInput\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:default-hours=\"defaultHours\"\n\t\t\t\t:default-minutes=\"defaultMinutes\"\n\t\t\t\t:default-seconds=\"defaultSeconds\"\n\t\t\t\t:default-meridiem=\"defaultMeridiem\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-time=\"handleEndTime\" />\n\t\t</template>\n\n\t\t<p v-if=\"!showTime && !showDate\" class=\"empty\">empty</p>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport { provide, ref } from 'vue'\nimport ADatePicker from './ADatePicker.vue'\nimport ADateTimeInput from './ADateTimeInput.vue'\n\nconst {\n\tshowDate = true,\n\tshowTime = true,\n\tselectRange = true,\n\tshowEndTime = false,\n\tallowMilitaryTime = false,\n\tdefaultDate,\n\tdefaultHours = 12,\n\tdefaultMinutes = 0,\n\tdefaultSeconds = 0,\n\tdefaultMeridiem = 'AM',\n\tuseSeconds = true,\n} = defineProps<{\n\tshowDate?: boolean\n\tshowTime?: boolean\n\tselectRange?: boolean\n\tshowEndTime?: boolean\n\tallowMilitaryTime?: boolean\n\t/** The day the calendar opens on, as `YYYY-MM-DD` */\n\tdefaultDate?: string\n\tdefaultHours?: number\n\tdefaultMinutes?: number\n\tdefaultSeconds?: number\n\tdefaultMeridiem?: string\n\tuseSeconds?: boolean\n}>()\n\n// `source` is forwarded from ADateTimeInput, which declares it on every `get-time`. It is\n// optional here only because a host or a test may emit these events by hand, and doing so always\n// means a user action — `'init'` is the one case that has to be marked, because it is the widget\n// announcing its start value as it mounts rather than anything the user did.\nconst emit = defineEmits<{\n\t'get-date': [{ selected: string; start?: string | null; end?: string | null }]\n\t'get-time': [{ hours: number; minutes: number; seconds: number; meridiem: string; source?: 'init' | 'user' }]\n\t'get-range': [{ start: Date; end: Date; source?: 'init' | 'user' }]\n}>()\n\nprovide('select-range', selectRange)\n\nconst today = Temporal.Now.plainDateISO()\nconst pickerStart = ref<Temporal.PlainDate>(today)\nconst pickerEnd = ref<Temporal.PlainDate>(today)\nconst startTimeMs = ref<number>(0)\nconst endTimeMs = ref<number>(0)\n\nconst mergeDateTime = (day: Temporal.PlainDate, timeMs: number): Date => {\n\tconst midnight = day.toZonedDateTime(Temporal.Now.timeZoneId())\n\treturn new Date(midnight.epochMilliseconds + timeMs)\n}\n\nconst timePayloadToMs = (payload: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n}): number => {\n\tlet h: number\n\tif (payload.militaryTime !== undefined) {\n\t\th = payload.militaryTime\n\t} else {\n\t\tconst hrs = payload.hours % 12\n\t\th = payload.meridiem === 'PM' ? hrs + 12 : hrs\n\t}\n\treturn (h * 3600 + payload.minutes * 60 + (payload.seconds ?? 0)) * 1000\n}\n\nconst tryEmitRange = (source: 'init' | 'user') => {\n\tif (!selectRange || !showTime || !showEndTime) return\n\temit('get-range', {\n\t\tstart: mergeDateTime(pickerStart.value, startTimeMs.value),\n\t\tend: mergeDateTime(pickerEnd.value, endTimeMs.value),\n\t\tsource,\n\t})\n}\n\nconst handleDate = (data: { start: string | null; end: string | null; selected: string }) => {\n\temit('get-date', data)\n\tif (selectRange) {\n\t\tpickerStart.value = fromISODate(data.start ?? data.selected) ?? today\n\t\tpickerEnd.value = fromISODate(data.end ?? data.selected) ?? today\n\t\t// Picking a day on the calendar is unambiguously a user action.\n\t\ttryEmitRange('user')\n\t}\n}\n\nconst handleStartTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\tstartTimeMs.value = timePayloadToMs(data)\n\tif (showEndTime) {\n\t\ttryEmitRange(data.source ?? 'user')\n\t} else {\n\t\temit('get-time', data)\n\t}\n}\n\nconst handleEndTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\tendTimeMs.value = timePayloadToMs(data)\n\ttryEmitRange(data.source ?? 'user')\n}\n</script>\n\n<style scoped>\n.adate-selection {\n\tdisplay: inline-block;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--sc-input-border-color);\n\tpadding: 10px;\n\tbackground: var(--sc-input-field-background);\n}\n\n.adate-selection__end-label {\n\tfont-size: 0.8em;\n\tfont-weight: bold;\n\tcolor: var(--sc-input-active-label-color);\n\tmargin-top: 8px;\n\tmargin-bottom: 2px;\n\tpadding-left: 2px;\n}\n\n.empty {\n\tcolor: var(--sc-input-label-color);\n\tpadding: 10px;\n\ttext-align: center;\n\tborder: 1px solid var(--sc-input-border-color);\n}\n</style>\n","<!-- This serves as a wrapper component for ADatePicker and ADateTimeInput in one component -->\n\n<template>\n\t<div class=\"adate-selection\">\n\t\t<ADatePicker v-if=\"showDate\" :model-value=\"defaultDate\" :select-range=\"selectRange\" @get-date=\"handleDate\" />\n\n\t\t<ADateTimeInput\n\t\t\tv-if=\"showTime\"\n\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t:default-hours=\"defaultHours\"\n\t\t\t:default-minutes=\"defaultMinutes\"\n\t\t\t:default-seconds=\"defaultSeconds\"\n\t\t\t:default-meridiem=\"defaultMeridiem\"\n\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t@get-time=\"handleStartTime\" />\n\n\t\t<template v-if=\"selectRange && showTime && showEndTime\">\n\t\t\t<div class=\"adate-selection__end-label\">End time</div>\n\t\t\t<ADateTimeInput\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:default-hours=\"defaultHours\"\n\t\t\t\t:default-minutes=\"defaultMinutes\"\n\t\t\t\t:default-seconds=\"defaultSeconds\"\n\t\t\t\t:default-meridiem=\"defaultMeridiem\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-time=\"handleEndTime\" />\n\t\t</template>\n\n\t\t<p v-if=\"!showTime && !showDate\" class=\"empty\">empty</p>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport { provide, ref } from 'vue'\nimport ADatePicker from './ADatePicker.vue'\nimport ADateTimeInput from './ADateTimeInput.vue'\n\nconst {\n\tshowDate = true,\n\tshowTime = true,\n\tselectRange = true,\n\tshowEndTime = false,\n\tallowMilitaryTime = false,\n\tdefaultDate,\n\tdefaultHours = 12,\n\tdefaultMinutes = 0,\n\tdefaultSeconds = 0,\n\tdefaultMeridiem = 'AM',\n\tuseSeconds = true,\n} = defineProps<{\n\tshowDate?: boolean\n\tshowTime?: boolean\n\tselectRange?: boolean\n\tshowEndTime?: boolean\n\tallowMilitaryTime?: boolean\n\t/** The day the calendar opens on, as `YYYY-MM-DD` */\n\tdefaultDate?: string\n\tdefaultHours?: number\n\tdefaultMinutes?: number\n\tdefaultSeconds?: number\n\tdefaultMeridiem?: string\n\tuseSeconds?: boolean\n}>()\n\n// `source` is forwarded from ADateTimeInput, which declares it on every `get-time`. It is\n// optional here only because a host or a test may emit these events by hand, and doing so always\n// means a user action — `'init'` is the one case that has to be marked, because it is the widget\n// announcing its start value as it mounts rather than anything the user did.\nconst emit = defineEmits<{\n\t'get-date': [{ selected: string; start?: string | null; end?: string | null }]\n\t'get-time': [{ hours: number; minutes: number; seconds: number; meridiem: string; source?: 'init' | 'user' }]\n\t'get-range': [{ start: Date; end: Date; source?: 'init' | 'user' }]\n}>()\n\nprovide('select-range', selectRange)\n\nconst today = Temporal.Now.plainDateISO()\nconst pickerStart = ref<Temporal.PlainDate>(today)\nconst pickerEnd = ref<Temporal.PlainDate>(today)\nconst startTimeMs = ref<number>(0)\nconst endTimeMs = ref<number>(0)\n\nconst mergeDateTime = (day: Temporal.PlainDate, timeMs: number): Date => {\n\tconst midnight = day.toZonedDateTime(Temporal.Now.timeZoneId())\n\treturn new Date(midnight.epochMilliseconds + timeMs)\n}\n\nconst timePayloadToMs = (payload: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n}): number => {\n\tlet h: number\n\tif (payload.militaryTime !== undefined) {\n\t\th = payload.militaryTime\n\t} else {\n\t\tconst hrs = payload.hours % 12\n\t\th = payload.meridiem === 'PM' ? hrs + 12 : hrs\n\t}\n\treturn (h * 3600 + payload.minutes * 60 + (payload.seconds ?? 0)) * 1000\n}\n\nconst tryEmitRange = (source: 'init' | 'user') => {\n\tif (!selectRange || !showTime || !showEndTime) return\n\temit('get-range', {\n\t\tstart: mergeDateTime(pickerStart.value, startTimeMs.value),\n\t\tend: mergeDateTime(pickerEnd.value, endTimeMs.value),\n\t\tsource,\n\t})\n}\n\nconst handleDate = (data: { start: string | null; end: string | null; selected: string }) => {\n\temit('get-date', data)\n\tif (selectRange) {\n\t\tpickerStart.value = fromISODate(data.start ?? data.selected) ?? today\n\t\tpickerEnd.value = fromISODate(data.end ?? data.selected) ?? today\n\t\t// Picking a day on the calendar is unambiguously a user action.\n\t\ttryEmitRange('user')\n\t}\n}\n\nconst handleStartTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\tstartTimeMs.value = timePayloadToMs(data)\n\tif (showEndTime) {\n\t\ttryEmitRange(data.source ?? 'user')\n\t} else {\n\t\temit('get-time', data)\n\t}\n}\n\nconst handleEndTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\tendTimeMs.value = timePayloadToMs(data)\n\ttryEmitRange(data.source ?? 'user')\n}\n</script>\n\n<style scoped>\n.adate-selection {\n\tdisplay: inline-block;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--sc-input-border-color);\n\tpadding: 10px;\n\tbackground: var(--sc-input-field-background);\n}\n\n.adate-selection__end-label {\n\tfont-size: 0.8em;\n\tfont-weight: bold;\n\tcolor: var(--sc-input-active-label-color);\n\tmargin-top: 8px;\n\tmargin-bottom: 2px;\n\tpadding-left: 2px;\n}\n\n.empty {\n\tcolor: var(--sc-input-label-color);\n\tpadding: 10px;\n\ttext-align: center;\n\tborder: 1px solid var(--sc-input-border-color);\n}\n</style>\n","import { onClickOutside } from '@vueuse/core'\nimport { type ComponentPublicInstance, nextTick, ref, type ShallowRef, useId } from 'vue'\n\n/** The keys a date field opens its calendar on: the ones a date input opens the browser's own calendar on, in Chrome. */\nexport const opensCalendar = (event: KeyboardEvent) =>\n\tevent.key === ' ' || event.key === 'F4' || (event.altKey && event.key === 'ArrowDown')\n\n/**\n * The calendar a date field opens from its box, and the keys and focus that go with it.\n * @param box - the field's box, which focus returns to when the calendar closes\n * @param calendar - the calendar, while it is open\n * @param uuid - the field's own id, when it has one\n */\nexport function useFieldCalendar(\n\tbox: Readonly<ShallowRef<HTMLElement | null>>,\n\tcalendar: Readonly<ShallowRef<ComponentPublicInstance | null>>,\n\tuuid: string | undefined\n) {\n\tconst showPicker = ref(false)\n\t// Unique for a standalone mount too, so two fields on one page can't cross-wire `aria-controls`.\n\tconst calendarId = `${uuid ?? `aform-date-${useId()}`}-calendar`\n\n\tonClickOutside(calendar, () => (showPicker.value = false))\n\n\tconst closePicker = () => {\n\t\tbox.value?.focus()\n\t\tshowPicker.value = false\n\t}\n\n\tconst openFromKey = async (event: KeyboardEvent) => {\n\t\t// A read-only box's arrows have nothing else to do, so plain Down opens it too, as a combobox's does.\n\t\tconst readOnlyDown = event.key === 'ArrowDown' && box.value instanceof HTMLInputElement && box.value.readOnly\n\t\tif (!opensCalendar(event) && !readOnlyDown) return\n\t\tevent.preventDefault()\n\t\tshowPicker.value = true\n\t\tawait nextTick()\n\t\tconst root: unknown = calendar.value?.$el\n\t\t// The calendar's one Tab stop is the day it has focused.\n\t\tif (root instanceof HTMLElement) root.querySelector<HTMLElement>('[role=\"grid\"] [tabindex=\"0\"]')?.focus()\n\t}\n\n\tconst closeOnEscape = (event: KeyboardEvent) => {\n\t\tif (event.key !== 'Escape' || !showPicker.value) return\n\t\tevent.stopPropagation()\n\t\tclosePicker()\n\t}\n\n\tconst closeWhenFocusLeaves = (event: FocusEvent) => {\n\t\tconst field = event.currentTarget\n\t\tconst next = event.relatedTarget\n\t\tif (!(field instanceof Node && next instanceof Node && field.contains(next))) showPicker.value = false\n\t}\n\n\treturn { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves }\n}\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<!-- `.prevent` and the calendar's keys keep the browser's own calendar shut: aform's is the only one this field opens.\n\t\t\t A date input cannot take the combobox role, and `aria-expanded` is not allowed on it. -->\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"date\"\n\t\t\t\tv-model=\"boxDay\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"date\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click.prevent=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adate-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:default-date=\"modelValue || undefined\"\n\t\t\t\t:select-range=\"false\"\n\t\t\t\t:show-time=\"false\"\n\t\t\t\t@get-date=\"handleDate\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, useTemplateRef, computed } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport ADateSelection from './ADateSelection.vue'\nimport type { ComponentProps } from '../../types'\nimport { dayFromBox } from '../../utils/emptiedBox'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst {\n\tlabel = 'Date',\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n} = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\n// The field holds a `YYYY-MM-DD` day, which is also the date input's own value; a Date would be an instant.\nconst modelValue = defineModel<string | null>()\n\nconst boxDay = computed({\n\tget: () => modelValue.value,\n\tset: (text: string) => (modelValue.value = dayFromBox(text)),\n})\n\nconst displayValue = computed(() =>\n\tmodelValue.value ? (fromISODate(modelValue.value)?.toLocaleString() ?? 'Invalid Date') : ''\n)\n\nconst { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('date'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = !showPicker.value\n}\n\nconst handleDate = (data: { selected: string }) => {\n\tmodelValue.value = data.selected\n\tclosePicker()\n}\n</script>\n\n<style scoped>\n.adate-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<!-- `.prevent` and the calendar's keys keep the browser's own calendar shut: aform's is the only one this field opens.\n\t\t\t A date input cannot take the combobox role, and `aria-expanded` is not allowed on it. -->\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"date\"\n\t\t\t\tv-model=\"boxDay\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"date\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click.prevent=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adate-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:default-date=\"modelValue || undefined\"\n\t\t\t\t:select-range=\"false\"\n\t\t\t\t:show-time=\"false\"\n\t\t\t\t@get-date=\"handleDate\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, useTemplateRef, computed } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport ADateSelection from './ADateSelection.vue'\nimport type { ComponentProps } from '../../types'\nimport { dayFromBox } from '../../utils/emptiedBox'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst {\n\tlabel = 'Date',\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n} = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\n// The field holds a `YYYY-MM-DD` day, which is also the date input's own value; a Date would be an instant.\nconst modelValue = defineModel<string | null>()\n\nconst boxDay = computed({\n\tget: () => modelValue.value,\n\tset: (text: string) => (modelValue.value = dayFromBox(text)),\n})\n\nconst displayValue = computed(() =>\n\tmodelValue.value ? (fromISODate(modelValue.value)?.toLocaleString() ?? 'Invalid Date') : ''\n)\n\nconst { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('date'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = !showPicker.value\n}\n\nconst handleDate = (data: { selected: string }) => {\n\tmodelValue.value = data.selected\n\tclosePicker()\n}\n</script>\n\n<style scoped>\n.adate-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<span v-if=\"displayLabel\" :class=\"classes\" :style=\"styleVars\">{{ displayLabel }}</span>\n</template>\n\n<script setup lang=\"ts\">\nimport type { BadgeDescriptor, BadgePresentation, BadgeVariant, FieldOptions } from '@stonecrop/schema'\nimport { lookupBadge } from '@stonecrop/schema'\nimport { computed, type CSSProperties } from 'vue'\n\nconst props = defineProps<\n\tPartial<BadgeDescriptor> & {\n\t\t/** Defaults to `cell-fill`: every call site fully determines this, so omitting it should\n\t\t * degrade to the common case rather than rendering an unstyled badge. */\n\t\tpresentation?: BadgePresentation\n\t\t/** Stored field value — used with `options` when `label` is omitted. */\n\t\tvalue?: unknown\n\t\toptions?: FieldOptions\n\t}\n>()\n\nconst resolved = computed((): BadgeDescriptor | undefined => {\n\tif (props.label?.trim()) {\n\t\treturn {\n\t\t\tlabel: props.label.trim(),\n\t\t\tvariant: props.variant,\n\t\t\tcolor: props.color,\n\t\t}\n\t}\n\tif (props.value === null || props.value === undefined || props.value === '') return undefined\n\tconst key = typeof props.value === 'string' ? props.value : String(props.value)\n\treturn lookupBadge(props.options, key)\n})\n\nconst displayLabel = computed(() => resolved.value?.label?.trim() ?? '')\n\nconst activeVariant = computed((): BadgeVariant => resolved.value?.variant ?? props.variant ?? 'neutral')\n\nconst activeColor = computed(() => resolved.value?.color ?? props.color)\n\nconst classes = computed(() => [\n\t'abadge',\n\t`abadge--${props.presentation ?? 'cell-fill'}`,\n\t`abadge--${activeVariant.value}`,\n])\n\nconst styleVars = computed((): CSSProperties => {\n\tconst color = activeColor.value\n\tif (!color) return {}\n\treturn {\n\t\t'--sc-badge-bg': color,\n\t\t'--sc-badge-text': color,\n\t\t'--sc-badge-accent': color,\n\t} as CSSProperties\n})\n\nexport type { BadgePresentation, BadgeVariant }\n</script>\n\n<style scoped>\n.abadge {\n\tdisplay: block;\n\tbox-sizing: border-box;\n\tfont: inherit;\n\tline-height: inherit;\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n.abadge--cell-fill {\n\tdisplay: block;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: calc(var(--sc-atable-row-height) + 2 * var(--sc-atable-row-padding));\n\tline-height: calc(var(--sc-atable-row-height) + 2 * var(--sc-atable-row-padding));\n\tmargin: 0;\n\tpadding: 0 0.5ch;\n\tborder-radius: 0;\n\ttext-align: inherit;\n\tbackground: var(--sc-badge-bg);\n\tcolor: var(--sc-badge-text);\n}\n\n.abadge--cell-fill.abadge--neutral {\n\t--sc-badge-bg: var(--sc-badge-neutral-bg);\n\t--sc-badge-text: var(--sc-badge-neutral-text);\n}\n\n.abadge--cell-fill.abadge--success {\n\t--sc-badge-bg: var(--sc-badge-success-bg);\n\t--sc-badge-text: var(--sc-badge-success-text);\n}\n\n.abadge--cell-fill.abadge--warning {\n\t--sc-badge-bg: var(--sc-badge-warning-bg);\n\t--sc-badge-text: var(--sc-badge-warning-text);\n}\n\n.abadge--cell-fill.abadge--danger {\n\t--sc-badge-bg: var(--sc-badge-danger-bg);\n\t--sc-badge-text: var(--sc-badge-danger-text);\n}\n\n.abadge--cell-fill.abadge--brand {\n\t--sc-badge-bg: var(--sc-badge-brand-bg);\n\t--sc-badge-text: var(--sc-badge-brand-text);\n}\n\n.abadge--input-accent {\n\tbackground: var(--sc-input-field-background);\n\tcolor: inherit;\n\tborder-left: 4px solid var(--sc-badge-accent);\n\tpadding-left: calc(1ch - 4px);\n}\n\n.abadge--input-accent.abadge--neutral {\n\t--sc-badge-accent: var(--sc-badge-neutral-accent);\n}\n\n.abadge--input-accent.abadge--success {\n\t--sc-badge-accent: var(--sc-badge-success-accent);\n}\n\n.abadge--input-accent.abadge--warning {\n\t--sc-badge-accent: var(--sc-badge-warning-accent);\n}\n\n.abadge--input-accent.abadge--danger {\n\t--sc-badge-accent: var(--sc-badge-danger-accent);\n}\n\n.abadge--input-accent.abadge--brand {\n\t--sc-badge-accent: var(--sc-badge-brand-accent);\n}\n</style>\n","<template>\n\t<span v-if=\"displayLabel\" :class=\"classes\" :style=\"styleVars\">{{ displayLabel }}</span>\n</template>\n\n<script setup lang=\"ts\">\nimport type { BadgeDescriptor, BadgePresentation, BadgeVariant, FieldOptions } from '@stonecrop/schema'\nimport { lookupBadge } from '@stonecrop/schema'\nimport { computed, type CSSProperties } from 'vue'\n\nconst props = defineProps<\n\tPartial<BadgeDescriptor> & {\n\t\t/** Defaults to `cell-fill`: every call site fully determines this, so omitting it should\n\t\t * degrade to the common case rather than rendering an unstyled badge. */\n\t\tpresentation?: BadgePresentation\n\t\t/** Stored field value — used with `options` when `label` is omitted. */\n\t\tvalue?: unknown\n\t\toptions?: FieldOptions\n\t}\n>()\n\nconst resolved = computed((): BadgeDescriptor | undefined => {\n\tif (props.label?.trim()) {\n\t\treturn {\n\t\t\tlabel: props.label.trim(),\n\t\t\tvariant: props.variant,\n\t\t\tcolor: props.color,\n\t\t}\n\t}\n\tif (props.value === null || props.value === undefined || props.value === '') return undefined\n\tconst key = typeof props.value === 'string' ? props.value : String(props.value)\n\treturn lookupBadge(props.options, key)\n})\n\nconst displayLabel = computed(() => resolved.value?.label?.trim() ?? '')\n\nconst activeVariant = computed((): BadgeVariant => resolved.value?.variant ?? props.variant ?? 'neutral')\n\nconst activeColor = computed(() => resolved.value?.color ?? props.color)\n\nconst classes = computed(() => [\n\t'abadge',\n\t`abadge--${props.presentation ?? 'cell-fill'}`,\n\t`abadge--${activeVariant.value}`,\n])\n\nconst styleVars = computed((): CSSProperties => {\n\tconst color = activeColor.value\n\tif (!color) return {}\n\treturn {\n\t\t'--sc-badge-bg': color,\n\t\t'--sc-badge-text': color,\n\t\t'--sc-badge-accent': color,\n\t} as CSSProperties\n})\n\nexport type { BadgePresentation, BadgeVariant }\n</script>\n\n<style scoped>\n.abadge {\n\tdisplay: block;\n\tbox-sizing: border-box;\n\tfont: inherit;\n\tline-height: inherit;\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n.abadge--cell-fill {\n\tdisplay: block;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: calc(var(--sc-atable-row-height) + 2 * var(--sc-atable-row-padding));\n\tline-height: calc(var(--sc-atable-row-height) + 2 * var(--sc-atable-row-padding));\n\tmargin: 0;\n\tpadding: 0 0.5ch;\n\tborder-radius: 0;\n\ttext-align: inherit;\n\tbackground: var(--sc-badge-bg);\n\tcolor: var(--sc-badge-text);\n}\n\n.abadge--cell-fill.abadge--neutral {\n\t--sc-badge-bg: var(--sc-badge-neutral-bg);\n\t--sc-badge-text: var(--sc-badge-neutral-text);\n}\n\n.abadge--cell-fill.abadge--success {\n\t--sc-badge-bg: var(--sc-badge-success-bg);\n\t--sc-badge-text: var(--sc-badge-success-text);\n}\n\n.abadge--cell-fill.abadge--warning {\n\t--sc-badge-bg: var(--sc-badge-warning-bg);\n\t--sc-badge-text: var(--sc-badge-warning-text);\n}\n\n.abadge--cell-fill.abadge--danger {\n\t--sc-badge-bg: var(--sc-badge-danger-bg);\n\t--sc-badge-text: var(--sc-badge-danger-text);\n}\n\n.abadge--cell-fill.abadge--brand {\n\t--sc-badge-bg: var(--sc-badge-brand-bg);\n\t--sc-badge-text: var(--sc-badge-brand-text);\n}\n\n.abadge--input-accent {\n\tbackground: var(--sc-input-field-background);\n\tcolor: inherit;\n\tborder-left: 4px solid var(--sc-badge-accent);\n\tpadding-left: calc(1ch - 4px);\n}\n\n.abadge--input-accent.abadge--neutral {\n\t--sc-badge-accent: var(--sc-badge-neutral-accent);\n}\n\n.abadge--input-accent.abadge--success {\n\t--sc-badge-accent: var(--sc-badge-success-accent);\n}\n\n.abadge--input-accent.abadge--warning {\n\t--sc-badge-accent: var(--sc-badge-warning-accent);\n}\n\n.abadge--input-accent.abadge--danger {\n\t--sc-badge-accent: var(--sc-badge-danger-accent);\n}\n\n.abadge--input-accent.abadge--brand {\n\t--sc-badge-accent: var(--sc-badge-brand-accent);\n}\n</style>\n","<template>\n\t<div\n\t\tclass=\"aform_form-element aform_segmented-control\"\n\t\t:class=\"{\n\t\t\t'aform_segmented-control--xs': size === 'xs',\n\t\t\t'aform_segmented-control--sm': size === 'sm',\n\t\t\t'aform_segmented-control--equal': equal,\n\t\t}\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<label class=\"aform_field-label\" :class=\"{ 'aform_segmented-sr-label': hideLabel }\">{{ label }}</label>\n\t\t\t<ABadge\n\t\t\t\tv-if=\"displayBadge\"\n\t\t\t\tclass=\"aform_display-value aform_segmented-display-badge\"\n\t\t\t\t:value=\"displayBadgeValue\"\n\t\t\t\t:options=\"options\"\n\t\t\t\tpresentation=\"input-accent\" />\n\t\t\t<span v-else class=\"aform_display-value\">{{ displayText }}</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<label :id=\"labelId\" class=\"aform_field-label\" :class=\"{ 'aform_segmented-sr-label': hideLabel }\">\n\t\t\t\t{{ label }}\n\t\t\t</label>\n\t\t\t<div\n\t\t\t\t:role=\"multiple ? 'group' : 'radiogroup'\"\n\t\t\t\tclass=\"aform_segmented-track\"\n\t\t\t\t:aria-labelledby=\"groupAriaLabel ? undefined : labelId\"\n\t\t\t\t:aria-label=\"groupAriaLabel\"\n\t\t\t\t:aria-busy=\"busy || undefined\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\">\n\t\t\t\t<label\n\t\t\t\t\tv-for=\"choice in choices\"\n\t\t\t\t\t:key=\"choice\"\n\t\t\t\t\tclass=\"aform_segmented-segment\"\n\t\t\t\t\t:class=\"segmentClasses(choice)\"\n\t\t\t\t\t:style=\"segmentStyle(choice)\"\n\t\t\t\t\t:data-segment-value=\"choice\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-if=\"multiple\"\n\t\t\t\t\t\tv-model=\"selectedMany\"\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\tclass=\"aform_segmented-input\"\n\t\t\t\t\t\t:name=\"groupName\"\n\t\t\t\t\t\t:value=\"choice\"\n\t\t\t\t\t\t:disabled=\"mode === 'read'\" />\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-else\n\t\t\t\t\t\tv-model=\"selected\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tclass=\"aform_segmented-input\"\n\t\t\t\t\t\t:name=\"groupName\"\n\t\t\t\t\t\t:value=\"choice\"\n\t\t\t\t\t\t:disabled=\"mode === 'read'\" />\n\t\t\t\t\t<span class=\"aform_segmented-label\">{{ segmentLabel(choice) }}</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { BadgeVariant, FieldOptions } from '@stonecrop/schema'\nimport { hasBadgeOptions, lookupBadge, selectChoices } from '@stonecrop/schema'\nimport { computed, useId, type CSSProperties } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport ABadge from './ABadge.vue'\n\nconst {\n\tlabel,\n\toptions = undefined,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tsize = 'sm',\n\tequal = false,\n\thideLabel = false,\n\tariaLabel = undefined,\n\tbusy = false,\n\tmultiple = false,\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: FieldOptions\n\t\tsize?: 'xs' | 'sm'\n\t\tequal?: boolean\n\t\thideLabel?: boolean\n\t\tariaLabel?: string\n\t\tbusy?: boolean\n\t\tmultiple?: boolean\n\t}\n>()\n\nconst selected = defineModel<string | string[]>({ default: '' })\n\nconst selectedMany = computed({\n\tget: () => (Array.isArray(selected.value) ? selected.value : []),\n\tset: (value: string[]) => {\n\t\tselected.value = value\n\t},\n})\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst fallbackId = useId()\nconst groupName = computed(() => uuid ?? `aform-segmented-${fallbackId}`)\nconst labelId = computed(() => `${groupName.value}-label`)\n\n// aria-labelledby outranks aria-label in the accessible-name algorithm, so the two are mutually\n// exclusive here: emitting both would silently leave `ariaLabel` inert. It only applies while the\n// label element is visually hidden — overriding a *visible* label would break WCAG 2.5.3.\nconst groupAriaLabel = computed(() => (hideLabel ? ariaLabel : undefined))\n\nconst choices = computed(() => selectChoices(options))\nconst badgeOptions = computed(() => hasBadgeOptions(options))\n\nfunction segmentLabel(choice: string): string {\n\treturn lookupBadge(options, choice)?.label ?? choice\n}\n\nfunction segmentVariant(choice: string): BadgeVariant {\n\treturn lookupBadge(options, choice)?.variant ?? 'neutral'\n}\n\nfunction isChoiceSelected(choice: string): boolean {\n\tif (multiple) return selectedMany.value.includes(choice)\n\treturn selected.value === choice\n}\n\nfunction segmentClasses(choice: string): Record<string, boolean> {\n\tif (!badgeOptions.value) return {}\n\treturn {\n\t\t'aform_segmented-segment--badge': true,\n\t\t[`aform_segmented-segment--${segmentVariant(choice)}`]: isChoiceSelected(choice),\n\t}\n}\n\nfunction segmentStyle(choice: string): CSSProperties {\n\tif (!badgeOptions.value || !isChoiceSelected(choice)) return {}\n\tconst color = lookupBadge(options, choice)?.color\n\tif (!color) return {}\n\treturn {\n\t\t'--sc-badge-bg': color,\n\t\t'--sc-badge-text': color,\n\t} as CSSProperties\n}\n\nconst displayText = computed(() => {\n\tif (multiple) {\n\t\treturn selectedMany.value.map(segmentLabel).filter(Boolean).join(', ')\n\t}\n\tconst value = selected.value\n\tif (typeof value !== 'string' || value === '') return ''\n\treturn segmentLabel(value)\n})\n\nconst displayBadge = computed(() => {\n\tif (!badgeOptions.value) return false\n\tif (multiple) return selectedMany.value.length === 1\n\treturn typeof selected.value === 'string' && selected.value !== ''\n})\n\nconst displayBadgeValue = computed(() => {\n\tif (multiple) return selectedMany.value[0] ?? ''\n\treturn typeof selected.value === 'string' ? selected.value : ''\n})\n</script>\n\n<style scoped>\n.aform_segmented-control--xs.aform_form-element {\n\tmin-width: 0;\n\tpadding-top: 0;\n\tmax-width: none;\n}\n\n.aform_segmented-control--xs:not(:has(.aform_segmented-sr-label)) {\n\tpadding-top: 0.5rem;\n}\n\n.aform_segmented-sr-label {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.aform_segmented-track {\n\tdisplay: inline-flex;\n\tflex-wrap: wrap;\n\talign-items: stretch;\n\tgap: 0.125rem;\n\tpadding: 0.125rem;\n\twidth: auto;\n\tmin-width: 0;\n\tmin-height: 2rem;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tborder-radius: 0;\n\tbox-sizing: border-box;\n\tbackground: var(--sc-input-addon-background);\n\tfont-family: var(--sc-font-family);\n}\n\n.aform_segmented-control--xs .aform_segmented-track {\n\tmin-height: 1.5rem;\n\tfont-size: 0.875rem;\n}\n\n.aform_segmented-control--equal .aform_segmented-track {\n\tdisplay: flex;\n\twidth: 100%;\n}\n\n.aform_segmented-segment {\n\tposition: relative;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tflex: none;\n\tmargin: 0;\n\tpadding: 0.125rem 0.5rem;\n\tmin-height: 1.5rem;\n\tborder-radius: 0;\n\tcolor: var(--sc-input-label-color);\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tfont-weight: 400;\n\tline-height: 1.25;\n\tcursor: pointer;\n\tuser-select: none;\n\tbox-sizing: border-box;\n}\n\n.aform_segmented-control--sm .aform_segmented-segment {\n\tmin-height: 1.75rem;\n\tpadding: 0.125rem 0.75rem;\n\tfont-size: var(--sc-font-size);\n}\n\n.aform_segmented-control--equal .aform_segmented-segment {\n\tflex: 1 1 0;\n}\n\n.aform_segmented-input {\n\tposition: absolute;\n\tinline-size: 1px;\n\tblock-size: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.aform_segmented-label {\n\tpointer-events: none;\n}\n\n.aform_segmented-segment:not(.aform_segmented-segment--badge):has(.aform_segmented-input:checked) {\n\tbackground: var(--sc-form-background);\n\tcolor: var(--sc-cell-text-color);\n\tfont-weight: 500;\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked) {\n\tfont-weight: 500;\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--neutral {\n\tbackground: var(--sc-badge-neutral-bg);\n\tcolor: var(--sc-badge-neutral-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--success {\n\tbackground: var(--sc-badge-success-bg);\n\tcolor: var(--sc-badge-success-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--warning {\n\tbackground: var(--sc-badge-warning-bg);\n\tcolor: var(--sc-badge-warning-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--danger {\n\tbackground: var(--sc-badge-danger-bg);\n\tcolor: var(--sc-badge-danger-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--brand {\n\tbackground: var(--sc-badge-brand-bg);\n\tcolor: var(--sc-badge-brand-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked)[style*='--sc-badge-bg'] {\n\tbackground: var(--sc-badge-bg);\n\tcolor: var(--sc-badge-text);\n}\n\n.aform_segmented-segment:has(.aform_segmented-input:focus-visible) {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n\n.aform_segmented-segment:hover:has(.aform_segmented-input:not(:disabled):not(:checked)) {\n\tbackground: color-mix(in srgb, var(--sc-form-background) 50%, transparent);\n}\n\n.aform_segmented-segment:has(.aform_segmented-input:disabled) {\n\tcursor: not-allowed;\n\topacity: 0.5;\n}\n\n.aform_segmented-track:has(.aform_segmented-input:focus-visible) {\n\toutline-color: var(--sc-input-active-border-color);\n}\n\n.aform_segmented-display-badge {\n\tdisplay: block;\n\tpadding: 0.5rem;\n\tmin-height: 2rem;\n\tbox-sizing: border-box;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n\t.aform_segmented-segment {\n\t\ttransition:\n\t\t\tbackground-color 0.1s ease-out,\n\t\t\tcolor 0.1s ease-out;\n\t}\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.aform_segmented-segment {\n\t\ttransition: none;\n\t}\n}\n</style>\n","<template>\n\t<div\n\t\tclass=\"aform_form-element aform_segmented-control\"\n\t\t:class=\"{\n\t\t\t'aform_segmented-control--xs': size === 'xs',\n\t\t\t'aform_segmented-control--sm': size === 'sm',\n\t\t\t'aform_segmented-control--equal': equal,\n\t\t}\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<label class=\"aform_field-label\" :class=\"{ 'aform_segmented-sr-label': hideLabel }\">{{ label }}</label>\n\t\t\t<ABadge\n\t\t\t\tv-if=\"displayBadge\"\n\t\t\t\tclass=\"aform_display-value aform_segmented-display-badge\"\n\t\t\t\t:value=\"displayBadgeValue\"\n\t\t\t\t:options=\"options\"\n\t\t\t\tpresentation=\"input-accent\" />\n\t\t\t<span v-else class=\"aform_display-value\">{{ displayText }}</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<label :id=\"labelId\" class=\"aform_field-label\" :class=\"{ 'aform_segmented-sr-label': hideLabel }\">\n\t\t\t\t{{ label }}\n\t\t\t</label>\n\t\t\t<div\n\t\t\t\t:role=\"multiple ? 'group' : 'radiogroup'\"\n\t\t\t\tclass=\"aform_segmented-track\"\n\t\t\t\t:aria-labelledby=\"groupAriaLabel ? undefined : labelId\"\n\t\t\t\t:aria-label=\"groupAriaLabel\"\n\t\t\t\t:aria-busy=\"busy || undefined\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\">\n\t\t\t\t<label\n\t\t\t\t\tv-for=\"choice in choices\"\n\t\t\t\t\t:key=\"choice\"\n\t\t\t\t\tclass=\"aform_segmented-segment\"\n\t\t\t\t\t:class=\"segmentClasses(choice)\"\n\t\t\t\t\t:style=\"segmentStyle(choice)\"\n\t\t\t\t\t:data-segment-value=\"choice\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-if=\"multiple\"\n\t\t\t\t\t\tv-model=\"selectedMany\"\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\tclass=\"aform_segmented-input\"\n\t\t\t\t\t\t:name=\"groupName\"\n\t\t\t\t\t\t:value=\"choice\"\n\t\t\t\t\t\t:disabled=\"mode === 'read'\" />\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-else\n\t\t\t\t\t\tv-model=\"selected\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tclass=\"aform_segmented-input\"\n\t\t\t\t\t\t:name=\"groupName\"\n\t\t\t\t\t\t:value=\"choice\"\n\t\t\t\t\t\t:disabled=\"mode === 'read'\" />\n\t\t\t\t\t<span class=\"aform_segmented-label\">{{ segmentLabel(choice) }}</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { BadgeVariant, FieldOptions } from '@stonecrop/schema'\nimport { hasBadgeOptions, lookupBadge, selectChoices } from '@stonecrop/schema'\nimport { computed, useId, type CSSProperties } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport ABadge from './ABadge.vue'\n\nconst {\n\tlabel,\n\toptions = undefined,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tsize = 'sm',\n\tequal = false,\n\thideLabel = false,\n\tariaLabel = undefined,\n\tbusy = false,\n\tmultiple = false,\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: FieldOptions\n\t\tsize?: 'xs' | 'sm'\n\t\tequal?: boolean\n\t\thideLabel?: boolean\n\t\tariaLabel?: string\n\t\tbusy?: boolean\n\t\tmultiple?: boolean\n\t}\n>()\n\nconst selected = defineModel<string | string[]>({ default: '' })\n\nconst selectedMany = computed({\n\tget: () => (Array.isArray(selected.value) ? selected.value : []),\n\tset: (value: string[]) => {\n\t\tselected.value = value\n\t},\n})\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst fallbackId = useId()\nconst groupName = computed(() => uuid ?? `aform-segmented-${fallbackId}`)\nconst labelId = computed(() => `${groupName.value}-label`)\n\n// aria-labelledby outranks aria-label in the accessible-name algorithm, so the two are mutually\n// exclusive here: emitting both would silently leave `ariaLabel` inert. It only applies while the\n// label element is visually hidden — overriding a *visible* label would break WCAG 2.5.3.\nconst groupAriaLabel = computed(() => (hideLabel ? ariaLabel : undefined))\n\nconst choices = computed(() => selectChoices(options))\nconst badgeOptions = computed(() => hasBadgeOptions(options))\n\nfunction segmentLabel(choice: string): string {\n\treturn lookupBadge(options, choice)?.label ?? choice\n}\n\nfunction segmentVariant(choice: string): BadgeVariant {\n\treturn lookupBadge(options, choice)?.variant ?? 'neutral'\n}\n\nfunction isChoiceSelected(choice: string): boolean {\n\tif (multiple) return selectedMany.value.includes(choice)\n\treturn selected.value === choice\n}\n\nfunction segmentClasses(choice: string): Record<string, boolean> {\n\tif (!badgeOptions.value) return {}\n\treturn {\n\t\t'aform_segmented-segment--badge': true,\n\t\t[`aform_segmented-segment--${segmentVariant(choice)}`]: isChoiceSelected(choice),\n\t}\n}\n\nfunction segmentStyle(choice: string): CSSProperties {\n\tif (!badgeOptions.value || !isChoiceSelected(choice)) return {}\n\tconst color = lookupBadge(options, choice)?.color\n\tif (!color) return {}\n\treturn {\n\t\t'--sc-badge-bg': color,\n\t\t'--sc-badge-text': color,\n\t} as CSSProperties\n}\n\nconst displayText = computed(() => {\n\tif (multiple) {\n\t\treturn selectedMany.value.map(segmentLabel).filter(Boolean).join(', ')\n\t}\n\tconst value = selected.value\n\tif (typeof value !== 'string' || value === '') return ''\n\treturn segmentLabel(value)\n})\n\nconst displayBadge = computed(() => {\n\tif (!badgeOptions.value) return false\n\tif (multiple) return selectedMany.value.length === 1\n\treturn typeof selected.value === 'string' && selected.value !== ''\n})\n\nconst displayBadgeValue = computed(() => {\n\tif (multiple) return selectedMany.value[0] ?? ''\n\treturn typeof selected.value === 'string' ? selected.value : ''\n})\n</script>\n\n<style scoped>\n.aform_segmented-control--xs.aform_form-element {\n\tmin-width: 0;\n\tpadding-top: 0;\n\tmax-width: none;\n}\n\n.aform_segmented-control--xs:not(:has(.aform_segmented-sr-label)) {\n\tpadding-top: 0.5rem;\n}\n\n.aform_segmented-sr-label {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.aform_segmented-track {\n\tdisplay: inline-flex;\n\tflex-wrap: wrap;\n\talign-items: stretch;\n\tgap: 0.125rem;\n\tpadding: 0.125rem;\n\twidth: auto;\n\tmin-width: 0;\n\tmin-height: 2rem;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tborder-radius: 0;\n\tbox-sizing: border-box;\n\tbackground: var(--sc-input-addon-background);\n\tfont-family: var(--sc-font-family);\n}\n\n.aform_segmented-control--xs .aform_segmented-track {\n\tmin-height: 1.5rem;\n\tfont-size: 0.875rem;\n}\n\n.aform_segmented-control--equal .aform_segmented-track {\n\tdisplay: flex;\n\twidth: 100%;\n}\n\n.aform_segmented-segment {\n\tposition: relative;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tflex: none;\n\tmargin: 0;\n\tpadding: 0.125rem 0.5rem;\n\tmin-height: 1.5rem;\n\tborder-radius: 0;\n\tcolor: var(--sc-input-label-color);\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tfont-weight: 400;\n\tline-height: 1.25;\n\tcursor: pointer;\n\tuser-select: none;\n\tbox-sizing: border-box;\n}\n\n.aform_segmented-control--sm .aform_segmented-segment {\n\tmin-height: 1.75rem;\n\tpadding: 0.125rem 0.75rem;\n\tfont-size: var(--sc-font-size);\n}\n\n.aform_segmented-control--equal .aform_segmented-segment {\n\tflex: 1 1 0;\n}\n\n.aform_segmented-input {\n\tposition: absolute;\n\tinline-size: 1px;\n\tblock-size: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.aform_segmented-label {\n\tpointer-events: none;\n}\n\n.aform_segmented-segment:not(.aform_segmented-segment--badge):has(.aform_segmented-input:checked) {\n\tbackground: var(--sc-form-background);\n\tcolor: var(--sc-cell-text-color);\n\tfont-weight: 500;\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked) {\n\tfont-weight: 500;\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--neutral {\n\tbackground: var(--sc-badge-neutral-bg);\n\tcolor: var(--sc-badge-neutral-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--success {\n\tbackground: var(--sc-badge-success-bg);\n\tcolor: var(--sc-badge-success-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--warning {\n\tbackground: var(--sc-badge-warning-bg);\n\tcolor: var(--sc-badge-warning-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--danger {\n\tbackground: var(--sc-badge-danger-bg);\n\tcolor: var(--sc-badge-danger-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--brand {\n\tbackground: var(--sc-badge-brand-bg);\n\tcolor: var(--sc-badge-brand-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked)[style*='--sc-badge-bg'] {\n\tbackground: var(--sc-badge-bg);\n\tcolor: var(--sc-badge-text);\n}\n\n.aform_segmented-segment:has(.aform_segmented-input:focus-visible) {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n\n.aform_segmented-segment:hover:has(.aform_segmented-input:not(:disabled):not(:checked)) {\n\tbackground: color-mix(in srgb, var(--sc-form-background) 50%, transparent);\n}\n\n.aform_segmented-segment:has(.aform_segmented-input:disabled) {\n\tcursor: not-allowed;\n\topacity: 0.5;\n}\n\n.aform_segmented-track:has(.aform_segmented-input:focus-visible) {\n\toutline-color: var(--sc-input-active-border-color);\n}\n\n.aform_segmented-display-badge {\n\tdisplay: block;\n\tpadding: 0.5rem;\n\tmin-height: 2rem;\n\tbox-sizing: border-box;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n\t.aform_segmented-segment {\n\t\ttransition:\n\t\t\tbackground-color 0.1s ease-out,\n\t\t\tcolor 0.1s ease-out;\n\t}\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.aform_segmented-segment {\n\t\ttransition: none;\n\t}\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"box\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-expanded=\"showPicker\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:value=\"datetimeDisplay\"\n\t\t\t\tplaceholder=\"Select date and time\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\treadonly\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adatetime-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:select-range=\"false\"\n\t\t\t\t:show-date=\"true\"\n\t\t\t\t:show-time=\"true\"\n\t\t\t\t:default-date=\"currentDateTime?.toPlainDate().toString()\"\n\t\t\t\t:default-hours=\"pickerDefaults.hours\"\n\t\t\t\t:default-minutes=\"pickerDefaults.minutes\"\n\t\t\t\t:default-seconds=\"pickerDefaults.seconds\"\n\t\t\t\t:default-meridiem=\"pickerDefaults.meridiem\"\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-date=\"handleDate\"\n\t\t\t\t@get-time=\"handleTime\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, ref, computed, useTemplateRef, watch } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport ADateSelection from './ADateSelection.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst {\n\tlabel = 'Date & Time',\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tallowMilitaryTime = false,\n\tuseSeconds = true,\n} = defineProps<\n\tComponentProps & {\n\t\tallowMilitaryTime?: boolean\n\t\tuseSeconds?: boolean\n\t}\n>()\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst modelValue = defineModel<string | Date | null>()\n\n/** Now, cut down to the smallest unit the picker shows, so a pick that leaves the time alone saves the time shown. */\nconst now = () =>\n\tTemporal.Now.zonedDateTimeISO().round({ smallestUnit: useSeconds ? 'second' : 'minute', roundingMode: 'trunc' })\n\n/** The field's moment on the user's clock, or null when the value names no moment. */\nconst readMoment = (value: string | Date): Temporal.ZonedDateTime | null => {\n\tconst epochMilliseconds = new Date(value).getTime()\n\tif (isNaN(epochMilliseconds)) return null\n\treturn Temporal.Instant.fromEpochMilliseconds(epochMilliseconds).toZonedDateTimeISO(Temporal.Now.timeZoneId())\n}\n\n/** What the field holds for a value: its moment, or now for an empty field, where the picker starts. */\nconst heldMoment = (value: string | Date | null | undefined) => (value ? readMoment(value) : now())\n\nconst currentDateTime = ref<Temporal.ZonedDateTime | null>(heldMoment(modelValue.value))\n\nconst { showPicker, calendarId, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('box'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = true\n}\n\n// A date and time as `toLocaleString` writes one by default, less the seconds.\nconst WITHOUT_SECONDS: Intl.DateTimeFormatOptions = {\n\tyear: 'numeric',\n\tmonth: 'numeric',\n\tday: 'numeric',\n\thour: 'numeric',\n\tminute: 'numeric',\n}\n\nconst displayValue = computed(() => {\n\tif (!modelValue.value) return ''\n\t// The wall-clock time alone: a `ZonedDateTime`'s own `toLocaleString` also names the zone.\n\tconst format = useSeconds ? undefined : WITHOUT_SECONDS\n\treturn currentDateTime.value?.toPlainDateTime().toLocaleString(undefined, format) ?? 'Invalid Date'\n})\n\nconst datetimeDisplay = computed(() => displayValue.value)\n\nconst pickerDefaults = computed(() => {\n\tconst d = currentDateTime.value ?? now()\n\tconst hours24 = d.hour\n\tconst meridiem = hours24 >= 12 ? 'PM' : 'AM'\n\tconst hours12 = hours24 % 12 || 12\n\treturn {\n\t\thours: allowMilitaryTime ? hours24 : hours12,\n\t\tminutes: d.minute,\n\t\tseconds: d.second,\n\t\tmeridiem,\n\t}\n})\n\nconst setMoment = (moment: Temporal.ZonedDateTime) => {\n\tcurrentDateTime.value = moment\n\tmodelValue.value = moment.toInstant().toString({ fractionalSecondDigits: 3 })\n}\n\nconst handleDate = (data: { selected: string }) => {\n\tconst day = fromISODate(data.selected)\n\tif (!day) return\n\tsetMoment((currentDateTime.value ?? now()).with({ year: day.year, month: day.month, day: day.day }))\n}\n\nconst handleTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\t// The widget announces its own starting value as it mounts, and those defaults come from\n\t// `pickerDefaults` — i.e. straight back out of this component. Writing that echo to the model\n\t// meant one click on an empty field silently filled it with the current date and time.\n\tif (data.source === 'init') return\n\n\tconst hours = data.militaryTime ?? data.hours\n\tsetMoment(\n\t\t(currentDateTime.value ?? now()).with({\n\t\t\thour: hours,\n\t\t\tminute: data.minutes,\n\t\t\tsecond: useSeconds ? data.seconds : 0,\n\t\t\tmillisecond: 0,\n\t\t\tmicrosecond: 0,\n\t\t\tnanosecond: 0,\n\t\t})\n\t)\n\t// Deliberately does NOT close the picker. `get-time` is the widget's current value, not a\n\t// commit — it fires on every blur, arrow key and meridiem change — so closing here shut the\n\t// picker as soon as the user tabbed out of the hours field. Dismissal is a click outside, Escape\n\t// or focus leaving the field; closing on `get-date` instead would strand the time half of a datetime.\n}\n\n// An empty value resets it too: skipping one kept the cleared moment, which the next pick wrote back.\nwatch(\n\t() => modelValue.value,\n\tnewValue => (currentDateTime.value = heldMoment(newValue))\n)\n</script>\n\n<style scoped>\n.adatetime-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"box\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-expanded=\"showPicker\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:value=\"datetimeDisplay\"\n\t\t\t\tplaceholder=\"Select date and time\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\treadonly\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adatetime-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:select-range=\"false\"\n\t\t\t\t:show-date=\"true\"\n\t\t\t\t:show-time=\"true\"\n\t\t\t\t:default-date=\"currentDateTime?.toPlainDate().toString()\"\n\t\t\t\t:default-hours=\"pickerDefaults.hours\"\n\t\t\t\t:default-minutes=\"pickerDefaults.minutes\"\n\t\t\t\t:default-seconds=\"pickerDefaults.seconds\"\n\t\t\t\t:default-meridiem=\"pickerDefaults.meridiem\"\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-date=\"handleDate\"\n\t\t\t\t@get-time=\"handleTime\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, ref, computed, useTemplateRef, watch } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport ADateSelection from './ADateSelection.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst {\n\tlabel = 'Date & Time',\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tallowMilitaryTime = false,\n\tuseSeconds = true,\n} = defineProps<\n\tComponentProps & {\n\t\tallowMilitaryTime?: boolean\n\t\tuseSeconds?: boolean\n\t}\n>()\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst modelValue = defineModel<string | Date | null>()\n\n/** Now, cut down to the smallest unit the picker shows, so a pick that leaves the time alone saves the time shown. */\nconst now = () =>\n\tTemporal.Now.zonedDateTimeISO().round({ smallestUnit: useSeconds ? 'second' : 'minute', roundingMode: 'trunc' })\n\n/** The field's moment on the user's clock, or null when the value names no moment. */\nconst readMoment = (value: string | Date): Temporal.ZonedDateTime | null => {\n\tconst epochMilliseconds = new Date(value).getTime()\n\tif (isNaN(epochMilliseconds)) return null\n\treturn Temporal.Instant.fromEpochMilliseconds(epochMilliseconds).toZonedDateTimeISO(Temporal.Now.timeZoneId())\n}\n\n/** What the field holds for a value: its moment, or now for an empty field, where the picker starts. */\nconst heldMoment = (value: string | Date | null | undefined) => (value ? readMoment(value) : now())\n\nconst currentDateTime = ref<Temporal.ZonedDateTime | null>(heldMoment(modelValue.value))\n\nconst { showPicker, calendarId, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('box'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = true\n}\n\n// A date and time as `toLocaleString` writes one by default, less the seconds.\nconst WITHOUT_SECONDS: Intl.DateTimeFormatOptions = {\n\tyear: 'numeric',\n\tmonth: 'numeric',\n\tday: 'numeric',\n\thour: 'numeric',\n\tminute: 'numeric',\n}\n\nconst displayValue = computed(() => {\n\tif (!modelValue.value) return ''\n\t// The wall-clock time alone: a `ZonedDateTime`'s own `toLocaleString` also names the zone.\n\tconst format = useSeconds ? undefined : WITHOUT_SECONDS\n\treturn currentDateTime.value?.toPlainDateTime().toLocaleString(undefined, format) ?? 'Invalid Date'\n})\n\nconst datetimeDisplay = computed(() => displayValue.value)\n\nconst pickerDefaults = computed(() => {\n\tconst d = currentDateTime.value ?? now()\n\tconst hours24 = d.hour\n\tconst meridiem = hours24 >= 12 ? 'PM' : 'AM'\n\tconst hours12 = hours24 % 12 || 12\n\treturn {\n\t\thours: allowMilitaryTime ? hours24 : hours12,\n\t\tminutes: d.minute,\n\t\tseconds: d.second,\n\t\tmeridiem,\n\t}\n})\n\nconst setMoment = (moment: Temporal.ZonedDateTime) => {\n\tcurrentDateTime.value = moment\n\tmodelValue.value = moment.toInstant().toString({ fractionalSecondDigits: 3 })\n}\n\nconst handleDate = (data: { selected: string }) => {\n\tconst day = fromISODate(data.selected)\n\tif (!day) return\n\tsetMoment((currentDateTime.value ?? now()).with({ year: day.year, month: day.month, day: day.day }))\n}\n\nconst handleTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\t// The widget announces its own starting value as it mounts, and those defaults come from\n\t// `pickerDefaults` — i.e. straight back out of this component. Writing that echo to the model\n\t// meant one click on an empty field silently filled it with the current date and time.\n\tif (data.source === 'init') return\n\n\tconst hours = data.militaryTime ?? data.hours\n\tsetMoment(\n\t\t(currentDateTime.value ?? now()).with({\n\t\t\thour: hours,\n\t\t\tminute: data.minutes,\n\t\t\tsecond: useSeconds ? data.seconds : 0,\n\t\t\tmillisecond: 0,\n\t\t\tmicrosecond: 0,\n\t\t\tnanosecond: 0,\n\t\t})\n\t)\n\t// Deliberately does NOT close the picker. `get-time` is the widget's current value, not a\n\t// commit — it fires on every blur, arrow key and meridiem change — so closing here shut the\n\t// picker as soon as the user tabbed out of the hours field. Dismissal is a click outside, Escape\n\t// or focus leaving the field; closing on `get-date` instead would strand the time half of a datetime.\n}\n\n// An empty value resets it too: skipping one kept the cleared moment, which the next pick wrote back.\nwatch(\n\t() => modelValue.value,\n\tnewValue => (currentDateTime.value = heldMoment(newValue))\n)\n</script>\n\n<style scoped>\n.adatetime-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<div class=\"aduration\">\n\t\t<template v-if=\"mode === 'display' || mode === 'read'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label>{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<ADateSelection\n\t\t\t\tref=\"selectionRef\"\n\t\t\t\t:select-range=\"true\"\n\t\t\t\t:show-time=\"true\"\n\t\t\t\t:show-end-time=\"true\"\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-range=\"handleRange\" />\n\t\t\t<div class=\"aduration__footer\">\n\t\t\t\t<label>{{ label }}</label>\n\t\t\t\t<div v-if=\"startDatetime && endDatetime\" class=\"aduration__summary\">\n\t\t\t\t\t<span class=\"aduration__label\">Duration:</span>\n\t\t\t\t\t<span class=\"aduration__value\">{{ humanDuration }}</span>\n\t\t\t\t\t<span class=\"aduration__held\">({{ modelValue }})</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { Temporal } from 'temporal-polyfill'\nimport { ref, computed } from 'vue'\nimport ADateSelection from './ADateSelection.vue'\n\nconst {\n\tlabel = 'Duration',\n\tmode = 'edit',\n\tallowMilitaryTime = false,\n\tuseSeconds = false,\n} = defineProps<{\n\tlabel?: string\n\tmode?: string\n\tallowMilitaryTime?: boolean\n\tuseSeconds?: boolean\n}>()\n\n// An ISO 8601 duration (`PT1H`), which Postgres and Temporal read natively and which, unlike a\n// count of milliseconds, holds days and months apart from hours.\nconst modelValue = defineModel<string | null>()\n\nconst startDatetime = ref<Date | null>(null)\nconst endDatetime = ref<Date | null>(null)\n\n// The time between two picks, counting a day as 24 hours; a pick before the start is no time at all.\nconst durationBetween = (start: Date, end: Date) =>\n\tTemporal.Duration.from({ milliseconds: Math.max(end.getTime() - start.getTime(), 0) })\n\t\t.round({ largestUnit: 'days' })\n\t\t.toString()\n\nconst handleRange = (data: { start: Date; end: Date; source?: 'init' | 'user' }) => {\n\t// Both time widgets announce their starting values as they mount, which ADateSelection turns\n\t// into a range. That is not a range the user picked: acting on it wrote a zero duration into the\n\t// model, and lit the summary strip, on first render.\n\tif (data.source === 'init') return\n\n\tstartDatetime.value = data.start\n\tendDatetime.value = data.end\n\tmodelValue.value = durationBetween(data.start, data.end)\n}\n\nconst readDuration = (value: string) => {\n\ttry {\n\t\treturn Temporal.Duration.from(value)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nconst UNIT_SUFFIXES = [\n\t['years', 'y'],\n\t['months', 'mo'],\n\t['weeks', 'w'],\n\t['days', 'd'],\n\t['hours', 'h'],\n\t['minutes', 'm'],\n] as const\n\n// The units the duration holds, as it holds them: `PT25H` is 25h, not 1d 1h.\nconst describeDuration = (duration: Temporal.Duration) => {\n\tconst parts = UNIT_SUFFIXES.filter(([unit]) => duration[unit]).map(([unit, suffix]) => `${duration[unit]}${suffix}`)\n\tconst seconds =\n\t\tduration.seconds + duration.milliseconds / 1e3 + duration.microseconds / 1e6 + duration.nanoseconds / 1e9\n\tif (seconds) parts.push(`${seconds}s`)\n\treturn parts.join(' ') || '0s'\n}\n\nconst heldDuration = computed(() => (modelValue.value ? readDuration(modelValue.value) : undefined))\n\nconst humanDuration = computed(() => (heldDuration.value ? describeDuration(heldDuration.value) : '0s'))\n\nconst displayValue = computed(() => {\n\tif (!modelValue.value) return '—'\n\tif (!heldDuration.value) return 'Invalid Duration'\n\treturn heldDuration.value.blank ? '—' : describeDuration(heldDuration.value)\n})\n</script>\n\n<style scoped>\n.aduration {\n\tposition: relative;\n\twidth: max-content;\n\tmax-width: 100%;\n}\n\n.aduration__summary {\n\tdisplay: flex;\n\tgap: 6px;\n\talign-items: baseline;\n\tmargin-top: 6px;\n\tfont-size: 0.9em;\n}\n\n.aduration__label {\n\tfont-weight: bold;\n\tcolor: var(--sc-input-active-label-color);\n}\n\n.aduration__value {\n\tcolor: var(--sc-cell-text-color);\n}\n\n.aduration__held {\n\tcolor: var(--sc-gray-50);\n\tfont-size: 0.85em;\n}\n\n.aduration__footer {\n\tmargin-top: 8px;\n}\n</style>\n","<template>\n\t<div class=\"aduration\">\n\t\t<template v-if=\"mode === 'display' || mode === 'read'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label>{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<ADateSelection\n\t\t\t\tref=\"selectionRef\"\n\t\t\t\t:select-range=\"true\"\n\t\t\t\t:show-time=\"true\"\n\t\t\t\t:show-end-time=\"true\"\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-range=\"handleRange\" />\n\t\t\t<div class=\"aduration__footer\">\n\t\t\t\t<label>{{ label }}</label>\n\t\t\t\t<div v-if=\"startDatetime && endDatetime\" class=\"aduration__summary\">\n\t\t\t\t\t<span class=\"aduration__label\">Duration:</span>\n\t\t\t\t\t<span class=\"aduration__value\">{{ humanDuration }}</span>\n\t\t\t\t\t<span class=\"aduration__held\">({{ modelValue }})</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { Temporal } from 'temporal-polyfill'\nimport { ref, computed } from 'vue'\nimport ADateSelection from './ADateSelection.vue'\n\nconst {\n\tlabel = 'Duration',\n\tmode = 'edit',\n\tallowMilitaryTime = false,\n\tuseSeconds = false,\n} = defineProps<{\n\tlabel?: string\n\tmode?: string\n\tallowMilitaryTime?: boolean\n\tuseSeconds?: boolean\n}>()\n\n// An ISO 8601 duration (`PT1H`), which Postgres and Temporal read natively and which, unlike a\n// count of milliseconds, holds days and months apart from hours.\nconst modelValue = defineModel<string | null>()\n\nconst startDatetime = ref<Date | null>(null)\nconst endDatetime = ref<Date | null>(null)\n\n// The time between two picks, counting a day as 24 hours; a pick before the start is no time at all.\nconst durationBetween = (start: Date, end: Date) =>\n\tTemporal.Duration.from({ milliseconds: Math.max(end.getTime() - start.getTime(), 0) })\n\t\t.round({ largestUnit: 'days' })\n\t\t.toString()\n\nconst handleRange = (data: { start: Date; end: Date; source?: 'init' | 'user' }) => {\n\t// Both time widgets announce their starting values as they mount, which ADateSelection turns\n\t// into a range. That is not a range the user picked: acting on it wrote a zero duration into the\n\t// model, and lit the summary strip, on first render.\n\tif (data.source === 'init') return\n\n\tstartDatetime.value = data.start\n\tendDatetime.value = data.end\n\tmodelValue.value = durationBetween(data.start, data.end)\n}\n\nconst readDuration = (value: string) => {\n\ttry {\n\t\treturn Temporal.Duration.from(value)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nconst UNIT_SUFFIXES = [\n\t['years', 'y'],\n\t['months', 'mo'],\n\t['weeks', 'w'],\n\t['days', 'd'],\n\t['hours', 'h'],\n\t['minutes', 'm'],\n] as const\n\n// The units the duration holds, as it holds them: `PT25H` is 25h, not 1d 1h.\nconst describeDuration = (duration: Temporal.Duration) => {\n\tconst parts = UNIT_SUFFIXES.filter(([unit]) => duration[unit]).map(([unit, suffix]) => `${duration[unit]}${suffix}`)\n\tconst seconds =\n\t\tduration.seconds + duration.milliseconds / 1e3 + duration.microseconds / 1e6 + duration.nanoseconds / 1e9\n\tif (seconds) parts.push(`${seconds}s`)\n\treturn parts.join(' ') || '0s'\n}\n\nconst heldDuration = computed(() => (modelValue.value ? readDuration(modelValue.value) : undefined))\n\nconst humanDuration = computed(() => (heldDuration.value ? describeDuration(heldDuration.value) : '0s'))\n\nconst displayValue = computed(() => {\n\tif (!modelValue.value) return '—'\n\tif (!heldDuration.value) return 'Invalid Duration'\n\treturn heldDuration.value.blank ? '—' : describeDuration(heldDuration.value)\n})\n</script>\n\n<style scoped>\n.aduration {\n\tposition: relative;\n\twidth: max-content;\n\tmax-width: 100%;\n}\n\n.aduration__summary {\n\tdisplay: flex;\n\tgap: 6px;\n\talign-items: baseline;\n\tmargin-top: 6px;\n\tfont-size: 0.9em;\n}\n\n.aduration__label {\n\tfont-weight: bold;\n\tcolor: var(--sc-input-active-label-color);\n}\n\n.aduration__value {\n\tcolor: var(--sc-cell-text-color);\n}\n\n.aduration__held {\n\tcolor: var(--sc-gray-50);\n\tfont-size: 0.85em;\n}\n\n.aduration__footer {\n\tmargin-top: 8px;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"box\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-expanded=\"showPicker\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:value=\"rangeDisplay\"\n\t\t\t\tplaceholder=\"Select date range\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\treadonly\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adaterange-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:select-range=\"true\"\n\t\t\t\t:show-time=\"false\"\n\t\t\t\t@get-date=\"handlePickerDate\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, ref, computed, useTemplateRef, watch } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport ADateSelection from './ADateSelection.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst fmt = (d: string) => fromISODate(d)?.toLocaleString() ?? 'Invalid Date'\n\nconst { label = 'Date Range', mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nexport interface DateRangeValue {\n\tstart_date: string | null\n\tend_date: string | null\n}\n\nconst modelValue = defineModel<DateRangeValue | null>({\n\tdefault: () => ({ start_date: null, end_date: null }),\n})\n\nconst readDay = (day: string | null | undefined) => (day ? (fromISODate(day) ?? null) : null)\n\nconst startDate = ref<Temporal.PlainDate | null>(readDay(modelValue.value?.start_date))\nconst endDate = ref<Temporal.PlainDate | null>(readDay(modelValue.value?.end_date))\n\nconst { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('box'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = true\n}\n\nconst formatDate = (d: Temporal.PlainDate | null): string => d?.toLocaleString() ?? ''\n\nconst rangeDisplay = computed(() => {\n\tconst s = formatDate(startDate.value)\n\tconst e = formatDate(endDate.value)\n\tif (s && e) return `${s} — ${e}`\n\tif (s) return `${s} — ...`\n\treturn ''\n})\n\nconst displayValue = computed(() => {\n\tconst s = modelValue.value?.start_date\n\tconst e = modelValue.value?.end_date\n\tif (!s && !e) return ''\n\tif (s && e) return `${fmt(s)} — ${fmt(e)}`\n\tif (s) return `From ${fmt(s)}`\n\treturn `Until ${fmt(e!)}`\n})\n\nconst ensureOrder = () => {\n\tconst s = startDate.value\n\tconst e = endDate.value\n\tif (s && e && Temporal.PlainDate.compare(e, s) < 0) {\n\t\t;[startDate.value, endDate.value] = [e, s]\n\t}\n}\n\nconst emitModel = () => {\n\tmodelValue.value = {\n\t\tstart_date: startDate.value?.toString() ?? null,\n\t\tend_date: endDate.value?.toString() ?? null,\n\t}\n}\n\nconst handlePickerDate = (data: { selected: string; start?: string | null; end?: string | null }) => {\n\tif (data.start) startDate.value = readDay(data.start)\n\tif (data.end) {\n\t\tendDate.value = readDay(data.end)\n\t\tensureOrder()\n\t\tclosePicker()\n\t}\n\temitModel()\n}\n\nwatch(\n\t() => modelValue.value,\n\tnewVal => {\n\t\tstartDate.value = readDay(newVal?.start_date)\n\t\tendDate.value = readDay(newVal?.end_date)\n\t},\n\t{ deep: true }\n)\n</script>\n\n<style scoped>\n.adaterange-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"box\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-expanded=\"showPicker\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:value=\"rangeDisplay\"\n\t\t\t\tplaceholder=\"Select date range\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\treadonly\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adaterange-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:select-range=\"true\"\n\t\t\t\t:show-time=\"false\"\n\t\t\t\t@get-date=\"handlePickerDate\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, ref, computed, useTemplateRef, watch } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport ADateSelection from './ADateSelection.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst fmt = (d: string) => fromISODate(d)?.toLocaleString() ?? 'Invalid Date'\n\nconst { label = 'Date Range', mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nexport interface DateRangeValue {\n\tstart_date: string | null\n\tend_date: string | null\n}\n\nconst modelValue = defineModel<DateRangeValue | null>({\n\tdefault: () => ({ start_date: null, end_date: null }),\n})\n\nconst readDay = (day: string | null | undefined) => (day ? (fromISODate(day) ?? null) : null)\n\nconst startDate = ref<Temporal.PlainDate | null>(readDay(modelValue.value?.start_date))\nconst endDate = ref<Temporal.PlainDate | null>(readDay(modelValue.value?.end_date))\n\nconst { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('box'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = true\n}\n\nconst formatDate = (d: Temporal.PlainDate | null): string => d?.toLocaleString() ?? ''\n\nconst rangeDisplay = computed(() => {\n\tconst s = formatDate(startDate.value)\n\tconst e = formatDate(endDate.value)\n\tif (s && e) return `${s} — ${e}`\n\tif (s) return `${s} — ...`\n\treturn ''\n})\n\nconst displayValue = computed(() => {\n\tconst s = modelValue.value?.start_date\n\tconst e = modelValue.value?.end_date\n\tif (!s && !e) return ''\n\tif (s && e) return `${fmt(s)} — ${fmt(e)}`\n\tif (s) return `From ${fmt(s)}`\n\treturn `Until ${fmt(e!)}`\n})\n\nconst ensureOrder = () => {\n\tconst s = startDate.value\n\tconst e = endDate.value\n\tif (s && e && Temporal.PlainDate.compare(e, s) < 0) {\n\t\t;[startDate.value, endDate.value] = [e, s]\n\t}\n}\n\nconst emitModel = () => {\n\tmodelValue.value = {\n\t\tstart_date: startDate.value?.toString() ?? null,\n\t\tend_date: endDate.value?.toString() ?? null,\n\t}\n}\n\nconst handlePickerDate = (data: { selected: string; start?: string | null; end?: string | null }) => {\n\tif (data.start) startDate.value = readDay(data.start)\n\tif (data.end) {\n\t\tendDate.value = readDay(data.end)\n\t\tensureOrder()\n\t\tclosePicker()\n\t}\n\temitModel()\n}\n\nwatch(\n\t() => modelValue.value,\n\tnewVal => {\n\t\tstartDate.value = readDay(newVal?.start_date)\n\t\tendDate.value = readDay(newVal?.end_date)\n\t},\n\t{ deep: true }\n)\n</script>\n\n<style scoped>\n.adaterange-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<form class=\"aform\">\n\t\t<template v-for=\"(componentObj, key) in schema\" :key=\"key\">\n\t\t\t<!-- A linked record: its form binds the link's own value -->\n\t\t\t<div v-if=\"isLinkSection(componentObj)\" class=\"aform-nested-section\">\n\t\t\t\t<h4 v-if=\"componentObj.label\" class=\"aform-nested-label\">\n\t\t\t\t\t{{ componentObj.label }}\n\t\t\t\t</h4>\n\t\t\t\t<component\n\t\t\t\t\t:is=\"componentObj.component ?? 'AForm'\"\n\t\t\t\t\t:data=\"nestedData[componentObj.fieldname]\"\n\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t:schema=\"componentObj.schema\"\n\t\t\t\t\t:label=\"componentObj.label\"\n\t\t\t\t\t:errors=\"errors\"\n\t\t\t\t\t@update:data=\"(val: any) => updateNestedData(componentObj.fieldname, val)\" />\n\t\t\t</div>\n\n\t\t\t<!-- A fieldset is layout: its fields are this record's own, so it binds this record.\n\t\t\t\t No h4, since AFieldset renders its own legend. -->\n\t\t\t<div v-else-if=\"isFieldsetSection(componentObj)\" class=\"aform-nested-section\">\n\t\t\t\t<component\n\t\t\t\t\t:is=\"componentObj.component ?? 'AFieldset'\"\n\t\t\t\t\t:data=\"dataModel\"\n\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t:schema=\"componentObj.schema\"\n\t\t\t\t\t:label=\"componentObj.label\"\n\t\t\t\t\t:collapsible=\"componentObj.collapsible\"\n\t\t\t\t\t:errors=\"errors\"\n\t\t\t\t\t@update:data=\"updateFieldsetData\" />\n\t\t\t</div>\n\n\t\t\t<!-- Regular field -->\n\t\t\t<component\n\t\t\t\t:is=\"componentObj.component\"\n\t\t\t\tv-else-if=\"!componentObj.hidden\"\n\t\t\t\tv-model=\"childModels[key].value\"\n\t\t\t\t:style=\"fieldStyle(componentObj)\"\n\t\t\t\t:schema=\"componentObj\"\n\t\t\t\t:data=\"dataModel[componentObj.fieldname]\"\n\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t:errors=\"fieldErrors(componentObj)\"\n\t\t\t\tv-bind=\"componentProps(componentObj)\">\n\t\t\t\t<template v-if=\"isListExpansionTable(componentObj)\" #content=\"{ row, rowIndex }\">\n\t\t\t\t\t<AForm\n\t\t\t\t\t\tclass=\"aform-table-expansion\"\n\t\t\t\t\t\t:data=\"row\"\n\t\t\t\t\t\t:schema=\"tableExpansionSchema(componentObj)\"\n\t\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t\t@update:data=\"val => updateTableRow(componentObj.fieldname, rowIndex, val)\" />\n\t\t\t\t</template>\n\t\t\t</component>\n\t\t</template>\n\t</form>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, watchEffect, watch, ref, useId } from 'vue'\n\nimport type { ResolvedField, ResolvedLink, ResolvedFieldset, ResolvedTable } from '../types'\nimport { partsPatch, readParts } from '@stonecrop/schema'\nimport type { ColumnSchema, InteractionMode } from '@stonecrop/schema'\n\nconst emit = defineEmits(['update:schema', 'update:data'])\nconst dataModel = defineModel<Record<string, any>>('data', { required: true })\nconst {\n\tschema,\n\tmode = 'edit',\n\terrors,\n} = defineProps<{\n\tschema: ResolvedField[]\n\tmode?: InteractionMode\n\t/** Inline validation errors keyed by fieldname. Fed by the host; the form stays store-agnostic. */\n\terrors?: Record<string, string[]>\n}>()\n\nconst hasChildSchema = (componentObj: ResolvedField) =>\n\t'schema' in componentObj && Array.isArray(componentObj.schema) && componentObj.schema.length > 0\n\nconst isLinkSection = (componentObj: ResolvedField): componentObj is ResolvedLink =>\n\tcomponentObj.kind === 'link' && hasChildSchema(componentObj)\n\nconst isFieldsetSection = (componentObj: ResolvedField): componentObj is ResolvedFieldset =>\n\tcomponentObj.kind === 'fieldset' && hasChildSchema(componentObj)\n\n// Reactive nested data refs for two-way binding with the forms of linked records\nconst nestedData = ref<Record<string, any>>({})\n\n// Sync external dataModel changes into nestedData (one-way, no emit back).\n// Uses a shallow watch so only top-level object replacement (e.g. parent reset)\n// triggers a sync — property mutations from within are handled by updateNestedData.\nwatch(\n\t() => dataModel.value,\n\tnewData => {\n\t\tif (!schema || !newData) return\n\t\tschema.forEach(field => {\n\t\t\tif (isLinkSection(field)) {\n\t\t\t\tnestedData.value[field.fieldname] = newData[field.fieldname] ?? {}\n\t\t\t}\n\t\t})\n\t},\n\t{ immediate: true }\n)\n\n// A nested form's edits: updates nestedData locally and propagates upward in one step,\n// avoiding the watchEffect feedback loop that occurred with v-model.\nconst updateNestedData = (fieldname: string, val: any) => {\n\tnestedData.value[fieldname] = val\n\tif (dataModel.value) {\n\t\tdataModel.value[fieldname] = val\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\n// A fieldset's edits. Its form holds this record, so its edits are this record's.\nconst updateFieldsetData = (val: Record<string, any>) => {\n\tif (dataModel.value) {\n\t\tObject.assign(dataModel.value, val)\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\nconst isListExpansionTable = (componentObj: ResolvedField): componentObj is ResolvedTable =>\n\tcomponentObj.kind === 'table' && componentObj.config?.view === 'list-expansion'\n\nconst tableExpansionSchema = (table: ResolvedTable): ResolvedField[] =>\n\ttable.schema\n\t\t.filter((col): col is ColumnSchema & { component: string } => Boolean(col.component))\n\t\t.map(({ fieldname, component, ...rest }) => Object.assign(rest, { kind: 'field' as const, fieldname, component }))\n\nconst updateTableRows = (fieldname: string, rows: Record<string, unknown>[]) => {\n\tif (dataModel.value) {\n\t\tdataModel.value[fieldname] = rows\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\nconst updateTableRow = (fieldname: string, rowIndex: number, val: Record<string, unknown>) => {\n\tconst rows = Array.isArray(dataModel.value?.[fieldname]) ? [...dataModel.value[fieldname]] : []\n\trows[rowIndex] = { ...rows[rowIndex], ...val }\n\tupdateTableRows(fieldname, rows)\n}\n\n// Each field's `uuid` ties its label and error message to its input; one id per form keeps them\n// unique when several forms, or a fieldset's nested form, share a page.\nconst formId = useId()\n\nconst componentProps = (componentObj: ResolvedField) => {\n\tconst propsToPass: Record<string, any> = {}\n\tfor (const [key, value] of Object.entries(componentObj)) {\n\t\t// 'mode' is excluded here because it is handled by resolvedMode()\n\t\t// and passed explicitly via :mode to avoid conflicting with the form-level defaults.\n\t\tif (\n\t\t\t!['component', 'primaryKey', 'computed', 'language', 'hidden', 'mode', 'width', 'height', 'parts'].includes(key)\n\t\t) {\n\t\t\tpropsToPass[key] = value\n\t\t}\n\t}\n\tpropsToPass['uuid'] ??= `${formId}-${componentObj.fieldname}`\n\n\t// A table sources its rows from the data model, never from the schema, and its edits come back\n\t// through `update:rows`. `kind` is the only check: every path into AForm sets it (Zod's\n\t// injectKind, Doctype.fromObject's normalizeFieldKind, and the registry), and hand-built\n\t// ResolvedTable literals declare it.\n\tif (componentObj.kind === 'table') {\n\t\tpropsToPass['rows'] = dataModel.value[componentObj.fieldname] || []\n\t\tpropsToPass['onUpdate:rows'] = (rows: Record<string, unknown>[]) => updateTableRows(componentObj.fieldname, rows)\n\t}\n\n\treturn propsToPass\n}\n\nconst fieldStyle = (componentObj: ResolvedField): Record<string, string> => {\n\tif (componentObj.kind !== 'field') return {}\n\tconst style: Record<string, string> = {}\n\tif (componentObj.width) {\n\t\tstyle.flexBasis = componentObj.width\n\t\tstyle.width = componentObj.width\n\t}\n\tif (componentObj.height) {\n\t\tstyle.height = componentObj.height\n\t\tstyle.minHeight = '0'\n\t\tstyle.flexGrow = '1'\n\t\tstyle.alignSelf = 'stretch'\n\t}\n\treturn style\n}\n\nconst effectiveFormMode = computed(() => mode ?? 'edit')\n\n// Resolve the effective mode for a schema field, allowing per-field overrides\nfunction resolvedMode(componentObj: ResolvedField): InteractionMode {\n\tconst fieldMode = componentObj.mode\n\tif (fieldMode) return fieldMode\n\treturn effectiveFormMode.value\n}\n\n// A field declaring `parts` binds the value its component edits, read part by part from the fields\n// that hold them and written back only where a part changed.\nconst fieldParts = (field: ResolvedField): Record<string, string> | undefined =>\n\tfield.kind === 'field' ? field.parts : undefined\n\nconst fieldErrors = (field: ResolvedField): string[] | undefined => {\n\tconst parts = fieldParts(field)\n\tif (!parts) return errors?.[field.fieldname]\n\treturn Object.values(parts).flatMap(fieldname => errors?.[fieldname] ?? [])\n}\n\n// Create stable computed refs array to avoid recreation on every access\nconst childModelsCache = ref<ReturnType<typeof computed>[]>([])\n\n// Watch for schema changes and update cache (avoiding side effects in computed)\nwatchEffect(() => {\n\tif (!schema) return\n\n\t// Recreate cache only if length changed\n\tif (childModelsCache.value.length !== schema.length) {\n\t\tchildModelsCache.value = schema.map((_field, index) => {\n\t\t\treturn computed({\n\t\t\t\tget() {\n\t\t\t\t\tconst parts = fieldParts(schema[index])\n\t\t\t\t\tif (parts) return readParts(parts, dataModel.value ?? {})\n\t\t\t\t\treturn dataModel.value?.[schema[index].fieldname]\n\t\t\t\t},\n\t\t\t\tset: (newValue: any) => {\n\t\t\t\t\tconst parts = fieldParts(schema[index])\n\t\t\t\t\tconst fieldname = schema[index].fieldname\n\t\t\t\t\tif (parts && dataModel.value) {\n\t\t\t\t\t\tObject.assign(dataModel.value, partsPatch(parts, dataModel.value, newValue))\n\t\t\t\t\t\temit('update:data', { ...dataModel.value })\n\t\t\t\t\t} else if (fieldname && dataModel.value) {\n\t\t\t\t\t\tdataModel.value[fieldname] = newValue\n\t\t\t\t\t\temit('update:data', { ...dataModel.value })\n\t\t\t\t\t}\n\t\t\t\t\temit('update:schema', schema)\n\t\t\t\t},\n\t\t\t})\n\t\t})\n\t}\n})\n\n// Computed just returns the cached models (no side effects)\nconst childModels = computed(() => childModelsCache.value)\n</script>\n\n<style>\n/* global styles for aform */\n.aform input {\n\tfont-family: var(--sc-font-family);\n\tborder: none;\n}\n.aform_form-element {\n\tpadding: var(--sc-form-label-offset) 0 0;\n\tmargin: 0;\n\tposition: relative;\n\tbox-sizing: border-box;\n\tflex-grow: 1;\n\tmin-width: 20ch;\n\tmax-width: var(--sc-form-field-max-width);\n\t/* margin-bottom: 1rem; */\n}\n.aform__grid--full {\n\tflex-basis: 100%;\n\twidth: 100%;\n}\n.aform_input-field {\n\tborder: none;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tfont-size: 1rem;\n\tpadding: 0.5rem;\n\tmargin: 0 0 0 0;\n\tborder-radius: 0;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: auto;\n\tposition: relative;\n\tcolor: var(--sc-cell-text-color);\n\tbackground: var(--sc-input-field-background);\n\tfont-family: var(--sc-font-family);\n}\n.aform_input-field:focus {\n\toutline: 1px solid var(--sc-input-active-border-color);\n}\n\n.aform_display-value {\n\tdisplay: block;\n\tpadding: 0.5rem;\n\tmin-height: 2rem;\n\tcolor: var(--sc-cell-text-color);\n\tword-break: break-word;\n}\n\n/* A label darkens while anything beside it holds focus, wherever it sits in its field's markup. */\n:focus-within > .aform_field-label {\n\tcolor: var(--sc-input-active-label-color);\n}\n\n.aform_field-label {\n\tcolor: var(--sc-input-label-color);\n\tdisplay: inline-block;\n\tposition: absolute;\n\tuser-select: none;\n\tpadding: 0 0.25rem;\n\tmargin: 0rem;\n\tz-index: 1;\n\tfont-size: 0.7rem;\n\tfont-weight: 300;\n\tletter-spacing: 0.05rem;\n\t/* The form colour masks the field's top border behind the text; below it the field shows\n\t through. Never paint a colour there: it can match only one of the surfaces a field shows. */\n\tbackground: linear-gradient(var(--sc-form-background) calc(50% + 1px), transparent calc(50% + 1px));\n\twidth: auto;\n\tbox-sizing: border-box;\n\tmargin: 0;\n\tgrid-row: 1;\n\ttop: 0;\n\tleft: 10px;\n\tborder: none;\n\tline-height: 0;\n\ttransform: translateY(-50%);\n}\n.aform_form-element > .aform_field-label {\n\ttop: var(--sc-form-label-offset);\n}\n\n.aform_input-field:disabled,\n.aform_checkbox-container:has(.aform_checkbox:disabled) {\n\tbackground: var(--sc-input-field-disabled-background);\n}\n.aform_field-label::after {\n\tmargin: 0;\n\tpadding: 0;\n\tbox-sizing: border-box;\n\tcontent: '';\n\tline-height: normal;\n}\np.aform_error {\n\t/* v-show toggles visibility per field; base display must be visible (was stuck at `none`,\n\t which overrode v-show and left every field error dormant). */\n\tdisplay: inline-block;\n\t/* Straddles the border like .aform_field-label, and paints the same way. */\n\tbackground: linear-gradient(var(--sc-form-background) calc(50% + 1px), transparent calc(50% + 1px));\n\tpadding: 0 0.25rem;\n\tmargin: 0rem;\n\twidth: auto;\n\tcolor: var(--sc-brand-danger);\n\tfont-size: 0.7rem;\n\tposition: absolute;\n\tright: 0;\n\ttop: var(--sc-form-label-offset);\n\tline-height: 0;\n\tpadding: 0.25rem;\n\ttransform: translate(-1rem, -50%);\n\tmargin: 0;\n}\n</style>\n\n<style scoped>\n.aform {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 1rem;\n\tpadding: 1rem;\n\tbackground: var(--sc-form-background);\n\tborder: 1px solid var(--sc-form-border);\n\tborder-left: 4px solid var(--sc-form-border);\n\tmargin-bottom: 1rem;\n\tmax-width: 100%;\n}\n@media screen and (max-width: 400px) {\n\t.aform {\n\t\tflex-direction: column;\n\t}\n}\n\n/* Nested form section */\n.aform-nested-section {\n\twidth: 100%;\n\tpadding: 0.5rem 0;\n}\n\n.aform-nested-label {\n\tfont-size: 0.9rem;\n\tfont-weight: 600;\n\tmargin: 0 0 0.5rem 0;\n\tcolor: var(--sc-input-label-color);\n}\n\n.aform-nested-section .aform {\n\tborder-left-width: 2px;\n\tmargin-left: 0.5rem;\n}\n\n.aform-table-expansion {\n\tmargin-bottom: 0;\n\tborder: none;\n\tborder-left: none;\n\tpadding: 0;\n}\n</style>\n","<template>\n\t<form class=\"aform\">\n\t\t<template v-for=\"(componentObj, key) in schema\" :key=\"key\">\n\t\t\t<!-- A linked record: its form binds the link's own value -->\n\t\t\t<div v-if=\"isLinkSection(componentObj)\" class=\"aform-nested-section\">\n\t\t\t\t<h4 v-if=\"componentObj.label\" class=\"aform-nested-label\">\n\t\t\t\t\t{{ componentObj.label }}\n\t\t\t\t</h4>\n\t\t\t\t<component\n\t\t\t\t\t:is=\"componentObj.component ?? 'AForm'\"\n\t\t\t\t\t:data=\"nestedData[componentObj.fieldname]\"\n\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t:schema=\"componentObj.schema\"\n\t\t\t\t\t:label=\"componentObj.label\"\n\t\t\t\t\t:errors=\"errors\"\n\t\t\t\t\t@update:data=\"(val: any) => updateNestedData(componentObj.fieldname, val)\" />\n\t\t\t</div>\n\n\t\t\t<!-- A fieldset is layout: its fields are this record's own, so it binds this record.\n\t\t\t\t No h4, since AFieldset renders its own legend. -->\n\t\t\t<div v-else-if=\"isFieldsetSection(componentObj)\" class=\"aform-nested-section\">\n\t\t\t\t<component\n\t\t\t\t\t:is=\"componentObj.component ?? 'AFieldset'\"\n\t\t\t\t\t:data=\"dataModel\"\n\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t:schema=\"componentObj.schema\"\n\t\t\t\t\t:label=\"componentObj.label\"\n\t\t\t\t\t:collapsible=\"componentObj.collapsible\"\n\t\t\t\t\t:errors=\"errors\"\n\t\t\t\t\t@update:data=\"updateFieldsetData\" />\n\t\t\t</div>\n\n\t\t\t<!-- Regular field -->\n\t\t\t<component\n\t\t\t\t:is=\"componentObj.component\"\n\t\t\t\tv-else-if=\"!componentObj.hidden\"\n\t\t\t\tv-model=\"childModels[key].value\"\n\t\t\t\t:style=\"fieldStyle(componentObj)\"\n\t\t\t\t:schema=\"componentObj\"\n\t\t\t\t:data=\"dataModel[componentObj.fieldname]\"\n\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t:errors=\"fieldErrors(componentObj)\"\n\t\t\t\tv-bind=\"componentProps(componentObj)\">\n\t\t\t\t<template v-if=\"isListExpansionTable(componentObj)\" #content=\"{ row, rowIndex }\">\n\t\t\t\t\t<AForm\n\t\t\t\t\t\tclass=\"aform-table-expansion\"\n\t\t\t\t\t\t:data=\"row\"\n\t\t\t\t\t\t:schema=\"tableExpansionSchema(componentObj)\"\n\t\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t\t@update:data=\"val => updateTableRow(componentObj.fieldname, rowIndex, val)\" />\n\t\t\t\t</template>\n\t\t\t</component>\n\t\t</template>\n\t</form>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, watchEffect, watch, ref, useId } from 'vue'\n\nimport type { ResolvedField, ResolvedLink, ResolvedFieldset, ResolvedTable } from '../types'\nimport { partsPatch, readParts } from '@stonecrop/schema'\nimport type { ColumnSchema, InteractionMode } from '@stonecrop/schema'\n\nconst emit = defineEmits(['update:schema', 'update:data'])\nconst dataModel = defineModel<Record<string, any>>('data', { required: true })\nconst {\n\tschema,\n\tmode = 'edit',\n\terrors,\n} = defineProps<{\n\tschema: ResolvedField[]\n\tmode?: InteractionMode\n\t/** Inline validation errors keyed by fieldname. Fed by the host; the form stays store-agnostic. */\n\terrors?: Record<string, string[]>\n}>()\n\nconst hasChildSchema = (componentObj: ResolvedField) =>\n\t'schema' in componentObj && Array.isArray(componentObj.schema) && componentObj.schema.length > 0\n\nconst isLinkSection = (componentObj: ResolvedField): componentObj is ResolvedLink =>\n\tcomponentObj.kind === 'link' && hasChildSchema(componentObj)\n\nconst isFieldsetSection = (componentObj: ResolvedField): componentObj is ResolvedFieldset =>\n\tcomponentObj.kind === 'fieldset' && hasChildSchema(componentObj)\n\n// Reactive nested data refs for two-way binding with the forms of linked records\nconst nestedData = ref<Record<string, any>>({})\n\n// Sync external dataModel changes into nestedData (one-way, no emit back).\n// Uses a shallow watch so only top-level object replacement (e.g. parent reset)\n// triggers a sync — property mutations from within are handled by updateNestedData.\nwatch(\n\t() => dataModel.value,\n\tnewData => {\n\t\tif (!schema || !newData) return\n\t\tschema.forEach(field => {\n\t\t\tif (isLinkSection(field)) {\n\t\t\t\tnestedData.value[field.fieldname] = newData[field.fieldname] ?? {}\n\t\t\t}\n\t\t})\n\t},\n\t{ immediate: true }\n)\n\n// A nested form's edits: updates nestedData locally and propagates upward in one step,\n// avoiding the watchEffect feedback loop that occurred with v-model.\nconst updateNestedData = (fieldname: string, val: any) => {\n\tnestedData.value[fieldname] = val\n\tif (dataModel.value) {\n\t\tdataModel.value[fieldname] = val\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\n// A fieldset's edits. Its form holds this record, so its edits are this record's.\nconst updateFieldsetData = (val: Record<string, any>) => {\n\tif (dataModel.value) {\n\t\tObject.assign(dataModel.value, val)\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\nconst isListExpansionTable = (componentObj: ResolvedField): componentObj is ResolvedTable =>\n\tcomponentObj.kind === 'table' && componentObj.config?.view === 'list-expansion'\n\nconst tableExpansionSchema = (table: ResolvedTable): ResolvedField[] =>\n\ttable.schema\n\t\t.filter((col): col is ColumnSchema & { component: string } => Boolean(col.component))\n\t\t.map(({ fieldname, component, ...rest }) => Object.assign(rest, { kind: 'field' as const, fieldname, component }))\n\nconst updateTableRows = (fieldname: string, rows: Record<string, unknown>[]) => {\n\tif (dataModel.value) {\n\t\tdataModel.value[fieldname] = rows\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\nconst updateTableRow = (fieldname: string, rowIndex: number, val: Record<string, unknown>) => {\n\tconst rows = Array.isArray(dataModel.value?.[fieldname]) ? [...dataModel.value[fieldname]] : []\n\trows[rowIndex] = { ...rows[rowIndex], ...val }\n\tupdateTableRows(fieldname, rows)\n}\n\n// Each field's `uuid` ties its label and error message to its input; one id per form keeps them\n// unique when several forms, or a fieldset's nested form, share a page.\nconst formId = useId()\n\nconst componentProps = (componentObj: ResolvedField) => {\n\tconst propsToPass: Record<string, any> = {}\n\tfor (const [key, value] of Object.entries(componentObj)) {\n\t\t// 'mode' is excluded here because it is handled by resolvedMode()\n\t\t// and passed explicitly via :mode to avoid conflicting with the form-level defaults.\n\t\tif (\n\t\t\t!['component', 'primaryKey', 'computed', 'language', 'hidden', 'mode', 'width', 'height', 'parts'].includes(key)\n\t\t) {\n\t\t\tpropsToPass[key] = value\n\t\t}\n\t}\n\tpropsToPass['uuid'] ??= `${formId}-${componentObj.fieldname}`\n\n\t// A table sources its rows from the data model, never from the schema, and its edits come back\n\t// through `update:rows`. `kind` is the only check: every path into AForm sets it (Zod's\n\t// injectKind, Doctype.fromObject's normalizeFieldKind, and the registry), and hand-built\n\t// ResolvedTable literals declare it.\n\tif (componentObj.kind === 'table') {\n\t\tpropsToPass['rows'] = dataModel.value[componentObj.fieldname] || []\n\t\tpropsToPass['onUpdate:rows'] = (rows: Record<string, unknown>[]) => updateTableRows(componentObj.fieldname, rows)\n\t}\n\n\treturn propsToPass\n}\n\nconst fieldStyle = (componentObj: ResolvedField): Record<string, string> => {\n\tif (componentObj.kind !== 'field') return {}\n\tconst style: Record<string, string> = {}\n\tif (componentObj.width) {\n\t\tstyle.flexBasis = componentObj.width\n\t\tstyle.width = componentObj.width\n\t}\n\tif (componentObj.height) {\n\t\tstyle.height = componentObj.height\n\t\tstyle.minHeight = '0'\n\t\tstyle.flexGrow = '1'\n\t\tstyle.alignSelf = 'stretch'\n\t}\n\treturn style\n}\n\nconst effectiveFormMode = computed(() => mode ?? 'edit')\n\n// Resolve the effective mode for a schema field, allowing per-field overrides\nfunction resolvedMode(componentObj: ResolvedField): InteractionMode {\n\tconst fieldMode = componentObj.mode\n\tif (fieldMode) return fieldMode\n\treturn effectiveFormMode.value\n}\n\n// A field declaring `parts` binds the value its component edits, read part by part from the fields\n// that hold them and written back only where a part changed.\nconst fieldParts = (field: ResolvedField): Record<string, string> | undefined =>\n\tfield.kind === 'field' ? field.parts : undefined\n\nconst fieldErrors = (field: ResolvedField): string[] | undefined => {\n\tconst parts = fieldParts(field)\n\tif (!parts) return errors?.[field.fieldname]\n\treturn Object.values(parts).flatMap(fieldname => errors?.[fieldname] ?? [])\n}\n\n// Create stable computed refs array to avoid recreation on every access\nconst childModelsCache = ref<ReturnType<typeof computed>[]>([])\n\n// Watch for schema changes and update cache (avoiding side effects in computed)\nwatchEffect(() => {\n\tif (!schema) return\n\n\t// Recreate cache only if length changed\n\tif (childModelsCache.value.length !== schema.length) {\n\t\tchildModelsCache.value = schema.map((_field, index) => {\n\t\t\treturn computed({\n\t\t\t\tget() {\n\t\t\t\t\tconst parts = fieldParts(schema[index])\n\t\t\t\t\tif (parts) return readParts(parts, dataModel.value ?? {})\n\t\t\t\t\treturn dataModel.value?.[schema[index].fieldname]\n\t\t\t\t},\n\t\t\t\tset: (newValue: any) => {\n\t\t\t\t\tconst parts = fieldParts(schema[index])\n\t\t\t\t\tconst fieldname = schema[index].fieldname\n\t\t\t\t\tif (parts && dataModel.value) {\n\t\t\t\t\t\tObject.assign(dataModel.value, partsPatch(parts, dataModel.value, newValue))\n\t\t\t\t\t\temit('update:data', { ...dataModel.value })\n\t\t\t\t\t} else if (fieldname && dataModel.value) {\n\t\t\t\t\t\tdataModel.value[fieldname] = newValue\n\t\t\t\t\t\temit('update:data', { ...dataModel.value })\n\t\t\t\t\t}\n\t\t\t\t\temit('update:schema', schema)\n\t\t\t\t},\n\t\t\t})\n\t\t})\n\t}\n})\n\n// Computed just returns the cached models (no side effects)\nconst childModels = computed(() => childModelsCache.value)\n</script>\n\n<style>\n/* global styles for aform */\n.aform input {\n\tfont-family: var(--sc-font-family);\n\tborder: none;\n}\n.aform_form-element {\n\tpadding: var(--sc-form-label-offset) 0 0;\n\tmargin: 0;\n\tposition: relative;\n\tbox-sizing: border-box;\n\tflex-grow: 1;\n\tmin-width: 20ch;\n\tmax-width: var(--sc-form-field-max-width);\n\t/* margin-bottom: 1rem; */\n}\n.aform__grid--full {\n\tflex-basis: 100%;\n\twidth: 100%;\n}\n.aform_input-field {\n\tborder: none;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tfont-size: 1rem;\n\tpadding: 0.5rem;\n\tmargin: 0 0 0 0;\n\tborder-radius: 0;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: auto;\n\tposition: relative;\n\tcolor: var(--sc-cell-text-color);\n\tbackground: var(--sc-input-field-background);\n\tfont-family: var(--sc-font-family);\n}\n.aform_input-field:focus {\n\toutline: 1px solid var(--sc-input-active-border-color);\n}\n\n.aform_display-value {\n\tdisplay: block;\n\tpadding: 0.5rem;\n\tmin-height: 2rem;\n\tcolor: var(--sc-cell-text-color);\n\tword-break: break-word;\n}\n\n/* A label darkens while anything beside it holds focus, wherever it sits in its field's markup. */\n:focus-within > .aform_field-label {\n\tcolor: var(--sc-input-active-label-color);\n}\n\n.aform_field-label {\n\tcolor: var(--sc-input-label-color);\n\tdisplay: inline-block;\n\tposition: absolute;\n\tuser-select: none;\n\tpadding: 0 0.25rem;\n\tmargin: 0rem;\n\tz-index: 1;\n\tfont-size: 0.7rem;\n\tfont-weight: 300;\n\tletter-spacing: 0.05rem;\n\t/* The form colour masks the field's top border behind the text; below it the field shows\n\t through. Never paint a colour there: it can match only one of the surfaces a field shows. */\n\tbackground: linear-gradient(var(--sc-form-background) calc(50% + 1px), transparent calc(50% + 1px));\n\twidth: auto;\n\tbox-sizing: border-box;\n\tmargin: 0;\n\tgrid-row: 1;\n\ttop: 0;\n\tleft: 10px;\n\tborder: none;\n\tline-height: 0;\n\ttransform: translateY(-50%);\n}\n.aform_form-element > .aform_field-label {\n\ttop: var(--sc-form-label-offset);\n}\n\n.aform_input-field:disabled,\n.aform_checkbox-container:has(.aform_checkbox:disabled) {\n\tbackground: var(--sc-input-field-disabled-background);\n}\n.aform_field-label::after {\n\tmargin: 0;\n\tpadding: 0;\n\tbox-sizing: border-box;\n\tcontent: '';\n\tline-height: normal;\n}\np.aform_error {\n\t/* v-show toggles visibility per field; base display must be visible (was stuck at `none`,\n\t which overrode v-show and left every field error dormant). */\n\tdisplay: inline-block;\n\t/* Straddles the border like .aform_field-label, and paints the same way. */\n\tbackground: linear-gradient(var(--sc-form-background) calc(50% + 1px), transparent calc(50% + 1px));\n\tpadding: 0 0.25rem;\n\tmargin: 0rem;\n\twidth: auto;\n\tcolor: var(--sc-brand-danger);\n\tfont-size: 0.7rem;\n\tposition: absolute;\n\tright: 0;\n\ttop: var(--sc-form-label-offset);\n\tline-height: 0;\n\tpadding: 0.25rem;\n\ttransform: translate(-1rem, -50%);\n\tmargin: 0;\n}\n</style>\n\n<style scoped>\n.aform {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 1rem;\n\tpadding: 1rem;\n\tbackground: var(--sc-form-background);\n\tborder: 1px solid var(--sc-form-border);\n\tborder-left: 4px solid var(--sc-form-border);\n\tmargin-bottom: 1rem;\n\tmax-width: 100%;\n}\n@media screen and (max-width: 400px) {\n\t.aform {\n\t\tflex-direction: column;\n\t}\n}\n\n/* Nested form section */\n.aform-nested-section {\n\twidth: 100%;\n\tpadding: 0.5rem 0;\n}\n\n.aform-nested-label {\n\tfont-size: 0.9rem;\n\tfont-weight: 600;\n\tmargin: 0 0 0.5rem 0;\n\tcolor: var(--sc-input-label-color);\n}\n\n.aform-nested-section .aform {\n\tborder-left-width: 2px;\n\tmargin-left: 0.5rem;\n}\n\n.aform-table-expansion {\n\tmargin-bottom: 0;\n\tborder: none;\n\tborder-left: none;\n\tpadding: 0;\n}\n</style>\n","<template>\n\t<button class=\"collapse-button\" :class=\"collapsed ? 'rotated' : 'unrotated'\">×</button>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{ collapsed: boolean }>()\n</script>\n\n<style scoped>\n.collapse-button {\n\twidth: 2ch;\n\tmin-width: calc(66px - 4ch);\n\tbackground-color: transparent;\n\tfont-size: 150%;\n\ttext-align: center;\n\tborder: none;\n\tmargin-top: -0.5rem;\n}\n.rotated {\n\ttransform: rotate(45deg);\n\t-webkit-transform: rotate(45deg);\n\t-moz-transform: rotate(45deg);\n\t-ms-transform: rotate(45deg);\n\t-o-transform: rotate(45deg);\n\ttransition: transform 250ms;\n\ttransform-origin: center center;\n}\n.unrotated {\n\ttransform: rotate(0deg);\n\t-webkit-transform: rotate(0deg);\n\t-moz-transform: rotate(0deg);\n\t-ms-transform: rotate(0deg);\n\t-o-transform: rotate(0deg);\n\ttransition: transform 250ms;\n}\n</style>\n","<template>\n\t<button class=\"collapse-button\" :class=\"collapsed ? 'rotated' : 'unrotated'\">×</button>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{ collapsed: boolean }>()\n</script>\n\n<style scoped>\n.collapse-button {\n\twidth: 2ch;\n\tmin-width: calc(66px - 4ch);\n\tbackground-color: transparent;\n\tfont-size: 150%;\n\ttext-align: center;\n\tborder: none;\n\tmargin-top: -0.5rem;\n}\n.rotated {\n\ttransform: rotate(45deg);\n\t-webkit-transform: rotate(45deg);\n\t-moz-transform: rotate(45deg);\n\t-ms-transform: rotate(45deg);\n\t-o-transform: rotate(45deg);\n\ttransition: transform 250ms;\n\ttransform-origin: center center;\n}\n.unrotated {\n\ttransform: rotate(0deg);\n\t-webkit-transform: rotate(0deg);\n\t-moz-transform: rotate(0deg);\n\t-ms-transform: rotate(0deg);\n\t-o-transform: rotate(0deg);\n\ttransition: transform 250ms;\n}\n</style>\n","<template>\n\t<fieldset>\n\t\t<legend v-if=\"label || collapsible\" @click=\"toggleCollapse\" @submit=\"toggleCollapse\">\n\t\t\t{{ label }}\n\t\t\t<CollapseButton v-if=\"collapsible\" :collapsed=\"collapsed\" />\n\t\t</legend>\n\t\t<slot :collapsed=\"collapsed\">\n\t\t\t<AForm v-show=\"!collapsed\" v-model:data=\"formData\" :schema=\"schema\" :mode=\"mode\" :errors=\"errors\" />\n\t\t</slot>\n\t</fieldset>\n</template>\n\n<script setup lang=\"ts\">\nimport type { InteractionMode } from '@stonecrop/schema'\nimport { ref } from 'vue'\n\nimport AForm from '../AForm.vue'\nimport CollapseButton from '../base/CollapseButton.vue'\nimport type { ResolvedField } from '../../types'\n\nconst {\n\tschema,\n\tlabel = undefined,\n\tcollapsible,\n\tmode = 'edit',\n\terrors = undefined,\n} = defineProps<{\n\tschema: ResolvedField[]\n\tlabel?: string\n\tcollapsible?: boolean\n\t/** Rendering mode forwarded to the inner AForm */\n\tmode?: InteractionMode\n\t/** Inline validation errors keyed by fieldname, forwarded to the inner AForm. */\n\terrors?: Record<string, string[]>\n}>()\n\n/** The record the fieldset's fields belong to: a fieldset is layout, so they are its own keys. */\nconst formData = defineModel<Record<string, any>>('data', { default: () => ({}) })\n\nconst collapsed = ref(false)\n\nconst toggleCollapse = (event: Event) => {\n\tevent.preventDefault()\n\tif (collapsible) {\n\t\tcollapsed.value = !collapsed.value\n\t}\n}\n\ndefineExpose({ collapsed })\n</script>\n\n<style scoped>\nfieldset {\n\t/* Its padding and border sit inside the width, and no browser margin sits outside it: a fieldset\n\t spans exactly the space it is given, so its border never crosses the form's. */\n\tbox-sizing: border-box;\n\tmax-width: 100%;\n\twidth: 100%;\n\tmargin: 0;\n\tborder: 1px solid transparent;\n\tborder-bottom: 1px solid var(--sc-gray-50);\n}\n\nlegend {\n\twidth: 100%;\n\theight: 1.15rem;\n\tborder: 1px solid transparent;\n\tpadding-bottom: 0.5rem;\n\tfont-size: 110%;\n\tfont-weight: 600;\n\tuser-select: none;\n}\n\n.collapse-button {\n\tfloat: right;\n}\n</style>\n","<template>\n\t<fieldset>\n\t\t<legend v-if=\"label || collapsible\" @click=\"toggleCollapse\" @submit=\"toggleCollapse\">\n\t\t\t{{ label }}\n\t\t\t<CollapseButton v-if=\"collapsible\" :collapsed=\"collapsed\" />\n\t\t</legend>\n\t\t<slot :collapsed=\"collapsed\">\n\t\t\t<AForm v-show=\"!collapsed\" v-model:data=\"formData\" :schema=\"schema\" :mode=\"mode\" :errors=\"errors\" />\n\t\t</slot>\n\t</fieldset>\n</template>\n\n<script setup lang=\"ts\">\nimport type { InteractionMode } from '@stonecrop/schema'\nimport { ref } from 'vue'\n\nimport AForm from '../AForm.vue'\nimport CollapseButton from '../base/CollapseButton.vue'\nimport type { ResolvedField } from '../../types'\n\nconst {\n\tschema,\n\tlabel = undefined,\n\tcollapsible,\n\tmode = 'edit',\n\terrors = undefined,\n} = defineProps<{\n\tschema: ResolvedField[]\n\tlabel?: string\n\tcollapsible?: boolean\n\t/** Rendering mode forwarded to the inner AForm */\n\tmode?: InteractionMode\n\t/** Inline validation errors keyed by fieldname, forwarded to the inner AForm. */\n\terrors?: Record<string, string[]>\n}>()\n\n/** The record the fieldset's fields belong to: a fieldset is layout, so they are its own keys. */\nconst formData = defineModel<Record<string, any>>('data', { default: () => ({}) })\n\nconst collapsed = ref(false)\n\nconst toggleCollapse = (event: Event) => {\n\tevent.preventDefault()\n\tif (collapsible) {\n\t\tcollapsed.value = !collapsed.value\n\t}\n}\n\ndefineExpose({ collapsed })\n</script>\n\n<style scoped>\nfieldset {\n\t/* Its padding and border sit inside the width, and no browser margin sits outside it: a fieldset\n\t spans exactly the space it is given, so its border never crosses the form's. */\n\tbox-sizing: border-box;\n\tmax-width: 100%;\n\twidth: 100%;\n\tmargin: 0;\n\tborder: 1px solid transparent;\n\tborder-bottom: 1px solid var(--sc-gray-50);\n}\n\nlegend {\n\twidth: 100%;\n\theight: 1.15rem;\n\tborder: 1px solid transparent;\n\tpadding-bottom: 0.5rem;\n\tfont-size: 110%;\n\tfont-weight: 600;\n\tuser-select: none;\n}\n\n.collapse-button {\n\tfloat: right;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element aform_file-attach aform__grid--full\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<template v-if=\"files\">\n\t\t\t\t<div class=\"aform_file-attach-feedback\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<b>{{ fileLengthText }}</b>\n\t\t\t\t\t</p>\n\t\t\t\t\t<li v-for=\"file of files\" :key=\"file.name\">{{ file.name }}</li>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t<span v-else class=\"aform_display-value\">No file selected</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<template v-if=\"files\">\n\t\t\t\t<div class=\"aform_file-attach-feedback\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\tYou have selected: <b>{{ fileLengthText }}</b>\n\t\t\t\t\t</p>\n\t\t\t\t\t<li v-for=\"file of files\" :key=\"file.name\">\n\t\t\t\t\t\t{{ file.name }}\n\t\t\t\t\t</li>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t<button type=\"button\" class=\"aform_form-btn\" :disabled=\"mode === 'read'\" @click=\"open()\">\n\t\t\t\t{{ label }}\n\t\t\t</button>\n\t\t\t<button type=\"button\" :disabled=\"!files || mode === 'read'\" class=\"aform_form-btn\" @click=\"reset()\">Reset</button>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { useFileDialog } from '@vueuse/core'\nimport { computed } from 'vue'\n\nimport type { ComponentProps } from '../../types'\n\nconst { label, mode } = defineProps<ComponentProps>()\nconst { files, open, reset, onChange } = useFileDialog()\n\nconst fileLengthText = computed(() => {\n\tconst count = files.value?.length ?? 0\n\treturn `${count} ${count === 1 ? 'file' : 'files'}`\n})\n\nonChange(changedFiles => changedFiles)\n</script>\n\n<style scoped>\n.aform_file-attach {\n\tpadding: 0.5rem;\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 0.5rem;\n\tflex-direction: row;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tborder: 1px dashed var(--sc-input-border-color);\n\twidth: 100%;\n}\n\n@media screen and (max-width: 400px) {\n\t.aform_file-attach > .aform_form-btn {\n\t\twidth: 100%;\n\t}\n}\n\n.aform_file-attach-feedback {\n\tcolor: var(--sc-input-label-color);\n\twidth: 100%;\n\tpadding: 0.5rem;\n\ttext-align: center;\n\talign-self: center;\n\n\t& > li {\n\t\tlist-style: none;\n\t\tfont-style: italic;\n\t}\n\t& > p {\n\t\tmargin-top: 0;\n\t}\n}\n\n.aform_form-btn {\n\tpadding: 0 1rem;\n\twidth: auto;\n\tfont-size: 1rem;\n\tline-height: 1;\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-input-label-color);\n\tcursor: pointer;\n\tbackground-color: var(--sc-btn-color);\n}\n\n.aform_form-btn:disabled {\n\tbackground-color: var(--sc-gray-5);\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element aform_file-attach aform__grid--full\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<template v-if=\"files\">\n\t\t\t\t<div class=\"aform_file-attach-feedback\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<b>{{ fileLengthText }}</b>\n\t\t\t\t\t</p>\n\t\t\t\t\t<li v-for=\"file of files\" :key=\"file.name\">{{ file.name }}</li>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t<span v-else class=\"aform_display-value\">No file selected</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<template v-if=\"files\">\n\t\t\t\t<div class=\"aform_file-attach-feedback\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\tYou have selected: <b>{{ fileLengthText }}</b>\n\t\t\t\t\t</p>\n\t\t\t\t\t<li v-for=\"file of files\" :key=\"file.name\">\n\t\t\t\t\t\t{{ file.name }}\n\t\t\t\t\t</li>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t<button type=\"button\" class=\"aform_form-btn\" :disabled=\"mode === 'read'\" @click=\"open()\">\n\t\t\t\t{{ label }}\n\t\t\t</button>\n\t\t\t<button type=\"button\" :disabled=\"!files || mode === 'read'\" class=\"aform_form-btn\" @click=\"reset()\">Reset</button>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { useFileDialog } from '@vueuse/core'\nimport { computed } from 'vue'\n\nimport type { ComponentProps } from '../../types'\n\nconst { label, mode } = defineProps<ComponentProps>()\nconst { files, open, reset, onChange } = useFileDialog()\n\nconst fileLengthText = computed(() => {\n\tconst count = files.value?.length ?? 0\n\treturn `${count} ${count === 1 ? 'file' : 'files'}`\n})\n\nonChange(changedFiles => changedFiles)\n</script>\n\n<style scoped>\n.aform_file-attach {\n\tpadding: 0.5rem;\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 0.5rem;\n\tflex-direction: row;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tborder: 1px dashed var(--sc-input-border-color);\n\twidth: 100%;\n}\n\n@media screen and (max-width: 400px) {\n\t.aform_file-attach > .aform_form-btn {\n\t\twidth: 100%;\n\t}\n}\n\n.aform_file-attach-feedback {\n\tcolor: var(--sc-input-label-color);\n\twidth: 100%;\n\tpadding: 0.5rem;\n\ttext-align: center;\n\talign-self: center;\n\n\t& > li {\n\t\tlist-style: none;\n\t\tfont-style: italic;\n\t}\n\t& > p {\n\t\tmargin-top: 0;\n\t}\n}\n\n.aform_form-btn {\n\tpadding: 0 1rem;\n\twidth: auto;\n\tfont-size: 1rem;\n\tline-height: 1;\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-input-label-color);\n\tcursor: pointer;\n\tbackground-color: var(--sc-btn-color);\n}\n\n.aform_form-btn:disabled {\n\tbackground-color: var(--sc-gray-5);\n}\n</style>\n","<template>\n\t<div :class=\"['aform_form-element', { 'aform_form-element--embedded': embedded }]\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayedText }}</span>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div v-on-click-outside=\"onClickOutside\" class=\"aform_form-link-wrapper\">\n\t\t\t\t<div class=\"input-group\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-model=\"searchText\"\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\taria-autocomplete=\"list\"\n\t\t\t\t\t\t:class=\"['aform_input-field', { 'aform_input-field--embedded': embedded }]\"\n\t\t\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t\t\t:aria-label=\"ariaLabel\"\n\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t:aria-expanded=\"dropdownOpen\"\n\t\t\t\t\t\t:aria-controls=\"dropdownOpen ? listboxId : undefined\"\n\t\t\t\t\t\t:aria-activedescendant=\"activeIndex === null ? undefined : `${listboxId}-opt-${activeIndex}`\"\n\t\t\t\t\t\t:disabled=\"disabled || mode === 'read'\"\n\t\t\t\t\t\t@input=\"onInput\"\n\t\t\t\t\t\t@focus=\"onFocus\"\n\t\t\t\t\t\t@keydown.down.prevent=\"selectNext\"\n\t\t\t\t\t\t@keydown.up.prevent=\"selectPrev\"\n\t\t\t\t\t\t@keydown.enter.prevent=\"selectCurrent\"\n\t\t\t\t\t\t@keydown.esc=\"closeDropdown\"\n\t\t\t\t\t\t@keydown.tab=\"closeDropdown\" />\n\t\t\t\t\t<button\n\t\t\t\t\t\tv-if=\"hasValidId && !disabled && !embedded\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclass=\"aform_form-btn\"\n\t\t\t\t\t\t@click=\"handleNavigate\"\n\t\t\t\t\t\t@keydown.enter.prevent=\"handleNavigate\">\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tclass=\"aform_form-btn-icon\"\n\t\t\t\t\t\t\t:data-icon=\"icon\"\n\t\t\t\t\t\t\tviewBox=\"1.75 2.75 12.5 10.5\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tfocusable=\"false\">\n\t\t\t\t\t\t\t<path v-if=\"icon === 'chevron-right'\" d=\"M6 3.5 10.5 8 6 12.5\" />\n\t\t\t\t\t\t\t<path v-else d=\"M2.5 8h11M9 3.5 13.5 8 9 12.5\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t<span class=\"aform_form-btn-name\">{{ icon === 'chevron-right' ? '›' : '→' }}</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<ADropdownList\n\t\t\t\t\tv-if=\"mode !== 'read'\"\n\t\t\t\t\t:listbox-id=\"listboxId\"\n\t\t\t\t\t:ariaLabel=\"ariaLabel ?? label ?? ''\"\n\t\t\t\t\t:open=\"dropdownOpen\"\n\t\t\t\t\t:option-count=\"() => dropdownResults.length\"\n\t\t\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t\t\t<li v-if=\"loading\" class=\"loading autocomplete-result\">Loading…</li>\n\t\t\t\t\t<li\n\t\t\t\t\t\tv-for=\"(option, i) in dropdownResults\"\n\t\t\t\t\t\tv-else\n\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t:aria-selected=\"isResultSelected(option)\"\n\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': isResultSelected(option) }\"\n\t\t\t\t\t\t@mousedown.prevent=\"selectOption(option)\"\n\t\t\t\t\t\t@mouseenter=\"activeIndex = i\">\n\t\t\t\t\t\t<slot name=\"option\" :option=\"option\">{{ option.displayText ?? String(option.id) }}</slot>\n\t\t\t\t\t</li>\n\t\t\t\t</ADropdownList>\n\t\t\t</div>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, inject, ref, useId, watch } from 'vue'\n\nimport type { AFormLinkModelValue, AFormLinkNavigator, AFormLinkValue, ComponentProps } from '../../types'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { asLinkValue, linkDisplayText, linkId } from '../../utils/linkValue'\nimport ADropdownList from './ADropdownList.vue'\n\nconst {\n\tlabel,\n\tmode,\n\tuuid,\n\trequired,\n\tdoctype = undefined,\n\tformatter = undefined,\n\ticon = 'arrow-right',\n\tdisabled = false,\n\tfilterFunction = undefined,\n\tisAsync = false,\n\tembedded = false,\n\tplaceholder = undefined,\n\tariaLabel = undefined,\n} = defineProps<\n\tComponentProps & {\n\t\tdoctype?: string\n\t\tformatter?: (value: AFormLinkValue) => string\n\t\ticon?: 'arrow-right' | 'chevron-right'\n\t\tdisabled?: boolean\n\t\tfilterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>)\n\t\tisAsync?: boolean\n\t\t// Bare rendering for compositing into another component's own bordered container:\n\t\t// suppresses this component's own outline/border and floating label so the parent\n\t\t// supplies both exactly once.\n\t\tembedded?: boolean\n\t\tplaceholder?: string\n\t\t// Accessible name for the search input. Needed in `embedded` mode, where the visible\n\t\t// <label> is suppressed and a placeholder is not a dependable accessible name — it is\n\t\t// not exposed consistently across screen readers and vanishes once a value is picked.\n\t\tariaLabel?: string\n\t}\n>()\n\n// Ties the input to its listbox and to the active option (aria-controls / aria-activedescendant).\n// `uuid` is per-field when AForm supplies it; the fallback keeps the ids unique for a standalone\n// mount so two pickers on one page can't cross-wire their ARIA relationships.\nconst listboxId = `${uuid ?? `aform-link-${useId()}`}-listbox`\n\nconst modelValue = defineModel<AFormLinkModelValue>({ default: () => ({ id: '', displayText: '' }) })\n\nconst hasValidId = computed(() => linkId(modelValue.value) !== undefined)\n\n// The record a link names, as last seen with its text: the value itself, a pick, or this field's own\n// lookup. Kept here and never written into the record: a lookup is not a pick, and Save's reply hands\n// the id back bare.\nconst knownLink = ref<AFormLinkValue>()\n\nwatch(\n\t() => modelValue.value,\n\tvalue => {\n\t\tif (linkDisplayText(value)) knownLink.value = asLinkValue(value)\n\t},\n\t{ immediate: true }\n)\n\nconst shownLink = computed<AFormLinkModelValue>(() => {\n\tconst value = modelValue.value\n\tif (linkDisplayText(value)) return value\n\tconst id = linkId(value)\n\tconst known = knownLink.value\n\treturn known && id !== undefined && String(known.id) === String(id) ? known : value\n})\n\nconst displayedText = computed(() => {\n\tconst id = linkId(shownLink.value)\n\tif (id === undefined) return '—'\n\tif (formatter) return formatter(asLinkValue(shownLink.value))\n\treturn linkDisplayText(shownLink.value) ?? id\n})\n\nconst searchText = ref(hasValidId.value ? displayedText.value : '')\n\nconst dropdownOpen = ref(false)\nconst loading = ref(false)\nconst dropdownResults = ref<AFormLinkValue[]>([])\nconst activeIndex = ref<number | null>(null)\n\nconst navigator = inject<AFormLinkNavigator | null>('aformLinkNavigator', null)\n\ntype FilterFn = (search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\n// A link's value arrives as a bare scalar as often as it does as an AFormLinkValue: a record\n// loaded from the DB carries the raw FK column, and a parent bound to that column coerces every\n// update it receives back to a scalar. So read the value through these three helpers rather than\n// reaching into `modelValue.value` directly.\n//\n// Rejected: normalizing on write — an immediate watch that replaced a scalar model with `{ id }`.\n// It survives only until the parent writes its scalar back, so it fixed a scalar passed once at\n// mount and nothing else, and it emitted an `update:modelValue` the user never made on every\n// mount of a scalar-valued link field.\n// When the id changes (including on first render), resolve its display text.\n// Tries filterFunction first (returns a list of candidates to search); falls back to the\n// injected resolver (a direct doctype+id lookup). Skips if displayText is already set.\nwatch(\n\t() => linkId(modelValue.value),\n\tasync id => {\n\t\t// Already carries its text: nothing to resolve, but the input still has to show it.\n\t\t// `searchText` is assigned at setup and then only by the branches below, by `selectOption`\n\t\t// and by `closeDropdown` — and at setup a record's value has not arrived yet. So a link the\n\t\t// server resolved for us (the middleware returns `{ id, displayText }` for an inline link)\n\t\t// rendered blank, while a bare id rendered fine because it took the resolve branch.\n\t\tif (id && linkDisplayText(shownLink.value)) {\n\t\t\t// Through `displayedText` rather than the raw text, for the reason the resolve branch\n\t\t\t// formats too: the same value must not render differently depending on how it arrived.\n\t\t\tsearchText.value = displayedText.value\n\t\t\treturn\n\t\t}\n\t\tif (!id) return\n\t\ttry {\n\t\t\tlet match: AFormLinkValue | undefined\n\t\t\tlet displayText: string | undefined\n\t\t\tif (filterFunction) {\n\t\t\t\tconst fn: FilterFn =\n\t\t\t\t\ttypeof filterFunction === 'string' ? deserializeFunction<FilterFn>(filterFunction) : filterFunction\n\t\t\t\tconst results = await fn(String(id))\n\t\t\t\tmatch = results.find(r => String(r.id) === String(id))\n\t\t\t\tdisplayText = match?.displayText\n\t\t\t\tif (displayText === undefined) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[AFormLink] filterFunction returned no matching result for id \"${id}\". ` +\n\t\t\t\t\t\t\t`The function must return an item whose \\`id\\` exactly matches the search string.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (resolver && doctype) {\n\t\t\t\tdisplayText = (await resolver(doctype, id.toString())) ?? undefined\n\t\t\t}\n\t\t\tif (displayText) {\n\t\t\t\t// Keep the whole matched record, not just its display text: a formatter may render the\n\t\t\t\t// extra properties an AFormLinkValue carries. `id` is pinned to the value we already\n\t\t\t\t// hold so a loosely-typed match (1 vs '1') can't stand for a different record.\n\t\t\t\tknownLink.value = { ...asLinkValue(modelValue.value), ...match, id, displayText }\n\t\t\t\t// Format for the same reason selectOption does: the input shows `formatter`'s output\n\t\t\t\t// everywhere else (initial render, blur), so assigning the raw displayText here would\n\t\t\t\t// make a value that arrived as a bare id render differently from the identical value\n\t\t\t\t// picked by hand — e.g. \"Euro\" instead of \"€\".\n\t\t\t\tsearchText.value = displayedText.value\n\t\t\t}\n\t\t} catch {\n\t\t\t// silent — fall back to showing the raw id\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst handleNavigate = () => {\n\tconst id = linkId(modelValue.value)\n\tif (navigator && doctype && id !== undefined) {\n\t\tnavigator.navigate(doctype, id)\n\t} else if (navigator && !doctype) {\n\t\tconsole.warn(\n\t\t\t`[AFormLink] Navigation requested but \\`doctype\\` prop is missing. ` +\n\t\t\t\t`Add \\`options\\` (or \\`doctype\\`) to the Link field definition to enable navigation.`\n\t\t)\n\t}\n}\n\nconst isResultSelected = (option: AFormLinkValue) => {\n\tconst id = linkId(modelValue.value)\n\treturn id !== undefined && String(option.id) === String(id)\n}\n\nconst openDropdown = async (text: string) => {\n\tif (!filterFunction || mode === 'read') return\n\tactiveIndex.value = null\n\tdropdownOpen.value = true\n\tif (isAsync) loading.value = true\n\ttry {\n\t\tconst fn: FilterFn =\n\t\t\ttypeof filterFunction === 'string' ? deserializeFunction<FilterFn>(filterFunction) : filterFunction\n\t\tdropdownResults.value = (await fn(text)) ?? []\n\t} catch {\n\t\tdropdownResults.value = []\n\t} finally {\n\t\tloading.value = false\n\t}\n}\n\nconst closeDropdown = () => {\n\tdropdownOpen.value = false\n\tactiveIndex.value = null\n\tsearchText.value = hasValidId.value ? displayedText.value : ''\n}\n\nconst onClickOutside = () => {\n\tif (dropdownOpen.value) closeDropdown()\n}\n\nconst onFocus = () => openDropdown(searchText.value)\n\nconst onInput = () => openDropdown(searchText.value)\n\nconst selectOption = (option: AFormLinkValue) => {\n\tmodelValue.value = option\n\t// Format `option` directly rather than reading back displayedText/modelValue: under a real\n\t// two-way v-model (e.g. ACurrencyInput binding to a computed with a side-effecting setter),\n\t// modelValue.value still reflects the *prop* until the parent's update round-trips back,\n\t// so reading it synchronously here would show stale (pre-selection) text for a tick.\n\tsearchText.value = formatter ? formatter(option) : (option.displayText ?? String(option.id))\n\tdropdownOpen.value = false\n\tactiveIndex.value = null\n}\n\nconst selectNext = () => {\n\tconst len = dropdownResults.value.length\n\tif (!len) return\n\tactiveIndex.value = activeIndex.value === null ? 0 : (activeIndex.value + 1) % len\n}\n\nconst selectPrev = () => {\n\tconst len = dropdownResults.value.length\n\tif (!len) return\n\tif (activeIndex.value === null || activeIndex.value === 0) {\n\t\tactiveIndex.value = null\n\t} else {\n\t\tactiveIndex.value -= 1\n\t}\n}\n\nconst selectCurrent = () => {\n\tif (activeIndex.value !== null && dropdownResults.value[activeIndex.value]) {\n\t\tselectOption(dropdownResults.value[activeIndex.value])\n\t}\n}\n</script>\n\n<style scoped>\n.aform_form-link-wrapper {\n\tposition: relative;\n}\n\n.input-group {\n\tdisplay: flex;\n\talign-items: stretch;\n}\n\n.aform_input-field {\n\tflex: 1;\n\tmin-width: 0;\n}\n\n/* No top padding: the shared rule reserves it for a floating label, which embedded mode never renders. */\n.aform_form-element--embedded {\n\tmin-width: 0;\n\tflex: 1 1 auto;\n\twidth: 100%;\n\tpadding-top: 0;\n}\n\n/* Embedded mode: the host component's own container supplies the border, so this input goes\n borderless. Its vertical padding stays the standalone field's, so its text lines up with the host's. */\n.aform_input-field--embedded {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0.5rem 1ch;\n}\n\n/* Only in embedded mode is the trigger deliberately narrower than its options (e.g. a currency\n symbol box): let the dropdown grow past it rather than truncate. Standalone pickers keep the\n dropdown flush with the input, so a long display text can't overhang a narrow form column. */\n.aform_form-element--embedded .autocomplete-results {\n\tmin-width: 100%;\n}\n\n/* Give the button the same outline as the input, then slide it 2px left so the outlines\n overlap exactly at the join: input right outline sits at (input_right - 1px),\n button left outline also sits at (button_left + 1px) = (input_right - 2px + 1px) = same pixel. */\n.aform_form-btn {\n\tappearance: none;\n\tborder: none;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tmargin-left: -2px;\n\tbackground: var(--sc-input-field-background);\n\tpadding: 0.5rem 0.75rem;\n\tcursor: pointer;\n\tdisplay: block;\n\tfont-size: 1rem;\n\tline-height: normal;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n}\n\n/* Drawn rather than a text glyph, but set on the text's baseline at capital height: text sits\n above its box's centre, so an icon centred in the box reads low beside the input's text. */\n.aform_form-btn-icon {\n\theight: 0.716em;\n\twidth: auto;\n\tvertical-align: baseline;\n\toverflow: visible;\n\tfill: none;\n\tstroke: currentColor;\n\tstroke-width: 1.5;\n\tstroke-linecap: round;\n\tstroke-linejoin: round;\n}\n\n/* The glyph stays as the button's spoken name, hidden from sight. */\n.aform_form-btn-name {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n}\n\n.aform_form-btn:focus,\n.input-group:focus-within .aform_form-btn {\n\toutline-color: var(--sc-input-active-border-color);\n}\n</style>\n","<template>\n\t<div :class=\"['aform_form-element', { 'aform_form-element--embedded': embedded }]\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayedText }}</span>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div v-on-click-outside=\"onClickOutside\" class=\"aform_form-link-wrapper\">\n\t\t\t\t<div class=\"input-group\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-model=\"searchText\"\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\taria-autocomplete=\"list\"\n\t\t\t\t\t\t:class=\"['aform_input-field', { 'aform_input-field--embedded': embedded }]\"\n\t\t\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t\t\t:aria-label=\"ariaLabel\"\n\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t:aria-expanded=\"dropdownOpen\"\n\t\t\t\t\t\t:aria-controls=\"dropdownOpen ? listboxId : undefined\"\n\t\t\t\t\t\t:aria-activedescendant=\"activeIndex === null ? undefined : `${listboxId}-opt-${activeIndex}`\"\n\t\t\t\t\t\t:disabled=\"disabled || mode === 'read'\"\n\t\t\t\t\t\t@input=\"onInput\"\n\t\t\t\t\t\t@focus=\"onFocus\"\n\t\t\t\t\t\t@keydown.down.prevent=\"selectNext\"\n\t\t\t\t\t\t@keydown.up.prevent=\"selectPrev\"\n\t\t\t\t\t\t@keydown.enter.prevent=\"selectCurrent\"\n\t\t\t\t\t\t@keydown.esc=\"closeDropdown\"\n\t\t\t\t\t\t@keydown.tab=\"closeDropdown\" />\n\t\t\t\t\t<button\n\t\t\t\t\t\tv-if=\"hasValidId && !disabled && !embedded\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclass=\"aform_form-btn\"\n\t\t\t\t\t\t@click=\"handleNavigate\"\n\t\t\t\t\t\t@keydown.enter.prevent=\"handleNavigate\">\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tclass=\"aform_form-btn-icon\"\n\t\t\t\t\t\t\t:data-icon=\"icon\"\n\t\t\t\t\t\t\tviewBox=\"1.75 2.75 12.5 10.5\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tfocusable=\"false\">\n\t\t\t\t\t\t\t<path v-if=\"icon === 'chevron-right'\" d=\"M6 3.5 10.5 8 6 12.5\" />\n\t\t\t\t\t\t\t<path v-else d=\"M2.5 8h11M9 3.5 13.5 8 9 12.5\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t<span class=\"aform_form-btn-name\">{{ icon === 'chevron-right' ? '›' : '→' }}</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<ADropdownList\n\t\t\t\t\tv-if=\"mode !== 'read'\"\n\t\t\t\t\t:listbox-id=\"listboxId\"\n\t\t\t\t\t:ariaLabel=\"ariaLabel ?? label ?? ''\"\n\t\t\t\t\t:open=\"dropdownOpen\"\n\t\t\t\t\t:option-count=\"() => dropdownResults.length\"\n\t\t\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t\t\t<li v-if=\"loading\" class=\"loading autocomplete-result\">Loading…</li>\n\t\t\t\t\t<li\n\t\t\t\t\t\tv-for=\"(option, i) in dropdownResults\"\n\t\t\t\t\t\tv-else\n\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t:aria-selected=\"isResultSelected(option)\"\n\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': isResultSelected(option) }\"\n\t\t\t\t\t\t@mousedown.prevent=\"selectOption(option)\"\n\t\t\t\t\t\t@mouseenter=\"activeIndex = i\">\n\t\t\t\t\t\t<slot name=\"option\" :option=\"option\">{{ option.displayText ?? String(option.id) }}</slot>\n\t\t\t\t\t</li>\n\t\t\t\t</ADropdownList>\n\t\t\t</div>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, inject, ref, useId, watch } from 'vue'\n\nimport type { AFormLinkModelValue, AFormLinkNavigator, AFormLinkValue, ComponentProps } from '../../types'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { asLinkValue, linkDisplayText, linkId } from '../../utils/linkValue'\nimport ADropdownList from './ADropdownList.vue'\n\nconst {\n\tlabel,\n\tmode,\n\tuuid,\n\trequired,\n\tdoctype = undefined,\n\tformatter = undefined,\n\ticon = 'arrow-right',\n\tdisabled = false,\n\tfilterFunction = undefined,\n\tisAsync = false,\n\tembedded = false,\n\tplaceholder = undefined,\n\tariaLabel = undefined,\n} = defineProps<\n\tComponentProps & {\n\t\tdoctype?: string\n\t\tformatter?: (value: AFormLinkValue) => string\n\t\ticon?: 'arrow-right' | 'chevron-right'\n\t\tdisabled?: boolean\n\t\tfilterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>)\n\t\tisAsync?: boolean\n\t\t// Bare rendering for compositing into another component's own bordered container:\n\t\t// suppresses this component's own outline/border and floating label so the parent\n\t\t// supplies both exactly once.\n\t\tembedded?: boolean\n\t\tplaceholder?: string\n\t\t// Accessible name for the search input. Needed in `embedded` mode, where the visible\n\t\t// <label> is suppressed and a placeholder is not a dependable accessible name — it is\n\t\t// not exposed consistently across screen readers and vanishes once a value is picked.\n\t\tariaLabel?: string\n\t}\n>()\n\n// Ties the input to its listbox and to the active option (aria-controls / aria-activedescendant).\n// `uuid` is per-field when AForm supplies it; the fallback keeps the ids unique for a standalone\n// mount so two pickers on one page can't cross-wire their ARIA relationships.\nconst listboxId = `${uuid ?? `aform-link-${useId()}`}-listbox`\n\nconst modelValue = defineModel<AFormLinkModelValue>({ default: () => ({ id: '', displayText: '' }) })\n\nconst hasValidId = computed(() => linkId(modelValue.value) !== undefined)\n\n// The record a link names, as last seen with its text: the value itself, a pick, or this field's own\n// lookup. Kept here and never written into the record: a lookup is not a pick, and Save's reply hands\n// the id back bare.\nconst knownLink = ref<AFormLinkValue>()\n\nwatch(\n\t() => modelValue.value,\n\tvalue => {\n\t\tif (linkDisplayText(value)) knownLink.value = asLinkValue(value)\n\t},\n\t{ immediate: true }\n)\n\nconst shownLink = computed<AFormLinkModelValue>(() => {\n\tconst value = modelValue.value\n\tif (linkDisplayText(value)) return value\n\tconst id = linkId(value)\n\tconst known = knownLink.value\n\treturn known && id !== undefined && String(known.id) === String(id) ? known : value\n})\n\nconst displayedText = computed(() => {\n\tconst id = linkId(shownLink.value)\n\tif (id === undefined) return '—'\n\tif (formatter) return formatter(asLinkValue(shownLink.value))\n\treturn linkDisplayText(shownLink.value) ?? id\n})\n\nconst searchText = ref(hasValidId.value ? displayedText.value : '')\n\nconst dropdownOpen = ref(false)\nconst loading = ref(false)\nconst dropdownResults = ref<AFormLinkValue[]>([])\nconst activeIndex = ref<number | null>(null)\n\nconst navigator = inject<AFormLinkNavigator | null>('aformLinkNavigator', null)\n\ntype FilterFn = (search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\n// A link's value arrives as a bare scalar as often as it does as an AFormLinkValue: a record\n// loaded from the DB carries the raw FK column, and a parent bound to that column coerces every\n// update it receives back to a scalar. So read the value through these three helpers rather than\n// reaching into `modelValue.value` directly.\n//\n// Rejected: normalizing on write — an immediate watch that replaced a scalar model with `{ id }`.\n// It survives only until the parent writes its scalar back, so it fixed a scalar passed once at\n// mount and nothing else, and it emitted an `update:modelValue` the user never made on every\n// mount of a scalar-valued link field.\n// When the id changes (including on first render), resolve its display text.\n// Tries filterFunction first (returns a list of candidates to search); falls back to the\n// injected resolver (a direct doctype+id lookup). Skips if displayText is already set.\nwatch(\n\t() => linkId(modelValue.value),\n\tasync id => {\n\t\t// Already carries its text: nothing to resolve, but the input still has to show it.\n\t\t// `searchText` is assigned at setup and then only by the branches below, by `selectOption`\n\t\t// and by `closeDropdown` — and at setup a record's value has not arrived yet. So a link the\n\t\t// server resolved for us (the middleware returns `{ id, displayText }` for an inline link)\n\t\t// rendered blank, while a bare id rendered fine because it took the resolve branch.\n\t\tif (id && linkDisplayText(shownLink.value)) {\n\t\t\t// Through `displayedText` rather than the raw text, for the reason the resolve branch\n\t\t\t// formats too: the same value must not render differently depending on how it arrived.\n\t\t\tsearchText.value = displayedText.value\n\t\t\treturn\n\t\t}\n\t\tif (!id) return\n\t\ttry {\n\t\t\tlet match: AFormLinkValue | undefined\n\t\t\tlet displayText: string | undefined\n\t\t\tif (filterFunction) {\n\t\t\t\tconst fn: FilterFn =\n\t\t\t\t\ttypeof filterFunction === 'string' ? deserializeFunction<FilterFn>(filterFunction) : filterFunction\n\t\t\t\tconst results = await fn(String(id))\n\t\t\t\tmatch = results.find(r => String(r.id) === String(id))\n\t\t\t\tdisplayText = match?.displayText\n\t\t\t\tif (displayText === undefined) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[AFormLink] filterFunction returned no matching result for id \"${id}\". ` +\n\t\t\t\t\t\t\t`The function must return an item whose \\`id\\` exactly matches the search string.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (resolver && doctype) {\n\t\t\t\tdisplayText = (await resolver(doctype, id.toString())) ?? undefined\n\t\t\t}\n\t\t\tif (displayText) {\n\t\t\t\t// Keep the whole matched record, not just its display text: a formatter may render the\n\t\t\t\t// extra properties an AFormLinkValue carries. `id` is pinned to the value we already\n\t\t\t\t// hold so a loosely-typed match (1 vs '1') can't stand for a different record.\n\t\t\t\tknownLink.value = { ...asLinkValue(modelValue.value), ...match, id, displayText }\n\t\t\t\t// Format for the same reason selectOption does: the input shows `formatter`'s output\n\t\t\t\t// everywhere else (initial render, blur), so assigning the raw displayText here would\n\t\t\t\t// make a value that arrived as a bare id render differently from the identical value\n\t\t\t\t// picked by hand — e.g. \"Euro\" instead of \"€\".\n\t\t\t\tsearchText.value = displayedText.value\n\t\t\t}\n\t\t} catch {\n\t\t\t// silent — fall back to showing the raw id\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst handleNavigate = () => {\n\tconst id = linkId(modelValue.value)\n\tif (navigator && doctype && id !== undefined) {\n\t\tnavigator.navigate(doctype, id)\n\t} else if (navigator && !doctype) {\n\t\tconsole.warn(\n\t\t\t`[AFormLink] Navigation requested but \\`doctype\\` prop is missing. ` +\n\t\t\t\t`Add \\`options\\` (or \\`doctype\\`) to the Link field definition to enable navigation.`\n\t\t)\n\t}\n}\n\nconst isResultSelected = (option: AFormLinkValue) => {\n\tconst id = linkId(modelValue.value)\n\treturn id !== undefined && String(option.id) === String(id)\n}\n\nconst openDropdown = async (text: string) => {\n\tif (!filterFunction || mode === 'read') return\n\tactiveIndex.value = null\n\tdropdownOpen.value = true\n\tif (isAsync) loading.value = true\n\ttry {\n\t\tconst fn: FilterFn =\n\t\t\ttypeof filterFunction === 'string' ? deserializeFunction<FilterFn>(filterFunction) : filterFunction\n\t\tdropdownResults.value = (await fn(text)) ?? []\n\t} catch {\n\t\tdropdownResults.value = []\n\t} finally {\n\t\tloading.value = false\n\t}\n}\n\nconst closeDropdown = () => {\n\tdropdownOpen.value = false\n\tactiveIndex.value = null\n\tsearchText.value = hasValidId.value ? displayedText.value : ''\n}\n\nconst onClickOutside = () => {\n\tif (dropdownOpen.value) closeDropdown()\n}\n\nconst onFocus = () => openDropdown(searchText.value)\n\nconst onInput = () => openDropdown(searchText.value)\n\nconst selectOption = (option: AFormLinkValue) => {\n\tmodelValue.value = option\n\t// Format `option` directly rather than reading back displayedText/modelValue: under a real\n\t// two-way v-model (e.g. ACurrencyInput binding to a computed with a side-effecting setter),\n\t// modelValue.value still reflects the *prop* until the parent's update round-trips back,\n\t// so reading it synchronously here would show stale (pre-selection) text for a tick.\n\tsearchText.value = formatter ? formatter(option) : (option.displayText ?? String(option.id))\n\tdropdownOpen.value = false\n\tactiveIndex.value = null\n}\n\nconst selectNext = () => {\n\tconst len = dropdownResults.value.length\n\tif (!len) return\n\tactiveIndex.value = activeIndex.value === null ? 0 : (activeIndex.value + 1) % len\n}\n\nconst selectPrev = () => {\n\tconst len = dropdownResults.value.length\n\tif (!len) return\n\tif (activeIndex.value === null || activeIndex.value === 0) {\n\t\tactiveIndex.value = null\n\t} else {\n\t\tactiveIndex.value -= 1\n\t}\n}\n\nconst selectCurrent = () => {\n\tif (activeIndex.value !== null && dropdownResults.value[activeIndex.value]) {\n\t\tselectOption(dropdownResults.value[activeIndex.value])\n\t}\n}\n</script>\n\n<style scoped>\n.aform_form-link-wrapper {\n\tposition: relative;\n}\n\n.input-group {\n\tdisplay: flex;\n\talign-items: stretch;\n}\n\n.aform_input-field {\n\tflex: 1;\n\tmin-width: 0;\n}\n\n/* No top padding: the shared rule reserves it for a floating label, which embedded mode never renders. */\n.aform_form-element--embedded {\n\tmin-width: 0;\n\tflex: 1 1 auto;\n\twidth: 100%;\n\tpadding-top: 0;\n}\n\n/* Embedded mode: the host component's own container supplies the border, so this input goes\n borderless. Its vertical padding stays the standalone field's, so its text lines up with the host's. */\n.aform_input-field--embedded {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0.5rem 1ch;\n}\n\n/* Only in embedded mode is the trigger deliberately narrower than its options (e.g. a currency\n symbol box): let the dropdown grow past it rather than truncate. Standalone pickers keep the\n dropdown flush with the input, so a long display text can't overhang a narrow form column. */\n.aform_form-element--embedded .autocomplete-results {\n\tmin-width: 100%;\n}\n\n/* Give the button the same outline as the input, then slide it 2px left so the outlines\n overlap exactly at the join: input right outline sits at (input_right - 1px),\n button left outline also sits at (button_left + 1px) = (input_right - 2px + 1px) = same pixel. */\n.aform_form-btn {\n\tappearance: none;\n\tborder: none;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tmargin-left: -2px;\n\tbackground: var(--sc-input-field-background);\n\tpadding: 0.5rem 0.75rem;\n\tcursor: pointer;\n\tdisplay: block;\n\tfont-size: 1rem;\n\tline-height: normal;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n}\n\n/* Drawn rather than a text glyph, but set on the text's baseline at capital height: text sits\n above its box's centre, so an icon centred in the box reads low beside the input's text. */\n.aform_form-btn-icon {\n\theight: 0.716em;\n\twidth: auto;\n\tvertical-align: baseline;\n\toverflow: visible;\n\tfill: none;\n\tstroke: currentColor;\n\tstroke-width: 1.5;\n\tstroke-linecap: round;\n\tstroke-linejoin: round;\n}\n\n/* The glyph stays as the button's spoken name, hidden from sight. */\n.aform_form-btn-name {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n}\n\n.aform_form-btn:focus,\n.input-group:focus-within .aform_form-btn {\n\toutline-color: var(--sc-input-active-border-color);\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ inputNumber ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"boxNumber\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"number\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\nimport { numberFromBox } from '../../utils/emptiedBox'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst inputNumber = defineModel<number | null>()\n\nconst boxNumber = computed({\n\tget: () => inputNumber.value,\n\tset: (value: number | '') => (inputNumber.value = numberFromBox(value)),\n})\n</script>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ inputNumber ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"boxNumber\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"number\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\nimport { numberFromBox } from '../../utils/emptiedBox'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst inputNumber = defineModel<number | null>()\n\nconst boxNumber = computed({\n\tget: () => inputNumber.value,\n\tset: (value: number | '') => (inputNumber.value = numberFromBox(value)),\n})\n</script>\n","import type { QuantityOptions, QuantityValue } from '../types'\n\n/** What a quantity box may hold, typed or pasted: digits, one decimal point and a leading minus sign. */\nexport const quantityEntryPattern = /^-?\\d*\\.?\\d*$/\n\nconst roundQty = (value: number): number => Number(value.toFixed(6))\n\nexport function resolveQuantityConversionFactor(\n\tuom: string,\n\toptions: QuantityOptions,\n\tcurrent: QuantityValue | null | undefined\n): number {\n\tconst stockUom = options.stockUom ?? current?.stockUom\n\tif (!uom || uom === stockUom) return 1\n\tconst mapped = options.conversionFactors?.[uom]\n\tif (mapped !== undefined) return mapped\n\tif (uom === current?.uom) return current.conversionFactor ?? 1\n\treturn 1\n}\n\nexport function recomputeQuantityValue(\n\tqty: number | null,\n\tuom: string,\n\toptions: QuantityOptions,\n\tcurrent: QuantityValue | null | undefined\n): QuantityValue {\n\tconst conversionFactor = resolveQuantityConversionFactor(uom, options, current)\n\treturn {\n\t\tqty,\n\t\tuom,\n\t\tconversionFactor,\n\t\tstockUom: options.stockUom ?? current?.stockUom ?? '',\n\t\tstockQty: qty === null ? null : roundQty(qty * conversionFactor),\n\t}\n}\n\nexport function patchQuantityQty(\n\tcurrent: QuantityValue | null | undefined,\n\tqty: number | null,\n\toptions: QuantityOptions\n): QuantityValue {\n\t// `current.uom` exactly as given, never `?? ''`: under `parts` the unit is a field of its own,\n\t// and typing a quantity must not turn an empty unit into `''`.\n\treturn recomputeQuantityValue(qty, current ? current.uom : '', options, current)\n}\n\nexport function patchQuantityUom(\n\tcurrent: QuantityValue | null | undefined,\n\tuom: string,\n\toptions: QuantityOptions\n): QuantityValue {\n\treturn recomputeQuantityValue(current?.qty ?? null, uom, options, current)\n}\n","<template>\n\t<div class=\"aform_form-element aquantity\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayText }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div class=\"aquantity__row\">\n\t\t\t\t<div class=\"aquantity__field aquantity__field--qty\">\n\t\t\t\t\t<div class=\"aquantity__group\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\tv-model.number=\"qty\"\n\t\t\t\t\t\t\tclass=\"aquantity__qty\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t@keydown=\"onQtyKeydown\"\n\t\t\t\t\t\t\t@paste=\"onQtyPaste\" />\n\t\t\t\t\t\t<div class=\"aquantity__uom\">\n\t\t\t\t\t\t\t<ADropdown\n\t\t\t\t\t\t\t\tv-model=\"uom\"\n\t\t\t\t\t\t\t\tembedded\n\t\t\t\t\t\t\t\ttrigger=\"button\"\n\t\t\t\t\t\t\t\tlist-anchor=\"group\"\n\t\t\t\t\t\t\t\t:options=\"uoms\"\n\t\t\t\t\t\t\t\t:mode=\"mode\"\n\t\t\t\t\t\t\t\t:uuid=\"uuid ? `${uuid}-uom` : undefined\"\n\t\t\t\t\t\t\t\t:aria-label=\"uomLabel\"\n\t\t\t\t\t\t\t\t:placeholder=\"uomLabel\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<p v-if=\"showStock && !errorText\" :id=\"helperId\" class=\"aquantity__helper\">{{ conversionHelperText }}</p>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps, QuantityOptions, QuantityValue } from '../../types'\nimport { numberFromBox } from '../../utils/emptiedBox'\nimport { numberFromRecord } from '../../utils/recordNumber'\nimport {\n\tpatchQuantityQty,\n\tpatchQuantityUom,\n\tquantityEntryPattern,\n\trecomputeQuantityValue,\n} from '../../utils/quantityValue'\nimport ADropdown from './ADropdown.vue'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\toptions = {},\n\tuomLabel = 'UOM',\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: QuantityOptions\n\t\tuomLabel?: string\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst helperId = computed(() => (uuid ? `${uuid}-helper` : undefined))\nconst helperDescribedBy = computed(() => (showStock.value && !errorText.value ? helperId.value : undefined))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText, helperDescribedBy)\n\n// No default: a field with no value shows empty, as null does, rather than a factor nobody entered.\nconst modelValue = defineModel<QuantityValue | null>()\n\nconst uoms = computed(() => options.uoms ?? [])\n\nconst qty = computed({\n\tget: () => modelValue.value?.qty ?? null,\n\tset: (value: number | '') => (modelValue.value = patchQuantityQty(modelValue.value, numberFromBox(value), options)),\n})\n\nconst uom = computed({\n\tget: () => modelValue.value?.uom ?? '',\n\tset: (value: string) => (modelValue.value = patchQuantityUom(modelValue.value, value, options)),\n})\n\nconst qtyNavigationKeys = new Set([\n\t'Backspace',\n\t'Delete',\n\t'Tab',\n\t'Escape',\n\t'Enter',\n\t'ArrowLeft',\n\t'ArrowRight',\n\t'ArrowUp',\n\t'ArrowDown',\n\t'Home',\n\t'End',\n])\n\nconst onQtyKeydown = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (qtyNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\t// Quantity is signed — returns, adjustments, and credit lines can be negative.\n\tconst input = event.target as HTMLInputElement\n\tif (event.key === '.' && !input.value.includes('.')) return\n\tif (event.key === '-' && !input.value.includes('-')) return\n\tevent.preventDefault()\n}\n\nconst onQtyPaste = (event: ClipboardEvent) => {\n\tconst pasted = event.clipboardData?.getData('text') ?? ''\n\tif (!quantityEntryPattern.test(pasted)) event.preventDefault()\n}\n\n// The stock figures are worked out from qty, uom and the options rather than read from the value:\n// under `parts` no field holds them, and the quantity field holds what the server sent (decimal text).\nconst shown = computed(() => {\n\tconst boxValue = modelValue.value\n\treturn boxValue ? recomputeQuantityValue(numberFromRecord(boxValue.qty), boxValue.uom, options, boxValue) : null\n})\n\nconst showStock = computed(() => {\n\tconst shownValue = shown.value\n\treturn !!shownValue?.stockUom && (shownValue.uom !== shownValue.stockUom || shownValue.qty !== shownValue.stockQty)\n})\n\nconst conversionHelperText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || shownValue.stockQty === null || shownValue.qty === null) return ''\n\tconst factor = shownValue.conversionFactor\n\treturn `= ${shownValue.stockQty} ${shownValue.stockUom} · 1 ${shownValue.uom} = ${factor} ${shownValue.stockUom}`\n})\n\nconst displayText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || !shownValue.uom || shownValue.qty === null) return '—'\n\tconst base = `${shownValue.qty} ${shownValue.uom}`\n\treturn showStock.value ? `${base} (${shownValue.stockQty} ${shownValue.stockUom})` : base\n})\n</script>\n\n<style scoped>\n.aquantity__row {\n\tdisplay: flex;\n\tgap: 1ch;\n}\n\n.aquantity__field {\n\tposition: relative;\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.aquantity__group {\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius);\n}\n\n.aquantity__group:focus-within {\n\tborder-color: var(--sc-input-active-border-color);\n}\n\n.aquantity__group > .aform_field-label {\n\tbackground: var(--sc-form-background);\n}\n\n/* Focus ring lives on the merged group only (see AForm :focus-within label + group border). */\n.aquantity__group :deep(.aform_dropdown-button:focus),\n.aquantity__group :deep(.aform_dropdown-button:focus-visible) {\n\toutline: none;\n\tbox-shadow: none;\n}\n\n.aquantity__qty {\n\tflex: 1 1 50%;\n\tmin-width: 0;\n\tborder: none;\n\toutline: none;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\ttext-align: right;\n\tbackground: transparent;\n\tborder-radius: var(--sc-border-radius) 0 0 var(--sc-border-radius);\n\tappearance: textfield;\n\t-moz-appearance: textfield;\n}\n\n.aquantity__qty::-webkit-outer-spin-button,\n.aquantity__qty::-webkit-inner-spin-button {\n\tappearance: none;\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.aquantity__uom {\n\tposition: static;\n\tflex: 1 1 50%;\n\tmin-width: 0;\n\tdisplay: flex;\n\talign-items: stretch;\n\tborder-left: 1px solid var(--sc-input-border-color);\n}\n\n/* ADropdown list: anchor to merged group, not the UOM trigger column (see dropdowns.browser.spec). */\n.aquantity__group :deep(.aform_form-element--embedded),\n.aquantity__group :deep(.autocomplete) {\n\tposition: static;\n\talign-self: stretch;\n}\n\n.aquantity__group :deep(.autocomplete-results--anchor-group) {\n\tleft: -1px;\n\tright: -1px;\n\tbox-sizing: border-box;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.aquantity__helper {\n\tmargin: 0.5rem 0 0;\n\tfont-size: 0.85rem;\n\tcolor: var(--sc-cell-text-color);\n\topacity: 0.75;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element aquantity\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayText }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div class=\"aquantity__row\">\n\t\t\t\t<div class=\"aquantity__field aquantity__field--qty\">\n\t\t\t\t\t<div class=\"aquantity__group\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\tv-model.number=\"qty\"\n\t\t\t\t\t\t\tclass=\"aquantity__qty\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t@keydown=\"onQtyKeydown\"\n\t\t\t\t\t\t\t@paste=\"onQtyPaste\" />\n\t\t\t\t\t\t<div class=\"aquantity__uom\">\n\t\t\t\t\t\t\t<ADropdown\n\t\t\t\t\t\t\t\tv-model=\"uom\"\n\t\t\t\t\t\t\t\tembedded\n\t\t\t\t\t\t\t\ttrigger=\"button\"\n\t\t\t\t\t\t\t\tlist-anchor=\"group\"\n\t\t\t\t\t\t\t\t:options=\"uoms\"\n\t\t\t\t\t\t\t\t:mode=\"mode\"\n\t\t\t\t\t\t\t\t:uuid=\"uuid ? `${uuid}-uom` : undefined\"\n\t\t\t\t\t\t\t\t:aria-label=\"uomLabel\"\n\t\t\t\t\t\t\t\t:placeholder=\"uomLabel\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<p v-if=\"showStock && !errorText\" :id=\"helperId\" class=\"aquantity__helper\">{{ conversionHelperText }}</p>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps, QuantityOptions, QuantityValue } from '../../types'\nimport { numberFromBox } from '../../utils/emptiedBox'\nimport { numberFromRecord } from '../../utils/recordNumber'\nimport {\n\tpatchQuantityQty,\n\tpatchQuantityUom,\n\tquantityEntryPattern,\n\trecomputeQuantityValue,\n} from '../../utils/quantityValue'\nimport ADropdown from './ADropdown.vue'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\toptions = {},\n\tuomLabel = 'UOM',\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: QuantityOptions\n\t\tuomLabel?: string\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst helperId = computed(() => (uuid ? `${uuid}-helper` : undefined))\nconst helperDescribedBy = computed(() => (showStock.value && !errorText.value ? helperId.value : undefined))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText, helperDescribedBy)\n\n// No default: a field with no value shows empty, as null does, rather than a factor nobody entered.\nconst modelValue = defineModel<QuantityValue | null>()\n\nconst uoms = computed(() => options.uoms ?? [])\n\nconst qty = computed({\n\tget: () => modelValue.value?.qty ?? null,\n\tset: (value: number | '') => (modelValue.value = patchQuantityQty(modelValue.value, numberFromBox(value), options)),\n})\n\nconst uom = computed({\n\tget: () => modelValue.value?.uom ?? '',\n\tset: (value: string) => (modelValue.value = patchQuantityUom(modelValue.value, value, options)),\n})\n\nconst qtyNavigationKeys = new Set([\n\t'Backspace',\n\t'Delete',\n\t'Tab',\n\t'Escape',\n\t'Enter',\n\t'ArrowLeft',\n\t'ArrowRight',\n\t'ArrowUp',\n\t'ArrowDown',\n\t'Home',\n\t'End',\n])\n\nconst onQtyKeydown = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (qtyNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\t// Quantity is signed — returns, adjustments, and credit lines can be negative.\n\tconst input = event.target as HTMLInputElement\n\tif (event.key === '.' && !input.value.includes('.')) return\n\tif (event.key === '-' && !input.value.includes('-')) return\n\tevent.preventDefault()\n}\n\nconst onQtyPaste = (event: ClipboardEvent) => {\n\tconst pasted = event.clipboardData?.getData('text') ?? ''\n\tif (!quantityEntryPattern.test(pasted)) event.preventDefault()\n}\n\n// The stock figures are worked out from qty, uom and the options rather than read from the value:\n// under `parts` no field holds them, and the quantity field holds what the server sent (decimal text).\nconst shown = computed(() => {\n\tconst boxValue = modelValue.value\n\treturn boxValue ? recomputeQuantityValue(numberFromRecord(boxValue.qty), boxValue.uom, options, boxValue) : null\n})\n\nconst showStock = computed(() => {\n\tconst shownValue = shown.value\n\treturn !!shownValue?.stockUom && (shownValue.uom !== shownValue.stockUom || shownValue.qty !== shownValue.stockQty)\n})\n\nconst conversionHelperText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || shownValue.stockQty === null || shownValue.qty === null) return ''\n\tconst factor = shownValue.conversionFactor\n\treturn `= ${shownValue.stockQty} ${shownValue.stockUom} · 1 ${shownValue.uom} = ${factor} ${shownValue.stockUom}`\n})\n\nconst displayText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || !shownValue.uom || shownValue.qty === null) return '—'\n\tconst base = `${shownValue.qty} ${shownValue.uom}`\n\treturn showStock.value ? `${base} (${shownValue.stockQty} ${shownValue.stockUom})` : base\n})\n</script>\n\n<style scoped>\n.aquantity__row {\n\tdisplay: flex;\n\tgap: 1ch;\n}\n\n.aquantity__field {\n\tposition: relative;\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.aquantity__group {\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius);\n}\n\n.aquantity__group:focus-within {\n\tborder-color: var(--sc-input-active-border-color);\n}\n\n.aquantity__group > .aform_field-label {\n\tbackground: var(--sc-form-background);\n}\n\n/* Focus ring lives on the merged group only (see AForm :focus-within label + group border). */\n.aquantity__group :deep(.aform_dropdown-button:focus),\n.aquantity__group :deep(.aform_dropdown-button:focus-visible) {\n\toutline: none;\n\tbox-shadow: none;\n}\n\n.aquantity__qty {\n\tflex: 1 1 50%;\n\tmin-width: 0;\n\tborder: none;\n\toutline: none;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\ttext-align: right;\n\tbackground: transparent;\n\tborder-radius: var(--sc-border-radius) 0 0 var(--sc-border-radius);\n\tappearance: textfield;\n\t-moz-appearance: textfield;\n}\n\n.aquantity__qty::-webkit-outer-spin-button,\n.aquantity__qty::-webkit-inner-spin-button {\n\tappearance: none;\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.aquantity__uom {\n\tposition: static;\n\tflex: 1 1 50%;\n\tmin-width: 0;\n\tdisplay: flex;\n\talign-items: stretch;\n\tborder-left: 1px solid var(--sc-input-border-color);\n}\n\n/* ADropdown list: anchor to merged group, not the UOM trigger column (see dropdowns.browser.spec). */\n.aquantity__group :deep(.aform_form-element--embedded),\n.aquantity__group :deep(.autocomplete) {\n\tposition: static;\n\talign-self: stretch;\n}\n\n.aquantity__group :deep(.autocomplete-results--anchor-group) {\n\tleft: -1px;\n\tright: -1px;\n\tbox-sizing: border-box;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.aquantity__helper {\n\tmargin: 0.5rem 0 0;\n\tfont-size: 0.85rem;\n\tcolor: var(--sc-cell-text-color);\n\topacity: 0.75;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ version ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\t:value=\"text\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\tautocomplete=\"off\"\n\t\t\t\tspellcheck=\"false\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@input=\"onInput\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { isSemver, isSemverPrefix } from '@stonecrop/utilities'\nimport { computed, ref, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst version = defineModel<string | null>()\n\n// The box can hold a version still being typed (`1.4.`), which the field holds as null until it is\n// whole, the way a date box holds null until every part of the day is filled.\nconst text = ref('')\nconst versionIn = (boxText: string) => (isSemver(boxText) ? boxText : null)\n\n// Show a value arriving from outside, unless the box already holds a draft of it. Only an edit\n// reports a value, so a record loading into the form never reads as a change.\nwatch(\n\tversion,\n\tvalue => {\n\t\tif (versionIn(text.value) !== (value ?? null)) text.value = value ?? ''\n\t},\n\t{ immediate: true }\n)\n\nconst onInput = (event: Event) => {\n\tconst box = event.target as HTMLInputElement\n\n\t// Refuse an edit leaving text that no version starts with, and put the caret back where it was.\n\t// Text already like that, saved before the field checked it, takes any edit so it can be fixed.\n\tif (!isSemverPrefix(box.value) && isSemverPrefix(text.value)) {\n\t\tconst caret = Math.max(0, (box.selectionStart ?? box.value.length) - (box.value.length - text.value.length))\n\t\tbox.value = text.value\n\t\tbox.setSelectionRange(caret, caret)\n\t\treturn\n\t}\n\n\ttext.value = box.value\n\tconst next = versionIn(box.value)\n\tif (next !== (version.value ?? null)) version.value = next\n}\n</script>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ version ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\t:value=\"text\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\tautocomplete=\"off\"\n\t\t\t\tspellcheck=\"false\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@input=\"onInput\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { isSemver, isSemverPrefix } from '@stonecrop/utilities'\nimport { computed, ref, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst version = defineModel<string | null>()\n\n// The box can hold a version still being typed (`1.4.`), which the field holds as null until it is\n// whole, the way a date box holds null until every part of the day is filled.\nconst text = ref('')\nconst versionIn = (boxText: string) => (isSemver(boxText) ? boxText : null)\n\n// Show a value arriving from outside, unless the box already holds a draft of it. Only an edit\n// reports a value, so a record loading into the form never reads as a change.\nwatch(\n\tversion,\n\tvalue => {\n\t\tif (versionIn(text.value) !== (value ?? null)) text.value = value ?? ''\n\t},\n\t{ immediate: true }\n)\n\nconst onInput = (event: Event) => {\n\tconst box = event.target as HTMLInputElement\n\n\t// Refuse an edit leaving text that no version starts with, and put the caret back where it was.\n\t// Text already like that, saved before the field checked it, takes any edit so it can be fixed.\n\tif (!isSemverPrefix(box.value) && isSemverPrefix(text.value)) {\n\t\tconst caret = Math.max(0, (box.selectionStart ?? box.value.length) - (box.value.length - text.value.length))\n\t\tbox.value = text.value\n\t\tbox.setSelectionRange(caret, caret)\n\t\treturn\n\t}\n\n\ttext.value = box.value\n\tconst next = versionIn(box.value)\n\tif (next !== (version.value ?? null)) version.value = next\n}\n</script>\n","import type { DirectiveBinding } from 'vue'\n\nimport { deserializeFunction } from '../utils/deserialize'\n\n/**\n * Extracts a mask function from a stringified function\n * @param mask - Mask string\n * @returns Mask function, or undefined if the string is not a valid function expression\n */\nfunction extractMaskFn(mask: string): ((locale: any) => string) | undefined {\n\ttry {\n\t\treturn deserializeFunction<(locale: any) => string>(mask)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * Gets the mask for a given directive binding\n * @param binding - Binding object from directive hook\n * @returns Mask string\n */\nfunction getMask(binding: DirectiveBinding<string>) {\n\tconst mask = binding.value\n\tif (!mask) return undefined\n\n\tconst maskFn = extractMaskFn(mask)\n\tif (maskFn) {\n\t\t// TODO: (state) replace with state management;\n\t\t// pass the entire form/table data to the function\n\t\t// Vue directive reads arbitrary fields off host component instance; type is unknown at this layer.\n\t\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion\n\t\tconst instance = binding.instance as Record<string, unknown> | null | undefined\n\t\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion\n\t\tconst locale = instance?.['locale'] as string | undefined\n\t\treturn maskFn(locale)\n\t}\n\n\treturn mask\n}\n\n/**\n * Unmasks the input string\n * @param input - Input string\n * @param maskToken - Mask token character\n * @returns Unmasked input string\n */\nfunction unmaskInput(input: string, maskToken?: string) {\n\tif (!maskToken) {\n\t\tmaskToken = '#'\n\t}\n\n\tlet unmaskedInput = input\n\tconst maskChars = [maskToken, '/', '-', '(', ')', ' ']\n\n\tfor (const char of maskChars) {\n\t\tunmaskedInput = unmaskedInput.replaceAll(char, '')\n\t}\n\n\treturn unmaskedInput\n}\n\n/**\n * Fills the mask with the input string\n * @param input - Input string\n * @param mask - Mask string\n * @param maskToken - Mask token character\n * @returns Masked input string\n */\nfunction fillMask(input: string, mask: string, maskToken?: string) {\n\tif (!maskToken) {\n\t\tmaskToken = '#'\n\t}\n\n\tlet replacement = mask\n\tfor (const inputChar of input) {\n\t\tconst replaceIndex = replacement.indexOf(maskToken)\n\t\tif (replaceIndex !== -1) {\n\t\t\tconst prefix = replacement.substring(0, replaceIndex)\n\t\t\tconst suffix = replacement.substring(replaceIndex + 1)\n\t\t\treplacement = prefix + inputChar + suffix\n\t\t}\n\t}\n\n\treturn replacement.slice(0, mask.length)\n}\n\n/**\n * Applies a mask to an input element\n * @param el - Input element\n * @param binding - Binding object from directive hook\n * @returns void\n * @public\n */\nexport function useStringMask(el: HTMLInputElement, binding: DirectiveBinding<string>) {\n\tconst mask = getMask(binding)\n\tif (!mask) return\n\n\tconst maskToken = '#'\n\tconst inputText = el.value\n\n\t// process input value with mask\n\tconst unmaskedInput = unmaskInput(inputText, maskToken)\n\tif (unmaskedInput) {\n\t\tconst replacement = fillMask(unmaskedInput, mask, maskToken)\n\n\t\t// TODO: (state) this is very opinionated;\n\t\t// most likely fixed with state management;\n\t\t// a better way could be to emit back to instance;\n\n\t\t// Vue directive reads/writes arbitrary fields on host component instance.\n\t\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion\n\t\tconst instance = binding.instance as Record<string, unknown> | null | undefined\n\t\tif (instance?.['maskFilled']) {\n\t\t\tinstance['maskFilled'] = !replacement.includes(maskToken)\n\t\t}\n\n\t\tel.value = replacement\n\t} else {\n\t\tel.value = mask\n\t}\n}\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ inputText ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"inputText\"\n\t\t\t\tv-mask=\"mask\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:maxlength=\"mask ? (maskFilled ? mask.length : undefined) : undefined\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }} </label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { /* inject, */ computed, ref } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { useStringMask as vMask } from '../../directives/mask'\nimport { ComponentProps } from '../../types'\n\nconst { label, mask, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\n// TODO: setup maskFilled as a computed property\nconst maskFilled = ref(true)\n\n// TODO: (state) replace with state management\n// const locale = inject<string>('locale', '')\n\nconst inputText = defineModel<number | string>()\n</script>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ inputText ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"inputText\"\n\t\t\t\tv-mask=\"mask\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:maxlength=\"mask ? (maskFilled ? mask.length : undefined) : undefined\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }} </label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { /* inject, */ computed, ref } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { useStringMask as vMask } from '../../directives/mask'\nimport { ComponentProps } from '../../types'\n\nconst { label, mask, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\n// TODO: setup maskFilled as a computed property\nconst maskFilled = ref(true)\n\n// TODO: (state) replace with state management\n// const locale = inject<string>('locale', '')\n\nconst inputText = defineModel<number | string>()\n</script>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value aform_textbox-display\">{{ inputText ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<textarea\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"inputText\"\n\t\t\t\tclass=\"aform_input-field aform_textbox\"\n\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t:rows=\"rows\"\n\t\t\t\t:maxlength=\"maxlength\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"></textarea>\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tplaceholder = '',\n\trows = 4,\n\tmaxlength,\n\tvalidation = { errorMessage: '' },\n} = defineProps<\n\tComponentProps & {\n\t\t/** Placeholder shown when the field is empty */\n\t\tplaceholder?: string\n\t\t/** Visible number of text lines (maps to the textarea `rows` attribute) */\n\t\trows?: number\n\t\t/** Maximum number of characters the field will accept */\n\t\tmaxlength?: number\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst inputText = defineModel<string | null>()\n</script>\n\n<style scoped>\n.aform_textbox {\n\tresize: vertical;\n\tline-height: 1.5;\n\tmin-height: 4rem;\n\tfont-family: inherit;\n}\n\n.aform_textbox-display {\n\twhite-space: pre-wrap;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value aform_textbox-display\">{{ inputText ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<textarea\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"inputText\"\n\t\t\t\tclass=\"aform_input-field aform_textbox\"\n\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t:rows=\"rows\"\n\t\t\t\t:maxlength=\"maxlength\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"></textarea>\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tplaceholder = '',\n\trows = 4,\n\tmaxlength,\n\tvalidation = { errorMessage: '' },\n} = defineProps<\n\tComponentProps & {\n\t\t/** Placeholder shown when the field is empty */\n\t\tplaceholder?: string\n\t\t/** Visible number of text lines (maps to the textarea `rows` attribute) */\n\t\trows?: number\n\t\t/** Maximum number of characters the field will accept */\n\t\tmaxlength?: number\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst inputText = defineModel<string | null>()\n</script>\n\n<style scoped>\n.aform_textbox {\n\tresize: vertical;\n\tline-height: 1.5;\n\tmin-height: 4rem;\n\tfont-family: inherit;\n}\n\n.aform_textbox-display {\n\twhite-space: pre-wrap;\n}\n</style>\n","<template>\n\t<div class=\"login-container\">\n\t\t<div>\n\t\t\t<div class=\"account-container\">\n\t\t\t\t<div class=\"account-header\">\n\t\t\t\t\t<h1 id=\"account-title\">{{ headerTitle }}</h1>\n\t\t\t\t\t<p id=\"account-subtitle\">{{ headerSubtitle }}</p>\n\t\t\t\t</div>\n\n\t\t\t\t<form @submit=\"onSubmit\">\n\t\t\t\t\t<div class=\"login-form-container\">\n\t\t\t\t\t\t<div class=\"login-form-email aform_form-element\">\n\t\t\t\t\t\t\t<label id=\"login-email\" for=\"email\" class=\"aform_field-label\">Email</label>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"email\"\n\t\t\t\t\t\t\t\tv-model=\"email\"\n\t\t\t\t\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t\t\t\t\tname=\"email\"\n\t\t\t\t\t\t\t\tplaceholder=\"name@example.com\"\n\t\t\t\t\t\t\t\ttype=\"email\"\n\t\t\t\t\t\t\t\tautocomplete=\"email\"\n\t\t\t\t\t\t\t\tautocapitalize=\"none\"\n\t\t\t\t\t\t\t\tautocorrect=\"off\"\n\t\t\t\t\t\t\t\t:disabled=\"isLoading\" />\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div class=\"login-form-password aform_form-element\">\n\t\t\t\t\t\t\t<label id=\"login-password\" for=\"password\" class=\"aform_field-label\">Password</label>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"password\"\n\t\t\t\t\t\t\t\tv-model=\"password\"\n\t\t\t\t\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t\t\t\t\tname=\"password\"\n\t\t\t\t\t\t\t\ttype=\"password\"\n\t\t\t\t\t\t\t\tautocomplete=\"current-password\"\n\t\t\t\t\t\t\t\t:disabled=\"isLoading\" />\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<button type=\"submit\" class=\"btn\" :disabled=\"isLoading || !email || !password\">\n\t\t\t\t\t\t\t<span v-if=\"isLoading\" class=\"material-symbols-outlined loading-icon\">progress_activity</span>\n\t\t\t\t\t\t\t<span id=\"login-form-button\">Login</span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\n\t\t\t\t<button type=\"button\" class=\"btn\">\n\t\t\t\t\t<span id=\"forgot-password-button\">Forgot password?</span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nconst { headerTitle = 'Login', headerSubtitle = 'Enter your email and password to login' } = defineProps<{\n\theaderTitle?: string\n\theaderSubtitle?: string\n}>()\n\nconst emit = defineEmits(['loginFailed', 'loginSuccess'])\n\nconst email = ref('')\nconst password = ref('')\n\nconst isLoading = ref(false)\nconst loginFailed = ref(false)\n\nfunction onSubmit(event: Event) {\n\tevent.preventDefault()\n\tisLoading.value = true\n\n\t// TODO: handle submit logic, handle failure\n\n\tif (loginFailed.value) {\n\t\tisLoading.value = false\n\t\temit('loginFailed')\n\t\treturn\n\t}\n\n\tisLoading.value = false\n\temit('loginSuccess')\n}\n</script>\n\n<style scoped>\n.login-container {\n\twidth: 100%;\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\tfont-family: var(--sc-font-family);\n\tbackground: var(--sc-form-background);\n}\n\n.account-container {\n\twidth: 100%;\n\tmargin-left: auto;\n\tmargin-top: 0.5rem;\n\tmargin-right: auto;\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n}\n\n.account-header {\n\tdisplay: flex;\n\tflex-direction: column;\n\ttext-align: center;\n\tmargin-top: 0.5rem;\n}\n\n#account-title {\n\tfont-size: 1.5rem;\n\tline-height: 2rem;\n\tfont-weight: 600;\n\tletter-spacing: -0.025em;\n\tmargin: 0;\n}\n\n#account-subtitle {\n\tfont-size: 0.875rem;\n\tline-height: 1.25rem;\n\tmargin: 1rem;\n}\n\n.login-form-container {\n\tdisplay: grid;\n\tgap: 0.5rem;\n}\n\n.login-form-element {\n\tdisplay: grid;\n\tmargin: 0.5rem 0;\n\tposition: relative;\n}\n.btn {\n\tbackground-color: var(--sc-btn-color);\n\tcolor: var(--sc-btn-label-color);\n\tborder: 1px solid var(--sc-btn-border);\n\tmargin: 0.5rem 0;\n\tpadding: 0.25rem;\n\tposition: relative;\n\tcursor: pointer;\n\n\t&:hover {\n\t\tbackground-color: var(--sc-btn-hover);\n\t}\n\n\t&:disabled {\n\t\tbackground-color: var(--sc-input-field-disabled-background);\n\t}\n}\n.disabled {\n\topacity: 0.5;\n}\n.loading-icon {\n\tanimation: spin 1s linear infinite forwards;\n\tdisplay: inline-block;\n\tmargin-right: 0.2rem;\n\tline-height: 0;\n\tfont-size: 1rem;\n\tposition: relative;\n\ttop: 0.2rem;\n}\n\n/* ANIMATION */\n@keyframes spin {\n\tfrom {\n\t\ttransform: rotate(0deg);\n\t}\n\n\tto {\n\t\ttransform: rotate(360deg);\n\t}\n}\n</style>\n","<template>\n\t<div class=\"login-container\">\n\t\t<div>\n\t\t\t<div class=\"account-container\">\n\t\t\t\t<div class=\"account-header\">\n\t\t\t\t\t<h1 id=\"account-title\">{{ headerTitle }}</h1>\n\t\t\t\t\t<p id=\"account-subtitle\">{{ headerSubtitle }}</p>\n\t\t\t\t</div>\n\n\t\t\t\t<form @submit=\"onSubmit\">\n\t\t\t\t\t<div class=\"login-form-container\">\n\t\t\t\t\t\t<div class=\"login-form-email aform_form-element\">\n\t\t\t\t\t\t\t<label id=\"login-email\" for=\"email\" class=\"aform_field-label\">Email</label>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"email\"\n\t\t\t\t\t\t\t\tv-model=\"email\"\n\t\t\t\t\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t\t\t\t\tname=\"email\"\n\t\t\t\t\t\t\t\tplaceholder=\"name@example.com\"\n\t\t\t\t\t\t\t\ttype=\"email\"\n\t\t\t\t\t\t\t\tautocomplete=\"email\"\n\t\t\t\t\t\t\t\tautocapitalize=\"none\"\n\t\t\t\t\t\t\t\tautocorrect=\"off\"\n\t\t\t\t\t\t\t\t:disabled=\"isLoading\" />\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div class=\"login-form-password aform_form-element\">\n\t\t\t\t\t\t\t<label id=\"login-password\" for=\"password\" class=\"aform_field-label\">Password</label>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"password\"\n\t\t\t\t\t\t\t\tv-model=\"password\"\n\t\t\t\t\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t\t\t\t\tname=\"password\"\n\t\t\t\t\t\t\t\ttype=\"password\"\n\t\t\t\t\t\t\t\tautocomplete=\"current-password\"\n\t\t\t\t\t\t\t\t:disabled=\"isLoading\" />\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<button type=\"submit\" class=\"btn\" :disabled=\"isLoading || !email || !password\">\n\t\t\t\t\t\t\t<span v-if=\"isLoading\" class=\"material-symbols-outlined loading-icon\">progress_activity</span>\n\t\t\t\t\t\t\t<span id=\"login-form-button\">Login</span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\n\t\t\t\t<button type=\"button\" class=\"btn\">\n\t\t\t\t\t<span id=\"forgot-password-button\">Forgot password?</span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nconst { headerTitle = 'Login', headerSubtitle = 'Enter your email and password to login' } = defineProps<{\n\theaderTitle?: string\n\theaderSubtitle?: string\n}>()\n\nconst emit = defineEmits(['loginFailed', 'loginSuccess'])\n\nconst email = ref('')\nconst password = ref('')\n\nconst isLoading = ref(false)\nconst loginFailed = ref(false)\n\nfunction onSubmit(event: Event) {\n\tevent.preventDefault()\n\tisLoading.value = true\n\n\t// TODO: handle submit logic, handle failure\n\n\tif (loginFailed.value) {\n\t\tisLoading.value = false\n\t\temit('loginFailed')\n\t\treturn\n\t}\n\n\tisLoading.value = false\n\temit('loginSuccess')\n}\n</script>\n\n<style scoped>\n.login-container {\n\twidth: 100%;\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\tfont-family: var(--sc-font-family);\n\tbackground: var(--sc-form-background);\n}\n\n.account-container {\n\twidth: 100%;\n\tmargin-left: auto;\n\tmargin-top: 0.5rem;\n\tmargin-right: auto;\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n}\n\n.account-header {\n\tdisplay: flex;\n\tflex-direction: column;\n\ttext-align: center;\n\tmargin-top: 0.5rem;\n}\n\n#account-title {\n\tfont-size: 1.5rem;\n\tline-height: 2rem;\n\tfont-weight: 600;\n\tletter-spacing: -0.025em;\n\tmargin: 0;\n}\n\n#account-subtitle {\n\tfont-size: 0.875rem;\n\tline-height: 1.25rem;\n\tmargin: 1rem;\n}\n\n.login-form-container {\n\tdisplay: grid;\n\tgap: 0.5rem;\n}\n\n.login-form-element {\n\tdisplay: grid;\n\tmargin: 0.5rem 0;\n\tposition: relative;\n}\n.btn {\n\tbackground-color: var(--sc-btn-color);\n\tcolor: var(--sc-btn-label-color);\n\tborder: 1px solid var(--sc-btn-border);\n\tmargin: 0.5rem 0;\n\tpadding: 0.25rem;\n\tposition: relative;\n\tcursor: pointer;\n\n\t&:hover {\n\t\tbackground-color: var(--sc-btn-hover);\n\t}\n\n\t&:disabled {\n\t\tbackground-color: var(--sc-input-field-disabled-background);\n\t}\n}\n.disabled {\n\topacity: 0.5;\n}\n.loading-icon {\n\tanimation: spin 1s linear infinite forwards;\n\tdisplay: inline-block;\n\tmargin-right: 0.2rem;\n\tline-height: 0;\n\tfont-size: 1rem;\n\tposition: relative;\n\ttop: 0.2rem;\n}\n\n/* ANIMATION */\n@keyframes spin {\n\tfrom {\n\t\ttransform: rotate(0deg);\n\t}\n\n\tto {\n\t\ttransform: rotate(360deg);\n\t}\n}\n</style>\n","<template>\n\t<div class=\"aform-loading\">\n\t\t<div class=\"aform-loading__label\">\n\t\t\t<slot></slot>\n\t\t</div>\n\t\t<div class=\"aform-loading__bar\"></div>\n\t</div>\n</template>\n\n<style scoped>\n.aform-loading {\n\twidth: 100%;\n\tborder: 1px solid var(--sc-form-border);\n\tborder-left: 4px solid var(--sc-form-border);\n\tpadding: 1rem;\n\tmargin-bottom: 1rem;\n\tbox-sizing: border-box;\n\tposition: relative;\n\toverflow: hidden;\n\tbackground: var(--sc-input-field-background);\n}\n\n.aform-loading__label {\n\tfont-size: 0.9rem;\n\tcolor: var(--sc-cell-text-color);\n\tz-index: 1;\n\tposition: relative;\n}\n\n.aform-loading__label:not(:empty)::after {\n\tcontent: '...';\n\tanimation: ellipsis 2s infinite;\n}\n\n.aform-loading__bar {\n\twidth: 100%;\n\theight: 100%;\n\tposition: absolute;\n\tleft: -100%;\n\ttop: 0;\n\tbackground: linear-gradient(\n\t\t90deg,\n\t\trgba(var(--sc-table-loading-color), 0) 0%,\n\t\trgba(var(--sc-table-loading-color), 1) 50%,\n\t\trgba(var(--sc-table-loading-color), 0) 100%\n\t);\n\tanimation: bar-sweep 2s infinite;\n\tz-index: 0;\n}\n\n@keyframes bar-sweep {\n\t0% {\n\t\tleft: -100%;\n\t}\n\t100% {\n\t\tleft: 100%;\n\t}\n}\n\n@keyframes ellipsis {\n\t0%,\n\t20% {\n\t\tcontent: '';\n\t}\n\t40% {\n\t\tcontent: '.';\n\t}\n\t60% {\n\t\tcontent: '..';\n\t}\n\t80%,\n\t100% {\n\t\tcontent: '...';\n\t}\n}\n</style>\n","<template>\n\t<button\n\t\ttype=\"button\"\n\t\tclass=\"expansion-index\"\n\t\t:aria-expanded=\"expanded\"\n\t\t:aria-label=\"expanded ? 'Collapse' : 'Expand'\">\n\t\t{{ expanded ? '▼' : '►' }}\n\t</button>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{\n\texpanded: boolean\n}>()\n</script>\n\n<style scoped>\n.expansion-index {\n\tcolor: var(--sc-header-text-color);\n\tfont-weight: bold;\n\tfont-size: 11px;\n\tline-height: 1;\n\ttext-align: center;\n\tuser-select: none;\n\twidth: 2ch;\n\tmin-width: 1.25rem;\n\theight: 1.25rem;\n\tpadding: 0;\n\tborder: none;\n\tbackground: transparent;\n\tcursor: pointer;\n\tbox-sizing: border-box;\n}\n</style>\n","<template>\n\t<button\n\t\ttype=\"button\"\n\t\tclass=\"expansion-index\"\n\t\t:aria-expanded=\"expanded\"\n\t\t:aria-label=\"expanded ? 'Collapse' : 'Expand'\">\n\t\t{{ expanded ? '▼' : '►' }}\n\t</button>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{\n\texpanded: boolean\n}>()\n</script>\n\n<style scoped>\n.expansion-index {\n\tcolor: var(--sc-header-text-color);\n\tfont-weight: bold;\n\tfont-size: 11px;\n\tline-height: 1;\n\ttext-align: center;\n\tuser-select: none;\n\twidth: 2ch;\n\tmin-width: 1.25rem;\n\theight: 1.25rem;\n\tpadding: 0;\n\tborder: none;\n\tbackground: transparent;\n\tcursor: pointer;\n\tbox-sizing: border-box;\n}\n</style>\n","import { nextTick, onMounted, ref, watch, type Ref } from 'vue'\n\ntype TableModalDropdownListOptions = {\n\tpanelRef: Readonly<Ref<HTMLElement | null>>\n\tisOpen: () => boolean\n\toptionCount: () => number\n\tselectAt: (index: number) => void\n\tonClose: () => void\n}\n\n/** Keyboard nav + focus for {@link ADropdownList} hosted in {@link ATableModal}. */\nexport function useTableModalDropdownList(options: TableModalDropdownListOptions) {\n\tconst activeIndex = ref<number | null>(null)\n\n\tconst focusPanel = () => {\n\t\tvoid nextTick(() => options.panelRef.value?.focus())\n\t}\n\n\twatch(\n\t\t() => options.isOpen(),\n\t\topen => {\n\t\t\tif (open) {\n\t\t\t\tactiveIndex.value = null\n\t\t\t\tfocusPanel()\n\t\t\t}\n\t\t}\n\t)\n\n\tonMounted(() => {\n\t\tif (options.isOpen()) focusPanel()\n\t})\n\n\tconst onKeydown = (event: KeyboardEvent) => {\n\t\t// Before the check for options: a picker with nothing to pick, or still loading, closes on Escape too.\n\t\tif (event.key === 'Escape') {\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\toptions.onClose()\n\t\t\treturn\n\t\t}\n\n\t\tconst count = options.optionCount()\n\t\tif (!count) return\n\n\t\tif (event.key === 'ArrowDown') {\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\tif (activeIndex.value != null) {\n\t\t\t\tactiveIndex.value = (activeIndex.value + 1) % count\n\t\t\t} else {\n\t\t\t\tactiveIndex.value = 0\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (event.key === 'ArrowUp') {\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\tif (activeIndex.value != null) {\n\t\t\t\tactiveIndex.value = activeIndex.value === 0 ? Math.max(count - 1, 0) : activeIndex.value - 1\n\t\t\t} else {\n\t\t\t\tactiveIndex.value = Math.max(count - 1, 0)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (event.key === 'Enter') {\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\tconst index = activeIndex.value ?? 0\n\t\t\tif (index >= 0 && index < count) options.selectAt(index)\n\t\t\treturn\n\t\t}\n\t}\n\n\tconst onClickOutside = () => {\n\t\toptions.onClose()\n\t}\n\n\t// Focus moving out of the picker, by Tab or to whatever was clicked, closes it.\n\tconst onFocusOut = (event: FocusEvent) => {\n\t\tif (event.relatedTarget instanceof Node && options.panelRef.value?.contains(event.relatedTarget)) return\n\t\toptions.onClose()\n\t}\n\n\treturn { activeIndex, onKeydown, onClickOutside, onFocusOut, focusPanel }\n}\n","<template>\n\t<div\n\t\tv-if=\"open\"\n\t\tref=\"panelRef\"\n\t\tclass=\"atable-tuple-picker-modal\"\n\t\ttabindex=\"-1\"\n\t\tv-on-click-outside=\"onClickOutside\"\n\t\t@keydown=\"onKeydown\"\n\t\t@focusout=\"onFocusOut\">\n\t\t<ADropdownList\n\t\t\t:listbox-id=\"listboxId\"\n\t\t\tariaLabel=\"Currency\"\n\t\t\t:open=\"true\"\n\t\t\tsurface=\"cell-modal\"\n\t\t\t:option-count=\"optionCount\"\n\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t<li v-if=\"loading\" class=\"loading autocomplete-result\">Loading…</li>\n\t\t\t<li\n\t\t\t\tv-for=\"(option, i) in currencyOptions\"\n\t\t\t\tv-else-if=\"!loading\"\n\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"isSelected(option)\"\n\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': isSelected(option) }\"\n\t\t\t\t@mousedown.prevent=\"selectCurrency(option)\">\n\t\t\t\t{{ option.symbol ? `${option.symbol} — ` : '' }}{{ option.displayText ?? option.id }}\n\t\t\t</li>\n\t\t</ADropdownList>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { TABLE_TUPLE_CURRENCY_PICKER, type TableStore } from '@stonecrop/atable'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport type { AFormLinkValue, CurrencyOptions, CurrencyValue } from '../../types'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { normalizeBaseCurrency, patchCurrencyCurrency, staticCurrencyChoices } from '../../utils/currencyValue'\nimport { useTableModalDropdownList } from '../../composables/useTableModalDropdownList'\nimport ADropdownList from '../form/ADropdownList.vue'\n\nconst { store } = defineProps<{\n\tstore: TableStore\n}>()\n\nconst panelRef = useTemplateRef('panelRef')\nconst loading = ref(false)\nconst currencyOptions = ref<AFormLinkValue[]>([])\n\nconst open = computed(() => !!store.modal.visible && store.modal.component === TABLE_TUPLE_CURRENCY_PICKER)\nconst colIndex = computed(() => store.modal.colIndex ?? 0)\nconst rowIndex = computed(() => store.modal.rowIndex ?? 0)\nconst column = computed(() => store.columns[colIndex.value])\nconst currencyFieldOptions = computed(() => (column.value?.options ?? {}) as CurrencyOptions)\nconst cellValue = computed(() => store.getCellData(colIndex.value, rowIndex.value) as CurrencyValue | null | undefined)\n\nconst listboxId = computed(() => `atable-tuple-cur-${rowIndex.value}-${colIndex.value}`)\n\nconst isSelected = (option: AFormLinkValue) => String(option.id) === String(cellValue.value?.currency?.id)\n\nconst loadCurrencyOptions = async () => {\n\tconst opts = currencyFieldOptions.value\n\tconst filterFunction = opts.filterFunction\n\tif (filterFunction) {\n\t\tloading.value = true\n\t\ttry {\n\t\t\tconst fn =\n\t\t\t\ttypeof filterFunction === 'string'\n\t\t\t\t\t? deserializeFunction<(search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>>(filterFunction)\n\t\t\t\t\t: filterFunction\n\t\t\tcurrencyOptions.value = (await fn('')) ?? []\n\t\t} catch {\n\t\t\tcurrencyOptions.value = []\n\t\t} finally {\n\t\t\tloading.value = false\n\t\t}\n\t\treturn\n\t}\n\tcurrencyOptions.value = staticCurrencyChoices(opts, cellValue.value)\n}\n\nwatch(open, visible => {\n\tif (visible) void loadCurrencyOptions()\n})\n\nonMounted(() => {\n\tif (open.value) void loadCurrencyOptions()\n})\n\nconst optionCount = () => (loading.value ? 0 : currencyOptions.value.length)\n\nconst closePicker = () => store.closeTuplePicker()\n\nconst selectCurrency = (option: AFormLinkValue) => {\n\tconst opts = currencyFieldOptions.value\n\tconst base = normalizeBaseCurrency(opts, cellValue.value)\n\tstore.setCellData(colIndex.value, rowIndex.value, patchCurrencyCurrency(cellValue.value, option, opts, base))\n\tclosePicker()\n}\n\nconst { activeIndex, onKeydown, onClickOutside, onFocusOut } = useTableModalDropdownList({\n\tpanelRef,\n\tisOpen: () => open.value,\n\toptionCount,\n\tselectAt: index => {\n\t\tconst option = currencyOptions.value[index]\n\t\tif (option !== undefined) selectCurrency(option)\n\t},\n\tonClose: closePicker,\n})\n</script>\n\n<style scoped>\n.atable-tuple-picker-modal {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 100%;\n\toutline: none;\n}\n</style>\n","<template>\n\t<div\n\t\tv-if=\"open\"\n\t\tref=\"panelRef\"\n\t\tclass=\"atable-tuple-picker-modal\"\n\t\ttabindex=\"-1\"\n\t\tv-on-click-outside=\"onClickOutside\"\n\t\t@keydown=\"onKeydown\"\n\t\t@focusout=\"onFocusOut\">\n\t\t<ADropdownList\n\t\t\t:listbox-id=\"listboxId\"\n\t\t\tariaLabel=\"Currency\"\n\t\t\t:open=\"true\"\n\t\t\tsurface=\"cell-modal\"\n\t\t\t:option-count=\"optionCount\"\n\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t<li v-if=\"loading\" class=\"loading autocomplete-result\">Loading…</li>\n\t\t\t<li\n\t\t\t\tv-for=\"(option, i) in currencyOptions\"\n\t\t\t\tv-else-if=\"!loading\"\n\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"isSelected(option)\"\n\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': isSelected(option) }\"\n\t\t\t\t@mousedown.prevent=\"selectCurrency(option)\">\n\t\t\t\t{{ option.symbol ? `${option.symbol} — ` : '' }}{{ option.displayText ?? option.id }}\n\t\t\t</li>\n\t\t</ADropdownList>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { TABLE_TUPLE_CURRENCY_PICKER, type TableStore } from '@stonecrop/atable'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport type { AFormLinkValue, CurrencyOptions, CurrencyValue } from '../../types'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { normalizeBaseCurrency, patchCurrencyCurrency, staticCurrencyChoices } from '../../utils/currencyValue'\nimport { useTableModalDropdownList } from '../../composables/useTableModalDropdownList'\nimport ADropdownList from '../form/ADropdownList.vue'\n\nconst { store } = defineProps<{\n\tstore: TableStore\n}>()\n\nconst panelRef = useTemplateRef('panelRef')\nconst loading = ref(false)\nconst currencyOptions = ref<AFormLinkValue[]>([])\n\nconst open = computed(() => !!store.modal.visible && store.modal.component === TABLE_TUPLE_CURRENCY_PICKER)\nconst colIndex = computed(() => store.modal.colIndex ?? 0)\nconst rowIndex = computed(() => store.modal.rowIndex ?? 0)\nconst column = computed(() => store.columns[colIndex.value])\nconst currencyFieldOptions = computed(() => (column.value?.options ?? {}) as CurrencyOptions)\nconst cellValue = computed(() => store.getCellData(colIndex.value, rowIndex.value) as CurrencyValue | null | undefined)\n\nconst listboxId = computed(() => `atable-tuple-cur-${rowIndex.value}-${colIndex.value}`)\n\nconst isSelected = (option: AFormLinkValue) => String(option.id) === String(cellValue.value?.currency?.id)\n\nconst loadCurrencyOptions = async () => {\n\tconst opts = currencyFieldOptions.value\n\tconst filterFunction = opts.filterFunction\n\tif (filterFunction) {\n\t\tloading.value = true\n\t\ttry {\n\t\t\tconst fn =\n\t\t\t\ttypeof filterFunction === 'string'\n\t\t\t\t\t? deserializeFunction<(search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>>(filterFunction)\n\t\t\t\t\t: filterFunction\n\t\t\tcurrencyOptions.value = (await fn('')) ?? []\n\t\t} catch {\n\t\t\tcurrencyOptions.value = []\n\t\t} finally {\n\t\t\tloading.value = false\n\t\t}\n\t\treturn\n\t}\n\tcurrencyOptions.value = staticCurrencyChoices(opts, cellValue.value)\n}\n\nwatch(open, visible => {\n\tif (visible) void loadCurrencyOptions()\n})\n\nonMounted(() => {\n\tif (open.value) void loadCurrencyOptions()\n})\n\nconst optionCount = () => (loading.value ? 0 : currencyOptions.value.length)\n\nconst closePicker = () => store.closeTuplePicker()\n\nconst selectCurrency = (option: AFormLinkValue) => {\n\tconst opts = currencyFieldOptions.value\n\tconst base = normalizeBaseCurrency(opts, cellValue.value)\n\tstore.setCellData(colIndex.value, rowIndex.value, patchCurrencyCurrency(cellValue.value, option, opts, base))\n\tclosePicker()\n}\n\nconst { activeIndex, onKeydown, onClickOutside, onFocusOut } = useTableModalDropdownList({\n\tpanelRef,\n\tisOpen: () => open.value,\n\toptionCount,\n\tselectAt: index => {\n\t\tconst option = currencyOptions.value[index]\n\t\tif (option !== undefined) selectCurrency(option)\n\t},\n\tonClose: closePicker,\n})\n</script>\n\n<style scoped>\n.atable-tuple-picker-modal {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 100%;\n\toutline: none;\n}\n</style>\n","<template>\n\t<div\n\t\tv-if=\"open\"\n\t\tref=\"panelRef\"\n\t\tclass=\"atable-tuple-picker-modal\"\n\t\ttabindex=\"-1\"\n\t\tv-on-click-outside=\"onClickOutside\"\n\t\t@keydown=\"onKeydown\"\n\t\t@focusout=\"onFocusOut\">\n\t\t<ADropdownList\n\t\t\t:listbox-id=\"listboxId\"\n\t\t\tariaLabel=\"Unit of measure\"\n\t\t\t:open=\"true\"\n\t\t\tsurface=\"cell-modal\"\n\t\t\t:option-count=\"optionCount\"\n\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t<li\n\t\t\t\tv-for=\"(uom, i) in uomOptions\"\n\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t:key=\"uom\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"uom === selectedUom\"\n\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': uom === selectedUom }\"\n\t\t\t\t@mousedown.prevent=\"selectUom(uom)\">\n\t\t\t\t{{ uom }}\n\t\t\t</li>\n\t\t</ADropdownList>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { TABLE_TUPLE_QUANTITY_PICKER, type TableStore } from '@stonecrop/atable'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, useTemplateRef } from 'vue'\n\nimport type { QuantityOptions, QuantityValue } from '../../types'\nimport { patchQuantityUom } from '../../utils/quantityValue'\nimport { useTableModalDropdownList } from '../../composables/useTableModalDropdownList'\nimport ADropdownList from '../form/ADropdownList.vue'\n\nconst { store } = defineProps<{\n\tstore: TableStore\n}>()\n\nconst panelRef = useTemplateRef('panelRef')\n\nconst open = computed(() => !!store.modal.visible && store.modal.component === TABLE_TUPLE_QUANTITY_PICKER)\nconst colIndex = computed(() => store.modal.colIndex ?? 0)\nconst rowIndex = computed(() => store.modal.rowIndex ?? 0)\nconst column = computed(() => store.columns[colIndex.value])\n\nconst uomOptions = computed(() => (column.value?.options as QuantityOptions | undefined)?.uoms ?? [])\nconst cellValue = computed(() => store.getCellData(colIndex.value, rowIndex.value) as QuantityValue | null | undefined)\nconst selectedUom = computed(() => cellValue.value?.uom ?? '')\n\nconst listboxId = computed(() => `atable-tuple-qty-${rowIndex.value}-${colIndex.value}`)\n\nconst optionCount = () => uomOptions.value.length\n\nconst closePicker = () => store.closeTuplePicker()\n\nconst selectUom = (uom: string) => {\n\tconst options = (column.value?.options ?? {}) as QuantityOptions\n\tstore.setCellData(colIndex.value, rowIndex.value, patchQuantityUom(cellValue.value, uom, options))\n\tclosePicker()\n}\n\nconst { activeIndex, onKeydown, onClickOutside, onFocusOut } = useTableModalDropdownList({\n\tpanelRef,\n\tisOpen: () => open.value,\n\toptionCount,\n\tselectAt: index => {\n\t\tconst uom = uomOptions.value[index]\n\t\tif (uom !== undefined) selectUom(uom)\n\t},\n\tonClose: closePicker,\n})\n</script>\n\n<style scoped>\n.atable-tuple-picker-modal {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 100%;\n\toutline: none;\n}\n</style>\n","<template>\n\t<div\n\t\tv-if=\"open\"\n\t\tref=\"panelRef\"\n\t\tclass=\"atable-tuple-picker-modal\"\n\t\ttabindex=\"-1\"\n\t\tv-on-click-outside=\"onClickOutside\"\n\t\t@keydown=\"onKeydown\"\n\t\t@focusout=\"onFocusOut\">\n\t\t<ADropdownList\n\t\t\t:listbox-id=\"listboxId\"\n\t\t\tariaLabel=\"Unit of measure\"\n\t\t\t:open=\"true\"\n\t\t\tsurface=\"cell-modal\"\n\t\t\t:option-count=\"optionCount\"\n\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t<li\n\t\t\t\tv-for=\"(uom, i) in uomOptions\"\n\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t:key=\"uom\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"uom === selectedUom\"\n\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': uom === selectedUom }\"\n\t\t\t\t@mousedown.prevent=\"selectUom(uom)\">\n\t\t\t\t{{ uom }}\n\t\t\t</li>\n\t\t</ADropdownList>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { TABLE_TUPLE_QUANTITY_PICKER, type TableStore } from '@stonecrop/atable'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, useTemplateRef } from 'vue'\n\nimport type { QuantityOptions, QuantityValue } from '../../types'\nimport { patchQuantityUom } from '../../utils/quantityValue'\nimport { useTableModalDropdownList } from '../../composables/useTableModalDropdownList'\nimport ADropdownList from '../form/ADropdownList.vue'\n\nconst { store } = defineProps<{\n\tstore: TableStore\n}>()\n\nconst panelRef = useTemplateRef('panelRef')\n\nconst open = computed(() => !!store.modal.visible && store.modal.component === TABLE_TUPLE_QUANTITY_PICKER)\nconst colIndex = computed(() => store.modal.colIndex ?? 0)\nconst rowIndex = computed(() => store.modal.rowIndex ?? 0)\nconst column = computed(() => store.columns[colIndex.value])\n\nconst uomOptions = computed(() => (column.value?.options as QuantityOptions | undefined)?.uoms ?? [])\nconst cellValue = computed(() => store.getCellData(colIndex.value, rowIndex.value) as QuantityValue | null | undefined)\nconst selectedUom = computed(() => cellValue.value?.uom ?? '')\n\nconst listboxId = computed(() => `atable-tuple-qty-${rowIndex.value}-${colIndex.value}`)\n\nconst optionCount = () => uomOptions.value.length\n\nconst closePicker = () => store.closeTuplePicker()\n\nconst selectUom = (uom: string) => {\n\tconst options = (column.value?.options ?? {}) as QuantityOptions\n\tstore.setCellData(colIndex.value, rowIndex.value, patchQuantityUom(cellValue.value, uom, options))\n\tclosePicker()\n}\n\nconst { activeIndex, onKeydown, onClickOutside, onFocusOut } = useTableModalDropdownList({\n\tpanelRef,\n\tisOpen: () => open.value,\n\toptionCount,\n\tselectAt: index => {\n\t\tconst uom = uomOptions.value[index]\n\t\tif (uom !== undefined) selectUom(uom)\n\t},\n\tonClose: closePicker,\n})\n</script>\n\n<style scoped>\n.atable-tuple-picker-modal {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 100%;\n\toutline: none;\n}\n</style>\n","<template>\n\t<div class=\"atable-tuple-shell\" :class=\"{ 'atable-tuple-shell--active': active }\">\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclass=\"atable-tuple-shell__handle\"\n\t\t\t:class=\"{ 'atable-tuple-shell__handle--visible': active }\"\n\t\t\ttabindex=\"-1\"\n\t\t\t:aria-label=\"pickerLabel\"\n\t\t\taria-haspopup=\"listbox\"\n\t\t\t:aria-expanded=\"pickerOpen\"\n\t\t\t:aria-hidden=\"!active\"\n\t\t\t@mousedown.prevent\n\t\t\t@click.stop=\"emit('open-picker')\">\n\t\t\t<span class=\"atable-tuple-shell__caret\" aria-hidden=\"true\" />\n\t\t</button>\n\t\t<span v-show=\"!active\" class=\"atable-tuple-shell__display\">{{ displayText }}</span>\n\t\t<slot v-if=\"active\" />\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{\n\tactive: boolean\n\tdisplayText: string\n\tpickerLabel: string\n\tpickerOpen: boolean\n}>()\n\nconst emit = defineEmits<{\n\t'open-picker': []\n}>()\n</script>\n\n<style scoped>\n.atable-tuple-shell {\n\tposition: relative;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\tmin-height: 1.25em;\n\tpadding-left: 0;\n}\n\n.atable-tuple-shell--active {\n\tbox-sizing: border-box;\n\tpadding-left: 1rem;\n}\n\n.atable-tuple-shell__handle {\n\tposition: absolute;\n\tleft: 0;\n\ttop: 0;\n\tbottom: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tbox-sizing: border-box;\n\twidth: 1rem;\n\tmin-width: 1rem;\n\tpadding: 0;\n\tmargin: 0;\n\tborder: none;\n\tbackground: transparent;\n\tcolor: var(--sc-cell-text-color);\n\tcursor: pointer;\n\topacity: 0;\n\tpointer-events: none;\n\ttransition: opacity 0.15s ease;\n\t-webkit-tap-highlight-color: transparent;\n}\n\n.atable-tuple-shell__handle--visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.atable-tuple-shell__caret {\n\tdisplay: inline-block;\n\twidth: 0;\n\theight: 0;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tborder-top: 0.3em solid currentColor;\n}\n\n.atable-tuple-shell__display {\n\tdisplay: block;\n\twidth: 100%;\n\tmin-width: 0;\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n</style>\n","<template>\n\t<div class=\"atable-tuple-shell\" :class=\"{ 'atable-tuple-shell--active': active }\">\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclass=\"atable-tuple-shell__handle\"\n\t\t\t:class=\"{ 'atable-tuple-shell__handle--visible': active }\"\n\t\t\ttabindex=\"-1\"\n\t\t\t:aria-label=\"pickerLabel\"\n\t\t\taria-haspopup=\"listbox\"\n\t\t\t:aria-expanded=\"pickerOpen\"\n\t\t\t:aria-hidden=\"!active\"\n\t\t\t@mousedown.prevent\n\t\t\t@click.stop=\"emit('open-picker')\">\n\t\t\t<span class=\"atable-tuple-shell__caret\" aria-hidden=\"true\" />\n\t\t</button>\n\t\t<span v-show=\"!active\" class=\"atable-tuple-shell__display\">{{ displayText }}</span>\n\t\t<slot v-if=\"active\" />\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{\n\tactive: boolean\n\tdisplayText: string\n\tpickerLabel: string\n\tpickerOpen: boolean\n}>()\n\nconst emit = defineEmits<{\n\t'open-picker': []\n}>()\n</script>\n\n<style scoped>\n.atable-tuple-shell {\n\tposition: relative;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\tmin-height: 1.25em;\n\tpadding-left: 0;\n}\n\n.atable-tuple-shell--active {\n\tbox-sizing: border-box;\n\tpadding-left: 1rem;\n}\n\n.atable-tuple-shell__handle {\n\tposition: absolute;\n\tleft: 0;\n\ttop: 0;\n\tbottom: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tbox-sizing: border-box;\n\twidth: 1rem;\n\tmin-width: 1rem;\n\tpadding: 0;\n\tmargin: 0;\n\tborder: none;\n\tbackground: transparent;\n\tcolor: var(--sc-cell-text-color);\n\tcursor: pointer;\n\topacity: 0;\n\tpointer-events: none;\n\ttransition: opacity 0.15s ease;\n\t-webkit-tap-highlight-color: transparent;\n}\n\n.atable-tuple-shell__handle--visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.atable-tuple-shell__caret {\n\tdisplay: inline-block;\n\twidth: 0;\n\theight: 0;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tborder-top: 0.3em solid currentColor;\n}\n\n.atable-tuple-shell__display {\n\tdisplay: block;\n\twidth: 100%;\n\tmin-width: 0;\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n</style>\n","<template>\n\t<ATupleCellShell\n\t\t:active=\"active\"\n\t\t:display-text=\"displayText\"\n\t\t:picker-label=\"pickerLabel\"\n\t\t:picker-open=\"pickerOpenForCell\"\n\t\t@open-picker=\"openPicker\">\n\t\t<input\n\t\t\tref=\"inputRef\"\n\t\t\t:id=\"inputId\"\n\t\t\tv-model=\"draftText\"\n\t\t\tclass=\"atable-tuple-shell__input\"\n\t\t\ttype=\"text\"\n\t\t\ttabindex=\"-1\"\n\t\t\tinputmode=\"decimal\"\n\t\t\t:aria-label=\"amountLabel\"\n\t\t\t@input=\"onInput\"\n\t\t\t@keydown=\"onKeydown\"\n\t\t\t@paste=\"onPaste\"\n\t\t\t@focus=\"onInputFocus\"\n\t\t\t@blur=\"onInputBlur\" />\n\t</ATupleCellShell>\n</template>\n\n<script setup lang=\"ts\">\nimport {\n\tcurrencyAmountEntryPattern,\n\tcurrencyInputFractionDigits,\n\tformatCurrencyAmountInput,\n\tparseCurrencyAmountInput,\n} from '@stonecrop/utilities'\nimport { isTableTuplePickerModal, type TableStore } from '@stonecrop/atable'\nimport { useElementBounding } from '@vueuse/core'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport type { CurrencyOptions, CurrencyValue, QuantityOptions, QuantityValue } from '../../types'\nimport { normalizeBaseCurrency, patchCurrencyAmount } from '../../utils/currencyValue'\nimport { patchQuantityQty, quantityEntryPattern } from '../../utils/quantityValue'\nimport ATupleCellShell from './ATupleCellShell.vue'\n\nconst { category, colIndex, rowIndex, store, active, displayText, inputId } = defineProps<{\n\tcategory: 'quantity' | 'currency'\n\tcolIndex: number\n\trowIndex: number\n\tstore: TableStore\n\tactive: boolean\n\tdisplayText: string\n\tinputId: string\n}>()\n\nconst emit = defineEmits<{\n\tdeactivate: []\n}>()\n\nconst inputRef = useTemplateRef<HTMLInputElement>('inputRef')\nconst draftText = ref('')\nconst selectOnFocus = ref(true)\n\nconst amountMaskEnabled = computed(\n\t() => category === 'currency' && (options.value as CurrencyOptions).amountMask !== false\n)\n\nconst column = computed(() => store.columns[colIndex])\nconst options = computed(() => column.value?.options ?? {})\nconst cellValue = computed(() => store.getCellData(colIndex, rowIndex))\n\nconst pickerLabel = computed(() => (category === 'currency' ? 'Choose currency' : 'Choose unit'))\nconst amountLabel = computed(() => (category === 'currency' ? 'Amount' : 'Quantity'))\n\nconst selectedCurrencyId = computed(() => String((cellValue.value as CurrencyValue | undefined)?.currency?.id ?? ''))\n\nconst cellElement = computed(() => {\n\tconst el = inputRef.value?.closest('td')\n\treturn el instanceof HTMLTableCellElement ? el : null\n})\nconst { left, bottom, width, height } = useElementBounding(cellElement)\n\nconst pickerOpenForCell = computed(\n\t() => isTableTuplePickerModal(store.modal) && store.modal.colIndex === colIndex && store.modal.rowIndex === rowIndex\n)\n\n// The picker holds focus while open, so the cell can't see focus leave. Once focus has settled after the picker closes:\n// if the page dropped it (a pick, Escape), bring it back to the box; if it went somewhere else, editing this cell is over.\nwatch(pickerOpenForCell, (open, wasOpen) => {\n\tif (!wasOpen || open) return\n\tsetTimeout(() => {\n\t\t// Reopened meanwhile, as a click on the handle does: the list has focus again.\n\t\tif (pickerOpenForCell.value) return\n\t\tconst focused = document.activeElement\n\t\tif (focused && cellElement.value?.contains(focused)) return\n\t\tif (!focused || focused === document.body) inputRef.value?.focus()\n\t\telse emit('deactivate')\n\t})\n})\n\nconst syncDraftFromModel = () => {\n\tconst v = cellValue.value\n\tif (category === 'quantity') {\n\t\tconst q = v as QuantityValue | null | undefined\n\t\tdraftText.value = q?.qty === null || q?.qty === undefined ? '' : String(q.qty)\n\t\treturn\n\t}\n\tconst c = v as CurrencyValue | null | undefined\n\tif (amountMaskEnabled.value) {\n\t\tdraftText.value = formatCurrencyAmountInput(c?.amount ?? null, selectedCurrencyId.value)\n\t\treturn\n\t}\n\tdraftText.value = c?.amount === null || c?.amount === undefined ? '' : String(c.amount)\n}\n\nwatch(\n\tcellValue,\n\t() => {\n\t\t// Not while the box is being typed in: the box holds text on its way to a number (\"1.\", \"-\"), and the number\n\t\t// read back from it would overwrite that text.\n\t\tif (document.activeElement !== inputRef.value) syncDraftFromModel()\n\t},\n\t{ deep: true }\n)\nwatch(\n\t() => active,\n\tisActive => {\n\t\tif (isActive) syncDraftFromModel()\n\t}\n)\n\nconst parseDraftAmount = (): number | null => {\n\tif (category === 'currency' && amountMaskEnabled.value) {\n\t\treturn parseCurrencyAmountInput(draftText.value)\n\t}\n\tconst text = draftText.value.trim()\n\tif (text === '' || text === '-') return null\n\tconst n = Number(text)\n\treturn Number.isFinite(n) ? n : null\n}\n\nconst commitNumber = () => {\n\tconst parsed = parseDraftAmount()\n\tif (category === 'quantity') {\n\t\tstore.setCellData(\n\t\t\tcolIndex,\n\t\t\trowIndex,\n\t\t\tpatchQuantityQty(cellValue.value as QuantityValue | null, parsed, options.value as QuantityOptions)\n\t\t)\n\t\treturn\n\t}\n\tconst base = normalizeBaseCurrency(options.value as CurrencyOptions, cellValue.value as CurrencyValue | null)\n\tstore.setCellData(\n\t\tcolIndex,\n\t\trowIndex,\n\t\tpatchCurrencyAmount(cellValue.value as CurrencyValue | null, parsed, options.value as CurrencyOptions, base)\n\t)\n}\n\nconst onInput = () => {\n\tif (category === 'currency' && amountMaskEnabled.value) {\n\t\tconst parsed = parseCurrencyAmountInput(draftText.value)\n\t\tif (draftText.value.trim() === '' || draftText.value.trim() === '-' || parsed !== null) {\n\t\t\tcommitNumber()\n\t\t}\n\t\treturn\n\t}\n\tcommitNumber()\n}\n\nconst shouldStayActiveAfterBlur = (related: EventTarget | null): boolean => {\n\tif (!(related instanceof Node)) return false\n\tif (document.querySelector('.amodal')?.contains(related)) return true\n\tif (pickerOpenForCell.value) return true\n\tconst cell = inputRef.value?.closest('td')\n\tif (!cell?.contains(related)) return false\n\tif (related instanceof Element && related.closest('.atable-tuple-shell__handle')) return true\n\tif (related === inputRef.value) return true\n\treturn false\n}\n\nconst onInputBlur = (event: FocusEvent) => {\n\tcommitNumber()\n\tif (category === 'currency' && amountMaskEnabled.value) syncDraftFromModel()\n\tif (!shouldStayActiveAfterBlur(event.relatedTarget)) emit('deactivate')\n}\n\nconst openPicker = () => {\n\tconst cell = cellElement.value\n\tif (!cell) return\n\tstore.openTuplePicker(colIndex, rowIndex, cell, {\n\t\tleft: left.value,\n\t\tbottom: bottom.value,\n\t\twidth: width.value,\n\t\theight: height.value,\n\t})\n}\n\nconst onKeydown = (event: KeyboardEvent) => {\n\tif (event.shiftKey && event.key === 'ArrowDown') {\n\t\tevent.preventDefault()\n\t\tevent.stopPropagation()\n\t\topenPicker()\n\t\treturn\n\t}\n\tif (category === 'currency' && amountMaskEnabled.value && !pickerOpenForCell.value) {\n\t\tif (onCurrencyKeydownMasked(event)) return\n\t}\n\tif (category === 'quantity' && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n\t\trefuseUnlessQuantity(event, event.key)\n\t}\n}\n\n// The box's text once `inserted` replaces its selection.\nconst textWith = (input: HTMLInputElement, inserted: string) =>\n\tinput.value.slice(0, input.selectionStart ?? 0) + inserted + input.value.slice(input.selectionEnd ?? 0)\n\n// The same text as the form's quantity field accepts, so a typo leaves the quantity as it was.\nconst refuseUnlessQuantity = (event: Event, inserted: string) => {\n\tif (!quantityEntryPattern.test(textWith(event.target as HTMLInputElement, inserted))) event.preventDefault()\n}\n\n// What the box may hold, as the form's field refuses anything else.\nconst entryPattern = computed(() => {\n\tif (category === 'quantity') return quantityEntryPattern\n\treturn amountMaskEnabled.value ? currencyAmountEntryPattern(selectedCurrencyId.value) : undefined\n})\n\n// A number copied from a spreadsheet cell comes with a line break or tab: what is pasted is the number without them.\nconst onPaste = (event: ClipboardEvent) => {\n\tconst pattern = entryPattern.value\n\tif (!pattern) return\n\tevent.preventDefault()\n\tconst input = event.target as HTMLInputElement\n\tconst pasted = (event.clipboardData?.getData('text') ?? '').trim()\n\tif (!pattern.test(textWith(input, pasted))) return\n\tinput.setRangeText(pasted, input.selectionStart ?? 0, input.selectionEnd ?? 0, 'end')\n\tinput.dispatchEvent(new Event('input', { bubbles: true }))\n}\n\nconst onCurrencyKeydownMasked = (event: KeyboardEvent): boolean => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return false\n\tconst navigation = new Set([\n\t\t'Backspace',\n\t\t'Delete',\n\t\t'Tab',\n\t\t'Escape',\n\t\t'Enter',\n\t\t'ArrowLeft',\n\t\t'ArrowRight',\n\t\t'ArrowUp',\n\t\t'ArrowDown',\n\t\t'Home',\n\t\t'End',\n\t])\n\tif (navigation.has(event.key)) return false\n\tif (/^[0-9]$/.test(event.key)) return false\n\tif (event.key === '-') {\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('-') && input.selectionStart === 0) return false\n\t}\n\tif (event.key === '.' || event.key === ',') {\n\t\tif (currencyInputFractionDigits(selectedCurrencyId.value) === 0) {\n\t\t\tevent.preventDefault()\n\t\t\treturn true\n\t\t}\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('.') && !input.value.includes(',')) return false\n\t}\n\tconst pattern = currencyAmountEntryPattern(selectedCurrencyId.value)\n\tconst input = event.target as HTMLInputElement\n\tconst { selectionStart, selectionEnd, value } = input\n\tif (selectionStart === null || selectionEnd === null) {\n\t\tevent.preventDefault()\n\t\treturn true\n\t}\n\tconst next = value.slice(0, selectionStart) + event.key + value.slice(selectionEnd)\n\tif (event.key.length === 1 && !pattern.test(next)) event.preventDefault()\n\treturn true\n}\n\nconst onInputFocus = () => {\n\tif (selectOnFocus.value) {\n\t\tvoid nextTick(() => {\n\t\t\tinputRef.value?.select()\n\t\t\tselectOnFocus.value = false\n\t\t})\n\t}\n}\n\nconst focusInput = () => {\n\tselectOnFocus.value = true\n\tvoid nextTick(() => inputRef.value?.focus())\n}\n\ndefineExpose({ focusInput, openPicker, commitNumber })\n</script>\n\n<style scoped>\n.atable-tuple-shell__input {\n\tdisplay: block;\n\twidth: 100%;\n\tmin-width: 0;\n\tbox-sizing: border-box;\n\tborder: none;\n\toutline: none;\n\tbox-shadow: none;\n\tbackground: transparent;\n\tfont: inherit;\n\tcolor: inherit;\n\ttext-align: inherit;\n\tpadding: 0;\n\tmargin: 0;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n\n.atable-tuple-shell__input::-webkit-outer-spin-button,\n.atable-tuple-shell__input::-webkit-inner-spin-button {\n\tappearance: none;\n}\n</style>\n","<template>\n\t<ATupleCellShell\n\t\t:active=\"active\"\n\t\t:display-text=\"displayText\"\n\t\t:picker-label=\"pickerLabel\"\n\t\t:picker-open=\"pickerOpenForCell\"\n\t\t@open-picker=\"openPicker\">\n\t\t<input\n\t\t\tref=\"inputRef\"\n\t\t\t:id=\"inputId\"\n\t\t\tv-model=\"draftText\"\n\t\t\tclass=\"atable-tuple-shell__input\"\n\t\t\ttype=\"text\"\n\t\t\ttabindex=\"-1\"\n\t\t\tinputmode=\"decimal\"\n\t\t\t:aria-label=\"amountLabel\"\n\t\t\t@input=\"onInput\"\n\t\t\t@keydown=\"onKeydown\"\n\t\t\t@paste=\"onPaste\"\n\t\t\t@focus=\"onInputFocus\"\n\t\t\t@blur=\"onInputBlur\" />\n\t</ATupleCellShell>\n</template>\n\n<script setup lang=\"ts\">\nimport {\n\tcurrencyAmountEntryPattern,\n\tcurrencyInputFractionDigits,\n\tformatCurrencyAmountInput,\n\tparseCurrencyAmountInput,\n} from '@stonecrop/utilities'\nimport { isTableTuplePickerModal, type TableStore } from '@stonecrop/atable'\nimport { useElementBounding } from '@vueuse/core'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport type { CurrencyOptions, CurrencyValue, QuantityOptions, QuantityValue } from '../../types'\nimport { normalizeBaseCurrency, patchCurrencyAmount } from '../../utils/currencyValue'\nimport { patchQuantityQty, quantityEntryPattern } from '../../utils/quantityValue'\nimport ATupleCellShell from './ATupleCellShell.vue'\n\nconst { category, colIndex, rowIndex, store, active, displayText, inputId } = defineProps<{\n\tcategory: 'quantity' | 'currency'\n\tcolIndex: number\n\trowIndex: number\n\tstore: TableStore\n\tactive: boolean\n\tdisplayText: string\n\tinputId: string\n}>()\n\nconst emit = defineEmits<{\n\tdeactivate: []\n}>()\n\nconst inputRef = useTemplateRef<HTMLInputElement>('inputRef')\nconst draftText = ref('')\nconst selectOnFocus = ref(true)\n\nconst amountMaskEnabled = computed(\n\t() => category === 'currency' && (options.value as CurrencyOptions).amountMask !== false\n)\n\nconst column = computed(() => store.columns[colIndex])\nconst options = computed(() => column.value?.options ?? {})\nconst cellValue = computed(() => store.getCellData(colIndex, rowIndex))\n\nconst pickerLabel = computed(() => (category === 'currency' ? 'Choose currency' : 'Choose unit'))\nconst amountLabel = computed(() => (category === 'currency' ? 'Amount' : 'Quantity'))\n\nconst selectedCurrencyId = computed(() => String((cellValue.value as CurrencyValue | undefined)?.currency?.id ?? ''))\n\nconst cellElement = computed(() => {\n\tconst el = inputRef.value?.closest('td')\n\treturn el instanceof HTMLTableCellElement ? el : null\n})\nconst { left, bottom, width, height } = useElementBounding(cellElement)\n\nconst pickerOpenForCell = computed(\n\t() => isTableTuplePickerModal(store.modal) && store.modal.colIndex === colIndex && store.modal.rowIndex === rowIndex\n)\n\n// The picker holds focus while open, so the cell can't see focus leave. Once focus has settled after the picker closes:\n// if the page dropped it (a pick, Escape), bring it back to the box; if it went somewhere else, editing this cell is over.\nwatch(pickerOpenForCell, (open, wasOpen) => {\n\tif (!wasOpen || open) return\n\tsetTimeout(() => {\n\t\t// Reopened meanwhile, as a click on the handle does: the list has focus again.\n\t\tif (pickerOpenForCell.value) return\n\t\tconst focused = document.activeElement\n\t\tif (focused && cellElement.value?.contains(focused)) return\n\t\tif (!focused || focused === document.body) inputRef.value?.focus()\n\t\telse emit('deactivate')\n\t})\n})\n\nconst syncDraftFromModel = () => {\n\tconst v = cellValue.value\n\tif (category === 'quantity') {\n\t\tconst q = v as QuantityValue | null | undefined\n\t\tdraftText.value = q?.qty === null || q?.qty === undefined ? '' : String(q.qty)\n\t\treturn\n\t}\n\tconst c = v as CurrencyValue | null | undefined\n\tif (amountMaskEnabled.value) {\n\t\tdraftText.value = formatCurrencyAmountInput(c?.amount ?? null, selectedCurrencyId.value)\n\t\treturn\n\t}\n\tdraftText.value = c?.amount === null || c?.amount === undefined ? '' : String(c.amount)\n}\n\nwatch(\n\tcellValue,\n\t() => {\n\t\t// Not while the box is being typed in: the box holds text on its way to a number (\"1.\", \"-\"), and the number\n\t\t// read back from it would overwrite that text.\n\t\tif (document.activeElement !== inputRef.value) syncDraftFromModel()\n\t},\n\t{ deep: true }\n)\nwatch(\n\t() => active,\n\tisActive => {\n\t\tif (isActive) syncDraftFromModel()\n\t}\n)\n\nconst parseDraftAmount = (): number | null => {\n\tif (category === 'currency' && amountMaskEnabled.value) {\n\t\treturn parseCurrencyAmountInput(draftText.value)\n\t}\n\tconst text = draftText.value.trim()\n\tif (text === '' || text === '-') return null\n\tconst n = Number(text)\n\treturn Number.isFinite(n) ? n : null\n}\n\nconst commitNumber = () => {\n\tconst parsed = parseDraftAmount()\n\tif (category === 'quantity') {\n\t\tstore.setCellData(\n\t\t\tcolIndex,\n\t\t\trowIndex,\n\t\t\tpatchQuantityQty(cellValue.value as QuantityValue | null, parsed, options.value as QuantityOptions)\n\t\t)\n\t\treturn\n\t}\n\tconst base = normalizeBaseCurrency(options.value as CurrencyOptions, cellValue.value as CurrencyValue | null)\n\tstore.setCellData(\n\t\tcolIndex,\n\t\trowIndex,\n\t\tpatchCurrencyAmount(cellValue.value as CurrencyValue | null, parsed, options.value as CurrencyOptions, base)\n\t)\n}\n\nconst onInput = () => {\n\tif (category === 'currency' && amountMaskEnabled.value) {\n\t\tconst parsed = parseCurrencyAmountInput(draftText.value)\n\t\tif (draftText.value.trim() === '' || draftText.value.trim() === '-' || parsed !== null) {\n\t\t\tcommitNumber()\n\t\t}\n\t\treturn\n\t}\n\tcommitNumber()\n}\n\nconst shouldStayActiveAfterBlur = (related: EventTarget | null): boolean => {\n\tif (!(related instanceof Node)) return false\n\tif (document.querySelector('.amodal')?.contains(related)) return true\n\tif (pickerOpenForCell.value) return true\n\tconst cell = inputRef.value?.closest('td')\n\tif (!cell?.contains(related)) return false\n\tif (related instanceof Element && related.closest('.atable-tuple-shell__handle')) return true\n\tif (related === inputRef.value) return true\n\treturn false\n}\n\nconst onInputBlur = (event: FocusEvent) => {\n\tcommitNumber()\n\tif (category === 'currency' && amountMaskEnabled.value) syncDraftFromModel()\n\tif (!shouldStayActiveAfterBlur(event.relatedTarget)) emit('deactivate')\n}\n\nconst openPicker = () => {\n\tconst cell = cellElement.value\n\tif (!cell) return\n\tstore.openTuplePicker(colIndex, rowIndex, cell, {\n\t\tleft: left.value,\n\t\tbottom: bottom.value,\n\t\twidth: width.value,\n\t\theight: height.value,\n\t})\n}\n\nconst onKeydown = (event: KeyboardEvent) => {\n\tif (event.shiftKey && event.key === 'ArrowDown') {\n\t\tevent.preventDefault()\n\t\tevent.stopPropagation()\n\t\topenPicker()\n\t\treturn\n\t}\n\tif (category === 'currency' && amountMaskEnabled.value && !pickerOpenForCell.value) {\n\t\tif (onCurrencyKeydownMasked(event)) return\n\t}\n\tif (category === 'quantity' && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n\t\trefuseUnlessQuantity(event, event.key)\n\t}\n}\n\n// The box's text once `inserted` replaces its selection.\nconst textWith = (input: HTMLInputElement, inserted: string) =>\n\tinput.value.slice(0, input.selectionStart ?? 0) + inserted + input.value.slice(input.selectionEnd ?? 0)\n\n// The same text as the form's quantity field accepts, so a typo leaves the quantity as it was.\nconst refuseUnlessQuantity = (event: Event, inserted: string) => {\n\tif (!quantityEntryPattern.test(textWith(event.target as HTMLInputElement, inserted))) event.preventDefault()\n}\n\n// What the box may hold, as the form's field refuses anything else.\nconst entryPattern = computed(() => {\n\tif (category === 'quantity') return quantityEntryPattern\n\treturn amountMaskEnabled.value ? currencyAmountEntryPattern(selectedCurrencyId.value) : undefined\n})\n\n// A number copied from a spreadsheet cell comes with a line break or tab: what is pasted is the number without them.\nconst onPaste = (event: ClipboardEvent) => {\n\tconst pattern = entryPattern.value\n\tif (!pattern) return\n\tevent.preventDefault()\n\tconst input = event.target as HTMLInputElement\n\tconst pasted = (event.clipboardData?.getData('text') ?? '').trim()\n\tif (!pattern.test(textWith(input, pasted))) return\n\tinput.setRangeText(pasted, input.selectionStart ?? 0, input.selectionEnd ?? 0, 'end')\n\tinput.dispatchEvent(new Event('input', { bubbles: true }))\n}\n\nconst onCurrencyKeydownMasked = (event: KeyboardEvent): boolean => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return false\n\tconst navigation = new Set([\n\t\t'Backspace',\n\t\t'Delete',\n\t\t'Tab',\n\t\t'Escape',\n\t\t'Enter',\n\t\t'ArrowLeft',\n\t\t'ArrowRight',\n\t\t'ArrowUp',\n\t\t'ArrowDown',\n\t\t'Home',\n\t\t'End',\n\t])\n\tif (navigation.has(event.key)) return false\n\tif (/^[0-9]$/.test(event.key)) return false\n\tif (event.key === '-') {\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('-') && input.selectionStart === 0) return false\n\t}\n\tif (event.key === '.' || event.key === ',') {\n\t\tif (currencyInputFractionDigits(selectedCurrencyId.value) === 0) {\n\t\t\tevent.preventDefault()\n\t\t\treturn true\n\t\t}\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('.') && !input.value.includes(',')) return false\n\t}\n\tconst pattern = currencyAmountEntryPattern(selectedCurrencyId.value)\n\tconst input = event.target as HTMLInputElement\n\tconst { selectionStart, selectionEnd, value } = input\n\tif (selectionStart === null || selectionEnd === null) {\n\t\tevent.preventDefault()\n\t\treturn true\n\t}\n\tconst next = value.slice(0, selectionStart) + event.key + value.slice(selectionEnd)\n\tif (event.key.length === 1 && !pattern.test(next)) event.preventDefault()\n\treturn true\n}\n\nconst onInputFocus = () => {\n\tif (selectOnFocus.value) {\n\t\tvoid nextTick(() => {\n\t\t\tinputRef.value?.select()\n\t\t\tselectOnFocus.value = false\n\t\t})\n\t}\n}\n\nconst focusInput = () => {\n\tselectOnFocus.value = true\n\tvoid nextTick(() => inputRef.value?.focus())\n}\n\ndefineExpose({ focusInput, openPicker, commitNumber })\n</script>\n\n<style scoped>\n.atable-tuple-shell__input {\n\tdisplay: block;\n\twidth: 100%;\n\tmin-width: 0;\n\tbox-sizing: border-box;\n\tborder: none;\n\toutline: none;\n\tbox-shadow: none;\n\tbackground: transparent;\n\tfont: inherit;\n\tcolor: inherit;\n\ttext-align: inherit;\n\tpadding: 0;\n\tmargin: 0;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n\n.atable-tuple-shell__input::-webkit-outer-spin-button,\n.atable-tuple-shell__input::-webkit-inner-spin-button {\n\tappearance: none;\n}\n</style>\n","export type * from '@stonecrop/atable/types'\nexport { deserializeFunction } from './utils/deserialize'\nexport { badgeInputAccentStyle, resolveFieldBadge } from './utils/badge'\nexport { resolvedFieldsToColumns } from './utils/columns'\nexport type { BadgeFormatContext, BadgeFormatFn } from './utils/badge'\nimport { install as installATable } from '@stonecrop/atable'\nimport type { App } from 'vue'\n\nimport ACheckbox from './components/form/ACheckbox.vue'\nimport ACurrencyInput from './components/form/ACurrencyInput.vue'\nimport ADate from './components/form/ADate.vue'\nimport ADropdown from './components/form/ADropdown.vue'\nimport ASegmentedControl from './components/form/ASegmentedControl.vue'\nimport ABadge from './components/form/ABadge.vue'\nimport ADatePicker from './components/form/ADatePicker.vue'\nimport ADateTime from './components/form/ADateTime.vue'\nimport ADateTimeInput from './components/form/ADateTimeInput.vue'\nimport ADateSelection from './components/form/ADateSelection.vue'\nimport ADuration from './components/form/ADuration.vue'\nimport ADateRange from './components/form/ADateRange.vue'\nimport AFieldset from './components/form/AFieldset.vue'\nimport AFileAttach from './components/form/AFileAttach.vue'\nimport AForm from './components/AForm.vue'\nimport AFormLink from './components/form/AFormLink.vue'\nimport ANumericInput from './components/form/ANumericInput.vue'\nimport AQuantityInput from './components/form/AQuantityInput.vue'\nimport ASemverInput from './components/form/ASemverInput.vue'\nimport ATextInput from './components/form/ATextInput.vue'\nimport ATextboxInput from './components/form/ATextboxInput.vue'\nimport Login from './components/utilities/Login.vue'\nimport AFormLoading from './components/AFormLoading.vue'\nimport ExpandButton from './components/base/ExpandButton.vue'\nimport ATableTupleCurrencyPicker from './components/table/ATableTupleCurrencyPicker.vue'\nimport ATableTupleQuantityPicker from './components/table/ATableTupleQuantityPicker.vue'\nimport ATupleCellEditor from './components/table/ATupleCellEditor.vue'\nimport ATupleCellShell from './components/table/ATupleCellShell.vue'\n\nexport type * from './types'\n\n/**\n * Install all AForm components\n * @param app - Vue app instance\n * @public\n */\nfunction install(app: App /* options */) {\n\tapp.use(installATable) // Install ATable components for use within AForm\n\n\tapp.component('ACheckbox', ACheckbox)\n\tapp.component('ACurrencyInput', ACurrencyInput)\n\tapp.component('ADate', ADate)\n\tapp.component('ADropdown', ADropdown)\n\tapp.component('ASegmentedControl', ASegmentedControl)\n\tapp.component('ABadge', ABadge)\n\tapp.component('ADatePicker', ADatePicker)\n\tapp.component('ADateTime', ADateTime)\n\tapp.component('ADateTimeInput', ADateTimeInput)\n\tapp.component('ADateRange', ADateRange)\n\tapp.component('ADateSelection', ADateSelection)\n\tapp.component('AFieldset', AFieldset)\n\tapp.component('AFileAttach', AFileAttach)\n\tapp.component('AForm', AForm)\n\tapp.component('AFormLink', AFormLink)\n\tapp.component('ANumericInput', ANumericInput)\n\tapp.component('AQuantityInput', AQuantityInput)\n\tapp.component('ASemverInput', ASemverInput)\n\tapp.component('ATextInput', ATextInput)\n\tapp.component('ATextboxInput', ATextboxInput)\n\tapp.component('ADuration', ADuration)\n\tapp.component('AFormLoading', AFormLoading)\n\tapp.component('ExpandButton', ExpandButton)\n\tapp.component('ATableTupleQuantityPicker', ATableTupleQuantityPicker)\n\tapp.component('ATableTupleCurrencyPicker', ATableTupleCurrencyPicker)\n\tapp.component('ATupleCellEditor', ATupleCellEditor)\n\tapp.component('ATupleCellShell', ATupleCellShell)\n}\n\nexport {\n\tACheckbox,\n\tACurrencyInput,\n\tADate,\n\tADropdown,\n\tASegmentedControl,\n\tABadge,\n\tADatePicker,\n\tADateRange,\n\tADateSelection,\n\tADuration,\n\tADateTime,\n\tADateTimeInput,\n\tAFieldset,\n\tAFileAttach,\n\tAForm,\n\tAFormLink,\n\tANumericInput,\n\tAQuantityInput,\n\tASemverInput,\n\tATextInput,\n\tATextboxInput,\n\tLogin,\n\tAFormLoading,\n\tExpandButton,\n\tATableTupleQuantityPicker,\n\tATableTupleCurrencyPicker,\n\tATupleCellEditor,\n\tATupleCellShell,\n\tinstall,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAgB,oBAAuD,QAAmB;CAEzF,OAAO,SAAS,yBAAyB,OAAO,EAAE,CAAC,CAAC;AACrD;;;;;;;ACKA,SAAgB,kBACf,OACA,SACA,QACA,UAA8B,CAAC,GACD;CAC9B,IAAI,QAAQ;EACX,IAAI;EACJ,IAAI,OAAO,WAAW,YACrB,YAAY,OAAO,OAAO,OAAO;OAGjC,YADiB,oBAAmC,MACxC,CAAA,CAAS,OAAO,OAAO;EAEpC,IAAI,kBAAkB,SAAS,GAE9B,OADc,UAAU,MAAM,KACvB,IAAQ,YAAY,KAAA;EAE5B,IAAI,OAAO,cAAc,YAAY,cAAc,IAClD,OAAO,YAAY,SAAS,SAAS,KAAK;GAAE,OAAO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AI,IAAI,SAAa;CAErB,IAAI,UAAU,aAAa,iBAAS;CACpC,IAAI,UAAU,kBAAkB,sBAAc;CAC9C,IAAI,UAAU,SAAS,aAAK;CAC5B,IAAI,UAAU,aAAa,iBAAS;CACpC,IAAI,UAAU,qBAAqB,yBAAiB;CACpD,IAAI,UAAU,UAAU,cAAM;CAC9B,IAAI,UAAU,eAAe,mBAAW;CACxC,IAAI,UAAU,aAAa,iBAAS;CACpC,IAAI,UAAU,kBAAkB,sBAAc;CAC9C,IAAI,UAAU,cAAc,kBAAU;CACtC,IAAI,UAAU,kBAAkB,sBAAc;CAC9C,IAAI,UAAU,aAAa,iBAAS;CACpC,IAAI,UAAU,eAAe,mBAAW;CACxC,IAAI,UAAU,SAAS,aAAK;CAC5B,IAAI,UAAU,aAAa,iBAAS;CACpC,IAAI,UAAU,iBAAiB,qBAAa;CAC5C,IAAI,UAAU,kBAAkB,sBAAc;CAC9C,IAAI,UAAU,gBAAgB,oBAAY;CAC1C,IAAI,UAAU,cAAc,kBAAU;CACtC,IAAI,UAAU,iBAAiB,qBAAa;CAC5C,IAAI,UAAU,aAAa,iBAAS;CACpC,IAAI,UAAU,gBAAgB,oBAAY;CAC1C,IAAI,UAAU,gBAAgB,oBAAY;CAC1C,IAAI,UAAU,6BAA6B,iCAAyB;CACpE,IAAI,UAAU,6BAA6B,iCAAyB;CACpE,IAAI,UAAU,oBAAoB,wBAAgB;CAClD,IAAI,UAAU,mBAAmB,uBAAe;AACjD"}
|
|
1
|
+
{"version":3,"file":"aform.js","names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_withDirectives","_unref","_vModelCheckbox","_vShow","_sfc_main","_hoisted_1","_withDirectives","_openBlock","_createElementBlock","_normalizeClass","_renderSlot","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_useModel","_openBlock","_createElementBlock","_normalizeClass","_Fragment","_normalizeStyle","_toDisplayString","_createCommentVNode","_withDirectives","_withKeys","_withModifiers","_createElementVNode","_unref","_vModelText","_createVNode","ADropdownList","_withCtx","_renderList","_renderSlot","_createTextVNode","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_createVNode","ADropdown","_unref","_withCtx","_createTextVNode","_withDirectives","_vModelText","_createCommentVNode","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_createCommentVNode","_withDirectives","_unref","_vShow","_renderList","_normalizeClass","_withModifiers","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_openBlock","_createElementBlock","_createElementVNode","_withDirectives","_withKeys","_withModifiers","_vModelText","_createCommentVNode","_vModelSelect","_sfc_main","_hoisted_1","_hoisted_2","_openBlock","_createElementBlock","_createBlock","ADatePicker","_createCommentVNode","ADateTimeInput","_Fragment","_createElementVNode","_createVNode","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_useModel","_openBlock","_createElementBlock","_unref","_Fragment","_createElementVNode","_toDisplayString","_withDirectives","_withModifiers","_vModelText","_vShow","_createBlock","ADateSelection","_createCommentVNode","_sfc_main","_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_toDisplayString","_createCommentVNode","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_useModel","_openBlock","_createElementBlock","_normalizeClass","_Fragment","_createElementVNode","_toDisplayString","_createBlock","ABadge","_unref","_renderList","_normalizeStyle","_withDirectives","_vModelCheckbox","_vModelRadio","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_useModel","_openBlock","_createElementBlock","_unref","_Fragment","_createElementVNode","_toDisplayString","_withDirectives","_vShow","_createBlock","ADateSelection","_createCommentVNode","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_createVNode","ADateSelection","_createCommentVNode","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_useModel","_openBlock","_createElementBlock","_unref","_Fragment","_createElementVNode","_toDisplayString","_withDirectives","_vShow","_createBlock","ADateSelection","_createCommentVNode","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_useModel","_resolveComponent","_openBlock","_createElementBlock","_Fragment","_renderList","_toDisplayString","_createCommentVNode","_createBlock","_resolveDynamicComponent","_mergeProps","_createSlots","_withCtx","_createVNode","_sfc_main","_openBlock","_createElementBlock","_normalizeClass","_sfc_main","_useModel","_openBlock","_createElementBlock","_createTextVNode","_toDisplayString","_createBlock","CollapseButton","_createCommentVNode","_renderSlot","_withDirectives","_createVNode","AForm","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_openBlock","_createElementBlock","_Fragment","_unref","_createElementVNode","_toDisplayString","_renderList","_createTextVNode","_createCommentVNode","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_useModel","_openBlock","_createElementBlock","_normalizeClass","_Fragment","_createElementVNode","_toDisplayString","_createCommentVNode","_withDirectives","_withKeys","_withModifiers","_vModelText","_createBlock","ADropdownList","_withCtx","_renderList","_renderSlot","_createTextVNode","_unref","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_withDirectives","_unref","_vModelText","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_withDirectives","_unref","_vModelText","_createVNode","ADropdown","_createCommentVNode","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_unref","_withDirectives","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_withDirectives","_unref","_vModelText","vMask","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_useModel","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_withDirectives","_unref","_vModelText","_vShow","_sfc_main","_hoisted_1","_hoisted_2","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_withDirectives","_vModelText","_createCommentVNode","_sfc_main","_hoisted_1","_hoisted_2","_openBlock","_createElementBlock","_createElementVNode","_renderSlot","_hoisted_1","_openBlock","_createElementBlock","_toDisplayString","_sfc_main","_hoisted_1","_withDirectives","_openBlock","_createElementBlock","_unref","_createVNode","ADropdownList","_withCtx","_Fragment","_renderList","_normalizeClass","_withModifiers","_toDisplayString","_createCommentVNode","_sfc_main","_hoisted_1","_withDirectives","_openBlock","_createElementBlock","_unref","_createVNode","ADropdownList","_withCtx","_Fragment","_renderList","_normalizeClass","_withModifiers","_toDisplayString","_createCommentVNode","_sfc_main","_hoisted_1","_openBlock","_createElementBlock","_normalizeClass","_createElementVNode","_withModifiers","_withDirectives","_toDisplayString","_vShow","_renderSlot","_createCommentVNode","_sfc_main","_openBlock","_createBlock","ATupleCellShell","_withCtx","_withDirectives","_createElementVNode","_vModelText","_sfc_main","installATable","ACheckbox","ACurrencyInput","ADate","ADropdown","ASegmentedControl","ABadge","ADatePicker","ADateTime","ADateTimeInput","ADateRange","ADateSelection","AFieldset","AFileAttach","AForm","AFormLink","ANumericInput","AQuantityInput","ASemverInput","ATextInput","ATextboxInput","ADuration","AFormLoading","ExpandButton","ATableTupleQuantityPicker","ATableTupleCurrencyPicker","ATupleCellEditor","ATupleCellShell"],"sources":["../src/utils/deserialize.ts","../src/utils/badge.ts","../src/utils/columns.ts","../src/composables/fieldErrorA11y.ts","../src/components/form/ACheckbox.vue","../src/components/form/ACheckbox.vue","../src/utils/linkValue.ts","../src/utils/currencyValue.ts","../src/utils/emptiedBox.ts","../src/utils/recordNumber.ts","../src/composables/dropdownList.ts","../src/components/form/ADropdownList.vue","../src/components/form/ADropdownList.vue","../src/components/form/ADropdown.vue","../src/components/form/ADropdown.vue","../src/components/form/ACurrencyInput.vue","../src/components/form/ACurrencyInput.vue","../src/utils/typedDay.ts","../src/components/form/ADatePicker.vue","../src/components/form/ADatePicker.vue","../src/components/form/ADateTimeInput.vue","../src/components/form/ADateTimeInput.vue","../src/components/form/ADateSelection.vue","../src/components/form/ADateSelection.vue","../src/utils/fieldCalendar.ts","../src/components/form/ADate.vue","../src/components/form/ADate.vue","../src/components/form/ABadge.vue","../src/components/form/ABadge.vue","../src/components/form/ASegmentedControl.vue","../src/components/form/ASegmentedControl.vue","../src/components/form/ADateTime.vue","../src/components/form/ADateTime.vue","../src/components/form/ADuration.vue","../src/components/form/ADuration.vue","../src/components/form/ADateRange.vue","../src/components/form/ADateRange.vue","../src/components/AForm.vue","../src/components/AForm.vue","../src/components/base/CollapseButton.vue","../src/components/base/CollapseButton.vue","../src/components/form/AFieldset.vue","../src/components/form/AFieldset.vue","../src/components/form/AFileAttach.vue","../src/components/form/AFileAttach.vue","../src/components/form/AFormLink.vue","../src/components/form/AFormLink.vue","../src/components/form/ANumericInput.vue","../src/components/form/ANumericInput.vue","../src/utils/quantityValue.ts","../src/components/form/AQuantityInput.vue","../src/components/form/AQuantityInput.vue","../src/components/form/ASemverInput.vue","../src/components/form/ASemverInput.vue","../src/directives/mask.ts","../src/components/form/ATextInput.vue","../src/components/form/ATextInput.vue","../src/components/form/ATextboxInput.vue","../src/components/form/ATextboxInput.vue","../src/components/utilities/Login.vue","../src/components/utilities/Login.vue","../src/components/AFormLoading.vue","../src/components/base/ExpandButton.vue","../src/components/base/ExpandButton.vue","../src/composables/useTableModalDropdownList.ts","../src/components/table/ATableTupleCurrencyPicker.vue","../src/components/table/ATableTupleCurrencyPicker.vue","../src/components/table/ATableTupleQuantityPicker.vue","../src/components/table/ATableTupleQuantityPicker.vue","../src/components/table/ATupleCellShell.vue","../src/components/table/ATupleCellShell.vue","../src/components/table/ATupleCellEditor.vue","../src/components/table/ATupleCellEditor.vue","../src/index.ts"],"sourcesContent":["/**\n * Deserializes a stringified function expression into a typed callable.\n *\n * Throws if the string cannot be parsed as a function (SyntaxError) or if the\n * resulting expression is not callable (TypeError), or if the expression references\n * an undefined variable (ReferenceError). Callers are responsible for try/catch.\n *\n * @example\n * ```ts\n * const fn = deserializeFunction<(x: number) => number>('(x) => x * 2')\n * fn(5) // 10\n * ```\n * @public\n */\n// T is intentionally a caller-supplied return type — this utility is unsafe by design (Function constructor).\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters\nexport function deserializeFunction<T extends (...args: any[]) => any>(source: string): T {\n\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion, typescript/no-implied-eval\n\treturn Function(`\"use strict\"; return (${source})`)() as T\n}\n","import type { BadgeDescriptor, FieldOptions } from '@stonecrop/schema'\nimport { isBadgeDescriptor, lookupBadge } from '@stonecrop/schema'\n\nimport { deserializeFunction } from './deserialize'\n\n/**\n * Row context passed to badge `format` functions in form fields.\n * @public\n */\nexport type BadgeFormatContext = {\n\trecord?: Record<string, unknown>\n\trow?: Record<string, unknown>\n}\n\n/**\n * Badge-aware field `format` function signature.\n * @public\n */\nexport type BadgeFormatFn = (value: unknown, context: BadgeFormatContext) => string | BadgeDescriptor\n\n/**\n * Resolve a field value to a badge descriptor using format (if present) then options map.\n * @public\n */\nexport function resolveFieldBadge(\n\tvalue: unknown,\n\toptions: FieldOptions | undefined,\n\tformat: string | BadgeFormatFn | undefined,\n\tcontext: BadgeFormatContext = {}\n): BadgeDescriptor | undefined {\n\tif (format) {\n\t\tlet formatted: unknown\n\t\tif (typeof format === 'function') {\n\t\t\tformatted = format(value, context)\n\t\t} else {\n\t\t\tconst formatFn = deserializeFunction<BadgeFormatFn>(format)\n\t\t\tformatted = formatFn(value, context)\n\t\t}\n\t\tif (isBadgeDescriptor(formatted)) {\n\t\t\tconst label = formatted.label.trim()\n\t\t\treturn label ? formatted : undefined\n\t\t}\n\t\tif (typeof formatted === 'string' && formatted !== '') {\n\t\t\treturn lookupBadge(options, formatted) ?? { label: formatted, variant: 'neutral' }\n\t\t}\n\t}\n\n\tconst key = badgeLookupKey(value)\n\tif (key === undefined) return undefined\n\treturn lookupBadge(options, key)\n}\n\n/**\n * Stored choice value as an options-map key. Only primitives can match a declared choice, so\n * anything else yields undefined rather than the '[object Object]' that String() would produce.\n */\nfunction badgeLookupKey(value: unknown): string | undefined {\n\tswitch (typeof value) {\n\t\tcase 'string':\n\t\t\treturn value === '' ? undefined : value\n\t\tcase 'number':\n\t\tcase 'boolean':\n\t\tcase 'bigint':\n\t\t\treturn String(value)\n\t\tdefault:\n\t\t\treturn undefined\n\t}\n}\n\nconst BADGE_VARIANTS = new Set<string>(['neutral', 'success', 'warning', 'danger', 'brand'])\n\n/**\n * CSS custom properties for input-accent styling on a native input.\n * @public\n */\nexport function badgeInputAccentStyle(descriptor: BadgeDescriptor | undefined): Record<string, string> | undefined {\n\tif (!descriptor?.label?.trim()) return undefined\n\tconst variant = descriptor.variant ?? 'neutral'\n\tif (descriptor.color) {\n\t\treturn {\n\t\t\tborderLeftWidth: '4px',\n\t\t\tborderLeftStyle: 'solid',\n\t\t\tborderLeftColor: descriptor.color,\n\t\t\tpaddingLeft: 'calc(1ch - 4px)',\n\t\t}\n\t}\n\tif (!BADGE_VARIANTS.has(variant)) return undefined\n\treturn {\n\t\tborderLeftWidth: '4px',\n\t\tborderLeftStyle: 'solid',\n\t\tborderLeftColor: `var(--sc-badge-${variant}-accent)`,\n\t\tpaddingLeft: 'calc(1ch - 4px)',\n\t}\n}\n","import type { ColumnSchema } from '@stonecrop/schema'\n\nimport type { ResolvedField } from '../types'\n\n/**\n * The resolved fields that can be columns in a list or table view, in declaration order.\n *\n * A cell renders one value, so only `kind: 'field'` qualifies. The other three kinds are\n * containers: a `fieldset` groups fields for layout and has no value of its own, while a `link`\n * and a `table` hold a nested record and an array of them. Neither has a `cellComponent`, so a\n * container reaching `ACell` falls through to plain-text rendering and stringifies its children —\n * no error and no log, just a wrong column.\n *\n * A fieldset's *children* are real columns, so it is flattened rather than dropped; losing them is\n * the same silent defect in the other direction.\n *\n * This is the one definition, for a child table's columns and a records list alike. Call it; never\n * re-derive it at a call site, which produced exactly one of the two failures above at each.\n *\n * @param fields - resolved fields, as produced by `resolveSchema`\n * @returns column definitions, with the `kind` discriminator stripped\n * @public\n */\nexport function resolvedFieldsToColumns(fields: readonly ResolvedField[]): ColumnSchema[] {\n\tconst columns: ColumnSchema[] = []\n\n\tfor (const field of fields) {\n\t\tif (field.kind === 'fieldset') {\n\t\t\tcolumns.push(...resolvedFieldsToColumns(field.schema))\n\t\t} else if (field.kind === 'field') {\n\t\t\tconst { kind: _kind, ...column } = field\n\t\t\tcolumns.push(column)\n\t\t}\n\t}\n\n\treturn columns\n}\n","import { computed, type ComputedRef } from 'vue'\n\nexport function fieldErrorA11y(\n\tuuid: string | undefined,\n\terrorText: ComputedRef<string>,\n\textraDescribedBy?: ComputedRef<string | undefined>\n) {\n\tconst errorId = computed(() => (uuid ? `${uuid}-error` : undefined))\n\tconst hasError = computed(() => Boolean(errorText.value))\n\tconst describedBy = computed(() => {\n\t\tif (hasError.value && errorId.value) return errorId.value\n\t\treturn extraDescribedBy?.value\n\t})\n\tconst invalid = computed(() => (hasError.value ? true : undefined))\n\n\treturn { errorId, hasError, describedBy, invalid }\n}\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t\t<span class=\"aform_display-value\">{{ checkbox ? '✓' : '✗' }}</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<span class=\"aform_checkbox-container aform_input-field\">\n\t\t\t\t<input\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\tv-model=\"checkbox\"\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclass=\"aform_checkbox\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t</span>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, InputHTMLAttributes } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst checkbox = defineModel<InputHTMLAttributes['checked']>()\n</script>\n\n<style scoped>\n.aform_checkbox {\n\tcursor: pointer;\n\twidth: auto;\n\tmargin-top: 0;\n\tdisplay: block;\n}\n\n.aform_checkbox:checked {\n\taccent-color: var(--sc-primary-color);\n\tborder: 1px solid var(--sc-input-active-border-color);\n}\n\n.aform_checkbox-container {\n\twidth: 100%;\n\tdisplay: inline-block;\n\ttext-align: left;\n}\n\n.aform_checkbox-container input {\n\twidth: auto;\n}\n\n.aform_form-element:has(> .aform_checkbox-container:hover) > .aform_field-label {\n\tcolor: var(--sc-input-active-label-color);\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t\t<span class=\"aform_display-value\">{{ checkbox ? '✓' : '✗' }}</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<span class=\"aform_checkbox-container aform_input-field\">\n\t\t\t\t<input\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\tv-model=\"checkbox\"\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclass=\"aform_checkbox\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t</span>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, InputHTMLAttributes } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst checkbox = defineModel<InputHTMLAttributes['checked']>()\n</script>\n\n<style scoped>\n.aform_checkbox {\n\tcursor: pointer;\n\twidth: auto;\n\tmargin-top: 0;\n\tdisplay: block;\n}\n\n.aform_checkbox:checked {\n\taccent-color: var(--sc-primary-color);\n\tborder: 1px solid var(--sc-input-active-border-color);\n}\n\n.aform_checkbox-container {\n\twidth: 100%;\n\tdisplay: inline-block;\n\ttext-align: left;\n}\n\n.aform_checkbox-container input {\n\twidth: auto;\n}\n\n.aform_form-element:has(> .aform_checkbox-container:hover) > .aform_field-label {\n\tcolor: var(--sc-input-active-label-color);\n}\n</style>\n","import type { AFormLinkModelValue, AFormLinkValue } from '../types'\n\nexport function linkId(value: AFormLinkModelValue | null | undefined): string | undefined {\n\tif (value == null) return undefined\n\tif (typeof value === 'string') return value === '' ? undefined : value\n\tif (typeof value === 'number') return String(value)\n\tconst id = value.id\n\tif (id === null || id === undefined || id === '') return undefined\n\treturn String(id)\n}\n\nexport function linkDisplayText(value: AFormLinkModelValue | null | undefined): string | undefined {\n\tif (value == null || typeof value !== 'object') return undefined\n\tconst text = value.displayText\n\tif (typeof text === 'string') return text\n\tif (typeof text === 'number') return String(text)\n\treturn undefined\n}\n\nexport function asLinkValue(value: AFormLinkModelValue | null | undefined): AFormLinkValue {\n\tif (value != null && typeof value === 'object') return value\n\tconst id = linkId(value)\n\treturn id !== undefined ? { id } : { id: '' }\n}\n","import type { AFormLinkValue, CurrencyOptions, CurrencyValue } from '../types'\nimport { linkId } from './linkValue'\n\nconst FLOAT_NOISE_DECIMALS = 6\n\nexport function normalizeBaseCurrency(\n\toptions: CurrencyOptions,\n\tcurrent: CurrencyValue | null | undefined\n): AFormLinkValue {\n\tconst base = options.baseCurrency ?? current?.baseCurrency\n\tif (!base) return { id: '' }\n\treturn typeof base === 'string' ? { id: base } : base\n}\n\nexport function baseAmountDecimals(options: CurrencyOptions): number {\n\tconst { precision } = options\n\tif (precision === undefined) return FLOAT_NOISE_DECIMALS\n\treturn Number.isInteger(precision) && precision >= 0 && precision <= 100 ? precision : FLOAT_NOISE_DECIMALS\n}\n\nexport function resolveCurrencyExchangeRate(\n\tcurrencyId: string | number | undefined,\n\toptions: CurrencyOptions,\n\tbaseCurrency: AFormLinkValue,\n\tcurrent: CurrencyValue | null | undefined\n): number {\n\tconst baseId = baseCurrency.id\n\tif (!currencyId || String(currencyId) === String(baseId)) return 1\n\t// `linkId`, never `.id`: a currency read from a record's own field may be its bare id, and taking it for\n\t// another currency replaces the stored rate.\n\tif (String(currencyId) === linkId(current?.currency)) {\n\t\treturn current?.exchangeRate ?? options.exchangeRates?.[String(currencyId)] ?? 1\n\t}\n\treturn options.exchangeRates?.[String(currencyId)] ?? 1\n}\n\nconst roundAmount = (value: number, decimals: number): number => Number(value.toFixed(decimals))\n\nexport function recomputeCurrencyValue(\n\tamount: number | null,\n\tcurrencyValue: AFormLinkValue,\n\toptions: CurrencyOptions,\n\tbaseCurrency: AFormLinkValue,\n\tcurrent: CurrencyValue | null | undefined\n): CurrencyValue {\n\tconst exchangeRate = resolveCurrencyExchangeRate(currencyValue.id, options, baseCurrency, current)\n\tconst decimals = baseAmountDecimals(options)\n\treturn {\n\t\tamount,\n\t\tcurrency: currencyValue,\n\t\texchangeRate,\n\t\tbaseCurrency,\n\t\tbaseAmount: amount === null ? null : roundAmount(amount * exchangeRate, decimals),\n\t}\n}\n\nexport function patchCurrencyAmount(\n\tcurrent: CurrencyValue | null | undefined,\n\tamount: number | null,\n\toptions: CurrencyOptions,\n\tbaseCurrency: AFormLinkValue\n): CurrencyValue {\n\tif (!current) return recomputeCurrencyValue(amount, { id: '' }, options, baseCurrency, current)\n\t// Currency and rate exactly as given, never re-derived: they are often fields of their own, which\n\t// an order's totals share, so typing one amount must not change them.\n\tconst recomputed = recomputeCurrencyValue(amount, current.currency ?? { id: '' }, options, baseCurrency, current)\n\treturn { ...recomputed, currency: current.currency, exchangeRate: current.exchangeRate }\n}\n\nexport function patchCurrencyCurrency(\n\tcurrent: CurrencyValue | null | undefined,\n\tcurrencyValue: AFormLinkValue,\n\toptions: CurrencyOptions,\n\tbaseCurrency: AFormLinkValue\n): CurrencyValue {\n\treturn recomputeCurrencyValue(current?.amount ?? null, currencyValue, options, baseCurrency, current)\n}\n\n/** Static currency choices when no async filterFunction is configured (base + exchangeRates keys). */\nexport function staticCurrencyChoices(\n\toptions: CurrencyOptions,\n\tcurrent: CurrencyValue | null | undefined\n): AFormLinkValue[] {\n\tconst base = normalizeBaseCurrency(options, current)\n\tconst seen = new Set<string>()\n\tconst choices: AFormLinkValue[] = []\n\tif (base.id) {\n\t\tchoices.push(base)\n\t\tseen.add(String(base.id))\n\t}\n\tconst currentCur = current?.currency\n\tif (currentCur?.id && !seen.has(String(currentCur.id))) {\n\t\tchoices.push(currentCur)\n\t\tseen.add(String(currentCur.id))\n\t}\n\tfor (const id of Object.keys(options.exchangeRates ?? {})) {\n\t\tif (!seen.has(id)) {\n\t\t\tchoices.push({ id, displayText: id })\n\t\t\tseen.add(id)\n\t\t}\n\t}\n\treturn choices\n}\n","/**\n * A date box's day as `v-model` hands it back, or null once any part of the box is empty, which the\n * browser reports as `''`.\n */\nexport function dayFromBox(text: string): string | null {\n\treturn text === '' ? null : text\n}\n\n/**\n * A number box's number as `v-model` hands it back, or null once the box is empty. `v-model` hands\n * back the box's text when it holds no number, and the browser reports an empty box as `''`.\n */\nexport function numberFromBox(value: number | ''): number | null {\n\treturn value === '' ? null : value\n}\n","/**\n * A number part of a box's value as a number, or null when it holds none. A part read from a record's\n * own field holds what the server sent, and Postgres sends a `numeric` column as its decimal text.\n */\nexport function numberFromRecord(value: number | string | null | undefined): number | null {\n\tif (value === null || value === undefined || value === '') return null\n\treturn typeof value === 'number' ? value : Number(value)\n}\n","import { nextTick, onBeforeUnmount, watch, type Ref } from 'vue'\n\n// Left between a shrunk list and the window's bottom.\nconst WINDOW_MARGIN = 8\n// With less room than this below, a list keeps this many rows and runs past the window.\nconst MIN_ROWS = 4\n\ntype DropdownListState = {\n\tisOpen: () => boolean\n\t/** Options arrive after a list opens when its search is async, and each arrival is measured again. */\n\toptionCount: () => number\n\tactiveIndex: () => number | null\n}\n\n/**\n * Keeps an open dropdown list in the window: its height is the smaller of `--sc-dropdown-max-height`\n * (the stylesheet's `max-height`) and the room left below it, never under about four rows, and the\n * option the arrow keys highlight is scrolled into sight.\n */\nexport function fitDropdownList(list: Readonly<Ref<HTMLElement | null>>, state: DropdownListState) {\n\tconst fit = (event?: Event) => {\n\t\tconst element = list.value\n\t\t// The list's own scrolling moves nothing it is measured against.\n\t\tif (!element || !state.isOpen() || event?.target === element) return\n\t\telement.style.maxHeight = ''\n\t\tconst cap = Number.parseFloat(getComputedStyle(element).maxHeight)\n\t\tconst row = element.querySelector('[role=\"option\"]')?.getBoundingClientRect().height ?? 0\n\t\tconst room = window.innerHeight - element.getBoundingClientRect().top - WINDOW_MARGIN\n\t\tconst height = Math.max(room, MIN_ROWS * row)\n\t\t// `none` reads as NaN, and then the room below is the only limit.\n\t\tif (Number.isNaN(cap) || height < cap) element.style.maxHeight = `${Math.floor(height)}px`\n\t}\n\n\tconst listen = () => {\n\t\twindow.addEventListener('scroll', fit, { capture: true, passive: true })\n\t\twindow.addEventListener('resize', fit, { passive: true })\n\t}\n\tconst stopListening = () => {\n\t\twindow.removeEventListener('scroll', fit, { capture: true })\n\t\twindow.removeEventListener('resize', fit)\n\t}\n\n\twatch(\n\t\t() => state.isOpen(),\n\t\topen => {\n\t\t\tif (open) return listen()\n\t\t\tstopListening()\n\t\t\tif (list.value) list.value.style.maxHeight = ''\n\t\t}\n\t)\n\n\t// After the flush, not in it: a `v-show` list is still hidden while post-flush watchers run, and a\n\t// hidden list measures as sitting at the top of the window.\n\twatch(\n\t\t() => state.isOpen() && state.optionCount(),\n\t\t() => void nextTick(() => fit())\n\t)\n\n\twatch(\n\t\t() => state.activeIndex(),\n\t\tindex => {\n\t\t\tif (index === null || index < 0) return\n\t\t\t// jsdom, where hosts test the forms they build, has no scrollIntoView.\n\t\t\tvoid nextTick(() =>\n\t\t\t\tlist.value?.querySelectorAll('[role=\"option\"]')[index]?.scrollIntoView?.({ block: 'nearest' })\n\t\t\t)\n\t\t},\n\t\t{ flush: 'post' }\n\t)\n\n\tonBeforeUnmount(stopListening)\n}\n","<template>\n\t<ul\n\t\tv-show=\"open\"\n\t\t:id=\"listboxId\"\n\t\tref=\"root\"\n\t\tclass=\"autocomplete-results\"\n\t\t:class=\"{\n\t\t\t'autocomplete-results--anchor-group': listAnchor === 'group',\n\t\t\t'autocomplete-results--cell-modal': surface === 'cell-modal',\n\t\t}\"\n\t\trole=\"listbox\"\n\t\t:aria-label=\"ariaLabel\">\n\t\t<slot />\n\t</ul>\n</template>\n\n<script setup lang=\"ts\">\nimport { useTemplateRef } from 'vue'\n\nimport { fitDropdownList } from '../../composables/dropdownList'\n\nconst {\n\tlistboxId,\n\tariaLabel,\n\topen,\n\tlistAnchor = 'field',\n\tsurface = 'field',\n\toptionCount,\n\tactiveIndex,\n} = defineProps<{\n\tlistboxId: string\n\tariaLabel: string\n\topen: boolean\n\tlistAnchor?: 'field' | 'group'\n\t/** `cell-modal`: list fills {@link ATableModal} width (table tuple pickers). */\n\tsurface?: 'field' | 'cell-modal'\n\toptionCount: () => number\n\tactiveIndex: () => number | null\n}>()\n\nconst root = useTemplateRef<HTMLElement>('root')\n\nfitDropdownList(root, {\n\tisOpen: () => open,\n\toptionCount,\n\tactiveIndex,\n})\n\ndefineExpose({ root })\n</script>\n\n<style scoped>\n.autocomplete-results {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\tright: 0;\n\tz-index: 100;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n\tcolor: var(--sc-cell-text-color);\n\tborder: 1px solid var(--sc-row-border-color);\n\tborder-radius: 0 0 var(--sc-border-radius) var(--sc-border-radius);\n\tborder-top: none;\n\tborder-left: none;\n\tbackground-color: var(--sc-overlay-background);\n\tbox-shadow: var(--sc-overlay-shadow);\n\tlist-style: none;\n\tmax-height: var(--sc-dropdown-max-height);\n\toverflow-y: auto;\n}\n\n.autocomplete-results--anchor-group {\n\tleft: -1px;\n\tright: -1px;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.autocomplete-results--cell-modal {\n\tposition: relative;\n\ttop: 0;\n\tleft: 0;\n\tright: 0;\n\twidth: 100%;\n\tmin-width: 100%;\n\tmax-width: none;\n\tborder-top: none;\n}\n\n/* :deep — option rows are slotted from ADropdown / AFormLink; scoped rules do not reach them otherwise. */\n.autocomplete-results :deep(.autocomplete-result) {\n\ttext-align: left;\n\tbox-sizing: border-box;\n\tborder-left: 2px solid transparent;\n\tpadding: 0.35rem 0.75ch 0.35rem 0.25ch;\n\tcursor: pointer;\n\tcolor: var(--sc-cell-text-color);\n}\n\n.autocomplete-results :deep(.autocomplete-result:hover),\n.autocomplete-results :deep(.autocomplete-result.is-active) {\n\tbackground-color: var(--sc-dropdown-option-hover-background);\n\tcolor: var(--sc-cell-text-color);\n}\n\n/* Committed value (v-model): one 2px bar (ATable uses 4px on row cells; no stacked list + inset). */\n.autocomplete-results :deep(.autocomplete-result.is-selected) {\n\tborder-left-color: var(--sc-dropdown-option-selected-accent);\n}\n</style>\n","<template>\n\t<ul\n\t\tv-show=\"open\"\n\t\t:id=\"listboxId\"\n\t\tref=\"root\"\n\t\tclass=\"autocomplete-results\"\n\t\t:class=\"{\n\t\t\t'autocomplete-results--anchor-group': listAnchor === 'group',\n\t\t\t'autocomplete-results--cell-modal': surface === 'cell-modal',\n\t\t}\"\n\t\trole=\"listbox\"\n\t\t:aria-label=\"ariaLabel\">\n\t\t<slot />\n\t</ul>\n</template>\n\n<script setup lang=\"ts\">\nimport { useTemplateRef } from 'vue'\n\nimport { fitDropdownList } from '../../composables/dropdownList'\n\nconst {\n\tlistboxId,\n\tariaLabel,\n\topen,\n\tlistAnchor = 'field',\n\tsurface = 'field',\n\toptionCount,\n\tactiveIndex,\n} = defineProps<{\n\tlistboxId: string\n\tariaLabel: string\n\topen: boolean\n\tlistAnchor?: 'field' | 'group'\n\t/** `cell-modal`: list fills {@link ATableModal} width (table tuple pickers). */\n\tsurface?: 'field' | 'cell-modal'\n\toptionCount: () => number\n\tactiveIndex: () => number | null\n}>()\n\nconst root = useTemplateRef<HTMLElement>('root')\n\nfitDropdownList(root, {\n\tisOpen: () => open,\n\toptionCount,\n\tactiveIndex,\n})\n\ndefineExpose({ root })\n</script>\n\n<style scoped>\n.autocomplete-results {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\tright: 0;\n\tz-index: 100;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n\tcolor: var(--sc-cell-text-color);\n\tborder: 1px solid var(--sc-row-border-color);\n\tborder-radius: 0 0 var(--sc-border-radius) var(--sc-border-radius);\n\tborder-top: none;\n\tborder-left: none;\n\tbackground-color: var(--sc-overlay-background);\n\tbox-shadow: var(--sc-overlay-shadow);\n\tlist-style: none;\n\tmax-height: var(--sc-dropdown-max-height);\n\toverflow-y: auto;\n}\n\n.autocomplete-results--anchor-group {\n\tleft: -1px;\n\tright: -1px;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.autocomplete-results--cell-modal {\n\tposition: relative;\n\ttop: 0;\n\tleft: 0;\n\tright: 0;\n\twidth: 100%;\n\tmin-width: 100%;\n\tmax-width: none;\n\tborder-top: none;\n}\n\n/* :deep — option rows are slotted from ADropdown / AFormLink; scoped rules do not reach them otherwise. */\n.autocomplete-results :deep(.autocomplete-result) {\n\ttext-align: left;\n\tbox-sizing: border-box;\n\tborder-left: 2px solid transparent;\n\tpadding: 0.35rem 0.75ch 0.35rem 0.25ch;\n\tcursor: pointer;\n\tcolor: var(--sc-cell-text-color);\n}\n\n.autocomplete-results :deep(.autocomplete-result:hover),\n.autocomplete-results :deep(.autocomplete-result.is-active) {\n\tbackground-color: var(--sc-dropdown-option-hover-background);\n\tcolor: var(--sc-cell-text-color);\n}\n\n/* Committed value (v-model): one 2px bar (ATable uses 4px on row cells; no stacked list + inset). */\n.autocomplete-results :deep(.autocomplete-result.is-selected) {\n\tborder-left-color: var(--sc-dropdown-option-selected-accent);\n}\n</style>\n","<template>\n\t<div\n\t\t:class=\"[\n\t\t\t'aform_form-element',\n\t\t\t{ 'aform_form-element--embedded': embedded, 'aform_dropdown--anchor-group': listAnchor === 'group' },\n\t\t]\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span v-if=\"!linkPicker && badgeDescriptor\" class=\"aform_display-value\" :style=\"displayAccentStyle\">{{\n\t\t\t\tbadgeDescriptor.label\n\t\t\t}}</span>\n\t\t\t<span v-else-if=\"!linkPicker\" class=\"aform_display-value\">{{ search }}</span>\n\t\t\t<span v-else class=\"aform_display-value\">{{ linkDisplayedText }}</span>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div v-on-click-outside=\"onClickOutside\" class=\"autocomplete\" :class=\"{ isOpen: dropdown.open }\">\n\t\t\t\t<button\n\t\t\t\t\tv-if=\"trigger === 'button'\"\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclass=\"aform_dropdown-button\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:aria-label=\"ariaLabel ?? label\"\n\t\t\t\t\taria-haspopup=\"listbox\"\n\t\t\t\t\t:aria-expanded=\"dropdown.open\"\n\t\t\t\t\t:aria-controls=\"dropdown.open ? listboxId : undefined\"\n\t\t\t\t\t:aria-activedescendant=\"\n\t\t\t\t\t\tdropdown.open && dropdown.activeItemIndex !== null\n\t\t\t\t\t\t\t? `${listboxId}-opt-${dropdown.activeItemIndex}`\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\"\n\t\t\t\t\t@click=\"toggleButtonDropdown\"\n\t\t\t\t\t@keydown.down.prevent=\"selectNextResult\"\n\t\t\t\t\t@keydown.up.prevent=\"selectPrevResult\"\n\t\t\t\t\t@keydown.enter.prevent=\"setCurrentResult\"\n\t\t\t\t\t@keydown.esc=\"onClickOutside\">\n\t\t\t\t\t<span class=\"aform_dropdown-button-value\">{{ search || placeholder || '' }}</span>\n\t\t\t\t\t<span class=\"aform_dropdown-button-caret\" aria-hidden=\"true\"></span>\n\t\t\t\t</button>\n\t\t\t\t<input\n\t\t\t\t\tv-else\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\tv-model=\"search\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\taria-autocomplete=\"list\"\n\t\t\t\t\t:class=\"['aform_input-field', { 'aform_input-field--embedded': embedded }]\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t\t:size=\"embeddedLinkInputSize\"\n\t\t\t\t\t:aria-label=\"ariaLabel\"\n\t\t\t\t\t:style=\"inputAccentStyle\"\n\t\t\t\t\t:aria-expanded=\"dropdown.open\"\n\t\t\t\t\t:aria-controls=\"dropdown.open ? listboxId : undefined\"\n\t\t\t\t\t:aria-activedescendant=\"\n\t\t\t\t\t\tdropdown.activeItemIndex === null ? undefined : `${listboxId}-opt-${dropdown.activeItemIndex}`\n\t\t\t\t\t\"\n\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t@input=\"onComboboxInput\"\n\t\t\t\t\t@focus=\"onComboboxFocus\"\n\t\t\t\t\t@click=\"onEmbeddedComboboxClick\"\n\t\t\t\t\t@pointerdown=\"onEmbeddedComboboxPointerDown\"\n\t\t\t\t\t@keydown.down.prevent=\"selectNextResult\"\n\t\t\t\t\t@keydown.up.prevent=\"selectPrevResult\"\n\t\t\t\t\t@keydown.enter.prevent=\"setCurrentResult\"\n\t\t\t\t\t@keydown.esc=\"onClickOutside\"\n\t\t\t\t\t@keydown.tab=\"onClickOutside\" />\n\n\t\t\t\t<ADropdownList\n\t\t\t\t\t:listbox-id=\"listboxId\"\n\t\t\t\t\t:ariaLabel=\"ariaLabel ?? label ?? ''\"\n\t\t\t\t\t:open=\"dropdown.open\"\n\t\t\t\t\t:list-anchor=\"listAnchor\"\n\t\t\t\t\t:option-count=\"optionCount\"\n\t\t\t\t\t:active-index=\"() => dropdown.activeItemIndex\">\n\t\t\t\t\t<li v-if=\"dropdown.loading\" class=\"loading autocomplete-result\">Loading results...</li>\n\t\t\t\t\t<template v-else-if=\"linkPicker\">\n\t\t\t\t\t\t<li\n\t\t\t\t\t\t\tv-for=\"(option, i) in linkResults\"\n\t\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t:aria-selected=\"isLinkOptionSelected(option)\"\n\t\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'is-active': i === dropdown.activeItemIndex,\n\t\t\t\t\t\t\t\t'is-selected': isLinkOptionSelected(option),\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@mousedown.prevent=\"selectLinkOption(option)\"\n\t\t\t\t\t\t\t@mouseenter=\"dropdown.activeItemIndex = i\">\n\t\t\t\t\t\t\t<slot name=\"option\" :option=\"option\">{{ option.displayText ?? String(option.id) }}</slot>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</template>\n\t\t\t\t\t<template v-else>\n\t\t\t\t\t\t<li\n\t\t\t\t\t\t\tv-for=\"(result, i) in dropdown.results\"\n\t\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t\t:key=\"result\"\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t:aria-selected=\"isChoiceSelected(result)\"\n\t\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'is-active': i === dropdown.activeItemIndex,\n\t\t\t\t\t\t\t\t'is-selected': isChoiceSelected(result),\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@mousedown.prevent=\"setChoiceResult(result)\"\n\t\t\t\t\t\t\t@mouseenter=\"dropdown.activeItemIndex = i\">\n\t\t\t\t\t\t\t{{ result }}\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</template>\n\t\t\t\t</ADropdownList>\n\t\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t</div>\n\t\t\t<p v-if=\"!embedded\" v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { FieldOptions } from '@stonecrop/schema'\nimport { selectChoices } from '@stonecrop/schema'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, inject, reactive, ref, useId, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { AFormLinkModelValue, AFormLinkValue, ComponentProps } from '../../types'\nimport type { BadgeFormatFn } from '../../utils/badge'\nimport { badgeInputAccentStyle, resolveFieldBadge } from '../../utils/badge'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { asLinkValue, linkDisplayText, linkId } from '../../utils/linkValue'\nimport ADropdownList from './ADropdownList.vue'\n\nconst {\n\tlabel,\n\trequired,\n\toptions = [],\n\tformat,\n\tisAsync = false,\n\tfilterFunction = undefined,\n\tlink = false,\n\tlinkFilterFunction = undefined,\n\tformatter = undefined,\n\tdoctype = undefined,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tembedded = false,\n\ttrigger = 'combobox',\n\tlistAnchor = 'field',\n\tplaceholder = undefined,\n\tariaLabel = undefined,\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: FieldOptions\n\t\tformat?: string\n\t\tisAsync?: boolean\n\t\tfilterFunction?: (search: string) => string[] | Promise<string[]>\n\t\t/** Picks a linked record, bound through `v-model:link-value` as an `AFormLinkValue` (embedded currency, etc.). */\n\t\tlink?: boolean\n\t\t/** Searches the records a `link` picker lists. */\n\t\tlinkFilterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>)\n\t\tformatter?: (value: AFormLinkValue) => string\n\t\tdoctype?: string\n\t\tembedded?: boolean\n\t\ttrigger?: 'combobox' | 'button'\n\t\tlistAnchor?: 'field' | 'group'\n\t\tplaceholder?: string\n\t\tariaLabel?: string\n\t}\n>()\n\nconst emit = defineEmits<{\n\t'update:open': [open: boolean]\n}>()\n\nconst linkPicker = computed(() => link)\n\n// The list's own id: `uuid` is already the box's, and `aria-controls` must name the list.\nconst listboxId = `${uuid ?? `aform-dropdown-${useId()}`}-listbox`\n\nconst choiceList = computed(() => selectChoices(options))\n\nconst formatFn = computed(() => (format ? deserializeFunction<BadgeFormatFn>(format) : undefined))\n\nconst badgeDescriptor = computed(() =>\n\tlinkPicker.value ? null : resolveFieldBadge(search.value, options, formatFn.value)\n)\n\nconst inputAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? undefined))\n\nconst displayAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? undefined))\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst modelValue = defineModel<string>()\nconst linkModel = defineModel<AFormLinkModelValue>('linkValue')\n\ntype FilterFn = (search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\n\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\nconst dropdown = reactive({\n\tactiveItemIndex: null as number | null,\n\topen: false,\n\tloading: false,\n\tresults: [] as string[],\n})\n\nwatch(\n\t() => dropdown.open,\n\topen => emit('update:open', open)\n)\n\nconst linkResults = ref<AFormLinkValue[]>([])\n\nconst optionCount = () => (linkPicker.value ? linkResults.value.length : dropdown.results.length)\n\nconst committedValue = ref(modelValue.value ?? '')\n\n// The text a picked record shows: the formatter's, or else its name, or else its id.\nconst linkText = (value: AFormLinkModelValue | undefined) => {\n\tconst record = asLinkValue(value)\n\treturn formatter ? formatter(record) : (linkDisplayText(record) ?? String(record.id))\n}\n\n// The record a link names, as last seen with its text: the value itself, a pick, or the picker's own\n// lookup. Kept here and never written into the record: a lookup is not a pick, and Save's reply hands\n// the id back bare.\nconst knownLink = ref<AFormLinkValue>()\n\nwatch(\n\t() => linkModel.value,\n\tvalue => {\n\t\tif (linkPicker.value && linkDisplayText(value)) knownLink.value = asLinkValue(value)\n\t},\n\t{ immediate: true }\n)\n\nconst shownLink = computed<AFormLinkModelValue | undefined>(() => {\n\tconst value = linkModel.value\n\tif (linkDisplayText(value)) return value\n\tconst id = linkId(value)\n\tconst known = knownLink.value\n\treturn known && id !== undefined && String(known.id) === String(id) ? known : value\n})\n\nconst linkDisplayedText = computed(() => (linkId(shownLink.value) === undefined ? '—' : linkText(shownLink.value)))\n\nconst search = ref('')\n\nwatch(\n\tmodelValue,\n\tvalue => {\n\t\tif (linkPicker.value) return\n\t\tconst next = value ?? ''\n\t\tsearch.value = next\n\t\tif (next === '' || choiceList.value.includes(next)) committedValue.value = next\n\t},\n\t{ immediate: true }\n)\n\nwatch(\n\tshownLink,\n\tvalue => {\n\t\tif (!linkPicker.value) return\n\t\tsearch.value = linkId(value) ? linkText(value) : ''\n\t},\n\t{ immediate: true }\n)\n\nwatch(\n\t() => (linkPicker.value && !linkDisplayText(shownLink.value) ? linkId(linkModel.value) : undefined),\n\tasync id => {\n\t\tif (!linkPicker.value || !id) return\n\t\ttry {\n\t\t\tlet match: AFormLinkValue | undefined\n\t\t\tlet displayText: string | undefined\n\t\t\tif (linkFilterFunction) {\n\t\t\t\tconst fn: FilterFn =\n\t\t\t\t\ttypeof linkFilterFunction === 'string'\n\t\t\t\t\t\t? deserializeFunction<FilterFn>(linkFilterFunction)\n\t\t\t\t\t\t: linkFilterFunction\n\t\t\t\tconst results = await fn(String(id))\n\t\t\t\tmatch = results.find(r => String(r.id) === String(id))\n\t\t\t\tdisplayText = match?.displayText\n\t\t\t} else if (resolver && doctype) {\n\t\t\t\tdisplayText = (await resolver(doctype, id.toString())) ?? undefined\n\t\t\t}\n\t\t\tif (displayText) knownLink.value = { ...asLinkValue(linkModel.value), ...match, id, displayText }\n\t\t} catch {\n\t\t\t// fall back to raw id in the input\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst onClickOutside = () => closeDropdown()\n\nconst isChoiceSelected = (result: string) => !!result && result === (modelValue.value ?? '')\n\nconst isLinkOptionSelected = (option: AFormLinkValue) => {\n\tconst id = linkId(linkModel.value)\n\treturn id !== undefined && String(option.id) === String(id)\n}\n\nconst embeddedLinkDisplayText = computed(() =>\n\tlinkId(shownLink.value) ? linkText(shownLink.value) : (placeholder ?? '')\n)\n\nconst embeddedLinkInputSize = computed(() => {\n\tif (!embedded || !linkPicker.value) return undefined\n\tconst text = embeddedLinkDisplayText.value\n\tconst length = text.length > 0 ? text.length : (placeholder ?? '').length\n\treturn length > 0 ? length : undefined\n})\n\nconst filterResults = () => {\n\tif (!search.value) {\n\t\tdropdown.results = choiceList.value\n\t} else {\n\t\tdropdown.results = choiceList.value.filter(item => item.toLowerCase().includes(search.value.toLowerCase()))\n\t}\n}\n\nconst openLinkDropdown = async (text: string) => {\n\tif (!linkFilterFunction || mode === 'read') return\n\tdropdown.activeItemIndex = null\n\tdropdown.open = true\n\tif (isAsync) dropdown.loading = true\n\ttry {\n\t\tconst fn: FilterFn =\n\t\t\ttypeof linkFilterFunction === 'string' ? deserializeFunction<FilterFn>(linkFilterFunction) : linkFilterFunction\n\t\tlinkResults.value = (await fn(text)) ?? []\n\t} catch {\n\t\tlinkResults.value = []\n\t} finally {\n\t\tdropdown.loading = false\n\t}\n}\n\nconst embeddedLinkFilterQuery = (): string => {\n\tif (!embedded || !linkPicker.value) return search.value\n\tconst id = linkId(shownLink.value)\n\tif (id && formatter) {\n\t\tconst formatted = formatter(asLinkValue(shownLink.value))\n\t\tif (search.value === formatted) return ''\n\t}\n\treturn search.value\n}\n\n// One click fires pointerdown, focus and click here, and the price field's own click: only the first looks the list up.\nconst openEmbeddedList = () => {\n\tif (linkPicker.value && !dropdown.open) openLinkDropdown(embeddedLinkFilterQuery())\n}\n\ndefineExpose({ openCurrencyList: openEmbeddedList })\n\nconst filter = async () => {\n\tdropdown.open = true\n\tdropdown.activeItemIndex = null\n\tif (filterFunction) {\n\t\tif (isAsync) dropdown.loading = true\n\t\ttry {\n\t\t\tconst filteredResults = await filterFunction(search.value || '')\n\t\t\tdropdown.results = filteredResults || []\n\t\t} catch {\n\t\t\tdropdown.results = []\n\t\t} finally {\n\t\t\tif (isAsync) dropdown.loading = false\n\t\t}\n\t} else {\n\t\tfilterResults()\n\t}\n}\n\nconst setChoiceResult = (result: string) => {\n\tmodelValue.value = result\n\tsearch.value = result\n\tcommittedValue.value = result\n\tcloseDropdown(result)\n}\n\nconst selectLinkOption = (option: AFormLinkValue) => {\n\tlinkModel.value = option\n\tsearch.value = linkText(option)\n\tdropdown.open = false\n\tdropdown.activeItemIndex = null\n}\n\nconst openChoiceDropdown = () => {\n\tconst idx = choiceList.value.indexOf(search.value)\n\tdropdown.activeItemIndex = isAsync ? null : idx >= 0 ? idx : null\n\tdropdown.open = true\n\tdropdown.results = isAsync ? [] : choiceList.value\n}\n\nconst closeDropdown = (result?: string) => {\n\tdropdown.activeItemIndex = null\n\tdropdown.open = false\n\tif (linkPicker.value) {\n\t\tsearch.value = linkId(shownLink.value) ? linkText(shownLink.value) : ''\n\t\treturn\n\t}\n\tconst typed = result || search.value || ''\n\tif (choiceList.value.includes(typed)) {\n\t\t// A choice typed out in full is picked, as if from the list. A pick from the list has already been sent.\n\t\tif (typed !== committedValue.value) {\n\t\t\tmodelValue.value = typed\n\t\t\tcommittedValue.value = typed\n\t\t}\n\t} else {\n\t\tsearch.value = committedValue.value\n\t\tmodelValue.value = committedValue.value\n\t}\n}\n\nconst toggleButtonDropdown = () => {\n\tif (dropdown.open) closeDropdown()\n\telse openChoiceDropdown()\n}\n\nconst onComboboxInput = () => {\n\tif (linkPicker.value) openLinkDropdown(embedded ? embeddedLinkFilterQuery() : search.value)\n\telse {\n\t\t// Typing searches the choices; the record changes only when one is picked, or when the box is cleared.\n\t\tif (search.value === '') {\n\t\t\tmodelValue.value = ''\n\t\t\tcommittedValue.value = ''\n\t\t}\n\t\tfilter()\n\t}\n}\n\nconst onComboboxFocus = (event: FocusEvent) => {\n\tif (linkPicker.value && embedded) {\n\t\topenEmbeddedList()\n\t\tconst input = event.target as HTMLInputElement | null\n\t\tif (input) requestAnimationFrame(() => input.select())\n\t\treturn\n\t}\n\tif (linkPicker.value) openLinkDropdown(search.value)\n\telse openChoiceDropdown()\n}\n\nconst onEmbeddedComboboxClick = () => {\n\tif (embedded && linkPicker.value) openEmbeddedList()\n}\n\nconst onEmbeddedComboboxPointerDown = () => {\n\tif (embedded && linkPicker.value) openEmbeddedList()\n}\n\nwatch(\n\tchoiceList,\n\tchoices => {\n\t\tif (!linkPicker.value) dropdown.results = choices\n\t},\n\t{ immediate: true }\n)\n\nconst ensureDropdownOpen = () => {\n\tif (dropdown.open) return\n\tif (linkPicker.value) {\n\t\tif (embedded) openEmbeddedList()\n\t\telse void openLinkDropdown(search.value)\n\t} else {\n\t\topenChoiceDropdown()\n\t}\n}\n\nconst selectNextResult = () => {\n\tconst resultsLength = optionCount()\n\tif (!resultsLength) return\n\tconst wasOpen = dropdown.open\n\tensureDropdownOpen()\n\tif (!wasOpen) {\n\t\t// Opening already highlights the current choice; with none, the first is.\n\t\tif (dropdown.activeItemIndex === null && !isAsync) dropdown.activeItemIndex = 0\n\t\treturn\n\t}\n\tif (dropdown.activeItemIndex != null) {\n\t\tdropdown.activeItemIndex = (dropdown.activeItemIndex + 1) % resultsLength\n\t} else {\n\t\tdropdown.activeItemIndex = 0\n\t}\n}\n\nconst selectPrevResult = () => {\n\tconst resultsLength = optionCount()\n\tif (!resultsLength) return\n\tensureDropdownOpen()\n\tif (dropdown.activeItemIndex != null) {\n\t\tif (dropdown.activeItemIndex === 0) {\n\t\t\tdropdown.activeItemIndex = trigger === 'button' ? resultsLength - 1 : null\n\t\t} else {\n\t\t\tdropdown.activeItemIndex = dropdown.activeItemIndex - 1\n\t\t}\n\t} else {\n\t\tdropdown.activeItemIndex = resultsLength - 1\n\t}\n}\n\nconst setCurrentResult = () => {\n\tif (!dropdown.open) {\n\t\tensureDropdownOpen()\n\t\treturn\n\t}\n\tif (linkPicker.value) {\n\t\tif (dropdown.activeItemIndex !== null && linkResults.value[dropdown.activeItemIndex]) {\n\t\t\tselectLinkOption(linkResults.value[dropdown.activeItemIndex])\n\t\t}\n\t\treturn\n\t}\n\tconst result = dropdown.results[dropdown.activeItemIndex ?? 0]\n\tif (result !== undefined) setChoiceResult(result)\n}\n</script>\n\n<style scoped>\n.autocomplete {\n\tposition: relative;\n}\n\n.aform_form-element--embedded {\n\tmin-width: 0;\n\tflex: 1 1 auto;\n\twidth: 100%;\n\tpadding-top: 0;\n}\n\n.aform_form-element--embedded .autocomplete {\n\tdisplay: flex;\n\tflex: 1;\n\tmin-width: 0;\n\tmin-height: 0;\n\twidth: 100%;\n}\n\n.aform_dropdown--anchor-group .autocomplete {\n\tposition: static;\n}\n\n.aform_input-field--embedded {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0.5rem 1ch;\n}\n\n.aform_dropdown-button {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 0.75ch;\n\tflex: 1;\n\talign-self: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: 100%;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\tbackground: var(--sc-input-addon-background);\n\tborder: none;\n\toutline: none;\n\tborder-radius: 0 var(--sc-border-radius) var(--sc-border-radius) 0;\n\twhite-space: nowrap;\n\tcursor: pointer;\n\t-webkit-tap-highlight-color: transparent;\n}\n\n.aform_dropdown-button:focus,\n.aform_dropdown-button:focus-visible {\n\toutline: none;\n\tbox-shadow: none;\n}\n\n.aform_dropdown-button::-moz-focus-inner {\n\tborder: 0;\n\tpadding: 0;\n}\n\n/* Merged fields (quantity UOM): same surface as the sibling input, not a nested addon chip. */\n.aform_form-element--embedded .aform_dropdown-button {\n\tbackground: transparent;\n}\n\n.aform_dropdown-button:disabled {\n\tcursor: not-allowed;\n\tcolor: var(--sc-gray-50);\n}\n\n.aform_dropdown-button-value {\n\tflex: 1;\n\tmin-width: 0;\n\ttext-align: left;\n}\n\n.aform_dropdown-button-caret {\n\tdisplay: inline-block;\n\twidth: 0;\n\theight: 0;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tborder-top: 0.3em solid currentColor;\n}\n</style>\n","<template>\n\t<div\n\t\t:class=\"[\n\t\t\t'aform_form-element',\n\t\t\t{ 'aform_form-element--embedded': embedded, 'aform_dropdown--anchor-group': listAnchor === 'group' },\n\t\t]\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span v-if=\"!linkPicker && badgeDescriptor\" class=\"aform_display-value\" :style=\"displayAccentStyle\">{{\n\t\t\t\tbadgeDescriptor.label\n\t\t\t}}</span>\n\t\t\t<span v-else-if=\"!linkPicker\" class=\"aform_display-value\">{{ search }}</span>\n\t\t\t<span v-else class=\"aform_display-value\">{{ linkDisplayedText }}</span>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div v-on-click-outside=\"onClickOutside\" class=\"autocomplete\" :class=\"{ isOpen: dropdown.open }\">\n\t\t\t\t<button\n\t\t\t\t\tv-if=\"trigger === 'button'\"\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tclass=\"aform_dropdown-button\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:aria-label=\"ariaLabel ?? label\"\n\t\t\t\t\taria-haspopup=\"listbox\"\n\t\t\t\t\t:aria-expanded=\"dropdown.open\"\n\t\t\t\t\t:aria-controls=\"dropdown.open ? listboxId : undefined\"\n\t\t\t\t\t:aria-activedescendant=\"\n\t\t\t\t\t\tdropdown.open && dropdown.activeItemIndex !== null\n\t\t\t\t\t\t\t? `${listboxId}-opt-${dropdown.activeItemIndex}`\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\"\n\t\t\t\t\t@click=\"toggleButtonDropdown\"\n\t\t\t\t\t@keydown.down.prevent=\"selectNextResult\"\n\t\t\t\t\t@keydown.up.prevent=\"selectPrevResult\"\n\t\t\t\t\t@keydown.enter.prevent=\"setCurrentResult\"\n\t\t\t\t\t@keydown.esc=\"onClickOutside\">\n\t\t\t\t\t<span class=\"aform_dropdown-button-value\">{{ search || placeholder || '' }}</span>\n\t\t\t\t\t<span class=\"aform_dropdown-button-caret\" aria-hidden=\"true\"></span>\n\t\t\t\t</button>\n\t\t\t\t<input\n\t\t\t\t\tv-else\n\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\tv-model=\"search\"\n\t\t\t\t\ttype=\"text\"\n\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\taria-autocomplete=\"list\"\n\t\t\t\t\t:class=\"['aform_input-field', { 'aform_input-field--embedded': embedded }]\"\n\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t\t:size=\"embeddedLinkInputSize\"\n\t\t\t\t\t:aria-label=\"ariaLabel\"\n\t\t\t\t\t:style=\"inputAccentStyle\"\n\t\t\t\t\t:aria-expanded=\"dropdown.open\"\n\t\t\t\t\t:aria-controls=\"dropdown.open ? listboxId : undefined\"\n\t\t\t\t\t:aria-activedescendant=\"\n\t\t\t\t\t\tdropdown.activeItemIndex === null ? undefined : `${listboxId}-opt-${dropdown.activeItemIndex}`\n\t\t\t\t\t\"\n\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t@input=\"onComboboxInput\"\n\t\t\t\t\t@focus=\"onComboboxFocus\"\n\t\t\t\t\t@click=\"onEmbeddedComboboxClick\"\n\t\t\t\t\t@pointerdown=\"onEmbeddedComboboxPointerDown\"\n\t\t\t\t\t@keydown.down.prevent=\"selectNextResult\"\n\t\t\t\t\t@keydown.up.prevent=\"selectPrevResult\"\n\t\t\t\t\t@keydown.enter.prevent=\"setCurrentResult\"\n\t\t\t\t\t@keydown.esc=\"onClickOutside\"\n\t\t\t\t\t@keydown.tab=\"onClickOutside\" />\n\n\t\t\t\t<ADropdownList\n\t\t\t\t\t:listbox-id=\"listboxId\"\n\t\t\t\t\t:ariaLabel=\"ariaLabel ?? label ?? ''\"\n\t\t\t\t\t:open=\"dropdown.open\"\n\t\t\t\t\t:list-anchor=\"listAnchor\"\n\t\t\t\t\t:option-count=\"optionCount\"\n\t\t\t\t\t:active-index=\"() => dropdown.activeItemIndex\">\n\t\t\t\t\t<li v-if=\"dropdown.loading\" class=\"loading autocomplete-result\">Loading results...</li>\n\t\t\t\t\t<template v-else-if=\"linkPicker\">\n\t\t\t\t\t\t<li\n\t\t\t\t\t\t\tv-for=\"(option, i) in linkResults\"\n\t\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t:aria-selected=\"isLinkOptionSelected(option)\"\n\t\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'is-active': i === dropdown.activeItemIndex,\n\t\t\t\t\t\t\t\t'is-selected': isLinkOptionSelected(option),\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@mousedown.prevent=\"selectLinkOption(option)\"\n\t\t\t\t\t\t\t@mouseenter=\"dropdown.activeItemIndex = i\">\n\t\t\t\t\t\t\t<slot name=\"option\" :option=\"option\">{{ option.displayText ?? String(option.id) }}</slot>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</template>\n\t\t\t\t\t<template v-else>\n\t\t\t\t\t\t<li\n\t\t\t\t\t\t\tv-for=\"(result, i) in dropdown.results\"\n\t\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t\t:key=\"result\"\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t:aria-selected=\"isChoiceSelected(result)\"\n\t\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t'is-active': i === dropdown.activeItemIndex,\n\t\t\t\t\t\t\t\t'is-selected': isChoiceSelected(result),\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@mousedown.prevent=\"setChoiceResult(result)\"\n\t\t\t\t\t\t\t@mouseenter=\"dropdown.activeItemIndex = i\">\n\t\t\t\t\t\t\t{{ result }}\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</template>\n\t\t\t\t</ADropdownList>\n\t\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t</div>\n\t\t\t<p v-if=\"!embedded\" v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { FieldOptions } from '@stonecrop/schema'\nimport { selectChoices } from '@stonecrop/schema'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, inject, reactive, ref, useId, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { AFormLinkModelValue, AFormLinkValue, ComponentProps } from '../../types'\nimport type { BadgeFormatFn } from '../../utils/badge'\nimport { badgeInputAccentStyle, resolveFieldBadge } from '../../utils/badge'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { asLinkValue, linkDisplayText, linkId } from '../../utils/linkValue'\nimport ADropdownList from './ADropdownList.vue'\n\nconst {\n\tlabel,\n\trequired,\n\toptions = [],\n\tformat,\n\tisAsync = false,\n\tfilterFunction = undefined,\n\tlink = false,\n\tlinkFilterFunction = undefined,\n\tformatter = undefined,\n\tdoctype = undefined,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tembedded = false,\n\ttrigger = 'combobox',\n\tlistAnchor = 'field',\n\tplaceholder = undefined,\n\tariaLabel = undefined,\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: FieldOptions\n\t\tformat?: string\n\t\tisAsync?: boolean\n\t\tfilterFunction?: (search: string) => string[] | Promise<string[]>\n\t\t/** Picks a linked record, bound through `v-model:link-value` as an `AFormLinkValue` (embedded currency, etc.). */\n\t\tlink?: boolean\n\t\t/** Searches the records a `link` picker lists. */\n\t\tlinkFilterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>)\n\t\tformatter?: (value: AFormLinkValue) => string\n\t\tdoctype?: string\n\t\tembedded?: boolean\n\t\ttrigger?: 'combobox' | 'button'\n\t\tlistAnchor?: 'field' | 'group'\n\t\tplaceholder?: string\n\t\tariaLabel?: string\n\t}\n>()\n\nconst emit = defineEmits<{\n\t'update:open': [open: boolean]\n}>()\n\nconst linkPicker = computed(() => link)\n\n// The list's own id: `uuid` is already the box's, and `aria-controls` must name the list.\nconst listboxId = `${uuid ?? `aform-dropdown-${useId()}`}-listbox`\n\nconst choiceList = computed(() => selectChoices(options))\n\nconst formatFn = computed(() => (format ? deserializeFunction<BadgeFormatFn>(format) : undefined))\n\nconst badgeDescriptor = computed(() =>\n\tlinkPicker.value ? null : resolveFieldBadge(search.value, options, formatFn.value)\n)\n\nconst inputAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? undefined))\n\nconst displayAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? undefined))\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst modelValue = defineModel<string>()\nconst linkModel = defineModel<AFormLinkModelValue>('linkValue')\n\ntype FilterFn = (search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\n\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\nconst dropdown = reactive({\n\tactiveItemIndex: null as number | null,\n\topen: false,\n\tloading: false,\n\tresults: [] as string[],\n})\n\nwatch(\n\t() => dropdown.open,\n\topen => emit('update:open', open)\n)\n\nconst linkResults = ref<AFormLinkValue[]>([])\n\nconst optionCount = () => (linkPicker.value ? linkResults.value.length : dropdown.results.length)\n\nconst committedValue = ref(modelValue.value ?? '')\n\n// The text a picked record shows: the formatter's, or else its name, or else its id.\nconst linkText = (value: AFormLinkModelValue | undefined) => {\n\tconst record = asLinkValue(value)\n\treturn formatter ? formatter(record) : (linkDisplayText(record) ?? String(record.id))\n}\n\n// The record a link names, as last seen with its text: the value itself, a pick, or the picker's own\n// lookup. Kept here and never written into the record: a lookup is not a pick, and Save's reply hands\n// the id back bare.\nconst knownLink = ref<AFormLinkValue>()\n\nwatch(\n\t() => linkModel.value,\n\tvalue => {\n\t\tif (linkPicker.value && linkDisplayText(value)) knownLink.value = asLinkValue(value)\n\t},\n\t{ immediate: true }\n)\n\nconst shownLink = computed<AFormLinkModelValue | undefined>(() => {\n\tconst value = linkModel.value\n\tif (linkDisplayText(value)) return value\n\tconst id = linkId(value)\n\tconst known = knownLink.value\n\treturn known && id !== undefined && String(known.id) === String(id) ? known : value\n})\n\nconst linkDisplayedText = computed(() => (linkId(shownLink.value) === undefined ? '—' : linkText(shownLink.value)))\n\nconst search = ref('')\n\nwatch(\n\tmodelValue,\n\tvalue => {\n\t\tif (linkPicker.value) return\n\t\tconst next = value ?? ''\n\t\tsearch.value = next\n\t\tif (next === '' || choiceList.value.includes(next)) committedValue.value = next\n\t},\n\t{ immediate: true }\n)\n\nwatch(\n\tshownLink,\n\tvalue => {\n\t\tif (!linkPicker.value) return\n\t\tsearch.value = linkId(value) ? linkText(value) : ''\n\t},\n\t{ immediate: true }\n)\n\nwatch(\n\t() => (linkPicker.value && !linkDisplayText(shownLink.value) ? linkId(linkModel.value) : undefined),\n\tasync id => {\n\t\tif (!linkPicker.value || !id) return\n\t\ttry {\n\t\t\tlet match: AFormLinkValue | undefined\n\t\t\tlet displayText: string | undefined\n\t\t\tif (linkFilterFunction) {\n\t\t\t\tconst fn: FilterFn =\n\t\t\t\t\ttypeof linkFilterFunction === 'string'\n\t\t\t\t\t\t? deserializeFunction<FilterFn>(linkFilterFunction)\n\t\t\t\t\t\t: linkFilterFunction\n\t\t\t\tconst results = await fn(String(id))\n\t\t\t\tmatch = results.find(r => String(r.id) === String(id))\n\t\t\t\tdisplayText = match?.displayText\n\t\t\t} else if (resolver && doctype) {\n\t\t\t\tdisplayText = (await resolver(doctype, id.toString())) ?? undefined\n\t\t\t}\n\t\t\tif (displayText) knownLink.value = { ...asLinkValue(linkModel.value), ...match, id, displayText }\n\t\t} catch {\n\t\t\t// fall back to raw id in the input\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst onClickOutside = () => closeDropdown()\n\nconst isChoiceSelected = (result: string) => !!result && result === (modelValue.value ?? '')\n\nconst isLinkOptionSelected = (option: AFormLinkValue) => {\n\tconst id = linkId(linkModel.value)\n\treturn id !== undefined && String(option.id) === String(id)\n}\n\nconst embeddedLinkDisplayText = computed(() =>\n\tlinkId(shownLink.value) ? linkText(shownLink.value) : (placeholder ?? '')\n)\n\nconst embeddedLinkInputSize = computed(() => {\n\tif (!embedded || !linkPicker.value) return undefined\n\tconst text = embeddedLinkDisplayText.value\n\tconst length = text.length > 0 ? text.length : (placeholder ?? '').length\n\treturn length > 0 ? length : undefined\n})\n\nconst filterResults = () => {\n\tif (!search.value) {\n\t\tdropdown.results = choiceList.value\n\t} else {\n\t\tdropdown.results = choiceList.value.filter(item => item.toLowerCase().includes(search.value.toLowerCase()))\n\t}\n}\n\nconst openLinkDropdown = async (text: string) => {\n\tif (!linkFilterFunction || mode === 'read') return\n\tdropdown.activeItemIndex = null\n\tdropdown.open = true\n\tif (isAsync) dropdown.loading = true\n\ttry {\n\t\tconst fn: FilterFn =\n\t\t\ttypeof linkFilterFunction === 'string' ? deserializeFunction<FilterFn>(linkFilterFunction) : linkFilterFunction\n\t\tlinkResults.value = (await fn(text)) ?? []\n\t} catch {\n\t\tlinkResults.value = []\n\t} finally {\n\t\tdropdown.loading = false\n\t}\n}\n\nconst embeddedLinkFilterQuery = (): string => {\n\tif (!embedded || !linkPicker.value) return search.value\n\tconst id = linkId(shownLink.value)\n\tif (id && formatter) {\n\t\tconst formatted = formatter(asLinkValue(shownLink.value))\n\t\tif (search.value === formatted) return ''\n\t}\n\treturn search.value\n}\n\n// One click fires pointerdown, focus and click here, and the price field's own click: only the first looks the list up.\nconst openEmbeddedList = () => {\n\tif (linkPicker.value && !dropdown.open) openLinkDropdown(embeddedLinkFilterQuery())\n}\n\ndefineExpose({ openCurrencyList: openEmbeddedList })\n\nconst filter = async () => {\n\tdropdown.open = true\n\tdropdown.activeItemIndex = null\n\tif (filterFunction) {\n\t\tif (isAsync) dropdown.loading = true\n\t\ttry {\n\t\t\tconst filteredResults = await filterFunction(search.value || '')\n\t\t\tdropdown.results = filteredResults || []\n\t\t} catch {\n\t\t\tdropdown.results = []\n\t\t} finally {\n\t\t\tif (isAsync) dropdown.loading = false\n\t\t}\n\t} else {\n\t\tfilterResults()\n\t}\n}\n\nconst setChoiceResult = (result: string) => {\n\tmodelValue.value = result\n\tsearch.value = result\n\tcommittedValue.value = result\n\tcloseDropdown(result)\n}\n\nconst selectLinkOption = (option: AFormLinkValue) => {\n\tlinkModel.value = option\n\tsearch.value = linkText(option)\n\tdropdown.open = false\n\tdropdown.activeItemIndex = null\n}\n\nconst openChoiceDropdown = () => {\n\tconst idx = choiceList.value.indexOf(search.value)\n\tdropdown.activeItemIndex = isAsync ? null : idx >= 0 ? idx : null\n\tdropdown.open = true\n\tdropdown.results = isAsync ? [] : choiceList.value\n}\n\nconst closeDropdown = (result?: string) => {\n\tdropdown.activeItemIndex = null\n\tdropdown.open = false\n\tif (linkPicker.value) {\n\t\tsearch.value = linkId(shownLink.value) ? linkText(shownLink.value) : ''\n\t\treturn\n\t}\n\tconst typed = result || search.value || ''\n\tif (choiceList.value.includes(typed)) {\n\t\t// A choice typed out in full is picked, as if from the list. A pick from the list has already been sent.\n\t\tif (typed !== committedValue.value) {\n\t\t\tmodelValue.value = typed\n\t\t\tcommittedValue.value = typed\n\t\t}\n\t} else {\n\t\tsearch.value = committedValue.value\n\t\tmodelValue.value = committedValue.value\n\t}\n}\n\nconst toggleButtonDropdown = () => {\n\tif (dropdown.open) closeDropdown()\n\telse openChoiceDropdown()\n}\n\nconst onComboboxInput = () => {\n\tif (linkPicker.value) openLinkDropdown(embedded ? embeddedLinkFilterQuery() : search.value)\n\telse {\n\t\t// Typing searches the choices; the record changes only when one is picked, or when the box is cleared.\n\t\tif (search.value === '') {\n\t\t\tmodelValue.value = ''\n\t\t\tcommittedValue.value = ''\n\t\t}\n\t\tfilter()\n\t}\n}\n\nconst onComboboxFocus = (event: FocusEvent) => {\n\tif (linkPicker.value && embedded) {\n\t\topenEmbeddedList()\n\t\tconst input = event.target as HTMLInputElement | null\n\t\tif (input) requestAnimationFrame(() => input.select())\n\t\treturn\n\t}\n\tif (linkPicker.value) openLinkDropdown(search.value)\n\telse openChoiceDropdown()\n}\n\nconst onEmbeddedComboboxClick = () => {\n\tif (embedded && linkPicker.value) openEmbeddedList()\n}\n\nconst onEmbeddedComboboxPointerDown = () => {\n\tif (embedded && linkPicker.value) openEmbeddedList()\n}\n\nwatch(\n\tchoiceList,\n\tchoices => {\n\t\tif (!linkPicker.value) dropdown.results = choices\n\t},\n\t{ immediate: true }\n)\n\nconst ensureDropdownOpen = () => {\n\tif (dropdown.open) return\n\tif (linkPicker.value) {\n\t\tif (embedded) openEmbeddedList()\n\t\telse void openLinkDropdown(search.value)\n\t} else {\n\t\topenChoiceDropdown()\n\t}\n}\n\nconst selectNextResult = () => {\n\tconst resultsLength = optionCount()\n\tif (!resultsLength) return\n\tconst wasOpen = dropdown.open\n\tensureDropdownOpen()\n\tif (!wasOpen) {\n\t\t// Opening already highlights the current choice; with none, the first is.\n\t\tif (dropdown.activeItemIndex === null && !isAsync) dropdown.activeItemIndex = 0\n\t\treturn\n\t}\n\tif (dropdown.activeItemIndex != null) {\n\t\tdropdown.activeItemIndex = (dropdown.activeItemIndex + 1) % resultsLength\n\t} else {\n\t\tdropdown.activeItemIndex = 0\n\t}\n}\n\nconst selectPrevResult = () => {\n\tconst resultsLength = optionCount()\n\tif (!resultsLength) return\n\tensureDropdownOpen()\n\tif (dropdown.activeItemIndex != null) {\n\t\tif (dropdown.activeItemIndex === 0) {\n\t\t\tdropdown.activeItemIndex = trigger === 'button' ? resultsLength - 1 : null\n\t\t} else {\n\t\t\tdropdown.activeItemIndex = dropdown.activeItemIndex - 1\n\t\t}\n\t} else {\n\t\tdropdown.activeItemIndex = resultsLength - 1\n\t}\n}\n\nconst setCurrentResult = () => {\n\tif (!dropdown.open) {\n\t\tensureDropdownOpen()\n\t\treturn\n\t}\n\tif (linkPicker.value) {\n\t\tif (dropdown.activeItemIndex !== null && linkResults.value[dropdown.activeItemIndex]) {\n\t\t\tselectLinkOption(linkResults.value[dropdown.activeItemIndex])\n\t\t}\n\t\treturn\n\t}\n\tconst result = dropdown.results[dropdown.activeItemIndex ?? 0]\n\tif (result !== undefined) setChoiceResult(result)\n}\n</script>\n\n<style scoped>\n.autocomplete {\n\tposition: relative;\n}\n\n.aform_form-element--embedded {\n\tmin-width: 0;\n\tflex: 1 1 auto;\n\twidth: 100%;\n\tpadding-top: 0;\n}\n\n.aform_form-element--embedded .autocomplete {\n\tdisplay: flex;\n\tflex: 1;\n\tmin-width: 0;\n\tmin-height: 0;\n\twidth: 100%;\n}\n\n.aform_dropdown--anchor-group .autocomplete {\n\tposition: static;\n}\n\n.aform_input-field--embedded {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0.5rem 1ch;\n}\n\n.aform_dropdown-button {\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 0.75ch;\n\tflex: 1;\n\talign-self: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: 100%;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\tbackground: var(--sc-input-addon-background);\n\tborder: none;\n\toutline: none;\n\tborder-radius: 0 var(--sc-border-radius) var(--sc-border-radius) 0;\n\twhite-space: nowrap;\n\tcursor: pointer;\n\t-webkit-tap-highlight-color: transparent;\n}\n\n.aform_dropdown-button:focus,\n.aform_dropdown-button:focus-visible {\n\toutline: none;\n\tbox-shadow: none;\n}\n\n.aform_dropdown-button::-moz-focus-inner {\n\tborder: 0;\n\tpadding: 0;\n}\n\n/* Merged fields (quantity UOM): same surface as the sibling input, not a nested addon chip. */\n.aform_form-element--embedded .aform_dropdown-button {\n\tbackground: transparent;\n}\n\n.aform_dropdown-button:disabled {\n\tcursor: not-allowed;\n\tcolor: var(--sc-gray-50);\n}\n\n.aform_dropdown-button-value {\n\tflex: 1;\n\tmin-width: 0;\n\ttext-align: left;\n}\n\n.aform_dropdown-button-caret {\n\tdisplay: inline-block;\n\twidth: 0;\n\theight: 0;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tborder-top: 0.3em solid currentColor;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element acurrency\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayText }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div class=\"acurrency__row\">\n\t\t\t\t<div class=\"acurrency__field acurrency__field--amount\">\n\t\t\t\t\t<div class=\"acurrency__group\">\n\t\t\t\t\t\t<div class=\"acurrency__currency\" @click=\"focusCurrencyPicker\">\n\t\t\t\t\t\t\t<ADropdown\n\t\t\t\t\t\t\t\tref=\"currencyDropdownRef\"\n\t\t\t\t\t\t\t\tv-model:link-value=\"currency\"\n\t\t\t\t\t\t\t\tlink\n\t\t\t\t\t\t\t\tembedded\n\t\t\t\t\t\t\t\tlist-anchor=\"group\"\n\t\t\t\t\t\t\t\t:mode=\"mode\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:placeholder=\"currencyLabel\"\n\t\t\t\t\t\t\t\t:aria-label=\"currencyLabel\"\n\t\t\t\t\t\t\t\t:formatter=\"formatCurrencySymbol\"\n\t\t\t\t\t\t\t\t:doctype=\"options.doctype\"\n\t\t\t\t\t\t\t\t:link-filter-function=\"options.filterFunction\"\n\t\t\t\t\t\t\t\t:is-async=\"options.isAsync\">\n\t\t\t\t\t\t\t\t<template #option=\"{ option }\"\n\t\t\t\t\t\t\t\t\t>{{ option.symbol ? `${option.symbol} — ` : '' }}{{ option.displayText ?? option.id }}</template\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t</ADropdown>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"acurrency__amount-wrap\">\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tv-if=\"amountMaskEnabled\"\n\t\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\t\t:value=\"amountText\"\n\t\t\t\t\t\t\t\tclass=\"acurrency__amount\"\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tinputmode=\"decimal\"\n\t\t\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t\t@focus=\"onAmountFocus\"\n\t\t\t\t\t\t\t\t@blur=\"onAmountBlur\"\n\t\t\t\t\t\t\t\t@input=\"onAmountInput\"\n\t\t\t\t\t\t\t\t@keydown=\"onAmountKeydownMasked\"\n\t\t\t\t\t\t\t\t@paste=\"onAmountPasteMasked\" />\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\t\tv-model.number=\"amount\"\n\t\t\t\t\t\t\t\tclass=\"acurrency__amount\"\n\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t\t@keydown=\"onAmountKeydown\"\n\t\t\t\t\t\t\t\t@paste=\"onAmountPaste\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"acurrency__field acurrency__field--base-currency\" aria-hidden=\"true\">\n\t\t\t\t\t<input type=\"text\" readonly tabindex=\"-1\" :value=\"baseCurrencyText\" />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<p v-if=\"showBase && !errorText\" :id=\"helperId\" class=\"acurrency__helper\">{{ conversionHelperText }}</p>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport {\n\tcurrencyAmountEntryPattern,\n\tcurrencyInputFractionDigits,\n\tformatCurrencyAmount,\n\tformatCurrencyAmountInput,\n\tformatCurrencySymbol,\n\tparseCurrencyAmountInput,\n} from '@stonecrop/utilities'\nimport { computed, inject, ref, useTemplateRef, watch } from 'vue'\n\nimport type { AFormLinkValue, ComponentProps, CurrencyOptions, CurrencyValue } from '../../types'\nimport {\n\tnormalizeBaseCurrency,\n\tpatchCurrencyAmount,\n\tpatchCurrencyCurrency,\n\trecomputeCurrencyValue,\n} from '../../utils/currencyValue'\nimport { numberFromBox } from '../../utils/emptiedBox'\nimport { asLinkValue, linkId } from '../../utils/linkValue'\nimport { numberFromRecord } from '../../utils/recordNumber'\nimport ADropdown from './ADropdown.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\toptions = {},\n\tcurrencyLabel = 'Currency',\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: CurrencyOptions\n\t\tcurrencyLabel?: string\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst helperId = computed(() => (uuid ? `${uuid}-helper` : undefined))\n\n// No default: a field with no value shows empty, as null does, rather than a rate nobody entered.\nconst modelValue = defineModel<CurrencyValue | null>()\n\n// The base figures are worked out from the amount, currency, rate and options rather than read from\n// the value: when its parts are fields of their own, no field holds them, and those fields hold what the\n// server sent (a bare currency id, decimal text). Only what is shown is read this way; an edit writes\n// back the parts it leaves alone exactly as they came.\nconst shown = computed(() => {\n\tconst boxValue = modelValue.value\n\tif (!boxValue) return null\n\tconst readValue = { ...boxValue, currency: asLinkValue(boxValue.currency) }\n\treturn recomputeCurrencyValue(\n\t\tnumberFromRecord(boxValue.amount),\n\t\treadValue.currency,\n\t\toptions,\n\t\tnormalizeBaseCurrency(options, boxValue),\n\t\treadValue\n\t)\n})\n\nconst showBase = computed(() => {\n\tconst shownValue = shown.value\n\treturn (\n\t\t!!shownValue?.baseCurrency?.id &&\n\t\t(shownValue.currency?.id !== shownValue.baseCurrency?.id || shownValue.amount !== shownValue.baseAmount)\n\t)\n})\n\nconst helperDescribedBy = computed(() => (showBase.value && !errorText.value ? helperId.value : undefined))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText, helperDescribedBy)\n\nconst currencyDropdownRef = useTemplateRef<{ openCurrencyList?: () => void }>('currencyDropdownRef')\n\nconst openCurrencyList = () => {\n\tcurrencyDropdownRef.value?.openCurrencyList?.()\n}\n\nconst focusCurrencyPicker = (event: MouseEvent) => {\n\tconst root = event.currentTarget as HTMLElement\n\tif ((event.target as HTMLElement).closest('input')) {\n\t\topenCurrencyList()\n\t\treturn\n\t}\n\tconst input = root.querySelector<HTMLInputElement>('input[role=\"combobox\"]')\n\tinput?.focus()\n\topenCurrencyList()\n}\n\nconst amountMaskEnabled = computed(() => options.amountMask !== false)\nconst amountFocused = ref(false)\nconst amountText = ref('')\n\nconst selectedCurrencyId = computed(() => linkId(modelValue.value?.currency) ?? '')\n\nconst syncAmountTextFromModel = () => {\n\tamountText.value = formatCurrencyAmountInput(modelValue.value?.amount ?? null, selectedCurrencyId.value)\n}\n\nwatch(selectedCurrencyId, () => {\n\tif (!amountFocused.value) syncAmountTextFromModel()\n})\n\nwatch(\n\t() => modelValue.value?.amount,\n\t() => {\n\t\tif (!amountFocused.value) syncAmountTextFromModel()\n\t},\n\t{ immediate: true }\n)\n\n// The base currency is fixed configuration, not user-editable. It may be supplied as a bare id\n// (resolved to displayText below via the same `aformLinkResolver` injection AFormLink uses) or\n// as a full AFormLinkValue that already carries displayText.\nconst normalizedBaseCurrency = computed<AFormLinkValue>(() => normalizeBaseCurrency(options, modelValue.value))\n\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\nconst resolvedBaseCurrency = ref<AFormLinkValue>(normalizedBaseCurrency.value)\n\nwatch(\n\tnormalizedBaseCurrency,\n\tasync base => {\n\t\tif (!base.id || base.displayText || !resolver || !options.doctype) {\n\t\t\tresolvedBaseCurrency.value = base\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst displayText = await resolver(options.doctype, String(base.id))\n\t\t\tresolvedBaseCurrency.value = displayText ? { ...base, displayText } : base\n\t\t} catch {\n\t\t\tresolvedBaseCurrency.value = base\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst baseCurrencyText = computed(() => {\n\tconst base = resolvedBaseCurrency.value\n\tif (!base?.id) return ''\n\treturn base.displayText ?? String(base.id)\n})\n\nconst amount = computed({\n\tget: () => modelValue.value?.amount ?? null,\n\tset: (value: number | '') =>\n\t\t(modelValue.value = patchCurrencyAmount(\n\t\t\tmodelValue.value,\n\t\t\tnumberFromBox(value),\n\t\t\toptions,\n\t\t\tresolvedBaseCurrency.value\n\t\t)),\n})\n\nconst currency = computed<AFormLinkValue>({\n\tget: () => modelValue.value?.currency ?? { id: '' },\n\tset: (value: AFormLinkValue) =>\n\t\t(modelValue.value = patchCurrencyCurrency(modelValue.value, value, options, resolvedBaseCurrency.value)),\n})\n\nconst amountNavigationKeys = new Set([\n\t'Backspace',\n\t'Delete',\n\t'Tab',\n\t'Escape',\n\t'Enter',\n\t'ArrowLeft',\n\t'ArrowRight',\n\t'ArrowUp',\n\t'ArrowDown',\n\t'Home',\n\t'End',\n])\n\nconst onAmountKeydown = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (amountNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\t// A currency amount is signed — credit notes, refunds and adjustments are negative.\n\t//\n\t// Both dedup checks below are best-effort: a `type=\"number\"` input reports `value` as `''`\n\t// whenever its content isn't a valid number, so mid-entry states like \"1.\" or \"-\" read as\n\t// empty and a second separator can slip through. The browser rejects the resulting value\n\t// anyway; this guard exists to stop the obviously-wrong keys (letters, 'e', '+'), not to be\n\t// the sole arbiter of well-formedness.\n\tconst input = event.target as HTMLInputElement\n\tif (event.key === '.' && !input.value.includes('.')) return\n\tif (event.key === '-' && !input.value.includes('-')) return\n\tevent.preventDefault()\n}\n\nconst onAmountPaste = (event: ClipboardEvent) => {\n\tconst pasted = event.clipboardData?.getData('text') ?? ''\n\tif (!/^-?\\d*\\.?\\d*$/.test(pasted)) event.preventDefault()\n}\n\nconst onAmountFocus = (event: FocusEvent) => {\n\tamountFocused.value = true\n\tconst input = event.target as HTMLInputElement | null\n\tif (input) requestAnimationFrame(() => input.select())\n}\n\nconst onAmountBlur = () => {\n\tamountFocused.value = false\n\tconst parsed = parseCurrencyAmountInput(amountText.value)\n\tmodelValue.value = patchCurrencyAmount(modelValue.value, parsed, options, resolvedBaseCurrency.value)\n\tsyncAmountTextFromModel()\n}\n\nconst onAmountInput = (event: Event) => {\n\tconst input = event.target as HTMLInputElement\n\tamountText.value = input.value\n\tconst parsed = parseCurrencyAmountInput(amountText.value)\n\tif (amountText.value.trim() === '' || amountText.value.trim() === '-' || parsed !== null) {\n\t\tmodelValue.value = patchCurrencyAmount(modelValue.value, parsed, options, resolvedBaseCurrency.value)\n\t}\n}\n\nconst onAmountKeydownMasked = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (amountNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\tif (event.key === '-') {\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('-') && input.selectionStart === 0) return\n\t}\n\tif (event.key === '.' || event.key === ',') {\n\t\tif (currencyInputFractionDigits(selectedCurrencyId.value) === 0) {\n\t\t\tevent.preventDefault()\n\t\t\treturn\n\t\t}\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('.') && !input.value.includes(',')) return\n\t}\n\tconst pattern = currencyAmountEntryPattern(selectedCurrencyId.value)\n\tconst input = event.target as HTMLInputElement\n\tconst { selectionStart, selectionEnd, value } = input\n\tif (selectionStart === null || selectionEnd === null) {\n\t\tevent.preventDefault()\n\t\treturn\n\t}\n\tconst next = value.slice(0, selectionStart) + event.key + value.slice(selectionEnd)\n\tif (event.key.length === 1 && !pattern.test(next)) event.preventDefault()\n}\n\n// The box's text once pasted, as a table cell checks it: \".5\" pasted after \"12.3\" is no amount.\nconst onAmountPasteMasked = (event: ClipboardEvent) => {\n\tconst input = event.target as HTMLInputElement\n\tconst pasted = (event.clipboardData?.getData('text') ?? '').trim()\n\tconst text = input.value.slice(0, input.selectionStart ?? 0) + pasted + input.value.slice(input.selectionEnd ?? 0)\n\tif (!currencyAmountEntryPattern(selectedCurrencyId.value).test(text)) event.preventDefault()\n}\n\nconst conversionHelperText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || shownValue.baseAmount === null || shownValue.amount === null) return ''\n\tconst baseLabel = baseCurrencyText.value || String(shownValue.baseCurrency?.id ?? '')\n\tconst enteredId = String(shownValue.currency?.id ?? '')\n\tconst rate = shownValue.exchangeRate\n\treturn `≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)} · 1 ${enteredId} = ${rate} ${baseLabel}`\n})\n\nconst displayText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || !shownValue.currency?.id || shownValue.amount === null) return '—'\n\tconst base = formatCurrencyAmount(shownValue.amount, shownValue.currency)\n\tif (!showBase.value) return base\n\treturn `${base} (≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)})`\n})\n</script>\n\n<style scoped>\n.acurrency__row {\n\tdisplay: flex;\n\tgap: 1ch;\n}\n\n.acurrency__field {\n\tposition: relative;\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.acurrency__field--base-currency {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.acurrency__group {\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius);\n}\n\n.acurrency__group:focus-within {\n\tborder-color: var(--sc-input-active-border-color);\n}\n\n/* Solid form surface behind long labels; the shared gradient only masks the top half and reads\n poorly over the merged prefix + amount backgrounds. Matches the field's page/form parent. */\n.acurrency__group > .aform_field-label {\n\tbackground: var(--sc-form-background);\n}\n\n.acurrency__amount-wrap {\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.acurrency__amount {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tborder: none;\n\toutline: none;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\tbackground: transparent;\n\tborder-radius: 0 var(--sc-border-radius) var(--sc-border-radius) 0;\n\ttext-align: right;\n\tappearance: textfield;\n\t-moz-appearance: textfield;\n}\n\n.acurrency__amount::-webkit-outer-spin-button,\n.acurrency__amount::-webkit-inner-spin-button {\n\tappearance: none;\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n/* The currency picker reads as a simple prefix addon (like Bootstrap's \"$\" prepend) rather\n than an equal partner to the amount box: fixed compact width (symbol or short code like NZD),\n tinted background, left-rounded to match the group's own\n corner so the tint doesn't overhang the border. The dropdown itself isn't bound by this\n width — ADropdown list spans the group — so search results still show full names. */\n.acurrency__currency {\n\t/* Fixed minimum prefix: 3rem content band + 1ch inset each side (fits NZD without shifting). */\n\tflex: 0 0 calc(3rem + 2ch);\n\twidth: calc(3rem + 2ch);\n\tmin-width: calc(3rem + 2ch);\n\tmax-width: calc(3rem + 2ch);\n\tbox-sizing: border-box;\n\tcursor: pointer;\n\tbackground: var(--sc-input-addon-background);\n\tborder-right: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius) 0 0 var(--sc-border-radius);\n}\n\n.acurrency__currency :deep(.aform_input-field--embedded) {\n\tpadding-left: 1ch;\n\tpadding-right: 1ch;\n\ttext-align: right;\n}\n\n.acurrency__currency :deep(.aform_form-element--embedded),\n.acurrency__currency :deep(.autocomplete) {\n\tposition: static;\n}\n\n.acurrency__group :deep(.autocomplete-results--anchor-group) {\n\tleft: -1px;\n\tright: -1px;\n\tbox-sizing: border-box;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.acurrency__helper {\n\tmargin: 0.5rem 0 0;\n\tfont-size: 0.85rem;\n\tcolor: var(--sc-cell-text-color);\n\topacity: 0.75;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element acurrency\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayText }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div class=\"acurrency__row\">\n\t\t\t\t<div class=\"acurrency__field acurrency__field--amount\">\n\t\t\t\t\t<div class=\"acurrency__group\">\n\t\t\t\t\t\t<div class=\"acurrency__currency\" @click=\"focusCurrencyPicker\">\n\t\t\t\t\t\t\t<ADropdown\n\t\t\t\t\t\t\t\tref=\"currencyDropdownRef\"\n\t\t\t\t\t\t\t\tv-model:link-value=\"currency\"\n\t\t\t\t\t\t\t\tlink\n\t\t\t\t\t\t\t\tembedded\n\t\t\t\t\t\t\t\tlist-anchor=\"group\"\n\t\t\t\t\t\t\t\t:mode=\"mode\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:placeholder=\"currencyLabel\"\n\t\t\t\t\t\t\t\t:aria-label=\"currencyLabel\"\n\t\t\t\t\t\t\t\t:formatter=\"formatCurrencySymbol\"\n\t\t\t\t\t\t\t\t:doctype=\"options.doctype\"\n\t\t\t\t\t\t\t\t:link-filter-function=\"options.filterFunction\"\n\t\t\t\t\t\t\t\t:is-async=\"options.isAsync\">\n\t\t\t\t\t\t\t\t<template #option=\"{ option }\"\n\t\t\t\t\t\t\t\t\t>{{ option.symbol ? `${option.symbol} — ` : '' }}{{ option.displayText ?? option.id }}</template\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t</ADropdown>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"acurrency__amount-wrap\">\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tv-if=\"amountMaskEnabled\"\n\t\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\t\t:value=\"amountText\"\n\t\t\t\t\t\t\t\tclass=\"acurrency__amount\"\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tinputmode=\"decimal\"\n\t\t\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t\t@focus=\"onAmountFocus\"\n\t\t\t\t\t\t\t\t@blur=\"onAmountBlur\"\n\t\t\t\t\t\t\t\t@input=\"onAmountInput\"\n\t\t\t\t\t\t\t\t@keydown=\"onAmountKeydownMasked\"\n\t\t\t\t\t\t\t\t@paste=\"onAmountPasteMasked\" />\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\t\tv-model.number=\"amount\"\n\t\t\t\t\t\t\t\tclass=\"acurrency__amount\"\n\t\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t\t@keydown=\"onAmountKeydown\"\n\t\t\t\t\t\t\t\t@paste=\"onAmountPaste\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"acurrency__field acurrency__field--base-currency\" aria-hidden=\"true\">\n\t\t\t\t\t<input type=\"text\" readonly tabindex=\"-1\" :value=\"baseCurrencyText\" />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<p v-if=\"showBase && !errorText\" :id=\"helperId\" class=\"acurrency__helper\">{{ conversionHelperText }}</p>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport {\n\tcurrencyAmountEntryPattern,\n\tcurrencyInputFractionDigits,\n\tformatCurrencyAmount,\n\tformatCurrencyAmountInput,\n\tformatCurrencySymbol,\n\tparseCurrencyAmountInput,\n} from '@stonecrop/utilities'\nimport { computed, inject, ref, useTemplateRef, watch } from 'vue'\n\nimport type { AFormLinkValue, ComponentProps, CurrencyOptions, CurrencyValue } from '../../types'\nimport {\n\tnormalizeBaseCurrency,\n\tpatchCurrencyAmount,\n\tpatchCurrencyCurrency,\n\trecomputeCurrencyValue,\n} from '../../utils/currencyValue'\nimport { numberFromBox } from '../../utils/emptiedBox'\nimport { asLinkValue, linkId } from '../../utils/linkValue'\nimport { numberFromRecord } from '../../utils/recordNumber'\nimport ADropdown from './ADropdown.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\toptions = {},\n\tcurrencyLabel = 'Currency',\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: CurrencyOptions\n\t\tcurrencyLabel?: string\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst helperId = computed(() => (uuid ? `${uuid}-helper` : undefined))\n\n// No default: a field with no value shows empty, as null does, rather than a rate nobody entered.\nconst modelValue = defineModel<CurrencyValue | null>()\n\n// The base figures are worked out from the amount, currency, rate and options rather than read from\n// the value: when its parts are fields of their own, no field holds them, and those fields hold what the\n// server sent (a bare currency id, decimal text). Only what is shown is read this way; an edit writes\n// back the parts it leaves alone exactly as they came.\nconst shown = computed(() => {\n\tconst boxValue = modelValue.value\n\tif (!boxValue) return null\n\tconst readValue = { ...boxValue, currency: asLinkValue(boxValue.currency) }\n\treturn recomputeCurrencyValue(\n\t\tnumberFromRecord(boxValue.amount),\n\t\treadValue.currency,\n\t\toptions,\n\t\tnormalizeBaseCurrency(options, boxValue),\n\t\treadValue\n\t)\n})\n\nconst showBase = computed(() => {\n\tconst shownValue = shown.value\n\treturn (\n\t\t!!shownValue?.baseCurrency?.id &&\n\t\t(shownValue.currency?.id !== shownValue.baseCurrency?.id || shownValue.amount !== shownValue.baseAmount)\n\t)\n})\n\nconst helperDescribedBy = computed(() => (showBase.value && !errorText.value ? helperId.value : undefined))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText, helperDescribedBy)\n\nconst currencyDropdownRef = useTemplateRef<{ openCurrencyList?: () => void }>('currencyDropdownRef')\n\nconst openCurrencyList = () => {\n\tcurrencyDropdownRef.value?.openCurrencyList?.()\n}\n\nconst focusCurrencyPicker = (event: MouseEvent) => {\n\tconst root = event.currentTarget as HTMLElement\n\tif ((event.target as HTMLElement).closest('input')) {\n\t\topenCurrencyList()\n\t\treturn\n\t}\n\tconst input = root.querySelector<HTMLInputElement>('input[role=\"combobox\"]')\n\tinput?.focus()\n\topenCurrencyList()\n}\n\nconst amountMaskEnabled = computed(() => options.amountMask !== false)\nconst amountFocused = ref(false)\nconst amountText = ref('')\n\nconst selectedCurrencyId = computed(() => linkId(modelValue.value?.currency) ?? '')\n\nconst syncAmountTextFromModel = () => {\n\tamountText.value = formatCurrencyAmountInput(modelValue.value?.amount ?? null, selectedCurrencyId.value)\n}\n\nwatch(selectedCurrencyId, () => {\n\tif (!amountFocused.value) syncAmountTextFromModel()\n})\n\nwatch(\n\t() => modelValue.value?.amount,\n\t() => {\n\t\tif (!amountFocused.value) syncAmountTextFromModel()\n\t},\n\t{ immediate: true }\n)\n\n// The base currency is fixed configuration, not user-editable. It may be supplied as a bare id\n// (resolved to displayText below via the same `aformLinkResolver` injection AFormLink uses) or\n// as a full AFormLinkValue that already carries displayText.\nconst normalizedBaseCurrency = computed<AFormLinkValue>(() => normalizeBaseCurrency(options, modelValue.value))\n\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\nconst resolvedBaseCurrency = ref<AFormLinkValue>(normalizedBaseCurrency.value)\n\nwatch(\n\tnormalizedBaseCurrency,\n\tasync base => {\n\t\tif (!base.id || base.displayText || !resolver || !options.doctype) {\n\t\t\tresolvedBaseCurrency.value = base\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst displayText = await resolver(options.doctype, String(base.id))\n\t\t\tresolvedBaseCurrency.value = displayText ? { ...base, displayText } : base\n\t\t} catch {\n\t\t\tresolvedBaseCurrency.value = base\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst baseCurrencyText = computed(() => {\n\tconst base = resolvedBaseCurrency.value\n\tif (!base?.id) return ''\n\treturn base.displayText ?? String(base.id)\n})\n\nconst amount = computed({\n\tget: () => modelValue.value?.amount ?? null,\n\tset: (value: number | '') =>\n\t\t(modelValue.value = patchCurrencyAmount(\n\t\t\tmodelValue.value,\n\t\t\tnumberFromBox(value),\n\t\t\toptions,\n\t\t\tresolvedBaseCurrency.value\n\t\t)),\n})\n\nconst currency = computed<AFormLinkValue>({\n\tget: () => modelValue.value?.currency ?? { id: '' },\n\tset: (value: AFormLinkValue) =>\n\t\t(modelValue.value = patchCurrencyCurrency(modelValue.value, value, options, resolvedBaseCurrency.value)),\n})\n\nconst amountNavigationKeys = new Set([\n\t'Backspace',\n\t'Delete',\n\t'Tab',\n\t'Escape',\n\t'Enter',\n\t'ArrowLeft',\n\t'ArrowRight',\n\t'ArrowUp',\n\t'ArrowDown',\n\t'Home',\n\t'End',\n])\n\nconst onAmountKeydown = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (amountNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\t// A currency amount is signed — credit notes, refunds and adjustments are negative.\n\t//\n\t// Both dedup checks below are best-effort: a `type=\"number\"` input reports `value` as `''`\n\t// whenever its content isn't a valid number, so mid-entry states like \"1.\" or \"-\" read as\n\t// empty and a second separator can slip through. The browser rejects the resulting value\n\t// anyway; this guard exists to stop the obviously-wrong keys (letters, 'e', '+'), not to be\n\t// the sole arbiter of well-formedness.\n\tconst input = event.target as HTMLInputElement\n\tif (event.key === '.' && !input.value.includes('.')) return\n\tif (event.key === '-' && !input.value.includes('-')) return\n\tevent.preventDefault()\n}\n\nconst onAmountPaste = (event: ClipboardEvent) => {\n\tconst pasted = event.clipboardData?.getData('text') ?? ''\n\tif (!/^-?\\d*\\.?\\d*$/.test(pasted)) event.preventDefault()\n}\n\nconst onAmountFocus = (event: FocusEvent) => {\n\tamountFocused.value = true\n\tconst input = event.target as HTMLInputElement | null\n\tif (input) requestAnimationFrame(() => input.select())\n}\n\nconst onAmountBlur = () => {\n\tamountFocused.value = false\n\tconst parsed = parseCurrencyAmountInput(amountText.value)\n\tmodelValue.value = patchCurrencyAmount(modelValue.value, parsed, options, resolvedBaseCurrency.value)\n\tsyncAmountTextFromModel()\n}\n\nconst onAmountInput = (event: Event) => {\n\tconst input = event.target as HTMLInputElement\n\tamountText.value = input.value\n\tconst parsed = parseCurrencyAmountInput(amountText.value)\n\tif (amountText.value.trim() === '' || amountText.value.trim() === '-' || parsed !== null) {\n\t\tmodelValue.value = patchCurrencyAmount(modelValue.value, parsed, options, resolvedBaseCurrency.value)\n\t}\n}\n\nconst onAmountKeydownMasked = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (amountNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\tif (event.key === '-') {\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('-') && input.selectionStart === 0) return\n\t}\n\tif (event.key === '.' || event.key === ',') {\n\t\tif (currencyInputFractionDigits(selectedCurrencyId.value) === 0) {\n\t\t\tevent.preventDefault()\n\t\t\treturn\n\t\t}\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('.') && !input.value.includes(',')) return\n\t}\n\tconst pattern = currencyAmountEntryPattern(selectedCurrencyId.value)\n\tconst input = event.target as HTMLInputElement\n\tconst { selectionStart, selectionEnd, value } = input\n\tif (selectionStart === null || selectionEnd === null) {\n\t\tevent.preventDefault()\n\t\treturn\n\t}\n\tconst next = value.slice(0, selectionStart) + event.key + value.slice(selectionEnd)\n\tif (event.key.length === 1 && !pattern.test(next)) event.preventDefault()\n}\n\n// The box's text once pasted, as a table cell checks it: \".5\" pasted after \"12.3\" is no amount.\nconst onAmountPasteMasked = (event: ClipboardEvent) => {\n\tconst input = event.target as HTMLInputElement\n\tconst pasted = (event.clipboardData?.getData('text') ?? '').trim()\n\tconst text = input.value.slice(0, input.selectionStart ?? 0) + pasted + input.value.slice(input.selectionEnd ?? 0)\n\tif (!currencyAmountEntryPattern(selectedCurrencyId.value).test(text)) event.preventDefault()\n}\n\nconst conversionHelperText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || shownValue.baseAmount === null || shownValue.amount === null) return ''\n\tconst baseLabel = baseCurrencyText.value || String(shownValue.baseCurrency?.id ?? '')\n\tconst enteredId = String(shownValue.currency?.id ?? '')\n\tconst rate = shownValue.exchangeRate\n\treturn `≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)} · 1 ${enteredId} = ${rate} ${baseLabel}`\n})\n\nconst displayText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || !shownValue.currency?.id || shownValue.amount === null) return '—'\n\tconst base = formatCurrencyAmount(shownValue.amount, shownValue.currency)\n\tif (!showBase.value) return base\n\treturn `${base} (≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)})`\n})\n</script>\n\n<style scoped>\n.acurrency__row {\n\tdisplay: flex;\n\tgap: 1ch;\n}\n\n.acurrency__field {\n\tposition: relative;\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.acurrency__field--base-currency {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.acurrency__group {\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius);\n}\n\n.acurrency__group:focus-within {\n\tborder-color: var(--sc-input-active-border-color);\n}\n\n/* Solid form surface behind long labels; the shared gradient only masks the top half and reads\n poorly over the merged prefix + amount backgrounds. Matches the field's page/form parent. */\n.acurrency__group > .aform_field-label {\n\tbackground: var(--sc-form-background);\n}\n\n.acurrency__amount-wrap {\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.acurrency__amount {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tborder: none;\n\toutline: none;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\tbackground: transparent;\n\tborder-radius: 0 var(--sc-border-radius) var(--sc-border-radius) 0;\n\ttext-align: right;\n\tappearance: textfield;\n\t-moz-appearance: textfield;\n}\n\n.acurrency__amount::-webkit-outer-spin-button,\n.acurrency__amount::-webkit-inner-spin-button {\n\tappearance: none;\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n/* The currency picker reads as a simple prefix addon (like Bootstrap's \"$\" prepend) rather\n than an equal partner to the amount box: fixed compact width (symbol or short code like NZD),\n tinted background, left-rounded to match the group's own\n corner so the tint doesn't overhang the border. The dropdown itself isn't bound by this\n width — ADropdown list spans the group — so search results still show full names. */\n.acurrency__currency {\n\t/* Fixed minimum prefix: 3rem content band + 1ch inset each side (fits NZD without shifting). */\n\tflex: 0 0 calc(3rem + 2ch);\n\twidth: calc(3rem + 2ch);\n\tmin-width: calc(3rem + 2ch);\n\tmax-width: calc(3rem + 2ch);\n\tbox-sizing: border-box;\n\tcursor: pointer;\n\tbackground: var(--sc-input-addon-background);\n\tborder-right: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius) 0 0 var(--sc-border-radius);\n}\n\n.acurrency__currency :deep(.aform_input-field--embedded) {\n\tpadding-left: 1ch;\n\tpadding-right: 1ch;\n\ttext-align: right;\n}\n\n.acurrency__currency :deep(.aform_form-element--embedded),\n.acurrency__currency :deep(.autocomplete) {\n\tposition: static;\n}\n\n.acurrency__group :deep(.autocomplete-results--anchor-group) {\n\tleft: -1px;\n\tright: -1px;\n\tbox-sizing: border-box;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.acurrency__helper {\n\tmargin: 0.5rem 0 0;\n\tfont-size: 0.85rem;\n\tcolor: var(--sc-cell-text-color);\n\topacity: 0.75;\n}\n</style>\n","import { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\n\n// The locale's numeric day in the Gregorian calendar with Western digits, whatever the locale's own\n// calendar and digits, so that `readTypedDay` reads back what `writeTypedDay` writes.\nconst TYPED_DAY_FORMAT: Intl.DateTimeFormatOptions = { calendar: 'gregory', numberingSystem: 'latn' }\n\n/**\n * A day written as the locale writes it in numbers, for a box a user types days into.\n * @param locale - The browser's own when omitted\n */\nexport function writeTypedDay(day: Temporal.PlainDate, locale?: string): string {\n\treturn day.toLocaleString(locale, TYPED_DAY_FORMAT)\n}\n\n/**\n * Reads a day typed as `writeTypedDay` writes it, or as `YYYY-MM-DD`. Any other text, or a day that does\n * not exist, reads as no day. Not `new Date(text)`, which reads `YYYY-MM-DD` as UTC midnight and rolls an\n * impossible day over.\n * @param locale - The browser's own when omitted\n */\nexport function readTypedDay(text: string, locale?: string): Temporal.PlainDate | undefined {\n\tconst isoDay = fromISODate(text.trim())\n\tif (isoDay) return isoDay\n\n\tconst numbers = text.match(/\\d+/g)\n\tif (numbers?.length !== 3) return undefined\n\tconst order = new Intl.DateTimeFormat(locale, TYPED_DAY_FORMAT)\n\t\t.formatToParts(0)\n\t\t.map(part => part.type)\n\t\t.filter(type => type === 'year' || type === 'month' || type === 'day')\n\tconst typed = Object.fromEntries(order.map((type, index) => [type, numbers[index]]))\n\tif (typed.year?.length !== 4) return undefined\n\n\ttry {\n\t\treturn Temporal.PlainDate.from(\n\t\t\t{ year: Number(typed.year), month: Number(typed.month), day: Number(typed.day) },\n\t\t\t{ overflow: 'reject' }\n\t\t)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n","<template>\n\t<template v-if=\"mode === 'display' || mode === 'read'\">\n\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t<label v-if=\"label\">{{ label }}</label>\n\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t</template>\n\t<template v-else>\n\t\t<div class=\"adatepicker\">\n\t\t\t<table ref=\"grid\" role=\"grid\" :aria-label=\"monthAndYear\" @mousedown=\"preventCellSelection\">\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td id=\"previous-month-btn\" :tabindex=\"-1\" @click=\"previousMonth\"><</td>\n\t\t\t\t\t\t<th colspan=\"5\" :tabindex=\"-1\">{{ monthAndYear }}</th>\n\t\t\t\t\t\t<td id=\"next-month-btn\" :tabindex=\"-1\" @click=\"nextMonth\">></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr v-if=\"selectRange\">\n\t\t\t\t\t\t<td colspan=\"7\" class=\"range-inputs\">\n\t\t\t\t\t\t\t<div class=\"date-input\">\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tref=\"start-date-input\"\n\t\t\t\t\t\t\t\t\t:value=\"getStartDate\"\n\t\t\t\t\t\t\t\t\tclass=\"date-input-start aform_input-field\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"start date\"\n\t\t\t\t\t\t\t\t\t@blur=\"enterInputDate()\"\n\t\t\t\t\t\t\t\t\t@keydown=\"enterDate\" />\n\t\t\t\t\t\t\t\t<div>-</div>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tref=\"end-date-input\"\n\t\t\t\t\t\t\t\t\t:value=\"getEndDate\"\n\t\t\t\t\t\t\t\t\tclass=\"date-input-end aform_input-field\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"end date\"\n\t\t\t\t\t\t\t\t\t@blur=\"enterInputDate()\"\n\t\t\t\t\t\t\t\t\t@keydown=\"enterDate\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<!-- {{ formattedDateRange }} -->\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class=\"days-header\">\n\t\t\t\t\t\t<td v-for=\"(letter, weekdayIndex) in weekdayLetters\" :key=\"weekdayIndex\">{{ letter }}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr v-for=\"rowNo in numberOfRows\" :key=\"rowNo\">\n\t\t\t\t\t\t<!-- the 'ref' key is currently only used for test references -->\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-for=\"colNo in numberOfColumns\"\n\t\t\t\t\t\t\tref=\"celldate\"\n\t\t\t\t\t\t\t:key=\"getCurrentCell(rowNo, colNo)\"\n\t\t\t\t\t\t\tclass=\"date-cell\"\n\t\t\t\t\t\t\t:contenteditable=\"false\"\n\t\t\t\t\t\t\t:spellcheck=\"false\"\n\t\t\t\t\t\t\t:tabindex=\"getCurrentDate(rowNo, colNo).equals(focusedDay) ? 0 : -1\"\n\t\t\t\t\t\t\t:aria-label=\"fullDate(getCurrentDate(rowNo, colNo))\"\n\t\t\t\t\t\t\t:aria-selected=\"isPicked(getCurrentDate(rowNo, colNo))\"\n\t\t\t\t\t\t\t:aria-current=\"isTodaysDate(getCurrentDate(rowNo, colNo)) ? 'date' : undefined\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\ttodaysDate: isTodaysDate(getCurrentDate(rowNo, colNo)),\n\t\t\t\t\t\t\t\tselectedDate: isSelectedDate(getCurrentDate(rowNo, colNo)),\n\t\t\t\t\t\t\t\twithinRange: selectRange ? isInDateRange(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t\tstartDate: selectRange ? isStartDate(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t\tendDate: selectRange ? isEndDate(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@click.prevent.stop=\"selectDate(getCurrentCell(rowNo, colNo))\"\n\t\t\t\t\t\t\t@keydown=\"onDayKeydown($event, getCurrentCell(rowNo, colNo))\"\n\t\t\t\t\t\t\t@mouseover=\"hoverDate(getCurrentCell(rowNo, colNo))\">\n\t\t\t\t\t\t\t{{ getCurrentDate(rowNo, colNo).day }}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t</template>\n</template>\n\n<script setup lang=\"ts\">\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { readTypedDay, writeTypedDay } from '../../utils/typedDay'\n\nconst numberOfRows = 6\nconst numberOfColumns = 7\n\nconst {\n\tmode,\n\tlabel,\n\tselectRange = false,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n} = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId } = fieldErrorA11y(uuid, errorText)\n\n// The calendar holds a `YYYY-MM-DD` day, and opens on today when it holds none it can read. No default\n// value: picking today on an empty calendar must still set it, and a model only reports a change.\nconst date = defineModel<string | null>()\nconst selectedDate = ref<Temporal.PlainDate>(fromISODate(date.value ?? '') ?? Temporal.Now.plainDateISO())\n// 0 for January.\nconst currentMonth = ref<number>(selectedDate.value.month - 1)\nconst currentYear = ref<number>(selectedDate.value.year)\nconst currentDates = ref<Temporal.PlainDate[]>([])\n\n// The day the grid's one Tab stop sits on, where its keys move from. It is always a day the grid shows.\nconst focusedDay = ref<Temporal.PlainDate>(selectedDate.value)\nconst grid = useTemplateRef<HTMLTableElement>('grid')\n\nconst hoveredDate = ref<Temporal.PlainDate>(selectedDate.value)\nconst start_date = ref<Temporal.PlainDate | null>(null)\nconst end_date = ref<Temporal.PlainDate | null>(null)\nconst startDateInput = useTemplateRef<HTMLInputElement>('start-date-input')\nconst endDateInput = useTemplateRef<HTMLInputElement>('end-date-input')\n\n/*******************\nEmits\n*******************/\n\nconst emit = defineEmits<{\n\t'get-date': [{ start: string | null; end: string | null; selected: string }]\n}>()\n\n/*******************\nComputed\n*******************/\n\nconst displayValue = computed(() => (date.value ? (fromISODate(date.value)?.toLocaleString() ?? 'Invalid Date') : ''))\n\nconst firstOfMonth = computed(() =>\n\tTemporal.PlainDate.from({ year: currentYear.value, month: currentMonth.value + 1, day: 1 })\n)\n\n// Not a `PlainYearMonth`: its `toLocaleString` throws for the ISO calendar.\nconst monthAndYear = computed(() => firstOfMonth.value.toLocaleString(undefined, { year: 'numeric', month: 'long' }))\n\n// The grid's first week, so the letters follow its Monday start.\nconst weekdayLetters = computed(() =>\n\tcurrentDates.value.slice(0, numberOfColumns).map(day => day.toLocaleString(undefined, { weekday: 'narrow' }))\n)\n\nconst getStartDate = computed(() => boxText(start_date.value))\n\nconst getEndDate = computed(() => boxText(end_date.value))\n\n/*******************\nFunctions\n*******************/\n\nconst boxText = (day: Temporal.PlainDate | null) => (day ? writeTypedDay(day) : '')\n\nconst isTodaysDate = (day: Temporal.PlainDate): boolean => {\n\tconst today = Temporal.Now.plainDateISO()\n\tif (currentMonth.value !== today.month - 1) return false\n\treturn day.equals(today)\n}\n\nconst isSelectedDate = (day: Temporal.PlainDate) => {\n\treturn day.equals(selectedDate.value)\n}\n\nconst isStartDate = (day: Temporal.PlainDate) => {\n\treturn start_date.value !== null && day.equals(start_date.value)\n}\n\nconst isEndDate = (day: Temporal.PlainDate) => {\n\treturn end_date.value !== null && day.equals(end_date.value)\n}\n\n// Every day the calendar marks as picked, so a screen reader hears the same days marked.\nconst isPicked = (day: Temporal.PlainDate) =>\n\tisSelectedDate(day) || (selectRange && (isStartDate(day) || isEndDate(day)))\n\nconst fullDate = (day: Temporal.PlainDate) =>\n\tday.toLocaleString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })\n\nconst getCurrentCell = (rowNo: number, colNo: number) => {\n\treturn (rowNo - 1) * numberOfColumns + colNo - 1\n}\n\nconst isInDateRange = (day: Temporal.PlainDate) => {\n\tconst start = start_date.value\n\tif (!start) return false\n\n\t//the end is either the selected end date or wherever the user is hovering\n\tconst end = end_date.value ?? hoveredDate.value\n\n\treturn Temporal.PlainDate.compare(day, start) > 0 && Temporal.PlainDate.compare(day, end) < 0\n}\n\nconst getCurrentDate = (rowNo: number, colNo: number) => {\n\treturn currentDates.value[getCurrentCell(rowNo, colNo)]\n}\n\nconst hoverDate = (currentIndex: number) => {\n\thoveredDate.value = currentDates.value[currentIndex]\n}\n\n// browsers (notably Firefox) allow drag-selecting text across table cells even with\n// `user-select: none` on the cells; blocking mousedown is the reliable cross-browser fix.\n// the start/end-date inputs must keep native mousedown behavior so they stay focusable/typable.\nconst preventCellSelection = (event: MouseEvent) => {\n\tif ((event.target as HTMLElement)?.tagName !== 'INPUT') {\n\t\tevent.preventDefault()\n\t}\n}\n\nconst populateMonth = () => {\n\t// The grid starts on the Monday on or before the 1st, matching the header's first column.\n\tconst gridStart = firstOfMonth.value.subtract({ days: firstOfMonth.value.dayOfWeek - 1 })\n\tcurrentDates.value = Array.from({ length: numberOfRows * numberOfColumns }, (_, cellIndex) =>\n\t\tgridStart.add({ days: cellIndex })\n\t)\n}\nconst previousYear = () => (currentYear.value -= 1)\nconst nextYear = () => (currentYear.value += 1)\n\nconst previousMonth = () => {\n\tif (currentMonth.value == 0) {\n\t\tcurrentMonth.value = 11\n\t\tpreviousYear()\n\t} else {\n\t\tcurrentMonth.value -= 1\n\t}\n}\n\nconst nextMonth = () => {\n\tif (currentMonth.value == 11) {\n\t\tcurrentMonth.value = 0\n\t\tnextYear()\n\t} else {\n\t\tcurrentMonth.value += 1\n\t}\n}\n\nconst enterDate = (event: KeyboardEvent) => {\n\tif (event.key === 'Enter') enterInputDate()\n}\n\n// The grid's keys move by day, not by table cell as `useKeyboardNav` does: that one can't cross into\n// another month, and on every cell it took the arrow keys from a range's typed-day boxes.\n/** The day a key moves focus to from `day`, or undefined for a key that moves nothing. */\nconst dayAfterKey = (event: KeyboardEvent, day: Temporal.PlainDate) => {\n\tswitch (event.key) {\n\t\tcase 'ArrowLeft':\n\t\t\treturn day.subtract({ days: 1 })\n\t\tcase 'ArrowRight':\n\t\t\treturn day.add({ days: 1 })\n\t\tcase 'ArrowUp':\n\t\t\treturn day.subtract({ weeks: 1 })\n\t\tcase 'ArrowDown':\n\t\t\treturn day.add({ weeks: 1 })\n\t\tcase 'PageUp':\n\t\t\treturn day.subtract(event.shiftKey ? { years: 1 } : { months: 1 })\n\t\tcase 'PageDown':\n\t\t\treturn day.add(event.shiftKey ? { years: 1 } : { months: 1 })\n\t\t// The grid's weeks run Monday, day 1, to Sunday, day 7.\n\t\tcase 'Home':\n\t\t\treturn day.subtract({ days: day.dayOfWeek - 1 })\n\t\tcase 'End':\n\t\t\treturn day.add({ days: 7 - day.dayOfWeek })\n\t}\n}\n\nconst focusTabStop = async () => {\n\tawait nextTick()\n\tgrid.value?.querySelector<HTMLElement>('[tabindex=\"0\"]')?.focus()\n}\n\nconst onDayKeydown = (event: KeyboardEvent, currentIndex: number) => {\n\tif (event.key === 'Enter' || event.key === ' ') {\n\t\tevent.preventDefault()\n\t\tselectDate(currentIndex)\n\t\treturn\n\t}\n\tconst next = dayAfterKey(event, focusedDay.value)\n\tif (!next) return\n\tevent.preventDefault()\n\tfocusedDay.value = next\n\tcurrentMonth.value = next.month - 1\n\tcurrentYear.value = next.year\n\tvoid focusTabStop()\n}\n\nconst selectDate = (currentIndex: number) => {\n\tconst picked = currentDates.value[currentIndex]\n\tselectedDate.value = picked\n\tfocusedDay.value = picked\n\t// A click leaves focus where it was, so focus follows a pick only when it is on a day already.\n\tif (document.activeElement instanceof HTMLTableCellElement && grid.value?.contains(document.activeElement)) {\n\t\tvoid focusTabStop()\n\t}\n\tdate.value = picked.toString()\n\n\tif (selectRange) {\n\t\tconst start = start_date.value\n\t\tif (start == null || end_date.value != null) {\n\t\t\tstart_date.value = picked\n\t\t\tend_date.value = null\n\t\t} else if (Temporal.PlainDate.compare(picked, start) < 0) {\n\t\t\tend_date.value = null\n\t\t\tstart_date.value = picked\n\t\t} else {\n\t\t\tend_date.value = picked\n\t\t}\n\t\tif (startDateInput.value) startDateInput.value.value = boxText(start_date.value)\n\t\tif (endDateInput.value) endDateInput.value.value = boxText(end_date.value)\n\t}\n\temitData()\n}\n\nconst testDateOrder = () => {\n\tconst start = start_date.value\n\tconst end = end_date.value\n\tif (start && end && Temporal.PlainDate.compare(end, start) < 0) [start_date.value, end_date.value] = [end, start]\n}\n\nconst enterInputDate = () => {\n\tif (startDateInput.value?.value == '') {\n\t\tstart_date.value = null\n\t} else if (startDateInput.value) {\n\t\tstart_date.value = readTypedDay(startDateInput.value.value) ?? null\n\t}\n\n\tif (endDateInput.value?.value == '') {\n\t\tend_date.value = null\n\t} else if (endDateInput.value) {\n\t\tend_date.value = readTypedDay(endDateInput.value.value) ?? null\n\t}\n\n\tif (start_date.value) {\n\t\tif (end_date.value) testDateOrder()\n\t\tselectedDate.value = start_date.value\n\t}\n\n\temitData()\n}\n\nconst emitData = () => {\n\temit('get-date', {\n\t\tstart: selectRange ? (start_date.value?.toString() ?? null) : null,\n\t\tend: selectRange ? (end_date.value?.toString() ?? null) : null,\n\t\tselected: selectedDate.value.toString(),\n\t})\n}\n\n/*******************\nHooks\n*******************/\n\n// The calendar takes no focus when it appears: a field opening it keeps focus in its box, where typing goes.\npopulateMonth()\n\n/*******************\nWatchers\n*******************/\n\nwatch([currentMonth, currentYear], () => {\n\tpopulateMonth()\n\t// The month buttons carry the Tab stop along, to the same day of the month shown.\n\tconst month = currentMonth.value + 1\n\tif (focusedDay.value.month !== month || focusedDay.value.year !== currentYear.value) {\n\t\tfocusedDay.value = focusedDay.value.with({ year: currentYear.value, month })\n\t}\n})\n\n// A day handed in, such as one typed into the field while the calendar is open. A pick here sets\n// `selectedDate` first, so picking a day of the next month in this grid leaves the month shown.\nwatch(date, value => {\n\tconst day = fromISODate(value ?? '')\n\tif (!day || day.equals(selectedDate.value)) return\n\tselectedDate.value = day\n\tfocusedDay.value = day\n\tcurrentMonth.value = day.month - 1\n\tcurrentYear.value = day.year\n})\n\n/*******************\nExpose\n*******************/\n\ndefineExpose({ currentMonth, currentYear, selectedDate: computed(() => selectedDate.value.toString()) })\n</script>\n\n<style scoped>\n.adatepicker,\n.adatepicker table,\n.adatepicker tr,\n.adatepicker td,\n.adatepicker th {\n\t-webkit-user-select: none;\n\t-moz-user-select: none;\n\tuser-select: none;\n}\n\n.adatepicker {\n\tfont-size: var(--sc-table-font-size);\n\tdisplay: inline-table;\n\tcolor: var(--sc-cell-text-color);\n\toutline: none;\n\tborder-collapse: collapse;\n\tmargin-bottom: 10px;\n\t/* width: calc(100% - 4px); */\n}\n\n.adatepicker tr {\n\theight: 1.15rem;\n\theight: 1.15rem;\n\ttext-align: center;\n\tvertical-align: middle;\n}\n\n.adatepicker td {\n\tborder: 2px solid transparent;\n\toutline: 2px solid transparent;\n\tmin-width: 3ch;\n\tmax-width: 3ch;\n\tcursor: pointer;\n}\n.adatepicker td.date-cell:hover {\n\tbackground: var(--sc-gray-10);\n}\n\n.adatepicker td.date-cell:focus-visible {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n\n.adatepicker td:focus,\n.adatepicker td:focus-within {\n\t/* outline: 1px dashed black; */\n\tbox-shadow: none;\n\toverflow: hidden;\n\tmin-height: 1.15em;\n\tmax-height: 1.15em;\n\toverflow: hidden;\n}\n.adatepicker .selectedDate,\n.adatepicker .startDate,\n.adatepicker .endDate {\n\t/* outline: 1px solid black; */\n\tbackground: var(--sc-gray-20);\n\tfont-weight: bolder;\n}\n.adatepicker .startDate {\n\t/* border-radius: 5px 0px 0px 5px; */\n\tborder-left: 1px solid var(--sc-gray-50);\n\tbackground: var(--sc-gray-20) !important;\n}\n.adatepicker .endDate {\n\tborder-right: 1px solid var(--sc-gray-50);\n\t/* border-radius: 0px 5px 5px 0px; */\n\tbackground: var(--sc-gray-20) !important;\n}\n.adatepicker .withinRange {\n\tbackground: var(--sc-gray-5);\n}\n\n.adatepicker .todaysDate {\n\tfont-weight: bolder;\n\t/* text-decoration: underline; */\n\tcolor: var(--sc-cell-text-color);\n}\n.days-header > td {\n\tfont-weight: bold;\n}\n.prev-date {\n\tcolor: var(--sc-gray-20);\n}\n\n.adatepicker .date-input {\n\tdisplay: flex;\n\twidth: 100%;\n\tgap: 5px;\n\talign-items: center;\n}\n/* The boxes' row widens the calendar past its 3ch day columns, so each box fits a day such as `04/09/2026`. */\n.adatepicker td.range-inputs {\n\tmax-width: none;\n}\n.adatepicker .date-input > input {\n\tflex: none;\n\twidth: 11ch;\n\tbox-sizing: border-box;\n\tpadding: 2px;\n}\n\n/* Keep the field error in-flow below the calendar. The shared .aform_error is absolutely\n positioned against a .aform_form-element anchor, which this grid component does not use. */\np.aform_error {\n\tposition: static;\n\tdisplay: block;\n\tcolor: var(--sc-brand-danger);\n\tfont-size: 0.7rem;\n\tmargin: 0.25rem 0 0;\n}\n</style>\n","<template>\n\t<template v-if=\"mode === 'display' || mode === 'read'\">\n\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t<label v-if=\"label\">{{ label }}</label>\n\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t</template>\n\t<template v-else>\n\t\t<div class=\"adatepicker\">\n\t\t\t<table ref=\"grid\" role=\"grid\" :aria-label=\"monthAndYear\" @mousedown=\"preventCellSelection\">\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td id=\"previous-month-btn\" :tabindex=\"-1\" @click=\"previousMonth\"><</td>\n\t\t\t\t\t\t<th colspan=\"5\" :tabindex=\"-1\">{{ monthAndYear }}</th>\n\t\t\t\t\t\t<td id=\"next-month-btn\" :tabindex=\"-1\" @click=\"nextMonth\">></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr v-if=\"selectRange\">\n\t\t\t\t\t\t<td colspan=\"7\" class=\"range-inputs\">\n\t\t\t\t\t\t\t<div class=\"date-input\">\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tref=\"start-date-input\"\n\t\t\t\t\t\t\t\t\t:value=\"getStartDate\"\n\t\t\t\t\t\t\t\t\tclass=\"date-input-start aform_input-field\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"start date\"\n\t\t\t\t\t\t\t\t\t@blur=\"enterInputDate()\"\n\t\t\t\t\t\t\t\t\t@keydown=\"enterDate\" />\n\t\t\t\t\t\t\t\t<div>-</div>\n\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\tref=\"end-date-input\"\n\t\t\t\t\t\t\t\t\t:value=\"getEndDate\"\n\t\t\t\t\t\t\t\t\tclass=\"date-input-end aform_input-field\"\n\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\tplaceholder=\"end date\"\n\t\t\t\t\t\t\t\t\t@blur=\"enterInputDate()\"\n\t\t\t\t\t\t\t\t\t@keydown=\"enterDate\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<!-- {{ formattedDateRange }} -->\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr class=\"days-header\">\n\t\t\t\t\t\t<td v-for=\"(letter, weekdayIndex) in weekdayLetters\" :key=\"weekdayIndex\">{{ letter }}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr v-for=\"rowNo in numberOfRows\" :key=\"rowNo\">\n\t\t\t\t\t\t<!-- the 'ref' key is currently only used for test references -->\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-for=\"colNo in numberOfColumns\"\n\t\t\t\t\t\t\tref=\"celldate\"\n\t\t\t\t\t\t\t:key=\"getCurrentCell(rowNo, colNo)\"\n\t\t\t\t\t\t\tclass=\"date-cell\"\n\t\t\t\t\t\t\t:contenteditable=\"false\"\n\t\t\t\t\t\t\t:spellcheck=\"false\"\n\t\t\t\t\t\t\t:tabindex=\"getCurrentDate(rowNo, colNo).equals(focusedDay) ? 0 : -1\"\n\t\t\t\t\t\t\t:aria-label=\"fullDate(getCurrentDate(rowNo, colNo))\"\n\t\t\t\t\t\t\t:aria-selected=\"isPicked(getCurrentDate(rowNo, colNo))\"\n\t\t\t\t\t\t\t:aria-current=\"isTodaysDate(getCurrentDate(rowNo, colNo)) ? 'date' : undefined\"\n\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\ttodaysDate: isTodaysDate(getCurrentDate(rowNo, colNo)),\n\t\t\t\t\t\t\t\tselectedDate: isSelectedDate(getCurrentDate(rowNo, colNo)),\n\t\t\t\t\t\t\t\twithinRange: selectRange ? isInDateRange(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t\tstartDate: selectRange ? isStartDate(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t\tendDate: selectRange ? isEndDate(getCurrentDate(rowNo, colNo)) : false,\n\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t@click.prevent.stop=\"selectDate(getCurrentCell(rowNo, colNo))\"\n\t\t\t\t\t\t\t@keydown=\"onDayKeydown($event, getCurrentCell(rowNo, colNo))\"\n\t\t\t\t\t\t\t@mouseover=\"hoverDate(getCurrentCell(rowNo, colNo))\">\n\t\t\t\t\t\t\t{{ getCurrentDate(rowNo, colNo).day }}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t</template>\n</template>\n\n<script setup lang=\"ts\">\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { readTypedDay, writeTypedDay } from '../../utils/typedDay'\n\nconst numberOfRows = 6\nconst numberOfColumns = 7\n\nconst {\n\tmode,\n\tlabel,\n\tselectRange = false,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n} = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId } = fieldErrorA11y(uuid, errorText)\n\n// The calendar holds a `YYYY-MM-DD` day, and opens on today when it holds none it can read. No default\n// value: picking today on an empty calendar must still set it, and a model only reports a change.\nconst date = defineModel<string | null>()\nconst selectedDate = ref<Temporal.PlainDate>(fromISODate(date.value ?? '') ?? Temporal.Now.plainDateISO())\n// 0 for January.\nconst currentMonth = ref<number>(selectedDate.value.month - 1)\nconst currentYear = ref<number>(selectedDate.value.year)\nconst currentDates = ref<Temporal.PlainDate[]>([])\n\n// The day the grid's one Tab stop sits on, where its keys move from. It is always a day the grid shows.\nconst focusedDay = ref<Temporal.PlainDate>(selectedDate.value)\nconst grid = useTemplateRef<HTMLTableElement>('grid')\n\nconst hoveredDate = ref<Temporal.PlainDate>(selectedDate.value)\nconst start_date = ref<Temporal.PlainDate | null>(null)\nconst end_date = ref<Temporal.PlainDate | null>(null)\nconst startDateInput = useTemplateRef<HTMLInputElement>('start-date-input')\nconst endDateInput = useTemplateRef<HTMLInputElement>('end-date-input')\n\n/*******************\nEmits\n*******************/\n\nconst emit = defineEmits<{\n\t'get-date': [{ start: string | null; end: string | null; selected: string }]\n}>()\n\n/*******************\nComputed\n*******************/\n\nconst displayValue = computed(() => (date.value ? (fromISODate(date.value)?.toLocaleString() ?? 'Invalid Date') : ''))\n\nconst firstOfMonth = computed(() =>\n\tTemporal.PlainDate.from({ year: currentYear.value, month: currentMonth.value + 1, day: 1 })\n)\n\n// Not a `PlainYearMonth`: its `toLocaleString` throws for the ISO calendar.\nconst monthAndYear = computed(() => firstOfMonth.value.toLocaleString(undefined, { year: 'numeric', month: 'long' }))\n\n// The grid's first week, so the letters follow its Monday start.\nconst weekdayLetters = computed(() =>\n\tcurrentDates.value.slice(0, numberOfColumns).map(day => day.toLocaleString(undefined, { weekday: 'narrow' }))\n)\n\nconst getStartDate = computed(() => boxText(start_date.value))\n\nconst getEndDate = computed(() => boxText(end_date.value))\n\n/*******************\nFunctions\n*******************/\n\nconst boxText = (day: Temporal.PlainDate | null) => (day ? writeTypedDay(day) : '')\n\nconst isTodaysDate = (day: Temporal.PlainDate): boolean => {\n\tconst today = Temporal.Now.plainDateISO()\n\tif (currentMonth.value !== today.month - 1) return false\n\treturn day.equals(today)\n}\n\nconst isSelectedDate = (day: Temporal.PlainDate) => {\n\treturn day.equals(selectedDate.value)\n}\n\nconst isStartDate = (day: Temporal.PlainDate) => {\n\treturn start_date.value !== null && day.equals(start_date.value)\n}\n\nconst isEndDate = (day: Temporal.PlainDate) => {\n\treturn end_date.value !== null && day.equals(end_date.value)\n}\n\n// Every day the calendar marks as picked, so a screen reader hears the same days marked.\nconst isPicked = (day: Temporal.PlainDate) =>\n\tisSelectedDate(day) || (selectRange && (isStartDate(day) || isEndDate(day)))\n\nconst fullDate = (day: Temporal.PlainDate) =>\n\tday.toLocaleString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })\n\nconst getCurrentCell = (rowNo: number, colNo: number) => {\n\treturn (rowNo - 1) * numberOfColumns + colNo - 1\n}\n\nconst isInDateRange = (day: Temporal.PlainDate) => {\n\tconst start = start_date.value\n\tif (!start) return false\n\n\t//the end is either the selected end date or wherever the user is hovering\n\tconst end = end_date.value ?? hoveredDate.value\n\n\treturn Temporal.PlainDate.compare(day, start) > 0 && Temporal.PlainDate.compare(day, end) < 0\n}\n\nconst getCurrentDate = (rowNo: number, colNo: number) => {\n\treturn currentDates.value[getCurrentCell(rowNo, colNo)]\n}\n\nconst hoverDate = (currentIndex: number) => {\n\thoveredDate.value = currentDates.value[currentIndex]\n}\n\n// browsers (notably Firefox) allow drag-selecting text across table cells even with\n// `user-select: none` on the cells; blocking mousedown is the reliable cross-browser fix.\n// the start/end-date inputs must keep native mousedown behavior so they stay focusable/typable.\nconst preventCellSelection = (event: MouseEvent) => {\n\tif ((event.target as HTMLElement)?.tagName !== 'INPUT') {\n\t\tevent.preventDefault()\n\t}\n}\n\nconst populateMonth = () => {\n\t// The grid starts on the Monday on or before the 1st, matching the header's first column.\n\tconst gridStart = firstOfMonth.value.subtract({ days: firstOfMonth.value.dayOfWeek - 1 })\n\tcurrentDates.value = Array.from({ length: numberOfRows * numberOfColumns }, (_, cellIndex) =>\n\t\tgridStart.add({ days: cellIndex })\n\t)\n}\nconst previousYear = () => (currentYear.value -= 1)\nconst nextYear = () => (currentYear.value += 1)\n\nconst previousMonth = () => {\n\tif (currentMonth.value == 0) {\n\t\tcurrentMonth.value = 11\n\t\tpreviousYear()\n\t} else {\n\t\tcurrentMonth.value -= 1\n\t}\n}\n\nconst nextMonth = () => {\n\tif (currentMonth.value == 11) {\n\t\tcurrentMonth.value = 0\n\t\tnextYear()\n\t} else {\n\t\tcurrentMonth.value += 1\n\t}\n}\n\nconst enterDate = (event: KeyboardEvent) => {\n\tif (event.key === 'Enter') enterInputDate()\n}\n\n// The grid's keys move by day, not by table cell as `useKeyboardNav` does: that one can't cross into\n// another month, and on every cell it took the arrow keys from a range's typed-day boxes.\n/** The day a key moves focus to from `day`, or undefined for a key that moves nothing. */\nconst dayAfterKey = (event: KeyboardEvent, day: Temporal.PlainDate) => {\n\tswitch (event.key) {\n\t\tcase 'ArrowLeft':\n\t\t\treturn day.subtract({ days: 1 })\n\t\tcase 'ArrowRight':\n\t\t\treturn day.add({ days: 1 })\n\t\tcase 'ArrowUp':\n\t\t\treturn day.subtract({ weeks: 1 })\n\t\tcase 'ArrowDown':\n\t\t\treturn day.add({ weeks: 1 })\n\t\tcase 'PageUp':\n\t\t\treturn day.subtract(event.shiftKey ? { years: 1 } : { months: 1 })\n\t\tcase 'PageDown':\n\t\t\treturn day.add(event.shiftKey ? { years: 1 } : { months: 1 })\n\t\t// The grid's weeks run Monday, day 1, to Sunday, day 7.\n\t\tcase 'Home':\n\t\t\treturn day.subtract({ days: day.dayOfWeek - 1 })\n\t\tcase 'End':\n\t\t\treturn day.add({ days: 7 - day.dayOfWeek })\n\t}\n}\n\nconst focusTabStop = async () => {\n\tawait nextTick()\n\tgrid.value?.querySelector<HTMLElement>('[tabindex=\"0\"]')?.focus()\n}\n\nconst onDayKeydown = (event: KeyboardEvent, currentIndex: number) => {\n\tif (event.key === 'Enter' || event.key === ' ') {\n\t\tevent.preventDefault()\n\t\tselectDate(currentIndex)\n\t\treturn\n\t}\n\tconst next = dayAfterKey(event, focusedDay.value)\n\tif (!next) return\n\tevent.preventDefault()\n\tfocusedDay.value = next\n\tcurrentMonth.value = next.month - 1\n\tcurrentYear.value = next.year\n\tvoid focusTabStop()\n}\n\nconst selectDate = (currentIndex: number) => {\n\tconst picked = currentDates.value[currentIndex]\n\tselectedDate.value = picked\n\tfocusedDay.value = picked\n\t// A click leaves focus where it was, so focus follows a pick only when it is on a day already.\n\tif (document.activeElement instanceof HTMLTableCellElement && grid.value?.contains(document.activeElement)) {\n\t\tvoid focusTabStop()\n\t}\n\tdate.value = picked.toString()\n\n\tif (selectRange) {\n\t\tconst start = start_date.value\n\t\tif (start == null || end_date.value != null) {\n\t\t\tstart_date.value = picked\n\t\t\tend_date.value = null\n\t\t} else if (Temporal.PlainDate.compare(picked, start) < 0) {\n\t\t\tend_date.value = null\n\t\t\tstart_date.value = picked\n\t\t} else {\n\t\t\tend_date.value = picked\n\t\t}\n\t\tif (startDateInput.value) startDateInput.value.value = boxText(start_date.value)\n\t\tif (endDateInput.value) endDateInput.value.value = boxText(end_date.value)\n\t}\n\temitData()\n}\n\nconst testDateOrder = () => {\n\tconst start = start_date.value\n\tconst end = end_date.value\n\tif (start && end && Temporal.PlainDate.compare(end, start) < 0) [start_date.value, end_date.value] = [end, start]\n}\n\nconst enterInputDate = () => {\n\tif (startDateInput.value?.value == '') {\n\t\tstart_date.value = null\n\t} else if (startDateInput.value) {\n\t\tstart_date.value = readTypedDay(startDateInput.value.value) ?? null\n\t}\n\n\tif (endDateInput.value?.value == '') {\n\t\tend_date.value = null\n\t} else if (endDateInput.value) {\n\t\tend_date.value = readTypedDay(endDateInput.value.value) ?? null\n\t}\n\n\tif (start_date.value) {\n\t\tif (end_date.value) testDateOrder()\n\t\tselectedDate.value = start_date.value\n\t}\n\n\temitData()\n}\n\nconst emitData = () => {\n\temit('get-date', {\n\t\tstart: selectRange ? (start_date.value?.toString() ?? null) : null,\n\t\tend: selectRange ? (end_date.value?.toString() ?? null) : null,\n\t\tselected: selectedDate.value.toString(),\n\t})\n}\n\n/*******************\nHooks\n*******************/\n\n// The calendar takes no focus when it appears: a field opening it keeps focus in its box, where typing goes.\npopulateMonth()\n\n/*******************\nWatchers\n*******************/\n\nwatch([currentMonth, currentYear], () => {\n\tpopulateMonth()\n\t// The month buttons carry the Tab stop along, to the same day of the month shown.\n\tconst month = currentMonth.value + 1\n\tif (focusedDay.value.month !== month || focusedDay.value.year !== currentYear.value) {\n\t\tfocusedDay.value = focusedDay.value.with({ year: currentYear.value, month })\n\t}\n})\n\n// A day handed in, such as one typed into the field while the calendar is open. A pick here sets\n// `selectedDate` first, so picking a day of the next month in this grid leaves the month shown.\nwatch(date, value => {\n\tconst day = fromISODate(value ?? '')\n\tif (!day || day.equals(selectedDate.value)) return\n\tselectedDate.value = day\n\tfocusedDay.value = day\n\tcurrentMonth.value = day.month - 1\n\tcurrentYear.value = day.year\n})\n\n/*******************\nExpose\n*******************/\n\ndefineExpose({ currentMonth, currentYear, selectedDate: computed(() => selectedDate.value.toString()) })\n</script>\n\n<style scoped>\n.adatepicker,\n.adatepicker table,\n.adatepicker tr,\n.adatepicker td,\n.adatepicker th {\n\t-webkit-user-select: none;\n\t-moz-user-select: none;\n\tuser-select: none;\n}\n\n.adatepicker {\n\tfont-size: var(--sc-table-font-size);\n\tdisplay: inline-table;\n\tcolor: var(--sc-cell-text-color);\n\toutline: none;\n\tborder-collapse: collapse;\n\tmargin-bottom: 10px;\n\t/* width: calc(100% - 4px); */\n}\n\n.adatepicker tr {\n\theight: 1.15rem;\n\theight: 1.15rem;\n\ttext-align: center;\n\tvertical-align: middle;\n}\n\n.adatepicker td {\n\tborder: 2px solid transparent;\n\toutline: 2px solid transparent;\n\tmin-width: 3ch;\n\tmax-width: 3ch;\n\tcursor: pointer;\n}\n.adatepicker td.date-cell:hover {\n\tbackground: var(--sc-gray-10);\n}\n\n.adatepicker td.date-cell:focus-visible {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n\n.adatepicker td:focus,\n.adatepicker td:focus-within {\n\t/* outline: 1px dashed black; */\n\tbox-shadow: none;\n\toverflow: hidden;\n\tmin-height: 1.15em;\n\tmax-height: 1.15em;\n\toverflow: hidden;\n}\n.adatepicker .selectedDate,\n.adatepicker .startDate,\n.adatepicker .endDate {\n\t/* outline: 1px solid black; */\n\tbackground: var(--sc-gray-20);\n\tfont-weight: bolder;\n}\n.adatepicker .startDate {\n\t/* border-radius: 5px 0px 0px 5px; */\n\tborder-left: 1px solid var(--sc-gray-50);\n\tbackground: var(--sc-gray-20) !important;\n}\n.adatepicker .endDate {\n\tborder-right: 1px solid var(--sc-gray-50);\n\t/* border-radius: 0px 5px 5px 0px; */\n\tbackground: var(--sc-gray-20) !important;\n}\n.adatepicker .withinRange {\n\tbackground: var(--sc-gray-5);\n}\n\n.adatepicker .todaysDate {\n\tfont-weight: bolder;\n\t/* text-decoration: underline; */\n\tcolor: var(--sc-cell-text-color);\n}\n.days-header > td {\n\tfont-weight: bold;\n}\n.prev-date {\n\tcolor: var(--sc-gray-20);\n}\n\n.adatepicker .date-input {\n\tdisplay: flex;\n\twidth: 100%;\n\tgap: 5px;\n\talign-items: center;\n}\n/* The boxes' row widens the calendar past its 3ch day columns, so each box fits a day such as `04/09/2026`. */\n.adatepicker td.range-inputs {\n\tmax-width: none;\n}\n.adatepicker .date-input > input {\n\tflex: none;\n\twidth: 11ch;\n\tbox-sizing: border-box;\n\tpadding: 2px;\n}\n\n/* Keep the field error in-flow below the calendar. The shared .aform_error is absolutely\n positioned against a .aform_form-element anchor, which this grid component does not use. */\np.aform_error {\n\tposition: static;\n\tdisplay: block;\n\tcolor: var(--sc-brand-danger);\n\tfont-size: 0.7rem;\n\tmargin: 0.25rem 0 0;\n}\n</style>\n","<template>\n\t<div class=\"adate_time\">\n\t\t<div class=\"adate_time_fields\">\n\t\t\t<input\n\t\t\t\tv-model=\"timeData.hours\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput($event, true)\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('hours')\"\n\t\t\t\t@keydown.down.prevent=\"tick('hours', -1)\" />\n\t\t\t<span class=\"colon\">:</span>\n\t\t\t<input\n\t\t\t\tv-model=\"timeData.minutes\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('minutes')\"\n\t\t\t\t@keydown.down.prevent=\"tick('minutes', -1)\" />\n\t\t\t<span v-if=\"useSeconds\" class=\"colon\">:</span>\n\t\t\t<input\n\t\t\t\tv-if=\"useSeconds\"\n\t\t\t\tv-model=\"timeData.seconds\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('seconds')\"\n\t\t\t\t@keydown.down.prevent=\"tick('seconds', -1)\" />\n\t\t\t<select\n\t\t\t\tv-if=\"!allowMilitaryTime\"\n\t\t\t\tref=\"meridiem-selector\"\n\t\t\t\tv-model=\"meridiem\"\n\t\t\t\tclass=\"aform-select meridiem-selector\"\n\t\t\t\t@change=\"confirmTime\">\n\t\t\t\t<option value=\"AM\">AM</option>\n\t\t\t\t<option value=\"PM\">PM</option>\n\t\t\t</select>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, reactive, useTemplateRef, watch, onMounted } from 'vue'\n\nconst {\n\tallowMilitaryTime = false,\n\tdefaultHours = 12,\n\tdefaultMinutes = 0,\n\tdefaultSeconds = 0,\n\tdefaultMeridiem = 'AM',\n\tuseSeconds = true,\n} = defineProps<{\n\tallowMilitaryTime?: boolean\n\tdefaultHours?: number\n\tdefaultMinutes?: number\n\tdefaultSeconds?: number\n\tdefaultMeridiem?: string\n\tuseSeconds?: boolean\n}>()\n\n// `get-time` carries the widget's CURRENT VALUE, not a commit: it fires once as the widget\n// mounts and again on every blur, Enter, arrow key and meridiem change — five times during one\n// ordinary edit. `source` is what lets a parent tell the start-up announcement apart from a real\n// user edit; without it a parent has nothing to key on and must guess from the value alone.\nconst emit = defineEmits<{\n\t'get-time': [\n\t\t{\n\t\t\thours: number\n\t\t\tminutes: number\n\t\t\tseconds: number\n\t\t\tmeridiem: string\n\t\t\tmilitaryTime: number\n\t\t\tsource: 'init' | 'user'\n\t\t},\n\t]\n}>()\n\nconst meridiemSelector = useTemplateRef<HTMLSelectElement>('meridiem-selector')\n\nconst timeData = reactive({\n\thours: String(defaultHours).padStart(2, '0'),\n\tminutes: String(defaultMinutes).padStart(2, '0'),\n\tseconds: String(defaultSeconds).padStart(2, '0'),\n})\n\nconst meridiem = ref(defaultMeridiem == 'AM' ? 'AM' : 'PM')\n\nonMounted(() => {\n\temitTime('init')\n})\n\nconst confirmTime = () => {\n\tconst maxHours = allowMilitaryTime ? 23 : 12\n\tconst minHours = allowMilitaryTime ? 0 : 1\n\tlet hours = Number(timeData.hours)\n\tlet minutes = Number(timeData.minutes)\n\tlet seconds = Number(timeData.seconds)\n\n\tif (isNaN(hours) || timeData.hours === '' || hours > maxHours) hours = maxHours\n\tif (!allowMilitaryTime && hours < minHours) hours = minHours\n\tif (isNaN(minutes) || timeData.minutes === '' || minutes > 59) minutes = 59\n\tif (isNaN(seconds) || timeData.seconds === '' || seconds > 59) seconds = 59\n\n\ttimeData.hours = String(hours).padStart(2, '0')\n\ttimeData.minutes = String(minutes).padStart(2, '0')\n\ttimeData.seconds = String(seconds).padStart(2, '0')\n\n\temitTime('user')\n}\n\nconst emitTime = (source: 'init' | 'user') => {\n\tconst hours = Number(timeData.hours)\n\tconst minutes = Number(timeData.minutes)\n\tconst seconds = Number(timeData.seconds)\n\temit('get-time', {\n\t\thours,\n\t\tminutes,\n\t\tseconds,\n\t\tsource,\n\t\tmeridiem: meridiem.value,\n\t\tmilitaryTime: allowMilitaryTime ? hours : meridiem.value === 'PM' ? (hours === 12 ? 12 : hours + 12) : hours % 12,\n\t})\n}\n\nconst focusInput = (event: FocusEvent) => {\n\tconst target = event.target\n\tif (target instanceof HTMLInputElement) {\n\t\ttarget.select()\n\t}\n}\n\nconst tick = (target: 'hours' | 'minutes' | 'seconds', amount = 1) => {\n\tconst maxHours = allowMilitaryTime ? 23 : 12\n\tconst minHours = allowMilitaryTime ? 0 : 1\n\n\tif (target == 'hours') {\n\t\tconst oldHours = Number(timeData.hours)\n\t\ttimeData.hours = String(oldHours + amount)\n\t\tif ((oldHours == 11 && Number(timeData.hours) == 12) || (oldHours == 12 && Number(timeData.hours) == 11)) {\n\t\t\tchangeMeridiem()\n\t\t}\n\t} else if (target == 'minutes') {\n\t\ttimeData.minutes = String(Number(timeData.minutes) + amount)\n\t} else if (target == 'seconds') {\n\t\ttimeData.seconds = String(Number(timeData.seconds) + amount)\n\t}\n\n\tconst prevHours = Number(timeData.hours)\n\n\tif (Number(timeData.seconds) < 0) timeData.minutes = String(Number(timeData.minutes) - 1)\n\telse if (Number(timeData.seconds) > 59) timeData.minutes = String(Number(timeData.minutes) + 1)\n\n\tif (Number(timeData.minutes) < 0) timeData.hours = String(prevHours - 1)\n\telse if (Number(timeData.minutes) > 59) timeData.hours = String(prevHours + 1)\n\n\tconst newRawHours = Number(timeData.hours)\n\tif (!allowMilitaryTime && newRawHours !== prevHours) {\n\t\tif ((prevHours === 11 && newRawHours === 12) || (prevHours === 12 && newRawHours === 11)) {\n\t\t\tchangeMeridiem()\n\t\t}\n\t}\n\n\ttimeData.hours = String(formatTime(Number(timeData.hours), minHours, maxHours)).padStart(2, '0')\n\ttimeData.minutes = String(formatTime(Number(timeData.minutes), 0, 59)).padStart(2, '0')\n\ttimeData.seconds = String(formatTime(Number(timeData.seconds), 0, 59)).padStart(2, '0')\n}\n\nwatch(\n\t() => timeData.hours,\n\t(newVal, oldVal) => {\n\t\ttimeData.hours = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\nwatch(\n\t() => timeData.minutes,\n\t(newVal, oldVal) => {\n\t\ttimeData.minutes = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\nwatch(\n\t() => timeData.seconds,\n\t(newVal, oldVal) => {\n\t\ttimeData.seconds = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\n\nconst formatTime = (target: number, min: number, max: number): number => {\n\tif (target > max) return min\n\telse if (target < min) return max\n\treturn target\n}\n\nconst changeMeridiem = () => {\n\tmeridiem.value = meridiem.value == 'PM' ? 'AM' : 'PM'\n\temitTime('user')\n}\n\nconst pasteInput = (event: ClipboardEvent, pasteAllFields = false) => {\n\tevent.stopPropagation()\n\tevent.preventDefault()\n\n\tconst clipboardData = event.clipboardData\n\tif (!clipboardData) return\n\tlet pastedData: string = clipboardData.getData('Text')\n\n\tpastedData = pastedData.replace(/[^0-9]/g, '')\n\n\tif (pasteAllFields) {\n\t\tif (pastedData.length % 2 != 0) pastedData = '0' + pastedData\n\t\tif (pastedData.length < 3) pastedData += '00'\n\t\tif (pastedData.length < 5) pastedData += '00'\n\n\t\tconst timeUnits = pastedData.match(/(..?)/g)\n\t\tif (!timeUnits || timeUnits.length < 3) return\n\n\t\ttimeData.seconds = timeUnits[2]\n\t\ttimeData.minutes = timeUnits[1]\n\t\ttimeData.hours = timeUnits[0]\n\t\tconfirmTime()\n\t\tif (!allowMilitaryTime) meridiemSelector.value?.focus()\n\t} else {\n\t\tif (pastedData.length > 2) pastedData = pastedData.slice(0, 2)\n\t\tconst target = event.target\n\t\tif (target instanceof HTMLInputElement) {\n\t\t\ttarget.value = pastedData\n\t\t\ttarget.dispatchEvent(new Event('input'))\n\t\t}\n\t}\n}\n</script>\n\n<style scoped>\n.adate_time {\n\twidth: auto;\n\tpadding: 10px;\n\tbox-sizing: border-box;\n\tfont-size: 1rem;\n\tbackground: var(--sc-input-field-background);\n}\n.adate_time_fields {\n\tdisplay: flex;\n\talign-items: stretch;\n\tgap: 5px;\n\tjustify-content: flex-start;\n}\n.adate_time_fields > input {\n\twidth: 2.5rem;\n\tmin-width: 2.5rem;\n\tflex: 0 0 auto;\n\tpadding: 0.25rem 0.15rem;\n\ttext-align: center;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-cell-text-color);\n\tborder-radius: var(--sc-border-radius);\n}\n.adate_time_fields > input:focus,\n.meridiem-selector:focus {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n.meridiem-selector {\n\tflex: 0 0 auto;\n\twidth: auto;\n\tmin-width: 5.5rem;\n\tmargin-left: 6px;\n\tpadding: 0.25rem 1.75rem 0.25rem 0.5rem;\n\tcursor: pointer;\n\tuser-select: none;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-cell-text-color);\n\tborder-radius: var(--sc-border-radius);\n\tfont-size: 1rem;\n}\n.adate_time_segment {\n\tdisplay: flex;\n\tflex-direction: column;\n\twidth: 40px;\n}\n.colon {\n\tdisplay: flex;\n\talign-items: normal;\n}\n.aform_form-btn {\n\tcursor: pointer;\n}\n.aform-select {\n\tbox-sizing: border-box;\n\tmin-height: auto;\n}\n</style>\n","<template>\n\t<div class=\"adate_time\">\n\t\t<div class=\"adate_time_fields\">\n\t\t\t<input\n\t\t\t\tv-model=\"timeData.hours\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput($event, true)\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('hours')\"\n\t\t\t\t@keydown.down.prevent=\"tick('hours', -1)\" />\n\t\t\t<span class=\"colon\">:</span>\n\t\t\t<input\n\t\t\t\tv-model=\"timeData.minutes\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('minutes')\"\n\t\t\t\t@keydown.down.prevent=\"tick('minutes', -1)\" />\n\t\t\t<span v-if=\"useSeconds\" class=\"colon\">:</span>\n\t\t\t<input\n\t\t\t\tv-if=\"useSeconds\"\n\t\t\t\tv-model=\"timeData.seconds\"\n\t\t\t\ttype=\"text\"\n\t\t\t\tinputmode=\"numeric\"\n\t\t\t\t@paste=\"pasteInput\"\n\t\t\t\t@focus=\"focusInput\"\n\t\t\t\t@blur=\"confirmTime\"\n\t\t\t\t@keydown.enter.prevent=\"confirmTime\"\n\t\t\t\t@keydown.up.prevent=\"tick('seconds')\"\n\t\t\t\t@keydown.down.prevent=\"tick('seconds', -1)\" />\n\t\t\t<select\n\t\t\t\tv-if=\"!allowMilitaryTime\"\n\t\t\t\tref=\"meridiem-selector\"\n\t\t\t\tv-model=\"meridiem\"\n\t\t\t\tclass=\"aform-select meridiem-selector\"\n\t\t\t\t@change=\"confirmTime\">\n\t\t\t\t<option value=\"AM\">AM</option>\n\t\t\t\t<option value=\"PM\">PM</option>\n\t\t\t</select>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, reactive, useTemplateRef, watch, onMounted } from 'vue'\n\nconst {\n\tallowMilitaryTime = false,\n\tdefaultHours = 12,\n\tdefaultMinutes = 0,\n\tdefaultSeconds = 0,\n\tdefaultMeridiem = 'AM',\n\tuseSeconds = true,\n} = defineProps<{\n\tallowMilitaryTime?: boolean\n\tdefaultHours?: number\n\tdefaultMinutes?: number\n\tdefaultSeconds?: number\n\tdefaultMeridiem?: string\n\tuseSeconds?: boolean\n}>()\n\n// `get-time` carries the widget's CURRENT VALUE, not a commit: it fires once as the widget\n// mounts and again on every blur, Enter, arrow key and meridiem change — five times during one\n// ordinary edit. `source` is what lets a parent tell the start-up announcement apart from a real\n// user edit; without it a parent has nothing to key on and must guess from the value alone.\nconst emit = defineEmits<{\n\t'get-time': [\n\t\t{\n\t\t\thours: number\n\t\t\tminutes: number\n\t\t\tseconds: number\n\t\t\tmeridiem: string\n\t\t\tmilitaryTime: number\n\t\t\tsource: 'init' | 'user'\n\t\t},\n\t]\n}>()\n\nconst meridiemSelector = useTemplateRef<HTMLSelectElement>('meridiem-selector')\n\nconst timeData = reactive({\n\thours: String(defaultHours).padStart(2, '0'),\n\tminutes: String(defaultMinutes).padStart(2, '0'),\n\tseconds: String(defaultSeconds).padStart(2, '0'),\n})\n\nconst meridiem = ref(defaultMeridiem == 'AM' ? 'AM' : 'PM')\n\nonMounted(() => {\n\temitTime('init')\n})\n\nconst confirmTime = () => {\n\tconst maxHours = allowMilitaryTime ? 23 : 12\n\tconst minHours = allowMilitaryTime ? 0 : 1\n\tlet hours = Number(timeData.hours)\n\tlet minutes = Number(timeData.minutes)\n\tlet seconds = Number(timeData.seconds)\n\n\tif (isNaN(hours) || timeData.hours === '' || hours > maxHours) hours = maxHours\n\tif (!allowMilitaryTime && hours < minHours) hours = minHours\n\tif (isNaN(minutes) || timeData.minutes === '' || minutes > 59) minutes = 59\n\tif (isNaN(seconds) || timeData.seconds === '' || seconds > 59) seconds = 59\n\n\ttimeData.hours = String(hours).padStart(2, '0')\n\ttimeData.minutes = String(minutes).padStart(2, '0')\n\ttimeData.seconds = String(seconds).padStart(2, '0')\n\n\temitTime('user')\n}\n\nconst emitTime = (source: 'init' | 'user') => {\n\tconst hours = Number(timeData.hours)\n\tconst minutes = Number(timeData.minutes)\n\tconst seconds = Number(timeData.seconds)\n\temit('get-time', {\n\t\thours,\n\t\tminutes,\n\t\tseconds,\n\t\tsource,\n\t\tmeridiem: meridiem.value,\n\t\tmilitaryTime: allowMilitaryTime ? hours : meridiem.value === 'PM' ? (hours === 12 ? 12 : hours + 12) : hours % 12,\n\t})\n}\n\nconst focusInput = (event: FocusEvent) => {\n\tconst target = event.target\n\tif (target instanceof HTMLInputElement) {\n\t\ttarget.select()\n\t}\n}\n\nconst tick = (target: 'hours' | 'minutes' | 'seconds', amount = 1) => {\n\tconst maxHours = allowMilitaryTime ? 23 : 12\n\tconst minHours = allowMilitaryTime ? 0 : 1\n\n\tif (target == 'hours') {\n\t\tconst oldHours = Number(timeData.hours)\n\t\ttimeData.hours = String(oldHours + amount)\n\t\tif ((oldHours == 11 && Number(timeData.hours) == 12) || (oldHours == 12 && Number(timeData.hours) == 11)) {\n\t\t\tchangeMeridiem()\n\t\t}\n\t} else if (target == 'minutes') {\n\t\ttimeData.minutes = String(Number(timeData.minutes) + amount)\n\t} else if (target == 'seconds') {\n\t\ttimeData.seconds = String(Number(timeData.seconds) + amount)\n\t}\n\n\tconst prevHours = Number(timeData.hours)\n\n\tif (Number(timeData.seconds) < 0) timeData.minutes = String(Number(timeData.minutes) - 1)\n\telse if (Number(timeData.seconds) > 59) timeData.minutes = String(Number(timeData.minutes) + 1)\n\n\tif (Number(timeData.minutes) < 0) timeData.hours = String(prevHours - 1)\n\telse if (Number(timeData.minutes) > 59) timeData.hours = String(prevHours + 1)\n\n\tconst newRawHours = Number(timeData.hours)\n\tif (!allowMilitaryTime && newRawHours !== prevHours) {\n\t\tif ((prevHours === 11 && newRawHours === 12) || (prevHours === 12 && newRawHours === 11)) {\n\t\t\tchangeMeridiem()\n\t\t}\n\t}\n\n\ttimeData.hours = String(formatTime(Number(timeData.hours), minHours, maxHours)).padStart(2, '0')\n\ttimeData.minutes = String(formatTime(Number(timeData.minutes), 0, 59)).padStart(2, '0')\n\ttimeData.seconds = String(formatTime(Number(timeData.seconds), 0, 59)).padStart(2, '0')\n}\n\nwatch(\n\t() => timeData.hours,\n\t(newVal, oldVal) => {\n\t\ttimeData.hours = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\nwatch(\n\t() => timeData.minutes,\n\t(newVal, oldVal) => {\n\t\ttimeData.minutes = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\nwatch(\n\t() => timeData.seconds,\n\t(newVal, oldVal) => {\n\t\ttimeData.seconds = Number(newVal) > 99 ? oldVal : newVal\n\t}\n)\n\nconst formatTime = (target: number, min: number, max: number): number => {\n\tif (target > max) return min\n\telse if (target < min) return max\n\treturn target\n}\n\nconst changeMeridiem = () => {\n\tmeridiem.value = meridiem.value == 'PM' ? 'AM' : 'PM'\n\temitTime('user')\n}\n\nconst pasteInput = (event: ClipboardEvent, pasteAllFields = false) => {\n\tevent.stopPropagation()\n\tevent.preventDefault()\n\n\tconst clipboardData = event.clipboardData\n\tif (!clipboardData) return\n\tlet pastedData: string = clipboardData.getData('Text')\n\n\tpastedData = pastedData.replace(/[^0-9]/g, '')\n\n\tif (pasteAllFields) {\n\t\tif (pastedData.length % 2 != 0) pastedData = '0' + pastedData\n\t\tif (pastedData.length < 3) pastedData += '00'\n\t\tif (pastedData.length < 5) pastedData += '00'\n\n\t\tconst timeUnits = pastedData.match(/(..?)/g)\n\t\tif (!timeUnits || timeUnits.length < 3) return\n\n\t\ttimeData.seconds = timeUnits[2]\n\t\ttimeData.minutes = timeUnits[1]\n\t\ttimeData.hours = timeUnits[0]\n\t\tconfirmTime()\n\t\tif (!allowMilitaryTime) meridiemSelector.value?.focus()\n\t} else {\n\t\tif (pastedData.length > 2) pastedData = pastedData.slice(0, 2)\n\t\tconst target = event.target\n\t\tif (target instanceof HTMLInputElement) {\n\t\t\ttarget.value = pastedData\n\t\t\ttarget.dispatchEvent(new Event('input'))\n\t\t}\n\t}\n}\n</script>\n\n<style scoped>\n.adate_time {\n\twidth: auto;\n\tpadding: 10px;\n\tbox-sizing: border-box;\n\tfont-size: 1rem;\n\tbackground: var(--sc-input-field-background);\n}\n.adate_time_fields {\n\tdisplay: flex;\n\talign-items: stretch;\n\tgap: 5px;\n\tjustify-content: flex-start;\n}\n.adate_time_fields > input {\n\twidth: 2.5rem;\n\tmin-width: 2.5rem;\n\tflex: 0 0 auto;\n\tpadding: 0.25rem 0.15rem;\n\ttext-align: center;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-cell-text-color);\n\tborder-radius: var(--sc-border-radius);\n}\n.adate_time_fields > input:focus,\n.meridiem-selector:focus {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n.meridiem-selector {\n\tflex: 0 0 auto;\n\twidth: auto;\n\tmin-width: 5.5rem;\n\tmargin-left: 6px;\n\tpadding: 0.25rem 1.75rem 0.25rem 0.5rem;\n\tcursor: pointer;\n\tuser-select: none;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-cell-text-color);\n\tborder-radius: var(--sc-border-radius);\n\tfont-size: 1rem;\n}\n.adate_time_segment {\n\tdisplay: flex;\n\tflex-direction: column;\n\twidth: 40px;\n}\n.colon {\n\tdisplay: flex;\n\talign-items: normal;\n}\n.aform_form-btn {\n\tcursor: pointer;\n}\n.aform-select {\n\tbox-sizing: border-box;\n\tmin-height: auto;\n}\n</style>\n","<!-- This serves as a wrapper component for ADatePicker and ADateTimeInput in one component -->\n\n<template>\n\t<div class=\"adate-selection\">\n\t\t<ADatePicker v-if=\"showDate\" :model-value=\"defaultDate\" :select-range=\"selectRange\" @get-date=\"handleDate\" />\n\n\t\t<ADateTimeInput\n\t\t\tv-if=\"showTime\"\n\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t:default-hours=\"defaultHours\"\n\t\t\t:default-minutes=\"defaultMinutes\"\n\t\t\t:default-seconds=\"defaultSeconds\"\n\t\t\t:default-meridiem=\"defaultMeridiem\"\n\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t@get-time=\"handleStartTime\" />\n\n\t\t<template v-if=\"selectRange && showTime && showEndTime\">\n\t\t\t<div class=\"adate-selection__end-label\">End time</div>\n\t\t\t<ADateTimeInput\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:default-hours=\"defaultHours\"\n\t\t\t\t:default-minutes=\"defaultMinutes\"\n\t\t\t\t:default-seconds=\"defaultSeconds\"\n\t\t\t\t:default-meridiem=\"defaultMeridiem\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-time=\"handleEndTime\" />\n\t\t</template>\n\n\t\t<p v-if=\"!showTime && !showDate\" class=\"empty\">empty</p>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport { provide, ref } from 'vue'\nimport ADatePicker from './ADatePicker.vue'\nimport ADateTimeInput from './ADateTimeInput.vue'\n\nconst {\n\tshowDate = true,\n\tshowTime = true,\n\tselectRange = true,\n\tshowEndTime = false,\n\tallowMilitaryTime = false,\n\tdefaultDate,\n\tdefaultHours = 12,\n\tdefaultMinutes = 0,\n\tdefaultSeconds = 0,\n\tdefaultMeridiem = 'AM',\n\tuseSeconds = true,\n} = defineProps<{\n\tshowDate?: boolean\n\tshowTime?: boolean\n\tselectRange?: boolean\n\tshowEndTime?: boolean\n\tallowMilitaryTime?: boolean\n\t/** The day the calendar opens on, as `YYYY-MM-DD` */\n\tdefaultDate?: string\n\tdefaultHours?: number\n\tdefaultMinutes?: number\n\tdefaultSeconds?: number\n\tdefaultMeridiem?: string\n\tuseSeconds?: boolean\n}>()\n\n// `source` is forwarded from ADateTimeInput, which declares it on every `get-time`. It is\n// optional here only because a host or a test may emit these events by hand, and doing so always\n// means a user action — `'init'` is the one case that has to be marked, because it is the widget\n// announcing its start value as it mounts rather than anything the user did.\nconst emit = defineEmits<{\n\t'get-date': [{ selected: string; start?: string | null; end?: string | null }]\n\t'get-time': [{ hours: number; minutes: number; seconds: number; meridiem: string; source?: 'init' | 'user' }]\n\t'get-range': [{ start: Date; end: Date; source?: 'init' | 'user' }]\n}>()\n\nprovide('select-range', selectRange)\n\nconst today = Temporal.Now.plainDateISO()\nconst pickerStart = ref<Temporal.PlainDate>(today)\nconst pickerEnd = ref<Temporal.PlainDate>(today)\nconst startTimeMs = ref<number>(0)\nconst endTimeMs = ref<number>(0)\n\nconst mergeDateTime = (day: Temporal.PlainDate, timeMs: number): Date => {\n\tconst midnight = day.toZonedDateTime(Temporal.Now.timeZoneId())\n\treturn new Date(midnight.epochMilliseconds + timeMs)\n}\n\nconst timePayloadToMs = (payload: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n}): number => {\n\tlet h: number\n\tif (payload.militaryTime !== undefined) {\n\t\th = payload.militaryTime\n\t} else {\n\t\tconst hrs = payload.hours % 12\n\t\th = payload.meridiem === 'PM' ? hrs + 12 : hrs\n\t}\n\treturn (h * 3600 + payload.minutes * 60 + (payload.seconds ?? 0)) * 1000\n}\n\nconst tryEmitRange = (source: 'init' | 'user') => {\n\tif (!selectRange || !showTime || !showEndTime) return\n\temit('get-range', {\n\t\tstart: mergeDateTime(pickerStart.value, startTimeMs.value),\n\t\tend: mergeDateTime(pickerEnd.value, endTimeMs.value),\n\t\tsource,\n\t})\n}\n\nconst handleDate = (data: { start: string | null; end: string | null; selected: string }) => {\n\temit('get-date', data)\n\tif (selectRange) {\n\t\tpickerStart.value = fromISODate(data.start ?? data.selected) ?? today\n\t\tpickerEnd.value = fromISODate(data.end ?? data.selected) ?? today\n\t\t// Picking a day on the calendar is unambiguously a user action.\n\t\ttryEmitRange('user')\n\t}\n}\n\nconst handleStartTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\tstartTimeMs.value = timePayloadToMs(data)\n\tif (showEndTime) {\n\t\ttryEmitRange(data.source ?? 'user')\n\t} else {\n\t\temit('get-time', data)\n\t}\n}\n\nconst handleEndTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\tendTimeMs.value = timePayloadToMs(data)\n\ttryEmitRange(data.source ?? 'user')\n}\n</script>\n\n<style scoped>\n.adate-selection {\n\tdisplay: inline-block;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--sc-input-border-color);\n\tpadding: 10px;\n\tbackground: var(--sc-input-field-background);\n}\n\n.adate-selection__end-label {\n\tfont-size: 0.8em;\n\tfont-weight: bold;\n\tcolor: var(--sc-input-active-label-color);\n\tmargin-top: 8px;\n\tmargin-bottom: 2px;\n\tpadding-left: 2px;\n}\n\n.empty {\n\tcolor: var(--sc-input-label-color);\n\tpadding: 10px;\n\ttext-align: center;\n\tborder: 1px solid var(--sc-input-border-color);\n}\n</style>\n","<!-- This serves as a wrapper component for ADatePicker and ADateTimeInput in one component -->\n\n<template>\n\t<div class=\"adate-selection\">\n\t\t<ADatePicker v-if=\"showDate\" :model-value=\"defaultDate\" :select-range=\"selectRange\" @get-date=\"handleDate\" />\n\n\t\t<ADateTimeInput\n\t\t\tv-if=\"showTime\"\n\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t:default-hours=\"defaultHours\"\n\t\t\t:default-minutes=\"defaultMinutes\"\n\t\t\t:default-seconds=\"defaultSeconds\"\n\t\t\t:default-meridiem=\"defaultMeridiem\"\n\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t@get-time=\"handleStartTime\" />\n\n\t\t<template v-if=\"selectRange && showTime && showEndTime\">\n\t\t\t<div class=\"adate-selection__end-label\">End time</div>\n\t\t\t<ADateTimeInput\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:default-hours=\"defaultHours\"\n\t\t\t\t:default-minutes=\"defaultMinutes\"\n\t\t\t\t:default-seconds=\"defaultSeconds\"\n\t\t\t\t:default-meridiem=\"defaultMeridiem\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-time=\"handleEndTime\" />\n\t\t</template>\n\n\t\t<p v-if=\"!showTime && !showDate\" class=\"empty\">empty</p>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport { provide, ref } from 'vue'\nimport ADatePicker from './ADatePicker.vue'\nimport ADateTimeInput from './ADateTimeInput.vue'\n\nconst {\n\tshowDate = true,\n\tshowTime = true,\n\tselectRange = true,\n\tshowEndTime = false,\n\tallowMilitaryTime = false,\n\tdefaultDate,\n\tdefaultHours = 12,\n\tdefaultMinutes = 0,\n\tdefaultSeconds = 0,\n\tdefaultMeridiem = 'AM',\n\tuseSeconds = true,\n} = defineProps<{\n\tshowDate?: boolean\n\tshowTime?: boolean\n\tselectRange?: boolean\n\tshowEndTime?: boolean\n\tallowMilitaryTime?: boolean\n\t/** The day the calendar opens on, as `YYYY-MM-DD` */\n\tdefaultDate?: string\n\tdefaultHours?: number\n\tdefaultMinutes?: number\n\tdefaultSeconds?: number\n\tdefaultMeridiem?: string\n\tuseSeconds?: boolean\n}>()\n\n// `source` is forwarded from ADateTimeInput, which declares it on every `get-time`. It is\n// optional here only because a host or a test may emit these events by hand, and doing so always\n// means a user action — `'init'` is the one case that has to be marked, because it is the widget\n// announcing its start value as it mounts rather than anything the user did.\nconst emit = defineEmits<{\n\t'get-date': [{ selected: string; start?: string | null; end?: string | null }]\n\t'get-time': [{ hours: number; minutes: number; seconds: number; meridiem: string; source?: 'init' | 'user' }]\n\t'get-range': [{ start: Date; end: Date; source?: 'init' | 'user' }]\n}>()\n\nprovide('select-range', selectRange)\n\nconst today = Temporal.Now.plainDateISO()\nconst pickerStart = ref<Temporal.PlainDate>(today)\nconst pickerEnd = ref<Temporal.PlainDate>(today)\nconst startTimeMs = ref<number>(0)\nconst endTimeMs = ref<number>(0)\n\nconst mergeDateTime = (day: Temporal.PlainDate, timeMs: number): Date => {\n\tconst midnight = day.toZonedDateTime(Temporal.Now.timeZoneId())\n\treturn new Date(midnight.epochMilliseconds + timeMs)\n}\n\nconst timePayloadToMs = (payload: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n}): number => {\n\tlet h: number\n\tif (payload.militaryTime !== undefined) {\n\t\th = payload.militaryTime\n\t} else {\n\t\tconst hrs = payload.hours % 12\n\t\th = payload.meridiem === 'PM' ? hrs + 12 : hrs\n\t}\n\treturn (h * 3600 + payload.minutes * 60 + (payload.seconds ?? 0)) * 1000\n}\n\nconst tryEmitRange = (source: 'init' | 'user') => {\n\tif (!selectRange || !showTime || !showEndTime) return\n\temit('get-range', {\n\t\tstart: mergeDateTime(pickerStart.value, startTimeMs.value),\n\t\tend: mergeDateTime(pickerEnd.value, endTimeMs.value),\n\t\tsource,\n\t})\n}\n\nconst handleDate = (data: { start: string | null; end: string | null; selected: string }) => {\n\temit('get-date', data)\n\tif (selectRange) {\n\t\tpickerStart.value = fromISODate(data.start ?? data.selected) ?? today\n\t\tpickerEnd.value = fromISODate(data.end ?? data.selected) ?? today\n\t\t// Picking a day on the calendar is unambiguously a user action.\n\t\ttryEmitRange('user')\n\t}\n}\n\nconst handleStartTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\tstartTimeMs.value = timePayloadToMs(data)\n\tif (showEndTime) {\n\t\ttryEmitRange(data.source ?? 'user')\n\t} else {\n\t\temit('get-time', data)\n\t}\n}\n\nconst handleEndTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\tendTimeMs.value = timePayloadToMs(data)\n\ttryEmitRange(data.source ?? 'user')\n}\n</script>\n\n<style scoped>\n.adate-selection {\n\tdisplay: inline-block;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tborder: 1px solid var(--sc-input-border-color);\n\tpadding: 10px;\n\tbackground: var(--sc-input-field-background);\n}\n\n.adate-selection__end-label {\n\tfont-size: 0.8em;\n\tfont-weight: bold;\n\tcolor: var(--sc-input-active-label-color);\n\tmargin-top: 8px;\n\tmargin-bottom: 2px;\n\tpadding-left: 2px;\n}\n\n.empty {\n\tcolor: var(--sc-input-label-color);\n\tpadding: 10px;\n\ttext-align: center;\n\tborder: 1px solid var(--sc-input-border-color);\n}\n</style>\n","import { onClickOutside } from '@vueuse/core'\nimport { type ComponentPublicInstance, nextTick, ref, type ShallowRef, useId } from 'vue'\n\n/** The keys a date field opens its calendar on: the ones a date input opens the browser's own calendar on, in Chrome. */\nexport const opensCalendar = (event: KeyboardEvent) =>\n\tevent.key === ' ' || event.key === 'F4' || (event.altKey && event.key === 'ArrowDown')\n\n/**\n * The calendar a date field opens from its box, and the keys and focus that go with it.\n * @param box - the field's box, which focus returns to when the calendar closes\n * @param calendar - the calendar, while it is open\n * @param uuid - the field's own id, when it has one\n */\nexport function useFieldCalendar(\n\tbox: Readonly<ShallowRef<HTMLElement | null>>,\n\tcalendar: Readonly<ShallowRef<ComponentPublicInstance | null>>,\n\tuuid: string | undefined\n) {\n\tconst showPicker = ref(false)\n\t// Unique for a standalone mount too, so two fields on one page can't cross-wire `aria-controls`.\n\tconst calendarId = `${uuid ?? `aform-date-${useId()}`}-calendar`\n\n\tonClickOutside(calendar, () => (showPicker.value = false))\n\n\tconst closePicker = () => {\n\t\tbox.value?.focus()\n\t\tshowPicker.value = false\n\t}\n\n\tconst openFromKey = async (event: KeyboardEvent) => {\n\t\t// A read-only box's arrows have nothing else to do, so plain Down opens it too, as a combobox's does.\n\t\tconst readOnlyDown = event.key === 'ArrowDown' && box.value instanceof HTMLInputElement && box.value.readOnly\n\t\tif (!opensCalendar(event) && !readOnlyDown) return\n\t\tevent.preventDefault()\n\t\tshowPicker.value = true\n\t\tawait nextTick()\n\t\tconst root: unknown = calendar.value?.$el\n\t\t// The calendar's one Tab stop is the day it has focused.\n\t\tif (root instanceof HTMLElement) root.querySelector<HTMLElement>('[role=\"grid\"] [tabindex=\"0\"]')?.focus()\n\t}\n\n\tconst closeOnEscape = (event: KeyboardEvent) => {\n\t\tif (event.key !== 'Escape' || !showPicker.value) return\n\t\tevent.stopPropagation()\n\t\tclosePicker()\n\t}\n\n\tconst closeWhenFocusLeaves = (event: FocusEvent) => {\n\t\tconst field = event.currentTarget\n\t\tconst next = event.relatedTarget\n\t\tif (!(field instanceof Node && next instanceof Node && field.contains(next))) showPicker.value = false\n\t}\n\n\treturn { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves }\n}\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<!-- `.prevent` and the calendar's keys keep the browser's own calendar shut: aform's is the only one this field opens.\n\t\t\t A date input cannot take the combobox role, and `aria-expanded` is not allowed on it. -->\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"date\"\n\t\t\t\tv-model=\"boxDay\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"date\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click.prevent=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adate-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:default-date=\"modelValue || undefined\"\n\t\t\t\t:select-range=\"false\"\n\t\t\t\t:show-time=\"false\"\n\t\t\t\t@get-date=\"handleDate\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, useTemplateRef, computed } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport ADateSelection from './ADateSelection.vue'\nimport type { ComponentProps } from '../../types'\nimport { dayFromBox } from '../../utils/emptiedBox'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst {\n\tlabel = 'Date',\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n} = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\n// The field holds a `YYYY-MM-DD` day, which is also the date input's own value; a Date would be an instant.\nconst modelValue = defineModel<string | null>()\n\nconst boxDay = computed({\n\tget: () => modelValue.value,\n\tset: (text: string) => (modelValue.value = dayFromBox(text)),\n})\n\nconst displayValue = computed(() =>\n\tmodelValue.value ? (fromISODate(modelValue.value)?.toLocaleString() ?? 'Invalid Date') : ''\n)\n\nconst { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('date'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = !showPicker.value\n}\n\nconst handleDate = (data: { selected: string }) => {\n\tmodelValue.value = data.selected\n\tclosePicker()\n}\n</script>\n\n<style scoped>\n.adate-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<!-- `.prevent` and the calendar's keys keep the browser's own calendar shut: aform's is the only one this field opens.\n\t\t\t A date input cannot take the combobox role, and `aria-expanded` is not allowed on it. -->\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"date\"\n\t\t\t\tv-model=\"boxDay\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"date\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click.prevent=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adate-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:default-date=\"modelValue || undefined\"\n\t\t\t\t:select-range=\"false\"\n\t\t\t\t:show-time=\"false\"\n\t\t\t\t@get-date=\"handleDate\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, useTemplateRef, computed } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport ADateSelection from './ADateSelection.vue'\nimport type { ComponentProps } from '../../types'\nimport { dayFromBox } from '../../utils/emptiedBox'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst {\n\tlabel = 'Date',\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n} = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\n// The field holds a `YYYY-MM-DD` day, which is also the date input's own value; a Date would be an instant.\nconst modelValue = defineModel<string | null>()\n\nconst boxDay = computed({\n\tget: () => modelValue.value,\n\tset: (text: string) => (modelValue.value = dayFromBox(text)),\n})\n\nconst displayValue = computed(() =>\n\tmodelValue.value ? (fromISODate(modelValue.value)?.toLocaleString() ?? 'Invalid Date') : ''\n)\n\nconst { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('date'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = !showPicker.value\n}\n\nconst handleDate = (data: { selected: string }) => {\n\tmodelValue.value = data.selected\n\tclosePicker()\n}\n</script>\n\n<style scoped>\n.adate-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<span v-if=\"displayLabel\" :class=\"classes\" :style=\"styleVars\">{{ displayLabel }}</span>\n</template>\n\n<script setup lang=\"ts\">\nimport type { BadgeDescriptor, BadgePresentation, BadgeVariant, FieldOptions } from '@stonecrop/schema'\nimport { lookupBadge } from '@stonecrop/schema'\nimport { computed, type CSSProperties } from 'vue'\n\nconst props = defineProps<\n\tPartial<BadgeDescriptor> & {\n\t\t/** Defaults to `cell-fill`: every call site fully determines this, so omitting it should\n\t\t * degrade to the common case rather than rendering an unstyled badge. */\n\t\tpresentation?: BadgePresentation\n\t\t/** Stored field value — used with `options` when `label` is omitted. */\n\t\tvalue?: unknown\n\t\toptions?: FieldOptions\n\t}\n>()\n\nconst resolved = computed((): BadgeDescriptor | undefined => {\n\tif (props.label?.trim()) {\n\t\treturn {\n\t\t\tlabel: props.label.trim(),\n\t\t\tvariant: props.variant,\n\t\t\tcolor: props.color,\n\t\t}\n\t}\n\tif (props.value === null || props.value === undefined || props.value === '') return undefined\n\tconst key = typeof props.value === 'string' ? props.value : String(props.value)\n\treturn lookupBadge(props.options, key)\n})\n\nconst displayLabel = computed(() => resolved.value?.label?.trim() ?? '')\n\nconst activeVariant = computed((): BadgeVariant => resolved.value?.variant ?? props.variant ?? 'neutral')\n\nconst activeColor = computed(() => resolved.value?.color ?? props.color)\n\nconst classes = computed(() => [\n\t'abadge',\n\t`abadge--${props.presentation ?? 'cell-fill'}`,\n\t`abadge--${activeVariant.value}`,\n])\n\nconst styleVars = computed((): CSSProperties => {\n\tconst color = activeColor.value\n\tif (!color) return {}\n\treturn {\n\t\t'--sc-badge-bg': color,\n\t\t'--sc-badge-text': color,\n\t\t'--sc-badge-accent': color,\n\t} as CSSProperties\n})\n\nexport type { BadgePresentation, BadgeVariant }\n</script>\n\n<style scoped>\n.abadge {\n\tdisplay: block;\n\tbox-sizing: border-box;\n\tfont: inherit;\n\tline-height: inherit;\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n.abadge--cell-fill {\n\tdisplay: block;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: calc(var(--sc-atable-row-height) + 2 * var(--sc-atable-row-padding));\n\tline-height: calc(var(--sc-atable-row-height) + 2 * var(--sc-atable-row-padding));\n\tmargin: 0;\n\tpadding: 0 0.5ch;\n\tborder-radius: 0;\n\ttext-align: inherit;\n\tbackground: var(--sc-badge-bg);\n\tcolor: var(--sc-badge-text);\n}\n\n.abadge--cell-fill.abadge--neutral {\n\t--sc-badge-bg: var(--sc-badge-neutral-bg);\n\t--sc-badge-text: var(--sc-badge-neutral-text);\n}\n\n.abadge--cell-fill.abadge--success {\n\t--sc-badge-bg: var(--sc-badge-success-bg);\n\t--sc-badge-text: var(--sc-badge-success-text);\n}\n\n.abadge--cell-fill.abadge--warning {\n\t--sc-badge-bg: var(--sc-badge-warning-bg);\n\t--sc-badge-text: var(--sc-badge-warning-text);\n}\n\n.abadge--cell-fill.abadge--danger {\n\t--sc-badge-bg: var(--sc-badge-danger-bg);\n\t--sc-badge-text: var(--sc-badge-danger-text);\n}\n\n.abadge--cell-fill.abadge--brand {\n\t--sc-badge-bg: var(--sc-badge-brand-bg);\n\t--sc-badge-text: var(--sc-badge-brand-text);\n}\n\n.abadge--input-accent {\n\tbackground: var(--sc-input-field-background);\n\tcolor: inherit;\n\tborder-left: 4px solid var(--sc-badge-accent);\n\tpadding-left: calc(1ch - 4px);\n}\n\n.abadge--input-accent.abadge--neutral {\n\t--sc-badge-accent: var(--sc-badge-neutral-accent);\n}\n\n.abadge--input-accent.abadge--success {\n\t--sc-badge-accent: var(--sc-badge-success-accent);\n}\n\n.abadge--input-accent.abadge--warning {\n\t--sc-badge-accent: var(--sc-badge-warning-accent);\n}\n\n.abadge--input-accent.abadge--danger {\n\t--sc-badge-accent: var(--sc-badge-danger-accent);\n}\n\n.abadge--input-accent.abadge--brand {\n\t--sc-badge-accent: var(--sc-badge-brand-accent);\n}\n</style>\n","<template>\n\t<span v-if=\"displayLabel\" :class=\"classes\" :style=\"styleVars\">{{ displayLabel }}</span>\n</template>\n\n<script setup lang=\"ts\">\nimport type { BadgeDescriptor, BadgePresentation, BadgeVariant, FieldOptions } from '@stonecrop/schema'\nimport { lookupBadge } from '@stonecrop/schema'\nimport { computed, type CSSProperties } from 'vue'\n\nconst props = defineProps<\n\tPartial<BadgeDescriptor> & {\n\t\t/** Defaults to `cell-fill`: every call site fully determines this, so omitting it should\n\t\t * degrade to the common case rather than rendering an unstyled badge. */\n\t\tpresentation?: BadgePresentation\n\t\t/** Stored field value — used with `options` when `label` is omitted. */\n\t\tvalue?: unknown\n\t\toptions?: FieldOptions\n\t}\n>()\n\nconst resolved = computed((): BadgeDescriptor | undefined => {\n\tif (props.label?.trim()) {\n\t\treturn {\n\t\t\tlabel: props.label.trim(),\n\t\t\tvariant: props.variant,\n\t\t\tcolor: props.color,\n\t\t}\n\t}\n\tif (props.value === null || props.value === undefined || props.value === '') return undefined\n\tconst key = typeof props.value === 'string' ? props.value : String(props.value)\n\treturn lookupBadge(props.options, key)\n})\n\nconst displayLabel = computed(() => resolved.value?.label?.trim() ?? '')\n\nconst activeVariant = computed((): BadgeVariant => resolved.value?.variant ?? props.variant ?? 'neutral')\n\nconst activeColor = computed(() => resolved.value?.color ?? props.color)\n\nconst classes = computed(() => [\n\t'abadge',\n\t`abadge--${props.presentation ?? 'cell-fill'}`,\n\t`abadge--${activeVariant.value}`,\n])\n\nconst styleVars = computed((): CSSProperties => {\n\tconst color = activeColor.value\n\tif (!color) return {}\n\treturn {\n\t\t'--sc-badge-bg': color,\n\t\t'--sc-badge-text': color,\n\t\t'--sc-badge-accent': color,\n\t} as CSSProperties\n})\n\nexport type { BadgePresentation, BadgeVariant }\n</script>\n\n<style scoped>\n.abadge {\n\tdisplay: block;\n\tbox-sizing: border-box;\n\tfont: inherit;\n\tline-height: inherit;\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n}\n\n.abadge--cell-fill {\n\tdisplay: block;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: calc(var(--sc-atable-row-height) + 2 * var(--sc-atable-row-padding));\n\tline-height: calc(var(--sc-atable-row-height) + 2 * var(--sc-atable-row-padding));\n\tmargin: 0;\n\tpadding: 0 0.5ch;\n\tborder-radius: 0;\n\ttext-align: inherit;\n\tbackground: var(--sc-badge-bg);\n\tcolor: var(--sc-badge-text);\n}\n\n.abadge--cell-fill.abadge--neutral {\n\t--sc-badge-bg: var(--sc-badge-neutral-bg);\n\t--sc-badge-text: var(--sc-badge-neutral-text);\n}\n\n.abadge--cell-fill.abadge--success {\n\t--sc-badge-bg: var(--sc-badge-success-bg);\n\t--sc-badge-text: var(--sc-badge-success-text);\n}\n\n.abadge--cell-fill.abadge--warning {\n\t--sc-badge-bg: var(--sc-badge-warning-bg);\n\t--sc-badge-text: var(--sc-badge-warning-text);\n}\n\n.abadge--cell-fill.abadge--danger {\n\t--sc-badge-bg: var(--sc-badge-danger-bg);\n\t--sc-badge-text: var(--sc-badge-danger-text);\n}\n\n.abadge--cell-fill.abadge--brand {\n\t--sc-badge-bg: var(--sc-badge-brand-bg);\n\t--sc-badge-text: var(--sc-badge-brand-text);\n}\n\n.abadge--input-accent {\n\tbackground: var(--sc-input-field-background);\n\tcolor: inherit;\n\tborder-left: 4px solid var(--sc-badge-accent);\n\tpadding-left: calc(1ch - 4px);\n}\n\n.abadge--input-accent.abadge--neutral {\n\t--sc-badge-accent: var(--sc-badge-neutral-accent);\n}\n\n.abadge--input-accent.abadge--success {\n\t--sc-badge-accent: var(--sc-badge-success-accent);\n}\n\n.abadge--input-accent.abadge--warning {\n\t--sc-badge-accent: var(--sc-badge-warning-accent);\n}\n\n.abadge--input-accent.abadge--danger {\n\t--sc-badge-accent: var(--sc-badge-danger-accent);\n}\n\n.abadge--input-accent.abadge--brand {\n\t--sc-badge-accent: var(--sc-badge-brand-accent);\n}\n</style>\n","<template>\n\t<div\n\t\tclass=\"aform_form-element aform_segmented-control\"\n\t\t:class=\"{\n\t\t\t'aform_segmented-control--xs': size === 'xs',\n\t\t\t'aform_segmented-control--sm': size === 'sm',\n\t\t\t'aform_segmented-control--equal': equal,\n\t\t}\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<label class=\"aform_field-label\" :class=\"{ 'aform_segmented-sr-label': hideLabel }\">{{ label }}</label>\n\t\t\t<ABadge\n\t\t\t\tv-if=\"displayBadge\"\n\t\t\t\tclass=\"aform_display-value aform_segmented-display-badge\"\n\t\t\t\t:value=\"displayBadgeValue\"\n\t\t\t\t:options=\"options\"\n\t\t\t\tpresentation=\"input-accent\" />\n\t\t\t<span v-else class=\"aform_display-value\">{{ displayText }}</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<label :id=\"labelId\" class=\"aform_field-label\" :class=\"{ 'aform_segmented-sr-label': hideLabel }\">\n\t\t\t\t{{ label }}\n\t\t\t</label>\n\t\t\t<div\n\t\t\t\t:role=\"multiple ? 'group' : 'radiogroup'\"\n\t\t\t\tclass=\"aform_segmented-track\"\n\t\t\t\t:aria-labelledby=\"groupAriaLabel ? undefined : labelId\"\n\t\t\t\t:aria-label=\"groupAriaLabel\"\n\t\t\t\t:aria-busy=\"busy || undefined\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\">\n\t\t\t\t<label\n\t\t\t\t\tv-for=\"choice in choices\"\n\t\t\t\t\t:key=\"choice\"\n\t\t\t\t\tclass=\"aform_segmented-segment\"\n\t\t\t\t\t:class=\"segmentClasses(choice)\"\n\t\t\t\t\t:style=\"segmentStyle(choice)\"\n\t\t\t\t\t:data-segment-value=\"choice\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-if=\"multiple\"\n\t\t\t\t\t\tv-model=\"selectedMany\"\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\tclass=\"aform_segmented-input\"\n\t\t\t\t\t\t:name=\"groupName\"\n\t\t\t\t\t\t:value=\"choice\"\n\t\t\t\t\t\t:disabled=\"mode === 'read'\" />\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-else\n\t\t\t\t\t\tv-model=\"selected\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tclass=\"aform_segmented-input\"\n\t\t\t\t\t\t:name=\"groupName\"\n\t\t\t\t\t\t:value=\"choice\"\n\t\t\t\t\t\t:disabled=\"mode === 'read'\" />\n\t\t\t\t\t<span class=\"aform_segmented-label\">{{ segmentLabel(choice) }}</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { BadgeVariant, FieldOptions } from '@stonecrop/schema'\nimport { hasBadgeOptions, lookupBadge, selectChoices } from '@stonecrop/schema'\nimport { computed, useId, type CSSProperties } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport ABadge from './ABadge.vue'\n\nconst {\n\tlabel,\n\toptions = undefined,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tsize = 'sm',\n\tequal = false,\n\thideLabel = false,\n\tariaLabel = undefined,\n\tbusy = false,\n\tmultiple = false,\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: FieldOptions\n\t\tsize?: 'xs' | 'sm'\n\t\tequal?: boolean\n\t\thideLabel?: boolean\n\t\tariaLabel?: string\n\t\tbusy?: boolean\n\t\tmultiple?: boolean\n\t}\n>()\n\nconst selected = defineModel<string | string[]>({ default: '' })\n\nconst selectedMany = computed({\n\tget: () => (Array.isArray(selected.value) ? selected.value : []),\n\tset: (value: string[]) => {\n\t\tselected.value = value\n\t},\n})\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst fallbackId = useId()\nconst groupName = computed(() => uuid ?? `aform-segmented-${fallbackId}`)\nconst labelId = computed(() => `${groupName.value}-label`)\n\n// aria-labelledby outranks aria-label in the accessible-name algorithm, so the two are mutually\n// exclusive here: emitting both would silently leave `ariaLabel` inert. It only applies while the\n// label element is visually hidden — overriding a *visible* label would break WCAG 2.5.3.\nconst groupAriaLabel = computed(() => (hideLabel ? ariaLabel : undefined))\n\nconst choices = computed(() => selectChoices(options))\nconst badgeOptions = computed(() => hasBadgeOptions(options))\n\nfunction segmentLabel(choice: string): string {\n\treturn lookupBadge(options, choice)?.label ?? choice\n}\n\nfunction segmentVariant(choice: string): BadgeVariant {\n\treturn lookupBadge(options, choice)?.variant ?? 'neutral'\n}\n\nfunction isChoiceSelected(choice: string): boolean {\n\tif (multiple) return selectedMany.value.includes(choice)\n\treturn selected.value === choice\n}\n\nfunction segmentClasses(choice: string): Record<string, boolean> {\n\tif (!badgeOptions.value) return {}\n\treturn {\n\t\t'aform_segmented-segment--badge': true,\n\t\t[`aform_segmented-segment--${segmentVariant(choice)}`]: isChoiceSelected(choice),\n\t}\n}\n\nfunction segmentStyle(choice: string): CSSProperties {\n\tif (!badgeOptions.value || !isChoiceSelected(choice)) return {}\n\tconst color = lookupBadge(options, choice)?.color\n\tif (!color) return {}\n\treturn {\n\t\t'--sc-badge-bg': color,\n\t\t'--sc-badge-text': color,\n\t} as CSSProperties\n}\n\nconst displayText = computed(() => {\n\tif (multiple) {\n\t\treturn selectedMany.value.map(segmentLabel).filter(Boolean).join(', ')\n\t}\n\tconst value = selected.value\n\tif (typeof value !== 'string' || value === '') return ''\n\treturn segmentLabel(value)\n})\n\nconst displayBadge = computed(() => {\n\tif (!badgeOptions.value) return false\n\tif (multiple) return selectedMany.value.length === 1\n\treturn typeof selected.value === 'string' && selected.value !== ''\n})\n\nconst displayBadgeValue = computed(() => {\n\tif (multiple) return selectedMany.value[0] ?? ''\n\treturn typeof selected.value === 'string' ? selected.value : ''\n})\n</script>\n\n<style scoped>\n.aform_segmented-control--xs.aform_form-element {\n\tmin-width: 0;\n\tpadding-top: 0;\n\tmax-width: none;\n}\n\n.aform_segmented-control--xs:not(:has(.aform_segmented-sr-label)) {\n\tpadding-top: 0.5rem;\n}\n\n.aform_segmented-sr-label {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.aform_segmented-track {\n\tdisplay: inline-flex;\n\tflex-wrap: wrap;\n\talign-items: stretch;\n\tgap: 0.125rem;\n\tpadding: 0.125rem;\n\twidth: auto;\n\tmin-width: 0;\n\tmin-height: 2rem;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tborder-radius: 0;\n\tbox-sizing: border-box;\n\tbackground: var(--sc-input-addon-background);\n\tfont-family: var(--sc-font-family);\n}\n\n.aform_segmented-control--xs .aform_segmented-track {\n\tmin-height: 1.5rem;\n\tfont-size: 0.875rem;\n}\n\n.aform_segmented-control--equal .aform_segmented-track {\n\tdisplay: flex;\n\twidth: 100%;\n}\n\n.aform_segmented-segment {\n\tposition: relative;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tflex: none;\n\tmargin: 0;\n\tpadding: 0.125rem 0.5rem;\n\tmin-height: 1.5rem;\n\tborder-radius: 0;\n\tcolor: var(--sc-input-label-color);\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tfont-weight: 400;\n\tline-height: 1.25;\n\tcursor: pointer;\n\tuser-select: none;\n\tbox-sizing: border-box;\n}\n\n.aform_segmented-control--sm .aform_segmented-segment {\n\tmin-height: 1.75rem;\n\tpadding: 0.125rem 0.75rem;\n\tfont-size: var(--sc-font-size);\n}\n\n.aform_segmented-control--equal .aform_segmented-segment {\n\tflex: 1 1 0;\n}\n\n.aform_segmented-input {\n\tposition: absolute;\n\tinline-size: 1px;\n\tblock-size: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.aform_segmented-label {\n\tpointer-events: none;\n}\n\n.aform_segmented-segment:not(.aform_segmented-segment--badge):has(.aform_segmented-input:checked) {\n\tbackground: var(--sc-form-background);\n\tcolor: var(--sc-cell-text-color);\n\tfont-weight: 500;\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked) {\n\tfont-weight: 500;\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--neutral {\n\tbackground: var(--sc-badge-neutral-bg);\n\tcolor: var(--sc-badge-neutral-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--success {\n\tbackground: var(--sc-badge-success-bg);\n\tcolor: var(--sc-badge-success-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--warning {\n\tbackground: var(--sc-badge-warning-bg);\n\tcolor: var(--sc-badge-warning-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--danger {\n\tbackground: var(--sc-badge-danger-bg);\n\tcolor: var(--sc-badge-danger-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--brand {\n\tbackground: var(--sc-badge-brand-bg);\n\tcolor: var(--sc-badge-brand-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked)[style*='--sc-badge-bg'] {\n\tbackground: var(--sc-badge-bg);\n\tcolor: var(--sc-badge-text);\n}\n\n.aform_segmented-segment:has(.aform_segmented-input:focus-visible) {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n\n.aform_segmented-segment:hover:has(.aform_segmented-input:not(:disabled):not(:checked)) {\n\tbackground: color-mix(in srgb, var(--sc-form-background) 50%, transparent);\n}\n\n.aform_segmented-segment:has(.aform_segmented-input:disabled) {\n\tcursor: not-allowed;\n\topacity: 0.5;\n}\n\n.aform_segmented-track:has(.aform_segmented-input:focus-visible) {\n\toutline-color: var(--sc-input-active-border-color);\n}\n\n.aform_segmented-display-badge {\n\tdisplay: block;\n\tpadding: 0.5rem;\n\tmin-height: 2rem;\n\tbox-sizing: border-box;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n\t.aform_segmented-segment {\n\t\ttransition:\n\t\t\tbackground-color 0.1s ease-out,\n\t\t\tcolor 0.1s ease-out;\n\t}\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.aform_segmented-segment {\n\t\ttransition: none;\n\t}\n}\n</style>\n","<template>\n\t<div\n\t\tclass=\"aform_form-element aform_segmented-control\"\n\t\t:class=\"{\n\t\t\t'aform_segmented-control--xs': size === 'xs',\n\t\t\t'aform_segmented-control--sm': size === 'sm',\n\t\t\t'aform_segmented-control--equal': equal,\n\t\t}\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<label class=\"aform_field-label\" :class=\"{ 'aform_segmented-sr-label': hideLabel }\">{{ label }}</label>\n\t\t\t<ABadge\n\t\t\t\tv-if=\"displayBadge\"\n\t\t\t\tclass=\"aform_display-value aform_segmented-display-badge\"\n\t\t\t\t:value=\"displayBadgeValue\"\n\t\t\t\t:options=\"options\"\n\t\t\t\tpresentation=\"input-accent\" />\n\t\t\t<span v-else class=\"aform_display-value\">{{ displayText }}</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<label :id=\"labelId\" class=\"aform_field-label\" :class=\"{ 'aform_segmented-sr-label': hideLabel }\">\n\t\t\t\t{{ label }}\n\t\t\t</label>\n\t\t\t<div\n\t\t\t\t:role=\"multiple ? 'group' : 'radiogroup'\"\n\t\t\t\tclass=\"aform_segmented-track\"\n\t\t\t\t:aria-labelledby=\"groupAriaLabel ? undefined : labelId\"\n\t\t\t\t:aria-label=\"groupAriaLabel\"\n\t\t\t\t:aria-busy=\"busy || undefined\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\">\n\t\t\t\t<label\n\t\t\t\t\tv-for=\"choice in choices\"\n\t\t\t\t\t:key=\"choice\"\n\t\t\t\t\tclass=\"aform_segmented-segment\"\n\t\t\t\t\t:class=\"segmentClasses(choice)\"\n\t\t\t\t\t:style=\"segmentStyle(choice)\"\n\t\t\t\t\t:data-segment-value=\"choice\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-if=\"multiple\"\n\t\t\t\t\t\tv-model=\"selectedMany\"\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\tclass=\"aform_segmented-input\"\n\t\t\t\t\t\t:name=\"groupName\"\n\t\t\t\t\t\t:value=\"choice\"\n\t\t\t\t\t\t:disabled=\"mode === 'read'\" />\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-else\n\t\t\t\t\t\tv-model=\"selected\"\n\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\tclass=\"aform_segmented-input\"\n\t\t\t\t\t\t:name=\"groupName\"\n\t\t\t\t\t\t:value=\"choice\"\n\t\t\t\t\t\t:disabled=\"mode === 'read'\" />\n\t\t\t\t\t<span class=\"aform_segmented-label\">{{ segmentLabel(choice) }}</span>\n\t\t\t\t</label>\n\t\t\t</div>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport type { BadgeVariant, FieldOptions } from '@stonecrop/schema'\nimport { hasBadgeOptions, lookupBadge, selectChoices } from '@stonecrop/schema'\nimport { computed, useId, type CSSProperties } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport ABadge from './ABadge.vue'\n\nconst {\n\tlabel,\n\toptions = undefined,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tsize = 'sm',\n\tequal = false,\n\thideLabel = false,\n\tariaLabel = undefined,\n\tbusy = false,\n\tmultiple = false,\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: FieldOptions\n\t\tsize?: 'xs' | 'sm'\n\t\tequal?: boolean\n\t\thideLabel?: boolean\n\t\tariaLabel?: string\n\t\tbusy?: boolean\n\t\tmultiple?: boolean\n\t}\n>()\n\nconst selected = defineModel<string | string[]>({ default: '' })\n\nconst selectedMany = computed({\n\tget: () => (Array.isArray(selected.value) ? selected.value : []),\n\tset: (value: string[]) => {\n\t\tselected.value = value\n\t},\n})\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst fallbackId = useId()\nconst groupName = computed(() => uuid ?? `aform-segmented-${fallbackId}`)\nconst labelId = computed(() => `${groupName.value}-label`)\n\n// aria-labelledby outranks aria-label in the accessible-name algorithm, so the two are mutually\n// exclusive here: emitting both would silently leave `ariaLabel` inert. It only applies while the\n// label element is visually hidden — overriding a *visible* label would break WCAG 2.5.3.\nconst groupAriaLabel = computed(() => (hideLabel ? ariaLabel : undefined))\n\nconst choices = computed(() => selectChoices(options))\nconst badgeOptions = computed(() => hasBadgeOptions(options))\n\nfunction segmentLabel(choice: string): string {\n\treturn lookupBadge(options, choice)?.label ?? choice\n}\n\nfunction segmentVariant(choice: string): BadgeVariant {\n\treturn lookupBadge(options, choice)?.variant ?? 'neutral'\n}\n\nfunction isChoiceSelected(choice: string): boolean {\n\tif (multiple) return selectedMany.value.includes(choice)\n\treturn selected.value === choice\n}\n\nfunction segmentClasses(choice: string): Record<string, boolean> {\n\tif (!badgeOptions.value) return {}\n\treturn {\n\t\t'aform_segmented-segment--badge': true,\n\t\t[`aform_segmented-segment--${segmentVariant(choice)}`]: isChoiceSelected(choice),\n\t}\n}\n\nfunction segmentStyle(choice: string): CSSProperties {\n\tif (!badgeOptions.value || !isChoiceSelected(choice)) return {}\n\tconst color = lookupBadge(options, choice)?.color\n\tif (!color) return {}\n\treturn {\n\t\t'--sc-badge-bg': color,\n\t\t'--sc-badge-text': color,\n\t} as CSSProperties\n}\n\nconst displayText = computed(() => {\n\tif (multiple) {\n\t\treturn selectedMany.value.map(segmentLabel).filter(Boolean).join(', ')\n\t}\n\tconst value = selected.value\n\tif (typeof value !== 'string' || value === '') return ''\n\treturn segmentLabel(value)\n})\n\nconst displayBadge = computed(() => {\n\tif (!badgeOptions.value) return false\n\tif (multiple) return selectedMany.value.length === 1\n\treturn typeof selected.value === 'string' && selected.value !== ''\n})\n\nconst displayBadgeValue = computed(() => {\n\tif (multiple) return selectedMany.value[0] ?? ''\n\treturn typeof selected.value === 'string' ? selected.value : ''\n})\n</script>\n\n<style scoped>\n.aform_segmented-control--xs.aform_form-element {\n\tmin-width: 0;\n\tpadding-top: 0;\n\tmax-width: none;\n}\n\n.aform_segmented-control--xs:not(:has(.aform_segmented-sr-label)) {\n\tpadding-top: 0.5rem;\n}\n\n.aform_segmented-sr-label {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.aform_segmented-track {\n\tdisplay: inline-flex;\n\tflex-wrap: wrap;\n\talign-items: stretch;\n\tgap: 0.125rem;\n\tpadding: 0.125rem;\n\twidth: auto;\n\tmin-width: 0;\n\tmin-height: 2rem;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tborder-radius: 0;\n\tbox-sizing: border-box;\n\tbackground: var(--sc-input-addon-background);\n\tfont-family: var(--sc-font-family);\n}\n\n.aform_segmented-control--xs .aform_segmented-track {\n\tmin-height: 1.5rem;\n\tfont-size: 0.875rem;\n}\n\n.aform_segmented-control--equal .aform_segmented-track {\n\tdisplay: flex;\n\twidth: 100%;\n}\n\n.aform_segmented-segment {\n\tposition: relative;\n\tdisplay: inline-flex;\n\talign-items: center;\n\tjustify-content: center;\n\tflex: none;\n\tmargin: 0;\n\tpadding: 0.125rem 0.5rem;\n\tmin-height: 1.5rem;\n\tborder-radius: 0;\n\tcolor: var(--sc-input-label-color);\n\tfont-family: inherit;\n\tfont-size: inherit;\n\tfont-weight: 400;\n\tline-height: 1.25;\n\tcursor: pointer;\n\tuser-select: none;\n\tbox-sizing: border-box;\n}\n\n.aform_segmented-control--sm .aform_segmented-segment {\n\tmin-height: 1.75rem;\n\tpadding: 0.125rem 0.75rem;\n\tfont-size: var(--sc-font-size);\n}\n\n.aform_segmented-control--equal .aform_segmented-segment {\n\tflex: 1 1 0;\n}\n\n.aform_segmented-input {\n\tposition: absolute;\n\tinline-size: 1px;\n\tblock-size: 1px;\n\tpadding: 0;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n\tborder: 0;\n}\n\n.aform_segmented-label {\n\tpointer-events: none;\n}\n\n.aform_segmented-segment:not(.aform_segmented-segment--badge):has(.aform_segmented-input:checked) {\n\tbackground: var(--sc-form-background);\n\tcolor: var(--sc-cell-text-color);\n\tfont-weight: 500;\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked) {\n\tfont-weight: 500;\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--neutral {\n\tbackground: var(--sc-badge-neutral-bg);\n\tcolor: var(--sc-badge-neutral-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--success {\n\tbackground: var(--sc-badge-success-bg);\n\tcolor: var(--sc-badge-success-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--warning {\n\tbackground: var(--sc-badge-warning-bg);\n\tcolor: var(--sc-badge-warning-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--danger {\n\tbackground: var(--sc-badge-danger-bg);\n\tcolor: var(--sc-badge-danger-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked).aform_segmented-segment--brand {\n\tbackground: var(--sc-badge-brand-bg);\n\tcolor: var(--sc-badge-brand-text);\n}\n\n.aform_segmented-segment--badge:has(.aform_segmented-input:checked)[style*='--sc-badge-bg'] {\n\tbackground: var(--sc-badge-bg);\n\tcolor: var(--sc-badge-text);\n}\n\n.aform_segmented-segment:has(.aform_segmented-input:focus-visible) {\n\toutline: 1px solid var(--sc-input-active-border-color);\n\toutline-offset: -1px;\n}\n\n.aform_segmented-segment:hover:has(.aform_segmented-input:not(:disabled):not(:checked)) {\n\tbackground: color-mix(in srgb, var(--sc-form-background) 50%, transparent);\n}\n\n.aform_segmented-segment:has(.aform_segmented-input:disabled) {\n\tcursor: not-allowed;\n\topacity: 0.5;\n}\n\n.aform_segmented-track:has(.aform_segmented-input:focus-visible) {\n\toutline-color: var(--sc-input-active-border-color);\n}\n\n.aform_segmented-display-badge {\n\tdisplay: block;\n\tpadding: 0.5rem;\n\tmin-height: 2rem;\n\tbox-sizing: border-box;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n\t.aform_segmented-segment {\n\t\ttransition:\n\t\t\tbackground-color 0.1s ease-out,\n\t\t\tcolor 0.1s ease-out;\n\t}\n}\n\n@media (prefers-reduced-motion: reduce) {\n\t.aform_segmented-segment {\n\t\ttransition: none;\n\t}\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"box\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-expanded=\"showPicker\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:value=\"datetimeDisplay\"\n\t\t\t\tplaceholder=\"Select date and time\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\treadonly\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adatetime-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:select-range=\"false\"\n\t\t\t\t:show-date=\"true\"\n\t\t\t\t:show-time=\"true\"\n\t\t\t\t:default-date=\"currentDateTime?.toPlainDate().toString()\"\n\t\t\t\t:default-hours=\"pickerDefaults.hours\"\n\t\t\t\t:default-minutes=\"pickerDefaults.minutes\"\n\t\t\t\t:default-seconds=\"pickerDefaults.seconds\"\n\t\t\t\t:default-meridiem=\"pickerDefaults.meridiem\"\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-date=\"handleDate\"\n\t\t\t\t@get-time=\"handleTime\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, ref, computed, useTemplateRef, watch } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport ADateSelection from './ADateSelection.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst {\n\tlabel = 'Date & Time',\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tallowMilitaryTime = false,\n\tuseSeconds = true,\n} = defineProps<\n\tComponentProps & {\n\t\tallowMilitaryTime?: boolean\n\t\tuseSeconds?: boolean\n\t}\n>()\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst modelValue = defineModel<string | Date | null>()\n\n/** Now, cut down to the smallest unit the picker shows, so a pick that leaves the time alone saves the time shown. */\nconst now = () =>\n\tTemporal.Now.zonedDateTimeISO().round({ smallestUnit: useSeconds ? 'second' : 'minute', roundingMode: 'trunc' })\n\n/** The field's moment on the user's clock, or null when the value names no moment. */\nconst readMoment = (value: string | Date): Temporal.ZonedDateTime | null => {\n\tconst epochMilliseconds = new Date(value).getTime()\n\tif (isNaN(epochMilliseconds)) return null\n\treturn Temporal.Instant.fromEpochMilliseconds(epochMilliseconds).toZonedDateTimeISO(Temporal.Now.timeZoneId())\n}\n\n/** What the field holds for a value: its moment, or now for an empty field, where the picker starts. */\nconst heldMoment = (value: string | Date | null | undefined) => (value ? readMoment(value) : now())\n\nconst currentDateTime = ref<Temporal.ZonedDateTime | null>(heldMoment(modelValue.value))\n\nconst { showPicker, calendarId, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('box'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = true\n}\n\n// A date and time as `toLocaleString` writes one by default, less the seconds.\nconst WITHOUT_SECONDS: Intl.DateTimeFormatOptions = {\n\tyear: 'numeric',\n\tmonth: 'numeric',\n\tday: 'numeric',\n\thour: 'numeric',\n\tminute: 'numeric',\n}\n\nconst displayValue = computed(() => {\n\tif (!modelValue.value) return ''\n\t// The wall-clock time alone: a `ZonedDateTime`'s own `toLocaleString` also names the zone.\n\tconst format = useSeconds ? undefined : WITHOUT_SECONDS\n\treturn currentDateTime.value?.toPlainDateTime().toLocaleString(undefined, format) ?? 'Invalid Date'\n})\n\nconst datetimeDisplay = computed(() => displayValue.value)\n\nconst pickerDefaults = computed(() => {\n\tconst d = currentDateTime.value ?? now()\n\tconst hours24 = d.hour\n\tconst meridiem = hours24 >= 12 ? 'PM' : 'AM'\n\tconst hours12 = hours24 % 12 || 12\n\treturn {\n\t\thours: allowMilitaryTime ? hours24 : hours12,\n\t\tminutes: d.minute,\n\t\tseconds: d.second,\n\t\tmeridiem,\n\t}\n})\n\nconst setMoment = (moment: Temporal.ZonedDateTime) => {\n\tcurrentDateTime.value = moment\n\tmodelValue.value = moment.toInstant().toString({ fractionalSecondDigits: 3 })\n}\n\nconst handleDate = (data: { selected: string }) => {\n\tconst day = fromISODate(data.selected)\n\tif (!day) return\n\tsetMoment((currentDateTime.value ?? now()).with({ year: day.year, month: day.month, day: day.day }))\n}\n\nconst handleTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\t// The widget announces its own starting value as it mounts, and those defaults come from\n\t// `pickerDefaults` — i.e. straight back out of this component. Writing that echo to the model\n\t// meant one click on an empty field silently filled it with the current date and time.\n\tif (data.source === 'init') return\n\n\tconst hours = data.militaryTime ?? data.hours\n\tsetMoment(\n\t\t(currentDateTime.value ?? now()).with({\n\t\t\thour: hours,\n\t\t\tminute: data.minutes,\n\t\t\tsecond: useSeconds ? data.seconds : 0,\n\t\t\tmillisecond: 0,\n\t\t\tmicrosecond: 0,\n\t\t\tnanosecond: 0,\n\t\t})\n\t)\n\t// Deliberately does NOT close the picker. `get-time` is the widget's current value, not a\n\t// commit — it fires on every blur, arrow key and meridiem change — so closing here shut the\n\t// picker as soon as the user tabbed out of the hours field. Dismissal is a click outside, Escape\n\t// or focus leaving the field; closing on `get-date` instead would strand the time half of a datetime.\n}\n\n// An empty value resets it too: skipping one kept the cleared moment, which the next pick wrote back.\nwatch(\n\t() => modelValue.value,\n\tnewValue => (currentDateTime.value = heldMoment(newValue))\n)\n</script>\n\n<style scoped>\n.adatetime-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"box\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-expanded=\"showPicker\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:value=\"datetimeDisplay\"\n\t\t\t\tplaceholder=\"Select date and time\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\treadonly\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adatetime-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:select-range=\"false\"\n\t\t\t\t:show-date=\"true\"\n\t\t\t\t:show-time=\"true\"\n\t\t\t\t:default-date=\"currentDateTime?.toPlainDate().toString()\"\n\t\t\t\t:default-hours=\"pickerDefaults.hours\"\n\t\t\t\t:default-minutes=\"pickerDefaults.minutes\"\n\t\t\t\t:default-seconds=\"pickerDefaults.seconds\"\n\t\t\t\t:default-meridiem=\"pickerDefaults.meridiem\"\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-date=\"handleDate\"\n\t\t\t\t@get-time=\"handleTime\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, ref, computed, useTemplateRef, watch } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport ADateSelection from './ADateSelection.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst {\n\tlabel = 'Date & Time',\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\tallowMilitaryTime = false,\n\tuseSeconds = true,\n} = defineProps<\n\tComponentProps & {\n\t\tallowMilitaryTime?: boolean\n\t\tuseSeconds?: boolean\n\t}\n>()\n\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst modelValue = defineModel<string | Date | null>()\n\n/** Now, cut down to the smallest unit the picker shows, so a pick that leaves the time alone saves the time shown. */\nconst now = () =>\n\tTemporal.Now.zonedDateTimeISO().round({ smallestUnit: useSeconds ? 'second' : 'minute', roundingMode: 'trunc' })\n\n/** The field's moment on the user's clock, or null when the value names no moment. */\nconst readMoment = (value: string | Date): Temporal.ZonedDateTime | null => {\n\tconst epochMilliseconds = new Date(value).getTime()\n\tif (isNaN(epochMilliseconds)) return null\n\treturn Temporal.Instant.fromEpochMilliseconds(epochMilliseconds).toZonedDateTimeISO(Temporal.Now.timeZoneId())\n}\n\n/** What the field holds for a value: its moment, or now for an empty field, where the picker starts. */\nconst heldMoment = (value: string | Date | null | undefined) => (value ? readMoment(value) : now())\n\nconst currentDateTime = ref<Temporal.ZonedDateTime | null>(heldMoment(modelValue.value))\n\nconst { showPicker, calendarId, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('box'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = true\n}\n\n// A date and time as `toLocaleString` writes one by default, less the seconds.\nconst WITHOUT_SECONDS: Intl.DateTimeFormatOptions = {\n\tyear: 'numeric',\n\tmonth: 'numeric',\n\tday: 'numeric',\n\thour: 'numeric',\n\tminute: 'numeric',\n}\n\nconst displayValue = computed(() => {\n\tif (!modelValue.value) return ''\n\t// The wall-clock time alone: a `ZonedDateTime`'s own `toLocaleString` also names the zone.\n\tconst format = useSeconds ? undefined : WITHOUT_SECONDS\n\treturn currentDateTime.value?.toPlainDateTime().toLocaleString(undefined, format) ?? 'Invalid Date'\n})\n\nconst datetimeDisplay = computed(() => displayValue.value)\n\nconst pickerDefaults = computed(() => {\n\tconst d = currentDateTime.value ?? now()\n\tconst hours24 = d.hour\n\tconst meridiem = hours24 >= 12 ? 'PM' : 'AM'\n\tconst hours12 = hours24 % 12 || 12\n\treturn {\n\t\thours: allowMilitaryTime ? hours24 : hours12,\n\t\tminutes: d.minute,\n\t\tseconds: d.second,\n\t\tmeridiem,\n\t}\n})\n\nconst setMoment = (moment: Temporal.ZonedDateTime) => {\n\tcurrentDateTime.value = moment\n\tmodelValue.value = moment.toInstant().toString({ fractionalSecondDigits: 3 })\n}\n\nconst handleDate = (data: { selected: string }) => {\n\tconst day = fromISODate(data.selected)\n\tif (!day) return\n\tsetMoment((currentDateTime.value ?? now()).with({ year: day.year, month: day.month, day: day.day }))\n}\n\nconst handleTime = (data: {\n\thours: number\n\tminutes: number\n\tseconds: number\n\tmeridiem: string\n\tmilitaryTime?: number\n\tsource?: 'init' | 'user'\n}) => {\n\t// The widget announces its own starting value as it mounts, and those defaults come from\n\t// `pickerDefaults` — i.e. straight back out of this component. Writing that echo to the model\n\t// meant one click on an empty field silently filled it with the current date and time.\n\tif (data.source === 'init') return\n\n\tconst hours = data.militaryTime ?? data.hours\n\tsetMoment(\n\t\t(currentDateTime.value ?? now()).with({\n\t\t\thour: hours,\n\t\t\tminute: data.minutes,\n\t\t\tsecond: useSeconds ? data.seconds : 0,\n\t\t\tmillisecond: 0,\n\t\t\tmicrosecond: 0,\n\t\t\tnanosecond: 0,\n\t\t})\n\t)\n\t// Deliberately does NOT close the picker. `get-time` is the widget's current value, not a\n\t// commit — it fires on every blur, arrow key and meridiem change — so closing here shut the\n\t// picker as soon as the user tabbed out of the hours field. Dismissal is a click outside, Escape\n\t// or focus leaving the field; closing on `get-date` instead would strand the time half of a datetime.\n}\n\n// An empty value resets it too: skipping one kept the cleared moment, which the next pick wrote back.\nwatch(\n\t() => modelValue.value,\n\tnewValue => (currentDateTime.value = heldMoment(newValue))\n)\n</script>\n\n<style scoped>\n.adatetime-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<div class=\"aduration\">\n\t\t<template v-if=\"mode === 'display' || mode === 'read'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label>{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<ADateSelection\n\t\t\t\tref=\"selectionRef\"\n\t\t\t\t:select-range=\"true\"\n\t\t\t\t:show-time=\"true\"\n\t\t\t\t:show-end-time=\"true\"\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-range=\"handleRange\" />\n\t\t\t<div class=\"aduration__footer\">\n\t\t\t\t<label>{{ label }}</label>\n\t\t\t\t<div v-if=\"startDatetime && endDatetime\" class=\"aduration__summary\">\n\t\t\t\t\t<span class=\"aduration__label\">Duration:</span>\n\t\t\t\t\t<span class=\"aduration__value\">{{ humanDuration }}</span>\n\t\t\t\t\t<span class=\"aduration__held\">({{ modelValue }})</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { Temporal } from 'temporal-polyfill'\nimport { ref, computed } from 'vue'\nimport ADateSelection from './ADateSelection.vue'\n\nconst {\n\tlabel = 'Duration',\n\tmode = 'edit',\n\tallowMilitaryTime = false,\n\tuseSeconds = false,\n} = defineProps<{\n\tlabel?: string\n\tmode?: string\n\tallowMilitaryTime?: boolean\n\tuseSeconds?: boolean\n}>()\n\n// An ISO 8601 duration (`PT1H`), which Postgres and Temporal read natively and which, unlike a\n// count of milliseconds, holds days and months apart from hours.\nconst modelValue = defineModel<string | null>()\n\nconst startDatetime = ref<Date | null>(null)\nconst endDatetime = ref<Date | null>(null)\n\n// The time between two picks, counting a day as 24 hours; a pick before the start is no time at all.\nconst durationBetween = (start: Date, end: Date) =>\n\tTemporal.Duration.from({ milliseconds: Math.max(end.getTime() - start.getTime(), 0) })\n\t\t.round({ largestUnit: 'days' })\n\t\t.toString()\n\nconst handleRange = (data: { start: Date; end: Date; source?: 'init' | 'user' }) => {\n\t// Both time widgets announce their starting values as they mount, which ADateSelection turns\n\t// into a range. That is not a range the user picked: acting on it wrote a zero duration into the\n\t// model, and lit the summary strip, on first render.\n\tif (data.source === 'init') return\n\n\tstartDatetime.value = data.start\n\tendDatetime.value = data.end\n\tmodelValue.value = durationBetween(data.start, data.end)\n}\n\nconst readDuration = (value: string) => {\n\ttry {\n\t\treturn Temporal.Duration.from(value)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nconst UNIT_SUFFIXES = [\n\t['years', 'y'],\n\t['months', 'mo'],\n\t['weeks', 'w'],\n\t['days', 'd'],\n\t['hours', 'h'],\n\t['minutes', 'm'],\n] as const\n\n// The units the duration holds, as it holds them: `PT25H` is 25h, not 1d 1h.\nconst describeDuration = (duration: Temporal.Duration) => {\n\tconst parts = UNIT_SUFFIXES.filter(([unit]) => duration[unit]).map(([unit, suffix]) => `${duration[unit]}${suffix}`)\n\tconst seconds =\n\t\tduration.seconds + duration.milliseconds / 1e3 + duration.microseconds / 1e6 + duration.nanoseconds / 1e9\n\tif (seconds) parts.push(`${seconds}s`)\n\treturn parts.join(' ') || '0s'\n}\n\nconst heldDuration = computed(() => (modelValue.value ? readDuration(modelValue.value) : undefined))\n\nconst humanDuration = computed(() => (heldDuration.value ? describeDuration(heldDuration.value) : '0s'))\n\nconst displayValue = computed(() => {\n\tif (!modelValue.value) return '—'\n\tif (!heldDuration.value) return 'Invalid Duration'\n\treturn heldDuration.value.blank ? '—' : describeDuration(heldDuration.value)\n})\n</script>\n\n<style scoped>\n.aduration {\n\tposition: relative;\n\twidth: max-content;\n\tmax-width: 100%;\n}\n\n.aduration__summary {\n\tdisplay: flex;\n\tgap: 6px;\n\talign-items: baseline;\n\tmargin-top: 6px;\n\tfont-size: 0.9em;\n}\n\n.aduration__label {\n\tfont-weight: bold;\n\tcolor: var(--sc-input-active-label-color);\n}\n\n.aduration__value {\n\tcolor: var(--sc-cell-text-color);\n}\n\n.aduration__held {\n\tcolor: var(--sc-gray-50);\n\tfont-size: 0.85em;\n}\n\n.aduration__footer {\n\tmargin-top: 8px;\n}\n</style>\n","<template>\n\t<div class=\"aduration\">\n\t\t<template v-if=\"mode === 'display' || mode === 'read'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label>{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<ADateSelection\n\t\t\t\tref=\"selectionRef\"\n\t\t\t\t:select-range=\"true\"\n\t\t\t\t:show-time=\"true\"\n\t\t\t\t:show-end-time=\"true\"\n\t\t\t\t:allow-military-time=\"allowMilitaryTime\"\n\t\t\t\t:use-seconds=\"useSeconds\"\n\t\t\t\t@get-range=\"handleRange\" />\n\t\t\t<div class=\"aduration__footer\">\n\t\t\t\t<label>{{ label }}</label>\n\t\t\t\t<div v-if=\"startDatetime && endDatetime\" class=\"aduration__summary\">\n\t\t\t\t\t<span class=\"aduration__label\">Duration:</span>\n\t\t\t\t\t<span class=\"aduration__value\">{{ humanDuration }}</span>\n\t\t\t\t\t<span class=\"aduration__held\">({{ modelValue }})</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { Temporal } from 'temporal-polyfill'\nimport { ref, computed } from 'vue'\nimport ADateSelection from './ADateSelection.vue'\n\nconst {\n\tlabel = 'Duration',\n\tmode = 'edit',\n\tallowMilitaryTime = false,\n\tuseSeconds = false,\n} = defineProps<{\n\tlabel?: string\n\tmode?: string\n\tallowMilitaryTime?: boolean\n\tuseSeconds?: boolean\n}>()\n\n// An ISO 8601 duration (`PT1H`), which Postgres and Temporal read natively and which, unlike a\n// count of milliseconds, holds days and months apart from hours.\nconst modelValue = defineModel<string | null>()\n\nconst startDatetime = ref<Date | null>(null)\nconst endDatetime = ref<Date | null>(null)\n\n// The time between two picks, counting a day as 24 hours; a pick before the start is no time at all.\nconst durationBetween = (start: Date, end: Date) =>\n\tTemporal.Duration.from({ milliseconds: Math.max(end.getTime() - start.getTime(), 0) })\n\t\t.round({ largestUnit: 'days' })\n\t\t.toString()\n\nconst handleRange = (data: { start: Date; end: Date; source?: 'init' | 'user' }) => {\n\t// Both time widgets announce their starting values as they mount, which ADateSelection turns\n\t// into a range. That is not a range the user picked: acting on it wrote a zero duration into the\n\t// model, and lit the summary strip, on first render.\n\tif (data.source === 'init') return\n\n\tstartDatetime.value = data.start\n\tendDatetime.value = data.end\n\tmodelValue.value = durationBetween(data.start, data.end)\n}\n\nconst readDuration = (value: string) => {\n\ttry {\n\t\treturn Temporal.Duration.from(value)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nconst UNIT_SUFFIXES = [\n\t['years', 'y'],\n\t['months', 'mo'],\n\t['weeks', 'w'],\n\t['days', 'd'],\n\t['hours', 'h'],\n\t['minutes', 'm'],\n] as const\n\n// The units the duration holds, as it holds them: `PT25H` is 25h, not 1d 1h.\nconst describeDuration = (duration: Temporal.Duration) => {\n\tconst parts = UNIT_SUFFIXES.filter(([unit]) => duration[unit]).map(([unit, suffix]) => `${duration[unit]}${suffix}`)\n\tconst seconds =\n\t\tduration.seconds + duration.milliseconds / 1e3 + duration.microseconds / 1e6 + duration.nanoseconds / 1e9\n\tif (seconds) parts.push(`${seconds}s`)\n\treturn parts.join(' ') || '0s'\n}\n\nconst heldDuration = computed(() => (modelValue.value ? readDuration(modelValue.value) : undefined))\n\nconst humanDuration = computed(() => (heldDuration.value ? describeDuration(heldDuration.value) : '0s'))\n\nconst displayValue = computed(() => {\n\tif (!modelValue.value) return '—'\n\tif (!heldDuration.value) return 'Invalid Duration'\n\treturn heldDuration.value.blank ? '—' : describeDuration(heldDuration.value)\n})\n</script>\n\n<style scoped>\n.aduration {\n\tposition: relative;\n\twidth: max-content;\n\tmax-width: 100%;\n}\n\n.aduration__summary {\n\tdisplay: flex;\n\tgap: 6px;\n\talign-items: baseline;\n\tmargin-top: 6px;\n\tfont-size: 0.9em;\n}\n\n.aduration__label {\n\tfont-weight: bold;\n\tcolor: var(--sc-input-active-label-color);\n}\n\n.aduration__value {\n\tcolor: var(--sc-cell-text-color);\n}\n\n.aduration__held {\n\tcolor: var(--sc-gray-50);\n\tfont-size: 0.85em;\n}\n\n.aduration__footer {\n\tmargin-top: 8px;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"box\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-expanded=\"showPicker\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:value=\"rangeDisplay\"\n\t\t\t\tplaceholder=\"Select date range\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\treadonly\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adaterange-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:select-range=\"true\"\n\t\t\t\t:show-time=\"false\"\n\t\t\t\t@get-date=\"handlePickerDate\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, ref, computed, useTemplateRef, watch } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport ADateSelection from './ADateSelection.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst fmt = (d: string) => fromISODate(d)?.toLocaleString() ?? 'Invalid Date'\n\nconst { label = 'Date Range', mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nexport interface DateRangeValue {\n\tstart_date: string | null\n\tend_date: string | null\n}\n\nconst modelValue = defineModel<DateRangeValue | null>({\n\tdefault: () => ({ start_date: null, end_date: null }),\n})\n\nconst readDay = (day: string | null | undefined) => (day ? (fromISODate(day) ?? null) : null)\n\nconst startDate = ref<Temporal.PlainDate | null>(readDay(modelValue.value?.start_date))\nconst endDate = ref<Temporal.PlainDate | null>(readDay(modelValue.value?.end_date))\n\nconst { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('box'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = true\n}\n\nconst formatDate = (d: Temporal.PlainDate | null): string => d?.toLocaleString() ?? ''\n\nconst rangeDisplay = computed(() => {\n\tconst s = formatDate(startDate.value)\n\tconst e = formatDate(endDate.value)\n\tif (s && e) return `${s} — ${e}`\n\tif (s) return `${s} — ...`\n\treturn ''\n})\n\nconst displayValue = computed(() => {\n\tconst s = modelValue.value?.start_date\n\tconst e = modelValue.value?.end_date\n\tif (!s && !e) return ''\n\tif (s && e) return `${fmt(s)} — ${fmt(e)}`\n\tif (s) return `From ${fmt(s)}`\n\treturn `Until ${fmt(e!)}`\n})\n\nconst ensureOrder = () => {\n\tconst s = startDate.value\n\tconst e = endDate.value\n\tif (s && e && Temporal.PlainDate.compare(e, s) < 0) {\n\t\t;[startDate.value, endDate.value] = [e, s]\n\t}\n}\n\nconst emitModel = () => {\n\tmodelValue.value = {\n\t\tstart_date: startDate.value?.toString() ?? null,\n\t\tend_date: endDate.value?.toString() ?? null,\n\t}\n}\n\nconst handlePickerDate = (data: { selected: string; start?: string | null; end?: string | null }) => {\n\tif (data.start) startDate.value = readDay(data.start)\n\tif (data.end) {\n\t\tendDate.value = readDay(data.end)\n\t\tensureOrder()\n\t\tclosePicker()\n\t}\n\temitModel()\n}\n\nwatch(\n\t() => modelValue.value,\n\tnewVal => {\n\t\tstartDate.value = readDay(newVal?.start_date)\n\t\tendDate.value = readDay(newVal?.end_date)\n\t},\n\t{ deep: true }\n)\n</script>\n\n<style scoped>\n.adaterange-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\" @focusout=\"closeWhenFocusLeaves\" @keydown=\"closeOnEscape\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayValue }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tref=\"box\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"text\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t:aria-expanded=\"showPicker\"\n\t\t\t\t:aria-controls=\"showPicker ? calendarId : undefined\"\n\t\t\t\t:value=\"rangeDisplay\"\n\t\t\t\tplaceholder=\"Select date range\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\treadonly\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@click=\"openPicker\"\n\t\t\t\t@keydown=\"openFromKey\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\n\t\t\t<ADateSelection\n\t\t\t\tv-if=\"showPicker\"\n\t\t\t\t:id=\"calendarId\"\n\t\t\t\tref=\"picker\"\n\t\t\t\tclass=\"adaterange-picker\"\n\t\t\t\trole=\"dialog\"\n\t\t\t\t:aria-label=\"label\"\n\t\t\t\t:select-range=\"true\"\n\t\t\t\t:show-time=\"false\"\n\t\t\t\t@get-date=\"handlePickerDate\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { type ComponentPublicInstance, ref, computed, useTemplateRef, watch } from 'vue'\nimport { fromISODate } from '@stonecrop/utilities'\nimport { Temporal } from 'temporal-polyfill'\nimport ADateSelection from './ADateSelection.vue'\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps } from '../../types'\nimport { useFieldCalendar } from '../../utils/fieldCalendar'\n\nconst fmt = (d: string) => fromISODate(d)?.toLocaleString() ?? 'Invalid Date'\n\nconst { label = 'Date Range', mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nexport interface DateRangeValue {\n\tstart_date: string | null\n\tend_date: string | null\n}\n\nconst modelValue = defineModel<DateRangeValue | null>({\n\tdefault: () => ({ start_date: null, end_date: null }),\n})\n\nconst readDay = (day: string | null | undefined) => (day ? (fromISODate(day) ?? null) : null)\n\nconst startDate = ref<Temporal.PlainDate | null>(readDay(modelValue.value?.start_date))\nconst endDate = ref<Temporal.PlainDate | null>(readDay(modelValue.value?.end_date))\n\nconst { showPicker, calendarId, closePicker, openFromKey, closeOnEscape, closeWhenFocusLeaves } = useFieldCalendar(\n\tuseTemplateRef<HTMLInputElement>('box'),\n\tuseTemplateRef<ComponentPublicInstance>('picker'),\n\tuuid\n)\n\nconst openPicker = () => {\n\tif (mode !== 'read') showPicker.value = true\n}\n\nconst formatDate = (d: Temporal.PlainDate | null): string => d?.toLocaleString() ?? ''\n\nconst rangeDisplay = computed(() => {\n\tconst s = formatDate(startDate.value)\n\tconst e = formatDate(endDate.value)\n\tif (s && e) return `${s} — ${e}`\n\tif (s) return `${s} — ...`\n\treturn ''\n})\n\nconst displayValue = computed(() => {\n\tconst s = modelValue.value?.start_date\n\tconst e = modelValue.value?.end_date\n\tif (!s && !e) return ''\n\tif (s && e) return `${fmt(s)} — ${fmt(e)}`\n\tif (s) return `From ${fmt(s)}`\n\treturn `Until ${fmt(e!)}`\n})\n\nconst ensureOrder = () => {\n\tconst s = startDate.value\n\tconst e = endDate.value\n\tif (s && e && Temporal.PlainDate.compare(e, s) < 0) {\n\t\t;[startDate.value, endDate.value] = [e, s]\n\t}\n}\n\nconst emitModel = () => {\n\tmodelValue.value = {\n\t\tstart_date: startDate.value?.toString() ?? null,\n\t\tend_date: endDate.value?.toString() ?? null,\n\t}\n}\n\nconst handlePickerDate = (data: { selected: string; start?: string | null; end?: string | null }) => {\n\tif (data.start) startDate.value = readDay(data.start)\n\tif (data.end) {\n\t\tendDate.value = readDay(data.end)\n\t\tensureOrder()\n\t\tclosePicker()\n\t}\n\temitModel()\n}\n\nwatch(\n\t() => modelValue.value,\n\tnewVal => {\n\t\tstartDate.value = readDay(newVal?.start_date)\n\t\tendDate.value = readDay(newVal?.end_date)\n\t},\n\t{ deep: true }\n)\n</script>\n\n<style scoped>\n.adaterange-picker {\n\tposition: absolute;\n\ttop: 100%;\n\tleft: 0;\n\twidth: max-content;\n\tmax-width: 100%;\n\tbox-sizing: border-box;\n\tz-index: 100;\n\tmargin-top: 0.25rem;\n}\n</style>\n","<template>\n\t<form class=\"aform\">\n\t\t<template v-for=\"(componentObj, key) in schema\" :key=\"key\">\n\t\t\t<!-- A linked record: its form binds the link's own value -->\n\t\t\t<div v-if=\"isLinkSection(componentObj)\" class=\"aform-nested-section\">\n\t\t\t\t<h4 v-if=\"componentObj.label\" class=\"aform-nested-label\">\n\t\t\t\t\t{{ componentObj.label }}\n\t\t\t\t</h4>\n\t\t\t\t<component\n\t\t\t\t\t:is=\"componentObj.component ?? 'AForm'\"\n\t\t\t\t\t:data=\"nestedData[componentObj.fieldname]\"\n\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t:schema=\"componentObj.schema\"\n\t\t\t\t\t:label=\"componentObj.label\"\n\t\t\t\t\t:errors=\"errors\"\n\t\t\t\t\t@update:data=\"(val: any) => updateNestedData(componentObj.fieldname, val)\" />\n\t\t\t</div>\n\n\t\t\t<!-- A fieldset is layout: its fields are this record's own, so it binds this record.\n\t\t\t\t No h4, since AFieldset renders its own legend. -->\n\t\t\t<div v-else-if=\"isFieldsetSection(componentObj)\" class=\"aform-nested-section\">\n\t\t\t\t<component\n\t\t\t\t\t:is=\"componentObj.component ?? 'AFieldset'\"\n\t\t\t\t\t:data=\"dataModel\"\n\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t:schema=\"componentObj.schema\"\n\t\t\t\t\t:label=\"componentObj.label\"\n\t\t\t\t\t:collapsible=\"componentObj.collapsible\"\n\t\t\t\t\t:errors=\"errors\"\n\t\t\t\t\t@update:data=\"updateFieldsetData\" />\n\t\t\t</div>\n\n\t\t\t<!-- Regular field -->\n\t\t\t<component\n\t\t\t\t:is=\"componentObj.component\"\n\t\t\t\tv-else-if=\"!componentObj.hidden\"\n\t\t\t\tv-model=\"childModels[key].value\"\n\t\t\t\t:style=\"fieldStyle(componentObj)\"\n\t\t\t\t:schema=\"componentObj\"\n\t\t\t\t:data=\"dataModel[componentObj.fieldname]\"\n\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t:errors=\"fieldErrors(componentObj)\"\n\t\t\t\tv-bind=\"componentProps(componentObj)\">\n\t\t\t\t<template v-if=\"isListExpansionTable(componentObj)\" #content=\"{ row, rowIndex }\">\n\t\t\t\t\t<AForm\n\t\t\t\t\t\tclass=\"aform-table-expansion\"\n\t\t\t\t\t\t:data=\"row\"\n\t\t\t\t\t\t:schema=\"tableExpansionSchema(componentObj)\"\n\t\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t\t@update:data=\"val => updateTableRow(componentObj.fieldname, rowIndex, val)\" />\n\t\t\t\t</template>\n\t\t\t</component>\n\t\t</template>\n\t</form>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, watchEffect, watch, ref, useId } from 'vue'\n\nimport type { ResolvedField, ResolvedLink, ResolvedFieldset, ResolvedTable } from '../types'\nimport { partsPatch, readParts } from '@stonecrop/schema'\nimport type { ColumnSchema, InteractionMode } from '@stonecrop/schema'\n\nconst emit = defineEmits(['update:schema', 'update:data'])\nconst dataModel = defineModel<Record<string, any>>('data', { required: true })\nconst {\n\tschema,\n\tmode = 'edit',\n\terrors,\n} = defineProps<{\n\tschema: ResolvedField[]\n\tmode?: InteractionMode\n\t/** Inline validation errors keyed by fieldname. Fed by the host; the form stays store-agnostic. */\n\terrors?: Record<string, string[]>\n}>()\n\nconst hasChildSchema = (componentObj: ResolvedField) =>\n\t'schema' in componentObj && Array.isArray(componentObj.schema) && componentObj.schema.length > 0\n\nconst isLinkSection = (componentObj: ResolvedField): componentObj is ResolvedLink =>\n\tcomponentObj.kind === 'link' && hasChildSchema(componentObj)\n\nconst isFieldsetSection = (componentObj: ResolvedField): componentObj is ResolvedFieldset =>\n\tcomponentObj.kind === 'fieldset' && hasChildSchema(componentObj)\n\n// Reactive nested data refs for two-way binding with the forms of linked records\nconst nestedData = ref<Record<string, any>>({})\n\n// Sync external dataModel changes into nestedData (one-way, no emit back).\n// Uses a shallow watch so only top-level object replacement (e.g. parent reset)\n// triggers a sync — property mutations from within are handled by updateNestedData.\nwatch(\n\t() => dataModel.value,\n\tnewData => {\n\t\tif (!schema || !newData) return\n\t\tschema.forEach(field => {\n\t\t\tif (isLinkSection(field)) {\n\t\t\t\tnestedData.value[field.fieldname] = newData[field.fieldname] ?? {}\n\t\t\t}\n\t\t})\n\t},\n\t{ immediate: true }\n)\n\n// A nested form's edits: updates nestedData locally and propagates upward in one step,\n// avoiding the watchEffect feedback loop that occurred with v-model.\nconst updateNestedData = (fieldname: string, val: any) => {\n\tnestedData.value[fieldname] = val\n\tif (dataModel.value) {\n\t\tdataModel.value[fieldname] = val\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\n// A fieldset's edits. Its form holds this record, so its edits are this record's.\nconst updateFieldsetData = (val: Record<string, any>) => {\n\tif (dataModel.value) {\n\t\tObject.assign(dataModel.value, val)\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\nconst isListExpansionTable = (componentObj: ResolvedField): componentObj is ResolvedTable =>\n\tcomponentObj.kind === 'table' && componentObj.config?.view === 'list-expansion'\n\nconst tableExpansionSchema = (table: ResolvedTable): ResolvedField[] =>\n\ttable.schema\n\t\t.filter((col): col is ColumnSchema & { component: string } => Boolean(col.component))\n\t\t.map(({ fieldname, component, ...rest }) => Object.assign(rest, { kind: 'field' as const, fieldname, component }))\n\nconst updateTableRows = (fieldname: string, rows: Record<string, unknown>[]) => {\n\tif (dataModel.value) {\n\t\tdataModel.value[fieldname] = rows\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\nconst updateTableRow = (fieldname: string, rowIndex: number, val: Record<string, unknown>) => {\n\tconst rows = Array.isArray(dataModel.value?.[fieldname]) ? [...dataModel.value[fieldname]] : []\n\trows[rowIndex] = { ...rows[rowIndex], ...val }\n\tupdateTableRows(fieldname, rows)\n}\n\n// Each field's `uuid` ties its label and error message to its input; one id per form keeps them\n// unique when several forms, or a fieldset's nested form, share a page.\nconst formId = useId()\n\nconst componentProps = (componentObj: ResolvedField) => {\n\tconst propsToPass: Record<string, any> = {}\n\tfor (const [key, value] of Object.entries(componentObj)) {\n\t\t// 'mode' is excluded here because it is handled by resolvedMode()\n\t\t// and passed explicitly via :mode to avoid conflicting with the form-level defaults.\n\t\tif (\n\t\t\t!['component', 'primaryKey', 'computed', 'language', 'hidden', 'mode', 'width', 'height', 'parts'].includes(key)\n\t\t) {\n\t\t\tpropsToPass[key] = value\n\t\t}\n\t}\n\tpropsToPass['uuid'] ??= `${formId}-${componentObj.fieldname}`\n\n\t// A table sources its rows from the data model, never from the schema, and its edits come back\n\t// through `update:rows`. `kind` is the only check: every path into AForm sets it (Zod's\n\t// injectKind, Doctype.fromObject's normalizeFieldKind, and the registry), and hand-built\n\t// ResolvedTable literals declare it.\n\tif (componentObj.kind === 'table') {\n\t\tpropsToPass['rows'] = dataModel.value[componentObj.fieldname] || []\n\t\tpropsToPass['onUpdate:rows'] = (rows: Record<string, unknown>[]) => updateTableRows(componentObj.fieldname, rows)\n\t}\n\n\treturn propsToPass\n}\n\nconst fieldStyle = (componentObj: ResolvedField): Record<string, string> => {\n\tif (componentObj.kind !== 'field') return {}\n\tconst style: Record<string, string> = {}\n\tif (componentObj.width) {\n\t\tstyle.flexBasis = componentObj.width\n\t\tstyle.width = componentObj.width\n\t}\n\tif (componentObj.height) {\n\t\tstyle.height = componentObj.height\n\t\tstyle.minHeight = '0'\n\t\tstyle.flexGrow = '1'\n\t\tstyle.alignSelf = 'stretch'\n\t}\n\treturn style\n}\n\nconst effectiveFormMode = computed(() => mode ?? 'edit')\n\n// Resolve the effective mode for a schema field, allowing per-field overrides\nfunction resolvedMode(componentObj: ResolvedField): InteractionMode {\n\tconst fieldMode = componentObj.mode\n\tif (fieldMode) return fieldMode\n\treturn effectiveFormMode.value\n}\n\n// A field declaring `parts` binds the value its component edits, read part by part from the fields\n// that hold them and written back only where a part changed.\nconst fieldParts = (field: ResolvedField): Record<string, string> | undefined =>\n\tfield.kind === 'field' ? field.parts : undefined\n\nconst fieldErrors = (field: ResolvedField): string[] | undefined => {\n\tconst parts = fieldParts(field)\n\tif (!parts) return errors?.[field.fieldname]\n\treturn Object.values(parts).flatMap(fieldname => errors?.[fieldname] ?? [])\n}\n\n// Create stable computed refs array to avoid recreation on every access\nconst childModelsCache = ref<ReturnType<typeof computed>[]>([])\n\n// Watch for schema changes and update cache (avoiding side effects in computed)\nwatchEffect(() => {\n\tif (!schema) return\n\n\t// Recreate cache only if length changed\n\tif (childModelsCache.value.length !== schema.length) {\n\t\tchildModelsCache.value = schema.map((_field, index) => {\n\t\t\treturn computed({\n\t\t\t\tget() {\n\t\t\t\t\tconst parts = fieldParts(schema[index])\n\t\t\t\t\tif (parts) return readParts(parts, dataModel.value ?? {})\n\t\t\t\t\treturn dataModel.value?.[schema[index].fieldname]\n\t\t\t\t},\n\t\t\t\tset: (newValue: any) => {\n\t\t\t\t\tconst parts = fieldParts(schema[index])\n\t\t\t\t\tconst fieldname = schema[index].fieldname\n\t\t\t\t\tif (parts && dataModel.value) {\n\t\t\t\t\t\tObject.assign(dataModel.value, partsPatch(parts, dataModel.value, newValue))\n\t\t\t\t\t\temit('update:data', { ...dataModel.value })\n\t\t\t\t\t} else if (fieldname && dataModel.value) {\n\t\t\t\t\t\tdataModel.value[fieldname] = newValue\n\t\t\t\t\t\temit('update:data', { ...dataModel.value })\n\t\t\t\t\t}\n\t\t\t\t\temit('update:schema', schema)\n\t\t\t\t},\n\t\t\t})\n\t\t})\n\t}\n})\n\n// Computed just returns the cached models (no side effects)\nconst childModels = computed(() => childModelsCache.value)\n</script>\n\n<style>\n/* global styles for aform */\n.aform input {\n\tfont-family: var(--sc-font-family);\n\tborder: none;\n}\n.aform_form-element {\n\tpadding: var(--sc-form-label-offset) 0 0;\n\tmargin: 0;\n\tposition: relative;\n\tbox-sizing: border-box;\n\tflex-grow: 1;\n\tmin-width: 20ch;\n\tmax-width: var(--sc-form-field-max-width);\n\t/* margin-bottom: 1rem; */\n}\n.aform__grid--full {\n\tflex-basis: 100%;\n\twidth: 100%;\n}\n.aform_input-field {\n\tborder: none;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tfont-size: 1rem;\n\tpadding: 0.5rem;\n\tmargin: 0 0 0 0;\n\tborder-radius: 0;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: auto;\n\tposition: relative;\n\tcolor: var(--sc-cell-text-color);\n\tbackground: var(--sc-input-field-background);\n\tfont-family: var(--sc-font-family);\n}\n.aform_input-field:focus {\n\toutline: 1px solid var(--sc-input-active-border-color);\n}\n\n.aform_display-value {\n\tdisplay: block;\n\tpadding: 0.5rem;\n\tmin-height: 2rem;\n\tcolor: var(--sc-cell-text-color);\n\tword-break: break-word;\n}\n\n/* A label darkens while anything beside it holds focus, wherever it sits in its field's markup. */\n:focus-within > .aform_field-label {\n\tcolor: var(--sc-input-active-label-color);\n}\n\n.aform_field-label {\n\tcolor: var(--sc-input-label-color);\n\tdisplay: inline-block;\n\tposition: absolute;\n\tuser-select: none;\n\tpadding: 0 0.25rem;\n\tmargin: 0rem;\n\tz-index: 1;\n\tfont-size: 0.7rem;\n\tfont-weight: 300;\n\tletter-spacing: 0.05rem;\n\t/* The form colour masks the field's top border behind the text; below it the field shows\n\t through. Never paint a colour there: it can match only one of the surfaces a field shows. */\n\tbackground: linear-gradient(var(--sc-form-background) calc(50% + 1px), transparent calc(50% + 1px));\n\twidth: auto;\n\tbox-sizing: border-box;\n\tmargin: 0;\n\tgrid-row: 1;\n\ttop: 0;\n\tleft: 10px;\n\tborder: none;\n\tline-height: 0;\n\ttransform: translateY(-50%);\n}\n.aform_form-element > .aform_field-label {\n\ttop: var(--sc-form-label-offset);\n}\n\n.aform_input-field:disabled,\n.aform_checkbox-container:has(.aform_checkbox:disabled) {\n\tbackground: var(--sc-input-field-disabled-background);\n}\n.aform_field-label::after {\n\tmargin: 0;\n\tpadding: 0;\n\tbox-sizing: border-box;\n\tcontent: '';\n\tline-height: normal;\n}\np.aform_error {\n\t/* v-show toggles visibility per field; base display must be visible (was stuck at `none`,\n\t which overrode v-show and left every field error dormant). */\n\tdisplay: inline-block;\n\t/* Straddles the border like .aform_field-label, and paints the same way. */\n\tbackground: linear-gradient(var(--sc-form-background) calc(50% + 1px), transparent calc(50% + 1px));\n\tpadding: 0 0.25rem;\n\tmargin: 0rem;\n\twidth: auto;\n\tcolor: var(--sc-brand-danger);\n\tfont-size: 0.7rem;\n\tposition: absolute;\n\tright: 0;\n\ttop: var(--sc-form-label-offset);\n\tline-height: 0;\n\tpadding: 0.25rem;\n\ttransform: translate(-1rem, -50%);\n\tmargin: 0;\n}\n</style>\n\n<style scoped>\n.aform {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 1rem;\n\tpadding: 1rem;\n\tbackground: var(--sc-form-background);\n\tborder: 1px solid var(--sc-form-border);\n\tborder-left: 4px solid var(--sc-form-border);\n\tmargin-bottom: 1rem;\n\tmax-width: 100%;\n}\n@media screen and (max-width: 400px) {\n\t.aform {\n\t\tflex-direction: column;\n\t}\n}\n\n/* Nested form section */\n.aform-nested-section {\n\twidth: 100%;\n\tpadding: 0.5rem 0;\n}\n\n.aform-nested-label {\n\tfont-size: 0.9rem;\n\tfont-weight: 600;\n\tmargin: 0 0 0.5rem 0;\n\tcolor: var(--sc-input-label-color);\n}\n\n.aform-nested-section .aform {\n\tborder-left-width: 2px;\n\tmargin-left: 0.5rem;\n}\n\n.aform-table-expansion {\n\tmargin-bottom: 0;\n\tborder: none;\n\tborder-left: none;\n\tpadding: 0;\n}\n</style>\n","<template>\n\t<form class=\"aform\">\n\t\t<template v-for=\"(componentObj, key) in schema\" :key=\"key\">\n\t\t\t<!-- A linked record: its form binds the link's own value -->\n\t\t\t<div v-if=\"isLinkSection(componentObj)\" class=\"aform-nested-section\">\n\t\t\t\t<h4 v-if=\"componentObj.label\" class=\"aform-nested-label\">\n\t\t\t\t\t{{ componentObj.label }}\n\t\t\t\t</h4>\n\t\t\t\t<component\n\t\t\t\t\t:is=\"componentObj.component ?? 'AForm'\"\n\t\t\t\t\t:data=\"nestedData[componentObj.fieldname]\"\n\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t:schema=\"componentObj.schema\"\n\t\t\t\t\t:label=\"componentObj.label\"\n\t\t\t\t\t:errors=\"errors\"\n\t\t\t\t\t@update:data=\"(val: any) => updateNestedData(componentObj.fieldname, val)\" />\n\t\t\t</div>\n\n\t\t\t<!-- A fieldset is layout: its fields are this record's own, so it binds this record.\n\t\t\t\t No h4, since AFieldset renders its own legend. -->\n\t\t\t<div v-else-if=\"isFieldsetSection(componentObj)\" class=\"aform-nested-section\">\n\t\t\t\t<component\n\t\t\t\t\t:is=\"componentObj.component ?? 'AFieldset'\"\n\t\t\t\t\t:data=\"dataModel\"\n\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t:schema=\"componentObj.schema\"\n\t\t\t\t\t:label=\"componentObj.label\"\n\t\t\t\t\t:collapsible=\"componentObj.collapsible\"\n\t\t\t\t\t:errors=\"errors\"\n\t\t\t\t\t@update:data=\"updateFieldsetData\" />\n\t\t\t</div>\n\n\t\t\t<!-- Regular field -->\n\t\t\t<component\n\t\t\t\t:is=\"componentObj.component\"\n\t\t\t\tv-else-if=\"!componentObj.hidden\"\n\t\t\t\tv-model=\"childModels[key].value\"\n\t\t\t\t:style=\"fieldStyle(componentObj)\"\n\t\t\t\t:schema=\"componentObj\"\n\t\t\t\t:data=\"dataModel[componentObj.fieldname]\"\n\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t:errors=\"fieldErrors(componentObj)\"\n\t\t\t\tv-bind=\"componentProps(componentObj)\">\n\t\t\t\t<template v-if=\"isListExpansionTable(componentObj)\" #content=\"{ row, rowIndex }\">\n\t\t\t\t\t<AForm\n\t\t\t\t\t\tclass=\"aform-table-expansion\"\n\t\t\t\t\t\t:data=\"row\"\n\t\t\t\t\t\t:schema=\"tableExpansionSchema(componentObj)\"\n\t\t\t\t\t\t:mode=\"resolvedMode(componentObj)\"\n\t\t\t\t\t\t@update:data=\"val => updateTableRow(componentObj.fieldname, rowIndex, val)\" />\n\t\t\t\t</template>\n\t\t\t</component>\n\t\t</template>\n\t</form>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, watchEffect, watch, ref, useId } from 'vue'\n\nimport type { ResolvedField, ResolvedLink, ResolvedFieldset, ResolvedTable } from '../types'\nimport { partsPatch, readParts } from '@stonecrop/schema'\nimport type { ColumnSchema, InteractionMode } from '@stonecrop/schema'\n\nconst emit = defineEmits(['update:schema', 'update:data'])\nconst dataModel = defineModel<Record<string, any>>('data', { required: true })\nconst {\n\tschema,\n\tmode = 'edit',\n\terrors,\n} = defineProps<{\n\tschema: ResolvedField[]\n\tmode?: InteractionMode\n\t/** Inline validation errors keyed by fieldname. Fed by the host; the form stays store-agnostic. */\n\terrors?: Record<string, string[]>\n}>()\n\nconst hasChildSchema = (componentObj: ResolvedField) =>\n\t'schema' in componentObj && Array.isArray(componentObj.schema) && componentObj.schema.length > 0\n\nconst isLinkSection = (componentObj: ResolvedField): componentObj is ResolvedLink =>\n\tcomponentObj.kind === 'link' && hasChildSchema(componentObj)\n\nconst isFieldsetSection = (componentObj: ResolvedField): componentObj is ResolvedFieldset =>\n\tcomponentObj.kind === 'fieldset' && hasChildSchema(componentObj)\n\n// Reactive nested data refs for two-way binding with the forms of linked records\nconst nestedData = ref<Record<string, any>>({})\n\n// Sync external dataModel changes into nestedData (one-way, no emit back).\n// Uses a shallow watch so only top-level object replacement (e.g. parent reset)\n// triggers a sync — property mutations from within are handled by updateNestedData.\nwatch(\n\t() => dataModel.value,\n\tnewData => {\n\t\tif (!schema || !newData) return\n\t\tschema.forEach(field => {\n\t\t\tif (isLinkSection(field)) {\n\t\t\t\tnestedData.value[field.fieldname] = newData[field.fieldname] ?? {}\n\t\t\t}\n\t\t})\n\t},\n\t{ immediate: true }\n)\n\n// A nested form's edits: updates nestedData locally and propagates upward in one step,\n// avoiding the watchEffect feedback loop that occurred with v-model.\nconst updateNestedData = (fieldname: string, val: any) => {\n\tnestedData.value[fieldname] = val\n\tif (dataModel.value) {\n\t\tdataModel.value[fieldname] = val\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\n// A fieldset's edits. Its form holds this record, so its edits are this record's.\nconst updateFieldsetData = (val: Record<string, any>) => {\n\tif (dataModel.value) {\n\t\tObject.assign(dataModel.value, val)\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\nconst isListExpansionTable = (componentObj: ResolvedField): componentObj is ResolvedTable =>\n\tcomponentObj.kind === 'table' && componentObj.config?.view === 'list-expansion'\n\nconst tableExpansionSchema = (table: ResolvedTable): ResolvedField[] =>\n\ttable.schema\n\t\t.filter((col): col is ColumnSchema & { component: string } => Boolean(col.component))\n\t\t.map(({ fieldname, component, ...rest }) => Object.assign(rest, { kind: 'field' as const, fieldname, component }))\n\nconst updateTableRows = (fieldname: string, rows: Record<string, unknown>[]) => {\n\tif (dataModel.value) {\n\t\tdataModel.value[fieldname] = rows\n\t\temit('update:data', { ...dataModel.value })\n\t}\n}\n\nconst updateTableRow = (fieldname: string, rowIndex: number, val: Record<string, unknown>) => {\n\tconst rows = Array.isArray(dataModel.value?.[fieldname]) ? [...dataModel.value[fieldname]] : []\n\trows[rowIndex] = { ...rows[rowIndex], ...val }\n\tupdateTableRows(fieldname, rows)\n}\n\n// Each field's `uuid` ties its label and error message to its input; one id per form keeps them\n// unique when several forms, or a fieldset's nested form, share a page.\nconst formId = useId()\n\nconst componentProps = (componentObj: ResolvedField) => {\n\tconst propsToPass: Record<string, any> = {}\n\tfor (const [key, value] of Object.entries(componentObj)) {\n\t\t// 'mode' is excluded here because it is handled by resolvedMode()\n\t\t// and passed explicitly via :mode to avoid conflicting with the form-level defaults.\n\t\tif (\n\t\t\t!['component', 'primaryKey', 'computed', 'language', 'hidden', 'mode', 'width', 'height', 'parts'].includes(key)\n\t\t) {\n\t\t\tpropsToPass[key] = value\n\t\t}\n\t}\n\tpropsToPass['uuid'] ??= `${formId}-${componentObj.fieldname}`\n\n\t// A table sources its rows from the data model, never from the schema, and its edits come back\n\t// through `update:rows`. `kind` is the only check: every path into AForm sets it (Zod's\n\t// injectKind, Doctype.fromObject's normalizeFieldKind, and the registry), and hand-built\n\t// ResolvedTable literals declare it.\n\tif (componentObj.kind === 'table') {\n\t\tpropsToPass['rows'] = dataModel.value[componentObj.fieldname] || []\n\t\tpropsToPass['onUpdate:rows'] = (rows: Record<string, unknown>[]) => updateTableRows(componentObj.fieldname, rows)\n\t}\n\n\treturn propsToPass\n}\n\nconst fieldStyle = (componentObj: ResolvedField): Record<string, string> => {\n\tif (componentObj.kind !== 'field') return {}\n\tconst style: Record<string, string> = {}\n\tif (componentObj.width) {\n\t\tstyle.flexBasis = componentObj.width\n\t\tstyle.width = componentObj.width\n\t}\n\tif (componentObj.height) {\n\t\tstyle.height = componentObj.height\n\t\tstyle.minHeight = '0'\n\t\tstyle.flexGrow = '1'\n\t\tstyle.alignSelf = 'stretch'\n\t}\n\treturn style\n}\n\nconst effectiveFormMode = computed(() => mode ?? 'edit')\n\n// Resolve the effective mode for a schema field, allowing per-field overrides\nfunction resolvedMode(componentObj: ResolvedField): InteractionMode {\n\tconst fieldMode = componentObj.mode\n\tif (fieldMode) return fieldMode\n\treturn effectiveFormMode.value\n}\n\n// A field declaring `parts` binds the value its component edits, read part by part from the fields\n// that hold them and written back only where a part changed.\nconst fieldParts = (field: ResolvedField): Record<string, string> | undefined =>\n\tfield.kind === 'field' ? field.parts : undefined\n\nconst fieldErrors = (field: ResolvedField): string[] | undefined => {\n\tconst parts = fieldParts(field)\n\tif (!parts) return errors?.[field.fieldname]\n\treturn Object.values(parts).flatMap(fieldname => errors?.[fieldname] ?? [])\n}\n\n// Create stable computed refs array to avoid recreation on every access\nconst childModelsCache = ref<ReturnType<typeof computed>[]>([])\n\n// Watch for schema changes and update cache (avoiding side effects in computed)\nwatchEffect(() => {\n\tif (!schema) return\n\n\t// Recreate cache only if length changed\n\tif (childModelsCache.value.length !== schema.length) {\n\t\tchildModelsCache.value = schema.map((_field, index) => {\n\t\t\treturn computed({\n\t\t\t\tget() {\n\t\t\t\t\tconst parts = fieldParts(schema[index])\n\t\t\t\t\tif (parts) return readParts(parts, dataModel.value ?? {})\n\t\t\t\t\treturn dataModel.value?.[schema[index].fieldname]\n\t\t\t\t},\n\t\t\t\tset: (newValue: any) => {\n\t\t\t\t\tconst parts = fieldParts(schema[index])\n\t\t\t\t\tconst fieldname = schema[index].fieldname\n\t\t\t\t\tif (parts && dataModel.value) {\n\t\t\t\t\t\tObject.assign(dataModel.value, partsPatch(parts, dataModel.value, newValue))\n\t\t\t\t\t\temit('update:data', { ...dataModel.value })\n\t\t\t\t\t} else if (fieldname && dataModel.value) {\n\t\t\t\t\t\tdataModel.value[fieldname] = newValue\n\t\t\t\t\t\temit('update:data', { ...dataModel.value })\n\t\t\t\t\t}\n\t\t\t\t\temit('update:schema', schema)\n\t\t\t\t},\n\t\t\t})\n\t\t})\n\t}\n})\n\n// Computed just returns the cached models (no side effects)\nconst childModels = computed(() => childModelsCache.value)\n</script>\n\n<style>\n/* global styles for aform */\n.aform input {\n\tfont-family: var(--sc-font-family);\n\tborder: none;\n}\n.aform_form-element {\n\tpadding: var(--sc-form-label-offset) 0 0;\n\tmargin: 0;\n\tposition: relative;\n\tbox-sizing: border-box;\n\tflex-grow: 1;\n\tmin-width: 20ch;\n\tmax-width: var(--sc-form-field-max-width);\n\t/* margin-bottom: 1rem; */\n}\n.aform__grid--full {\n\tflex-basis: 100%;\n\twidth: 100%;\n}\n.aform_input-field {\n\tborder: none;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tfont-size: 1rem;\n\tpadding: 0.5rem;\n\tmargin: 0 0 0 0;\n\tborder-radius: 0;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-height: auto;\n\tposition: relative;\n\tcolor: var(--sc-cell-text-color);\n\tbackground: var(--sc-input-field-background);\n\tfont-family: var(--sc-font-family);\n}\n.aform_input-field:focus {\n\toutline: 1px solid var(--sc-input-active-border-color);\n}\n\n.aform_display-value {\n\tdisplay: block;\n\tpadding: 0.5rem;\n\tmin-height: 2rem;\n\tcolor: var(--sc-cell-text-color);\n\tword-break: break-word;\n}\n\n/* A label darkens while anything beside it holds focus, wherever it sits in its field's markup. */\n:focus-within > .aform_field-label {\n\tcolor: var(--sc-input-active-label-color);\n}\n\n.aform_field-label {\n\tcolor: var(--sc-input-label-color);\n\tdisplay: inline-block;\n\tposition: absolute;\n\tuser-select: none;\n\tpadding: 0 0.25rem;\n\tmargin: 0rem;\n\tz-index: 1;\n\tfont-size: 0.7rem;\n\tfont-weight: 300;\n\tletter-spacing: 0.05rem;\n\t/* The form colour masks the field's top border behind the text; below it the field shows\n\t through. Never paint a colour there: it can match only one of the surfaces a field shows. */\n\tbackground: linear-gradient(var(--sc-form-background) calc(50% + 1px), transparent calc(50% + 1px));\n\twidth: auto;\n\tbox-sizing: border-box;\n\tmargin: 0;\n\tgrid-row: 1;\n\ttop: 0;\n\tleft: 10px;\n\tborder: none;\n\tline-height: 0;\n\ttransform: translateY(-50%);\n}\n.aform_form-element > .aform_field-label {\n\ttop: var(--sc-form-label-offset);\n}\n\n.aform_input-field:disabled,\n.aform_checkbox-container:has(.aform_checkbox:disabled) {\n\tbackground: var(--sc-input-field-disabled-background);\n}\n.aform_field-label::after {\n\tmargin: 0;\n\tpadding: 0;\n\tbox-sizing: border-box;\n\tcontent: '';\n\tline-height: normal;\n}\np.aform_error {\n\t/* v-show toggles visibility per field; base display must be visible (was stuck at `none`,\n\t which overrode v-show and left every field error dormant). */\n\tdisplay: inline-block;\n\t/* Straddles the border like .aform_field-label, and paints the same way. */\n\tbackground: linear-gradient(var(--sc-form-background) calc(50% + 1px), transparent calc(50% + 1px));\n\tpadding: 0 0.25rem;\n\tmargin: 0rem;\n\twidth: auto;\n\tcolor: var(--sc-brand-danger);\n\tfont-size: 0.7rem;\n\tposition: absolute;\n\tright: 0;\n\ttop: var(--sc-form-label-offset);\n\tline-height: 0;\n\tpadding: 0.25rem;\n\ttransform: translate(-1rem, -50%);\n\tmargin: 0;\n}\n</style>\n\n<style scoped>\n.aform {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 1rem;\n\tpadding: 1rem;\n\tbackground: var(--sc-form-background);\n\tborder: 1px solid var(--sc-form-border);\n\tborder-left: 4px solid var(--sc-form-border);\n\tmargin-bottom: 1rem;\n\tmax-width: 100%;\n}\n@media screen and (max-width: 400px) {\n\t.aform {\n\t\tflex-direction: column;\n\t}\n}\n\n/* Nested form section */\n.aform-nested-section {\n\twidth: 100%;\n\tpadding: 0.5rem 0;\n}\n\n.aform-nested-label {\n\tfont-size: 0.9rem;\n\tfont-weight: 600;\n\tmargin: 0 0 0.5rem 0;\n\tcolor: var(--sc-input-label-color);\n}\n\n.aform-nested-section .aform {\n\tborder-left-width: 2px;\n\tmargin-left: 0.5rem;\n}\n\n.aform-table-expansion {\n\tmargin-bottom: 0;\n\tborder: none;\n\tborder-left: none;\n\tpadding: 0;\n}\n</style>\n","<template>\n\t<button class=\"collapse-button\" :class=\"collapsed ? 'rotated' : 'unrotated'\">×</button>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{ collapsed: boolean }>()\n</script>\n\n<style scoped>\n.collapse-button {\n\twidth: 2ch;\n\tmin-width: calc(66px - 4ch);\n\tbackground-color: transparent;\n\tfont-size: 150%;\n\ttext-align: center;\n\tborder: none;\n\tmargin-top: -0.5rem;\n}\n.rotated {\n\ttransform: rotate(45deg);\n\t-webkit-transform: rotate(45deg);\n\t-moz-transform: rotate(45deg);\n\t-ms-transform: rotate(45deg);\n\t-o-transform: rotate(45deg);\n\ttransition: transform 250ms;\n\ttransform-origin: center center;\n}\n.unrotated {\n\ttransform: rotate(0deg);\n\t-webkit-transform: rotate(0deg);\n\t-moz-transform: rotate(0deg);\n\t-ms-transform: rotate(0deg);\n\t-o-transform: rotate(0deg);\n\ttransition: transform 250ms;\n}\n</style>\n","<template>\n\t<button class=\"collapse-button\" :class=\"collapsed ? 'rotated' : 'unrotated'\">×</button>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{ collapsed: boolean }>()\n</script>\n\n<style scoped>\n.collapse-button {\n\twidth: 2ch;\n\tmin-width: calc(66px - 4ch);\n\tbackground-color: transparent;\n\tfont-size: 150%;\n\ttext-align: center;\n\tborder: none;\n\tmargin-top: -0.5rem;\n}\n.rotated {\n\ttransform: rotate(45deg);\n\t-webkit-transform: rotate(45deg);\n\t-moz-transform: rotate(45deg);\n\t-ms-transform: rotate(45deg);\n\t-o-transform: rotate(45deg);\n\ttransition: transform 250ms;\n\ttransform-origin: center center;\n}\n.unrotated {\n\ttransform: rotate(0deg);\n\t-webkit-transform: rotate(0deg);\n\t-moz-transform: rotate(0deg);\n\t-ms-transform: rotate(0deg);\n\t-o-transform: rotate(0deg);\n\ttransition: transform 250ms;\n}\n</style>\n","<template>\n\t<fieldset>\n\t\t<legend v-if=\"label || collapsible\" @click=\"toggleCollapse\" @submit=\"toggleCollapse\">\n\t\t\t{{ label }}\n\t\t\t<CollapseButton v-if=\"collapsible\" :collapsed=\"collapsed\" />\n\t\t</legend>\n\t\t<slot :collapsed=\"collapsed\">\n\t\t\t<AForm v-show=\"!collapsed\" v-model:data=\"formData\" :schema=\"schema\" :mode=\"mode\" :errors=\"errors\" />\n\t\t</slot>\n\t</fieldset>\n</template>\n\n<script setup lang=\"ts\">\nimport type { InteractionMode } from '@stonecrop/schema'\nimport { ref } from 'vue'\n\nimport AForm from '../AForm.vue'\nimport CollapseButton from '../base/CollapseButton.vue'\nimport type { ResolvedField } from '../../types'\n\nconst {\n\tschema,\n\tlabel = undefined,\n\tcollapsible,\n\tmode = 'edit',\n\terrors = undefined,\n} = defineProps<{\n\tschema: ResolvedField[]\n\tlabel?: string\n\tcollapsible?: boolean\n\t/** Rendering mode forwarded to the inner AForm */\n\tmode?: InteractionMode\n\t/** Inline validation errors keyed by fieldname, forwarded to the inner AForm. */\n\terrors?: Record<string, string[]>\n}>()\n\n/** The record the fieldset's fields belong to: a fieldset is layout, so they are its own keys. */\nconst formData = defineModel<Record<string, any>>('data', { default: () => ({}) })\n\nconst collapsed = ref(false)\n\nconst toggleCollapse = (event: Event) => {\n\tevent.preventDefault()\n\tif (collapsible) {\n\t\tcollapsed.value = !collapsed.value\n\t}\n}\n\ndefineExpose({ collapsed })\n</script>\n\n<style scoped>\nfieldset {\n\t/* Its padding and border sit inside the width, and no browser margin sits outside it: a fieldset\n\t spans exactly the space it is given, so its border never crosses the form's. */\n\tbox-sizing: border-box;\n\tmax-width: 100%;\n\twidth: 100%;\n\tmargin: 0;\n\tborder: 1px solid transparent;\n\tborder-bottom: 1px solid var(--sc-gray-50);\n}\n\nlegend {\n\twidth: 100%;\n\theight: 1.15rem;\n\tborder: 1px solid transparent;\n\tpadding-bottom: 0.5rem;\n\tfont-size: 110%;\n\tfont-weight: 600;\n\tuser-select: none;\n}\n\n.collapse-button {\n\tfloat: right;\n}\n</style>\n","<template>\n\t<fieldset>\n\t\t<legend v-if=\"label || collapsible\" @click=\"toggleCollapse\" @submit=\"toggleCollapse\">\n\t\t\t{{ label }}\n\t\t\t<CollapseButton v-if=\"collapsible\" :collapsed=\"collapsed\" />\n\t\t</legend>\n\t\t<slot :collapsed=\"collapsed\">\n\t\t\t<AForm v-show=\"!collapsed\" v-model:data=\"formData\" :schema=\"schema\" :mode=\"mode\" :errors=\"errors\" />\n\t\t</slot>\n\t</fieldset>\n</template>\n\n<script setup lang=\"ts\">\nimport type { InteractionMode } from '@stonecrop/schema'\nimport { ref } from 'vue'\n\nimport AForm from '../AForm.vue'\nimport CollapseButton from '../base/CollapseButton.vue'\nimport type { ResolvedField } from '../../types'\n\nconst {\n\tschema,\n\tlabel = undefined,\n\tcollapsible,\n\tmode = 'edit',\n\terrors = undefined,\n} = defineProps<{\n\tschema: ResolvedField[]\n\tlabel?: string\n\tcollapsible?: boolean\n\t/** Rendering mode forwarded to the inner AForm */\n\tmode?: InteractionMode\n\t/** Inline validation errors keyed by fieldname, forwarded to the inner AForm. */\n\terrors?: Record<string, string[]>\n}>()\n\n/** The record the fieldset's fields belong to: a fieldset is layout, so they are its own keys. */\nconst formData = defineModel<Record<string, any>>('data', { default: () => ({}) })\n\nconst collapsed = ref(false)\n\nconst toggleCollapse = (event: Event) => {\n\tevent.preventDefault()\n\tif (collapsible) {\n\t\tcollapsed.value = !collapsed.value\n\t}\n}\n\ndefineExpose({ collapsed })\n</script>\n\n<style scoped>\nfieldset {\n\t/* Its padding and border sit inside the width, and no browser margin sits outside it: a fieldset\n\t spans exactly the space it is given, so its border never crosses the form's. */\n\tbox-sizing: border-box;\n\tmax-width: 100%;\n\twidth: 100%;\n\tmargin: 0;\n\tborder: 1px solid transparent;\n\tborder-bottom: 1px solid var(--sc-gray-50);\n}\n\nlegend {\n\twidth: 100%;\n\theight: 1.15rem;\n\tborder: 1px solid transparent;\n\tpadding-bottom: 0.5rem;\n\tfont-size: 110%;\n\tfont-weight: 600;\n\tuser-select: none;\n}\n\n.collapse-button {\n\tfloat: right;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element aform_file-attach aform__grid--full\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<template v-if=\"files\">\n\t\t\t\t<div class=\"aform_file-attach-feedback\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<b>{{ fileLengthText }}</b>\n\t\t\t\t\t</p>\n\t\t\t\t\t<li v-for=\"file of files\" :key=\"file.name\">{{ file.name }}</li>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t<span v-else class=\"aform_display-value\">No file selected</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<template v-if=\"files\">\n\t\t\t\t<div class=\"aform_file-attach-feedback\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\tYou have selected: <b>{{ fileLengthText }}</b>\n\t\t\t\t\t</p>\n\t\t\t\t\t<li v-for=\"file of files\" :key=\"file.name\">\n\t\t\t\t\t\t{{ file.name }}\n\t\t\t\t\t</li>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t<button type=\"button\" class=\"aform_form-btn\" :disabled=\"mode === 'read'\" @click=\"open()\">\n\t\t\t\t{{ label }}\n\t\t\t</button>\n\t\t\t<button type=\"button\" :disabled=\"!files || mode === 'read'\" class=\"aform_form-btn\" @click=\"reset()\">Reset</button>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { useFileDialog } from '@vueuse/core'\nimport { computed } from 'vue'\n\nimport type { ComponentProps } from '../../types'\n\nconst { label, mode } = defineProps<ComponentProps>()\nconst { files, open, reset, onChange } = useFileDialog()\n\nconst fileLengthText = computed(() => {\n\tconst count = files.value?.length ?? 0\n\treturn `${count} ${count === 1 ? 'file' : 'files'}`\n})\n\nonChange(changedFiles => changedFiles)\n</script>\n\n<style scoped>\n.aform_file-attach {\n\tpadding: 0.5rem;\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 0.5rem;\n\tflex-direction: row;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tborder: 1px dashed var(--sc-input-border-color);\n\twidth: 100%;\n}\n\n@media screen and (max-width: 400px) {\n\t.aform_file-attach > .aform_form-btn {\n\t\twidth: 100%;\n\t}\n}\n\n.aform_file-attach-feedback {\n\tcolor: var(--sc-input-label-color);\n\twidth: 100%;\n\tpadding: 0.5rem;\n\ttext-align: center;\n\talign-self: center;\n\n\t& > li {\n\t\tlist-style: none;\n\t\tfont-style: italic;\n\t}\n\t& > p {\n\t\tmargin-top: 0;\n\t}\n}\n\n.aform_form-btn {\n\tpadding: 0 1rem;\n\twidth: auto;\n\tfont-size: 1rem;\n\tline-height: 1;\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-input-label-color);\n\tcursor: pointer;\n\tbackground-color: var(--sc-btn-color);\n}\n\n.aform_form-btn:disabled {\n\tbackground-color: var(--sc-gray-5);\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element aform_file-attach aform__grid--full\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<template v-if=\"files\">\n\t\t\t\t<div class=\"aform_file-attach-feedback\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<b>{{ fileLengthText }}</b>\n\t\t\t\t\t</p>\n\t\t\t\t\t<li v-for=\"file of files\" :key=\"file.name\">{{ file.name }}</li>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t<span v-else class=\"aform_display-value\">No file selected</span>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<template v-if=\"files\">\n\t\t\t\t<div class=\"aform_file-attach-feedback\">\n\t\t\t\t\t<p>\n\t\t\t\t\t\tYou have selected: <b>{{ fileLengthText }}</b>\n\t\t\t\t\t</p>\n\t\t\t\t\t<li v-for=\"file of files\" :key=\"file.name\">\n\t\t\t\t\t\t{{ file.name }}\n\t\t\t\t\t</li>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t\t<button type=\"button\" class=\"aform_form-btn\" :disabled=\"mode === 'read'\" @click=\"open()\">\n\t\t\t\t{{ label }}\n\t\t\t</button>\n\t\t\t<button type=\"button\" :disabled=\"!files || mode === 'read'\" class=\"aform_form-btn\" @click=\"reset()\">Reset</button>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { useFileDialog } from '@vueuse/core'\nimport { computed } from 'vue'\n\nimport type { ComponentProps } from '../../types'\n\nconst { label, mode } = defineProps<ComponentProps>()\nconst { files, open, reset, onChange } = useFileDialog()\n\nconst fileLengthText = computed(() => {\n\tconst count = files.value?.length ?? 0\n\treturn `${count} ${count === 1 ? 'file' : 'files'}`\n})\n\nonChange(changedFiles => changedFiles)\n</script>\n\n<style scoped>\n.aform_file-attach {\n\tpadding: 0.5rem;\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tgap: 0.5rem;\n\tflex-direction: row;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tborder: 1px dashed var(--sc-input-border-color);\n\twidth: 100%;\n}\n\n@media screen and (max-width: 400px) {\n\t.aform_file-attach > .aform_form-btn {\n\t\twidth: 100%;\n\t}\n}\n\n.aform_file-attach-feedback {\n\tcolor: var(--sc-input-label-color);\n\twidth: 100%;\n\tpadding: 0.5rem;\n\ttext-align: center;\n\talign-self: center;\n\n\t& > li {\n\t\tlist-style: none;\n\t\tfont-style: italic;\n\t}\n\t& > p {\n\t\tmargin-top: 0;\n\t}\n}\n\n.aform_form-btn {\n\tpadding: 0 1rem;\n\twidth: auto;\n\tfont-size: 1rem;\n\tline-height: 1;\n\tborder: 1px solid var(--sc-input-border-color);\n\tcolor: var(--sc-input-label-color);\n\tcursor: pointer;\n\tbackground-color: var(--sc-btn-color);\n}\n\n.aform_form-btn:disabled {\n\tbackground-color: var(--sc-gray-5);\n}\n</style>\n","<template>\n\t<div :class=\"['aform_form-element', { 'aform_form-element--embedded': embedded }]\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayedText }}</span>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div v-on-click-outside=\"onClickOutside\" class=\"aform_form-link-wrapper\">\n\t\t\t\t<div class=\"input-group\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-model=\"searchText\"\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\taria-autocomplete=\"list\"\n\t\t\t\t\t\t:class=\"['aform_input-field', { 'aform_input-field--embedded': embedded }]\"\n\t\t\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t\t\t:aria-label=\"ariaLabel\"\n\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t:aria-expanded=\"dropdownOpen\"\n\t\t\t\t\t\t:aria-controls=\"dropdownOpen ? listboxId : undefined\"\n\t\t\t\t\t\t:aria-activedescendant=\"activeIndex === null ? undefined : `${listboxId}-opt-${activeIndex}`\"\n\t\t\t\t\t\t:disabled=\"disabled || mode === 'read'\"\n\t\t\t\t\t\t@input=\"onInput\"\n\t\t\t\t\t\t@focus=\"onFocus\"\n\t\t\t\t\t\t@keydown.down.prevent=\"selectNext\"\n\t\t\t\t\t\t@keydown.up.prevent=\"selectPrev\"\n\t\t\t\t\t\t@keydown.enter.prevent=\"selectCurrent\"\n\t\t\t\t\t\t@keydown.esc=\"closeDropdown\"\n\t\t\t\t\t\t@keydown.tab=\"closeDropdown\" />\n\t\t\t\t\t<button\n\t\t\t\t\t\tv-if=\"hasValidId && !disabled && !embedded\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclass=\"aform_form-btn\"\n\t\t\t\t\t\t@click=\"handleNavigate\"\n\t\t\t\t\t\t@keydown.enter.prevent=\"handleNavigate\">\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tclass=\"aform_form-btn-icon\"\n\t\t\t\t\t\t\t:data-icon=\"icon\"\n\t\t\t\t\t\t\tviewBox=\"1.75 2.75 12.5 10.5\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tfocusable=\"false\">\n\t\t\t\t\t\t\t<path v-if=\"icon === 'chevron-right'\" d=\"M6 3.5 10.5 8 6 12.5\" />\n\t\t\t\t\t\t\t<path v-else d=\"M2.5 8h11M9 3.5 13.5 8 9 12.5\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t<span class=\"aform_form-btn-name\">{{ icon === 'chevron-right' ? '›' : '→' }}</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<ADropdownList\n\t\t\t\t\tv-if=\"mode !== 'read'\"\n\t\t\t\t\t:listbox-id=\"listboxId\"\n\t\t\t\t\t:ariaLabel=\"ariaLabel ?? label ?? ''\"\n\t\t\t\t\t:open=\"dropdownOpen\"\n\t\t\t\t\t:option-count=\"() => dropdownResults.length\"\n\t\t\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t\t\t<li v-if=\"loading\" class=\"loading autocomplete-result\">Loading…</li>\n\t\t\t\t\t<li\n\t\t\t\t\t\tv-for=\"(option, i) in dropdownResults\"\n\t\t\t\t\t\tv-else\n\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t:aria-selected=\"isResultSelected(option)\"\n\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': isResultSelected(option) }\"\n\t\t\t\t\t\t@mousedown.prevent=\"selectOption(option)\"\n\t\t\t\t\t\t@mouseenter=\"activeIndex = i\">\n\t\t\t\t\t\t<slot name=\"option\" :option=\"option\">{{ option.displayText ?? String(option.id) }}</slot>\n\t\t\t\t\t</li>\n\t\t\t\t</ADropdownList>\n\t\t\t</div>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, inject, ref, useId, watch } from 'vue'\n\nimport type { AFormLinkModelValue, AFormLinkNavigator, AFormLinkValue, ComponentProps } from '../../types'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { asLinkValue, linkDisplayText, linkId } from '../../utils/linkValue'\nimport ADropdownList from './ADropdownList.vue'\n\nconst {\n\tlabel,\n\tmode,\n\tuuid,\n\trequired,\n\tdoctype = undefined,\n\tformatter = undefined,\n\ticon = 'arrow-right',\n\tdisabled = false,\n\tfilterFunction = undefined,\n\tisAsync = false,\n\tembedded = false,\n\tplaceholder = undefined,\n\tariaLabel = undefined,\n} = defineProps<\n\tComponentProps & {\n\t\tdoctype?: string\n\t\tformatter?: (value: AFormLinkValue) => string\n\t\ticon?: 'arrow-right' | 'chevron-right'\n\t\tdisabled?: boolean\n\t\tfilterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>)\n\t\tisAsync?: boolean\n\t\t// Bare rendering for compositing into another component's own bordered container:\n\t\t// suppresses this component's own outline/border and floating label so the parent\n\t\t// supplies both exactly once.\n\t\tembedded?: boolean\n\t\tplaceholder?: string\n\t\t// Accessible name for the search input. Needed in `embedded` mode, where the visible\n\t\t// <label> is suppressed and a placeholder is not a dependable accessible name — it is\n\t\t// not exposed consistently across screen readers and vanishes once a value is picked.\n\t\tariaLabel?: string\n\t}\n>()\n\n// Ties the input to its listbox and to the active option (aria-controls / aria-activedescendant).\n// `uuid` is per-field when AForm supplies it; the fallback keeps the ids unique for a standalone\n// mount so two pickers on one page can't cross-wire their ARIA relationships.\nconst listboxId = `${uuid ?? `aform-link-${useId()}`}-listbox`\n\nconst modelValue = defineModel<AFormLinkModelValue>({ default: () => ({ id: '', displayText: '' }) })\n\nconst hasValidId = computed(() => linkId(modelValue.value) !== undefined)\n\n// The record a link names, as last seen with its text: the value itself, a pick, or this field's own\n// lookup. Kept here and never written into the record: a lookup is not a pick, and Save's reply hands\n// the id back bare.\nconst knownLink = ref<AFormLinkValue>()\n\nwatch(\n\t() => modelValue.value,\n\tvalue => {\n\t\tif (linkDisplayText(value)) knownLink.value = asLinkValue(value)\n\t},\n\t{ immediate: true }\n)\n\nconst shownLink = computed<AFormLinkModelValue>(() => {\n\tconst value = modelValue.value\n\tif (linkDisplayText(value)) return value\n\tconst id = linkId(value)\n\tconst known = knownLink.value\n\treturn known && id !== undefined && String(known.id) === String(id) ? known : value\n})\n\nconst displayedText = computed(() => {\n\tconst id = linkId(shownLink.value)\n\tif (id === undefined) return '—'\n\tif (formatter) return formatter(asLinkValue(shownLink.value))\n\treturn linkDisplayText(shownLink.value) ?? id\n})\n\nconst searchText = ref(hasValidId.value ? displayedText.value : '')\n\nconst dropdownOpen = ref(false)\nconst loading = ref(false)\nconst dropdownResults = ref<AFormLinkValue[]>([])\nconst activeIndex = ref<number | null>(null)\n\nconst navigator = inject<AFormLinkNavigator | null>('aformLinkNavigator', null)\n\ntype FilterFn = (search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\n// A link's value arrives as a bare scalar as often as it does as an AFormLinkValue: a record\n// loaded from the DB carries the raw FK column, and a parent bound to that column coerces every\n// update it receives back to a scalar. So read the value through these three helpers rather than\n// reaching into `modelValue.value` directly.\n//\n// Rejected: normalizing on write — an immediate watch that replaced a scalar model with `{ id }`.\n// It survives only until the parent writes its scalar back, so it fixed a scalar passed once at\n// mount and nothing else, and it emitted an `update:modelValue` the user never made on every\n// mount of a scalar-valued link field.\n// When the id changes (including on first render), resolve its display text.\n// Tries filterFunction first (returns a list of candidates to search); falls back to the\n// injected resolver (a direct doctype+id lookup). Skips if displayText is already set.\nwatch(\n\t() => linkId(modelValue.value),\n\tasync id => {\n\t\t// Already carries its text: nothing to resolve, but the input still has to show it.\n\t\t// `searchText` is assigned at setup and then only by the branches below, by `selectOption`\n\t\t// and by `closeDropdown` — and at setup a record's value has not arrived yet. So a link the\n\t\t// server resolved for us (the middleware returns `{ id, displayText }` for an inline link)\n\t\t// rendered blank, while a bare id rendered fine because it took the resolve branch.\n\t\tif (id && linkDisplayText(shownLink.value)) {\n\t\t\t// Through `displayedText` rather than the raw text, for the reason the resolve branch\n\t\t\t// formats too: the same value must not render differently depending on how it arrived.\n\t\t\tsearchText.value = displayedText.value\n\t\t\treturn\n\t\t}\n\t\tif (!id) return\n\t\ttry {\n\t\t\tlet match: AFormLinkValue | undefined\n\t\t\tlet displayText: string | undefined\n\t\t\tif (filterFunction) {\n\t\t\t\tconst fn: FilterFn =\n\t\t\t\t\ttypeof filterFunction === 'string' ? deserializeFunction<FilterFn>(filterFunction) : filterFunction\n\t\t\t\tconst results = await fn(String(id))\n\t\t\t\tmatch = results.find(r => String(r.id) === String(id))\n\t\t\t\tdisplayText = match?.displayText\n\t\t\t\tif (displayText === undefined) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[AFormLink] filterFunction returned no matching result for id \"${id}\". ` +\n\t\t\t\t\t\t\t`The function must return an item whose \\`id\\` exactly matches the search string.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (resolver && doctype) {\n\t\t\t\tdisplayText = (await resolver(doctype, id.toString())) ?? undefined\n\t\t\t}\n\t\t\tif (displayText) {\n\t\t\t\t// Keep the whole matched record, not just its display text: a formatter may render the\n\t\t\t\t// extra properties an AFormLinkValue carries. `id` is pinned to the value we already\n\t\t\t\t// hold so a loosely-typed match (1 vs '1') can't stand for a different record.\n\t\t\t\tknownLink.value = { ...asLinkValue(modelValue.value), ...match, id, displayText }\n\t\t\t\t// Format for the same reason selectOption does: the input shows `formatter`'s output\n\t\t\t\t// everywhere else (initial render, blur), so assigning the raw displayText here would\n\t\t\t\t// make a value that arrived as a bare id render differently from the identical value\n\t\t\t\t// picked by hand — e.g. \"Euro\" instead of \"€\".\n\t\t\t\tsearchText.value = displayedText.value\n\t\t\t}\n\t\t} catch {\n\t\t\t// silent — fall back to showing the raw id\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst handleNavigate = () => {\n\tconst id = linkId(modelValue.value)\n\tif (navigator && doctype && id !== undefined) {\n\t\tnavigator.navigate(doctype, id)\n\t} else if (navigator && !doctype) {\n\t\tconsole.warn(\n\t\t\t`[AFormLink] Navigation requested but \\`doctype\\` prop is missing. ` +\n\t\t\t\t`Add \\`options\\` (or \\`doctype\\`) to the Link field definition to enable navigation.`\n\t\t)\n\t}\n}\n\nconst isResultSelected = (option: AFormLinkValue) => {\n\tconst id = linkId(modelValue.value)\n\treturn id !== undefined && String(option.id) === String(id)\n}\n\nconst openDropdown = async (text: string) => {\n\tif (!filterFunction || mode === 'read') return\n\tactiveIndex.value = null\n\tdropdownOpen.value = true\n\tif (isAsync) loading.value = true\n\ttry {\n\t\tconst fn: FilterFn =\n\t\t\ttypeof filterFunction === 'string' ? deserializeFunction<FilterFn>(filterFunction) : filterFunction\n\t\tdropdownResults.value = (await fn(text)) ?? []\n\t} catch {\n\t\tdropdownResults.value = []\n\t} finally {\n\t\tloading.value = false\n\t}\n}\n\nconst closeDropdown = () => {\n\tdropdownOpen.value = false\n\tactiveIndex.value = null\n\tsearchText.value = hasValidId.value ? displayedText.value : ''\n}\n\nconst onClickOutside = () => {\n\tif (dropdownOpen.value) closeDropdown()\n}\n\nconst onFocus = () => openDropdown(searchText.value)\n\nconst onInput = () => openDropdown(searchText.value)\n\nconst selectOption = (option: AFormLinkValue) => {\n\tmodelValue.value = option\n\t// Format `option` directly rather than reading back displayedText/modelValue: under a real\n\t// two-way v-model (e.g. ACurrencyInput binding to a computed with a side-effecting setter),\n\t// modelValue.value still reflects the *prop* until the parent's update round-trips back,\n\t// so reading it synchronously here would show stale (pre-selection) text for a tick.\n\tsearchText.value = formatter ? formatter(option) : (option.displayText ?? String(option.id))\n\tdropdownOpen.value = false\n\tactiveIndex.value = null\n}\n\nconst selectNext = () => {\n\tconst len = dropdownResults.value.length\n\tif (!len) return\n\tactiveIndex.value = activeIndex.value === null ? 0 : (activeIndex.value + 1) % len\n}\n\nconst selectPrev = () => {\n\tconst len = dropdownResults.value.length\n\tif (!len) return\n\tif (activeIndex.value === null || activeIndex.value === 0) {\n\t\tactiveIndex.value = null\n\t} else {\n\t\tactiveIndex.value -= 1\n\t}\n}\n\nconst selectCurrent = () => {\n\tif (activeIndex.value !== null && dropdownResults.value[activeIndex.value]) {\n\t\tselectOption(dropdownResults.value[activeIndex.value])\n\t}\n}\n</script>\n\n<style scoped>\n.aform_form-link-wrapper {\n\tposition: relative;\n}\n\n.input-group {\n\tdisplay: flex;\n\talign-items: stretch;\n}\n\n.aform_input-field {\n\tflex: 1;\n\tmin-width: 0;\n}\n\n/* No top padding: the shared rule reserves it for a floating label, which embedded mode never renders. */\n.aform_form-element--embedded {\n\tmin-width: 0;\n\tflex: 1 1 auto;\n\twidth: 100%;\n\tpadding-top: 0;\n}\n\n/* Embedded mode: the host component's own container supplies the border, so this input goes\n borderless. Its vertical padding stays the standalone field's, so its text lines up with the host's. */\n.aform_input-field--embedded {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0.5rem 1ch;\n}\n\n/* Only in embedded mode is the trigger deliberately narrower than its options (e.g. a currency\n symbol box): let the dropdown grow past it rather than truncate. Standalone pickers keep the\n dropdown flush with the input, so a long display text can't overhang a narrow form column. */\n.aform_form-element--embedded .autocomplete-results {\n\tmin-width: 100%;\n}\n\n/* Give the button the same outline as the input, then slide it 2px left so the outlines\n overlap exactly at the join: input right outline sits at (input_right - 1px),\n button left outline also sits at (button_left + 1px) = (input_right - 2px + 1px) = same pixel. */\n.aform_form-btn {\n\tappearance: none;\n\tborder: none;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tmargin-left: -2px;\n\tbackground: var(--sc-input-field-background);\n\tpadding: 0.5rem 0.75rem;\n\tcursor: pointer;\n\tdisplay: block;\n\tfont-size: 1rem;\n\tline-height: normal;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n}\n\n/* Drawn rather than a text glyph, but set on the text's baseline at capital height: text sits\n above its box's centre, so an icon centred in the box reads low beside the input's text. */\n.aform_form-btn-icon {\n\theight: 0.716em;\n\twidth: auto;\n\tvertical-align: baseline;\n\toverflow: visible;\n\tfill: none;\n\tstroke: currentColor;\n\tstroke-width: 1.5;\n\tstroke-linecap: round;\n\tstroke-linejoin: round;\n}\n\n/* The glyph stays as the button's spoken name, hidden from sight. */\n.aform_form-btn-name {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n}\n\n.aform_form-btn:focus,\n.input-group:focus-within .aform_form-btn {\n\toutline-color: var(--sc-input-active-border-color);\n}\n</style>\n","<template>\n\t<div :class=\"['aform_form-element', { 'aform_form-element--embedded': embedded }]\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayedText }}</span>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div v-on-click-outside=\"onClickOutside\" class=\"aform_form-link-wrapper\">\n\t\t\t\t<div class=\"input-group\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tv-model=\"searchText\"\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\taria-autocomplete=\"list\"\n\t\t\t\t\t\t:class=\"['aform_input-field', { 'aform_input-field--embedded': embedded }]\"\n\t\t\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t\t\t:aria-label=\"ariaLabel\"\n\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t:aria-expanded=\"dropdownOpen\"\n\t\t\t\t\t\t:aria-controls=\"dropdownOpen ? listboxId : undefined\"\n\t\t\t\t\t\t:aria-activedescendant=\"activeIndex === null ? undefined : `${listboxId}-opt-${activeIndex}`\"\n\t\t\t\t\t\t:disabled=\"disabled || mode === 'read'\"\n\t\t\t\t\t\t@input=\"onInput\"\n\t\t\t\t\t\t@focus=\"onFocus\"\n\t\t\t\t\t\t@keydown.down.prevent=\"selectNext\"\n\t\t\t\t\t\t@keydown.up.prevent=\"selectPrev\"\n\t\t\t\t\t\t@keydown.enter.prevent=\"selectCurrent\"\n\t\t\t\t\t\t@keydown.esc=\"closeDropdown\"\n\t\t\t\t\t\t@keydown.tab=\"closeDropdown\" />\n\t\t\t\t\t<button\n\t\t\t\t\t\tv-if=\"hasValidId && !disabled && !embedded\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclass=\"aform_form-btn\"\n\t\t\t\t\t\t@click=\"handleNavigate\"\n\t\t\t\t\t\t@keydown.enter.prevent=\"handleNavigate\">\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\tclass=\"aform_form-btn-icon\"\n\t\t\t\t\t\t\t:data-icon=\"icon\"\n\t\t\t\t\t\t\tviewBox=\"1.75 2.75 12.5 10.5\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tfocusable=\"false\">\n\t\t\t\t\t\t\t<path v-if=\"icon === 'chevron-right'\" d=\"M6 3.5 10.5 8 6 12.5\" />\n\t\t\t\t\t\t\t<path v-else d=\"M2.5 8h11M9 3.5 13.5 8 9 12.5\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t<span class=\"aform_form-btn-name\">{{ icon === 'chevron-right' ? '›' : '→' }}</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<ADropdownList\n\t\t\t\t\tv-if=\"mode !== 'read'\"\n\t\t\t\t\t:listbox-id=\"listboxId\"\n\t\t\t\t\t:ariaLabel=\"ariaLabel ?? label ?? ''\"\n\t\t\t\t\t:open=\"dropdownOpen\"\n\t\t\t\t\t:option-count=\"() => dropdownResults.length\"\n\t\t\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t\t\t<li v-if=\"loading\" class=\"loading autocomplete-result\">Loading…</li>\n\t\t\t\t\t<li\n\t\t\t\t\t\tv-for=\"(option, i) in dropdownResults\"\n\t\t\t\t\t\tv-else\n\t\t\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t:aria-selected=\"isResultSelected(option)\"\n\t\t\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': isResultSelected(option) }\"\n\t\t\t\t\t\t@mousedown.prevent=\"selectOption(option)\"\n\t\t\t\t\t\t@mouseenter=\"activeIndex = i\">\n\t\t\t\t\t\t<slot name=\"option\" :option=\"option\">{{ option.displayText ?? String(option.id) }}</slot>\n\t\t\t\t\t</li>\n\t\t\t\t</ADropdownList>\n\t\t\t</div>\n\t\t\t<label v-if=\"label && !embedded\" class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, inject, ref, useId, watch } from 'vue'\n\nimport type { AFormLinkModelValue, AFormLinkNavigator, AFormLinkValue, ComponentProps } from '../../types'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { asLinkValue, linkDisplayText, linkId } from '../../utils/linkValue'\nimport ADropdownList from './ADropdownList.vue'\n\nconst {\n\tlabel,\n\tmode,\n\tuuid,\n\trequired,\n\tdoctype = undefined,\n\tformatter = undefined,\n\ticon = 'arrow-right',\n\tdisabled = false,\n\tfilterFunction = undefined,\n\tisAsync = false,\n\tembedded = false,\n\tplaceholder = undefined,\n\tariaLabel = undefined,\n} = defineProps<\n\tComponentProps & {\n\t\tdoctype?: string\n\t\tformatter?: (value: AFormLinkValue) => string\n\t\ticon?: 'arrow-right' | 'chevron-right'\n\t\tdisabled?: boolean\n\t\tfilterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>)\n\t\tisAsync?: boolean\n\t\t// Bare rendering for compositing into another component's own bordered container:\n\t\t// suppresses this component's own outline/border and floating label so the parent\n\t\t// supplies both exactly once.\n\t\tembedded?: boolean\n\t\tplaceholder?: string\n\t\t// Accessible name for the search input. Needed in `embedded` mode, where the visible\n\t\t// <label> is suppressed and a placeholder is not a dependable accessible name — it is\n\t\t// not exposed consistently across screen readers and vanishes once a value is picked.\n\t\tariaLabel?: string\n\t}\n>()\n\n// Ties the input to its listbox and to the active option (aria-controls / aria-activedescendant).\n// `uuid` is per-field when AForm supplies it; the fallback keeps the ids unique for a standalone\n// mount so two pickers on one page can't cross-wire their ARIA relationships.\nconst listboxId = `${uuid ?? `aform-link-${useId()}`}-listbox`\n\nconst modelValue = defineModel<AFormLinkModelValue>({ default: () => ({ id: '', displayText: '' }) })\n\nconst hasValidId = computed(() => linkId(modelValue.value) !== undefined)\n\n// The record a link names, as last seen with its text: the value itself, a pick, or this field's own\n// lookup. Kept here and never written into the record: a lookup is not a pick, and Save's reply hands\n// the id back bare.\nconst knownLink = ref<AFormLinkValue>()\n\nwatch(\n\t() => modelValue.value,\n\tvalue => {\n\t\tif (linkDisplayText(value)) knownLink.value = asLinkValue(value)\n\t},\n\t{ immediate: true }\n)\n\nconst shownLink = computed<AFormLinkModelValue>(() => {\n\tconst value = modelValue.value\n\tif (linkDisplayText(value)) return value\n\tconst id = linkId(value)\n\tconst known = knownLink.value\n\treturn known && id !== undefined && String(known.id) === String(id) ? known : value\n})\n\nconst displayedText = computed(() => {\n\tconst id = linkId(shownLink.value)\n\tif (id === undefined) return '—'\n\tif (formatter) return formatter(asLinkValue(shownLink.value))\n\treturn linkDisplayText(shownLink.value) ?? id\n})\n\nconst searchText = ref(hasValidId.value ? displayedText.value : '')\n\nconst dropdownOpen = ref(false)\nconst loading = ref(false)\nconst dropdownResults = ref<AFormLinkValue[]>([])\nconst activeIndex = ref<number | null>(null)\n\nconst navigator = inject<AFormLinkNavigator | null>('aformLinkNavigator', null)\n\ntype FilterFn = (search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>\ntype ResolverFn = (doctype: string, id: string) => string | undefined | Promise<string | undefined>\nconst resolver = inject<ResolverFn | null>('aformLinkResolver', null)\n\n// A link's value arrives as a bare scalar as often as it does as an AFormLinkValue: a record\n// loaded from the DB carries the raw FK column, and a parent bound to that column coerces every\n// update it receives back to a scalar. So read the value through these three helpers rather than\n// reaching into `modelValue.value` directly.\n//\n// Rejected: normalizing on write — an immediate watch that replaced a scalar model with `{ id }`.\n// It survives only until the parent writes its scalar back, so it fixed a scalar passed once at\n// mount and nothing else, and it emitted an `update:modelValue` the user never made on every\n// mount of a scalar-valued link field.\n// When the id changes (including on first render), resolve its display text.\n// Tries filterFunction first (returns a list of candidates to search); falls back to the\n// injected resolver (a direct doctype+id lookup). Skips if displayText is already set.\nwatch(\n\t() => linkId(modelValue.value),\n\tasync id => {\n\t\t// Already carries its text: nothing to resolve, but the input still has to show it.\n\t\t// `searchText` is assigned at setup and then only by the branches below, by `selectOption`\n\t\t// and by `closeDropdown` — and at setup a record's value has not arrived yet. So a link the\n\t\t// server resolved for us (the middleware returns `{ id, displayText }` for an inline link)\n\t\t// rendered blank, while a bare id rendered fine because it took the resolve branch.\n\t\tif (id && linkDisplayText(shownLink.value)) {\n\t\t\t// Through `displayedText` rather than the raw text, for the reason the resolve branch\n\t\t\t// formats too: the same value must not render differently depending on how it arrived.\n\t\t\tsearchText.value = displayedText.value\n\t\t\treturn\n\t\t}\n\t\tif (!id) return\n\t\ttry {\n\t\t\tlet match: AFormLinkValue | undefined\n\t\t\tlet displayText: string | undefined\n\t\t\tif (filterFunction) {\n\t\t\t\tconst fn: FilterFn =\n\t\t\t\t\ttypeof filterFunction === 'string' ? deserializeFunction<FilterFn>(filterFunction) : filterFunction\n\t\t\t\tconst results = await fn(String(id))\n\t\t\t\tmatch = results.find(r => String(r.id) === String(id))\n\t\t\t\tdisplayText = match?.displayText\n\t\t\t\tif (displayText === undefined) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[AFormLink] filterFunction returned no matching result for id \"${id}\". ` +\n\t\t\t\t\t\t\t`The function must return an item whose \\`id\\` exactly matches the search string.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (resolver && doctype) {\n\t\t\t\tdisplayText = (await resolver(doctype, id.toString())) ?? undefined\n\t\t\t}\n\t\t\tif (displayText) {\n\t\t\t\t// Keep the whole matched record, not just its display text: a formatter may render the\n\t\t\t\t// extra properties an AFormLinkValue carries. `id` is pinned to the value we already\n\t\t\t\t// hold so a loosely-typed match (1 vs '1') can't stand for a different record.\n\t\t\t\tknownLink.value = { ...asLinkValue(modelValue.value), ...match, id, displayText }\n\t\t\t\t// Format for the same reason selectOption does: the input shows `formatter`'s output\n\t\t\t\t// everywhere else (initial render, blur), so assigning the raw displayText here would\n\t\t\t\t// make a value that arrived as a bare id render differently from the identical value\n\t\t\t\t// picked by hand — e.g. \"Euro\" instead of \"€\".\n\t\t\t\tsearchText.value = displayedText.value\n\t\t\t}\n\t\t} catch {\n\t\t\t// silent — fall back to showing the raw id\n\t\t}\n\t},\n\t{ immediate: true }\n)\n\nconst handleNavigate = () => {\n\tconst id = linkId(modelValue.value)\n\tif (navigator && doctype && id !== undefined) {\n\t\tnavigator.navigate(doctype, id)\n\t} else if (navigator && !doctype) {\n\t\tconsole.warn(\n\t\t\t`[AFormLink] Navigation requested but \\`doctype\\` prop is missing. ` +\n\t\t\t\t`Add \\`options\\` (or \\`doctype\\`) to the Link field definition to enable navigation.`\n\t\t)\n\t}\n}\n\nconst isResultSelected = (option: AFormLinkValue) => {\n\tconst id = linkId(modelValue.value)\n\treturn id !== undefined && String(option.id) === String(id)\n}\n\nconst openDropdown = async (text: string) => {\n\tif (!filterFunction || mode === 'read') return\n\tactiveIndex.value = null\n\tdropdownOpen.value = true\n\tif (isAsync) loading.value = true\n\ttry {\n\t\tconst fn: FilterFn =\n\t\t\ttypeof filterFunction === 'string' ? deserializeFunction<FilterFn>(filterFunction) : filterFunction\n\t\tdropdownResults.value = (await fn(text)) ?? []\n\t} catch {\n\t\tdropdownResults.value = []\n\t} finally {\n\t\tloading.value = false\n\t}\n}\n\nconst closeDropdown = () => {\n\tdropdownOpen.value = false\n\tactiveIndex.value = null\n\tsearchText.value = hasValidId.value ? displayedText.value : ''\n}\n\nconst onClickOutside = () => {\n\tif (dropdownOpen.value) closeDropdown()\n}\n\nconst onFocus = () => openDropdown(searchText.value)\n\nconst onInput = () => openDropdown(searchText.value)\n\nconst selectOption = (option: AFormLinkValue) => {\n\tmodelValue.value = option\n\t// Format `option` directly rather than reading back displayedText/modelValue: under a real\n\t// two-way v-model (e.g. ACurrencyInput binding to a computed with a side-effecting setter),\n\t// modelValue.value still reflects the *prop* until the parent's update round-trips back,\n\t// so reading it synchronously here would show stale (pre-selection) text for a tick.\n\tsearchText.value = formatter ? formatter(option) : (option.displayText ?? String(option.id))\n\tdropdownOpen.value = false\n\tactiveIndex.value = null\n}\n\nconst selectNext = () => {\n\tconst len = dropdownResults.value.length\n\tif (!len) return\n\tactiveIndex.value = activeIndex.value === null ? 0 : (activeIndex.value + 1) % len\n}\n\nconst selectPrev = () => {\n\tconst len = dropdownResults.value.length\n\tif (!len) return\n\tif (activeIndex.value === null || activeIndex.value === 0) {\n\t\tactiveIndex.value = null\n\t} else {\n\t\tactiveIndex.value -= 1\n\t}\n}\n\nconst selectCurrent = () => {\n\tif (activeIndex.value !== null && dropdownResults.value[activeIndex.value]) {\n\t\tselectOption(dropdownResults.value[activeIndex.value])\n\t}\n}\n</script>\n\n<style scoped>\n.aform_form-link-wrapper {\n\tposition: relative;\n}\n\n.input-group {\n\tdisplay: flex;\n\talign-items: stretch;\n}\n\n.aform_input-field {\n\tflex: 1;\n\tmin-width: 0;\n}\n\n/* No top padding: the shared rule reserves it for a floating label, which embedded mode never renders. */\n.aform_form-element--embedded {\n\tmin-width: 0;\n\tflex: 1 1 auto;\n\twidth: 100%;\n\tpadding-top: 0;\n}\n\n/* Embedded mode: the host component's own container supplies the border, so this input goes\n borderless. Its vertical padding stays the standalone field's, so its text lines up with the host's. */\n.aform_input-field--embedded {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\toutline: none;\n\tbackground: transparent;\n\tpadding: 0.5rem 1ch;\n}\n\n/* Only in embedded mode is the trigger deliberately narrower than its options (e.g. a currency\n symbol box): let the dropdown grow past it rather than truncate. Standalone pickers keep the\n dropdown flush with the input, so a long display text can't overhang a narrow form column. */\n.aform_form-element--embedded .autocomplete-results {\n\tmin-width: 100%;\n}\n\n/* Give the button the same outline as the input, then slide it 2px left so the outlines\n overlap exactly at the join: input right outline sits at (input_right - 1px),\n button left outline also sits at (button_left + 1px) = (input_right - 2px + 1px) = same pixel. */\n.aform_form-btn {\n\tappearance: none;\n\tborder: none;\n\toutline: 1px solid var(--sc-input-border-color);\n\toutline-offset: -1px;\n\tmargin-left: -2px;\n\tbackground: var(--sc-input-field-background);\n\tpadding: 0.5rem 0.75rem;\n\tcursor: pointer;\n\tdisplay: block;\n\tfont-size: 1rem;\n\tline-height: normal;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n}\n\n/* Drawn rather than a text glyph, but set on the text's baseline at capital height: text sits\n above its box's centre, so an icon centred in the box reads low beside the input's text. */\n.aform_form-btn-icon {\n\theight: 0.716em;\n\twidth: auto;\n\tvertical-align: baseline;\n\toverflow: visible;\n\tfill: none;\n\tstroke: currentColor;\n\tstroke-width: 1.5;\n\tstroke-linecap: round;\n\tstroke-linejoin: round;\n}\n\n/* The glyph stays as the button's spoken name, hidden from sight. */\n.aform_form-btn-name {\n\tposition: absolute;\n\twidth: 1px;\n\theight: 1px;\n\tmargin: -1px;\n\toverflow: hidden;\n\tclip: rect(0, 0, 0, 0);\n\twhite-space: nowrap;\n}\n\n.aform_form-btn:focus,\n.input-group:focus-within .aform_form-btn {\n\toutline-color: var(--sc-input-active-border-color);\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ inputNumber ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"boxNumber\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"number\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\nimport { numberFromBox } from '../../utils/emptiedBox'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst inputNumber = defineModel<number | null>()\n\nconst boxNumber = computed({\n\tget: () => inputNumber.value,\n\tset: (value: number | '') => (inputNumber.value = numberFromBox(value)),\n})\n</script>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ inputNumber ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"boxNumber\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\ttype=\"number\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\nimport { numberFromBox } from '../../utils/emptiedBox'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst inputNumber = defineModel<number | null>()\n\nconst boxNumber = computed({\n\tget: () => inputNumber.value,\n\tset: (value: number | '') => (inputNumber.value = numberFromBox(value)),\n})\n</script>\n","import type { QuantityOptions, QuantityValue } from '../types'\n\n/** What a quantity box may hold, typed or pasted: digits, one decimal point and a leading minus sign. */\nexport const quantityEntryPattern = /^-?\\d*\\.?\\d*$/\n\nconst roundQty = (value: number): number => Number(value.toFixed(6))\n\nexport function resolveQuantityConversionFactor(\n\tuom: string,\n\toptions: QuantityOptions,\n\tcurrent: QuantityValue | null | undefined\n): number {\n\tconst stockUom = options.stockUom ?? current?.stockUom\n\tif (!uom || uom === stockUom) return 1\n\tconst mapped = options.conversionFactors?.[uom]\n\tif (mapped !== undefined) return mapped\n\tif (uom === current?.uom) return current.conversionFactor ?? 1\n\treturn 1\n}\n\nexport function recomputeQuantityValue(\n\tqty: number | null,\n\tuom: string,\n\toptions: QuantityOptions,\n\tcurrent: QuantityValue | null | undefined\n): QuantityValue {\n\tconst conversionFactor = resolveQuantityConversionFactor(uom, options, current)\n\treturn {\n\t\tqty,\n\t\tuom,\n\t\tconversionFactor,\n\t\tstockUom: options.stockUom ?? current?.stockUom ?? '',\n\t\tstockQty: qty === null ? null : roundQty(qty * conversionFactor),\n\t}\n}\n\nexport function patchQuantityQty(\n\tcurrent: QuantityValue | null | undefined,\n\tqty: number | null,\n\toptions: QuantityOptions\n): QuantityValue {\n\t// `current.uom` exactly as given, never `?? ''`: under `parts` the unit is a field of its own,\n\t// and typing a quantity must not turn an empty unit into `''`.\n\treturn recomputeQuantityValue(qty, current ? current.uom : '', options, current)\n}\n\nexport function patchQuantityUom(\n\tcurrent: QuantityValue | null | undefined,\n\tuom: string,\n\toptions: QuantityOptions\n): QuantityValue {\n\treturn recomputeQuantityValue(current?.qty ?? null, uom, options, current)\n}\n","<template>\n\t<div class=\"aform_form-element aquantity\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayText }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div class=\"aquantity__row\">\n\t\t\t\t<div class=\"aquantity__field aquantity__field--qty\">\n\t\t\t\t\t<div class=\"aquantity__group\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\tv-model.number=\"qty\"\n\t\t\t\t\t\t\tclass=\"aquantity__qty\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t@keydown=\"onQtyKeydown\"\n\t\t\t\t\t\t\t@paste=\"onQtyPaste\" />\n\t\t\t\t\t\t<div class=\"aquantity__uom\">\n\t\t\t\t\t\t\t<ADropdown\n\t\t\t\t\t\t\t\tv-model=\"uom\"\n\t\t\t\t\t\t\t\tembedded\n\t\t\t\t\t\t\t\ttrigger=\"button\"\n\t\t\t\t\t\t\t\tlist-anchor=\"group\"\n\t\t\t\t\t\t\t\t:options=\"uoms\"\n\t\t\t\t\t\t\t\t:mode=\"mode\"\n\t\t\t\t\t\t\t\t:uuid=\"uuid ? `${uuid}-uom` : undefined\"\n\t\t\t\t\t\t\t\t:aria-label=\"uomLabel\"\n\t\t\t\t\t\t\t\t:placeholder=\"uomLabel\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<p v-if=\"showStock && !errorText\" :id=\"helperId\" class=\"aquantity__helper\">{{ conversionHelperText }}</p>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps, QuantityOptions, QuantityValue } from '../../types'\nimport { numberFromBox } from '../../utils/emptiedBox'\nimport { numberFromRecord } from '../../utils/recordNumber'\nimport {\n\tpatchQuantityQty,\n\tpatchQuantityUom,\n\tquantityEntryPattern,\n\trecomputeQuantityValue,\n} from '../../utils/quantityValue'\nimport ADropdown from './ADropdown.vue'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\toptions = {},\n\tuomLabel = 'UOM',\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: QuantityOptions\n\t\tuomLabel?: string\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst helperId = computed(() => (uuid ? `${uuid}-helper` : undefined))\nconst helperDescribedBy = computed(() => (showStock.value && !errorText.value ? helperId.value : undefined))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText, helperDescribedBy)\n\n// No default: a field with no value shows empty, as null does, rather than a factor nobody entered.\nconst modelValue = defineModel<QuantityValue | null>()\n\nconst uoms = computed(() => options.uoms ?? [])\n\nconst qty = computed({\n\tget: () => modelValue.value?.qty ?? null,\n\tset: (value: number | '') => (modelValue.value = patchQuantityQty(modelValue.value, numberFromBox(value), options)),\n})\n\nconst uom = computed({\n\tget: () => modelValue.value?.uom ?? '',\n\tset: (value: string) => (modelValue.value = patchQuantityUom(modelValue.value, value, options)),\n})\n\nconst qtyNavigationKeys = new Set([\n\t'Backspace',\n\t'Delete',\n\t'Tab',\n\t'Escape',\n\t'Enter',\n\t'ArrowLeft',\n\t'ArrowRight',\n\t'ArrowUp',\n\t'ArrowDown',\n\t'Home',\n\t'End',\n])\n\nconst onQtyKeydown = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (qtyNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\t// Quantity is signed — returns, adjustments, and credit lines can be negative.\n\tconst input = event.target as HTMLInputElement\n\tif (event.key === '.' && !input.value.includes('.')) return\n\tif (event.key === '-' && !input.value.includes('-')) return\n\tevent.preventDefault()\n}\n\nconst onQtyPaste = (event: ClipboardEvent) => {\n\tconst pasted = event.clipboardData?.getData('text') ?? ''\n\tif (!quantityEntryPattern.test(pasted)) event.preventDefault()\n}\n\n// The stock figures are worked out from qty, uom and the options rather than read from the value:\n// under `parts` no field holds them, and the quantity field holds what the server sent (decimal text).\nconst shown = computed(() => {\n\tconst boxValue = modelValue.value\n\treturn boxValue ? recomputeQuantityValue(numberFromRecord(boxValue.qty), boxValue.uom, options, boxValue) : null\n})\n\nconst showStock = computed(() => {\n\tconst shownValue = shown.value\n\treturn !!shownValue?.stockUom && (shownValue.uom !== shownValue.stockUom || shownValue.qty !== shownValue.stockQty)\n})\n\nconst conversionHelperText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || shownValue.stockQty === null || shownValue.qty === null) return ''\n\tconst factor = shownValue.conversionFactor\n\treturn `= ${shownValue.stockQty} ${shownValue.stockUom} · 1 ${shownValue.uom} = ${factor} ${shownValue.stockUom}`\n})\n\nconst displayText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || !shownValue.uom || shownValue.qty === null) return '—'\n\tconst base = `${shownValue.qty} ${shownValue.uom}`\n\treturn showStock.value ? `${base} (${shownValue.stockQty} ${shownValue.stockUom})` : base\n})\n</script>\n\n<style scoped>\n.aquantity__row {\n\tdisplay: flex;\n\tgap: 1ch;\n}\n\n.aquantity__field {\n\tposition: relative;\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.aquantity__group {\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius);\n}\n\n.aquantity__group:focus-within {\n\tborder-color: var(--sc-input-active-border-color);\n}\n\n.aquantity__group > .aform_field-label {\n\tbackground: var(--sc-form-background);\n}\n\n/* Focus ring lives on the merged group only (see AForm :focus-within label + group border). */\n.aquantity__group :deep(.aform_dropdown-button:focus),\n.aquantity__group :deep(.aform_dropdown-button:focus-visible) {\n\toutline: none;\n\tbox-shadow: none;\n}\n\n.aquantity__qty {\n\tflex: 1 1 50%;\n\tmin-width: 0;\n\tborder: none;\n\toutline: none;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\ttext-align: right;\n\tbackground: transparent;\n\tborder-radius: var(--sc-border-radius) 0 0 var(--sc-border-radius);\n\tappearance: textfield;\n\t-moz-appearance: textfield;\n}\n\n.aquantity__qty::-webkit-outer-spin-button,\n.aquantity__qty::-webkit-inner-spin-button {\n\tappearance: none;\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.aquantity__uom {\n\tposition: static;\n\tflex: 1 1 50%;\n\tmin-width: 0;\n\tdisplay: flex;\n\talign-items: stretch;\n\tborder-left: 1px solid var(--sc-input-border-color);\n}\n\n/* ADropdown list: anchor to merged group, not the UOM trigger column (see dropdowns.browser.spec). */\n.aquantity__group :deep(.aform_form-element--embedded),\n.aquantity__group :deep(.autocomplete) {\n\tposition: static;\n\talign-self: stretch;\n}\n\n.aquantity__group :deep(.autocomplete-results--anchor-group) {\n\tleft: -1px;\n\tright: -1px;\n\tbox-sizing: border-box;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.aquantity__helper {\n\tmargin: 0.5rem 0 0;\n\tfont-size: 0.85rem;\n\tcolor: var(--sc-cell-text-color);\n\topacity: 0.75;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element aquantity\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ displayText }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<div class=\"aquantity__row\">\n\t\t\t\t<div class=\"aquantity__field aquantity__field--qty\">\n\t\t\t\t\t<div class=\"aquantity__group\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t:id=\"uuid\"\n\t\t\t\t\t\t\tv-model.number=\"qty\"\n\t\t\t\t\t\t\tclass=\"aquantity__qty\"\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t\t\t\t:required=\"required\"\n\t\t\t\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t\t\t\t@keydown=\"onQtyKeydown\"\n\t\t\t\t\t\t\t@paste=\"onQtyPaste\" />\n\t\t\t\t\t\t<div class=\"aquantity__uom\">\n\t\t\t\t\t\t\t<ADropdown\n\t\t\t\t\t\t\t\tv-model=\"uom\"\n\t\t\t\t\t\t\t\tembedded\n\t\t\t\t\t\t\t\ttrigger=\"button\"\n\t\t\t\t\t\t\t\tlist-anchor=\"group\"\n\t\t\t\t\t\t\t\t:options=\"uoms\"\n\t\t\t\t\t\t\t\t:mode=\"mode\"\n\t\t\t\t\t\t\t\t:uuid=\"uuid ? `${uuid}-uom` : undefined\"\n\t\t\t\t\t\t\t\t:aria-label=\"uomLabel\"\n\t\t\t\t\t\t\t\t:placeholder=\"uomLabel\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<p v-if=\"showStock && !errorText\" :id=\"helperId\" class=\"aquantity__helper\">{{ conversionHelperText }}</p>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport type { ComponentProps, QuantityOptions, QuantityValue } from '../../types'\nimport { numberFromBox } from '../../utils/emptiedBox'\nimport { numberFromRecord } from '../../utils/recordNumber'\nimport {\n\tpatchQuantityQty,\n\tpatchQuantityUom,\n\tquantityEntryPattern,\n\trecomputeQuantityValue,\n} from '../../utils/quantityValue'\nimport ADropdown from './ADropdown.vue'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tvalidation = { errorMessage: '' },\n\toptions = {},\n\tuomLabel = 'UOM',\n} = defineProps<\n\tComponentProps & {\n\t\toptions?: QuantityOptions\n\t\tuomLabel?: string\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst helperId = computed(() => (uuid ? `${uuid}-helper` : undefined))\nconst helperDescribedBy = computed(() => (showStock.value && !errorText.value ? helperId.value : undefined))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText, helperDescribedBy)\n\n// No default: a field with no value shows empty, as null does, rather than a factor nobody entered.\nconst modelValue = defineModel<QuantityValue | null>()\n\nconst uoms = computed(() => options.uoms ?? [])\n\nconst qty = computed({\n\tget: () => modelValue.value?.qty ?? null,\n\tset: (value: number | '') => (modelValue.value = patchQuantityQty(modelValue.value, numberFromBox(value), options)),\n})\n\nconst uom = computed({\n\tget: () => modelValue.value?.uom ?? '',\n\tset: (value: string) => (modelValue.value = patchQuantityUom(modelValue.value, value, options)),\n})\n\nconst qtyNavigationKeys = new Set([\n\t'Backspace',\n\t'Delete',\n\t'Tab',\n\t'Escape',\n\t'Enter',\n\t'ArrowLeft',\n\t'ArrowRight',\n\t'ArrowUp',\n\t'ArrowDown',\n\t'Home',\n\t'End',\n])\n\nconst onQtyKeydown = (event: KeyboardEvent) => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return\n\tif (qtyNavigationKeys.has(event.key)) return\n\tif (/^[0-9]$/.test(event.key)) return\n\t// Quantity is signed — returns, adjustments, and credit lines can be negative.\n\tconst input = event.target as HTMLInputElement\n\tif (event.key === '.' && !input.value.includes('.')) return\n\tif (event.key === '-' && !input.value.includes('-')) return\n\tevent.preventDefault()\n}\n\nconst onQtyPaste = (event: ClipboardEvent) => {\n\tconst pasted = event.clipboardData?.getData('text') ?? ''\n\tif (!quantityEntryPattern.test(pasted)) event.preventDefault()\n}\n\n// The stock figures are worked out from qty, uom and the options rather than read from the value:\n// under `parts` no field holds them, and the quantity field holds what the server sent (decimal text).\nconst shown = computed(() => {\n\tconst boxValue = modelValue.value\n\treturn boxValue ? recomputeQuantityValue(numberFromRecord(boxValue.qty), boxValue.uom, options, boxValue) : null\n})\n\nconst showStock = computed(() => {\n\tconst shownValue = shown.value\n\treturn !!shownValue?.stockUom && (shownValue.uom !== shownValue.stockUom || shownValue.qty !== shownValue.stockQty)\n})\n\nconst conversionHelperText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || shownValue.stockQty === null || shownValue.qty === null) return ''\n\tconst factor = shownValue.conversionFactor\n\treturn `= ${shownValue.stockQty} ${shownValue.stockUom} · 1 ${shownValue.uom} = ${factor} ${shownValue.stockUom}`\n})\n\nconst displayText = computed(() => {\n\tconst shownValue = shown.value\n\tif (!shownValue || !shownValue.uom || shownValue.qty === null) return '—'\n\tconst base = `${shownValue.qty} ${shownValue.uom}`\n\treturn showStock.value ? `${base} (${shownValue.stockQty} ${shownValue.stockUom})` : base\n})\n</script>\n\n<style scoped>\n.aquantity__row {\n\tdisplay: flex;\n\tgap: 1ch;\n}\n\n.aquantity__field {\n\tposition: relative;\n\tflex: 1;\n\tmin-width: 0;\n}\n\n.aquantity__group {\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: stretch;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tbackground: var(--sc-input-field-background);\n\tborder: 1px solid var(--sc-input-border-color);\n\tborder-radius: var(--sc-border-radius);\n}\n\n.aquantity__group:focus-within {\n\tborder-color: var(--sc-input-active-border-color);\n}\n\n.aquantity__group > .aform_field-label {\n\tbackground: var(--sc-form-background);\n}\n\n/* Focus ring lives on the merged group only (see AForm :focus-within label + group border). */\n.aquantity__group :deep(.aform_dropdown-button:focus),\n.aquantity__group :deep(.aform_dropdown-button:focus-visible) {\n\toutline: none;\n\tbox-shadow: none;\n}\n\n.aquantity__qty {\n\tflex: 1 1 50%;\n\tmin-width: 0;\n\tborder: none;\n\toutline: none;\n\tpadding: 0.5rem 1ch;\n\tfont-size: 1rem;\n\tfont-family: var(--sc-font-family);\n\tcolor: var(--sc-cell-text-color);\n\ttext-align: right;\n\tbackground: transparent;\n\tborder-radius: var(--sc-border-radius) 0 0 var(--sc-border-radius);\n\tappearance: textfield;\n\t-moz-appearance: textfield;\n}\n\n.aquantity__qty::-webkit-outer-spin-button,\n.aquantity__qty::-webkit-inner-spin-button {\n\tappearance: none;\n\t-webkit-appearance: none;\n\tmargin: 0;\n}\n\n.aquantity__uom {\n\tposition: static;\n\tflex: 1 1 50%;\n\tmin-width: 0;\n\tdisplay: flex;\n\talign-items: stretch;\n\tborder-left: 1px solid var(--sc-input-border-color);\n}\n\n/* ADropdown list: anchor to merged group, not the UOM trigger column (see dropdowns.browser.spec). */\n.aquantity__group :deep(.aform_form-element--embedded),\n.aquantity__group :deep(.autocomplete) {\n\tposition: static;\n\talign-self: stretch;\n}\n\n.aquantity__group :deep(.autocomplete-results--anchor-group) {\n\tleft: -1px;\n\tright: -1px;\n\tbox-sizing: border-box;\n\twidth: auto;\n\tmin-width: unset;\n\tmax-width: none;\n}\n\n.aquantity__helper {\n\tmargin: 0.5rem 0 0;\n\tfont-size: 0.85rem;\n\tcolor: var(--sc-cell-text-color);\n\topacity: 0.75;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ version ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\t:value=\"text\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\tautocomplete=\"off\"\n\t\t\t\tspellcheck=\"false\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@input=\"onInput\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { isSemver, isSemverPrefix } from '@stonecrop/utilities'\nimport { computed, ref, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst version = defineModel<string | null>()\n\n// The box can hold a version still being typed (`1.4.`), which the field holds as null until it is\n// whole, the way a date box holds null until every part of the day is filled.\nconst text = ref('')\nconst versionIn = (boxText: string) => (isSemver(boxText) ? boxText : null)\n\n// Show a value arriving from outside, unless the box already holds a draft of it. Only an edit\n// reports a value, so a record loading into the form never reads as a change.\nwatch(\n\tversion,\n\tvalue => {\n\t\tif (versionIn(text.value) !== (value ?? null)) text.value = value ?? ''\n\t},\n\t{ immediate: true }\n)\n\nconst onInput = (event: Event) => {\n\tconst box = event.target as HTMLInputElement\n\n\t// Refuse an edit leaving text that no version starts with, and put the caret back where it was.\n\t// Text already like that, saved before the field checked it, takes any edit so it can be fixed.\n\tif (!isSemverPrefix(box.value) && isSemverPrefix(text.value)) {\n\t\tconst caret = Math.max(0, (box.selectionStart ?? box.value.length) - (box.value.length - text.value.length))\n\t\tbox.value = text.value\n\t\tbox.setSelectionRange(caret, caret)\n\t\treturn\n\t}\n\n\ttext.value = box.value\n\tconst next = versionIn(box.value)\n\tif (next !== (version.value ?? null)) version.value = next\n}\n</script>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ version ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\t:value=\"text\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\tautocomplete=\"off\"\n\t\t\t\tspellcheck=\"false\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"\n\t\t\t\t@input=\"onInput\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { isSemver, isSemverPrefix } from '@stonecrop/utilities'\nimport { computed, ref, watch } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst { label, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst version = defineModel<string | null>()\n\n// The box can hold a version still being typed (`1.4.`), which the field holds as null until it is\n// whole, the way a date box holds null until every part of the day is filled.\nconst text = ref('')\nconst versionIn = (boxText: string) => (isSemver(boxText) ? boxText : null)\n\n// Show a value arriving from outside, unless the box already holds a draft of it. Only an edit\n// reports a value, so a record loading into the form never reads as a change.\nwatch(\n\tversion,\n\tvalue => {\n\t\tif (versionIn(text.value) !== (value ?? null)) text.value = value ?? ''\n\t},\n\t{ immediate: true }\n)\n\nconst onInput = (event: Event) => {\n\tconst box = event.target as HTMLInputElement\n\n\t// Refuse an edit leaving text that no version starts with, and put the caret back where it was.\n\t// Text already like that, saved before the field checked it, takes any edit so it can be fixed.\n\tif (!isSemverPrefix(box.value) && isSemverPrefix(text.value)) {\n\t\tconst caret = Math.max(0, (box.selectionStart ?? box.value.length) - (box.value.length - text.value.length))\n\t\tbox.value = text.value\n\t\tbox.setSelectionRange(caret, caret)\n\t\treturn\n\t}\n\n\ttext.value = box.value\n\tconst next = versionIn(box.value)\n\tif (next !== (version.value ?? null)) version.value = next\n}\n</script>\n","import type { DirectiveBinding } from 'vue'\n\nimport { deserializeFunction } from '../utils/deserialize'\n\n/**\n * Extracts a mask function from a stringified function\n * @param mask - Mask string\n * @returns Mask function, or undefined if the string is not a valid function expression\n */\nfunction extractMaskFn(mask: string): ((locale: any) => string) | undefined {\n\ttry {\n\t\treturn deserializeFunction<(locale: any) => string>(mask)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/**\n * Gets the mask for a given directive binding\n * @param binding - Binding object from directive hook\n * @returns Mask string\n */\nfunction getMask(binding: DirectiveBinding<string>) {\n\tconst mask = binding.value\n\tif (!mask) return undefined\n\n\tconst maskFn = extractMaskFn(mask)\n\tif (maskFn) {\n\t\t// TODO: (state) replace with state management;\n\t\t// pass the entire form/table data to the function\n\t\t// Vue directive reads arbitrary fields off host component instance; type is unknown at this layer.\n\t\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion\n\t\tconst instance = binding.instance as Record<string, unknown> | null | undefined\n\t\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion\n\t\tconst locale = instance?.['locale'] as string | undefined\n\t\treturn maskFn(locale)\n\t}\n\n\treturn mask\n}\n\n/**\n * Unmasks the input string\n * @param input - Input string\n * @param maskToken - Mask token character\n * @returns Unmasked input string\n */\nfunction unmaskInput(input: string, maskToken?: string) {\n\tif (!maskToken) {\n\t\tmaskToken = '#'\n\t}\n\n\tlet unmaskedInput = input\n\tconst maskChars = [maskToken, '/', '-', '(', ')', ' ']\n\n\tfor (const char of maskChars) {\n\t\tunmaskedInput = unmaskedInput.replaceAll(char, '')\n\t}\n\n\treturn unmaskedInput\n}\n\n/**\n * Fills the mask with the input string\n * @param input - Input string\n * @param mask - Mask string\n * @param maskToken - Mask token character\n * @returns Masked input string\n */\nfunction fillMask(input: string, mask: string, maskToken?: string) {\n\tif (!maskToken) {\n\t\tmaskToken = '#'\n\t}\n\n\tlet replacement = mask\n\tfor (const inputChar of input) {\n\t\tconst replaceIndex = replacement.indexOf(maskToken)\n\t\tif (replaceIndex !== -1) {\n\t\t\tconst prefix = replacement.substring(0, replaceIndex)\n\t\t\tconst suffix = replacement.substring(replaceIndex + 1)\n\t\t\treplacement = prefix + inputChar + suffix\n\t\t}\n\t}\n\n\treturn replacement.slice(0, mask.length)\n}\n\n/**\n * Applies a mask to an input element\n * @param el - Input element\n * @param binding - Binding object from directive hook\n * @returns void\n * @public\n */\nexport function useStringMask(el: HTMLInputElement, binding: DirectiveBinding<string>) {\n\tconst mask = getMask(binding)\n\tif (!mask) return\n\n\tconst maskToken = '#'\n\tconst inputText = el.value\n\n\t// process input value with mask\n\tconst unmaskedInput = unmaskInput(inputText, maskToken)\n\tif (unmaskedInput) {\n\t\tconst replacement = fillMask(unmaskedInput, mask, maskToken)\n\n\t\t// TODO: (state) this is very opinionated;\n\t\t// most likely fixed with state management;\n\t\t// a better way could be to emit back to instance;\n\n\t\t// Vue directive reads/writes arbitrary fields on host component instance.\n\t\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion\n\t\tconst instance = binding.instance as Record<string, unknown> | null | undefined\n\t\tif (instance?.['maskFilled']) {\n\t\t\tinstance['maskFilled'] = !replacement.includes(maskToken)\n\t\t}\n\n\t\tel.value = replacement\n\t} else {\n\t\tel.value = mask\n\t}\n}\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ inputText ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"inputText\"\n\t\t\t\tv-mask=\"mask\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:maxlength=\"mask ? (maskFilled ? mask.length : undefined) : undefined\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }} </label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { /* inject, */ computed, ref } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { useStringMask as vMask } from '../../directives/mask'\nimport { ComponentProps } from '../../types'\n\nconst { label, mask, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\n// TODO: setup maskFilled as a computed property\nconst maskFilled = ref(true)\n\n// TODO: (state) replace with state management\n// const locale = inject<string>('locale', '')\n\nconst inputText = defineModel<number | string>()\n</script>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value\">{{ inputText ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<input\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"inputText\"\n\t\t\t\tv-mask=\"mask\"\n\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:maxlength=\"mask ? (maskFilled ? mask.length : undefined) : undefined\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\" />\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }} </label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { /* inject, */ computed, ref } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { useStringMask as vMask } from '../../directives/mask'\nimport { ComponentProps } from '../../types'\n\nconst { label, mask, required, mode, uuid, errors, validation = { errorMessage: '' } } = defineProps<ComponentProps>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\n// TODO: setup maskFilled as a computed property\nconst maskFilled = ref(true)\n\n// TODO: (state) replace with state management\n// const locale = inject<string>('locale', '')\n\nconst inputText = defineModel<number | string>()\n</script>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value aform_textbox-display\">{{ inputText ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<textarea\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"inputText\"\n\t\t\t\tclass=\"aform_input-field aform_textbox\"\n\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t:rows=\"rows\"\n\t\t\t\t:maxlength=\"maxlength\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"></textarea>\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tplaceholder = '',\n\trows = 4,\n\tmaxlength,\n\tvalidation = { errorMessage: '' },\n} = defineProps<\n\tComponentProps & {\n\t\t/** Placeholder shown when the field is empty */\n\t\tplaceholder?: string\n\t\t/** Visible number of text lines (maps to the textarea `rows` attribute) */\n\t\trows?: number\n\t\t/** Maximum number of characters the field will accept */\n\t\tmaxlength?: number\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst inputText = defineModel<string | null>()\n</script>\n\n<style scoped>\n.aform_textbox {\n\tresize: vertical;\n\tline-height: 1.5;\n\tmin-height: 4rem;\n\tfont-family: inherit;\n}\n\n.aform_textbox-display {\n\twhite-space: pre-wrap;\n}\n</style>\n","<template>\n\t<div class=\"aform_form-element\">\n\t\t<template v-if=\"mode === 'display'\">\n\t\t\t<span class=\"aform_display-value aform_textbox-display\">{{ inputText ?? '' }}</span>\n\t\t\t<label class=\"aform_field-label\">{{ label }}</label>\n\t\t</template>\n\t\t<template v-else>\n\t\t\t<textarea\n\t\t\t\t:id=\"uuid\"\n\t\t\t\tv-model=\"inputText\"\n\t\t\t\tclass=\"aform_input-field aform_textbox\"\n\t\t\t\t:placeholder=\"placeholder\"\n\t\t\t\t:rows=\"rows\"\n\t\t\t\t:maxlength=\"maxlength\"\n\t\t\t\t:disabled=\"mode === 'read'\"\n\t\t\t\t:required=\"required\"\n\t\t\t\t:aria-invalid=\"invalid\"\n\t\t\t\t:aria-describedby=\"describedBy\"></textarea>\n\t\t\t<label class=\"aform_field-label\" :for=\"uuid\">{{ label }}</label>\n\t\t\t<p v-show=\"errorText\" :id=\"errorId\" class=\"aform_error\" role=\"alert\">{{ errorText }}</p>\n\t\t</template>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { fieldErrorA11y } from '../../composables/fieldErrorA11y'\nimport { ComponentProps } from '../../types'\n\nconst {\n\tlabel,\n\trequired,\n\tmode,\n\tuuid,\n\terrors,\n\tplaceholder = '',\n\trows = 4,\n\tmaxlength,\n\tvalidation = { errorMessage: '' },\n} = defineProps<\n\tComponentProps & {\n\t\t/** Placeholder shown when the field is empty */\n\t\tplaceholder?: string\n\t\t/** Visible number of text lines (maps to the textarea `rows` attribute) */\n\t\trows?: number\n\t\t/** Maximum number of characters the field will accept */\n\t\tmaxlength?: number\n\t}\n>()\n\n// Dynamic trigger errors take precedence over a static schema errorMessage; empty means the slot hides.\nconst errorText = computed(() => (errors?.length ? errors.join('; ') : (validation.errorMessage ?? '')))\nconst { errorId, describedBy, invalid } = fieldErrorA11y(uuid, errorText)\n\nconst inputText = defineModel<string | null>()\n</script>\n\n<style scoped>\n.aform_textbox {\n\tresize: vertical;\n\tline-height: 1.5;\n\tmin-height: 4rem;\n\tfont-family: inherit;\n}\n\n.aform_textbox-display {\n\twhite-space: pre-wrap;\n}\n</style>\n","<template>\n\t<div class=\"login-container\">\n\t\t<div>\n\t\t\t<div class=\"account-container\">\n\t\t\t\t<div class=\"account-header\">\n\t\t\t\t\t<h1 id=\"account-title\">{{ headerTitle }}</h1>\n\t\t\t\t\t<p id=\"account-subtitle\">{{ headerSubtitle }}</p>\n\t\t\t\t</div>\n\n\t\t\t\t<form @submit=\"onSubmit\">\n\t\t\t\t\t<div class=\"login-form-container\">\n\t\t\t\t\t\t<div class=\"login-form-email aform_form-element\">\n\t\t\t\t\t\t\t<label id=\"login-email\" for=\"email\" class=\"aform_field-label\">Email</label>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"email\"\n\t\t\t\t\t\t\t\tv-model=\"email\"\n\t\t\t\t\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t\t\t\t\tname=\"email\"\n\t\t\t\t\t\t\t\tplaceholder=\"name@example.com\"\n\t\t\t\t\t\t\t\ttype=\"email\"\n\t\t\t\t\t\t\t\tautocomplete=\"email\"\n\t\t\t\t\t\t\t\tautocapitalize=\"none\"\n\t\t\t\t\t\t\t\tautocorrect=\"off\"\n\t\t\t\t\t\t\t\t:disabled=\"isLoading\" />\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div class=\"login-form-password aform_form-element\">\n\t\t\t\t\t\t\t<label id=\"login-password\" for=\"password\" class=\"aform_field-label\">Password</label>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"password\"\n\t\t\t\t\t\t\t\tv-model=\"password\"\n\t\t\t\t\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t\t\t\t\tname=\"password\"\n\t\t\t\t\t\t\t\ttype=\"password\"\n\t\t\t\t\t\t\t\tautocomplete=\"current-password\"\n\t\t\t\t\t\t\t\t:disabled=\"isLoading\" />\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<button type=\"submit\" class=\"btn\" :disabled=\"isLoading || !email || !password\">\n\t\t\t\t\t\t\t<span v-if=\"isLoading\" class=\"material-symbols-outlined loading-icon\">progress_activity</span>\n\t\t\t\t\t\t\t<span id=\"login-form-button\">Login</span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\n\t\t\t\t<button type=\"button\" class=\"btn\">\n\t\t\t\t\t<span id=\"forgot-password-button\">Forgot password?</span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nconst { headerTitle = 'Login', headerSubtitle = 'Enter your email and password to login' } = defineProps<{\n\theaderTitle?: string\n\theaderSubtitle?: string\n}>()\n\nconst emit = defineEmits(['loginFailed', 'loginSuccess'])\n\nconst email = ref('')\nconst password = ref('')\n\nconst isLoading = ref(false)\nconst loginFailed = ref(false)\n\nfunction onSubmit(event: Event) {\n\tevent.preventDefault()\n\tisLoading.value = true\n\n\t// TODO: handle submit logic, handle failure\n\n\tif (loginFailed.value) {\n\t\tisLoading.value = false\n\t\temit('loginFailed')\n\t\treturn\n\t}\n\n\tisLoading.value = false\n\temit('loginSuccess')\n}\n</script>\n\n<style scoped>\n.login-container {\n\twidth: 100%;\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\tfont-family: var(--sc-font-family);\n\tbackground: var(--sc-form-background);\n}\n\n.account-container {\n\twidth: 100%;\n\tmargin-left: auto;\n\tmargin-top: 0.5rem;\n\tmargin-right: auto;\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n}\n\n.account-header {\n\tdisplay: flex;\n\tflex-direction: column;\n\ttext-align: center;\n\tmargin-top: 0.5rem;\n}\n\n#account-title {\n\tfont-size: 1.5rem;\n\tline-height: 2rem;\n\tfont-weight: 600;\n\tletter-spacing: -0.025em;\n\tmargin: 0;\n}\n\n#account-subtitle {\n\tfont-size: 0.875rem;\n\tline-height: 1.25rem;\n\tmargin: 1rem;\n}\n\n.login-form-container {\n\tdisplay: grid;\n\tgap: 0.5rem;\n}\n\n.login-form-element {\n\tdisplay: grid;\n\tmargin: 0.5rem 0;\n\tposition: relative;\n}\n.btn {\n\tbackground-color: var(--sc-btn-color);\n\tcolor: var(--sc-btn-label-color);\n\tborder: 1px solid var(--sc-btn-border);\n\tmargin: 0.5rem 0;\n\tpadding: 0.25rem;\n\tposition: relative;\n\tcursor: pointer;\n\n\t&:hover {\n\t\tbackground-color: var(--sc-btn-hover);\n\t}\n\n\t&:disabled {\n\t\tbackground-color: var(--sc-input-field-disabled-background);\n\t}\n}\n.disabled {\n\topacity: 0.5;\n}\n.loading-icon {\n\tanimation: spin 1s linear infinite forwards;\n\tdisplay: inline-block;\n\tmargin-right: 0.2rem;\n\tline-height: 0;\n\tfont-size: 1rem;\n\tposition: relative;\n\ttop: 0.2rem;\n}\n\n/* ANIMATION */\n@keyframes spin {\n\tfrom {\n\t\ttransform: rotate(0deg);\n\t}\n\n\tto {\n\t\ttransform: rotate(360deg);\n\t}\n}\n</style>\n","<template>\n\t<div class=\"login-container\">\n\t\t<div>\n\t\t\t<div class=\"account-container\">\n\t\t\t\t<div class=\"account-header\">\n\t\t\t\t\t<h1 id=\"account-title\">{{ headerTitle }}</h1>\n\t\t\t\t\t<p id=\"account-subtitle\">{{ headerSubtitle }}</p>\n\t\t\t\t</div>\n\n\t\t\t\t<form @submit=\"onSubmit\">\n\t\t\t\t\t<div class=\"login-form-container\">\n\t\t\t\t\t\t<div class=\"login-form-email aform_form-element\">\n\t\t\t\t\t\t\t<label id=\"login-email\" for=\"email\" class=\"aform_field-label\">Email</label>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"email\"\n\t\t\t\t\t\t\t\tv-model=\"email\"\n\t\t\t\t\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t\t\t\t\tname=\"email\"\n\t\t\t\t\t\t\t\tplaceholder=\"name@example.com\"\n\t\t\t\t\t\t\t\ttype=\"email\"\n\t\t\t\t\t\t\t\tautocomplete=\"email\"\n\t\t\t\t\t\t\t\tautocapitalize=\"none\"\n\t\t\t\t\t\t\t\tautocorrect=\"off\"\n\t\t\t\t\t\t\t\t:disabled=\"isLoading\" />\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div class=\"login-form-password aform_form-element\">\n\t\t\t\t\t\t\t<label id=\"login-password\" for=\"password\" class=\"aform_field-label\">Password</label>\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\tid=\"password\"\n\t\t\t\t\t\t\t\tv-model=\"password\"\n\t\t\t\t\t\t\t\tclass=\"aform_input-field\"\n\t\t\t\t\t\t\t\tname=\"password\"\n\t\t\t\t\t\t\t\ttype=\"password\"\n\t\t\t\t\t\t\t\tautocomplete=\"current-password\"\n\t\t\t\t\t\t\t\t:disabled=\"isLoading\" />\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<button type=\"submit\" class=\"btn\" :disabled=\"isLoading || !email || !password\">\n\t\t\t\t\t\t\t<span v-if=\"isLoading\" class=\"material-symbols-outlined loading-icon\">progress_activity</span>\n\t\t\t\t\t\t\t<span id=\"login-form-button\">Login</span>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\n\t\t\t\t<button type=\"button\" class=\"btn\">\n\t\t\t\t\t<span id=\"forgot-password-button\">Forgot password?</span>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nconst { headerTitle = 'Login', headerSubtitle = 'Enter your email and password to login' } = defineProps<{\n\theaderTitle?: string\n\theaderSubtitle?: string\n}>()\n\nconst emit = defineEmits(['loginFailed', 'loginSuccess'])\n\nconst email = ref('')\nconst password = ref('')\n\nconst isLoading = ref(false)\nconst loginFailed = ref(false)\n\nfunction onSubmit(event: Event) {\n\tevent.preventDefault()\n\tisLoading.value = true\n\n\t// TODO: handle submit logic, handle failure\n\n\tif (loginFailed.value) {\n\t\tisLoading.value = false\n\t\temit('loginFailed')\n\t\treturn\n\t}\n\n\tisLoading.value = false\n\temit('loginSuccess')\n}\n</script>\n\n<style scoped>\n.login-container {\n\twidth: 100%;\n\tposition: relative;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tjustify-content: center;\n\tfont-family: var(--sc-font-family);\n\tbackground: var(--sc-form-background);\n}\n\n.account-container {\n\twidth: 100%;\n\tmargin-left: auto;\n\tmargin-top: 0.5rem;\n\tmargin-right: auto;\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n}\n\n.account-header {\n\tdisplay: flex;\n\tflex-direction: column;\n\ttext-align: center;\n\tmargin-top: 0.5rem;\n}\n\n#account-title {\n\tfont-size: 1.5rem;\n\tline-height: 2rem;\n\tfont-weight: 600;\n\tletter-spacing: -0.025em;\n\tmargin: 0;\n}\n\n#account-subtitle {\n\tfont-size: 0.875rem;\n\tline-height: 1.25rem;\n\tmargin: 1rem;\n}\n\n.login-form-container {\n\tdisplay: grid;\n\tgap: 0.5rem;\n}\n\n.login-form-element {\n\tdisplay: grid;\n\tmargin: 0.5rem 0;\n\tposition: relative;\n}\n.btn {\n\tbackground-color: var(--sc-btn-color);\n\tcolor: var(--sc-btn-label-color);\n\tborder: 1px solid var(--sc-btn-border);\n\tmargin: 0.5rem 0;\n\tpadding: 0.25rem;\n\tposition: relative;\n\tcursor: pointer;\n\n\t&:hover {\n\t\tbackground-color: var(--sc-btn-hover);\n\t}\n\n\t&:disabled {\n\t\tbackground-color: var(--sc-input-field-disabled-background);\n\t}\n}\n.disabled {\n\topacity: 0.5;\n}\n.loading-icon {\n\tanimation: spin 1s linear infinite forwards;\n\tdisplay: inline-block;\n\tmargin-right: 0.2rem;\n\tline-height: 0;\n\tfont-size: 1rem;\n\tposition: relative;\n\ttop: 0.2rem;\n}\n\n/* ANIMATION */\n@keyframes spin {\n\tfrom {\n\t\ttransform: rotate(0deg);\n\t}\n\n\tto {\n\t\ttransform: rotate(360deg);\n\t}\n}\n</style>\n","<template>\n\t<div class=\"aform-loading\">\n\t\t<div class=\"aform-loading__label\">\n\t\t\t<slot></slot>\n\t\t</div>\n\t\t<div class=\"aform-loading__bar\"></div>\n\t</div>\n</template>\n\n<style scoped>\n.aform-loading {\n\twidth: 100%;\n\tborder: 1px solid var(--sc-form-border);\n\tborder-left: 4px solid var(--sc-form-border);\n\tpadding: 1rem;\n\tmargin-bottom: 1rem;\n\tbox-sizing: border-box;\n\tposition: relative;\n\toverflow: hidden;\n\tbackground: var(--sc-input-field-background);\n}\n\n.aform-loading__label {\n\tfont-size: 0.9rem;\n\tcolor: var(--sc-cell-text-color);\n\tz-index: 1;\n\tposition: relative;\n}\n\n.aform-loading__label:not(:empty)::after {\n\tcontent: '...';\n\tanimation: ellipsis 2s infinite;\n}\n\n.aform-loading__bar {\n\twidth: 100%;\n\theight: 100%;\n\tposition: absolute;\n\tleft: -100%;\n\ttop: 0;\n\tbackground: linear-gradient(\n\t\t90deg,\n\t\trgba(var(--sc-table-loading-color), 0) 0%,\n\t\trgba(var(--sc-table-loading-color), 1) 50%,\n\t\trgba(var(--sc-table-loading-color), 0) 100%\n\t);\n\tanimation: bar-sweep 2s infinite;\n\tz-index: 0;\n}\n\n@keyframes bar-sweep {\n\t0% {\n\t\tleft: -100%;\n\t}\n\t100% {\n\t\tleft: 100%;\n\t}\n}\n\n@keyframes ellipsis {\n\t0%,\n\t20% {\n\t\tcontent: '';\n\t}\n\t40% {\n\t\tcontent: '.';\n\t}\n\t60% {\n\t\tcontent: '..';\n\t}\n\t80%,\n\t100% {\n\t\tcontent: '...';\n\t}\n}\n</style>\n","<template>\n\t<button\n\t\ttype=\"button\"\n\t\tclass=\"expansion-index\"\n\t\t:aria-expanded=\"expanded\"\n\t\t:aria-label=\"expanded ? 'Collapse' : 'Expand'\">\n\t\t{{ expanded ? '▼' : '►' }}\n\t</button>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{\n\texpanded: boolean\n}>()\n</script>\n\n<style scoped>\n.expansion-index {\n\tcolor: var(--sc-header-text-color);\n\tfont-weight: bold;\n\tfont-size: 11px;\n\tline-height: 1;\n\ttext-align: center;\n\tuser-select: none;\n\twidth: 2ch;\n\tmin-width: 1.25rem;\n\theight: 1.25rem;\n\tpadding: 0;\n\tborder: none;\n\tbackground: transparent;\n\tcursor: pointer;\n\tbox-sizing: border-box;\n}\n</style>\n","<template>\n\t<button\n\t\ttype=\"button\"\n\t\tclass=\"expansion-index\"\n\t\t:aria-expanded=\"expanded\"\n\t\t:aria-label=\"expanded ? 'Collapse' : 'Expand'\">\n\t\t{{ expanded ? '▼' : '►' }}\n\t</button>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{\n\texpanded: boolean\n}>()\n</script>\n\n<style scoped>\n.expansion-index {\n\tcolor: var(--sc-header-text-color);\n\tfont-weight: bold;\n\tfont-size: 11px;\n\tline-height: 1;\n\ttext-align: center;\n\tuser-select: none;\n\twidth: 2ch;\n\tmin-width: 1.25rem;\n\theight: 1.25rem;\n\tpadding: 0;\n\tborder: none;\n\tbackground: transparent;\n\tcursor: pointer;\n\tbox-sizing: border-box;\n}\n</style>\n","import { nextTick, onMounted, ref, watch, type Ref } from 'vue'\n\ntype TableModalDropdownListOptions = {\n\tpanelRef: Readonly<Ref<HTMLElement | null>>\n\tisOpen: () => boolean\n\toptionCount: () => number\n\tselectAt: (index: number) => void\n\tonClose: () => void\n}\n\n/** Keyboard nav + focus for {@link ADropdownList} hosted in {@link ATableModal}. */\nexport function useTableModalDropdownList(options: TableModalDropdownListOptions) {\n\tconst activeIndex = ref<number | null>(null)\n\n\tconst focusPanel = () => {\n\t\tvoid nextTick(() => options.panelRef.value?.focus())\n\t}\n\n\twatch(\n\t\t() => options.isOpen(),\n\t\topen => {\n\t\t\tif (open) {\n\t\t\t\tactiveIndex.value = null\n\t\t\t\tfocusPanel()\n\t\t\t}\n\t\t}\n\t)\n\n\tonMounted(() => {\n\t\tif (options.isOpen()) focusPanel()\n\t})\n\n\tconst onKeydown = (event: KeyboardEvent) => {\n\t\t// Before the check for options: a picker with nothing to pick, or still loading, closes on Escape too.\n\t\tif (event.key === 'Escape') {\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\toptions.onClose()\n\t\t\treturn\n\t\t}\n\n\t\tconst count = options.optionCount()\n\t\tif (!count) return\n\n\t\tif (event.key === 'ArrowDown') {\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\tif (activeIndex.value != null) {\n\t\t\t\tactiveIndex.value = (activeIndex.value + 1) % count\n\t\t\t} else {\n\t\t\t\tactiveIndex.value = 0\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (event.key === 'ArrowUp') {\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\tif (activeIndex.value != null) {\n\t\t\t\tactiveIndex.value = activeIndex.value === 0 ? Math.max(count - 1, 0) : activeIndex.value - 1\n\t\t\t} else {\n\t\t\t\tactiveIndex.value = Math.max(count - 1, 0)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (event.key === 'Enter') {\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\tconst index = activeIndex.value ?? 0\n\t\t\tif (index >= 0 && index < count) options.selectAt(index)\n\t\t\treturn\n\t\t}\n\t}\n\n\tconst onClickOutside = () => {\n\t\toptions.onClose()\n\t}\n\n\t// Focus moving out of the picker, by Tab or to whatever was clicked, closes it.\n\tconst onFocusOut = (event: FocusEvent) => {\n\t\tif (event.relatedTarget instanceof Node && options.panelRef.value?.contains(event.relatedTarget)) return\n\t\toptions.onClose()\n\t}\n\n\treturn { activeIndex, onKeydown, onClickOutside, onFocusOut, focusPanel }\n}\n","<template>\n\t<div\n\t\tv-if=\"open\"\n\t\tref=\"panelRef\"\n\t\tclass=\"atable-tuple-picker-modal\"\n\t\ttabindex=\"-1\"\n\t\tv-on-click-outside=\"onClickOutside\"\n\t\t@keydown=\"onKeydown\"\n\t\t@focusout=\"onFocusOut\">\n\t\t<ADropdownList\n\t\t\t:listbox-id=\"listboxId\"\n\t\t\tariaLabel=\"Currency\"\n\t\t\t:open=\"true\"\n\t\t\tsurface=\"cell-modal\"\n\t\t\t:option-count=\"optionCount\"\n\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t<li v-if=\"loading\" class=\"loading autocomplete-result\">Loading…</li>\n\t\t\t<li\n\t\t\t\tv-for=\"(option, i) in currencyOptions\"\n\t\t\t\tv-else-if=\"!loading\"\n\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"isSelected(option)\"\n\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': isSelected(option) }\"\n\t\t\t\t@mousedown.prevent=\"selectCurrency(option)\">\n\t\t\t\t{{ option.symbol ? `${option.symbol} — ` : '' }}{{ option.displayText ?? option.id }}\n\t\t\t</li>\n\t\t</ADropdownList>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { TABLE_TUPLE_CURRENCY_PICKER, type TableStore } from '@stonecrop/atable'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport type { AFormLinkValue, CurrencyOptions, CurrencyValue } from '../../types'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { normalizeBaseCurrency, patchCurrencyCurrency, staticCurrencyChoices } from '../../utils/currencyValue'\nimport { useTableModalDropdownList } from '../../composables/useTableModalDropdownList'\nimport ADropdownList from '../form/ADropdownList.vue'\n\nconst { store } = defineProps<{\n\tstore: TableStore\n}>()\n\nconst panelRef = useTemplateRef('panelRef')\nconst loading = ref(false)\nconst currencyOptions = ref<AFormLinkValue[]>([])\n\nconst open = computed(() => !!store.modal.visible && store.modal.component === TABLE_TUPLE_CURRENCY_PICKER)\nconst colIndex = computed(() => store.modal.colIndex ?? 0)\nconst rowIndex = computed(() => store.modal.rowIndex ?? 0)\nconst column = computed(() => store.columns[colIndex.value])\nconst currencyFieldOptions = computed(() => (column.value?.options ?? {}) as CurrencyOptions)\nconst cellValue = computed(() => store.getCellData(colIndex.value, rowIndex.value) as CurrencyValue | null | undefined)\n\nconst listboxId = computed(() => `atable-tuple-cur-${rowIndex.value}-${colIndex.value}`)\n\nconst isSelected = (option: AFormLinkValue) => String(option.id) === String(cellValue.value?.currency?.id)\n\nconst loadCurrencyOptions = async () => {\n\tconst opts = currencyFieldOptions.value\n\tconst filterFunction = opts.filterFunction\n\tif (filterFunction) {\n\t\tloading.value = true\n\t\ttry {\n\t\t\tconst fn =\n\t\t\t\ttypeof filterFunction === 'string'\n\t\t\t\t\t? deserializeFunction<(search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>>(filterFunction)\n\t\t\t\t\t: filterFunction\n\t\t\tcurrencyOptions.value = (await fn('')) ?? []\n\t\t} catch {\n\t\t\tcurrencyOptions.value = []\n\t\t} finally {\n\t\t\tloading.value = false\n\t\t}\n\t\treturn\n\t}\n\tcurrencyOptions.value = staticCurrencyChoices(opts, cellValue.value)\n}\n\nwatch(open, visible => {\n\tif (visible) void loadCurrencyOptions()\n})\n\nonMounted(() => {\n\tif (open.value) void loadCurrencyOptions()\n})\n\nconst optionCount = () => (loading.value ? 0 : currencyOptions.value.length)\n\nconst closePicker = () => store.closeTuplePicker()\n\nconst selectCurrency = (option: AFormLinkValue) => {\n\tconst opts = currencyFieldOptions.value\n\tconst base = normalizeBaseCurrency(opts, cellValue.value)\n\tstore.setCellData(colIndex.value, rowIndex.value, patchCurrencyCurrency(cellValue.value, option, opts, base))\n\tclosePicker()\n}\n\nconst { activeIndex, onKeydown, onClickOutside, onFocusOut } = useTableModalDropdownList({\n\tpanelRef,\n\tisOpen: () => open.value,\n\toptionCount,\n\tselectAt: index => {\n\t\tconst option = currencyOptions.value[index]\n\t\tif (option !== undefined) selectCurrency(option)\n\t},\n\tonClose: closePicker,\n})\n</script>\n\n<style scoped>\n.atable-tuple-picker-modal {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 100%;\n\toutline: none;\n}\n</style>\n","<template>\n\t<div\n\t\tv-if=\"open\"\n\t\tref=\"panelRef\"\n\t\tclass=\"atable-tuple-picker-modal\"\n\t\ttabindex=\"-1\"\n\t\tv-on-click-outside=\"onClickOutside\"\n\t\t@keydown=\"onKeydown\"\n\t\t@focusout=\"onFocusOut\">\n\t\t<ADropdownList\n\t\t\t:listbox-id=\"listboxId\"\n\t\t\tariaLabel=\"Currency\"\n\t\t\t:open=\"true\"\n\t\t\tsurface=\"cell-modal\"\n\t\t\t:option-count=\"optionCount\"\n\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t<li v-if=\"loading\" class=\"loading autocomplete-result\">Loading…</li>\n\t\t\t<li\n\t\t\t\tv-for=\"(option, i) in currencyOptions\"\n\t\t\t\tv-else-if=\"!loading\"\n\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t:key=\"String(option.id)\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"isSelected(option)\"\n\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': isSelected(option) }\"\n\t\t\t\t@mousedown.prevent=\"selectCurrency(option)\">\n\t\t\t\t{{ option.symbol ? `${option.symbol} — ` : '' }}{{ option.displayText ?? option.id }}\n\t\t\t</li>\n\t\t</ADropdownList>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { TABLE_TUPLE_CURRENCY_PICKER, type TableStore } from '@stonecrop/atable'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport type { AFormLinkValue, CurrencyOptions, CurrencyValue } from '../../types'\nimport { deserializeFunction } from '../../utils/deserialize'\nimport { normalizeBaseCurrency, patchCurrencyCurrency, staticCurrencyChoices } from '../../utils/currencyValue'\nimport { useTableModalDropdownList } from '../../composables/useTableModalDropdownList'\nimport ADropdownList from '../form/ADropdownList.vue'\n\nconst { store } = defineProps<{\n\tstore: TableStore\n}>()\n\nconst panelRef = useTemplateRef('panelRef')\nconst loading = ref(false)\nconst currencyOptions = ref<AFormLinkValue[]>([])\n\nconst open = computed(() => !!store.modal.visible && store.modal.component === TABLE_TUPLE_CURRENCY_PICKER)\nconst colIndex = computed(() => store.modal.colIndex ?? 0)\nconst rowIndex = computed(() => store.modal.rowIndex ?? 0)\nconst column = computed(() => store.columns[colIndex.value])\nconst currencyFieldOptions = computed(() => (column.value?.options ?? {}) as CurrencyOptions)\nconst cellValue = computed(() => store.getCellData(colIndex.value, rowIndex.value) as CurrencyValue | null | undefined)\n\nconst listboxId = computed(() => `atable-tuple-cur-${rowIndex.value}-${colIndex.value}`)\n\nconst isSelected = (option: AFormLinkValue) => String(option.id) === String(cellValue.value?.currency?.id)\n\nconst loadCurrencyOptions = async () => {\n\tconst opts = currencyFieldOptions.value\n\tconst filterFunction = opts.filterFunction\n\tif (filterFunction) {\n\t\tloading.value = true\n\t\ttry {\n\t\t\tconst fn =\n\t\t\t\ttypeof filterFunction === 'string'\n\t\t\t\t\t? deserializeFunction<(search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>>(filterFunction)\n\t\t\t\t\t: filterFunction\n\t\t\tcurrencyOptions.value = (await fn('')) ?? []\n\t\t} catch {\n\t\t\tcurrencyOptions.value = []\n\t\t} finally {\n\t\t\tloading.value = false\n\t\t}\n\t\treturn\n\t}\n\tcurrencyOptions.value = staticCurrencyChoices(opts, cellValue.value)\n}\n\nwatch(open, visible => {\n\tif (visible) void loadCurrencyOptions()\n})\n\nonMounted(() => {\n\tif (open.value) void loadCurrencyOptions()\n})\n\nconst optionCount = () => (loading.value ? 0 : currencyOptions.value.length)\n\nconst closePicker = () => store.closeTuplePicker()\n\nconst selectCurrency = (option: AFormLinkValue) => {\n\tconst opts = currencyFieldOptions.value\n\tconst base = normalizeBaseCurrency(opts, cellValue.value)\n\tstore.setCellData(colIndex.value, rowIndex.value, patchCurrencyCurrency(cellValue.value, option, opts, base))\n\tclosePicker()\n}\n\nconst { activeIndex, onKeydown, onClickOutside, onFocusOut } = useTableModalDropdownList({\n\tpanelRef,\n\tisOpen: () => open.value,\n\toptionCount,\n\tselectAt: index => {\n\t\tconst option = currencyOptions.value[index]\n\t\tif (option !== undefined) selectCurrency(option)\n\t},\n\tonClose: closePicker,\n})\n</script>\n\n<style scoped>\n.atable-tuple-picker-modal {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 100%;\n\toutline: none;\n}\n</style>\n","<template>\n\t<div\n\t\tv-if=\"open\"\n\t\tref=\"panelRef\"\n\t\tclass=\"atable-tuple-picker-modal\"\n\t\ttabindex=\"-1\"\n\t\tv-on-click-outside=\"onClickOutside\"\n\t\t@keydown=\"onKeydown\"\n\t\t@focusout=\"onFocusOut\">\n\t\t<ADropdownList\n\t\t\t:listbox-id=\"listboxId\"\n\t\t\tariaLabel=\"Unit of measure\"\n\t\t\t:open=\"true\"\n\t\t\tsurface=\"cell-modal\"\n\t\t\t:option-count=\"optionCount\"\n\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t<li\n\t\t\t\tv-for=\"(uom, i) in uomOptions\"\n\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t:key=\"uom\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"uom === selectedUom\"\n\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': uom === selectedUom }\"\n\t\t\t\t@mousedown.prevent=\"selectUom(uom)\">\n\t\t\t\t{{ uom }}\n\t\t\t</li>\n\t\t</ADropdownList>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { TABLE_TUPLE_QUANTITY_PICKER, type TableStore } from '@stonecrop/atable'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, useTemplateRef } from 'vue'\n\nimport type { QuantityOptions, QuantityValue } from '../../types'\nimport { patchQuantityUom } from '../../utils/quantityValue'\nimport { useTableModalDropdownList } from '../../composables/useTableModalDropdownList'\nimport ADropdownList from '../form/ADropdownList.vue'\n\nconst { store } = defineProps<{\n\tstore: TableStore\n}>()\n\nconst panelRef = useTemplateRef('panelRef')\n\nconst open = computed(() => !!store.modal.visible && store.modal.component === TABLE_TUPLE_QUANTITY_PICKER)\nconst colIndex = computed(() => store.modal.colIndex ?? 0)\nconst rowIndex = computed(() => store.modal.rowIndex ?? 0)\nconst column = computed(() => store.columns[colIndex.value])\n\nconst uomOptions = computed(() => (column.value?.options as QuantityOptions | undefined)?.uoms ?? [])\nconst cellValue = computed(() => store.getCellData(colIndex.value, rowIndex.value) as QuantityValue | null | undefined)\nconst selectedUom = computed(() => cellValue.value?.uom ?? '')\n\nconst listboxId = computed(() => `atable-tuple-qty-${rowIndex.value}-${colIndex.value}`)\n\nconst optionCount = () => uomOptions.value.length\n\nconst closePicker = () => store.closeTuplePicker()\n\nconst selectUom = (uom: string) => {\n\tconst options = (column.value?.options ?? {}) as QuantityOptions\n\tstore.setCellData(colIndex.value, rowIndex.value, patchQuantityUom(cellValue.value, uom, options))\n\tclosePicker()\n}\n\nconst { activeIndex, onKeydown, onClickOutside, onFocusOut } = useTableModalDropdownList({\n\tpanelRef,\n\tisOpen: () => open.value,\n\toptionCount,\n\tselectAt: index => {\n\t\tconst uom = uomOptions.value[index]\n\t\tif (uom !== undefined) selectUom(uom)\n\t},\n\tonClose: closePicker,\n})\n</script>\n\n<style scoped>\n.atable-tuple-picker-modal {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 100%;\n\toutline: none;\n}\n</style>\n","<template>\n\t<div\n\t\tv-if=\"open\"\n\t\tref=\"panelRef\"\n\t\tclass=\"atable-tuple-picker-modal\"\n\t\ttabindex=\"-1\"\n\t\tv-on-click-outside=\"onClickOutside\"\n\t\t@keydown=\"onKeydown\"\n\t\t@focusout=\"onFocusOut\">\n\t\t<ADropdownList\n\t\t\t:listbox-id=\"listboxId\"\n\t\t\tariaLabel=\"Unit of measure\"\n\t\t\t:open=\"true\"\n\t\t\tsurface=\"cell-modal\"\n\t\t\t:option-count=\"optionCount\"\n\t\t\t:active-index=\"() => activeIndex\">\n\t\t\t<li\n\t\t\t\tv-for=\"(uom, i) in uomOptions\"\n\t\t\t\t:id=\"`${listboxId}-opt-${i}`\"\n\t\t\t\t:key=\"uom\"\n\t\t\t\trole=\"option\"\n\t\t\t\t:aria-selected=\"uom === selectedUom\"\n\t\t\t\tclass=\"autocomplete-result\"\n\t\t\t\t:class=\"{ 'is-active': i === activeIndex, 'is-selected': uom === selectedUom }\"\n\t\t\t\t@mousedown.prevent=\"selectUom(uom)\">\n\t\t\t\t{{ uom }}\n\t\t\t</li>\n\t\t</ADropdownList>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { TABLE_TUPLE_QUANTITY_PICKER, type TableStore } from '@stonecrop/atable'\nimport { vOnClickOutside } from '@vueuse/components'\nimport { computed, useTemplateRef } from 'vue'\n\nimport type { QuantityOptions, QuantityValue } from '../../types'\nimport { patchQuantityUom } from '../../utils/quantityValue'\nimport { useTableModalDropdownList } from '../../composables/useTableModalDropdownList'\nimport ADropdownList from '../form/ADropdownList.vue'\n\nconst { store } = defineProps<{\n\tstore: TableStore\n}>()\n\nconst panelRef = useTemplateRef('panelRef')\n\nconst open = computed(() => !!store.modal.visible && store.modal.component === TABLE_TUPLE_QUANTITY_PICKER)\nconst colIndex = computed(() => store.modal.colIndex ?? 0)\nconst rowIndex = computed(() => store.modal.rowIndex ?? 0)\nconst column = computed(() => store.columns[colIndex.value])\n\nconst uomOptions = computed(() => (column.value?.options as QuantityOptions | undefined)?.uoms ?? [])\nconst cellValue = computed(() => store.getCellData(colIndex.value, rowIndex.value) as QuantityValue | null | undefined)\nconst selectedUom = computed(() => cellValue.value?.uom ?? '')\n\nconst listboxId = computed(() => `atable-tuple-qty-${rowIndex.value}-${colIndex.value}`)\n\nconst optionCount = () => uomOptions.value.length\n\nconst closePicker = () => store.closeTuplePicker()\n\nconst selectUom = (uom: string) => {\n\tconst options = (column.value?.options ?? {}) as QuantityOptions\n\tstore.setCellData(colIndex.value, rowIndex.value, patchQuantityUom(cellValue.value, uom, options))\n\tclosePicker()\n}\n\nconst { activeIndex, onKeydown, onClickOutside, onFocusOut } = useTableModalDropdownList({\n\tpanelRef,\n\tisOpen: () => open.value,\n\toptionCount,\n\tselectAt: index => {\n\t\tconst uom = uomOptions.value[index]\n\t\tif (uom !== undefined) selectUom(uom)\n\t},\n\tonClose: closePicker,\n})\n</script>\n\n<style scoped>\n.atable-tuple-picker-modal {\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 100%;\n\toutline: none;\n}\n</style>\n","<template>\n\t<div class=\"atable-tuple-shell\" :class=\"{ 'atable-tuple-shell--active': active }\">\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclass=\"atable-tuple-shell__handle\"\n\t\t\t:class=\"{ 'atable-tuple-shell__handle--visible': active }\"\n\t\t\ttabindex=\"-1\"\n\t\t\t:aria-label=\"pickerLabel\"\n\t\t\taria-haspopup=\"listbox\"\n\t\t\t:aria-expanded=\"pickerOpen\"\n\t\t\t:aria-hidden=\"!active\"\n\t\t\t@mousedown.prevent\n\t\t\t@click.stop=\"emit('open-picker')\">\n\t\t\t<span class=\"atable-tuple-shell__caret\" aria-hidden=\"true\" />\n\t\t</button>\n\t\t<span v-show=\"!active\" class=\"atable-tuple-shell__display\">{{ displayText }}</span>\n\t\t<slot v-if=\"active\" />\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{\n\tactive: boolean\n\tdisplayText: string\n\tpickerLabel: string\n\tpickerOpen: boolean\n}>()\n\nconst emit = defineEmits<{\n\t'open-picker': []\n}>()\n</script>\n\n<style scoped>\n.atable-tuple-shell {\n\tposition: relative;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\tmin-height: 1.25em;\n\tpadding-left: 0;\n}\n\n.atable-tuple-shell--active {\n\tbox-sizing: border-box;\n\tpadding-left: 1rem;\n}\n\n.atable-tuple-shell__handle {\n\tposition: absolute;\n\tleft: 0;\n\ttop: 0;\n\tbottom: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tbox-sizing: border-box;\n\twidth: 1rem;\n\tmin-width: 1rem;\n\tpadding: 0;\n\tmargin: 0;\n\tborder: none;\n\tbackground: transparent;\n\tcolor: var(--sc-cell-text-color);\n\tcursor: pointer;\n\topacity: 0;\n\tpointer-events: none;\n\ttransition: opacity 0.15s ease;\n\t-webkit-tap-highlight-color: transparent;\n}\n\n.atable-tuple-shell__handle--visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.atable-tuple-shell__caret {\n\tdisplay: inline-block;\n\twidth: 0;\n\theight: 0;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tborder-top: 0.3em solid currentColor;\n}\n\n.atable-tuple-shell__display {\n\tdisplay: block;\n\twidth: 100%;\n\tmin-width: 0;\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n</style>\n","<template>\n\t<div class=\"atable-tuple-shell\" :class=\"{ 'atable-tuple-shell--active': active }\">\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclass=\"atable-tuple-shell__handle\"\n\t\t\t:class=\"{ 'atable-tuple-shell__handle--visible': active }\"\n\t\t\ttabindex=\"-1\"\n\t\t\t:aria-label=\"pickerLabel\"\n\t\t\taria-haspopup=\"listbox\"\n\t\t\t:aria-expanded=\"pickerOpen\"\n\t\t\t:aria-hidden=\"!active\"\n\t\t\t@mousedown.prevent\n\t\t\t@click.stop=\"emit('open-picker')\">\n\t\t\t<span class=\"atable-tuple-shell__caret\" aria-hidden=\"true\" />\n\t\t</button>\n\t\t<span v-show=\"!active\" class=\"atable-tuple-shell__display\">{{ displayText }}</span>\n\t\t<slot v-if=\"active\" />\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\ndefineProps<{\n\tactive: boolean\n\tdisplayText: string\n\tpickerLabel: string\n\tpickerOpen: boolean\n}>()\n\nconst emit = defineEmits<{\n\t'open-picker': []\n}>()\n</script>\n\n<style scoped>\n.atable-tuple-shell {\n\tposition: relative;\n\tbox-sizing: border-box;\n\twidth: 100%;\n\tmin-width: 0;\n\tmin-height: 1.25em;\n\tpadding-left: 0;\n}\n\n.atable-tuple-shell--active {\n\tbox-sizing: border-box;\n\tpadding-left: 1rem;\n}\n\n.atable-tuple-shell__handle {\n\tposition: absolute;\n\tleft: 0;\n\ttop: 0;\n\tbottom: 0;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tbox-sizing: border-box;\n\twidth: 1rem;\n\tmin-width: 1rem;\n\tpadding: 0;\n\tmargin: 0;\n\tborder: none;\n\tbackground: transparent;\n\tcolor: var(--sc-cell-text-color);\n\tcursor: pointer;\n\topacity: 0;\n\tpointer-events: none;\n\ttransition: opacity 0.15s ease;\n\t-webkit-tap-highlight-color: transparent;\n}\n\n.atable-tuple-shell__handle--visible {\n\topacity: 1;\n\tpointer-events: auto;\n}\n\n.atable-tuple-shell__caret {\n\tdisplay: inline-block;\n\twidth: 0;\n\theight: 0;\n\tborder-left: 0.3em solid transparent;\n\tborder-right: 0.3em solid transparent;\n\tborder-top: 0.3em solid currentColor;\n}\n\n.atable-tuple-shell__display {\n\tdisplay: block;\n\twidth: 100%;\n\tmin-width: 0;\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n</style>\n","<template>\n\t<ATupleCellShell\n\t\t:active=\"active\"\n\t\t:display-text=\"displayText\"\n\t\t:picker-label=\"pickerLabel\"\n\t\t:picker-open=\"pickerOpenForCell\"\n\t\t@open-picker=\"openPicker\">\n\t\t<input\n\t\t\tref=\"inputRef\"\n\t\t\t:id=\"inputId\"\n\t\t\tv-model=\"draftText\"\n\t\t\tclass=\"atable-tuple-shell__input\"\n\t\t\ttype=\"text\"\n\t\t\ttabindex=\"-1\"\n\t\t\tinputmode=\"decimal\"\n\t\t\t:aria-label=\"amountLabel\"\n\t\t\t@input=\"onInput\"\n\t\t\t@keydown=\"onKeydown\"\n\t\t\t@paste=\"onPaste\"\n\t\t\t@focus=\"onInputFocus\"\n\t\t\t@blur=\"onInputBlur\" />\n\t</ATupleCellShell>\n</template>\n\n<script setup lang=\"ts\">\nimport {\n\tcurrencyAmountEntryPattern,\n\tcurrencyInputFractionDigits,\n\tformatCurrencyAmountInput,\n\tparseCurrencyAmountInput,\n} from '@stonecrop/utilities'\nimport { isTableTuplePickerModal, type TableStore } from '@stonecrop/atable'\nimport { useElementBounding } from '@vueuse/core'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport type { CurrencyOptions, CurrencyValue, QuantityOptions, QuantityValue } from '../../types'\nimport { normalizeBaseCurrency, patchCurrencyAmount } from '../../utils/currencyValue'\nimport { patchQuantityQty, quantityEntryPattern } from '../../utils/quantityValue'\nimport ATupleCellShell from './ATupleCellShell.vue'\n\nconst { category, colIndex, rowIndex, store, active, displayText, inputId } = defineProps<{\n\tcategory: 'quantity' | 'currency'\n\tcolIndex: number\n\trowIndex: number\n\tstore: TableStore\n\tactive: boolean\n\tdisplayText: string\n\tinputId: string\n}>()\n\nconst emit = defineEmits<{\n\tdeactivate: []\n}>()\n\nconst inputRef = useTemplateRef<HTMLInputElement>('inputRef')\nconst draftText = ref('')\nconst selectOnFocus = ref(true)\n\nconst amountMaskEnabled = computed(\n\t() => category === 'currency' && (options.value as CurrencyOptions).amountMask !== false\n)\n\nconst column = computed(() => store.columns[colIndex])\nconst options = computed(() => column.value?.options ?? {})\nconst cellValue = computed(() => store.getCellData(colIndex, rowIndex))\n\nconst pickerLabel = computed(() => (category === 'currency' ? 'Choose currency' : 'Choose unit'))\nconst amountLabel = computed(() => (category === 'currency' ? 'Amount' : 'Quantity'))\n\nconst selectedCurrencyId = computed(() => String((cellValue.value as CurrencyValue | undefined)?.currency?.id ?? ''))\n\nconst cellElement = computed(() => {\n\tconst el = inputRef.value?.closest('td')\n\treturn el instanceof HTMLTableCellElement ? el : null\n})\nconst { left, bottom, width, height } = useElementBounding(cellElement)\n\nconst pickerOpenForCell = computed(\n\t() => isTableTuplePickerModal(store.modal) && store.modal.colIndex === colIndex && store.modal.rowIndex === rowIndex\n)\n\n// The picker holds focus while open, so the cell can't see focus leave. Once focus has settled after the picker closes:\n// if the page dropped it (a pick, Escape), bring it back to the box; if it went somewhere else, editing this cell is over.\nwatch(pickerOpenForCell, (open, wasOpen) => {\n\tif (!wasOpen || open) return\n\tsetTimeout(() => {\n\t\t// Reopened meanwhile, as a click on the handle does: the list has focus again.\n\t\tif (pickerOpenForCell.value) return\n\t\tconst focused = document.activeElement\n\t\tif (focused && cellElement.value?.contains(focused)) return\n\t\tif (!focused || focused === document.body) inputRef.value?.focus()\n\t\telse emit('deactivate')\n\t})\n})\n\nconst syncDraftFromModel = () => {\n\tconst v = cellValue.value\n\tif (category === 'quantity') {\n\t\tconst q = v as QuantityValue | null | undefined\n\t\tdraftText.value = q?.qty === null || q?.qty === undefined ? '' : String(q.qty)\n\t\treturn\n\t}\n\tconst c = v as CurrencyValue | null | undefined\n\tif (amountMaskEnabled.value) {\n\t\tdraftText.value = formatCurrencyAmountInput(c?.amount ?? null, selectedCurrencyId.value)\n\t\treturn\n\t}\n\tdraftText.value = c?.amount === null || c?.amount === undefined ? '' : String(c.amount)\n}\n\nwatch(\n\tcellValue,\n\t() => {\n\t\t// Not while the box is being typed in: the box holds text on its way to a number (\"1.\", \"-\"), and the number\n\t\t// read back from it would overwrite that text.\n\t\tif (document.activeElement !== inputRef.value) syncDraftFromModel()\n\t},\n\t{ deep: true }\n)\nwatch(\n\t() => active,\n\tisActive => {\n\t\tif (isActive) syncDraftFromModel()\n\t}\n)\n\nconst parseDraftAmount = (): number | null => {\n\tif (category === 'currency' && amountMaskEnabled.value) {\n\t\treturn parseCurrencyAmountInput(draftText.value)\n\t}\n\tconst text = draftText.value.trim()\n\tif (text === '' || text === '-') return null\n\tconst n = Number(text)\n\treturn Number.isFinite(n) ? n : null\n}\n\nconst commitNumber = () => {\n\tconst parsed = parseDraftAmount()\n\tif (category === 'quantity') {\n\t\tstore.setCellData(\n\t\t\tcolIndex,\n\t\t\trowIndex,\n\t\t\tpatchQuantityQty(cellValue.value as QuantityValue | null, parsed, options.value as QuantityOptions)\n\t\t)\n\t\treturn\n\t}\n\tconst base = normalizeBaseCurrency(options.value as CurrencyOptions, cellValue.value as CurrencyValue | null)\n\tstore.setCellData(\n\t\tcolIndex,\n\t\trowIndex,\n\t\tpatchCurrencyAmount(cellValue.value as CurrencyValue | null, parsed, options.value as CurrencyOptions, base)\n\t)\n}\n\nconst onInput = () => {\n\tif (category === 'currency' && amountMaskEnabled.value) {\n\t\tconst parsed = parseCurrencyAmountInput(draftText.value)\n\t\tif (draftText.value.trim() === '' || draftText.value.trim() === '-' || parsed !== null) {\n\t\t\tcommitNumber()\n\t\t}\n\t\treturn\n\t}\n\tcommitNumber()\n}\n\nconst shouldStayActiveAfterBlur = (related: EventTarget | null): boolean => {\n\tif (!(related instanceof Node)) return false\n\tif (document.querySelector('.amodal')?.contains(related)) return true\n\tif (pickerOpenForCell.value) return true\n\tconst cell = inputRef.value?.closest('td')\n\tif (!cell?.contains(related)) return false\n\tif (related instanceof Element && related.closest('.atable-tuple-shell__handle')) return true\n\tif (related === inputRef.value) return true\n\treturn false\n}\n\nconst onInputBlur = (event: FocusEvent) => {\n\tcommitNumber()\n\tif (category === 'currency' && amountMaskEnabled.value) syncDraftFromModel()\n\tif (!shouldStayActiveAfterBlur(event.relatedTarget)) emit('deactivate')\n}\n\nconst openPicker = () => {\n\tconst cell = cellElement.value\n\tif (!cell) return\n\tstore.openTuplePicker(colIndex, rowIndex, cell, {\n\t\tleft: left.value,\n\t\tbottom: bottom.value,\n\t\twidth: width.value,\n\t\theight: height.value,\n\t})\n}\n\nconst onKeydown = (event: KeyboardEvent) => {\n\tif (event.shiftKey && event.key === 'ArrowDown') {\n\t\tevent.preventDefault()\n\t\tevent.stopPropagation()\n\t\topenPicker()\n\t\treturn\n\t}\n\tif (category === 'currency' && amountMaskEnabled.value && !pickerOpenForCell.value) {\n\t\tif (onCurrencyKeydownMasked(event)) return\n\t}\n\tif (category === 'quantity' && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n\t\trefuseUnlessQuantity(event, event.key)\n\t}\n}\n\n// The box's text once `inserted` replaces its selection.\nconst textWith = (input: HTMLInputElement, inserted: string) =>\n\tinput.value.slice(0, input.selectionStart ?? 0) + inserted + input.value.slice(input.selectionEnd ?? 0)\n\n// The same text as the form's quantity field accepts, so a typo leaves the quantity as it was.\nconst refuseUnlessQuantity = (event: Event, inserted: string) => {\n\tif (!quantityEntryPattern.test(textWith(event.target as HTMLInputElement, inserted))) event.preventDefault()\n}\n\n// What the box may hold, as the form's field refuses anything else.\nconst entryPattern = computed(() => {\n\tif (category === 'quantity') return quantityEntryPattern\n\treturn amountMaskEnabled.value ? currencyAmountEntryPattern(selectedCurrencyId.value) : undefined\n})\n\n// A number copied from a spreadsheet cell comes with a line break or tab: what is pasted is the number without them.\nconst onPaste = (event: ClipboardEvent) => {\n\tconst pattern = entryPattern.value\n\tif (!pattern) return\n\tevent.preventDefault()\n\tconst input = event.target as HTMLInputElement\n\tconst pasted = (event.clipboardData?.getData('text') ?? '').trim()\n\tif (!pattern.test(textWith(input, pasted))) return\n\tinput.setRangeText(pasted, input.selectionStart ?? 0, input.selectionEnd ?? 0, 'end')\n\tinput.dispatchEvent(new Event('input', { bubbles: true }))\n}\n\nconst onCurrencyKeydownMasked = (event: KeyboardEvent): boolean => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return false\n\tconst navigation = new Set([\n\t\t'Backspace',\n\t\t'Delete',\n\t\t'Tab',\n\t\t'Escape',\n\t\t'Enter',\n\t\t'ArrowLeft',\n\t\t'ArrowRight',\n\t\t'ArrowUp',\n\t\t'ArrowDown',\n\t\t'Home',\n\t\t'End',\n\t])\n\tif (navigation.has(event.key)) return false\n\tif (/^[0-9]$/.test(event.key)) return false\n\tif (event.key === '-') {\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('-') && input.selectionStart === 0) return false\n\t}\n\tif (event.key === '.' || event.key === ',') {\n\t\tif (currencyInputFractionDigits(selectedCurrencyId.value) === 0) {\n\t\t\tevent.preventDefault()\n\t\t\treturn true\n\t\t}\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('.') && !input.value.includes(',')) return false\n\t}\n\tconst pattern = currencyAmountEntryPattern(selectedCurrencyId.value)\n\tconst input = event.target as HTMLInputElement\n\tconst { selectionStart, selectionEnd, value } = input\n\tif (selectionStart === null || selectionEnd === null) {\n\t\tevent.preventDefault()\n\t\treturn true\n\t}\n\tconst next = value.slice(0, selectionStart) + event.key + value.slice(selectionEnd)\n\tif (event.key.length === 1 && !pattern.test(next)) event.preventDefault()\n\treturn true\n}\n\nconst onInputFocus = () => {\n\tif (selectOnFocus.value) {\n\t\tvoid nextTick(() => {\n\t\t\tinputRef.value?.select()\n\t\t\tselectOnFocus.value = false\n\t\t})\n\t}\n}\n\nconst focusInput = () => {\n\tselectOnFocus.value = true\n\tvoid nextTick(() => inputRef.value?.focus())\n}\n\ndefineExpose({ focusInput, openPicker, commitNumber })\n</script>\n\n<style scoped>\n.atable-tuple-shell__input {\n\tdisplay: block;\n\twidth: 100%;\n\tmin-width: 0;\n\tbox-sizing: border-box;\n\tborder: none;\n\toutline: none;\n\tbox-shadow: none;\n\tbackground: transparent;\n\tfont: inherit;\n\tcolor: inherit;\n\ttext-align: inherit;\n\tpadding: 0;\n\tmargin: 0;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n\n.atable-tuple-shell__input::-webkit-outer-spin-button,\n.atable-tuple-shell__input::-webkit-inner-spin-button {\n\tappearance: none;\n}\n</style>\n","<template>\n\t<ATupleCellShell\n\t\t:active=\"active\"\n\t\t:display-text=\"displayText\"\n\t\t:picker-label=\"pickerLabel\"\n\t\t:picker-open=\"pickerOpenForCell\"\n\t\t@open-picker=\"openPicker\">\n\t\t<input\n\t\t\tref=\"inputRef\"\n\t\t\t:id=\"inputId\"\n\t\t\tv-model=\"draftText\"\n\t\t\tclass=\"atable-tuple-shell__input\"\n\t\t\ttype=\"text\"\n\t\t\ttabindex=\"-1\"\n\t\t\tinputmode=\"decimal\"\n\t\t\t:aria-label=\"amountLabel\"\n\t\t\t@input=\"onInput\"\n\t\t\t@keydown=\"onKeydown\"\n\t\t\t@paste=\"onPaste\"\n\t\t\t@focus=\"onInputFocus\"\n\t\t\t@blur=\"onInputBlur\" />\n\t</ATupleCellShell>\n</template>\n\n<script setup lang=\"ts\">\nimport {\n\tcurrencyAmountEntryPattern,\n\tcurrencyInputFractionDigits,\n\tformatCurrencyAmountInput,\n\tparseCurrencyAmountInput,\n} from '@stonecrop/utilities'\nimport { isTableTuplePickerModal, type TableStore } from '@stonecrop/atable'\nimport { useElementBounding } from '@vueuse/core'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport type { CurrencyOptions, CurrencyValue, QuantityOptions, QuantityValue } from '../../types'\nimport { normalizeBaseCurrency, patchCurrencyAmount } from '../../utils/currencyValue'\nimport { patchQuantityQty, quantityEntryPattern } from '../../utils/quantityValue'\nimport ATupleCellShell from './ATupleCellShell.vue'\n\nconst { category, colIndex, rowIndex, store, active, displayText, inputId } = defineProps<{\n\tcategory: 'quantity' | 'currency'\n\tcolIndex: number\n\trowIndex: number\n\tstore: TableStore\n\tactive: boolean\n\tdisplayText: string\n\tinputId: string\n}>()\n\nconst emit = defineEmits<{\n\tdeactivate: []\n}>()\n\nconst inputRef = useTemplateRef<HTMLInputElement>('inputRef')\nconst draftText = ref('')\nconst selectOnFocus = ref(true)\n\nconst amountMaskEnabled = computed(\n\t() => category === 'currency' && (options.value as CurrencyOptions).amountMask !== false\n)\n\nconst column = computed(() => store.columns[colIndex])\nconst options = computed(() => column.value?.options ?? {})\nconst cellValue = computed(() => store.getCellData(colIndex, rowIndex))\n\nconst pickerLabel = computed(() => (category === 'currency' ? 'Choose currency' : 'Choose unit'))\nconst amountLabel = computed(() => (category === 'currency' ? 'Amount' : 'Quantity'))\n\nconst selectedCurrencyId = computed(() => String((cellValue.value as CurrencyValue | undefined)?.currency?.id ?? ''))\n\nconst cellElement = computed(() => {\n\tconst el = inputRef.value?.closest('td')\n\treturn el instanceof HTMLTableCellElement ? el : null\n})\nconst { left, bottom, width, height } = useElementBounding(cellElement)\n\nconst pickerOpenForCell = computed(\n\t() => isTableTuplePickerModal(store.modal) && store.modal.colIndex === colIndex && store.modal.rowIndex === rowIndex\n)\n\n// The picker holds focus while open, so the cell can't see focus leave. Once focus has settled after the picker closes:\n// if the page dropped it (a pick, Escape), bring it back to the box; if it went somewhere else, editing this cell is over.\nwatch(pickerOpenForCell, (open, wasOpen) => {\n\tif (!wasOpen || open) return\n\tsetTimeout(() => {\n\t\t// Reopened meanwhile, as a click on the handle does: the list has focus again.\n\t\tif (pickerOpenForCell.value) return\n\t\tconst focused = document.activeElement\n\t\tif (focused && cellElement.value?.contains(focused)) return\n\t\tif (!focused || focused === document.body) inputRef.value?.focus()\n\t\telse emit('deactivate')\n\t})\n})\n\nconst syncDraftFromModel = () => {\n\tconst v = cellValue.value\n\tif (category === 'quantity') {\n\t\tconst q = v as QuantityValue | null | undefined\n\t\tdraftText.value = q?.qty === null || q?.qty === undefined ? '' : String(q.qty)\n\t\treturn\n\t}\n\tconst c = v as CurrencyValue | null | undefined\n\tif (amountMaskEnabled.value) {\n\t\tdraftText.value = formatCurrencyAmountInput(c?.amount ?? null, selectedCurrencyId.value)\n\t\treturn\n\t}\n\tdraftText.value = c?.amount === null || c?.amount === undefined ? '' : String(c.amount)\n}\n\nwatch(\n\tcellValue,\n\t() => {\n\t\t// Not while the box is being typed in: the box holds text on its way to a number (\"1.\", \"-\"), and the number\n\t\t// read back from it would overwrite that text.\n\t\tif (document.activeElement !== inputRef.value) syncDraftFromModel()\n\t},\n\t{ deep: true }\n)\nwatch(\n\t() => active,\n\tisActive => {\n\t\tif (isActive) syncDraftFromModel()\n\t}\n)\n\nconst parseDraftAmount = (): number | null => {\n\tif (category === 'currency' && amountMaskEnabled.value) {\n\t\treturn parseCurrencyAmountInput(draftText.value)\n\t}\n\tconst text = draftText.value.trim()\n\tif (text === '' || text === '-') return null\n\tconst n = Number(text)\n\treturn Number.isFinite(n) ? n : null\n}\n\nconst commitNumber = () => {\n\tconst parsed = parseDraftAmount()\n\tif (category === 'quantity') {\n\t\tstore.setCellData(\n\t\t\tcolIndex,\n\t\t\trowIndex,\n\t\t\tpatchQuantityQty(cellValue.value as QuantityValue | null, parsed, options.value as QuantityOptions)\n\t\t)\n\t\treturn\n\t}\n\tconst base = normalizeBaseCurrency(options.value as CurrencyOptions, cellValue.value as CurrencyValue | null)\n\tstore.setCellData(\n\t\tcolIndex,\n\t\trowIndex,\n\t\tpatchCurrencyAmount(cellValue.value as CurrencyValue | null, parsed, options.value as CurrencyOptions, base)\n\t)\n}\n\nconst onInput = () => {\n\tif (category === 'currency' && amountMaskEnabled.value) {\n\t\tconst parsed = parseCurrencyAmountInput(draftText.value)\n\t\tif (draftText.value.trim() === '' || draftText.value.trim() === '-' || parsed !== null) {\n\t\t\tcommitNumber()\n\t\t}\n\t\treturn\n\t}\n\tcommitNumber()\n}\n\nconst shouldStayActiveAfterBlur = (related: EventTarget | null): boolean => {\n\tif (!(related instanceof Node)) return false\n\tif (document.querySelector('.amodal')?.contains(related)) return true\n\tif (pickerOpenForCell.value) return true\n\tconst cell = inputRef.value?.closest('td')\n\tif (!cell?.contains(related)) return false\n\tif (related instanceof Element && related.closest('.atable-tuple-shell__handle')) return true\n\tif (related === inputRef.value) return true\n\treturn false\n}\n\nconst onInputBlur = (event: FocusEvent) => {\n\tcommitNumber()\n\tif (category === 'currency' && amountMaskEnabled.value) syncDraftFromModel()\n\tif (!shouldStayActiveAfterBlur(event.relatedTarget)) emit('deactivate')\n}\n\nconst openPicker = () => {\n\tconst cell = cellElement.value\n\tif (!cell) return\n\tstore.openTuplePicker(colIndex, rowIndex, cell, {\n\t\tleft: left.value,\n\t\tbottom: bottom.value,\n\t\twidth: width.value,\n\t\theight: height.value,\n\t})\n}\n\nconst onKeydown = (event: KeyboardEvent) => {\n\tif (event.shiftKey && event.key === 'ArrowDown') {\n\t\tevent.preventDefault()\n\t\tevent.stopPropagation()\n\t\topenPicker()\n\t\treturn\n\t}\n\tif (category === 'currency' && amountMaskEnabled.value && !pickerOpenForCell.value) {\n\t\tif (onCurrencyKeydownMasked(event)) return\n\t}\n\tif (category === 'quantity' && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n\t\trefuseUnlessQuantity(event, event.key)\n\t}\n}\n\n// The box's text once `inserted` replaces its selection.\nconst textWith = (input: HTMLInputElement, inserted: string) =>\n\tinput.value.slice(0, input.selectionStart ?? 0) + inserted + input.value.slice(input.selectionEnd ?? 0)\n\n// The same text as the form's quantity field accepts, so a typo leaves the quantity as it was.\nconst refuseUnlessQuantity = (event: Event, inserted: string) => {\n\tif (!quantityEntryPattern.test(textWith(event.target as HTMLInputElement, inserted))) event.preventDefault()\n}\n\n// What the box may hold, as the form's field refuses anything else.\nconst entryPattern = computed(() => {\n\tif (category === 'quantity') return quantityEntryPattern\n\treturn amountMaskEnabled.value ? currencyAmountEntryPattern(selectedCurrencyId.value) : undefined\n})\n\n// A number copied from a spreadsheet cell comes with a line break or tab: what is pasted is the number without them.\nconst onPaste = (event: ClipboardEvent) => {\n\tconst pattern = entryPattern.value\n\tif (!pattern) return\n\tevent.preventDefault()\n\tconst input = event.target as HTMLInputElement\n\tconst pasted = (event.clipboardData?.getData('text') ?? '').trim()\n\tif (!pattern.test(textWith(input, pasted))) return\n\tinput.setRangeText(pasted, input.selectionStart ?? 0, input.selectionEnd ?? 0, 'end')\n\tinput.dispatchEvent(new Event('input', { bubbles: true }))\n}\n\nconst onCurrencyKeydownMasked = (event: KeyboardEvent): boolean => {\n\tif (event.ctrlKey || event.metaKey || event.altKey) return false\n\tconst navigation = new Set([\n\t\t'Backspace',\n\t\t'Delete',\n\t\t'Tab',\n\t\t'Escape',\n\t\t'Enter',\n\t\t'ArrowLeft',\n\t\t'ArrowRight',\n\t\t'ArrowUp',\n\t\t'ArrowDown',\n\t\t'Home',\n\t\t'End',\n\t])\n\tif (navigation.has(event.key)) return false\n\tif (/^[0-9]$/.test(event.key)) return false\n\tif (event.key === '-') {\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('-') && input.selectionStart === 0) return false\n\t}\n\tif (event.key === '.' || event.key === ',') {\n\t\tif (currencyInputFractionDigits(selectedCurrencyId.value) === 0) {\n\t\t\tevent.preventDefault()\n\t\t\treturn true\n\t\t}\n\t\tconst input = event.target as HTMLInputElement\n\t\tif (!input.value.includes('.') && !input.value.includes(',')) return false\n\t}\n\tconst pattern = currencyAmountEntryPattern(selectedCurrencyId.value)\n\tconst input = event.target as HTMLInputElement\n\tconst { selectionStart, selectionEnd, value } = input\n\tif (selectionStart === null || selectionEnd === null) {\n\t\tevent.preventDefault()\n\t\treturn true\n\t}\n\tconst next = value.slice(0, selectionStart) + event.key + value.slice(selectionEnd)\n\tif (event.key.length === 1 && !pattern.test(next)) event.preventDefault()\n\treturn true\n}\n\nconst onInputFocus = () => {\n\tif (selectOnFocus.value) {\n\t\tvoid nextTick(() => {\n\t\t\tinputRef.value?.select()\n\t\t\tselectOnFocus.value = false\n\t\t})\n\t}\n}\n\nconst focusInput = () => {\n\tselectOnFocus.value = true\n\tvoid nextTick(() => inputRef.value?.focus())\n}\n\ndefineExpose({ focusInput, openPicker, commitNumber })\n</script>\n\n<style scoped>\n.atable-tuple-shell__input {\n\tdisplay: block;\n\twidth: 100%;\n\tmin-width: 0;\n\tbox-sizing: border-box;\n\tborder: none;\n\toutline: none;\n\tbox-shadow: none;\n\tbackground: transparent;\n\tfont: inherit;\n\tcolor: inherit;\n\ttext-align: inherit;\n\tpadding: 0;\n\tmargin: 0;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n}\n\n.atable-tuple-shell__input::-webkit-outer-spin-button,\n.atable-tuple-shell__input::-webkit-inner-spin-button {\n\tappearance: none;\n}\n</style>\n","export type * from '@stonecrop/atable/types'\nexport { deserializeFunction } from './utils/deserialize'\nexport { badgeInputAccentStyle, resolveFieldBadge } from './utils/badge'\nexport { resolvedFieldsToColumns } from './utils/columns'\nexport type { BadgeFormatContext, BadgeFormatFn } from './utils/badge'\nimport { install as installATable } from '@stonecrop/atable'\nimport type { App } from 'vue'\n\nimport ACheckbox from './components/form/ACheckbox.vue'\nimport ACurrencyInput from './components/form/ACurrencyInput.vue'\nimport ADate from './components/form/ADate.vue'\nimport ADropdown from './components/form/ADropdown.vue'\nimport ASegmentedControl from './components/form/ASegmentedControl.vue'\nimport ABadge from './components/form/ABadge.vue'\nimport ADatePicker from './components/form/ADatePicker.vue'\nimport ADateTime from './components/form/ADateTime.vue'\nimport ADateTimeInput from './components/form/ADateTimeInput.vue'\nimport ADateSelection from './components/form/ADateSelection.vue'\nimport ADuration from './components/form/ADuration.vue'\nimport ADateRange from './components/form/ADateRange.vue'\nimport AFieldset from './components/form/AFieldset.vue'\nimport AFileAttach from './components/form/AFileAttach.vue'\nimport AForm from './components/AForm.vue'\nimport AFormLink from './components/form/AFormLink.vue'\nimport ANumericInput from './components/form/ANumericInput.vue'\nimport AQuantityInput from './components/form/AQuantityInput.vue'\nimport ASemverInput from './components/form/ASemverInput.vue'\nimport ATextInput from './components/form/ATextInput.vue'\nimport ATextboxInput from './components/form/ATextboxInput.vue'\nimport Login from './components/utilities/Login.vue'\nimport AFormLoading from './components/AFormLoading.vue'\nimport ExpandButton from './components/base/ExpandButton.vue'\nimport ATableTupleCurrencyPicker from './components/table/ATableTupleCurrencyPicker.vue'\nimport ATableTupleQuantityPicker from './components/table/ATableTupleQuantityPicker.vue'\nimport ATupleCellEditor from './components/table/ATupleCellEditor.vue'\nimport ATupleCellShell from './components/table/ATupleCellShell.vue'\n\nexport type * from './types'\n\n/**\n * Install all AForm components\n * @param app - Vue app instance\n * @public\n */\nfunction install(app: App /* options */) {\n\tapp.use(installATable) // Install ATable components for use within AForm\n\n\tapp.component('ACheckbox', ACheckbox)\n\tapp.component('ACurrencyInput', ACurrencyInput)\n\tapp.component('ADate', ADate)\n\tapp.component('ADropdown', ADropdown)\n\tapp.component('ASegmentedControl', ASegmentedControl)\n\tapp.component('ABadge', ABadge)\n\tapp.component('ADatePicker', ADatePicker)\n\tapp.component('ADateTime', ADateTime)\n\tapp.component('ADateTimeInput', ADateTimeInput)\n\tapp.component('ADateRange', ADateRange)\n\tapp.component('ADateSelection', ADateSelection)\n\tapp.component('AFieldset', AFieldset)\n\tapp.component('AFileAttach', AFileAttach)\n\tapp.component('AForm', AForm)\n\tapp.component('AFormLink', AFormLink)\n\tapp.component('ANumericInput', ANumericInput)\n\tapp.component('AQuantityInput', AQuantityInput)\n\tapp.component('ASemverInput', ASemverInput)\n\tapp.component('ATextInput', ATextInput)\n\tapp.component('ATextboxInput', ATextboxInput)\n\tapp.component('ADuration', ADuration)\n\tapp.component('AFormLoading', AFormLoading)\n\tapp.component('ExpandButton', ExpandButton)\n\tapp.component('ATableTupleQuantityPicker', ATableTupleQuantityPicker)\n\tapp.component('ATableTupleCurrencyPicker', ATableTupleCurrencyPicker)\n\tapp.component('ATupleCellEditor', ATupleCellEditor)\n\tapp.component('ATupleCellShell', ATupleCellShell)\n}\n\nexport {\n\tACheckbox,\n\tACurrencyInput,\n\tADate,\n\tADropdown,\n\tASegmentedControl,\n\tABadge,\n\tADatePicker,\n\tADateRange,\n\tADateSelection,\n\tADuration,\n\tADateTime,\n\tADateTimeInput,\n\tAFieldset,\n\tAFileAttach,\n\tAForm,\n\tAFormLink,\n\tANumericInput,\n\tAQuantityInput,\n\tASemverInput,\n\tATextInput,\n\tATextboxInput,\n\tLogin,\n\tAFormLoading,\n\tExpandButton,\n\tATableTupleQuantityPicker,\n\tATableTupleCurrencyPicker,\n\tATupleCellEditor,\n\tATupleCellShell,\n\tinstall,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAgB,oBAAuD,QAAmB;CAEzF,OAAO,SAAS,yBAAyB,OAAO,EAAE,CAAC,CAAC;AACrD;;;;;;;ACKA,SAAgB,kBACf,OACA,SACA,QACA,UA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