@gridkitjs/forms 0.0.0-dev-20261206115313 → 0.0.0-dev-20261206155240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +140 -3
- package/dist/index.js +3432 -409
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/calendar/Calendar.tsx","../src/date/DateInput.tsx","../src/field/fieldContext.ts","../src/calendar/PopupCalendar.tsx","../src/calendar/CalendarBody.tsx","../src/calendar/MonthPanel.tsx","../src/field/parts.tsx","../src/calendar/MonthsView.tsx","../src/calendar/useCalendarNavigation.ts","../src/text/parts.tsx","../src/dev.ts","../src/field/Field.tsx","../src/form/formContext.ts","../src/settings.tsx","../src/field/FieldHelp.tsx","../src/picker/usePickerPopup.ts","../src/field/FieldMessages.tsx","../src/refs.ts","../src/useFieldInput.tsx","../src/DisplayValue.tsx","../src/date/SegmentedControl.tsx","../src/picker/PickerPopup.tsx","../src/date/useSegmentedInput.tsx","../src/calendar/usePickerField.tsx","../src/calendar/RangeCalendar.tsx","../src/date/DateTimeInput.tsx","../src/time/DateTimePicker.tsx","../src/time/TimeColumns.tsx","../src/date/TimeInput.tsx","../src/time/TimePicker.tsx","../src/field/FieldGroup.tsx","../src/field/useField.ts","../src/form/Form.tsx","../src/FormsProvider.tsx","../src/form/MessageSummary.tsx","../src/layout/Fieldset.tsx","../src/layout/FormLayout.tsx","../src/layout/FormSection.tsx","../src/duration/DurationInput.tsx","../src/number/numberKind.ts","../src/mask/MaskedInput.tsx","../src/mask/maskKind.ts","../src/number/NumberInput.tsx","../src/number/NumberRangeInput.tsx","../src/useCompositeInput.tsx","../src/number/PercentInput.tsx","../src/period/PeriodInput.tsx","../src/period/PeriodPicker.tsx","../src/text/SearchInput.tsx","../src/text/TextInput.tsx","../src/toggle/ToggleInput.tsx","../src/toggle/Checkbox.tsx","../src/toggle/Switch.tsx","../src/index.ts"],"sourcesContent":["import {\n availableDateRule,\n dateDetails,\n dateFormatter,\n formatDate,\n isCalendarDayDisabled,\n isPlainDate,\n maxDateRule,\n minDateRule,\n requiredRule,\n weekInfo,\n type CalendarLimits,\n type CalendarMonth,\n type DateDetails,\n type DateFieldOptions,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport { useCallback, useMemo, type RefCallback } from \"react\";\nimport { todayFor } from \"../date/DateInput\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { joinIds, OwnMessages, useOwnMessagesId } from \"../text/parts\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { CalendarBody } from \"./CalendarBody\";\nimport type {\n CalendarBaseProps,\n CalendarLimitProps,\n CalendarSettings,\n} from \"./calendarProps\";\nimport { NO_MARKS, titleId, type CalendarLook } from \"./MonthPanel\";\nimport { useCalendarNavigation, useToday } from \"./useCalendarNavigation\";\nimport {\n hiddenInputs,\n usePickerField,\n type PickerKind,\n} from \"./usePickerField\";\n\nexport interface CalendarProps\n extends\n CalendarBaseProps<PlainDate, DateDetails>,\n CalendarLimitProps,\n CalendarSettings {\n /** The month shown, `\"2026-03\"`; present means controlled. The value's month, else today's, by default. */\n readonly month?: CalendarMonth | undefined;\n /** The month shown first, uncontrolled. */\n readonly defaultMonth?: CalendarMonth | undefined;\n /** The month shown changed: the month buttons, the keys, the month view. */\n readonly onMonthChange?: ((month: CalendarMonth) => void) | undefined;\n}\n\n/** The day in a calendar that takes focus from code: its one Tab stop in the grid. */\nexport function focusedDayIn(root: HTMLElement): HTMLElement | null {\n return root.querySelector<HTMLElement>('[role=\"gridcell\"][tabindex=\"0\"]');\n}\n\nconst SELECTED = { ...NO_MARKS, selected: true };\n\n/**\n * A month grid to choose one day from, following the APG date picker:\n * the arrows move by day and week, Home and End to the week's ends,\n * PageUp and PageDown by month (with Shift, by year), Enter or Space\n * chooses, and the month buttons and the title's month and year view jump\n * further. Weeks start on the locale's first day and may show their\n * numbers; days outside `min` and `max` and those `isDateDisabled` marks\n * take focus but cannot be chosen.\n *\n * Its value is a `PlainDate`, `null` when nothing is chosen. Choosing a\n * day fires the change and commit events with `source` and `trigger`\n * `\"picker\"` and `DateDetails`; moving between days fires only\n * `onMonthChange` when the month changes. It takes the shared input props:\n * display mode, `readOnly` (days take focus, none can be chosen),\n * `disabled`, messages, `name` and the events of `@gridkitjs/forms`.\n */\nexport function Calendar({\n min,\n max,\n isDateDisabled,\n timeZone,\n firstDayOfWeek,\n weekNumbers = false,\n weekNumbering,\n month,\n defaultMonth,\n onMonthChange,\n required,\n validate,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: CalendarProps) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const needsValue = required === true || field?.required === true;\n const today = todayFor(timeZone);\n const options: DateFieldOptions = { today, shortcuts: false, min, max };\n const kind: PickerKind<PlainDate, DateDetails> = {\n name: \"Calendar\",\n defaultFormat: dateFormatter(),\n details: (current, _previous, cause) =>\n dateDetails(current, cause, { ...options, locale, messages }),\n display: (value) => formatDate(value, locale),\n isValue: isPlainDate,\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<PlainDate>()] : []),\n ...(min === undefined ? [] : [minDateRule(min)]),\n ...(max === undefined ? [] : [maxDateRule(max)]),\n ...(isDateDisabled === undefined\n ? []\n : [availableDateRule<PlainDate>(isDateDisabled)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, isDateDisabled, validate],\n );\n const picker = usePickerField(\n { ...props, required, validate: validators },\n kind,\n focusedDayIn,\n );\n const { rootId, readOnly, disabled } = picker;\n const { value } = picker.state;\n\n const limits: CalendarLimits = useMemo(\n () => ({ min, max, isDateDisabled }),\n [min, max, isDateDisabled],\n );\n const firstDay = firstDayOfWeek ?? weekInfo(locale).firstDay;\n const nav = useCalendarNavigation({\n focus: value ?? today(),\n month,\n defaultMonth,\n onMonthChange,\n context: { firstDayOfWeek: firstDay, visibleMonths: 1, limits },\n });\n const { setRoot } = picker;\n const navSetRoot = nav.setRoot;\n const rootRef = useCallback<RefCallback<HTMLDivElement>>(\n (element) => {\n navSetRoot(element);\n setRoot(element);\n },\n [navSetRoot, setRoot],\n );\n const shownToday = useToday(timeZone);\n const ownMessagesId = useOwnMessagesId(rootId);\n const hidden = hiddenInputs(props.name, props.form, disabled, [\n [\"\", value ?? \"\"],\n ]);\n\n if (picker.mode === \"display\") {\n return (\n <div\n className={classNames(\n \"gridkit-forms-calendar\",\n \"is-display\",\n className,\n )}\n style={style}\n >\n <DisplayValue\n text={picker.displayText}\n emptyText={picker.strings.emptyValue}\n />\n {hidden}\n </div>\n );\n }\n\n function choose(date: PlainDate, nativeEvent: Event) {\n if (!readOnly && !disabled && !isCalendarDayDisabled(date, limits)) {\n picker.pick(date, nativeEvent);\n }\n }\n\n const look: CalendarLook = {\n rootId,\n locale,\n strings: picker.strings,\n firstDayOfWeek: firstDay,\n weekNumbering,\n weekNumbers,\n weekend: weekInfo(locale).weekend,\n limits,\n today: shownToday,\n focused: nav.state.focused,\n disabled,\n readOnly,\n range: false,\n marks: (date) => (date === value ? SELECTED : NO_MARKS),\n };\n\n return (\n <div\n ref={rootRef}\n id={rootId}\n className={classNames(\n \"gridkit-forms-calendar\",\n disabled && \"is-disabled\",\n readOnly && \"is-read-only\",\n picker.invalid && \"is-invalid\",\n className,\n )}\n style={style}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy ??\n (ariaLabel === undefined\n ? joinIds(picker.fieldLabelId, titleId(rootId, 0))\n : undefined)\n }\n aria-describedby={joinIds(\n picker.describedBy,\n ownMessagesId,\n ariaDescribedBy,\n )}\n >\n <CalendarBody\n nav={nav}\n look={look}\n visibleMonths={1}\n onDayClick={(date, event) => {\n choose(date, event.nativeEvent);\n }}\n onChooseKey={(date, event) => {\n choose(date, event.nativeEvent);\n }}\n />\n {hidden}\n <OwnMessages\n id={`${rootId}-messages`}\n messages={picker.messages}\n strings={picker.strings}\n named\n />\n </div>\n );\n}\n","import {\n availableDateRule,\n compareDates,\n dateDetails,\n dateFormatter,\n dateLayout,\n dateParser,\n formatDate,\n isPlainDate,\n maxDateRule,\n minDateRule,\n nowIn,\n pivotYear,\n requiredRule,\n runtimeTimeZone,\n todayIn,\n type DateDetails,\n type DateFieldOptions,\n type PlainDate,\n type PlainDateTime,\n type PopupOpenChange,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, useState } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport type { CalendarSettings } from \"../calendar/calendarProps\";\nimport { PopupCalendar } from \"../calendar/PopupCalendar\";\nimport { CalendarIcon, InputFrame } from \"../text/parts\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { SegmentedControl } from \"./SegmentedControl\";\nimport type { DayLimits, SegmentedInputProps } from \"./segmentedProps\";\nimport {\n createSegmentsAccess,\n typingSegment,\n type SegmentedKind,\n} from \"./useSegmentedInput\";\n\nexport interface DateInputProps\n extends\n SegmentedInputProps<PlainDate, DateDetails>,\n DayLimits,\n CalendarSettings {\n /** The calendar button and its popup; on by default. */\n readonly calendar?: boolean | undefined;\n /** The calendar popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n}\n\n/** The day cell that takes focus as a calendar popup opens: the chosen day, else today. */\nexport function focusedDay(panel: HTMLElement): HTMLElement | null {\n return panel.querySelector<HTMLElement>('[role=\"gridcell\"][tabindex=\"0\"]');\n}\n\n/** Today in `timeZone`, or the runtime's zone, read when it is asked for. */\nexport function todayFor(timeZone: string | undefined): () => PlainDate {\n return () => todayIn(timeZone ?? runtimeTimeZone(), Date.now());\n}\n\n/** The wall clock now in `timeZone`, or the runtime's zone, read when it is asked for. */\nexport function nowFor(timeZone: string | undefined): () => PlainDateTime {\n return () => nowIn(timeZone ?? runtimeTimeZone(), Date.now());\n}\n\nfunction DateInputControl({\n min,\n max,\n isDateDisabled,\n shortcuts = true,\n timeZone,\n calendar = true,\n onOpenChange,\n firstDayOfWeek,\n weekNumbers,\n weekNumbering,\n required,\n validate,\n ...props\n}: DateInputProps) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const [segments] = useState(createSegmentsAccess);\n const { numberingSystem, displayFormat } = props;\n const needsValue = required === true || field?.required === true;\n\n const today = todayFor(timeZone);\n const options: DateFieldOptions = {\n today,\n shortcuts,\n min,\n max,\n numberingSystem,\n displayFormat,\n activeSegment: () => typingSegment(segments),\n };\n const kind: SegmentedKind<PlainDate, DateDetails> = {\n name: \"DateInput\",\n layout: dateLayout({ locale, fields: \"date\", numberingSystem }, messages),\n defaultParse: dateParser(options),\n defaultFormat: dateFormatter({ numberingSystem }),\n details: (current, _previous, cause) =>\n dateDetails(current, cause, { ...options, locale, messages }),\n display: (value) => formatDate(value, locale, displayFormat),\n serialize: (value) => value,\n isValue: isPlainDate,\n inLimits: (value) =>\n (min === undefined || compareDates(value, min) >= 0) &&\n (max === undefined || compareDates(value, max) <= 0),\n shortcuts,\n today,\n pivot: (digits) => pivotYear(digits, { today: today(), min, max }),\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<PlainDate>()] : []),\n ...(min === undefined ? [] : [minDateRule(min, displayFormat)]),\n ...(max === undefined ? [] : [maxDateRule(max, displayFormat)]),\n ...(isDateDisabled === undefined\n ? []\n : [availableDateRule<PlainDate>(isDateDisabled)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, displayFormat, isDateDisabled, validate],\n );\n\n return (\n <SegmentedControl\n props={{ ...props, required, validate: validators }}\n kind={kind}\n rootClassName=\"gridkit-forms-date-input\"\n segments={segments}\n picker={\n calendar\n ? {\n label: messages.chooseDate,\n icon: <CalendarIcon />,\n buttonClassName: \"gridkit-forms-calendar-button\",\n popupClassName: \"gridkit-forms-calendar-popup\",\n onOpenChange,\n initialFocus: focusedDay,\n content: ({ value, id, pick, close, setEscapeHandler }) => (\n <PopupCalendar\n id={id}\n selected={value}\n min={min}\n max={max}\n isDateDisabled={isDateDisabled}\n timeZone={timeZone}\n firstDayOfWeek={firstDayOfWeek}\n weekNumbers={weekNumbers}\n weekNumbering={weekNumbering}\n locale={locale}\n strings={messages}\n onChoose={(date, nativeEvent) => {\n pick(date, nativeEvent);\n close(\"picker\");\n }}\n setEscapeHandler={setEscapeHandler}\n />\n ),\n }\n : undefined\n }\n />\n );\n}\n\n/**\n * A date typed in segments in the locale's order (`03/14/2026` in en-US,\n * `14.03.2026` in de-DE, `2026/03/14` in ja-JP): typing moves on by\n * itself, the arrow keys move between segments and step them, separators\n * are optional, and the whole field is one Tab stop. A letter or a sign\n * opens a box for shortcuts (`t` today, `+3`, `-1w`, `s` and `e` for the\n * month's start and end), and a pasted date in any common form is read\n * whole. Its value is a `PlainDate`, an ISO string (`\"2026-03-14\"`),\n * `null` when empty; text that is incomplete or no date keeps the last\n * value and says why. `min`, `max` and `isDateDisabled` add their\n * messages. It takes every shared input prop: display mode, `readOnly`,\n * `disabled`, messages with their severity, density, prefix and suffix,\n * and the events of `@gridkitjs/forms` with `DateDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function DateInput(props: DateInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <DateInputControl {...props} />\n </InputFrame>\n );\n}\n","import type { FieldMessage, Severity } from \"@gridkitjs/forms-core\";\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\nimport type { FormSettings } from \"../settings\";\n\n/**\n * What an input tells the `Field` around it about its control, so a\n * floating label knows whether to rest inside the control or rise above.\n */\nexport interface FieldControlState {\n readonly focused: boolean;\n /** No text in the control. */\n readonly empty: boolean;\n /** Something sits at the control's start, such as a prefix, where a resting label would cover it. */\n readonly startAdornment?: boolean | undefined;\n /** The input needs a value by a `required` of its own, so the field marks its label. */\n readonly required?: boolean | undefined;\n /**\n * The control carries its own label beside it (a checkbox, a switch), so\n * nothing can rest inside it: a floating label sits above, as `top`.\n */\n readonly labelBeside?: boolean | undefined;\n}\n\n/** What a `Field`, or a `FieldGroup`, gives the inputs inside it. */\nexport interface FieldContextValue {\n /**\n * The control's `id`, which the label's `for` names; `null` in a\n * group, whose inputs each keep their own.\n */\n readonly controlId: string | null;\n /** The field's own settings, its props laid over the form's. */\n readonly settings: FormSettings;\n /** `aria-describedby` for the control: the description and the messages. */\n readonly describedBy: string;\n /** The field's `required`: the input checks for a value. */\n readonly required: boolean;\n /**\n * An error is shown under the field: from the app, or in a single field\n * from its input. In a group each input marks only its own errors.\n */\n readonly invalid: boolean;\n /**\n * The most serious message shown under a single field, which its\n * control's border takes; `null` in a group, whose inputs each take\n * their own.\n */\n readonly severity: Severity | null;\n /**\n * The shown messages of the input `reporter` names (its own `useId`),\n * which the field lists with its own; none takes the report back.\n */\n readonly setControlMessages: (\n reporter: string,\n messages: readonly FieldMessage[],\n ) => void;\n /** `null` when the input goes. A group ignores it. */\n readonly setControlState: (state: FieldControlState | null) => void;\n}\n\nexport const FieldContext = createContext<FieldContextValue | null>(null);\n\n/** The `Field` around the caller, or `null` outside one. */\nexport function useFieldContext(): FieldContextValue | null {\n return useContext(FieldContext);\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\nconst NO_REPORTS: ReadonlyMap<string, readonly FieldMessage[]> = new Map();\n\n/**\n * What the inputs inside a field or a group report as their shown\n * messages, in the order they first reported, and the setter they report\n * through.\n */\nexport function useControlMessages(): readonly [\n readonly FieldMessage[],\n FieldContextValue[\"setControlMessages\"],\n] {\n const [reports, setReports] = useState(NO_REPORTS);\n const setControlMessages = useCallback(\n (reporter: string, messages: readonly FieldMessage[]) => {\n setReports((current) => {\n if (messages.length === 0) {\n if (!current.has(reporter)) {\n return current;\n }\n const next = new Map(current);\n next.delete(reporter);\n return next;\n }\n return current.get(reporter) === messages\n ? current\n : new Map(current).set(reporter, messages);\n });\n },\n [],\n );\n const messages = useMemo(\n () => (reports.size === 0 ? NO_MESSAGES : [...reports.values()].flat()),\n [reports],\n );\n return [messages, setControlMessages];\n}\n","import {\n isCalendarDayDisabled,\n weekInfo,\n type CalendarLimits,\n type FormsMessages,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport { useLayoutEffect, useMemo } from \"react\";\nimport { todayFor } from \"../date/DateInput\";\nimport type { CalendarLimitProps, CalendarSettings } from \"./calendarProps\";\nimport { CalendarBody } from \"./CalendarBody\";\nimport { NO_MARKS, titleId, type CalendarLook } from \"./MonthPanel\";\nimport { useCalendarNavigation, useToday } from \"./useCalendarNavigation\";\n\nconst SELECTED = { ...NO_MARKS, selected: true };\n\n/** What a calendar in a picker popup reads. */\nexport interface PopupCalendarProps\n extends CalendarLimitProps, CalendarSettings {\n /** The popup's `id`, the prefix of the calendar's own ids. */\n readonly id: string;\n /** The day shown chosen, and where focus starts; today when `null`. */\n readonly selected: PlainDate | null;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** A day chosen by click, tap, Enter or Space; never a disabled one. */\n readonly onChoose: (date: PlainDate, nativeEvent: Event) => void;\n /** Takes Escape while the month view shows, which goes back to the days. */\n readonly setEscapeHandler: (handler: (() => boolean) | null) => void;\n}\n\n/**\n * The calendar a date input's popup shows: one month, the keys, the month\n * buttons and the month and year view of `Calendar`, without a field of\n * its own. Choosing a day calls `onChoose`, which the input turns into a\n * pick; focus starts on the chosen day, else today.\n */\nexport function PopupCalendar({\n id,\n selected,\n min,\n max,\n isDateDisabled,\n timeZone,\n firstDayOfWeek,\n weekNumbers = false,\n weekNumbering,\n locale,\n strings,\n onChoose,\n setEscapeHandler,\n}: PopupCalendarProps) {\n const limits: CalendarLimits = useMemo(\n () => ({ min, max, isDateDisabled }),\n [min, max, isDateDisabled],\n );\n const firstDay = firstDayOfWeek ?? weekInfo(locale).firstDay;\n const nav = useCalendarNavigation({\n focus: selected ?? todayFor(timeZone)(),\n context: { firstDayOfWeek: firstDay, visibleMonths: 1, limits },\n });\n const shownToday = useToday(timeZone);\n const { setRoot } = nav;\n\n useLayoutEffect(() => {\n setEscapeHandler(() => {\n if (nav.state.view.kind !== \"months\") {\n return false;\n }\n nav.dispatch({ type: \"closeMonths\" });\n nav.focusDay();\n return true;\n });\n return () => {\n setEscapeHandler(null);\n };\n });\n\n function choose(date: PlainDate, nativeEvent: Event) {\n if (!isCalendarDayDisabled(date, limits)) {\n onChoose(date, nativeEvent);\n }\n }\n\n const rootId = `${id}-calendar`;\n const look: CalendarLook = {\n rootId,\n locale,\n strings,\n firstDayOfWeek: firstDay,\n weekNumbering,\n weekNumbers,\n weekend: weekInfo(locale).weekend,\n limits,\n today: shownToday,\n focused: nav.state.focused,\n disabled: false,\n readOnly: false,\n range: false,\n marks: (date) => (date === selected ? SELECTED : NO_MARKS),\n };\n\n return (\n <div\n ref={setRoot}\n id={rootId}\n className=\"gridkit-forms-calendar\"\n role=\"group\"\n aria-labelledby={titleId(rootId, 0)}\n >\n <CalendarBody\n nav={nav}\n look={look}\n visibleMonths={1}\n onDayClick={(date, event) => {\n choose(date, event.nativeEvent);\n }}\n onChooseKey={(date, event) => {\n choose(date, event.nativeEvent);\n }}\n />\n </div>\n );\n}\n","import {\n calendarMonth,\n calendarMonthParts,\n type CalendarMonth,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport {\n Fragment,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from \"react\";\nimport {\n MonthGridTable,\n MonthHeader,\n monthTitle,\n titleId,\n type CalendarLook,\n} from \"./MonthPanel\";\nimport { MonthsView } from \"./MonthsView\";\nimport {\n calendarKeyMove,\n isRightToLeft,\n type CalendarNavigation,\n} from \"./useCalendarNavigation\";\n\n/** The month `months` after `month`. */\nfunction monthAfter(month: CalendarMonth, months: number): CalendarMonth {\n const parts = calendarMonthParts(month);\n const index = parts.year * 12 + parts.month - 1 + months;\n const year = Math.floor(index / 12);\n return calendarMonth(year, index - year * 12 + 1);\n}\n\n/**\n * What a calendar draws inside its root: each month shown with its header\n * and grid (wrapped in its own `gridkit-forms-calendar` in a range\n * calendar), or the month view in their place. It wires the keys, the\n * month buttons and the month view to `nav`; what choosing a day does is\n * the calendar's.\n */\nexport function CalendarBody({\n nav,\n look,\n visibleMonths,\n onDayClick,\n onChooseKey,\n onFocusMoved,\n onOtherKey,\n}: {\n readonly nav: CalendarNavigation;\n readonly look: CalendarLook;\n readonly visibleMonths: number;\n /** A day clicked or tapped; focus is already on it. */\n readonly onDayClick: (date: PlainDate, event: MouseEvent) => void;\n /** Enter or Space on the focused day. */\n readonly onChooseKey: (date: PlainDate, event: KeyboardEvent) => void;\n /** A key moved focus to `date`. */\n readonly onFocusMoved?: ((date: PlainDate) => void) | undefined;\n /** Any other key in a grid. */\n readonly onOtherKey?: ((event: KeyboardEvent) => void) | undefined;\n}) {\n const { state } = nav;\n\n function onKeyDown(event: KeyboardEvent<HTMLTableElement>) {\n const move = calendarKeyMove(event, isRightToLeft(event.currentTarget));\n if (move !== null) {\n event.preventDefault();\n const next = nav.dispatch({ type: \"move\", move });\n nav.focusDay();\n onFocusMoved?.(next.focused);\n return;\n }\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n onChooseKey(state.focused, event);\n return;\n }\n onOtherKey?.(event);\n }\n\n function page(months: -1 | 1) {\n const next = nav.dispatch({ type: \"page\", months });\n // The button disables at the last month it reaches, which would drop focus.\n if (!nav.canPage(months, next)) {\n nav.focusDay();\n }\n }\n\n const Panel = look.range ? RangePanel : Fragment;\n\n if (state.view.kind === \"months\") {\n const { year, panel } = state.view;\n const shown = monthAfter(state.month, panel);\n const parts = calendarMonthParts(shown);\n const close = () => {\n nav.dispatch({ type: \"closeMonths\" });\n nav.focusDay();\n };\n return (\n <Panel>\n <MonthHeader\n look={look}\n panel={panel}\n title={monthTitle(look, shown)}\n expanded\n previous={null}\n next={null}\n onTitle={close}\n />\n <MonthsView\n year={year}\n shownMonth={parts.month}\n shownYear={parts.year}\n limits={look.limits}\n locale={look.locale}\n strings={look.strings}\n labelId={titleId(look.rootId, panel)}\n onYear={(chosen) => {\n nav.dispatch({ type: \"showYear\", year: chosen });\n }}\n onMonth={(chosen) => {\n nav.dispatch({ type: \"chooseMonth\", month: chosen });\n nav.focusDay();\n }}\n onClose={close}\n />\n </Panel>\n );\n }\n\n return Array.from({ length: visibleMonths }, (_, panel) => {\n const month = monthAfter(state.month, panel);\n return (\n <Panel key={panel}>\n <MonthHeader\n look={look}\n panel={panel}\n title={monthTitle(look, month)}\n expanded={false}\n previous={\n panel === 0\n ? {\n enabled: nav.canPage(-1),\n onClick: () => {\n page(-1);\n },\n }\n : null\n }\n next={\n panel === visibleMonths - 1\n ? {\n enabled: nav.canPage(1),\n onClick: () => {\n page(1);\n },\n }\n : null\n }\n onTitle={() => {\n nav.dispatch({ type: \"openMonths\", panel });\n }}\n />\n <MonthGridTable\n look={look}\n month={month}\n panel={panel}\n onKeyDown={onKeyDown}\n onDayClick={(date, event) => {\n nav.dispatch({ type: \"focus\", date });\n nav.focusDay();\n onDayClick(date, event);\n }}\n />\n </Panel>\n );\n });\n}\n\nfunction RangePanel({ children }: { readonly children: ReactNode }) {\n return <div className=\"gridkit-forms-calendar is-range\">{children}</div>;\n}\n","import {\n calendarMonthParts,\n formatCalendarMonth,\n formatDate,\n formatDayOfMonth,\n formatWeekday,\n isCalendarDayDisabled,\n monthGrid,\n type CalendarLimits,\n type CalendarMonth,\n type FormsMessages,\n type PlainDate,\n type Weekday,\n type WeekNumbering,\n} from \"@gridkitjs/forms-core\";\nimport {\n useMemo,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from \"react\";\nimport { classNames } from \"../field/parts\";\n\n/** How a day shows: chosen, an end or the middle of a range, a range previewed. */\nexport interface DayMarks {\n readonly selected: boolean;\n readonly rangeStart: boolean;\n readonly rangeEnd: boolean;\n readonly inRange: boolean;\n readonly preview: boolean;\n}\n\nexport const NO_MARKS: DayMarks = {\n selected: false,\n rangeStart: false,\n rangeEnd: false,\n inRange: false,\n preview: false,\n};\n\n/** What every month of one calendar shares. */\nexport interface CalendarLook {\n readonly rootId: string;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n readonly firstDayOfWeek: Weekday;\n readonly weekNumbering: WeekNumbering | undefined;\n readonly weekNumbers: boolean;\n readonly weekend: readonly Weekday[];\n readonly limits: CalendarLimits;\n readonly today: PlainDate | null;\n /** The day that takes focus in the grid. */\n readonly focused: PlainDate;\n readonly disabled: boolean;\n readonly readOnly: boolean;\n /** A range calendar's grid selects several days. */\n readonly range: boolean;\n readonly marks: (date: PlainDate) => DayMarks;\n}\n\n/** The id of a month's title, which names its grid. */\nexport function titleId(rootId: string, panel: number): string {\n return `${rootId}-title-${String(panel)}`;\n}\n\n/** The date of the day cell an event happened in, if any. */\nexport function dateOf(target: EventTarget | null): PlainDate | null {\n if (!(target instanceof Element)) {\n return null;\n }\n const cell = target.closest<HTMLElement>(\"[data-gridkit-forms-date]\");\n return (cell?.dataset.gridkitFormsDate as PlainDate | undefined) ?? null;\n}\n\nexport function ChevronIcon({ side }: { readonly side: \"start\" | \"end\" }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={side === \"start\" ? \"m15 18-6-6 6-6\" : \"m9 18 6-6-6-6\"} />\n </svg>\n );\n}\n\n/**\n * A month's header: the previous and next buttons where `canPage` says\n * this month has them, and the title, a button that opens the month view\n * (`expanded` while it shows), read politely as it changes.\n */\nexport function MonthHeader({\n look,\n panel,\n title,\n expanded,\n previous,\n next,\n onTitle,\n}: {\n readonly look: CalendarLook;\n readonly panel: number;\n readonly title: string;\n readonly expanded: boolean;\n /** The previous month button, or `null` where this month has none. */\n readonly previous: NavButton | null;\n readonly next: NavButton | null;\n readonly onTitle: () => void;\n}) {\n const { strings, disabled } = look;\n return (\n <div className=\"gridkit-forms-calendar-header\">\n {previous !== null && (\n <button\n type=\"button\"\n className=\"gridkit-forms-calendar-nav is-previous\"\n aria-label={strings.previousMonth}\n disabled={disabled || !previous.enabled}\n onClick={previous.onClick}\n >\n <ChevronIcon side=\"start\" />\n </button>\n )}\n <button\n type=\"button\"\n className=\"gridkit-forms-calendar-title\"\n id={titleId(look.rootId, panel)}\n aria-live=\"polite\"\n aria-expanded={expanded}\n disabled={disabled}\n onClick={onTitle}\n >\n {title}\n </button>\n {next !== null && (\n <button\n type=\"button\"\n className=\"gridkit-forms-calendar-nav is-next\"\n aria-label={strings.nextMonth}\n disabled={disabled || !next.enabled}\n onClick={next.onClick}\n >\n <ChevronIcon side=\"end\" />\n </button>\n )}\n </div>\n );\n}\n\n/** A month button in a header: whether it can move, and what it does. */\nexport interface NavButton {\n readonly enabled: boolean;\n readonly onClick: (event: MouseEvent<HTMLButtonElement>) => void;\n}\n\n/** A day's accessible name: the full date, and its place in a range. */\nfunction dayLabel(look: CalendarLook, date: PlainDate, marks: DayMarks) {\n const full = formatDate(date, look.locale, { dateStyle: \"full\" });\n if (!look.range) {\n return full;\n }\n const ends = [\n marks.rangeStart && look.strings.calendarRangeStart,\n marks.rangeEnd && look.strings.calendarRangeEnd,\n ].filter(Boolean);\n return [full, ...ends].join(\", \");\n}\n\nconst WEEKDAYS: readonly Weekday[] = [1, 2, 3, 4, 5, 6, 7];\n\n/**\n * How weekday headers are written: the short names (\"Mon\", \"Mo.\"), unless\n * one is longer than four characters, as Arabic's are, which would not\n * fit a cell; then the narrow ones.\n */\nfunction weekdayHeaderWidth(locale: Intl.LocalesArgument): \"short\" | \"narrow\" {\n return WEEKDAYS.every(\n (weekday) => formatWeekday(weekday, locale, \"short\").length <= 4,\n )\n ? \"short\"\n : \"narrow\";\n}\n\n/**\n * One month as a grid (the APG date picker's): weekday headers from\n * `Intl`, week numbers when asked, six weeks of days with the days of the\n * months either side, the focused day the grid's one Tab stop.\n */\nexport function MonthGridTable({\n look,\n month,\n panel,\n onKeyDown,\n onDayClick,\n}: {\n readonly look: CalendarLook;\n readonly month: CalendarMonth;\n readonly panel: number;\n readonly onKeyDown: (event: KeyboardEvent<HTMLTableElement>) => void;\n readonly onDayClick: (date: PlainDate, event: MouseEvent) => void;\n}) {\n const { firstDayOfWeek, weekNumbering } = look;\n // The month's 42 days are laid out again only when the month or the week settings change.\n const grid = useMemo(() => {\n const { year, month: monthNumber } = calendarMonthParts(month);\n return monthGrid(year, monthNumber, { firstDayOfWeek, weekNumbering });\n }, [month, firstDayOfWeek, weekNumbering]);\n const weekNumber = new Intl.NumberFormat(look.locale, { useGrouping: false });\n const headerWidth = weekdayHeaderWidth(look.locale);\n return (\n <table\n className=\"gridkit-forms-calendar-grid\"\n role=\"grid\"\n aria-labelledby={titleId(look.rootId, panel)}\n aria-multiselectable={look.range || undefined}\n aria-readonly={look.readOnly || undefined}\n aria-disabled={look.disabled || undefined}\n onKeyDown={onKeyDown}\n >\n <thead>\n <tr>\n {look.weekNumbers && (\n <th className=\"gridkit-forms-calendar-week-number\" scope=\"col\">\n <span className=\"gridkit-forms-sr-only\">\n {look.strings.weekColumn}\n </span>\n </th>\n )}\n {grid.weekdays.map((weekday) => (\n <th\n key={weekday}\n className=\"gridkit-forms-calendar-weekday\"\n scope=\"col\"\n abbr={formatWeekday(weekday, look.locale, \"long\")}\n >\n {formatWeekday(weekday, look.locale, headerWidth)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {grid.weeks.map(({ week, days }) => (\n <tr key={`${String(week.year)}-${String(week.week)}`}>\n {look.weekNumbers && (\n <th\n className=\"gridkit-forms-calendar-week-number\"\n scope=\"row\"\n aria-label={look.strings.weekLabel(week.week)}\n >\n {weekNumber.format(week.week)}\n </th>\n )}\n {days.map(({ date, weekday, inMonth }) => (\n <Day\n key={date}\n look={look}\n date={date}\n weekday={weekday}\n inMonth={inMonth}\n onClick={onDayClick}\n />\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\nfunction Day({\n look,\n date,\n weekday,\n inMonth,\n onClick,\n}: {\n readonly look: CalendarLook;\n readonly date: PlainDate;\n readonly weekday: Weekday;\n readonly inMonth: boolean;\n readonly onClick: (date: PlainDate, event: MouseEvent) => void;\n}): ReactNode {\n const marks = look.marks(date);\n const disabled = isCalendarDayDisabled(date, look.limits);\n const today = date === look.today;\n const tabStop = inMonth && date === look.focused;\n return (\n <td\n role=\"gridcell\"\n className={classNames(\n \"gridkit-forms-calendar-day\",\n today && \"is-today\",\n marks.selected && \"is-selected\",\n !inMonth && \"is-outside\",\n disabled && \"is-disabled\",\n look.weekend.includes(weekday) && \"is-weekend\",\n marks.rangeStart && \"is-range-start\",\n marks.rangeEnd && \"is-range-end\",\n marks.inRange && \"is-in-range\",\n marks.preview && \"is-preview\",\n )}\n data-gridkit-forms-date={date}\n tabIndex={look.disabled ? undefined : tabStop ? 0 : -1}\n aria-selected={marks.selected}\n aria-disabled={disabled || undefined}\n aria-current={today ? \"date\" : undefined}\n aria-label={dayLabel(look, date, marks)}\n onClick={(event) => {\n onClick(date, event);\n }}\n >\n {formatDayOfMonth(date, look.locale)}\n </td>\n );\n}\n\n/** A month's title: \"March 2026\". */\nexport function monthTitle(look: CalendarLook, month: CalendarMonth): string {\n return formatCalendarMonth(month, look.locale);\n}\n","import {\n sortFieldMessages,\n toFieldMessages,\n type FieldMessage,\n type FieldMessageInput,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, type CSSProperties } from \"react\";\nimport type { NecessityIndicator } from \"../settings\";\n\n/** Columns a field, a group or a fieldset takes in a `FormLayout`. */\nexport type FieldSpan = 1 | 2 | 3 | 4 | \"full\";\n\n/** The state class for `span`; none for one column. */\nexport function spanClass(span: FieldSpan | undefined): string | false {\n return span !== undefined && span !== 1 && `is-span-${String(span)}`;\n}\n\n/** `style` with the label column's width set, when there is one. */\nexport function withLabelWidth(\n style: CSSProperties | undefined,\n labelWidth: string | undefined,\n): CSSProperties | undefined {\n return labelWidth === undefined\n ? style\n : ({\n ...style,\n \"--gridkit-forms-label-width\": labelWidth,\n } as CSSProperties);\n}\n\n/** Joins the class names that are set. */\nexport function classNames(...names: (string | false | undefined)[]): string {\n return names.filter(Boolean).join(\" \");\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/**\n * The messages a field or group shows: its inputs' and the app's, most\n * serious first, each text of a severity once, as when two inputs of a\n * group both lack a value. A disabled one shows only the app's.\n */\nexport function useShownMessages(\n controlMessages: readonly FieldMessage[],\n message: FieldMessageInput | readonly FieldMessageInput[] | undefined,\n disabled: boolean,\n): readonly FieldMessage[] {\n return useMemo(() => {\n const seen = new Set<string>();\n return sortFieldMessages([\n ...(disabled ? NO_MESSAGES : controlMessages),\n ...toFieldMessages(message, \"app\"),\n ]).filter((shown) => {\n const key = `${shown.severity}:${shown.text}`;\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n }, [disabled, controlMessages, message]);\n}\n\n/**\n * The marker after a label: a star for a required field, hidden from\n * screen readers since the control's `aria-required` says it, or\n * \"(optional)\" for the others, read as part of the label.\n */\nexport function NecessityMarker({\n required,\n indicator,\n strings,\n}: {\n readonly required: boolean;\n readonly indicator: NecessityIndicator;\n readonly strings: FormsMessages;\n}) {\n if (required && indicator === \"required\") {\n return (\n <span className=\"gridkit-forms-field-required\" aria-hidden=\"true\">\n *\n </span>\n );\n }\n if (!required && indicator === \"optional\") {\n return (\n <span className=\"gridkit-forms-field-optional\">\n {` (${strings.optional})`}\n </span>\n );\n }\n return null;\n}\n","import {\n calendarYears,\n formatCalendarYear,\n formatMonthName,\n isCalendarMonthDisabled,\n type CalendarLimits,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport { useLayoutEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport { classNames } from \"../field/parts\";\nimport { isRightToLeft } from \"./useCalendarNavigation\";\n\nconst MONTHS = Array.from({ length: 12 }, (_, index) => index + 1);\nconst COLUMNS = 3;\n\n/** Moves focus among `buttons` from `index` by the key, or returns `null` for a key that moves nothing. */\nexport function nextIndex(\n event: KeyboardEvent,\n index: number,\n count: number,\n steps: { readonly row: number; readonly column: number },\n): number | null {\n const rtl = isRightToLeft(event.currentTarget);\n const moves: Readonly<Record<string, number>> = {\n ArrowLeft: rtl ? steps.column : -steps.column,\n ArrowRight: rtl ? -steps.column : steps.column,\n ArrowUp: -steps.row,\n ArrowDown: steps.row,\n Home: -index,\n End: count - 1 - index,\n };\n const move = moves[event.key];\n if (move === undefined || move === 0) {\n return move === 0 ? index : null;\n }\n return Math.min(Math.max(index + move, 0), count - 1);\n}\n\n/**\n * A calendar's month view, in place of one month's days: its year's\n * twelve months as a grid of buttons, and the years to choose from as a\n * scrolling list. Each is one Tab stop moved through with the arrows; a\n * month chosen goes back to the days, Escape goes back unchanged.\n */\nexport function MonthsView({\n year,\n shownMonth,\n shownYear,\n limits,\n locale,\n strings,\n labelId,\n onYear,\n onMonth,\n onClose,\n}: {\n readonly year: number;\n /** The month and year of the days this view replaced. */\n readonly shownMonth: number;\n readonly shownYear: number;\n readonly limits: CalendarLimits;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** The title's id, which names the months. */\n readonly labelId: string;\n readonly onYear: (year: number) => void;\n readonly onMonth: (month: number) => void;\n readonly onClose: () => void;\n}) {\n const monthsRef = useRef<HTMLDivElement>(null);\n const yearsRef = useRef<HTMLDivElement>(null);\n const [monthFocus, setMonthFocus] = useState(() =>\n year === shownYear\n ? shownMonth\n : (MONTHS.find(\n (month) => !isCalendarMonthDisabled(year, month, limits),\n ) ?? 1),\n );\n // The list stays around the year it opened on, so choosing a year never scrolls it away.\n const [listYear] = useState(year);\n const range = calendarYears(listYear, limits);\n const years = Array.from(\n { length: range.last - range.first + 1 },\n (_, index) => range.first + index,\n );\n\n // On opening, focus goes to the month shown, and the year list scrolls to its year.\n useLayoutEffect(() => {\n monthsRef.current\n ?.querySelector<HTMLElement>('[tabindex=\"0\"]')\n ?.focus({ preventScroll: true });\n const years = yearsRef.current;\n const chosen = years?.querySelector<HTMLElement>('[tabindex=\"0\"]');\n if (years !== null && chosen !== null && chosen !== undefined) {\n years.scrollTop =\n chosen.offsetTop - (years.clientHeight - chosen.offsetHeight) / 2;\n }\n }, []);\n\n function onKeyDown(event: KeyboardEvent<HTMLElement>) {\n if (event.key === \"Escape\") {\n event.preventDefault();\n onClose();\n }\n }\n\n function focusButton(container: HTMLElement | null, index: number) {\n container?.querySelectorAll<HTMLElement>(\"button\")[index]?.focus();\n }\n\n return (\n <div onKeyDown={onKeyDown}>\n <div\n ref={monthsRef}\n className=\"gridkit-forms-calendar-months\"\n role=\"group\"\n aria-labelledby={labelId}\n onKeyDown={(event) => {\n const next = nextIndex(event, monthFocus - 1, 12, {\n row: COLUMNS,\n column: 1,\n });\n if (next !== null) {\n event.preventDefault();\n setMonthFocus(next + 1);\n focusButton(monthsRef.current, next);\n }\n }}\n >\n {MONTHS.map((month) => {\n const current = month === shownMonth && year === shownYear;\n return (\n <button\n key={month}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-calendar-month\",\n current && \"is-selected\",\n )}\n tabIndex={month === monthFocus ? 0 : -1}\n aria-current={current || undefined}\n disabled={isCalendarMonthDisabled(year, month, limits)}\n onClick={() => {\n onMonth(month);\n }}\n >\n {formatMonthName(month, locale, \"long\")}\n </button>\n );\n })}\n </div>\n <div\n ref={yearsRef}\n className=\"gridkit-forms-calendar-years\"\n role=\"group\"\n aria-label={strings.calendarYears}\n onKeyDown={(event) => {\n const index = years.indexOf(year);\n const next = nextIndex(event, index, years.length, {\n row: 1,\n column: 0,\n });\n if (next !== null && next !== index) {\n event.preventDefault();\n const chosen = years[next];\n if (chosen !== undefined) {\n onYear(chosen);\n }\n focusButton(yearsRef.current, next);\n }\n }}\n >\n {years.map((listed) => (\n <button\n key={listed}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-calendar-year\",\n listed === year && \"is-selected\",\n )}\n tabIndex={listed === year ? 0 : -1}\n aria-pressed={listed === year}\n onClick={() => {\n onYear(listed);\n }}\n >\n {formatCalendarYear(listed, locale)}\n </button>\n ))}\n </div>\n </div>\n );\n}\n","import {\n calendarReducer,\n calendarStart,\n runtimeTimeZone,\n todayIn,\n type CalendarAction,\n type CalendarContext,\n type CalendarMonth,\n type CalendarMove,\n type CalendarState,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport {\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type KeyboardEvent,\n} from \"react\";\n\n/** The key's move in a calendar's grid, ArrowLeft and ArrowRight mirrored right to left; `null` for any other key. */\nexport function calendarKeyMove(\n event: KeyboardEvent,\n rtl: boolean,\n): CalendarMove | null {\n if (event.altKey || event.ctrlKey || event.metaKey) {\n return null;\n }\n switch (event.key) {\n case \"ArrowLeft\":\n return rtl ? \"nextDay\" : \"previousDay\";\n case \"ArrowRight\":\n return rtl ? \"previousDay\" : \"nextDay\";\n case \"ArrowUp\":\n return \"previousWeek\";\n case \"ArrowDown\":\n return \"nextWeek\";\n case \"Home\":\n return \"startOfWeek\";\n case \"End\":\n return \"endOfWeek\";\n case \"PageUp\":\n return event.shiftKey ? \"previousYear\" : \"previousMonth\";\n case \"PageDown\":\n return event.shiftKey ? \"nextYear\" : \"nextMonth\";\n default:\n return null;\n }\n}\n\n/** Whether `element` lays out right to left. */\nexport function isRightToLeft(element: Element): boolean {\n return getComputedStyle(element).direction === \"rtl\";\n}\n\nconst noSubscription = () => () => undefined;\n\n/**\n * Today in `timeZone`, or the runtime's zone; `null` on the server and\n * while hydrating, so the page the server sent never marks another day.\n */\nexport function useToday(timeZone: string | undefined): PlainDate | null {\n return useSyncExternalStore(\n noSubscription,\n () => todayIn(timeZone ?? runtimeTimeZone(), Date.now()),\n () => null,\n );\n}\n\n/** The selector of the grid cell holding `date` in its own month. */\nexport function dayCellSelector(date: PlainDate): string {\n return `[data-gridkit-forms-date=\"${date}\"]:not(.is-outside)`;\n}\n\n/** What `useCalendarNavigation` reads. */\nexport interface CalendarNavigationOptions {\n /** The day focus starts on: the value's, else today. */\n readonly focus: PlainDate;\n /** The app's first month shown; present means controlled. */\n readonly month?: CalendarMonth | undefined;\n readonly defaultMonth?: CalendarMonth | undefined;\n readonly onMonthChange?: ((month: CalendarMonth) => void) | undefined;\n readonly context: CalendarContext;\n}\n\n/** What `useCalendarNavigation` gives the calendar that calls it. */\nexport interface CalendarNavigation {\n readonly state: CalendarState;\n /** Applies `action`, telling `onMonthChange` when the first month shown changes, and returns the new state. */\n readonly dispatch: (action: CalendarAction) => CalendarState;\n /** Moves focus to the focused day once the calendar has drawn. */\n readonly focusDay: () => void;\n /** Whether the previous (`-1`) or next (`1`) month button would move the months shown, from `from` or now. */\n readonly canPage: (months: -1 | 1, from?: CalendarState) => boolean;\n /** Points at the calendar's root, which the focused day is looked for in; the same function on every render. */\n readonly setRoot: (root: HTMLElement | null) => void;\n}\n\nfunction sameState(a: CalendarState, b: CalendarState): boolean {\n return a.month === b.month && a.focused === b.focused && a.view === b.view;\n}\n\n/**\n * Holds where a calendar is (forms-core's `calendarReducer`): the months\n * shown, the focused day and the month view. A controlled `month` is\n * followed on every render, and the state is fitted to the latest limits\n * and number of months. `focusDay` asks for focus on the focused day after\n * the next draw, for a key or a click that moved it.\n */\nexport function useCalendarNavigation({\n focus,\n month,\n defaultMonth,\n onMonthChange,\n context,\n}: CalendarNavigationOptions): CalendarNavigation {\n const [stored, setStored] = useState(() =>\n calendarStart(focus, month ?? defaultMonth, context),\n );\n let state = stored;\n const fitted = calendarReducer(\n stored,\n { type: \"show\", month: month ?? stored.month },\n context,\n );\n if (!sameState(fitted, stored)) {\n state = fitted;\n setStored(fitted);\n }\n const latest = useRef(state);\n const root = useRef<HTMLElement | null>(null);\n const setRoot = useCallback((element: HTMLElement | null) => {\n root.current = element;\n }, []);\n const focusPending = useRef(false);\n useLayoutEffect(() => {\n latest.current = state;\n if (!focusPending.current) {\n return;\n }\n focusPending.current = false;\n root.current\n ?.querySelector<HTMLElement>(dayCellSelector(state.focused))\n ?.focus();\n });\n\n return {\n state,\n dispatch: (action) => {\n const current = latest.current;\n const next = calendarReducer(current, action, context);\n if (next === current) {\n return current;\n }\n latest.current = next;\n setStored(next);\n if (next.month !== current.month) {\n onMonthChange?.(next.month);\n }\n return next;\n },\n focusDay: () => {\n focusPending.current = true;\n },\n canPage: (months, from = state) =>\n calendarReducer(from, { type: \"page\", months }, context).month !==\n from.month,\n setRoot,\n };\n}\n","import type {\n FieldMessage,\n FormsMessages,\n Severity,\n} from \"@gridkitjs/forms-core\";\nimport {\n useCallback,\n useEffect,\n useState,\n type MouseEvent,\n type ReactNode,\n type Ref,\n type RefCallback,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport { Field } from \"../field/Field\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { FieldMessages } from \"../field/FieldMessages\";\nimport { classNames } from \"../field/parts\";\nimport { setRef } from \"../refs\";\nimport type { Density, FieldMode } from \"../settings\";\nimport type { TextControl } from \"@gridkitjs/forms-dom\";\n\nfunction Icon({ children }: { readonly children: ReactNode }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n {children}\n </svg>\n );\n}\n\nexport function ClearIcon() {\n return (\n <Icon>\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </Icon>\n );\n}\n\nexport function EyeIcon() {\n return (\n <Icon>\n <path d=\"M2.06 12.35a1 1 0 0 1 0-.7 10.75 10.75 0 0 1 19.88 0 1 1 0 0 1 0 .7 10.75 10.75 0 0 1-19.88 0\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </Icon>\n );\n}\n\nexport function SearchIcon() {\n return (\n <Icon>\n <circle cx=\"11\" cy=\"11\" r=\"8\" />\n <path d=\"m21 21-4.3-4.3\" />\n </Icon>\n );\n}\n\nexport function ClockIcon() {\n return (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 6v6l4 2\" />\n </Icon>\n );\n}\n\nexport function CalendarIcon() {\n return (\n <Icon>\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\" />\n <path d=\"M16 2v4\" />\n <path d=\"M8 2v4\" />\n <path d=\"M3 10h18\" />\n </Icon>\n );\n}\n\n/**\n * Keeps focus, and the selection, in the control when a button in its box\n * is pressed, by a mouse or, through the mouse events that follow a tap,\n * a finger. Not on `pointerdown`: WebKit fires no `click` after a touch\n * whose `pointerdown` was prevented.\n */\nexport function keepFocus(event: MouseEvent): void {\n event.preventDefault();\n}\n\n/** The density state class; none for `standard`. */\nexport function densityClass(density: Density): string | false {\n return density !== \"standard\" && `is-${density}`;\n}\n\n/** Joins the ids that are set into one `aria-describedby`, or `undefined` for none. */\nexport function joinIds(\n ...ids: (string | false | undefined)[]\n): string | undefined {\n const joined = ids.filter(Boolean).join(\" \");\n return joined === \"\" ? undefined : joined;\n}\n\n/**\n * The native control, in state for the input's own behaviours, and one\n * ref that also points the app's `ref` at it.\n */\nexport function useControlElement<E extends TextControl>(\n ref: Ref<E> | undefined,\n): readonly [E | null, RefCallback<E>] {\n const [element, setElement] = useState<E | null>(null);\n const merged = useCallback<RefCallback<E>>(\n (control) => {\n setElement(control);\n const release = setRef(ref, control);\n return () => {\n setElement(null);\n release?.();\n };\n },\n [ref],\n );\n return [element, merged];\n}\n\n/**\n * Outside a `Field`, an input given a `label` or a `description` draws a\n * `Field` around itself with them; otherwise it draws only itself.\n */\nexport function InputFrame({\n label,\n description,\n id,\n mode,\n density,\n readOnly,\n disabled,\n children,\n}: {\n readonly label: ReactNode;\n readonly description: ReactNode;\n readonly id: string | undefined;\n readonly mode: FieldMode | undefined;\n readonly density: Density | undefined;\n readonly readOnly: boolean | undefined;\n readonly disabled: boolean | undefined;\n readonly children: ReactNode;\n}) {\n const field = useFieldContext();\n const hasLabel = label !== undefined && label !== null;\n const hasDescription = description !== undefined && description !== null;\n if (field !== null || (!hasLabel && !hasDescription)) {\n return children;\n }\n return (\n <Field\n label={label}\n description={description}\n id={id}\n mode={mode}\n density={density}\n readOnly={readOnly}\n disabled={disabled}\n >\n {children}\n </Field>\n );\n}\n\n/**\n * A bare input's own message area, outside any `Field`; a `Field` lists\n * the messages itself, so inside one this draws nothing. Warns once in\n * development when the bare input has no name at all.\n */\nexport function OwnMessages({\n id,\n messages,\n strings,\n named,\n}: {\n readonly id: string;\n readonly messages: readonly FieldMessage[];\n readonly strings: FormsMessages;\n /** The control has an `aria-label` or an `aria-labelledby`. */\n readonly named: boolean;\n}) {\n const inField = useFieldContext() !== null;\n useEffect(() => {\n if (!inField && !named) {\n warnOnce(\n \"input-label\",\n \"An input outside a Field has no label, aria-label or aria-labelledby, so it has no name. Give it one of them (a placeholder is not a name).\",\n );\n }\n }, [inField, named]);\n return inField ? null : (\n <FieldMessages id={id} messages={messages} strings={strings} />\n );\n}\n\n/** The id of a bare input's own message area, when it has one. */\nexport function useOwnMessagesId(controlId: string): string | undefined {\n return useFieldContext() === null ? `${controlId}-messages` : undefined;\n}\n\n/**\n * The drawn box around a text control: its border, background and focus\n * ring, in the colour of the most serious message shown, with the\n * adornments, the clear button and the spinner inside it.\n */\nexport function ControlBox({\n className,\n boxRef,\n severity,\n disabled,\n readOnly,\n loading,\n density,\n start,\n prefix,\n prefixId,\n suffix,\n suffixId,\n clear,\n end,\n children,\n}: {\n /** More classes for the box, beside its own. */\n readonly className?: string | undefined;\n /** The box itself: what a picker popup opens beside. */\n readonly boxRef?: Ref<HTMLDivElement> | undefined;\n readonly severity: Severity | null;\n readonly disabled: boolean;\n readonly readOnly: boolean;\n readonly loading: boolean;\n readonly density: Density;\n /** Before the prefix: the search icon. */\n readonly start?: ReactNode;\n readonly prefix: ReactNode;\n readonly prefixId: string;\n readonly suffix: ReactNode;\n readonly suffixId: string;\n /** The clear button's name and action, while it shows. */\n readonly clear: {\n readonly label: string;\n readonly onClear: (event: MouseEvent) => void;\n } | null;\n /** After the spinner: the password's reveal button. */\n readonly end?: ReactNode;\n /** The native control. */\n readonly children: ReactNode;\n}) {\n return (\n <div\n ref={boxRef}\n className={classNames(\n \"gridkit-forms-control\",\n className,\n severity !== null && `is-${severity}`,\n disabled && \"is-disabled\",\n readOnly && \"is-readonly\",\n loading && \"is-loading\",\n densityClass(density),\n )}\n >\n {start}\n {hasNode(prefix) && (\n <span className=\"gridkit-forms-prefix\" id={prefixId}>\n {prefix}\n </span>\n )}\n {children}\n {clear !== null && (\n <button\n type=\"button\"\n className=\"gridkit-forms-clear-button\"\n tabIndex={-1}\n aria-label={clear.label}\n onMouseDown={keepFocus}\n onClick={clear.onClear}\n >\n <ClearIcon />\n </button>\n )}\n {loading && <span className=\"gridkit-forms-spinner\" aria-hidden=\"true\" />}\n {end}\n {hasNode(suffix) && (\n <span className=\"gridkit-forms-suffix\" id={suffixId}>\n {suffix}\n </span>\n )}\n </div>\n );\n}\n\nexport function hasNode(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n","// Bundlers replace `process.env.NODE_ENV` with a string; without one, as in\n// a browser loading the files unbundled, `process` does not exist.\ndeclare const process: { readonly env: { readonly NODE_ENV?: string } };\n\nfunction isDevelopment(): boolean {\n try {\n return process.env.NODE_ENV !== \"production\";\n } catch {\n return false;\n }\n}\n\nconst warned = new Set<string>();\n\n/** Warns once per page about `key`, in a development build only. */\nexport function warnOnce(key: string, message: string): void {\n if (warned.has(key) || !isDevelopment()) {\n return;\n }\n warned.add(key);\n console.warn(`@gridkitjs/forms: ${message}`);\n}\n","import { mostSevere, type FieldMessageInput } from \"@gridkitjs/forms-core\";\nimport {\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport { useSummaryEntry } from \"../form/formContext\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type FieldMode,\n type LabelPosition,\n type NecessityIndicator,\n} from \"../settings\";\nimport {\n FieldContext,\n useControlMessages,\n type FieldContextValue,\n type FieldControlState,\n} from \"./fieldContext\";\nimport { FieldHelp } from \"./FieldHelp\";\nimport { FieldMessages } from \"./FieldMessages\";\nimport {\n classNames,\n NecessityMarker,\n spanClass,\n useShownMessages,\n withLabelWidth,\n type FieldSpan,\n} from \"./parts\";\n\nexport interface FieldProps {\n /**\n * Names the input. Leave it out only when the input has an `aria-label`;\n * `labelPosition=\"hidden\"` keeps a label out of sight.\n */\n readonly label?: ReactNode;\n /** Help text under the control, read as part of its description. */\n readonly description?: ReactNode;\n /**\n * Longer help behind a button after the label, shown in a small panel\n * beside it and read out as it opens.\n */\n readonly help?: ReactNode;\n /** The app's messages, always shown; a string is an error. */\n readonly message?:\n FieldMessageInput | readonly FieldMessageInput[] | undefined;\n /** Marks the label, and tells the input a value is required. */\n readonly required?: boolean | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly necessityIndicator?: NecessityIndicator | undefined;\n readonly density?: Density | undefined;\n readonly mode?: FieldMode | undefined;\n readonly readOnly?: boolean | undefined;\n readonly disabled?: boolean | undefined;\n /** Columns taken in a `FormLayout`. */\n readonly span?: FieldSpan | undefined;\n /** The control's `id`; one is generated without it. */\n readonly id?: string | undefined;\n /** On the field's root. */\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n /** One input: a forms input, or the app's own through `useField`. */\n readonly children?: ReactNode;\n}\n\n/** Whether a floating label sits above the control rather than inside it. */\nfunction isRaised(state: FieldControlState | null, mode: FieldMode): boolean {\n if (mode === \"display\") {\n return true;\n }\n return (\n state !== null &&\n (state.focused || !state.empty || state.startAdornment === true)\n );\n}\n\n/**\n * One input with its label, required or optional marker, help button,\n * description and messages, wired to it for assistive technology: the label\n * names the control, the description and messages describe it, and\n * `aria-invalid` and `aria-required` follow the field. The input reads all of it from\n * context, so an app's own input gets the same through `useField`.\n *\n * The messages shown are the app's (`message`) and the input's own shown\n * ones, most serious first; the most serious sets the field's severity\n * class. A disabled field shows only the app's. Inside a `Form` they are\n * listed in its `MessageSummary`.\n */\nexport function Field({\n label,\n description,\n help,\n message,\n required = false,\n labelPosition,\n labelWidth,\n necessityIndicator,\n density,\n mode,\n readOnly,\n disabled,\n span,\n id,\n className,\n style,\n children,\n}: FieldProps) {\n const settings = useResolvedSettings({\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n });\n const generatedId = useId();\n const controlId = id ?? generatedId;\n const labelId = `${controlId}-label`;\n const descriptionId = `${controlId}-description`;\n const messagesId = `${controlId}-messages`;\n const hasLabel = label !== undefined && label !== null;\n const hasDescription = description !== undefined && description !== null;\n const hasHelp = help !== undefined && help !== null;\n\n const [controlMessages, setControlMessages] = useControlMessages();\n const [controlState, setControlState] = useState<FieldControlState | null>(\n null,\n );\n const shown = useShownMessages(controlMessages, message, settings.disabled);\n const severity = mostSevere(\n shown.map((shownMessage) => shownMessage.severity),\n );\n const describedBy = hasDescription\n ? `${descriptionId} ${messagesId}`\n : messagesId;\n\n const context = useMemo<FieldContextValue>(\n () => ({\n controlId,\n settings,\n describedBy,\n required,\n invalid: severity === \"error\",\n severity,\n setControlMessages,\n setControlState,\n }),\n [controlId, settings, describedBy, required, severity, setControlMessages],\n );\n\n // Marked when either the field or its input asks for a value.\n const marked = required || controlState?.required === true;\n const display = settings.mode === \"display\";\n const position =\n settings.labelPosition === \"floating\" && controlState?.labelBeside === true\n ? \"top\"\n : settings.labelPosition;\n const raised =\n position === \"floating\" && isRaised(controlState, settings.mode);\n\n const root = useRef<HTMLDivElement>(null);\n useSummaryEntry(controlId, hasLabel ? label : null, shown, root);\n useEffect(() => {\n if (hasLabel || display) {\n return;\n }\n const control = root.current?.ownerDocument.getElementById(controlId);\n if (\n control !== null &&\n control !== undefined &&\n !control.hasAttribute(\"aria-label\") &&\n !control.hasAttribute(\"aria-labelledby\") &&\n // A checkbox named by the label wrapped around it.\n !(\n control instanceof HTMLInputElement && (control.labels?.length ?? 0) > 0\n )\n ) {\n warnOnce(\n \"field-label\",\n 'A Field has no label and its input no aria-label, so the input has no name. Give the Field a label (labelPosition=\"hidden\" keeps it out of sight) or the input an aria-label.',\n );\n }\n }, [hasLabel, display, controlId]);\n\n const marker = (\n <NecessityMarker\n required={marked}\n indicator={settings.necessityIndicator}\n strings={settings.messages}\n />\n );\n const labelClass = classNames(\n \"gridkit-forms-field-label\",\n position === \"hidden\" && \"gridkit-forms-sr-only\",\n );\n // In display mode there is no control for a <label> to point at.\n const labelElement = !hasLabel ? null : display ? (\n <span className={labelClass} id={labelId}>\n {label}\n {marker}\n </span>\n ) : (\n <label className={labelClass} id={labelId} htmlFor={controlId}>\n {label}\n {marker}\n </label>\n );\n const labelInside = position === \"floating\" && !display;\n // The label and its help button on one line. A floating label stays in\n // the control, leaving the button alone on the row.\n const heading = hasHelp ? (\n <div className=\"gridkit-forms-field-label-row\">\n {!labelInside && labelElement}\n <FieldHelp\n id={`${controlId}-help`}\n label={settings.messages.fieldHelp}\n describedBy={hasLabel ? labelId : undefined}\n help={help}\n />\n </div>\n ) : (\n !labelInside && labelElement\n );\n\n return (\n <div\n ref={root}\n className={classNames(\n \"gridkit-forms-field\",\n `is-label-${position}`,\n raised && \"is-label-raised\",\n marked && \"is-required\",\n severity !== null && `is-${severity}`,\n settings.disabled && \"is-disabled\",\n settings.readOnly && \"is-readonly\",\n display && \"is-display\",\n settings.density !== \"standard\" && `is-${settings.density}`,\n spanClass(span),\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n role={display && hasLabel ? \"group\" : undefined}\n aria-labelledby={display && hasLabel ? labelId : undefined}\n aria-describedby={display ? describedBy : undefined}\n >\n {heading}\n <div className=\"gridkit-forms-field-control\">\n {labelInside && labelElement}\n <FormSettingsProvider settings={settings}>\n <FieldContext value={context}>{children}</FieldContext>\n </FormSettingsProvider>\n </div>\n {hasDescription && (\n <p className=\"gridkit-forms-field-description\" id={descriptionId}>\n {description}\n </p>\n )}\n <FieldMessages\n id={messagesId}\n messages={shown}\n strings={settings.messages}\n />\n </div>\n );\n}\n","import {\n createFieldRegistry,\n type FieldMessage,\n type FieldRegistry,\n type RegisteredField,\n} from \"@gridkitjs/forms-core\";\nimport { compareDocumentOrder } from \"@gridkitjs/forms-dom\";\nimport {\n createContext,\n useContext,\n useLayoutEffect,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\n\n/** A field as a `MessageSummary` lists it. */\nexport interface SummaryField extends RegisteredField {\n /** What the summary names the field by; `null` lists its messages alone. */\n readonly label: ReactNode;\n /** The field's root, which places it in document order. */\n readonly element: HTMLElement;\n}\n\n/** A collapsible `FormSection`, which opens before focus moves inside it. */\nexport interface CollapsibleSection {\n readonly element: HTMLElement;\n readonly expand: () => void;\n}\n\n/** What a `Form` shares with the fields, sections and summary inside it. */\nexport interface FormContextValue {\n readonly registry: FieldRegistry<SummaryField>;\n /** Adds a collapsible section, and returns what removes it. */\n readonly addSection: (section: CollapsibleSection) => () => void;\n /**\n * Sets the form's `MessageSummary` element while it shows, which a\n * refused submit focuses, and returns what unsets it.\n */\n readonly setSummary: (element: HTMLElement) => () => void;\n readonly getSummary: () => HTMLElement | null;\n /** Opens every collapsed section around `control`, then focuses it. */\n readonly focusControl: (control: HTMLElement) => void;\n}\n\n/** The context of one `Form`, made once when it mounts. */\nexport function createFormContext(): FormContextValue {\n const sections = new Set<CollapsibleSection>();\n let summary: HTMLElement | null = null;\n return {\n registry: createFieldRegistry<SummaryField>((a, b) =>\n compareDocumentOrder(a.element, b.element),\n ),\n addSection(section) {\n sections.add(section);\n return () => {\n sections.delete(section);\n };\n },\n setSummary(element) {\n summary = element;\n return () => {\n if (summary === element) {\n summary = null;\n }\n };\n },\n getSummary: () => summary,\n focusControl(control) {\n // A control in a collapsed section is hidden and takes no focus\n // until the section has opened, so the opening renders first.\n flushSync(() => {\n for (const section of sections) {\n if (section.element.contains(control)) {\n section.expand();\n }\n }\n });\n control.focus();\n },\n };\n}\n\nexport const FormContext = createContext<FormContextValue | null>(null);\n\n/** The `Form` around the caller, or `null` outside one. */\nexport function useFormContext(): FormContextValue | null {\n return useContext(FormContext);\n}\n\n/**\n * Lists a field's shown `messages` in its form's summary, under `id` (the\n * element a summary link points at) and `label`, while it has any.\n */\nexport function useSummaryEntry(\n id: string,\n label: ReactNode,\n messages: readonly FieldMessage[],\n root: RefObject<HTMLElement | null>,\n): void {\n const form = useFormContext();\n useLayoutEffect(() => {\n const element = root.current;\n if (form === null || element === null || messages.length === 0) {\n return undefined;\n }\n return form.registry.register({ id, label, messages, element });\n }, [form, id, label, messages, root]);\n}\n","import {\n defaultFormsMessages,\n resolveFormsMessages,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\";\n\n/** How tightly fields are drawn. */\nexport type Density = \"compact\" | \"standard\" | \"comfortable\";\n\n/** `\"display\"` shows a field's value as text, with no control to operate. */\nexport type FieldMode = \"edit\" | \"display\";\n\n/**\n * Where a field's label sits: above the control (`\"top\"`), inside it until\n * the field is focused or filled (`\"floating\"`), beside it (`\"start\"`), or\n * nowhere visible while still naming the control (`\"hidden\"`).\n */\nexport type LabelPosition = \"top\" | \"floating\" | \"start\" | \"hidden\";\n\n/**\n * Which fields a label marks: required ones with an asterisk\n * (`\"required\"`), the others with \"(optional)\" (`\"optional\"`), or none.\n */\nexport type NecessityIndicator = \"required\" | \"optional\" | \"none\";\n\n/** What every field under a level of a form shares, worked out for that level. */\nexport interface FormSettings {\n readonly mode: FieldMode;\n readonly density: Density;\n readonly labelPosition: LabelPosition;\n readonly necessityIndicator: NecessityIndicator;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n readonly locale: Intl.LocalesArgument;\n /** The app's strings, laid over the defaults; `undefined` for none. */\n readonly messageOverrides: Partial<FormsMessages> | undefined;\n /** Every string, the overrides laid over the defaults for `locale`. */\n readonly messages: FormsMessages;\n}\n\n/** What one level (a form, a section, a field) sets; `undefined` takes the level above's. */\nexport interface FormSettingsOverrides {\n readonly mode?: FieldMode | undefined;\n readonly density?: Density | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n readonly necessityIndicator?: NecessityIndicator | undefined;\n readonly readOnly?: boolean | undefined;\n readonly disabled?: boolean | undefined;\n readonly locale?: Intl.LocalesArgument;\n readonly messages?: Partial<FormsMessages> | undefined;\n}\n\nconst DEFAULT_SETTINGS: FormSettings = {\n mode: \"edit\",\n density: \"standard\",\n labelPosition: \"top\",\n necessityIndicator: \"required\",\n readOnly: false,\n disabled: false,\n locale: undefined,\n messageOverrides: undefined,\n messages: defaultFormsMessages,\n};\n\nconst FormSettingsContext = createContext<FormSettings>(DEFAULT_SETTINGS);\n\n/** The settings of the nearest level above, or the defaults outside any. */\nexport function useFormSettings(): FormSettings {\n return useContext(FormSettingsContext);\n}\n\n/**\n * `overrides` laid over `parent`: the nearest level wins, except that\n * `readOnly` and `disabled` set anywhere above stay set.\n */\nexport function resolveFormSettings(\n parent: FormSettings,\n overrides: FormSettingsOverrides,\n): FormSettings {\n const locale = overrides.locale ?? parent.locale;\n const messageOverrides =\n overrides.messages === undefined\n ? parent.messageOverrides\n : { ...parent.messageOverrides, ...overrides.messages };\n return {\n mode: overrides.mode ?? parent.mode,\n density: overrides.density ?? parent.density,\n labelPosition: overrides.labelPosition ?? parent.labelPosition,\n necessityIndicator:\n overrides.necessityIndicator ?? parent.necessityIndicator,\n readOnly: parent.readOnly || overrides.readOnly === true,\n disabled: parent.disabled || overrides.disabled === true,\n locale,\n messageOverrides,\n messages:\n locale === parent.locale && messageOverrides === parent.messageOverrides\n ? parent.messages\n : resolveFormsMessages(messageOverrides, locale),\n };\n}\n\n/**\n * The settings of the level above with `overrides` laid over them,\n * memoized on each override, so a level re-rendering with the same props\n * re-renders none of its fields.\n */\nexport function useResolvedSettings(\n overrides: FormSettingsOverrides,\n): FormSettings {\n const parent = useFormSettings();\n const {\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n locale,\n messages,\n } = overrides;\n return useMemo(\n () =>\n resolveFormSettings(parent, {\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n locale,\n messages,\n }),\n [\n parent,\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n locale,\n messages,\n ],\n );\n}\n\n/** Gives every field under it `settings`. */\nexport function FormSettingsProvider({\n settings,\n children,\n}: {\n readonly settings: FormSettings;\n readonly children: ReactNode;\n}) {\n return <FormSettingsContext value={settings}>{children}</FormSettingsContext>;\n}\n","import { attachOverlay, writingDirection } from \"@gridkitjs/forms-dom\";\nimport { useLayoutEffect, useReducer, useState, type ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { colorSchemeOf, type PickerScope } from \"../picker/usePickerPopup\";\nimport { classNames } from \"./parts\";\n\n/**\n * Where a field's help is: `closed`; `opening`, its panel drawn with the\n * live region in it still empty; `open`, the text in that region. The text\n * goes in a frame after the region appears, because a screen reader reads\n * what changes in a live region, not what it held as it appeared.\n */\ntype HelpState =\n | { readonly kind: \"closed\" }\n | { readonly kind: \"opening\"; readonly scope: PickerScope }\n | { readonly kind: \"open\"; readonly scope: PickerScope };\n\ntype HelpAction =\n | { readonly type: \"open\"; readonly scope: PickerScope }\n | { readonly type: \"fill\" }\n | { readonly type: \"close\" };\n\nconst CLOSED: HelpState = { kind: \"closed\" };\n\nfunction helpReducer(state: HelpState, action: HelpAction): HelpState {\n switch (action.type) {\n case \"open\":\n return state.kind === \"closed\"\n ? { kind: \"opening\", scope: action.scope }\n : state;\n case \"fill\":\n return state.kind === \"opening\"\n ? { kind: \"open\", scope: state.scope }\n : state;\n case \"close\":\n return CLOSED;\n }\n}\n\n/** The space between the button and the panel, for its shadow. */\nconst ANCHOR_GAP = 4;\n\nfunction HelpIcon() {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3\" />\n <path d=\"M12 17h.01\" />\n </svg>\n );\n}\n\n/**\n * A field's help toggletip: a button after the label, outside the\n * `<label>` so it never joins the control's name, that shows `help` in a\n * small panel beside it. The panel is portalled into `document.body`, so\n * no scrolling ancestor clips it, in the button's colour scheme and `dir`,\n * and its text sits in a `role=\"status\"` region, read out as it opens\n * while focus stays on the button. Pressing the button again, Escape, a\n * press outside or focus leaving closes it, through forms-dom's\n * `attachOverlay`.\n */\nexport function FieldHelp({\n id,\n label,\n describedBy,\n help,\n}: {\n /** The panel's id. */\n readonly id: string;\n /** The button's accessible name. */\n readonly label: string;\n /** The field label's id, read after the button's name. */\n readonly describedBy: string | undefined;\n readonly help: ReactNode;\n}) {\n const [state, dispatch] = useReducer(helpReducer, CLOSED);\n const [button, setButton] = useState<HTMLButtonElement | null>(null);\n const [panel, setPanel] = useState<HTMLElement | null>(null);\n\n useLayoutEffect(() => {\n if (button === null || panel === null) {\n return undefined;\n }\n const frame = requestAnimationFrame(() => {\n dispatch({ type: \"fill\" });\n });\n const detach = attachOverlay(button, panel, {\n placement: \"bottom-start\",\n gap: ANCHOR_GAP,\n initialFocus: \"none\",\n // Focus never enters the panel, so it has nothing to give back, and\n // closing as focus leaves the button must not pull it back there.\n returnFocusTo: null,\n onDismiss: () => {\n dispatch({ type: \"close\" });\n },\n });\n return () => {\n cancelAnimationFrame(frame);\n detach();\n };\n }, [button, panel]);\n\n const opened = state.kind !== \"closed\";\n return (\n <>\n <button\n ref={setButton}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-field-help-button\",\n opened && \"is-open\",\n )}\n aria-label={label}\n aria-describedby={describedBy}\n aria-expanded={opened}\n aria-controls={opened ? id : undefined}\n onClick={(event) => {\n const target = event.currentTarget;\n dispatch(\n opened\n ? { type: \"close\" }\n : {\n type: \"open\",\n scope: {\n scheme: colorSchemeOf(target),\n direction: writingDirection(target),\n },\n },\n );\n }}\n // The overlay watches focus leaving its panel, which focus never\n // enters here, so focus moving on from the button closes it. Focus\n // going nowhere, as a press on the panel's text sends it, does not.\n onBlur={(event) => {\n const next = event.relatedTarget;\n if (opened && next !== null && panel?.contains(next) !== true) {\n dispatch({ type: \"close\" });\n }\n }}\n >\n <HelpIcon />\n </button>\n {opened &&\n createPortal(\n <div\n ref={setPanel}\n id={id}\n className={classNames(\n \"gridkit-forms-field-help\",\n state.scope.scheme !== null && `is-${state.scope.scheme}`,\n )}\n dir={state.scope.direction}\n role=\"status\"\n >\n {state.kind === \"open\" ? help : null}\n </div>,\n document.body,\n )}\n </>\n );\n}\n","import {\n POPUP_CLOSED,\n popupReducer,\n type PopupAction,\n type PopupCloseReason,\n type PopupOpenChange,\n type PopupOpenReason,\n type PopupState,\n type WritingDirection,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachOverlay,\n writingDirection,\n type OverlayDismissReason,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n type RefCallback,\n} from \"react\";\n\n/**\n * What a popup portalled out of its field copies from it, read as it\n * opens: the field's colour scheme where a palette pins one (the theme\n * pins the popup to it with `is-light` or `is-dark`), else `null` to\n * follow the page, and the writing direction, which lays out its content\n * and places it.\n */\nexport interface PickerScope {\n readonly scheme: \"light\" | \"dark\" | null;\n readonly direction: WritingDirection;\n}\n\n/** What `usePickerPopup` reads, on every render. */\nexport interface PickerPopupOptions {\n /** Whether the field can show its popup now: drawn, enabled and not read-only. */\n readonly enabled: boolean;\n /** The popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n /**\n * The element in the field focus goes back to as the popup closes when\n * focus was not on a control in `anchor` as it opened: the first segment.\n */\n readonly returnFocusTo: (anchor: HTMLElement) => HTMLElement | null;\n /** Where focus goes in the popup as it opens: its chosen day; its first control by default. */\n readonly initialFocus?:\n ((panel: HTMLElement) => HTMLElement | null) | undefined;\n}\n\n/** What `usePickerPopup` gives the field that calls it. */\nexport interface PickerPopup {\n readonly state: PopupState;\n /** Read as the popup opened; `null` while it is closed. */\n readonly scope: PickerScope | null;\n readonly open: (reason: PopupOpenReason) => void;\n /**\n * Closes it, handing focus back to the field unless it left for\n * somewhere else: to `returnTo` when given (the picker button, for Tab\n * out of the popup), else to where it was as the popup opened.\n */\n readonly close: (reason: PopupCloseReason, returnTo?: HTMLElement) => void;\n /** Its button: opens it, or closes it. */\n readonly toggle: () => void;\n /** Whether `node` is in the popup, which the field's focus group counts as inside the field. */\n readonly isInside: (node: Node) => boolean;\n /**\n * What Escape in the popup does before it closes it: a handler that\n * returns `true` has dealt with the key (a calendar's month view going\n * back to the days), and the popup stays open. `null` removes it.\n */\n readonly setEscapeHandler: (handler: (() => boolean) | null) => void;\n /** The element the popup opens beside: the field's box. */\n readonly setAnchor: RefCallback<HTMLElement>;\n /** The popup's panel, drawn while it is open. */\n readonly setPanel: RefCallback<HTMLElement>;\n}\n\n/** The space between the field's box and the popup, for its shadow. */\nconst ANCHOR_GAP = 4;\n\n/** The colour scheme `element` is drawn in, when it is exactly one. */\nexport function colorSchemeOf(element: Element): PickerScope[\"scheme\"] {\n const { colorScheme } = getComputedStyle(element);\n return colorScheme === \"light\" || colorScheme === \"dark\" ? colorScheme : null;\n}\n\n/**\n * A field's picker popup: whether it is open (forms-core's\n * `popupReducer`, telling `onOpenChange` each change once), and, while its\n * panel is drawn, forms-dom's `attachOverlay` on it, below the field's box,\n * with focus moved in and kept there by Tab.\n *\n * Closing detaches the overlay at once, so after a press outside focus\n * goes back to the field before the browser moves it for the press, and\n * the field then blurs as it would without a popup. Focus leaving the\n * popup for somewhere else (`\"blur\"`) closes it without taking focus\n * back. A field that stops being `enabled` closes it with `\"disabled\"`.\n */\nexport function usePickerPopup(options: PickerPopupOptions): PickerPopup {\n const [state, setState] = useState<PopupState>(POPUP_CLOSED);\n const [scope, setScope] = useState<PickerScope | null>(null);\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n const [panel, setPanel] = useState<HTMLElement | null>(null);\n const latestState = useRef(state);\n const latestOptions = useRef(options);\n const panelRef = useRef<HTMLElement | null>(null);\n const escapeHandler = useRef<(() => boolean) | null>(null);\n const returnTarget = useRef<HTMLElement | null>(null);\n const closing = useRef<PopupCloseReason | null>(null);\n const detachOverlay = useRef<(() => void) | null>(null);\n useLayoutEffect(() => {\n latestOptions.current = options;\n panelRef.current = panel;\n });\n\n const dispatch = useCallback((action: PopupAction): void => {\n const step = popupReducer(latestState.current, action);\n if (step.change === null) {\n return;\n }\n latestState.current = step.state;\n setState(step.state);\n if (!step.change.open) {\n closing.current = step.change.reason;\n // Detached now rather than once the panel leaves the page, so focus\n // is back in the field before the press that closed it moves it on.\n detachOverlay.current?.();\n detachOverlay.current = null;\n setScope(null);\n }\n latestOptions.current.onOpenChange?.(step.change);\n }, []);\n\n const open = useCallback(\n (reason: PopupOpenReason): void => {\n if (\n anchor === null ||\n !latestOptions.current.enabled ||\n latestState.current.kind === \"open\"\n ) {\n return;\n }\n const active = anchor.ownerDocument.activeElement;\n returnTarget.current =\n active instanceof HTMLElement &&\n anchor.contains(active) &&\n active.matches(\"input\")\n ? active\n : latestOptions.current.returnFocusTo(anchor);\n closing.current = null;\n setScope({\n scheme: colorSchemeOf(anchor),\n direction: writingDirection(anchor),\n });\n dispatch({ type: \"open\", reason });\n },\n [anchor, dispatch],\n );\n\n const close = useCallback(\n (reason: PopupCloseReason, returnTo?: HTMLElement): void => {\n if (returnTo !== undefined && latestState.current.kind === \"open\") {\n returnTarget.current = returnTo;\n }\n dispatch({ type: \"close\", reason });\n },\n [dispatch],\n );\n\n const toggle = useCallback((): void => {\n if (latestState.current.kind === \"open\") {\n close(\"button\");\n } else {\n open(\"button\");\n }\n }, [open, close]);\n\n const isOpen = state.kind === \"open\";\n const { enabled } = options;\n useLayoutEffect(() => {\n if (!enabled && isOpen) {\n close(\"disabled\");\n }\n }, [enabled, isOpen, close]);\n\n useLayoutEffect(() => {\n if (anchor === null || panel === null) {\n return undefined;\n }\n const onDismiss = (reason: OverlayDismissReason): void => {\n if (reason === \"escape\" && escapeHandler.current?.() === true) {\n return;\n }\n close(reason);\n };\n const detach = attachOverlay(anchor, panel, {\n placement: \"bottom-start\",\n gap: ANCHOR_GAP,\n trapFocus: true,\n initialFocus: latestOptions.current.initialFocus?.(panel) ?? \"first\",\n returnFocusTo: null,\n // Focus moving out of the panel has gone somewhere, and stays there;\n // the window losing focus leaves it in the panel, to come back to the\n // field.\n returnFocusFallback: () =>\n closing.current === \"blur\" &&\n !panel.contains(panel.ownerDocument.activeElement)\n ? null\n : returnTarget.current,\n onDismiss,\n });\n detachOverlay.current = detach;\n return () => {\n detach();\n if (detachOverlay.current === detach) {\n detachOverlay.current = null;\n }\n };\n }, [anchor, panel, close]);\n\n return {\n state,\n scope,\n open,\n close,\n toggle,\n isInside: useCallback(\n (node: Node) => panelRef.current?.contains(node) === true,\n [],\n ),\n setEscapeHandler: useCallback((handler: (() => boolean) | null) => {\n escapeHandler.current = handler;\n }, []),\n setAnchor,\n setPanel,\n };\n}\n","import type {\n FieldMessage,\n FormsMessages,\n Severity,\n} from \"@gridkitjs/forms-core\";\nimport type { ReactNode } from \"react\";\n\nfunction Icon({ children }: { readonly children: ReactNode }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n {children}\n </svg>\n );\n}\n\n/**\n * A different shape for each severity, so it never rests on colour alone:\n * a cross, an exclamation mark in a triangle, an \"i\" and a tick.\n */\nexport function SeverityIcon({ severity }: { readonly severity: Severity }) {\n switch (severity) {\n case \"error\":\n return (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"m15 9-6 6\" />\n <path d=\"m9 9 6 6\" />\n </Icon>\n );\n case \"warning\":\n return (\n <Icon>\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n </Icon>\n );\n case \"info\":\n return (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n </Icon>\n );\n case \"success\":\n return (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"m9 12 2 2 4-4\" />\n </Icon>\n );\n }\n}\n\n/**\n * A field's message area: always in the page, empty when there is nothing\n * to say, and a polite live region, so a message that appears as the user\n * leaves the field is read without moving focus. Each message is read\n * after its severity's name, which is visually hidden; the icon says it to\n * the eye.\n */\nexport function FieldMessages({\n id,\n messages,\n strings,\n}: {\n readonly id: string;\n readonly messages: readonly FieldMessage[];\n readonly strings: FormsMessages;\n}) {\n return (\n <div className=\"gridkit-forms-field-messages\" id={id} aria-live=\"polite\">\n {messages.map((message, index) => (\n <p\n // Messages carry no id, and two may share a text.\n key={`${String(index)}:${message.text}`}\n className={`gridkit-forms-message is-${message.severity}`}\n >\n <span className=\"gridkit-forms-message-icon\" aria-hidden=\"true\">\n <SeverityIcon severity={message.severity} />\n </span>\n <span className=\"gridkit-forms-sr-only\">\n {`${strings.severityLabel(message.severity)}: `}\n </span>\n <span className=\"gridkit-forms-message-text\">{message.text}</span>\n </p>\n ))}\n </div>\n );\n}\n","import type { Ref } from \"react\";\n\n/** Points `ref` at `element`, and returns what lets go of it again. */\nexport function setRef<T>(\n ref: Ref<T> | undefined,\n element: T,\n): (() => void) | null {\n if (typeof ref === \"function\") {\n const cleanup = ref(element);\n return typeof cleanup === \"function\"\n ? cleanup\n : () => {\n ref(null);\n };\n }\n if (ref === undefined || ref === null) {\n return null;\n }\n ref.current = element;\n return () => {\n ref.current = null;\n };\n}\n","import {\n createFieldController,\n hasError,\n mostSevere,\n resolveFormsMessages,\n sortFieldMessages,\n toFieldMessages,\n type FieldController,\n type FieldMessage,\n type FieldMessageInput,\n type FieldOptions,\n type ChangeCause,\n type FieldPhase,\n type FieldState,\n type FormatContext,\n type InputFilter,\n type Formatter,\n type FormsMessages,\n type NoDetails,\n type ParseContext,\n type ParseResult,\n type Parser,\n type Severity,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachTextInput,\n attachToggle,\n scheduleTimeout,\n type AttachedTextInput,\n type AttachedToggle,\n type TextControl,\n type TextInputOptions,\n type ToggleOptions,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactElement,\n type Ref,\n type RefCallback,\n} from \"react\";\nimport { DisplayValue } from \"./DisplayValue\";\nimport type { FieldClearEvent, FieldHandlers } from \"./events\";\nimport {\n useFieldContext,\n type FieldContextValue,\n type FieldControlState,\n} from \"./field/fieldContext\";\nimport { useFormContext, type FormContextValue } from \"./form/formContext\";\nimport { setRef } from \"./refs\";\nimport { useFormSettings, type FieldMode } from \"./settings\";\n\n/** What an input does from code: focus it, read it, change it. */\nexport interface InputHandle<V> {\n /** The focusable element, while it is in the page. */\n readonly element: HTMLElement | null;\n focus(options?: FocusOptions): void;\n blur(): void;\n getValue(): V | null;\n getText(): string;\n /** `onBeforeChange`, `onChange` and `onValidate`, with `source: \"api\"`; no commit. */\n setValue(value: V | null): void;\n /** Back to `defaultValue`, or `null`, as `setValue` changes it. */\n reset(): void;\n /** Shows the field's messages from now on, as a commit attempt would. */\n revealMessages(): void;\n}\n\n/** How an input reads, writes and submits its value. */\nexport interface FieldInputKind<V, D extends object = NoDetails> {\n /** The input's own reading of text, which a `parse` prop can wrap. */\n readonly defaultParse: (\n text: string,\n context: ParseContext<V>,\n ) => ParseResult<V>;\n /** The input's own writing of the value, which a `format` prop can wrap. */\n readonly defaultFormat: (\n value: V | null,\n context: FormatContext<V>,\n ) => string;\n /**\n * The value as its hidden input submits it, the same in every locale.\n * Never called with `null`, which submits `\"\"`.\n */\n readonly serialize: (value: V) => string;\n /** Whether two values are one; `Object.is` by default. Never called with `null`. */\n readonly equals?: ((a: V, b: V) => boolean) | undefined;\n /** The input's own details, added to every event it fires. */\n readonly details?:\n ((current: FieldState<V>, previous: FieldState<V>) => D) | undefined;\n /**\n * The input's own judgement of each edit the app's `onBeforeInput` lets\n * through: a number input refusing letters and typing its decimals.\n */\n readonly filterInput?: InputFilter<Event> | undefined;\n}\n\n/** The props `useFieldInput` reads; an input passes on its own. */\nexport interface FieldInputProps<\n V,\n E extends TextControl = HTMLInputElement,\n D extends object = NoDetails,\n> extends FieldHandlers<V, D> {\n /** Present, `null` included, means controlled. */\n readonly value?: V | null | undefined;\n /** The value of an uncontrolled field at first, and what `reset` returns to. */\n readonly defaultValue?: V | null | undefined;\n /** The app's reading of typed text; `context.defaultParse` is the input's own. */\n readonly parse?: Parser<V> | undefined;\n /** The app's writing of the value; `context.defaultFormat` is the input's own. */\n readonly format?: Formatter<V> | undefined;\n readonly validate?: Validator<V> | readonly Validator<V>[] | undefined;\n /**\n * The control needs a value: it sets `aria-required` and marks the label\n * of the `Field` around it. The input adds the check to `validate`.\n */\n readonly required?: boolean | undefined;\n /** The app's messages, always shown with the field's own; a string is an error. */\n readonly message?:\n FieldMessageInput | readonly FieldMessageInput[] | undefined;\n /** Shows the error state with no message, for a form library that shows its errors elsewhere. */\n readonly invalid?: boolean | undefined;\n /** Called first when the field is cleared, before its change and commit. */\n readonly onClear?: ((event: FieldClearEvent<V>) => void) | undefined;\n /** Submits the value under this name, through a hidden input. */\n readonly name?: string | undefined;\n /** The `id` of a `<form>` elsewhere in the page that the value belongs to. */\n readonly form?: string | undefined;\n readonly readOnly?: boolean | undefined;\n /** Disabled, and not submitted. */\n readonly disabled?: boolean | undefined;\n /** `\"display\"` shows the value as text; the `Field` or form around it sets it otherwise. */\n readonly mode?: FieldMode | undefined;\n /** The control's `id` outside a `Field`; inside one, the field's is used. */\n readonly id?: string | undefined;\n readonly locale?: Intl.LocalesArgument;\n /** Strings laid over the default English ones. */\n readonly messages?: Partial<FormsMessages> | undefined;\n /** The native control. */\n readonly ref?: Ref<E> | undefined;\n readonly handleRef?: Ref<InputHandle<V>> | undefined;\n}\n\n/** How the input that calls `useFieldInput` behaves, which its own props decide. */\nexport interface FieldInputOptions extends TextInputOptions {\n /**\n * Something sits at the control's start (a prefix, an icon), where a\n * resting floating label would cover it, so the label stays raised.\n */\n readonly startAdornment?: boolean | undefined;\n /**\n * Milliseconds typing must pause before the text is read (`onChange`),\n * for a search box; `onInput` fires at once and a commit reads at once.\n */\n readonly changeDelay?: number | undefined;\n /**\n * The control is a checkbox, flipped whole, rather than text: forms-dom's\n * toggle behaviour drives it, every flip commits, leaving commits nothing\n * more, and its label sits beside it, so a `Field`'s floating label stays\n * above. `readOnly` is passed on by the hook.\n */\n readonly toggle?: Omit<ToggleOptions, \"readOnly\"> | undefined;\n}\n\n/** The props `useFieldInput` gives the native control. */\nexport interface FieldControlBinding<E extends TextControl> {\n readonly ref: RefCallback<E>;\n readonly id: string;\n /**\n * The text on screen, for a text control. The control's live text is\n * forms-dom's, so it is never a controlled `value`.\n */\n readonly defaultValue: string | undefined;\n /** Whether a toggle is checked when it is first drawn; forms-dom keeps it after. */\n readonly defaultChecked: boolean | undefined;\n /** A text control's native `readOnly`; a toggle, which ignores it, has `aria-readonly`. */\n readonly readOnly: boolean | undefined;\n readonly \"aria-readonly\": true | undefined;\n readonly disabled: boolean | undefined;\n readonly \"aria-invalid\": true | undefined;\n /** The description and messages of the `Field` around it. */\n readonly \"aria-describedby\": string | undefined;\n readonly \"aria-required\": true | undefined;\n}\n\n/** What `useFieldInput` gives the input that calls it, to draw. */\nexport interface FieldInput<V, E extends TextControl = HTMLInputElement> {\n readonly state: FieldState<V>;\n /** The text on screen. */\n readonly text: string;\n /**\n * The messages to show: the app's `message`, and the field's own from\n * the first commit attempt or `revealMessages` on, except while\n * disabled. A `Field` around the input lists them itself.\n */\n readonly messages: readonly FieldMessage[];\n /**\n * The most serious message shown, under the input or anywhere in the\n * `Field` around it, or `\"error\"` for `invalid`: the control box's\n * border colour.\n */\n readonly severity: Severity | null;\n /** Fires `onClear`, then empties the field and commits it (`source` and `trigger` `\"clear\"`). */\n readonly clear: (nativeEvent: Event | null) => void;\n /** The value now, read at the moment of the call rather than at render. */\n readonly getValue: () => V | null;\n /**\n * The change chain to `value`, with `cause`'s source and native event,\n * and no commit: a step, a part of a composite input.\n */\n readonly change: (value: V | null, cause: ChangeCause<Event>) => void;\n /** The props', the `Field`'s or the form's. */\n readonly mode: FieldMode;\n /** The value as text, to draw in place of the control in display mode. */\n readonly displayValue: ReactElement;\n /** Spread onto the native control. */\n readonly controlProps: FieldControlBinding<E>;\n /** The hidden input carrying `name`, to draw beside the control; `null` without one. */\n readonly hiddenInput: ReactElement | null;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/** Whether the control has focus, from where the field is in an edit. */\nexport function isFocused(phase: FieldPhase<unknown>): boolean {\n switch (phase.kind) {\n case \"editing\":\n case \"leaving\":\n return true;\n case \"checking\":\n return !phase.leaving;\n default:\n return false;\n }\n}\n\n/** The forms-dom behaviour driving the control. */\ntype AttachedBehaviour =\n | { readonly kind: \"text\"; readonly handle: AttachedTextInput }\n | { readonly kind: \"toggle\"; readonly handle: AttachedToggle };\n\nfunction attachBehaviour<V, D extends object>(\n control: TextControl,\n controller: FieldController<V, D, Event>,\n toggle: boolean,\n): AttachedBehaviour {\n if (!toggle) {\n return { kind: \"text\", handle: attachTextInput(control, controller) };\n }\n if (!(control instanceof HTMLInputElement)) {\n throw new TypeError(\"A toggle's control must be an <input>.\");\n }\n // A toggle input's value is always a boolean: `Checkbox` and `Switch`\n // are its only callers, and each is typed so.\n const toggleController = controller as unknown as FieldController<\n boolean,\n D,\n Event\n >;\n return { kind: \"toggle\", handle: attachToggle(control, toggleController) };\n}\n\n/** `validate` as a list. */\nexport function validatorsOf<V>(\n validate: Validator<V> | readonly Validator<V>[] | undefined,\n): readonly Validator<V>[] {\n if (validate === undefined) {\n return [];\n }\n return typeof validate === \"function\" ? [validate] : validate;\n}\n\n/** The settings an input takes from its own props, its `Field` and its form. */\nexport function useInputSettings(\n props: Pick<\n FieldInputProps<unknown>,\n \"readOnly\" | \"disabled\" | \"mode\" | \"locale\" | \"messages\"\n >,\n) {\n const field = useFieldContext();\n const form = useFormContext();\n const formSettings = useFormSettings();\n const ownId = useId();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const messages = useMemo(\n () =>\n props.messages === undefined && props.locale === undefined\n ? settings.messages\n : resolveFormsMessages(\n { ...settings.messageOverrides, ...props.messages },\n locale,\n ),\n [props.messages, props.locale, settings, locale],\n );\n return {\n field,\n form,\n settings,\n ownId,\n readOnly: props.readOnly === true || settings.readOnly,\n disabled: props.disabled === true || settings.disabled,\n mode: props.mode ?? settings.mode,\n locale,\n messages,\n };\n}\n\n/**\n * Passes a controlled `value` to the field after every render, takes a\n * form's reveal for the field while it is in one, and cancels what the\n * field waits for on unmount.\n */\nexport function useControllerLifecycle<V>(\n controller: Pick<FieldController<V>, \"sync\" | \"reveal\" | \"destroy\">,\n value: V | null | undefined,\n form: FormContextValue | null,\n): void {\n useLayoutEffect(() => {\n if (value !== undefined) {\n controller.sync(value);\n }\n });\n useEffect(\n () => () => {\n controller.destroy();\n },\n [controller],\n );\n useLayoutEffect(\n () => form?.registry.addRevealer(controller.reveal),\n [form, controller],\n );\n}\n\n/**\n * The messages an input shows (`own`, the field's, and the app's\n * `message`) and the most serious among them and the `Field`'s, or\n * `\"error\"` for `invalid`.\n */\nexport function useShownMessages(\n own: readonly FieldMessage[],\n message: FieldInputProps<unknown>[\"message\"],\n invalid: boolean | undefined,\n field: FieldContextValue | null,\n): {\n readonly shown: readonly FieldMessage[];\n readonly severity: Severity | null;\n} {\n const shown = useMemo(\n () =>\n message === undefined\n ? own\n : sortFieldMessages([...own, ...toFieldMessages(message, \"app\")]),\n [own, message],\n );\n const fieldSeverity = field?.severity ?? null;\n const severity =\n invalid === true\n ? \"error\"\n : mostSevere([\n ...shown.map((shownMessage) => shownMessage.severity),\n ...(fieldSeverity === null ? [] : [fieldSeverity]),\n ]);\n return { shown, severity };\n}\n\n/** Tells the `Field` around an input its shown messages and its control's state, until it goes. */\nexport function useFieldReport(\n field: FieldContextValue | null,\n ownId: string,\n shown: readonly FieldMessage[],\n {\n focused,\n empty,\n required = false,\n startAdornment = false,\n labelBeside = false,\n }: FieldControlState,\n): void {\n const setControlMessages = field?.setControlMessages;\n useLayoutEffect(() => {\n if (setControlMessages === undefined) {\n return undefined;\n }\n setControlMessages(ownId, shown);\n return () => {\n setControlMessages(ownId, NO_MESSAGES);\n };\n }, [setControlMessages, ownId, shown]);\n\n const setControlState = field?.setControlState;\n useLayoutEffect(() => {\n if (setControlState === undefined) {\n return undefined;\n }\n setControlState({\n focused,\n empty,\n required,\n startAdornment,\n labelBeside,\n });\n return () => {\n setControlState(null);\n };\n }, [setControlState, focused, empty, required, startAdornment, labelBeside]);\n}\n\n/**\n * Binds a native text control, or with `options.toggle` a checkbox, to a\n * field: the value and draft model, the\n * events in their order, controlled and imperative changes, validation and\n * the hidden input that submits the value. The input that calls it draws\n * the control with `controlProps` spread on it, and `hiddenInput` beside\n * it; it renders nothing itself.\n *\n * It only wires: forms-core's controller decides every event, and forms-dom\n * connects it to the control once the control is in the page. The latest\n * props reach the controller on every render. A controlled `value` is\n * passed on after every render and adopted whenever the user is not\n * typing, with no event; `handleRef`'s `setValue` and `reset` fire the\n * change events with `source: \"api\"`.\n *\n * Inside a `Field` the control takes the field's `id`, description,\n * required and invalid states, and `readOnly`, `disabled` and `mode` from\n * the field and the form, and the hook tells the field its shown messages\n * and whether the control is focused, empty and required. `options` are\n * the calling input's own behaviour; the latest reach forms-dom after\n * every render.\n */\nexport function useFieldInput<\n V,\n E extends TextControl = HTMLInputElement,\n D extends object = NoDetails,\n>(\n props: FieldInputProps<V, E, D>,\n kind: FieldInputKind<V, D>,\n options: FieldInputOptions = {},\n): FieldInput<V, E> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const toggle = options.toggle !== undefined;\n const fieldOptions: FieldOptions<V, D, Event> = {\n value: props.value,\n defaultValue: props.defaultValue,\n parse: props.parse,\n format: props.format,\n defaultParse: kind.defaultParse,\n defaultFormat: kind.defaultFormat,\n equals: kind.equals,\n details: kind.details,\n filterInput: kind.filterInput,\n validators: validatorsOf(props.validate),\n schedule: scheduleTimeout,\n changeDelay: options.changeDelay,\n commitOnLeave: !toggle,\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [controller] = useState(() => createFieldController(fieldOptions));\n controller.setOptions(fieldOptions);\n const state = useSyncExternalStore(\n controller.subscribe,\n controller.getState,\n controller.getState,\n );\n\n useControllerLifecycle(controller, props.value, form);\n\n // The control in state, not a ref, so that a new `ref` prop rebinds the\n // app's ref without detaching the pipeline mid-edit.\n const [control, setControl] = useState<E | null>(null);\n const { ref } = props;\n const controlRef = useCallback<RefCallback<E>>(\n (element) => {\n setControl(element);\n const release = setRef(ref, element);\n return () => {\n setControl(null);\n release?.();\n };\n },\n [ref],\n );\n const { onClear } = props;\n function fireClear(nativeEvent: Event | null): void {\n onClear?.({\n previousValue: controller.getState().value,\n previousText: controller.getText(),\n nativeEvent,\n });\n }\n const textOptions: TextInputOptions = {\n selectOnFocus: options.selectOnFocus,\n escape: options.escape,\n onClear: fireClear,\n mapCaret: options.mapCaret,\n decimalKey: options.decimalKey,\n lastCaret: options.lastCaret,\n };\n const toggleOptions: ToggleOptions = { ...options.toggle, readOnly };\n const behaviour = useRef<AttachedBehaviour | null>(null);\n useLayoutEffect(() => {\n if (control === null) {\n return undefined;\n }\n const attached = attachBehaviour(control, controller, toggle);\n behaviour.current = attached;\n return () => {\n attached.handle.detach();\n behaviour.current = null;\n };\n }, [control, controller, toggle]);\n // Every render's options, the attaching render's included: this effect\n // runs straight after the one above, before any event can arrive.\n useLayoutEffect(() => {\n const attached = behaviour.current;\n if (attached?.kind === \"text\") {\n attached.handle.setOptions(textOptions);\n } else if (attached?.kind === \"toggle\") {\n attached.handle.setOptions(toggleOptions);\n }\n });\n\n useImperativeHandle(\n props.handleRef,\n () => ({\n element: control,\n focus: (focusOptions) => {\n control?.focus(focusOptions);\n },\n blur: () => {\n control?.blur();\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n }),\n [control, controller],\n );\n\n const text = controller.getText();\n // A disabled field is not validated, so it shows none of its own messages.\n const own =\n state.revealed && !disabled ? controller.getMessages() : NO_MESSAGES;\n const { shown, severity } = useShownMessages(\n own,\n props.message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.phase),\n empty: text === \"\",\n required,\n startAdornment: options.startAdornment === true,\n labelBeside: toggle,\n });\n\n return {\n state,\n text,\n messages: shown,\n severity,\n clear: (nativeEvent) => {\n fireClear(nativeEvent);\n controller.clear(nativeEvent);\n },\n getValue: () => controller.getState().value,\n change: controller.change,\n mode,\n displayValue: <DisplayValue text={text} emptyText={messages.emptyValue} />,\n controlProps: {\n ref: controlRef,\n id: field?.controlId ?? props.id ?? ownId,\n defaultValue: toggle ? undefined : text,\n defaultChecked: toggle ? state.value === true : undefined,\n readOnly: toggle ? undefined : readOnly,\n \"aria-readonly\": (toggle && readOnly) || undefined,\n disabled,\n \"aria-invalid\":\n hasError(shown) ||\n props.invalid === true ||\n field?.invalid === true ||\n undefined,\n \"aria-describedby\": field?.describedBy,\n \"aria-required\": required || field?.required === true || undefined,\n },\n hiddenInput:\n props.name === undefined ? null : (\n <input\n type=\"hidden\"\n name={props.name}\n form={props.form}\n disabled={disabled}\n value={state.value === null ? \"\" : kind.serialize(state.value)}\n />\n ),\n };\n}\n","/**\n * A value in display mode: its text, as a document shows it, or for an\n * empty value a dash that is read as `emptyText`.\n */\nexport function DisplayValue({\n text,\n emptyText,\n}: {\n readonly text: string;\n readonly emptyText: string;\n}) {\n if (text !== \"\") {\n return <span className=\"gridkit-forms-display-value\">{text}</span>;\n }\n return (\n <span className=\"gridkit-forms-display-value gridkit-forms-display-empty\">\n <span aria-hidden=\"true\">—</span>\n <span className=\"gridkit-forms-sr-only\">{emptyText}</span>\n </span>\n );\n}\n","import {\n segmentRuns,\n splitSegments,\n type DateLayout,\n type PopupCloseReason,\n type PopupOpenChange,\n type SegmentType,\n} from \"@gridkitjs/forms-core\";\nimport { Fragment, useRef, type ReactNode, type Ref } from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { PickerButton, PickerPopup } from \"../picker/PickerPopup\";\nimport { usePickerPopup } from \"../picker/usePickerPopup\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n joinIds,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport { useInputSettings } from \"../useFieldInput\";\nimport type { SegmentedInputProps } from \"./segmentedProps\";\nimport {\n useSegmentedInput,\n type SegmentedKind,\n type SegmentsAccess,\n} from \"./useSegmentedInput\";\n\n/** What a segmented input's picker content is given while its popup is open. */\nexport interface PickerContext<V> {\n /** The field's value now. */\n readonly value: V | null;\n /** The popup's `id`, a prefix for the content's own ids. */\n readonly id: string;\n /** Chooses `value` whole and commits it: the change and commit events with `source` and `trigger` `\"picker\"`. */\n readonly pick: (value: V | null, nativeEvent: Event) => void;\n /** Closes the popup; after a pick, with `\"picker\"`. Focus goes back to the segments. */\n readonly close: (reason: PopupCloseReason) => void;\n /** What Escape does before it closes the popup; see `PickerPopup.setEscapeHandler`. */\n readonly setEscapeHandler: (handler: (() => boolean) | null) => void;\n}\n\n/**\n * A segmented input's picker: the button in its box, after the segments,\n * that opens a popup (as F4 and Alt+ArrowDown in a segment do), and what\n * the popup draws. The popup counts as inside the field, so opening it\n * neither commits nor blurs it.\n */\nexport interface SegmentedPicker<V> {\n /** The button's and the popup's name: \"Choose date\". */\n readonly label: string;\n readonly icon: ReactNode;\n /** The button's class beside `gridkit-forms-picker-button`: `gridkit-forms-calendar-button`. */\n readonly buttonClassName: string;\n /** The popup's class beside `gridkit-forms-picker-popup`: `gridkit-forms-calendar-popup`. */\n readonly popupClassName: string;\n /** The popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n /** Where focus goes in the popup as it opens; its first control by default. */\n readonly initialFocus?:\n ((panel: HTMLElement) => HTMLElement | null) | undefined;\n /**\n * Whether Tab leaves the popup at its ends: Tab from its last stop goes\n * on to the button, Shift+Tab from its first back to the segments, and\n * either closes it (`\"blur\"`). Without, Tab stays inside it.\n */\n readonly tabOut?: boolean | undefined;\n /** The popup's content, drawn while it is open. */\n readonly content: (context: PickerContext<V>) => ReactNode;\n}\n\n/** Where focus goes back to in a field's box: the free-text box while it shows, else the first segment. */\nfunction fieldFocusTarget(box: HTMLElement): HTMLElement | null {\n return box.querySelector<HTMLElement>(\n \"[data-gridkit-forms-segment-text]:not([hidden]), [data-gridkit-forms-segments]:not([hidden]) input[data-gridkit-forms-segment]\",\n );\n}\n\n/** A segment's state class: `is-month`, `is-day-period`. */\nfunction segmentClass(type: SegmentType): string {\n return `is-${type.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;\n}\n\n/** What every segment input shares, beside its own place in the layout. */\ninterface SegmentShared {\n readonly controlId: string;\n readonly texts: readonly string[] | null;\n readonly labelledBy: string | undefined;\n readonly describedBy: string | undefined;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n readonly invalid: boolean;\n readonly required: boolean;\n readonly loading: boolean;\n readonly autoFocus: boolean | undefined;\n readonly autoComplete: string | undefined;\n readonly enterKeyHint: SegmentedInputProps<unknown, object>[\"enterKeyHint\"];\n readonly firstRef: Ref<HTMLInputElement> | undefined;\n}\n\n/** The id of the hidden text naming segment `type`: \"month\". */\nfunction nameId(controlId: string, type: SegmentType): string {\n return `${controlId}-name-${type}`;\n}\n\n/** Segment `index`'s native control: a spinbutton typed into through forms-dom. */\nfunction SegmentInput({\n layout,\n index,\n shared,\n}: {\n readonly layout: DateLayout;\n readonly index: number;\n readonly shared: SegmentShared;\n}) {\n const segment = layout.segments[index];\n if (segment === undefined) {\n return null;\n }\n const first = index === 0;\n return (\n <input\n ref={first ? shared.firstRef : undefined}\n id={first ? shared.controlId : `${shared.controlId}-${segment.type}`}\n className={classNames(\n \"gridkit-forms-segment\",\n segmentClass(segment.type),\n )}\n data-gridkit-forms-segment={segment.type}\n type=\"text\"\n role=\"spinbutton\"\n inputMode={segment.type === \"dayPeriod\" ? \"text\" : \"numeric\"}\n autoComplete={shared.autoComplete ?? \"off\"}\n autoCorrect=\"off\"\n spellCheck={false}\n enterKeyHint={shared.enterKeyHint}\n autoFocus={first ? shared.autoFocus : undefined}\n tabIndex={first ? 0 : -1}\n size={Math.max(segment.width, segment.placeholder.length)}\n placeholder={segment.placeholder}\n defaultValue={shared.texts?.[index] ?? \"\"}\n readOnly={shared.readOnly}\n disabled={shared.disabled}\n aria-labelledby={joinIds(\n shared.labelledBy,\n nameId(shared.controlId, segment.type),\n )}\n aria-describedby={shared.describedBy}\n aria-invalid={shared.invalid || undefined}\n aria-required={(first && shared.required) || undefined}\n aria-busy={shared.loading || undefined}\n />\n );\n}\n\n/**\n * The segments in the layout's order with the literals between them, each\n * run of number segments that reads left to right wrapped in `dir=\"ltr\"`,\n * so a right-to-left field orders them as the locale writes them; in a\n * left-to-right field the wrapper changes nothing.\n */\nfunction SegmentList({\n layout,\n shared,\n hidden,\n}: {\n readonly layout: DateLayout;\n readonly shared: SegmentShared;\n readonly hidden: boolean;\n}) {\n const part = (partIndex: number): ReactNode => {\n const layoutPart = layout.parts[partIndex];\n if (layoutPart === undefined) {\n return null;\n }\n return layoutPart.kind === \"literal\" ? (\n <span\n key={partIndex}\n className=\"gridkit-forms-segment-literal\"\n aria-hidden=\"true\"\n >\n {layoutPart.text}\n </span>\n ) : (\n <SegmentInput\n key={partIndex}\n layout={layout}\n index={layoutPart.index}\n shared={shared}\n />\n );\n };\n return (\n <span\n className=\"gridkit-forms-segments\"\n data-gridkit-forms-segments=\"\"\n hidden={hidden}\n >\n {segmentRuns(layout, \"rtl\").map((run, runIndex) =>\n run.leftToRight ? (\n <span key={runIndex} className=\"gridkit-forms-segment-run\" dir=\"ltr\">\n {run.parts.map(part)}\n </span>\n ) : (\n <Fragment key={runIndex}>{run.parts.map(part)}</Fragment>\n ),\n )}\n </span>\n );\n}\n\n/**\n * The drawing every segmented input shares: the group with its box, the\n * segments, the free-text box for shortcuts, each segment's hidden name,\n * the hidden input and a bare input's own messages; in display mode, the\n * value as text.\n */\nexport function SegmentedControl<V, D extends object>({\n props: {\n loading = false,\n density,\n autoFocus,\n prefix,\n suffix,\n clearable = false,\n autoComplete,\n enterKeyHint,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n },\n kind,\n rootClassName,\n segments,\n picker,\n}: {\n readonly props: SegmentedInputProps<V, D>;\n readonly kind: SegmentedKind<V, D>;\n /** The input's own class: `gridkit-forms-date-input`. */\n readonly rootClassName: string;\n /** Where forms-dom's segments are held, for the kind's reading. */\n readonly segments: SegmentsAccess;\n /** The input's picker button and popup; none without. */\n readonly picker?: SegmentedPicker<V> | undefined;\n}) {\n const field = useFieldContext();\n const settings = useFormSettings();\n const buttonRef = useRef<HTMLButtonElement>(null);\n // Read before the field binds, which needs the popup's `isInside`.\n const { readOnly, disabled, mode } = useInputSettings(props);\n const popup = usePickerPopup({\n enabled:\n picker !== undefined && mode !== \"display\" && !readOnly && !disabled,\n onOpenChange: picker?.onOpenChange,\n returnFocusTo: fieldFocusTarget,\n initialFocus: picker?.initialFocus,\n });\n const input = useSegmentedInput(props, kind, segments, {\n startAdornment: hasNode(prefix),\n picker:\n picker === undefined\n ? undefined\n : {\n onOpen: () => {\n popup.open(\"keyboard\");\n },\n isInside: popup.isInside,\n },\n });\n const { controlId, strings, setGroup } = input;\n const ownMessagesId = useOwnMessagesId(controlId);\n const resolvedDensity = density ?? settings.density;\n const root = classNames(\n rootClassName,\n densityClass(resolvedDensity),\n className,\n );\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n <DisplayValue text={input.displayText} emptyText={strings.emptyValue} />\n {input.hiddenInput}\n </div>\n );\n }\n\n const groupId = `${controlId}-group`;\n const popupId = `${controlId}-picker`;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const fieldLabelId =\n field?.controlId === null || field === null\n ? undefined\n : `${controlId}-label`;\n const groupLabelledBy =\n ariaLabelledBy ?? (ariaLabel === undefined ? fieldLabelId : undefined);\n const describedBy = joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n input.describedBy,\n ownMessagesId,\n ariaDescribedBy,\n );\n const texts = splitSegments(kind.layout, input.text);\n const shared: SegmentShared = {\n controlId,\n texts,\n labelledBy: ariaLabel === undefined ? groupLabelledBy : groupId,\n describedBy,\n readOnly: input.readOnly,\n disabled: input.disabled,\n invalid: input.invalid,\n required: input.required,\n loading,\n autoFocus,\n autoComplete,\n enterKeyHint,\n firstRef: ref,\n };\n const editable = !input.readOnly && !input.disabled;\n\n return (\n <div\n ref={setGroup}\n className={root}\n style={style}\n role=\"group\"\n id={groupId}\n aria-label={ariaLabel}\n aria-labelledby={groupLabelledBy}\n aria-describedby={describedBy}\n >\n <ControlBox\n boxRef={popup.setAnchor}\n severity={input.severity}\n disabled={input.disabled}\n readOnly={input.readOnly}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n end={\n picker !== undefined &&\n !input.readOnly && (\n <PickerButton\n buttonRef={buttonRef}\n picker={popup}\n popupId={popupId}\n label={picker.label}\n className={picker.buttonClassName}\n disabled={input.disabled}\n icon={picker.icon}\n />\n )\n }\n >\n <SegmentList\n layout={kind.layout}\n shared={shared}\n hidden={texts === null}\n />\n <input\n className=\"gridkit-forms-date-text\"\n data-gridkit-forms-segment-text=\"\"\n type=\"text\"\n hidden={texts !== null}\n defaultValue={texts === null ? input.text : \"\"}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n enterKeyHint={enterKeyHint}\n readOnly={input.readOnly}\n disabled={input.disabled}\n aria-label={groupLabelledBy === undefined ? ariaLabel : undefined}\n aria-labelledby={groupLabelledBy}\n aria-describedby={describedBy}\n aria-invalid={input.invalid || undefined}\n />\n </ControlBox>\n {picker !== undefined && (\n <PickerPopup\n picker={popup}\n id={popupId}\n label={picker.label}\n className={picker.popupClassName}\n onTabOut={\n picker.tabOut === true\n ? (backward) => {\n const button = backward ? null : buttonRef.current;\n popup.close(\"blur\", button ?? undefined);\n }\n : undefined\n }\n >\n {picker.content({\n value: input.state.value,\n id: popupId,\n pick: input.pick,\n close: popup.close,\n setEscapeHandler: popup.setEscapeHandler,\n })}\n </PickerPopup>\n )}\n {kind.layout.segments.map((segment) => (\n <span\n key={segment.type}\n className=\"gridkit-forms-sr-only\"\n id={nameId(controlId, segment.type)}\n >\n {segment.label}\n </span>\n ))}\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n","import type { KeyboardEvent, ReactNode, Ref } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { classNames } from \"../field/parts\";\nimport { keepFocus } from \"../text/parts\";\nimport type { PickerPopup as PickerPopupState } from \"./usePickerPopup\";\n\n/** What Tab stops on in `panel`, in document order. */\nfunction tabStops(panel: HTMLElement): HTMLElement[] {\n return Array.from(\n panel.querySelectorAll<HTMLElement>(\"button, input, [tabindex]\"),\n ).filter((element) => element.tabIndex >= 0 && !element.matches(\":disabled\"));\n}\n\n/**\n * A field's picker popup, portalled into `document.body` so no scrolling\n * ancestor clips it, while it is open: a modal dialog named `label`,\n * in the field's colour scheme and `dir`. `usePickerPopup` places it\n * and moves focus in. Tab stays inside it, unless `onTabOut` is given:\n * then Tab from its last stop, or Shift+Tab from its first, calls that\n * instead.\n */\nexport function PickerPopup({\n picker,\n id,\n label,\n className,\n onTabOut,\n children,\n}: {\n readonly picker: PickerPopupState;\n readonly id: string;\n readonly label: string;\n /** The popup's own class beside `gridkit-forms-picker-popup`: `gridkit-forms-calendar-popup`. */\n readonly className: string;\n readonly onTabOut?: ((backward: boolean) => void) | undefined;\n readonly children: ReactNode;\n}) {\n const { scope, state, setPanel } = picker;\n if (state.kind !== \"open\" || scope === null) {\n return null;\n }\n // In the capture phase, so it runs before the overlay's focus trap on the panel.\n const onKeyDownCapture =\n onTabOut === undefined\n ? undefined\n : (event: KeyboardEvent<HTMLElement>) => {\n if (\n event.key !== \"Tab\" ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey\n ) {\n return;\n }\n const stops = tabStops(event.currentTarget);\n const edge = event.shiftKey ? stops[0] : stops.at(-1);\n if (edge !== undefined && edge === event.target) {\n event.preventDefault();\n onTabOut(event.shiftKey);\n }\n };\n return createPortal(\n <div\n ref={setPanel}\n id={id}\n className={classNames(\n \"gridkit-forms-picker-popup\",\n className,\n scope.scheme !== null && `is-${scope.scheme}`,\n )}\n dir={scope.direction}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={label}\n onKeyDownCapture={onKeyDownCapture}\n >\n {children}\n </div>,\n document.body,\n );\n}\n\n/**\n * The button in a field's box that opens its picker popup and closes it\n * again. A press keeps focus in the field, so the popup hands focus back\n * to the segment the user was in.\n */\nexport function PickerButton({\n picker,\n popupId,\n label,\n className,\n disabled,\n icon,\n buttonRef,\n}: {\n readonly picker: PickerPopupState;\n readonly popupId: string;\n readonly buttonRef?: Ref<HTMLButtonElement> | undefined;\n readonly label: string;\n /** The button's own class beside `gridkit-forms-picker-button`: `gridkit-forms-calendar-button`. */\n readonly className: string;\n readonly disabled: boolean;\n readonly icon: ReactNode;\n}) {\n const open = picker.state.kind === \"open\";\n return (\n <button\n ref={buttonRef}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-picker-button\",\n className,\n open && \"is-open\",\n )}\n aria-label={label}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? popupId : undefined}\n disabled={disabled}\n onMouseDown={keepFocus}\n onClick={picker.toggle}\n >\n {icon}\n </button>\n );\n}\n","import {\n createFieldController,\n dateParts,\n hasError,\n joinSegments,\n type ChangeCause,\n type DateLayout,\n type FieldMessage,\n type FieldMessageInput,\n type FieldOptions,\n type FieldState,\n type FormatContext,\n type FormsMessages,\n type ParseContext,\n type ParseResult,\n type PlainDate,\n type SegmentState,\n type SegmentType,\n type Severity,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachSegments,\n scheduleTimeout,\n type AttachedSegments,\n type SegmentsOptions,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactElement,\n type RefCallback,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport type { FieldMode } from \"../settings\";\nimport {\n isFocused,\n useControllerLifecycle,\n useFieldReport,\n useInputSettings,\n useShownMessages,\n validatorsOf,\n type FieldInputProps,\n} from \"../useFieldInput\";\n\n/** How a segmented input reads, writes, shows and limits its value. */\nexport interface SegmentedKind<V, D extends object> {\n /** The component's name, for warnings. */\n readonly name: string;\n readonly layout: DateLayout;\n readonly defaultParse: (\n text: string,\n context: ParseContext<V>,\n ) => ParseResult<V>;\n /** The value in the field's segments. */\n readonly defaultFormat: (\n value: V | null,\n context: FormatContext<V>,\n ) => string;\n readonly details: (\n current: FieldState<V>,\n previous: FieldState<V>,\n cause: ChangeCause<Event>,\n ) => D;\n /** The value as display mode writes it, before the app's `format`. */\n readonly display: (value: V) => string;\n /** The value as its hidden input submits it: the ISO string. */\n readonly serialize: (value: V) => string;\n /** Whether a value from the app is one; anything else is treated as empty, with a warning. */\n readonly isValue: (value: unknown) => value is V;\n /** Whether `value` lies within the input's `min` and `max`: a step never leaves them. */\n readonly inLimits: (value: V) => boolean;\n /** Whether letters and signs open the free-text box. */\n readonly shortcuts: boolean;\n readonly minuteStep?: number | undefined;\n /** Today in the input's zone, read when a step or a shortcut needs it. */\n readonly today: () => PlainDate;\n /**\n * Where an empty segment steps from, read when a step needs it: today's\n * year, month or day and 0 for a time unless given (a period steps from\n * today's period).\n */\n readonly reference?: ((type: SegmentType) => number) | undefined;\n /** The year one or two digits left in the year segment mean. */\n readonly pivot: (digits: number) => number;\n /** A message shown beside the field's own while it holds `value`: an instant's skipped hour. */\n readonly note?: ((value: V | null) => FieldMessageInput | null) | undefined;\n}\n\n/** What the segments know of the input's picker popup. */\nexport interface SegmentsPicker {\n /** F4 or Alt+ArrowDown in a segment. */\n readonly onOpen: (nativeEvent: KeyboardEvent) => void;\n /** Whether `node` is in the popup, so focus moving there does not leave the field. */\n readonly isInside: (node: Node) => boolean;\n}\n\n/** The props `useSegmentedInput` reads. */\nexport type SegmentedHookProps<V, D extends object> = Omit<\n FieldInputProps<V, HTMLInputElement, D>,\n \"ref\"\n> & {\n readonly revertOnEscape?: boolean | undefined;\n};\n\n/** What `useSegmentedInput` gives the input that calls it, to draw. */\nexport interface SegmentedInput<V> {\n readonly state: FieldState<V>;\n /** The segments' text, or the free text. */\n readonly text: string;\n readonly messages: readonly FieldMessage[];\n readonly severity: Severity | null;\n readonly invalid: boolean;\n readonly mode: FieldMode;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n /** The input's own `required`, or the `Field`'s. */\n readonly required: boolean;\n /** The first segment's `id`: the `Field`'s inside one, so its label points there. */\n readonly controlId: string;\n /** The `Field`'s description and messages. */\n readonly describedBy: string | undefined;\n readonly strings: FormsMessages;\n /** The value as display mode shows it, through the app's `format`; `\"\"` when empty. */\n readonly displayText: string;\n /** Fires `onClear`, then empties the field and commits it. */\n readonly clear: (nativeEvent: Event | null) => void;\n /** The value chosen whole in a picker, then committed: `source` and `trigger` `\"picker\"`. */\n readonly pick: (value: V | null, nativeEvent: Event) => void;\n /** The element around the segments and the free-text box. */\n readonly setGroup: RefCallback<HTMLElement>;\n /** The hidden input carrying `name` and the ISO value; `null` without a `name`. */\n readonly hiddenInput: ReactElement | null;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n// `Array.isArray` does not narrow a readonly array, hence the guard.\nfunction isMessageList(\n message: FieldMessageInput | readonly FieldMessageInput[],\n): message is readonly FieldMessageInput[] {\n return Array.isArray(message);\n}\nconst DATE_SEGMENTS = new Set([\"year\", \"month\", \"day\"]);\n\n/**\n * Where forms-dom's segments are held once attached, so a kind's reading\n * can ask where typing stands. An input makes one with `useState` and\n * hands it to `useSegmentedInput`, which attaches and releases it.\n */\nexport interface SegmentsAccess {\n readonly attach: (attached: AttachedSegments | null) => void;\n readonly setOptions: (options: SegmentsOptions) => void;\n readonly getState: () => SegmentState | null;\n}\n\nexport function createSegmentsAccess(): SegmentsAccess {\n let current: AttachedSegments | null = null;\n return {\n attach: (attached) => {\n current = attached;\n },\n setOptions: (options) => {\n current?.setOptions(options);\n },\n getState: () => current?.getState() ?? null,\n };\n}\n\n/** The segment typing is in, or `null`: a short year there is not pivoted yet. */\nexport function typingSegment(segments: SegmentsAccess): number | null {\n const entry = segments.getState()?.entry;\n return entry?.kind === \"active\" ||\n entry?.kind === \"typing\" ||\n entry?.kind === \"composing\"\n ? entry.segment\n : null;\n}\n\n/** The segments' text typing works on: the text the free-text box opened over while it shows. */\nexport function typedSegments(segments: SegmentsAccess): string {\n const state = segments.getState();\n if (state === null) {\n return \"\";\n }\n return state.entry.kind === \"text\" ? state.entry.before : state.text;\n}\n\n/**\n * Binds a segmented input to one field, as `useFieldInput` binds one\n * control: forms-core's controller, made once and handed the latest props\n * and `kind` on every render; a controlled `value` (one that is not a\n * value of the kind is empty, with a warning); the `Field` and form around\n * it; and forms-dom's `attachSegments` on `setGroup`, held in `segments`\n * so the kind's reading can ask where typing stands.\n *\n * The app's `format` writes display mode's text only: the segments are not\n * free text. Its `parse` reads the segments, pastes and free text, around\n * the kind's own.\n */\nexport function useSegmentedInput<V, D extends object>(\n props: SegmentedHookProps<V, D>,\n kind: SegmentedKind<V, D>,\n segments: SegmentsAccess,\n {\n startAdornment,\n picker,\n }: {\n /** Something sits at the box's start, where a resting floating label would cover it. */\n readonly startAdornment: boolean;\n /** The input's picker popup: F4 and Alt+ArrowDown open it, and focus in it stays in the field. */\n readonly picker?: SegmentsPicker | undefined;\n },\n): SegmentedInput<V> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const valueOf = (value: V | null | undefined): V | null | undefined =>\n value === undefined || value === null || kind.isValue(value) ? value : null;\n const value = valueOf(props.value);\n const defaultValue = valueOf(props.defaultValue);\n const strayValue =\n (value === null && props.value !== null && props.value !== undefined) ||\n (defaultValue === null &&\n props.defaultValue !== null &&\n props.defaultValue !== undefined);\n useEffect(() => {\n if (strayValue) {\n warnOnce(\n `${kind.name}-value`,\n `${kind.name} was given a value that is not one it holds (an ISO string such as \"2026-03-14\"), so it shows nothing.`,\n );\n }\n }, [strayValue, kind.name]);\n\n const fieldOptions: FieldOptions<V, D, Event> = {\n value,\n defaultValue,\n parse: props.parse,\n defaultParse: kind.defaultParse,\n defaultFormat: kind.defaultFormat,\n details: kind.details,\n validators: validatorsOf(props.validate),\n schedule: scheduleTimeout,\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [controller] = useState(() => createFieldController(fieldOptions));\n controller.setOptions(fieldOptions);\n const state = useSyncExternalStore(\n controller.subscribe,\n controller.getState,\n controller.getState,\n );\n useControllerLifecycle(controller, value, form);\n\n const formatContext: FormatContext<V> = {\n defaultFormat: (shown) => kind.defaultFormat(shown, formatContext),\n locale,\n messages,\n purpose: \"edit\",\n };\n const segmentOptions: SegmentsOptions = {\n context: {\n layout: kind.layout,\n reference: (type) => {\n if (kind.reference !== undefined) {\n return kind.reference(type);\n }\n if (!DATE_SEGMENTS.has(type)) {\n return 0;\n }\n const today = dateParts(kind.today());\n return type === \"year\"\n ? today.year\n : type === \"month\"\n ? today.month\n : today.day;\n },\n pivotYear: kind.pivot,\n shortcuts: kind.shortcuts,\n readWhole: (text) => {\n const result = controller.read(text);\n return result.kind === \"value\" && result.value !== null\n ? kind.defaultFormat(result.value, formatContext)\n : null;\n },\n minuteStep: kind.minuteStep,\n allows: (texts) => {\n const result = controller.read(joinSegments(kind.layout, texts));\n return (\n result.kind !== \"value\" ||\n result.value === null ||\n kind.inLimits(result.value)\n );\n },\n },\n locale,\n messages,\n escape: props.revertOnEscape === false ? \"none\" : \"revert\",\n onOpenPicker: picker?.onOpen,\n isInside: picker?.isInside,\n };\n\n const [group, setGroup] = useState<HTMLElement | null>(null);\n const latestOptions = useRef(segmentOptions);\n // Every render's options; on the first, before the effect below attaches.\n useLayoutEffect(() => {\n latestOptions.current = segmentOptions;\n segments.setOptions(segmentOptions);\n });\n useLayoutEffect(() => {\n if (group === null) {\n return undefined;\n }\n const attached = attachSegments(group, controller, latestOptions.current);\n segments.attach(attached);\n return () => {\n attached.detach();\n segments.attach(null);\n };\n }, [group, controller, segments]);\n\n useImperativeHandle(\n props.handleRef,\n () => {\n const firstSegment = (): HTMLInputElement | null =>\n group?.querySelector<HTMLInputElement>(\n \"input[data-gridkit-forms-segment]\",\n ) ?? null;\n return {\n get element() {\n return firstSegment();\n },\n focus: (focusOptions) => {\n firstSegment()?.focus(focusOptions);\n },\n blur: () => {\n const active = group?.ownerDocument.activeElement;\n if (\n active instanceof HTMLElement &&\n group?.contains(active) === true\n ) {\n active.blur();\n }\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n };\n },\n [group, controller],\n );\n\n const text = controller.getText();\n // A disabled field is not validated, so it shows none of its own messages.\n const own =\n state.revealed && !disabled ? controller.getMessages() : NO_MESSAGES;\n const note = kind.note?.(state.value) ?? null;\n const { message: appMessage } = props;\n const message = useMemo(() => {\n if (note === null) {\n return appMessage;\n }\n if (appMessage === undefined) {\n return note;\n }\n return [...(isMessageList(appMessage) ? appMessage : [appMessage]), note];\n }, [appMessage, note]);\n const { shown, severity } = useShownMessages(\n own,\n message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.phase),\n empty: text === \"\",\n required,\n startAdornment,\n });\n\n const { format, onClear } = props;\n const displayText =\n format === undefined\n ? state.value === null\n ? \"\"\n : kind.display(state.value)\n : format(state.value, {\n defaultFormat: (shown) => (shown === null ? \"\" : kind.display(shown)),\n locale,\n messages,\n purpose: \"display\",\n });\n\n return {\n state,\n text,\n messages: shown,\n severity,\n invalid:\n hasError(shown) || props.invalid === true || field?.invalid === true,\n mode,\n readOnly,\n disabled,\n required: required || field?.required === true,\n controlId: field?.controlId ?? props.id ?? ownId,\n describedBy: field?.describedBy,\n strings: messages,\n displayText,\n clear: (nativeEvent) => {\n onClear?.({\n previousValue: controller.getState().value,\n previousText: controller.getText(),\n nativeEvent,\n });\n controller.clear(nativeEvent);\n },\n pick: (picked, nativeEvent) => {\n controller.pick(picked, \"picker\", \"picker\", nativeEvent);\n },\n setGroup,\n hiddenInput:\n props.name === undefined ? null : (\n <input\n type=\"hidden\"\n name={props.name}\n form={props.form}\n disabled={disabled}\n value={state.value === null ? \"\" : kind.serialize(state.value)}\n />\n ),\n };\n}\n","import {\n createFieldController,\n hasError,\n parsed,\n unreadable,\n type ChangeCause,\n type FieldController,\n type FieldMessage,\n type FieldOptions,\n type FieldState,\n type FormatContext,\n type FormsMessages,\n type Severity,\n} from \"@gridkitjs/forms-core\";\nimport { attachFocusGroup } from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useState,\n useSyncExternalStore,\n type ReactElement,\n type RefCallback,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport type { FieldMode } from \"../settings\";\nimport {\n isFocused,\n useControllerLifecycle,\n useFieldReport,\n useInputSettings,\n useShownMessages,\n validatorsOf,\n type FieldInputProps,\n} from \"../useFieldInput\";\n\n/** How an input whose value is only ever chosen whole (a calendar) writes, shows and checks it. */\nexport interface PickerKind<V, D extends object> {\n /** The component's name, for warnings. */\n readonly name: string;\n /** The value as the events' `text` carries it. */\n readonly defaultFormat: (\n value: V | null,\n context: FormatContext<V>,\n ) => string;\n readonly details: (\n current: FieldState<V>,\n previous: FieldState<V>,\n cause: ChangeCause<Event>,\n ) => D;\n /** The value as display mode writes it. */\n readonly display: (value: V) => string;\n /** Whether a value from the app is one; anything else is treated as empty, with a warning. */\n readonly isValue: (value: unknown) => value is V;\n readonly equals?: ((a: V, b: V) => boolean) | undefined;\n}\n\n/** The props `usePickerField` reads. */\nexport type PickerFieldProps<V, D extends object> = Omit<\n FieldInputProps<V, HTMLInputElement, D>,\n \"ref\" | \"parse\" | \"format\" | \"onBeforeInput\" | \"onInput\"\n>;\n\n/** What `usePickerField` gives the input that calls it, to draw. */\nexport interface PickerField<V, D extends object> {\n readonly controller: FieldController<V, D, Event>;\n readonly state: FieldState<V>;\n readonly messages: readonly FieldMessage[];\n readonly severity: Severity | null;\n readonly invalid: boolean;\n readonly mode: FieldMode;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n /** The input's own `required`, or the `Field`'s. */\n readonly required: boolean;\n /** The root's `id`: the props', else one of its own. */\n readonly rootId: string;\n /** The `Field`'s label, when the input is in one. */\n readonly fieldLabelId: string | undefined;\n /** The `Field`'s description and messages. */\n readonly describedBy: string | undefined;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** The value as display mode shows it; `\"\"` when empty. */\n readonly displayText: string;\n /** The value chosen whole, then committed: `source` and `trigger` `\"picker\"`. */\n readonly pick: (value: V | null, nativeEvent: Event) => void;\n /** The element around every focusable part: focus leaving it blurs the field. */\n readonly setRoot: RefCallback<HTMLElement>;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/**\n * Binds an input whose value is chosen whole, never typed (a calendar), to\n * one field, as `useFieldInput` binds a text control: forms-core's\n * controller, made once and handed the latest props on every render; a\n * controlled `value` (one that is not a value of the kind is empty, with a\n * warning); the `Field` and form around it. Focus entering the root starts\n * the field's edit and leaving it (forms-dom's focus group) ends it, so\n * `onFocus` and `onBlur` fire once for the whole input. `focusTarget`\n * finds the element `handleRef`'s `focus` moves to.\n */\nexport function usePickerField<V, D extends object>(\n props: PickerFieldProps<V, D>,\n kind: PickerKind<V, D>,\n focusTarget: (root: HTMLElement) => HTMLElement | null,\n): PickerField<V, D> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const valueOf = (value: V | null | undefined): V | null | undefined =>\n value === undefined || value === null || kind.isValue(value) ? value : null;\n const value = valueOf(props.value);\n const defaultValue = valueOf(props.defaultValue);\n const strayValue =\n (value === null && props.value !== null && props.value !== undefined) ||\n (defaultValue === null &&\n props.defaultValue !== null &&\n props.defaultValue !== undefined);\n useEffect(() => {\n if (strayValue) {\n warnOnce(\n `${kind.name}-value`,\n `${kind.name} was given a value that is not one it holds, so it shows nothing.`,\n );\n }\n }, [strayValue, kind.name]);\n\n const fieldOptions: FieldOptions<V, D, Event> = {\n value,\n defaultValue,\n // Nothing is typed into a picker, so its text never needs reading.\n defaultParse: (text) =>\n text === \"\" ? parsed(null) : unreadable(messages.unreadable),\n defaultFormat: kind.defaultFormat,\n // Every pick commits, so leaving has nothing more to commit.\n commitOnLeave: false,\n equals: kind.equals,\n details: kind.details,\n validators: validatorsOf(props.validate),\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [controller] = useState(() => createFieldController(fieldOptions));\n controller.setOptions(fieldOptions);\n const state = useSyncExternalStore(\n controller.subscribe,\n controller.getState,\n controller.getState,\n );\n useControllerLifecycle(controller, value, form);\n\n const [root, setRoot] = useState<HTMLElement | null>(null);\n useLayoutEffect(() => {\n if (root === null) {\n return undefined;\n }\n const onFocusIn = (event: FocusEvent) => {\n if (!isFocused(controller.getState().phase)) {\n controller.focus(event);\n }\n };\n root.addEventListener(\"focusin\", onFocusIn);\n // A focused day can leave the page as the months change, which moves\n // focus nowhere until the calendar focuses the new day; focus is only\n // gone once it has not come back by then.\n const group = attachFocusGroup(root, {\n onLeave: (_by, nativeEvent) => {\n queueMicrotask(() => {\n if (!root.contains(root.ownerDocument.activeElement)) {\n controller.blur(nativeEvent);\n }\n });\n },\n });\n return () => {\n root.removeEventListener(\"focusin\", onFocusIn);\n group.detach();\n };\n }, [root, controller]);\n\n useImperativeHandle(\n props.handleRef,\n () => ({\n get element() {\n return root === null ? null : focusTarget(root);\n },\n focus: (focusOptions) => {\n if (root !== null) {\n focusTarget(root)?.focus(focusOptions);\n }\n },\n blur: () => {\n const active = root?.ownerDocument.activeElement;\n if (active instanceof HTMLElement && root?.contains(active) === true) {\n active.blur();\n }\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n }),\n [root, controller, focusTarget],\n );\n\n // A disabled field is not validated, so it shows none of its own messages.\n const own =\n state.revealed && !disabled ? controller.getMessages() : NO_MESSAGES;\n const { shown, severity } = useShownMessages(\n own,\n props.message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.phase),\n empty: state.value === null,\n required,\n startAdornment: false,\n });\n\n return {\n controller,\n state,\n messages: shown,\n severity,\n invalid:\n hasError(shown) || props.invalid === true || field?.invalid === true,\n mode,\n readOnly,\n disabled,\n required: required || field?.required === true,\n rootId: field?.controlId ?? props.id ?? ownId,\n fieldLabelId:\n field === null || field.controlId === null\n ? undefined\n : `${field.controlId}-label`,\n describedBy: field?.describedBy,\n locale,\n strings: messages,\n displayText: state.value === null ? \"\" : kind.display(state.value),\n pick: (picked, nativeEvent) => {\n controller.pick(picked, \"picker\", \"picker\", nativeEvent);\n },\n setRoot,\n };\n}\n\n/** The hidden inputs that submit `values` under `name`, or `null` without a name. */\nexport function hiddenInputs(\n name: string | undefined,\n form: string | undefined,\n disabled: boolean,\n values: readonly (readonly [suffix: string, value: string])[],\n): ReactElement[] | null {\n if (name === undefined) {\n return null;\n }\n return values.map(([suffix, submitted]) => (\n <input\n key={suffix}\n type=\"hidden\"\n name={`${name}${suffix}`}\n form={form}\n disabled={disabled}\n value={submitted}\n />\n ));\n}\n","import {\n addDays,\n compareDates,\n dateRangeKind,\n formatDate,\n formatDateRange,\n isCalendarDayDisabled,\n isPlainDate,\n pickedDays,\n rangeDetails,\n rangePickPreview,\n rangePickReducer,\n requiredRule,\n sameRange,\n weekInfo,\n type CalendarLimits,\n type DateRange,\n type DateRuleContext,\n type NoFlags,\n type PickedDays,\n type PlainDate,\n type RangeBounds,\n type RangeDetails,\n type RangePick,\n type RangePickAction,\n type RelativeDateRule,\n} from \"@gridkitjs/forms-core\";\nimport { attachFitCount } from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type PointerEvent,\n type RefCallback,\n} from \"react\";\nimport { todayFor } from \"../date/DateInput\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { joinIds, OwnMessages, useOwnMessagesId } from \"../text/parts\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { focusedDayIn } from \"./Calendar\";\nimport { CalendarBody } from \"./CalendarBody\";\nimport type {\n CalendarBaseProps,\n CalendarLimitProps,\n CalendarSettings,\n} from \"./calendarProps\";\nimport {\n dateOf,\n NO_MARKS,\n titleId,\n type CalendarLook,\n type DayMarks,\n} from \"./MonthPanel\";\nimport { useCalendarNavigation, useToday } from \"./useCalendarNavigation\";\nimport {\n hiddenInputs,\n usePickerField,\n type PickerKind,\n} from \"./usePickerField\";\n\n/**\n * What a range calendar adds to every event: the range's details, with\n * `changedEnd` always `\"both\"` and `rule` always `null` (a calendar holds\n * fixed days).\n */\nexport type RangeCalendarDetails = RangeDetails<\n PlainDate,\n NoFlags,\n number,\n RelativeDateRule\n>;\n\nexport interface RangeCalendarProps\n extends\n CalendarBaseProps<DateRange, RangeCalendarDetails>,\n CalendarLimitProps,\n CalendarSettings {\n /** Months side by side; by default 2 where two fit beside each other, else 1. */\n readonly visibleMonths?: 1 | 2 | 3 | undefined;\n /** `\"[)\"` by default: the value's `end` is the day after the last day picked. `\"[]\"` stores the last day. */\n readonly bounds?: RangeBounds | undefined;\n}\n\n/** Whether `value` is a range of days a range calendar can hold. */\nfunction isDateRange(value: unknown): value is DateRange {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const { start, end } = value as Record<string, unknown>;\n const isEnd = (end: unknown) => end === null || isPlainDate(end);\n return isEnd(start) && isEnd(end) && (start !== null || end !== null);\n}\n\n/** The last day a stored range covers: the day before a half-open `end`. */\nfunction lastDayOf(range: DateRange, bounds: RangeBounds): PlainDate | null {\n return range.end === null || bounds === \"[]\"\n ? range.end\n : addDays(range.end, -1);\n}\n\n/** The days a stored range covers, its ends included; an open end shows the other alone. */\nfunction daysOf(range: DateRange, bounds: RangeBounds): PickedDays | null {\n const last = lastDayOf(range, bounds);\n const first = range.start ?? last;\n return first === null ? null : pickedDays(first, last ?? first);\n}\n\n/** How a day in `days` shows; `preview` while the range is still being picked. */\nfunction marksIn(\n days: PickedDays | null,\n date: PlainDate,\n preview: boolean,\n): DayMarks {\n if (\n days === null ||\n compareDates(date, days.first) < 0 ||\n compareDates(date, days.last) > 0\n ) {\n return NO_MARKS;\n }\n const rangeStart = date === days.first;\n const rangeEnd = date === days.last;\n return {\n selected: true,\n rangeStart,\n rangeEnd,\n inRange: !rangeStart && !rangeEnd,\n preview,\n };\n}\n\nconst IDLE: RangePick = { kind: \"idle\" };\n\n/**\n * Months side by side to pick a range of days from: a first day chosen\n * (click, tap, Enter or Space) anchors the range, moving the pointer or\n * focus previews it, and a second choice finishes it; an end before the\n * start swaps them. With a mouse or pen, a press dragged across days\n * picks the range in one gesture. Escape drops a range in progress. Keys,\n * limits, week numbers and the month view are `Calendar`'s.\n *\n * Its value is a `DateRange`, stored half-open: picking 1 to 14 March\n * gives `{ start: \"2026-03-01\", end: \"2026-03-15\" }`, and the days shown\n * are the 1st to the 14th. The range commits once, when its end is\n * chosen, with `source` and `trigger` `\"picker\"`.\n */\nexport function RangeCalendar({\n min,\n max,\n isDateDisabled,\n timeZone,\n firstDayOfWeek,\n weekNumbers = false,\n weekNumbering,\n visibleMonths,\n bounds = \"[)\",\n required,\n validate,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: RangeCalendarProps) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const needsValue = required === true || field?.required === true;\n const today = todayFor(timeZone);\n const firstDay = firstDayOfWeek ?? weekInfo(locale).firstDay;\n const ruleContext: DateRuleContext = {\n today,\n firstDayOfWeek: firstDay,\n fiscalYearStart: 1,\n };\n const write = (range: DateRange) =>\n formatDateRange(range, { locale, messages, bounds });\n const writeEnd = (date: PlainDate | null) =>\n date === null ? \"\" : formatDate(date, locale);\n const kind: PickerKind<DateRange, RangeCalendarDetails> = {\n name: \"RangeCalendar\",\n defaultFormat: (range) => (range === null ? \"\" : write(range)),\n details: ({ value: range }) =>\n rangeDetails(\n dateRangeKind,\n range,\n \"all\",\n {\n start: writeEnd(range?.start ?? null),\n end: writeEnd(range === null ? null : lastDayOf(range, bounds)),\n },\n bounds,\n ruleContext,\n ),\n display: write,\n isValue: isDateRange,\n equals: (a, b) => sameRange(dateRangeKind, a, b),\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<DateRange>()] : []),\n ...validatorsOf(validate),\n ],\n [needsValue, validate],\n );\n const picker = usePickerField(\n { ...props, required, validate: validators },\n kind,\n focusedDayIn,\n );\n const { rootId, readOnly, disabled } = picker;\n const { value } = picker.state;\n\n const [fitted, setFitted] = useState(2);\n const shownMonths = visibleMonths ?? fitted;\n const limits: CalendarLimits = useMemo(\n () => ({ min, max, isDateDisabled }),\n [min, max, isDateDisabled],\n );\n const nav = useCalendarNavigation({\n focus: value?.start ?? value?.end ?? today(),\n context: { firstDayOfWeek: firstDay, visibleMonths: shownMonths, limits },\n });\n\n const [pick, setPick] = useState<RangePick>(IDLE);\n const latestPick = useRef(pick);\n useLayoutEffect(() => {\n latestPick.current = pick;\n });\n const [announcement, setAnnouncement] = useState(\"\");\n // A mouse or pen press picks through its pointer events, so the click that follows it is not a choice.\n const pointerPicked = useRef(false);\n\n const [root, setRootElement] = useState<HTMLDivElement | null>(null);\n const { setRoot } = picker;\n const navSetRoot = nav.setRoot;\n const rootRef = useCallback<RefCallback<HTMLDivElement>>(\n (element) => {\n navSetRoot(element);\n setRoot(element);\n setRootElement(element);\n },\n [navSetRoot, setRoot],\n );\n const automatic = visibleMonths === undefined;\n useLayoutEffect(() => {\n if (root === null || !automatic) {\n return undefined;\n }\n const watch = attachFitCount(root, { max: 2, onCount: setFitted });\n return () => {\n watch.detach();\n };\n }, [root, automatic]);\n\n const shownToday = useToday(timeZone);\n const ownMessagesId = useOwnMessagesId(rootId);\n const hidden = hiddenInputs(props.name, props.form, disabled, [\n [\".start\", value?.start ?? \"\"],\n [\".end\", value?.end ?? \"\"],\n ]);\n\n if (picker.mode === \"display\") {\n return (\n <div\n className={classNames(\n \"gridkit-forms-range-calendar\",\n \"is-display\",\n className,\n )}\n style={style}\n >\n <DisplayValue\n text={picker.displayText}\n emptyText={picker.strings.emptyValue}\n />\n {hidden}\n </div>\n );\n }\n\n const selectable = (date: PlainDate) =>\n !readOnly && !disabled && !isCalendarDayDisabled(date, limits);\n\n function run(action: RangePickAction, nativeEvent: Event | null) {\n const step = rangePickReducer(latestPick.current, action, selectable);\n if (step.state !== latestPick.current) {\n latestPick.current = step.state;\n setPick(step.state);\n }\n if (step.picked === null) {\n return;\n }\n const { first, last } = step.picked;\n const range: DateRange = {\n start: first,\n end: bounds === \"[)\" ? addDays(last, 1) : last,\n };\n if (nativeEvent !== null) {\n picker.pick(range, nativeEvent);\n }\n setAnnouncement(\n formatDateRange(range, {\n locale,\n messages: picker.strings,\n bounds,\n displayFormat: { dateStyle: \"long\" },\n }),\n );\n }\n\n function onPointerDown(event: PointerEvent<HTMLDivElement>) {\n const date = dateOf(event.target);\n pointerPicked.current = false;\n if (event.pointerType === \"touch\" || event.button !== 0 || date === null) {\n return;\n }\n pointerPicked.current = true;\n run({ type: \"press\", date }, event.nativeEvent);\n if (latestPick.current.kind === \"dragging\") {\n event.currentTarget.setPointerCapture(event.pointerId);\n }\n }\n\n /** The day under the pointer: a captured pointer's events all go to the root. */\n function dayAt(event: PointerEvent): PlainDate | null {\n return latestPick.current.kind === \"dragging\"\n ? dateOf(document.elementFromPoint(event.clientX, event.clientY))\n : dateOf(event.target);\n }\n\n function onPointerMove(event: PointerEvent<HTMLDivElement>) {\n if (event.pointerType === \"touch\") {\n return;\n }\n const date = dayAt(event);\n if (date !== null) {\n run({ type: \"preview\", date }, event.nativeEvent);\n }\n }\n\n function onPointerUp(event: PointerEvent<HTMLDivElement>) {\n if (latestPick.current.kind !== \"dragging\") {\n return;\n }\n const date = dayAt(event);\n if (date !== null) {\n run({ type: \"preview\", date }, event.nativeEvent);\n }\n run({ type: \"release\" }, event.nativeEvent);\n if (date !== null) {\n nav.dispatch({ type: \"focus\", date });\n nav.focusDay();\n }\n }\n\n const preview = rangePickPreview(pick);\n const shown = preview ?? (value === null ? null : daysOf(value, bounds));\n const look: CalendarLook = {\n rootId,\n locale,\n strings: picker.strings,\n firstDayOfWeek: firstDay,\n weekNumbering,\n weekNumbers,\n weekend: weekInfo(locale).weekend,\n limits,\n today: shownToday,\n focused: nav.state.focused,\n disabled,\n readOnly,\n range: true,\n marks: (date) => marksIn(shown, date, preview !== null),\n };\n\n return (\n <div\n ref={rootRef}\n id={rootId}\n className={classNames(\n \"gridkit-forms-range-calendar\",\n pick.kind !== \"idle\" && \"is-picking\",\n disabled && \"is-disabled\",\n readOnly && \"is-read-only\",\n picker.invalid && \"is-invalid\",\n className,\n )}\n style={style}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy ??\n (ariaLabel === undefined\n ? joinIds(picker.fieldLabelId, titleId(rootId, 0))\n : undefined)\n }\n aria-describedby={joinIds(\n picker.describedBy,\n ownMessagesId,\n ariaDescribedBy,\n )}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={(event) => {\n run({ type: \"lose\" }, event.nativeEvent);\n }}\n onLostPointerCapture={(event) => {\n run({ type: \"lose\" }, event.nativeEvent);\n }}\n >\n <CalendarBody\n nav={nav}\n look={look}\n visibleMonths={shownMonths}\n onDayClick={(date, event) => {\n if (pointerPicked.current) {\n pointerPicked.current = false;\n return;\n }\n run({ type: \"choose\", date }, event.nativeEvent);\n }}\n onChooseKey={(date, event) => {\n run({ type: \"choose\", date }, event.nativeEvent);\n }}\n onFocusMoved={(date) => {\n run({ type: \"preview\", date }, null);\n }}\n onOtherKey={(event) => {\n if (event.key === \"Escape\" && latestPick.current.kind !== \"idle\") {\n event.preventDefault();\n run({ type: \"cancel\" }, event.nativeEvent);\n }\n }}\n />\n <span className=\"gridkit-forms-sr-only\" aria-live=\"polite\">\n {announcement}\n </span>\n {hidden}\n <OwnMessages\n id={`${rootId}-messages`}\n messages={picker.messages}\n strings={picker.strings}\n named\n />\n </div>\n );\n}\n","import {\n availableDateRule,\n compareDateTimes,\n compareInstants,\n dateLayout,\n dateTimeDetails,\n dateTimeFormatter,\n dateTimeParser,\n exactInstantOf,\n formatDateTime,\n formatInstant,\n instantDetails,\n instantFormatter,\n instantParser,\n instantZoneMessage,\n isInstant,\n isPlainDateTime,\n maxDateTimeRule,\n maxInstantRule,\n minDateTimeRule,\n minInstantRule,\n pivotYear,\n requiredRule,\n segmentsTime,\n wallClockOf,\n type DateTimeDetails,\n type DateTimeFieldOptions,\n type FieldMessageInput,\n type Instant,\n type InstantFieldOptions,\n type PlainDate,\n type PlainDateTime,\n type PlainTime,\n type PopupOpenChange,\n type TimeZoneDisambiguation,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, useState } from \"react\";\nimport type { CalendarSettings } from \"../calendar/calendarProps\";\nimport type { FieldChangeEvent } from \"../events\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { CalendarIcon, InputFrame } from \"../text/parts\";\nimport { DateTimePicker } from \"../time/DateTimePicker\";\nimport { segmentTimeOption } from \"../time/TimeColumns\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { focusedDay, nowFor, todayFor } from \"./DateInput\";\nimport { SegmentedControl, type SegmentedPicker } from \"./SegmentedControl\";\nimport type {\n DayLimits,\n SegmentedInputProps,\n TimeSettings,\n} from \"./segmentedProps\";\nimport {\n createSegmentsAccess,\n typedSegments,\n typingSegment,\n type SegmentedKind,\n} from \"./useSegmentedInput\";\n\n/** What a date-time input holds: a wall clock (`\"local\"`) or an exact moment (`\"instant\"`). */\nexport type DateTimeValueType = \"local\" | \"instant\";\n\n/** The value of a date-time input of `T`. */\nexport type DateTimeValue<T extends DateTimeValueType> = T extends \"instant\"\n ? Instant\n : PlainDateTime;\n\ninterface DateTimeOwnProps<T extends DateTimeValueType>\n extends\n SegmentedInputProps<DateTimeValue<T>, DateTimeDetails>,\n Omit<DayLimits, \"min\" | \"max\" | \"timeZone\">,\n CalendarSettings,\n TimeSettings {\n /** The calendar button and its popup of a calendar and time columns; on by default. */\n readonly calendar?: boolean | undefined;\n /** The popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n /** The earliest moment allowed, inclusive. */\n readonly min?: DateTimeValue<T> | undefined;\n /** The latest moment allowed, inclusive. */\n readonly max?: DateTimeValue<T> | undefined;\n /** The time a date gets when its time is left empty; `\"00:00\"` by default. */\n readonly defaultTime?: PlainTime | undefined;\n /** Which moment a wall clock in a skipped or repeated hour means; `\"compatible\"` by default, as Temporal's. */\n readonly disambiguation?: TimeZoneDisambiguation | undefined;\n /** `\"local\"` (default): a wall clock, `PlainDateTime`. `\"instant\"`: an exact moment, typed in `timeZone`. */\n readonly valueType?: T | undefined;\n}\n\n/** The zone a value is typed and shown in: required for an instant, where \"today\" is for a wall clock. */\nexport type DateTimeZoneProps<T extends DateTimeValueType> = T extends \"instant\"\n ? { readonly timeZone: string }\n : { readonly timeZone?: string | undefined };\n\nexport type DateTimeInputProps<T extends DateTimeValueType = \"local\"> =\n DateTimeOwnProps<T> & DateTimeZoneProps<T>;\n\ntype LocalProps = DateTimeInputProps;\ntype InstantProps = DateTimeInputProps<\"instant\">;\n\n/** The day of a wall clock. */\nfunction dayOf(dateTime: PlainDateTime): PlainDate {\n return dateTime.slice(0, 10) as PlainDate;\n}\n\n/**\n * What both kinds of date-time input share: settings, the layout, today,\n * and the time a date gets when only the date was given, which is the\n * time already typed in the segments, else `defaultTime`. So a shortcut\n * (`t`, `+3`) or a pasted date sets the date and keeps the time.\n */\nfunction useDateTimeSetup(\n props: LocalProps | InstantProps,\n todayZone: string | undefined,\n) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const [segments] = useState(createSegmentsAccess);\n const { hourCycle, precision, numberingSystem, displayFormat } = props;\n const layout = dateLayout(\n { locale, fields: \"dateTime\", hourCycle, precision, numberingSystem },\n messages,\n );\n const today = todayFor(todayZone);\n const base = {\n today,\n shortcuts: props.shortcuts ?? true,\n hourCycle,\n precision,\n numberingSystem,\n displayFormat,\n activeSegment: () => typingSegment(segments),\n } satisfies Partial<DateTimeFieldOptions>;\n const keptTime = (): PlainTime =>\n segmentsTime(layout, typedSegments(segments)) ??\n props.defaultTime ??\n \"00:00\";\n return {\n locale,\n messages,\n segments,\n layout,\n today,\n base,\n keptTime,\n needsValue: props.required === true || field?.required === true,\n };\n}\n\n/** How a date-time input's value reads as a wall clock in its zone, and back. */\ninterface WallClockView<V> {\n readonly toWall: (value: V) => PlainDateTime;\n readonly fromWall: (wall: PlainDateTime) => V;\n readonly zone: string | undefined;\n}\n\n/**\n * A date-time input's picker: a calendar and time columns working on the\n * wall clock its value shows, unless `calendar` is `false`.\n */\nfunction dateTimePicker<V>(\n props: LocalProps | InstantProps,\n setup: ReturnType<typeof useDateTimeSetup>,\n view: WallClockView<V>,\n limits: { readonly min: V | undefined; readonly max: V | undefined },\n): SegmentedPicker<V> | undefined {\n if (props.calendar === false) {\n return undefined;\n }\n const { locale, messages, layout, today, keptTime } = setup;\n const wallOf = (value: V | undefined) =>\n value === undefined ? null : view.toWall(value);\n return {\n label: messages.chooseDateTime,\n icon: <CalendarIcon />,\n buttonClassName: \"gridkit-forms-calendar-button\",\n popupClassName: \"gridkit-forms-date-time-popup\",\n onOpenChange: props.onOpenChange,\n initialFocus: (panel) => segmentTimeOption(panel) ?? focusedDay(panel),\n content: ({ value, id, pick, close, setEscapeHandler }) => (\n <DateTimePicker\n id={id}\n value={value === null ? null : view.toWall(value)}\n layout={layout}\n minuteStep={props.minuteStep}\n min={wallOf(limits.min)}\n max={wallOf(limits.max)}\n isDateDisabled={props.isDateDisabled}\n timeZone={view.zone}\n firstDayOfWeek={props.firstDayOfWeek}\n weekNumbers={props.weekNumbers}\n weekNumbering={props.weekNumbering}\n locale={locale}\n strings={messages}\n today={today}\n now={nowFor(view.zone)}\n keptTime={keptTime}\n onPick={(wall, nativeEvent) => {\n pick(view.fromWall(wall), nativeEvent);\n }}\n close={close}\n setEscapeHandler={setEscapeHandler}\n />\n ),\n };\n}\n\nfunction LocalDateTimeControl(props: LocalProps) {\n const { min, max, isDateDisabled, validate, minuteStep, timeZone } = props;\n const setup = useDateTimeSetup(props, timeZone);\n const { locale, messages, base, today } = setup;\n const { displayFormat } = props;\n const options = (): DateTimeFieldOptions => ({\n ...base,\n min,\n max,\n defaultTime: setup.keptTime(),\n });\n const kind: SegmentedKind<PlainDateTime, DateTimeDetails> = {\n name: \"DateTimeInput\",\n layout: setup.layout,\n defaultParse: (text, context) => dateTimeParser(options())(text, context),\n defaultFormat: dateTimeFormatter(base),\n details: (current, _previous, cause) =>\n dateTimeDetails(current, cause, { ...options(), locale, messages }),\n display: (value) => formatDateTime(value, locale, displayFormat),\n serialize: (value) => value,\n isValue: isPlainDateTime,\n inLimits: (value) =>\n (min === undefined || compareDateTimes(value, min) >= 0) &&\n (max === undefined || compareDateTimes(value, max) <= 0),\n shortcuts: base.shortcuts,\n minuteStep,\n today,\n pivot: (digits) =>\n pivotYear(digits, {\n today: today(),\n min: min === undefined ? null : dayOf(min),\n max: max === undefined ? null : dayOf(max),\n }),\n };\n const { needsValue } = setup;\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<PlainDateTime>()] : []),\n ...(min === undefined ? [] : [minDateTimeRule(min, displayFormat)]),\n ...(max === undefined ? [] : [maxDateTimeRule(max, displayFormat)]),\n ...(isDateDisabled === undefined\n ? []\n : [availableDateRule<PlainDateTime>(isDateDisabled)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, displayFormat, isDateDisabled, validate],\n );\n\n return (\n <SegmentedControl\n props={{ ...props, validate: validators }}\n kind={kind}\n rootClassName=\"gridkit-forms-date-time-input\"\n segments={setup.segments}\n picker={dateTimePicker(\n props,\n setup,\n {\n toWall: (value: PlainDateTime) => value,\n fromWall: (wall) => wall,\n zone: timeZone,\n },\n { min, max },\n )}\n />\n );\n}\n\n/** The info message for a wall clock read across a daylight-saving change, while the field holds what it was read as. */\ninterface ZoneNote {\n readonly value: Instant | null;\n readonly message: FieldMessageInput;\n}\n\n/** Keeps the info message an instant's typed wall clock earns, from the change that read it until the value changes. */\nfunction useZoneNote(\n options: () => InstantFieldOptions,\n locale: Intl.LocalesArgument,\n messages: ReturnType<typeof useInputSettings>[\"messages\"],\n onChange: InstantProps[\"onChange\"],\n) {\n const [note, setNote] = useState<ZoneNote | null>(null);\n return {\n note: (value: Instant | null) =>\n note !== null && note.value === value ? note.message : null,\n onChange: (event: FieldChangeEvent<Instant, DateTimeDetails>) => {\n const text = instantZoneMessage(event.text, {\n ...options(),\n locale,\n messages,\n });\n setNote(\n text === null\n ? null\n : { value: event.value, message: { text, severity: \"info\" } },\n );\n onChange?.(event);\n },\n };\n}\n\nfunction InstantControl(props: InstantProps) {\n const {\n min,\n max,\n isDateDisabled,\n validate,\n minuteStep,\n timeZone,\n disambiguation,\n } = props;\n const setup = useDateTimeSetup(props, timeZone);\n const { locale, messages, base, today } = setup;\n const { displayFormat } = props;\n const options = (): InstantFieldOptions => ({\n ...base,\n timeZone,\n disambiguation,\n min,\n max,\n defaultTime: setup.keptTime(),\n });\n const zone = useZoneNote(options, locale, messages, props.onChange);\n const wallDay = (limit: Instant | undefined) =>\n limit === undefined ? null : dayOf(wallClockOf(limit, timeZone));\n const kind: SegmentedKind<Instant, DateTimeDetails> = {\n name: \"DateTimeInput\",\n layout: setup.layout,\n defaultParse: (text, context) => instantParser(options())(text, context),\n defaultFormat: instantFormatter({ ...base, timeZone }),\n details: (current, _previous, cause) =>\n instantDetails(current, cause, { ...options(), locale, messages }),\n display: (value) => formatInstant(value, timeZone, locale, displayFormat),\n serialize: (value) => value,\n isValue: isInstant,\n inLimits: (value) =>\n (min === undefined || compareInstants(value, min) >= 0) &&\n (max === undefined || compareInstants(value, max) <= 0),\n shortcuts: base.shortcuts,\n minuteStep,\n today,\n pivot: (digits) =>\n pivotYear(digits, {\n today: today(),\n min: wallDay(min),\n max: wallDay(max),\n }),\n note: zone.note,\n };\n const { needsValue } = setup;\n const validators = useMemo(() => {\n const available: Validator<PlainDateTime> | null =\n isDateDisabled === undefined ? null : availableDateRule(isDateDisabled);\n return [\n ...(needsValue ? [requiredRule<Instant>()] : []),\n ...(min === undefined\n ? []\n : [minInstantRule(min, timeZone, displayFormat)]),\n ...(max === undefined\n ? []\n : [maxInstantRule(max, timeZone, displayFormat)]),\n ...(available === null\n ? []\n : [\n ((value, context) =>\n available(\n value === null ? null : wallClockOf(value, timeZone),\n context,\n )) satisfies Validator<Instant>,\n ]),\n ...validatorsOf(validate),\n ];\n }, [needsValue, min, max, timeZone, displayFormat, isDateDisabled, validate]);\n\n return (\n <SegmentedControl\n props={{ ...props, validate: validators, onChange: zone.onChange }}\n kind={kind}\n rootClassName=\"gridkit-forms-date-time-input\"\n segments={setup.segments}\n picker={dateTimePicker(\n props,\n setup,\n {\n toWall: (value: Instant) => wallClockOf(value, timeZone),\n fromWall: (wall) => exactInstantOf(wall, timeZone, disambiguation),\n zone: timeZone,\n },\n { min, max },\n )}\n />\n );\n}\n\n/** Whether `props` are an instant input's. */\nfunction isInstantProps(\n props: LocalProps | InstantProps,\n): props is InstantProps {\n return props.valueType === \"instant\";\n}\n\n/**\n * A date and a time typed in segments in the locale's order\n * (`03/14/2026, 3:05 PM` in en-US): `DateInput`'s keys and shortcuts for\n * the date, `TimeInput`'s for the time, one Tab stop for both. A shortcut\n * or a pasted date sets the date and keeps a time already typed; a date\n * whose time is left empty takes `defaultTime`. The calendar button, F4 or\n * Alt+ArrowDown opens a calendar with time columns beside it, to choose\n * both with the mouse alone. Its value is a wall clock,\n * a `PlainDateTime` (`\"2026-03-14T15:05\"`), or with `valueType=\"instant\"`\n * an exact moment, an `Instant` (`\"2026-03-14T14:05:00.000Z\"`) typed and\n * shown in the `timeZone` it requires. A wall clock in an hour the zone\n * skips or repeats is read as `disambiguation` says, with an info message\n * until the value changes. It takes every shared input prop and the\n * events of `@gridkitjs/forms` with `DateTimeDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function DateTimeInput<T extends DateTimeValueType = \"local\">(\n props: DateTimeInputProps<T>,\n) {\n // `T` is decided by `valueType` alone, so it tells the two apart.\n const known = props as unknown as LocalProps | InstantProps;\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n {isInstantProps(known) ? (\n <InstantControl {...known} />\n ) : (\n <LocalDateTimeControl {...known} />\n )}\n </InputFrame>\n );\n}\n","import {\n clampCalendarDate,\n clampTime,\n dayTimeLimits,\n isCalendarDayDisabled,\n plainDateTime,\n setTimeColumn,\n snapTime,\n splitDateTime,\n timeColumns,\n type DateLayout,\n type FormsMessages,\n type PlainDate,\n type PlainDateTime,\n type PlainTime,\n type PopupCloseReason,\n} from \"@gridkitjs/forms-core\";\nimport type { CalendarSettings } from \"../calendar/calendarProps\";\nimport { PopupCalendar } from \"../calendar/PopupCalendar\";\nimport { TimeColumns } from \"./TimeColumns\";\n\n/** What a date-time input's popup reads, in wall-clock terms whatever the input holds. */\nexport interface DateTimePickerProps extends CalendarSettings {\n /** The popup's `id`, the prefix of its own ids. */\n readonly id: string;\n readonly value: PlainDateTime | null;\n readonly layout: DateLayout;\n readonly minuteStep?: number | undefined;\n readonly min: PlainDateTime | null;\n readonly max: PlainDateTime | null;\n readonly isDateDisabled?: ((date: PlainDate) => boolean) | undefined;\n /** The zone \"today\" is in, for the calendar. */\n readonly timeZone: string | undefined;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** Today, and the wall clock now, read when asked for. */\n readonly today: () => PlainDate;\n readonly now: () => PlainDateTime;\n /** The time a day chosen with no value yet gets: the time typed, else `defaultTime`. */\n readonly keptTime: () => PlainTime;\n readonly onPick: (value: PlainDateTime, nativeEvent: Event) => void;\n readonly close: (reason: PopupCloseReason) => void;\n readonly setEscapeHandler: (handler: (() => boolean) | null) => void;\n}\n\n/**\n * What a date-time input's popup shows: the calendar, with forms-core's\n * time columns beside it, and \"Now\" and \"Done\" buttons. A day chosen by a\n * click or Space keeps the time (the one typed, else `defaultTime`, while\n * the field is empty) and leaves the popup open for the time; a choice in\n * a column sets that part of the time at once. Enter, on a day or in a\n * column, closes it after its choice, as \"Done\" does; \"Now\" picks the\n * time it is now and closes it. Times outside `min` and `max` on the day\n * shown are disabled, and a day chosen brings its time within them.\n */\nexport function DateTimePicker({\n id,\n value,\n layout,\n minuteStep,\n min,\n max,\n isDateDisabled,\n timeZone,\n firstDayOfWeek,\n weekNumbers,\n weekNumbering,\n locale,\n strings,\n today,\n now,\n keptTime,\n onPick,\n close,\n setEscapeHandler,\n}: DateTimePickerProps) {\n const chosen = value === null ? null : splitDateTime(value);\n const dayLimits = {\n min: min === null ? undefined : splitDateTime(min).date,\n max: max === null ? undefined : splitDateTime(max).date,\n isDateDisabled,\n };\n // The day the columns set a time on: the value's, else today within the limits.\n const day = chosen?.date ?? clampCalendarDate(today(), dayLimits);\n const columnOptions = (on: PlainDate) => ({\n layout,\n minuteStep,\n ...dayTimeLimits(on, min, max),\n });\n const nowDay = splitDateTime(now()).date;\n\n return (\n <>\n <div className=\"gridkit-forms-date-time-picker\">\n <PopupCalendar\n id={id}\n selected={chosen?.date ?? null}\n min={dayLimits.min}\n max={dayLimits.max}\n isDateDisabled={isDateDisabled}\n timeZone={timeZone}\n firstDayOfWeek={firstDayOfWeek}\n weekNumbers={weekNumbers}\n weekNumbering={weekNumbering}\n locale={locale}\n strings={strings}\n onChoose={(date, nativeEvent) => {\n const time = clampTime(\n chosen?.time ?? keptTime(),\n dayTimeLimits(date, min, max),\n );\n onPick(plainDateTime(date, time), nativeEvent);\n if (\n nativeEvent instanceof KeyboardEvent &&\n nativeEvent.key === \"Enter\"\n ) {\n close(\"picker\");\n }\n }}\n setEscapeHandler={setEscapeHandler}\n />\n <TimeColumns\n id={id}\n columns={timeColumns(chosen?.time ?? null, columnOptions(day))}\n onSet={(type, part, nativeEvent) => {\n const time = setTimeColumn(\n chosen?.time ?? keptTime(),\n type,\n part,\n columnOptions(day),\n );\n onPick(plainDateTime(day, time), nativeEvent);\n }}\n onDone={() => {\n close(\"picker\");\n }}\n />\n </div>\n <div className=\"gridkit-forms-picker-footer\">\n <button\n type=\"button\"\n className=\"gridkit-forms-picker-action\"\n disabled={isCalendarDayDisabled(nowDay, dayLimits)}\n onClick={(event) => {\n const { date, time } = splitDateTime(now());\n onPick(\n plainDateTime(date, snapTime(time, columnOptions(date))),\n event.nativeEvent,\n );\n close(\"picker\");\n }}\n >\n {strings.pickerNow}\n </button>\n <button\n type=\"button\"\n className=\"gridkit-forms-picker-action is-done\"\n onClick={() => {\n close(\"picker\");\n }}\n >\n {strings.pickerDone}\n </button>\n </div>\n </>\n );\n}\n","import type {\n TimeColumn,\n TimeColumnOption,\n TimeColumnType,\n} from \"@gridkitjs/forms-core\";\nimport { useLayoutEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport { isRightToLeft } from \"../calendar/useCalendarNavigation\";\nimport { classNames } from \"../field/parts\";\n\n/** How many options PageUp and PageDown move. */\nconst PAGE = 5;\n\nconst COLUMN_SELECTOR = \"[data-gridkit-forms-time-column]\";\nconst ACTIVE_OPTION = '[role=\"option\"][tabindex=\"0\"]';\n\n/** A column's state class: `is-hour`, `is-day-period`. */\nfunction columnClass(type: TimeColumnType): string {\n return type === \"dayPeriod\" ? \"is-day-period\" : `is-${type}`;\n}\n\n/** Moves focus to `option`, scrolling its column only as far as it takes. */\nfunction focusOption(option: Element | null | undefined): void {\n if (option instanceof HTMLElement) {\n option.focus({ preventScroll: true });\n option.scrollIntoView({ block: \"nearest\" });\n }\n}\n\n/**\n * The option a time picker's focus starts on: in the column of the time\n * segment that had focus as the popup opened, else `null`.\n */\nexport function segmentTimeOption(panel: HTMLElement): HTMLElement | null {\n const active = panel.ownerDocument.activeElement;\n const type =\n active instanceof HTMLElement\n ? active.dataset.gridkitFormsSegment\n : undefined;\n if (type === undefined) {\n return null;\n }\n return panel.querySelector<HTMLElement>(\n `[data-gridkit-forms-time-column=\"${type}\"] ${ACTIVE_OPTION}`,\n );\n}\n\n/** The option of a time picker's first column that takes focus. */\nexport function firstTimeOption(panel: HTMLElement): HTMLElement | null {\n return panel.querySelector<HTMLElement>(\n `${COLUMN_SELECTOR} ${ACTIVE_OPTION}`,\n );\n}\n\n/** The option that takes focus when the column has none chosen: the first enabled one. */\nfunction fallbackOf(options: readonly TimeColumnOption[]): number {\n return (options.find((option) => !option.disabled) ?? options[0])?.value ?? 0;\n}\n\n/** Where a key moves in a column of `count` options from `index`, or `null` for a key that moves nothing. */\nfunction movedIndex(key: string, index: number, count: number): number | null {\n const moves: Readonly<Record<string, number>> = {\n ArrowDown: index + 1,\n ArrowUp: index - 1,\n PageDown: index + PAGE,\n PageUp: index - PAGE,\n Home: 0,\n End: count - 1,\n };\n const move = moves[key];\n return move === undefined ? null : Math.min(Math.max(move, 0), count - 1);\n}\n\n/**\n * One column of a time picker: a listbox of its options, one Tab stop,\n * whose chosen option scrolls into the middle as it appears. The arrows,\n * Home, End, PageUp and PageDown move through it and choose the option\n * they land on unless it is disabled; Space chooses, Enter chooses and\n * calls `onDone`; ArrowLeft and ArrowRight move to the columns either side.\n */\nfunction TimeColumnList({\n id,\n column,\n onSet,\n onDone,\n}: {\n readonly id: string;\n readonly column: TimeColumn;\n readonly onSet: (value: number, nativeEvent: Event) => void;\n readonly onDone: (nativeEvent: Event) => void;\n}) {\n const listRef = useRef<HTMLDivElement>(null);\n // Where focus moved to without choosing: a disabled option.\n const [moved, setMoved] = useState<number | null>(null);\n const { options, selected } = column;\n const active = moved ?? selected ?? fallbackOf(options);\n\n useLayoutEffect(() => {\n const list = listRef.current;\n const option = list?.querySelector<HTMLElement>(ACTIVE_OPTION);\n if (list === null || option === null || option === undefined) {\n return;\n }\n const listBox = list.getBoundingClientRect();\n const optionBox = option.getBoundingClientRect();\n list.scrollTop +=\n optionBox.top - listBox.top - (list.clientHeight - optionBox.height) / 2;\n }, []);\n\n function choose(option: TimeColumnOption, nativeEvent: Event): void {\n setMoved(option.disabled ? option.value : null);\n if (!option.disabled && option.value !== selected) {\n onSet(option.value, nativeEvent);\n }\n }\n\n function optionElement(value: number): Element | null | undefined {\n return listRef.current?.querySelector(\n `[data-gridkit-forms-time-value=\"${String(value)}\"]`,\n );\n }\n\n function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n if (event.altKey || event.ctrlKey || event.metaKey) {\n return;\n }\n const index = options.findIndex((option) => option.value === active);\n const current = options[index];\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n if (current !== undefined) {\n choose(current, event.nativeEvent);\n }\n if (event.key === \"Enter\") {\n onDone(event.nativeEvent);\n }\n return;\n }\n if (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\") {\n const columns = Array.from(\n event.currentTarget\n .closest(\".gridkit-forms-time-columns\")\n ?.querySelectorAll(COLUMN_SELECTOR) ?? [],\n );\n const forward =\n (event.key === \"ArrowRight\") !== isRightToLeft(event.currentTarget);\n const next =\n columns[columns.indexOf(event.currentTarget) + (forward ? 1 : -1)];\n if (next !== undefined) {\n event.preventDefault();\n focusOption(next.querySelector(ACTIVE_OPTION));\n }\n return;\n }\n const nextIndex = movedIndex(event.key, index, options.length);\n const next = nextIndex === null ? undefined : options[nextIndex];\n if (next !== undefined) {\n event.preventDefault();\n choose(next, event.nativeEvent);\n focusOption(optionElement(next.value));\n }\n }\n\n return (\n <div\n ref={listRef}\n className={classNames(\n \"gridkit-forms-time-column\",\n columnClass(column.type),\n )}\n data-gridkit-forms-time-column={column.type}\n role=\"listbox\"\n aria-label={column.label}\n // Firefox makes a scrolling box a Tab stop of its own; the option is the column's one.\n tabIndex={-1}\n onKeyDown={onKeyDown}\n >\n {options.map((option) => {\n const isSelected = option.value === selected;\n return (\n <div\n key={option.value}\n id={`${id}-${column.type}-${String(option.value)}`}\n className={classNames(\n \"gridkit-forms-time-option\",\n isSelected && \"is-selected\",\n option.disabled && \"is-disabled\",\n )}\n data-gridkit-forms-time-value={option.value}\n role=\"option\"\n tabIndex={option.value === active ? 0 : -1}\n aria-selected={isSelected}\n aria-disabled={option.disabled || undefined}\n onClick={(event) => {\n choose(option, event.nativeEvent);\n }}\n >\n {option.text}\n </div>\n );\n })}\n </div>\n );\n}\n\n/**\n * A time picker's columns side by side, in the field's order and\n * direction: each a listbox from forms-core's `timeColumns`. A click or a\n * key that lands on an option calls `onSet` with its column and value at\n * once; Enter calls `onDone`.\n */\nexport function TimeColumns({\n id,\n columns,\n onSet,\n onDone,\n}: {\n /** The prefix of the options' ids. */\n readonly id: string;\n readonly columns: readonly TimeColumn[];\n readonly onSet: (\n type: TimeColumnType,\n value: number,\n nativeEvent: Event,\n ) => void;\n readonly onDone: (nativeEvent: Event) => void;\n}) {\n return (\n <div className=\"gridkit-forms-time-columns\">\n {columns.map((column) => (\n <TimeColumnList\n key={column.type}\n id={id}\n column={column}\n onSet={(value, nativeEvent) => {\n onSet(column.type, value, nativeEvent);\n }}\n onDone={onDone}\n />\n ))}\n </div>\n );\n}\n","import {\n compareTimes,\n dateLayout,\n formatTime,\n isPlainTime,\n maxTimeRule,\n minTimeRule,\n requiredRule,\n splitDateTime,\n timeDetails,\n timeFormatter,\n timeParser,\n type PlainDate,\n type PlainTime,\n type PopupOpenChange,\n type TimeDetails,\n type TimeFieldOptions,\n} from \"@gridkitjs/forms-core\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { warnOnce } from \"../dev\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { ClockIcon, InputFrame } from \"../text/parts\";\nimport { firstTimeOption, segmentTimeOption } from \"../time/TimeColumns\";\nimport { TimePicker } from \"../time/TimePicker\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { nowFor } from \"./DateInput\";\nimport { SegmentedControl } from \"./SegmentedControl\";\nimport type { SegmentedInputProps, TimeSettings } from \"./segmentedProps\";\nimport { createSegmentsAccess, type SegmentedKind } from \"./useSegmentedInput\";\n\nexport interface TimeInputProps\n extends SegmentedInputProps<PlainTime, TimeDetails>, TimeSettings {\n /** The earliest time allowed, inclusive. */\n readonly min?: PlainTime | undefined;\n /** The latest time allowed, inclusive. */\n readonly max?: PlainTime | undefined;\n /** The clock button and its popup of time columns; on by default. */\n readonly picker?: boolean | undefined;\n /** The time columns' popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n}\n\n/** A time field has no days; its segments step from 0. */\nconst NO_DAY: PlainDate = \"2000-01-01\";\n\nfunction TimeInputControl({\n min,\n max,\n hourCycle,\n precision,\n minuteStep,\n picker = true,\n onOpenChange,\n required,\n validate,\n ...props\n}: TimeInputProps) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const [segments] = useState(createSegmentsAccess);\n const { numberingSystem, displayFormat } = props;\n const needsValue = required === true || field?.required === true;\n const overMidnight =\n min !== undefined && max !== undefined && compareTimes(min, max) > 0;\n useEffect(() => {\n if (overMidnight) {\n warnOnce(\n \"time-input-window\",\n \"TimeInput's min is after its max, which no time of day satisfies. A window over midnight is a TimeRangeInput's.\",\n );\n }\n }, [overMidnight]);\n\n const options: TimeFieldOptions = {\n hourCycle,\n precision,\n numberingSystem,\n displayFormat,\n };\n const kind: SegmentedKind<PlainTime, TimeDetails> = {\n name: \"TimeInput\",\n layout: dateLayout(\n { locale, fields: \"time\", hourCycle, precision, numberingSystem },\n messages,\n ),\n defaultParse: timeParser(options),\n defaultFormat: timeFormatter(options),\n details: (current, _previous, cause) =>\n timeDetails(current, cause, { ...options, locale, messages }),\n display: (value) => formatTime(value, locale, displayFormat),\n serialize: (value) => value,\n isValue: isPlainTime,\n inLimits: (value) =>\n (min === undefined || compareTimes(value, min) >= 0) &&\n (max === undefined || compareTimes(value, max) <= 0),\n shortcuts: false,\n minuteStep,\n today: () => NO_DAY,\n pivot: (digits) => digits,\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<PlainTime>()] : []),\n ...(min === undefined ? [] : [minTimeRule(min, displayFormat)]),\n ...(max === undefined ? [] : [maxTimeRule(max, displayFormat)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, displayFormat, validate],\n );\n\n return (\n <SegmentedControl\n props={{ ...props, required, validate: validators }}\n kind={kind}\n rootClassName=\"gridkit-forms-time-input\"\n segments={segments}\n picker={\n picker\n ? {\n label: messages.chooseTime,\n icon: <ClockIcon />,\n buttonClassName: \"gridkit-forms-time-button\",\n popupClassName: \"gridkit-forms-time-popup\",\n onOpenChange,\n initialFocus: (panel) =>\n segmentTimeOption(panel) ?? firstTimeOption(panel),\n tabOut: true,\n content: ({ value, id, pick, close }) => (\n <TimePicker\n id={id}\n value={value}\n options={{\n layout: kind.layout,\n minuteStep,\n min: min ?? null,\n max: max ?? null,\n }}\n strings={messages}\n now={() => splitDateTime(nowFor(undefined)()).time}\n onPick={pick}\n close={close}\n />\n ),\n }\n : undefined\n }\n />\n );\n}\n\n/**\n * A time of day typed in segments, in the locale's hour cycle (`3:05 PM`\n * in en-US, `15:05` in de-DE) unless `hourCycle` sets one: typing moves on\n * by itself, the arrow keys move between segments and step them (minutes\n * by `minuteStep`), `a` and `p` set the day period, and a pasted time in\n * any common form is read whole. The clock button, F4 or Alt+ArrowDown\n * opens columns of hours, minutes, seconds and day periods to choose from,\n * each choice set at once. Its value is a `PlainTime`, an ISO string\n * (`\"15:05\"`, with seconds under `precision=\"second\"`), `null` when empty.\n * `min` and `max` add their messages. It takes every shared input prop and\n * the events of `@gridkitjs/forms` with `TimeDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function TimeInput(props: TimeInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <TimeInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n setTimeColumn,\n snapTime,\n timeColumns,\n type FormsMessages,\n type PlainTime,\n type PopupCloseReason,\n type TimeColumnsOptions,\n} from \"@gridkitjs/forms-core\";\nimport { TimeColumns } from \"./TimeColumns\";\n\n/**\n * What a time input's popup shows: forms-core's time columns for the\n * field's layout, step and limits, and a \"Now\" button. A choice in a\n * column picks the time with that part set at once and leaves the popup\n * open; Enter closes it, and \"Now\" picks the time it is now (to the step,\n * within the limits) and closes it.\n */\nexport function TimePicker({\n id,\n value,\n options,\n strings,\n now,\n onPick,\n close,\n}: {\n /** The popup's `id`, the prefix of the options' ids. */\n readonly id: string;\n readonly value: PlainTime | null;\n readonly options: TimeColumnsOptions;\n readonly strings: FormsMessages;\n /** The time it is now, read as \"Now\" is pressed. */\n readonly now: () => PlainTime;\n readonly onPick: (time: PlainTime, nativeEvent: Event) => void;\n readonly close: (reason: PopupCloseReason) => void;\n}) {\n return (\n <>\n <TimeColumns\n id={id}\n columns={timeColumns(value, options)}\n onSet={(type, part, nativeEvent) => {\n onPick(setTimeColumn(value, type, part, options), nativeEvent);\n }}\n onDone={() => {\n close(\"picker\");\n }}\n />\n <div className=\"gridkit-forms-picker-footer\">\n <button\n type=\"button\"\n className=\"gridkit-forms-picker-action\"\n onClick={(event) => {\n onPick(snapTime(now(), options), event.nativeEvent);\n close(\"picker\");\n }}\n >\n {strings.pickerNow}\n </button>\n </div>\n </>\n );\n}\n","import {\n hasError,\n mostSevere,\n toFieldMessages,\n type FieldMessageInput,\n} from \"@gridkitjs/forms-core\";\nimport {\n useId,\n useMemo,\n useRef,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport { useSummaryEntry } from \"../form/formContext\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type LabelPosition,\n type NecessityIndicator,\n} from \"../settings\";\nimport {\n FieldContext,\n useControlMessages,\n type FieldContextValue,\n} from \"./fieldContext\";\nimport { FieldMessages } from \"./FieldMessages\";\nimport {\n classNames,\n NecessityMarker,\n spanClass,\n useShownMessages,\n withLabelWidth,\n type FieldSpan,\n} from \"./parts\";\n\nexport interface FieldGroupProps {\n /** Names the group; each input in it needs an `aria-label` of its own. */\n readonly label: ReactNode;\n /** Help text under the inputs, read as part of each one's description. */\n readonly description?: ReactNode;\n /** The app's messages, always shown; a string is an error. */\n readonly message?:\n FieldMessageInput | readonly FieldMessageInput[] | undefined;\n /** Marks the label, and tells every input a value is required. */\n readonly required?: boolean | undefined;\n /** `\"floating\"` is drawn as `\"top\"`: the label names no one control. */\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly necessityIndicator?: NecessityIndicator | undefined;\n /** Columns taken in a `FormLayout`. */\n readonly span?: FieldSpan | undefined;\n /** The group's `id`, which a summary link points at; generated without it. */\n readonly id?: string | undefined;\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n /** Several inputs, each with its own `aria-label`. */\n readonly children?: ReactNode;\n}\n\nfunction ignoreControlState(): void {\n // A group's label names no one control, so it does not float.\n}\n\n/**\n * Several inputs under one label and one message area, such as a postal\n * code and a city: a group the label names, laid out as a field is. Every\n * input is described by the group's description and messages, and lists\n * its own messages in the group's message area.\n */\nexport function FieldGroup({\n label,\n description,\n message,\n required = false,\n labelPosition,\n labelWidth,\n necessityIndicator,\n span,\n id,\n className,\n style,\n children,\n}: FieldGroupProps) {\n const settings = useResolvedSettings({ labelPosition, necessityIndicator });\n const generatedId = useId();\n const groupId = id ?? generatedId;\n const labelId = `${groupId}-label`;\n const descriptionId = `${groupId}-description`;\n const messagesId = `${groupId}-messages`;\n const hasDescription = description !== undefined && description !== null;\n\n const [controlMessages, setControlMessages] = useControlMessages();\n const shown = useShownMessages(controlMessages, message, settings.disabled);\n const severity = mostSevere(\n shown.map((shownMessage) => shownMessage.severity),\n );\n const describedBy = hasDescription\n ? `${descriptionId} ${messagesId}`\n : messagesId;\n // Only the app's error is the whole group's; an input's is its own.\n const invalid = hasError(toFieldMessages(message, \"app\"));\n\n const context = useMemo<FieldContextValue>(\n () => ({\n controlId: null,\n settings,\n describedBy,\n required,\n invalid,\n severity: null,\n setControlMessages,\n setControlState: ignoreControlState,\n }),\n [settings, describedBy, required, invalid, setControlMessages],\n );\n\n const root = useRef<HTMLDivElement>(null);\n useSummaryEntry(groupId, label, shown, root);\n\n const position =\n settings.labelPosition === \"floating\" ? \"top\" : settings.labelPosition;\n\n return (\n <div\n ref={root}\n id={groupId}\n role=\"group\"\n aria-labelledby={labelId}\n className={classNames(\n \"gridkit-forms-field\",\n \"gridkit-forms-field-group\",\n `is-label-${position}`,\n required && \"is-required\",\n severity !== null && `is-${severity}`,\n settings.disabled && \"is-disabled\",\n settings.readOnly && \"is-readonly\",\n settings.mode === \"display\" && \"is-display\",\n settings.density !== \"standard\" && `is-${settings.density}`,\n spanClass(span),\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n >\n <span\n className={classNames(\n \"gridkit-forms-field-label\",\n position === \"hidden\" && \"gridkit-forms-sr-only\",\n )}\n id={labelId}\n >\n {label}\n <NecessityMarker\n required={required}\n indicator={settings.necessityIndicator}\n strings={settings.messages}\n />\n </span>\n <div className=\"gridkit-forms-field-control gridkit-forms-field-group-controls\">\n <FormSettingsProvider settings={settings}>\n <FieldContext value={context}>{children}</FieldContext>\n </FormSettingsProvider>\n </div>\n {hasDescription && (\n <p className=\"gridkit-forms-field-description\" id={descriptionId}>\n {description}\n </p>\n )}\n <FieldMessages\n id={messagesId}\n messages={shown}\n strings={settings.messages}\n />\n </div>\n );\n}\n","import { toFieldMessages, type FieldMessageInput } from \"@gridkitjs/forms-core\";\nimport { useCallback, useId, useLayoutEffect, useRef } from \"react\";\nimport { useFormContext } from \"../form/formContext\";\nimport { useFormSettings, type Density, type FieldMode } from \"../settings\";\nimport { useFieldContext, type FieldControlState } from \"./fieldContext\";\n\n/** The attributes `useField` gives an app's own control, to spread on it. */\nexport interface FieldControlProps {\n readonly id: string;\n readonly \"aria-describedby\": string | undefined;\n readonly \"aria-invalid\": true | undefined;\n readonly \"aria-required\": true | undefined;\n readonly disabled: boolean;\n readonly readOnly: boolean;\n}\n\n/** What an app's own input tells `useField`. */\nexport interface UseFieldOptions {\n /**\n * Called when the `Form` around the input reveals every field's\n * messages, on a submit attempt, so the input shows its own messages as\n * a commit would. The form looks for an invalid control right after, so\n * a native constraint or `setCustomValidity` set here refuses the submit.\n */\n readonly onReveal?: (() => void) | undefined;\n}\n\n/** What `useField` gives an app's own input. */\nexport interface UseFieldResult {\n /** Spread onto the control. */\n readonly controlProps: FieldControlProps;\n readonly mode: FieldMode;\n readonly density: Density;\n /** The field is marked required: the input checks for a value itself. */\n readonly required: boolean;\n /**\n * Lists the input's own messages under the field, with the field's. Call\n * it from an effect, with `null` once there are none.\n */\n readonly reportMessages: (\n messages: FieldMessageInput | readonly FieldMessageInput[] | null,\n ) => void;\n /**\n * Tells the field whether the control is focused and empty, which a\n * floating label follows, and whether the input needs a value by a\n * `required` of its own, which marks the label. Call it from an effect\n * whenever any of them changes.\n */\n readonly reportControlState: (state: FieldControlState) => void;\n}\n\n/**\n * Wires an app's own input into the `Field` around it: the control's `id`\n * that the label names, its description, the invalid and required states,\n * and `readOnly` and `disabled` from the field and the form. Outside a\n * `Field` it gives the form's settings and an `id` of its own, and the\n * reports go nowhere.\n */\nexport function useField(options: UseFieldOptions = {}): UseFieldResult {\n const field = useFieldContext();\n const form = useFormContext();\n const formSettings = useFormSettings();\n const ownId = useId();\n\n // The latest callback, read when the form reveals, so a new function on\n // every render does not add the input to the form again.\n const onReveal = useRef(options.onReveal);\n useLayoutEffect(() => {\n onReveal.current = options.onReveal;\n });\n useLayoutEffect(\n () =>\n form?.registry.addRevealer(() => {\n onReveal.current?.();\n }),\n [form],\n );\n const settings = field?.settings ?? formSettings;\n const setControlMessages = field?.setControlMessages;\n const setControlState = field?.setControlState;\n\n const reportMessages = useCallback(\n (messages: FieldMessageInput | readonly FieldMessageInput[] | null) => {\n setControlMessages?.(ownId, toFieldMessages(messages, \"app\"));\n },\n [setControlMessages, ownId],\n );\n const reportControlState = useCallback(\n (state: FieldControlState) => {\n setControlState?.(state);\n },\n [setControlState],\n );\n\n return {\n controlProps: {\n id: field?.controlId ?? ownId,\n \"aria-describedby\": field?.describedBy,\n \"aria-invalid\": field?.invalid === true || undefined,\n \"aria-required\": field?.required === true || undefined,\n disabled: settings.disabled,\n readOnly: settings.readOnly,\n },\n mode: settings.mode,\n density: settings.density,\n required: field?.required ?? false,\n reportMessages,\n reportControlState,\n };\n}\n","import type { FormsMessages } from \"@gridkitjs/forms-core\";\nimport {\n attachEnterNavigation,\n findFirstInvalidControl,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useLayoutEffect,\n useState,\n type CSSProperties,\n type ReactNode,\n type Ref,\n type RefCallback,\n type SubmitEvent,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { classNames, withLabelWidth } from \"../field/parts\";\nimport { setRef } from \"../refs\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type FieldMode,\n type LabelPosition,\n type NecessityIndicator,\n} from \"../settings\";\nimport { createFormContext, FormContext } from \"./formContext\";\n\nexport interface FormProps {\n /** `\"display\"` shows every field as text. */\n readonly mode?: FieldMode | undefined;\n readonly density?: Density | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly necessityIndicator?: NecessityIndicator | undefined;\n /**\n * Enter in a single-line field, a checkbox or a switch moves to the next\n * field rather than submitting; from the last one it submits.\n */\n readonly enterMovesToNextField?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly disabled?: boolean | undefined;\n readonly locale?: Intl.LocalesArgument;\n /** Strings laid over the default English ones. */\n readonly messages?: Partial<FormsMessages> | undefined;\n /**\n * Lets every submit through without checking the fields, for a form\n * library that validates itself.\n */\n readonly noValidate?: boolean | undefined;\n /** Called only for a submit the form lets through. */\n readonly onSubmit?:\n ((event: SubmitEvent<HTMLFormElement>) => void) | undefined;\n /**\n * The form's `action`: a URL, or a React form action, which runs only\n * for a submit the form lets through.\n */\n readonly action?:\n string | ((formData: FormData) => void | Promise<void>) | undefined;\n readonly ref?: Ref<HTMLFormElement> | undefined;\n readonly id?: string | undefined;\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n readonly \"aria-label\"?: string | undefined;\n readonly \"aria-labelledby\"?: string | undefined;\n readonly children?: ReactNode;\n}\n\n/**\n * A `<form>` whose fields share its mode, density, label position and\n * width, necessity indicator, `readOnly` and `disabled`, and which refuses\n * a submit while a field holds an error.\n *\n * On a submit it reveals every field's messages, then looks for the first\n * invalid control in document order: a field showing an error, or a native\n * constraint of an app's own control. If there is one it cancels the\n * submit, so neither `onSubmit` nor a React form action runs, and moves\n * focus to the form's `MessageSummary` if it shows, or else to that\n * control, opening a collapsed section around it first. The browser's own\n * validation bubbles never show: the fields show their messages instead.\n */\nexport function Form({\n mode,\n density,\n labelPosition,\n labelWidth,\n necessityIndicator,\n enterMovesToNextField = false,\n readOnly,\n disabled,\n locale,\n messages,\n noValidate = false,\n onSubmit,\n action,\n ref,\n id,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n children,\n}: FormProps) {\n const settings = useResolvedSettings({\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n locale,\n messages,\n });\n const [context] = useState(createFormContext);\n\n const [form, setForm] = useState<HTMLFormElement | null>(null);\n const formRef = useCallback<RefCallback<HTMLFormElement>>(\n (element) => {\n setForm(element);\n const release = setRef(ref, element);\n return () => {\n setForm(null);\n release?.();\n };\n },\n [ref],\n );\n useLayoutEffect(() => {\n if (form === null || !enterMovesToNextField) {\n return undefined;\n }\n return attachEnterNavigation(form).detach;\n }, [form, enterMovesToNextField]);\n\n function handleSubmit(event: SubmitEvent<HTMLFormElement>): void {\n if (!noValidate) {\n // Rendered at once, so the summary lists the messages before it is\n // focused.\n flushSync(() => {\n context.registry.revealAll();\n });\n const invalid = findFirstInvalidControl(event.currentTarget);\n if (invalid !== null) {\n event.preventDefault();\n const summary = context.getSummary();\n if (summary === null) {\n context.focusControl(invalid);\n } else {\n summary.focus();\n }\n return;\n }\n }\n onSubmit?.(event);\n }\n\n return (\n <form\n ref={formRef}\n id={id}\n noValidate\n action={action}\n onSubmit={handleSubmit}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={classNames(\n \"gridkit-forms-form\",\n settings.mode === \"display\" && \"is-display\",\n settings.density !== \"standard\" && `is-${settings.density}`,\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n >\n <FormContext value={context}>\n <FormSettingsProvider settings={settings}>\n {children}\n </FormSettingsProvider>\n </FormContext>\n </form>\n );\n}\n","import type { FormsMessages } from \"@gridkitjs/forms-core\";\nimport type { ReactNode } from \"react\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n} from \"./settings\";\n\nexport interface FormsProviderProps {\n /** Formats counts, for every forms component under it. */\n readonly locale?: Intl.LocalesArgument;\n /** Strings laid over the default English ones. */\n readonly messages?: Partial<FormsMessages> | undefined;\n readonly density?: Density | undefined;\n readonly children?: ReactNode;\n}\n\n/**\n * Sets the locale, strings and density of every forms component under it,\n * inside a `Form` or not. A `Form`, a layout level, a field or an input\n * that sets one of them itself wins over the provider.\n */\nexport function FormsProvider({\n locale,\n messages,\n density,\n children,\n}: FormsProviderProps) {\n const settings = useResolvedSettings({ locale, messages, density });\n return (\n <FormSettingsProvider settings={settings}>{children}</FormSettingsProvider>\n );\n}\n","import { summarizeMessages, type Severity } from \"@gridkitjs/forms-core\";\nimport { focusTargetIn } from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useId,\n useMemo,\n useSyncExternalStore,\n type MouseEvent,\n type ReactNode,\n type RefCallback,\n} from \"react\";\nimport { SeverityIcon } from \"../field/FieldMessages\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport { useFormContext, type FormContextValue } from \"./formContext\";\n\nexport interface MessageSummaryProps {\n /** In place of \"There are 2 problems with this form\". */\n readonly title?: ReactNode;\n /** The heading element the title is. */\n readonly headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined;\n /** Which messages it lists. */\n readonly severities?: readonly Severity[] | undefined;\n readonly className?: string | undefined;\n}\n\nconst DEFAULT_SEVERITIES: readonly Severity[] = [\"error\", \"warning\"];\n\nfunction subscribeToNothing() {\n return () => undefined;\n}\n\nconst NO_FIELDS: readonly never[] = [];\n\n/**\n * Every message the fields of its `Form` show, of the chosen severities,\n * field by field in document order, each a link that focuses its field\n * (opening a collapsed section around it), under a title with the count\n * and a count per severity. It renders nothing while there is nothing to\n * list. A refused submit moves focus to it, so the count is read first.\n */\nexport function MessageSummary({\n title,\n headingLevel = 2,\n severities = DEFAULT_SEVERITIES,\n className,\n}: MessageSummaryProps) {\n const form = useFormContext();\n const { messages } = useFormSettings();\n const titleId = useId();\n const fields = useSyncExternalStore(\n form?.registry.subscribe ?? subscribeToNothing,\n () => form?.registry.getFields() ?? NO_FIELDS,\n () => NO_FIELDS,\n );\n const { items, counts } = useMemo(\n () => summarizeMessages(fields, severities),\n [fields, severities],\n );\n const summaryRef = useCallback<RefCallback<HTMLDivElement>>(\n (element) => (element === null ? undefined : form?.setSummary(element)),\n [form],\n );\n\n if (form === null || items.length === 0) {\n return null;\n }\n const Heading = `h${String(headingLevel)}` as\n \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n\n return (\n <div\n ref={summaryRef}\n role=\"region\"\n aria-labelledby={titleId}\n tabIndex={-1}\n className={classNames(\n \"gridkit-forms-message-summary\",\n `is-${counts[0]?.severity ?? \"error\"}`,\n className,\n )}\n >\n <Heading className=\"gridkit-forms-message-summary-title\" id={titleId}>\n {title ?? messages.messageSummaryTitle(items.length)}\n </Heading>\n <p className=\"gridkit-forms-message-summary-counts\">\n {counts.map(({ severity, count }, index) => (\n <span key={severity}>\n {index > 0 && \", \"}\n <span\n className={`gridkit-forms-message-summary-count is-${severity}`}\n >\n {messages.severityCount(severity, count)}\n </span>\n </span>\n ))}\n </p>\n <ul className=\"gridkit-forms-message-summary-list\">\n {items.map(({ field, message }, index) => (\n <li\n // A field may show two messages with one text.\n key={`${field.id}:${String(index)}`}\n className={`gridkit-forms-message-summary-item is-${message.severity}`}\n >\n <span className=\"gridkit-forms-message-icon\" aria-hidden=\"true\">\n <SeverityIcon severity={message.severity} />\n </span>\n <a\n className=\"gridkit-forms-message-summary-link\"\n href={`#${field.id}`}\n onClick={(event) => {\n focusField(event, form, field.id);\n }}\n >\n {field.label === null ? (\n message.text\n ) : (\n <>\n {field.label}: {message.text}\n </>\n )}\n </a>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n\n/**\n * Focuses the field a summary link points at, rather than only scrolling\n * to it, when it is in the page.\n */\nfunction focusField(\n event: MouseEvent<HTMLAnchorElement>,\n form: FormContextValue,\n id: string,\n): void {\n const target = event.currentTarget.ownerDocument.getElementById(id);\n const control = target === null ? null : focusTargetIn(target);\n if (control !== null) {\n event.preventDefault();\n form.focusControl(control);\n }\n}\n","import { useId, type CSSProperties, type ReactNode } from \"react\";\nimport {\n classNames,\n spanClass,\n withLabelWidth,\n type FieldSpan,\n} from \"../field/parts\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type FieldMode,\n type LabelPosition,\n} from \"../settings\";\n\nexport interface FieldsetProps {\n /** Names the fields inside, as a native `<legend>`. */\n readonly legend: ReactNode;\n /** Under the legend, describing the fieldset. */\n readonly description?: ReactNode;\n readonly mode?: FieldMode | undefined;\n readonly density?: Density | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly readOnly?: boolean | undefined;\n /** Disables every control inside, natively as well. */\n readonly disabled?: boolean | undefined;\n /** Columns taken in a `FormLayout`. */\n readonly span?: FieldSpan | undefined;\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n readonly children?: ReactNode;\n}\n\n/**\n * Several fields under a legend, such as a delivery address, with\n * settings for the fields inside. Usually holds a `FormLayout`.\n */\nexport function Fieldset({\n legend,\n description,\n mode,\n density,\n labelPosition,\n labelWidth,\n readOnly,\n disabled,\n span,\n className,\n style,\n children,\n}: FieldsetProps) {\n const settings = useResolvedSettings({\n mode,\n density,\n labelPosition,\n readOnly,\n disabled,\n });\n const descriptionId = useId();\n const hasDescription = description !== undefined && description !== null;\n return (\n <fieldset\n disabled={disabled}\n aria-describedby={hasDescription ? descriptionId : undefined}\n className={classNames(\n \"gridkit-forms-fieldset\",\n spanClass(span),\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n >\n <legend className=\"gridkit-forms-fieldset-legend\">{legend}</legend>\n {hasDescription && (\n <p className=\"gridkit-forms-fieldset-description\" id={descriptionId}>\n {description}\n </p>\n )}\n <FormSettingsProvider settings={settings}>\n {children}\n </FormSettingsProvider>\n </fieldset>\n );\n}\n","import type { CSSProperties, ReactNode } from \"react\";\nimport { classNames, withLabelWidth } from \"../field/parts\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type LabelPosition,\n} from \"../settings\";\n\nexport interface FormLayoutProps {\n /** The most columns it lays fields out in; fewer as it narrows. */\n readonly columns?: 1 | 2 | 3 | 4 | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly density?: Density | undefined;\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n /** Fields, groups and fieldsets, each taking its `span` of columns. */\n readonly children?: ReactNode;\n}\n\n/**\n * Lays fields out in up to four columns, which drop to fewer as the layout\n * itself narrows: one below 32rem, at most two below 48rem, at most three\n * below 64rem. A field's `span` never takes more columns than the layout\n * has at its width, and start labels stack on top below 30rem. The columns\n * follow the writing direction.\n */\nexport function FormLayout({\n columns = 1,\n labelPosition,\n labelWidth,\n density,\n className,\n style,\n children,\n}: FormLayoutProps) {\n const settings = useResolvedSettings({ labelPosition, density });\n return (\n <div\n className={classNames(\n \"gridkit-forms-layout\",\n columns !== 1 && `is-columns-${String(columns)}`,\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n >\n {/* The columns respond to the outer element's width, which a\n container query cannot read from the grid itself. */}\n <div className=\"gridkit-forms-layout-grid\">\n <FormSettingsProvider settings={settings}>\n {children}\n </FormSettingsProvider>\n </div>\n </div>\n );\n}\n","import {\n useCallback,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { classNames } from \"../field/parts\";\nimport { useFormContext } from \"../form/formContext\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type FieldMode,\n type LabelPosition,\n} from \"../settings\";\n\nexport interface FormSectionProps {\n readonly title: ReactNode;\n /** The heading element the title is. */\n readonly headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined;\n /** Under the title. */\n readonly description?: ReactNode;\n /** The title becomes a button that shows and hides the section's body. */\n readonly collapsible?: boolean | undefined;\n /** Whether a collapsible section is open; present means controlled. */\n readonly expanded?: boolean | undefined;\n /** Whether an uncontrolled collapsible section starts open. */\n readonly defaultExpanded?: boolean | undefined;\n readonly onExpandedChange?: ((expanded: boolean) => void) | undefined;\n readonly mode?: FieldMode | undefined;\n readonly density?: Density | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n readonly readOnly?: boolean | undefined;\n readonly disabled?: boolean | undefined;\n /** The section's `id`; the title's and the body's are made from it. */\n readonly id?: string | undefined;\n readonly className?: string | undefined;\n readonly children?: ReactNode;\n}\n\nfunction Chevron() {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n );\n}\n\n/**\n * A titled part of a long form, with settings for the fields in it. A\n * collapsible one follows the disclosure pattern: its title is a button\n * that shows and hides the body, which stays mounted while hidden, so its\n * fields keep their values. Focus moving to a field inside a collapsed\n * section of a `Form` (a summary link, a refused submit) opens it first.\n */\nexport function FormSection({\n title,\n headingLevel = 2,\n description,\n collapsible = false,\n expanded,\n defaultExpanded = true,\n onExpandedChange,\n mode,\n density,\n labelPosition,\n readOnly,\n disabled,\n id,\n className,\n children,\n}: FormSectionProps) {\n const settings = useResolvedSettings({\n mode,\n density,\n labelPosition,\n readOnly,\n disabled,\n });\n const generatedId = useId();\n const sectionId = id ?? generatedId;\n const titleId = `${sectionId}-title`;\n const bodyId = `${sectionId}-body`;\n const descriptionId = `${sectionId}-description`;\n const hasDescription = description !== undefined && description !== null;\n\n const [ownExpanded, setOwnExpanded] = useState(defaultExpanded);\n const open = !collapsible || (expanded ?? ownExpanded);\n const setOpen = useCallback(\n (next: boolean) => {\n if (expanded === undefined) {\n setOwnExpanded(next);\n }\n onExpandedChange?.(next);\n },\n [expanded, onExpandedChange],\n );\n\n const root = useRef<HTMLElement>(null);\n const form = useFormContext();\n useLayoutEffect(() => {\n const element = root.current;\n if (form === null || element === null || !collapsible) {\n return undefined;\n }\n return form.addSection({\n element,\n expand: () => {\n if (!open) {\n setOpen(true);\n }\n },\n });\n }, [form, collapsible, open, setOpen]);\n\n const Heading = `h${String(headingLevel)}` as\n \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n\n return (\n <section\n ref={root}\n id={sectionId}\n aria-labelledby={titleId}\n aria-describedby={hasDescription ? descriptionId : undefined}\n className={classNames(\n \"gridkit-forms-section\",\n collapsible && \"is-collapsible\",\n !open && \"is-collapsed\",\n className,\n )}\n >\n <div className=\"gridkit-forms-section-header\">\n <Heading className=\"gridkit-forms-section-title\" id={titleId}>\n {collapsible ? (\n <button\n type=\"button\"\n className=\"gridkit-forms-section-toggle\"\n aria-expanded={open}\n aria-controls={bodyId}\n onClick={() => {\n setOpen(!open);\n }}\n >\n <span\n className=\"gridkit-forms-section-toggle-icon\"\n aria-hidden=\"true\"\n >\n <Chevron />\n </span>\n {title}\n </button>\n ) : (\n title\n )}\n </Heading>\n {hasDescription && (\n <p className=\"gridkit-forms-section-description\" id={descriptionId}>\n {description}\n </p>\n )}\n </div>\n <div className=\"gridkit-forms-section-body\" id={bodyId} hidden={!open}>\n <FormSettingsProvider settings={settings}>\n {children}\n </FormSettingsProvider>\n </div>\n </section>\n );\n}\n","import {\n convertDuration,\n durationDetails,\n durationFormatter,\n durationParser,\n formatDuration,\n maxDurationRule,\n minDurationRule,\n requiredRule,\n stepNumberValue,\n type ChangeCause,\n type DurationDetails,\n type DurationNotation,\n type DurationOptions,\n type DurationUnit,\n type StepDirection,\n type StepSize,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, type Ref } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport type { NumberStepEvent } from \"../number/NumberInput\";\nimport { useStepKeys } from \"../number/numberKind\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n OwnMessages,\n useControlElement,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport type { TextInputBaseProps } from \"../text/textInputProps\";\nimport {\n useFieldInput,\n validatorsOf,\n type FieldInputKind,\n} from \"../useFieldInput\";\n\nexport interface DurationInputProps extends TextInputBaseProps<\n number,\n HTMLInputElement,\n DurationDetails\n> {\n /** The unit the value is held in; `\"minute\"` by default, so timesheet values stay whole. */\n readonly valueUnit?: DurationUnit | undefined;\n /** What a bare number means: `\"hour\"` by default, so \"1.5\" is an hour and a half. */\n readonly inputUnit?: \"minute\" | \"hour\" | undefined;\n /** The smallest part that can be typed; finer parts round half up to it. `\"minute\"` by default. */\n readonly precision?: \"minute\" | \"second\" | undefined;\n /** How the value is written: `\"units\"` (\"1h 30m\", default), `\"clock\"` (\"1:30\") or `\"decimal\"` hours (\"1.5\"). */\n readonly notation?: DurationNotation | undefined;\n /** How many hours `d` is: 24 by default, 8 for a working day. */\n readonly hoursPerDay?: number | undefined;\n /** Whether a duration may be negative; off by default. */\n readonly allowNegative?: boolean | undefined;\n /** The shortest duration allowed, in `valueUnit`, inclusive. */\n readonly min?: number | undefined;\n /** The longest duration allowed, in `valueUnit`, inclusive. */\n readonly max?: number | undefined;\n /** What ArrowUp and ArrowDown add, in `valueUnit`: 15 minutes by default. */\n readonly step?: number | undefined;\n /** What PageUp and PageDown add, in `valueUnit`: an hour by default. */\n readonly largeStep?: number | undefined;\n /** Escape puts back the last committed value; on by default. */\n readonly revertOnEscape?: boolean | undefined;\n readonly onStep?: ((event: NumberStepEvent<number>) => void) | undefined;\n readonly ref?: Ref<HTMLInputElement> | undefined;\n}\n\n/** A duration field's `kind`: forms-core's duration parser, formatter and details. */\nfunction durationKind(\n options: DurationOptions,\n): FieldInputKind<number, DurationDetails> {\n return {\n defaultParse: durationParser(options),\n defaultFormat: durationFormatter(options),\n serialize: (value) => String(value),\n details: (current) => durationDetails(current, options),\n };\n}\n\nfunction DurationInputControl({\n valueUnit = \"minute\",\n inputUnit,\n precision,\n notation,\n hoursPerDay,\n allowNegative = false,\n min,\n max,\n step,\n largeStep,\n revertOnEscape = true,\n onStep,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n selectOnFocus = true,\n inputMode = \"text\",\n enterKeyHint,\n autoComplete = \"off\",\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: DurationInputProps) {\n const field = useFieldContext();\n const formSettings = useFormSettings();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const needsValue = required === true || field?.required === true;\n\n const options = useMemo<DurationOptions>(\n () => ({\n locale,\n valueUnit,\n inputUnit,\n precision,\n notation,\n hoursPerDay,\n allowNegative,\n }),\n [\n locale,\n valueUnit,\n inputUnit,\n precision,\n notation,\n hoursPerDay,\n allowNegative,\n ],\n );\n const kind = useMemo(() => durationKind(options), [options]);\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<number>()] : []),\n ...(min === undefined ? [] : [minDurationRule(min, options)]),\n ...(max === undefined ? [] : [maxDurationRule(max, options)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, options, validate],\n );\n\n const [element, controlRef] = useControlElement(ref);\n const input = useFieldInput(\n { ...props, required, validate: validators, ref: controlRef },\n kind,\n {\n startAdornment: hasNode(prefix),\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n },\n );\n const { controlProps, state } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const editable = !controlProps.readOnly && !controlProps.disabled;\n const display = input.mode === \"display\";\n\n const limits = {\n step: step ?? convertDuration(15, \"minute\", valueUnit),\n largeStep: largeStep ?? convertDuration(60, \"minute\", valueUnit),\n // A step never goes below zero in a field that takes no negatives.\n min: allowNegative ? (min ?? null) : Math.max(min ?? 0, 0),\n max: max ?? null,\n };\n\n function takeStep(\n direction: StepDirection,\n size: StepSize,\n nativeEvent: KeyboardEvent | WheelEvent,\n ): void {\n const previous = input.getValue();\n const next = stepNumberValue(previous, { direction, size, ...limits });\n if (next === null || next === previous) {\n return;\n }\n onStep?.({\n direction,\n size,\n via: nativeEvent instanceof WheelEvent ? \"wheel\" : \"key\",\n value: next,\n previousValue: previous,\n nativeEvent,\n });\n const cause: ChangeCause<Event> = {\n source: \"step\",\n nativeEvent,\n input: null,\n };\n input.change(next, cause);\n if (element !== null && element.ownerDocument.activeElement === element) {\n const end = element.value.length;\n element.setSelectionRange(end, end);\n }\n }\n\n useStepKeys(element, editable && !display, {\n onStep: takeStep,\n edges: { min: min !== undefined, max: max !== undefined },\n });\n\n const root = classNames(\n \"gridkit-forms-duration-input\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (display) {\n return (\n <div className={root} style={style}>\n {input.displayValue}\n {input.hiddenInput}\n </div>\n );\n }\n\n const { value } = state;\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n >\n <input\n autoCorrect=\"off\"\n spellCheck={false}\n {...extraControlProps}\n {...controlProps}\n className=\"gridkit-forms-duration-input-control\"\n type=\"text\"\n role=\"spinbutton\"\n placeholder={placeholder}\n autoFocus={autoFocus}\n inputMode={inputMode}\n enterKeyHint={enterKeyHint}\n autoComplete={autoComplete}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n aria-busy={loading || undefined}\n aria-valuenow={value ?? undefined}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuetext={\n value === null ? undefined : formatDuration(value, options)\n }\n />\n </ControlBox>\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * An amount of time typed freely, for timesheets and estimates: `1h 30m`,\n * `1h30`, `90m`, `1:30` or a bare `1.5` (hours, unless `inputUnit` says\n * minutes) all read as 90 minutes, unit words in the locale or English,\n * and a commit rewrites the text in `notation` (\"1h 30m\", \"1:30\" or\n * \"1.5\"). Its value is a number in `valueUnit` (minutes by default),\n * `null` when empty; text that is no duration keeps the last value and\n * says why. It is a spinbutton the arrow keys step by `step` (15\n * minutes) and PageUp and PageDown by `largeStep` (an hour), reporting\n * `onStep` as `NumberInput` does. `min` and `max` add their messages and\n * bound the steps. It takes every shared input prop: display mode,\n * `readOnly`, `disabled`, messages with their severity, density, prefix\n * and suffix, and the events of `@gridkitjs/forms` with `DurationDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function DurationInput(props: DurationInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <DurationInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n compareDecimals,\n filterNumberEdit,\n normalizeDecimal,\n numberDetails,\n numberFormatter,\n numberParser,\n numberToDecimal,\n shiftDecimal,\n type DecimalString,\n type FieldState,\n type NumberDetails,\n type NumberOptions,\n type NumberReadingInfo,\n type NumberValue,\n type NumberValueType,\n type PercentScale,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachStepKeys,\n type AttachedStepKeys,\n type StepKeysOptions,\n} from \"@gridkitjs/forms-dom\";\nimport { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport { warnOnce } from \"../dev\";\nimport type { FieldInputKind } from \"../useFieldInput\";\nimport type { NumberInputProps } from \"./NumberInput\";\n\n/** The props that decide how a number field reads and writes its text. */\nexport type NumberFormatProps<T extends NumberValueType> = Pick<\n NumberInputProps<T>,\n | \"valueType\"\n | \"fractionDigits\"\n | \"minimumFractionDigits\"\n | \"maximumFractionDigits\"\n | \"integer\"\n | \"roundingMode\"\n | \"useGrouping\"\n | \"negative\"\n | \"decimalSeparator\"\n | \"groupSeparator\"\n | \"groupSizes\"\n | \"numberingSystem\"\n | \"currency\"\n | \"currencyDisplay\"\n | \"unit\"\n | \"unitDisplay\"\n>;\n\n/** A number value as an exact decimal string. */\nexport function toDecimal(value: number | string): DecimalString {\n return typeof value === \"number\"\n ? numberToDecimal(value)\n : (normalizeDecimal(value) ?? value);\n}\n\n/** Whether two numbers are the same, compared exactly. */\nexport function sameNumber(a: number | string, b: number | string): boolean {\n return compareDecimals(toDecimal(a), toDecimal(b)) === 0;\n}\n\nconst supported = new Map<string, boolean>();\n\n/** Whether Intl knows the currency code or unit; a dev warning otherwise. */\nfunction isSupported(style: \"currency\" | \"unit\", code: string): boolean {\n const key = `${style}:${code}`;\n let known = supported.get(key);\n if (known === undefined) {\n try {\n new Intl.NumberFormat(\"en\", { style, [style]: code });\n known = true;\n } catch {\n known = false;\n warnOnce(\n key,\n `NumberInput: ${style} \"${code}\" is not one Intl knows, so it is ignored.`,\n );\n }\n supported.set(key, known);\n }\n return known;\n}\n\n/** The style a number field writes in: a percent, else a currency (which wins over a unit), else a unit. */\nfunction numberStyle(\n percentScale: PercentScale | undefined,\n currency: string | undefined,\n unit: string | undefined,\n): NumberOptions[\"style\"] {\n if (percentScale !== undefined) {\n return \"percent\";\n }\n if (currency !== undefined && unit !== undefined) {\n warnOnce(\n \"number-currency-unit\",\n \"NumberInput: both currency and unit are set; the currency is shown.\",\n );\n }\n if (currency !== undefined && isSupported(\"currency\", currency)) {\n return \"currency\";\n }\n if (unit !== undefined && isSupported(\"unit\", unit)) {\n return \"unit\";\n }\n return \"decimal\";\n}\n\n/** How a number field with these props reads and writes, memoized on them. */\nexport function useNumberOptions<T extends NumberValueType>(\n {\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer = false,\n roundingMode,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n }: NumberFormatProps<T>,\n locale: Intl.LocalesArgument,\n percentScale?: PercentScale,\n): NumberOptions {\n const style = numberStyle(percentScale, currency, unit);\n return useMemo<NumberOptions>(\n () => ({\n locale,\n style,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n minimumFractionDigits: integer\n ? 0\n : (fractionDigits ?? minimumFractionDigits),\n maximumFractionDigits: integer\n ? 0\n : (fractionDigits ?? maximumFractionDigits),\n roundingMode,\n useGrouping,\n negative,\n percentScale,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n }),\n [\n locale,\n style,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n integer,\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n roundingMode,\n useGrouping,\n negative,\n percentScale,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n ],\n );\n}\n\n/** A number field's `kind`, its details always given. */\nexport type NumberKind<V> = FieldInputKind<V, NumberDetails> & {\n readonly details: (current: FieldState<V>) => NumberDetails;\n};\n\n/** How a number field's text is judged as it is typed. */\nexport interface NumberEntrySettings<T extends NumberValueType> {\n readonly valueType: T | undefined;\n /** Refuses keys that cannot be part of a number, and cleans pastes. */\n readonly cleanInput: boolean;\n /** Whether a minus may be typed: no `min`, or one below zero. */\n readonly negatives: boolean;\n readonly limitFractionDigits: boolean | undefined;\n readonly decimalEntry: \"fixed\" | \"free\" | undefined;\n}\n\n/**\n * A number field's `kind`: forms-core's parser and formatter, an exact\n * `equals`, `NumberDetails`, and `filterNumberEdit` as its filter. It\n * keeps how clean-up read the paste on screen, until the next edit, for\n * the details, so each field takes a kind of its own.\n */\nexport function numberKind<T extends NumberValueType>(\n options: NumberOptions,\n entry: NumberEntrySettings<T>,\n): NumberKind<NumberValue<T>> {\n let pasted: NumberReadingInfo | null = null;\n return {\n defaultParse: numberParser<T>({ ...options, valueType: entry.valueType }),\n defaultFormat: numberFormatter<NumberValue<T>>(options),\n serialize: (value) => toDecimal(value),\n equals: sameNumber,\n details: (current) => numberDetails(current, options, pasted),\n filterInput: entry.cleanInput\n ? (edit, before) => {\n const result = filterNumberEdit(edit, before, {\n ...options,\n negatives: entry.negatives,\n limitFractionDigits: entry.limitFractionDigits,\n decimalEntry: entry.decimalEntry,\n });\n pasted = result.pasted;\n return result.decision;\n }\n : undefined,\n };\n}\n\n/** Whether a field with this `min` takes negative numbers. */\nexport function takesNegatives(min: number | string | undefined): boolean {\n return min === undefined || compareDecimals(toDecimal(min), \"0\") < 0;\n}\n\n/** A development warning when `min` is above `max`. */\nexport function useLimitsWarning(\n name: string,\n min: number | string | undefined,\n max: number | string | undefined,\n): void {\n useEffect(() => {\n if (\n min !== undefined &&\n max !== undefined &&\n compareDecimals(toDecimal(min), toDecimal(max)) > 0\n ) {\n warnOnce(\n \"number-min-max\",\n `${name}: min is above max, so no value can satisfy both.`,\n );\n }\n }, [name, min, max]);\n}\n\n/** What a step adds: `step` (one, or a percentage point), and `largeStep` (ten steps). */\nexport function stepSizes(\n step: number | string | undefined,\n largeStep: number | string | undefined,\n percentScale: PercentScale | undefined,\n): { readonly step: DecimalString; readonly largeStep: DecimalString } {\n const size =\n step === undefined\n ? percentScale === \"fraction\"\n ? \"0.01\"\n : \"1\"\n : toDecimal(step);\n return {\n step: size,\n largeStep:\n largeStep === undefined ? shiftDecimal(size, 1) : toDecimal(largeStep),\n };\n}\n\n/** Options to attach with, before a render's own reach them. */\nconst NO_STEP_KEYS: StepKeysOptions = { onStep: () => undefined };\n\n/**\n * Attaches forms-dom's step keys to `element` while `on`, and hands them\n * every render's options.\n */\nexport function useStepKeys(\n element: HTMLInputElement | null,\n on: boolean,\n options: StepKeysOptions,\n): void {\n const stepKeys = useRef<AttachedStepKeys | null>(null);\n useLayoutEffect(() => {\n if (element === null || !on) {\n return undefined;\n }\n const attached = attachStepKeys(element, NO_STEP_KEYS);\n stepKeys.current = attached;\n return () => {\n attached.detach();\n stepKeys.current = null;\n };\n }, [element, on]);\n // Every render's options, the attaching render's included: this effect\n // runs straight after the one above, before any key can arrive.\n useLayoutEffect(() => {\n stepKeys.current?.setOptions(options);\n });\n}\n","import {\n maskDetails,\n requiredRule,\n type MaskDetails,\n type MaskOptions,\n type MaskPreset,\n type MaskSource,\n type MaskValueFormat,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, type Ref } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport type { TextInputBaseProps } from \"../text/textInputProps\";\nimport { useFieldInput, validatorsOf } from \"../useFieldInput\";\nimport {\n firstEmptySlot,\n maskCaret,\n maskKind,\n maskTemplate,\n resolveMask,\n} from \"./maskKind\";\n\nexport interface MaskedInputProps\n extends\n TextInputBaseProps<string, HTMLInputElement, MaskDetails>,\n Partial<Pick<MaskOptions, \"tokens\" | \"promptCharacter\">> {\n /**\n * A pattern (`\"(000) 000-0000\"`), several tried in order as the text\n * grows, a function choosing one from the raw text, or a preset from\n * `maskPresets`.\n */\n readonly mask: MaskSource | MaskPreset;\n /**\n * `\"raw\"` (default): only the characters typed. `\"formatted\"`: with the\n * literals. A preset sets its own, which this overrides.\n */\n readonly valueFormat?: MaskValueFormat | undefined;\n /** A fixed-width font, so the slots line up down a column of fields. */\n readonly monospace?: boolean | undefined;\n /** Escape puts back the last committed value; on by default. */\n readonly revertOnEscape?: boolean | undefined;\n readonly ref?: Ref<HTMLInputElement> | undefined;\n}\n\nfunction MaskedInputControl({\n mask,\n tokens,\n promptCharacter,\n valueFormat,\n monospace = false,\n revertOnEscape = true,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n selectOnFocus = false,\n inputMode,\n enterKeyHint,\n autoComplete,\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: MaskedInputProps) {\n const field = useFieldContext();\n const formSettings = useFormSettings();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const needsValue = required === true || field?.required === true;\n\n const resolved = useMemo(\n () => resolveMask(mask, { tokens, promptCharacter, valueFormat }, locale),\n [mask, tokens, promptCharacter, valueFormat, locale],\n );\n const { options } = resolved;\n const kind = useMemo(\n () => maskKind(options, resolved.valueFormat),\n [options, resolved.valueFormat],\n );\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<string>()] : []),\n ...(resolved.validate === undefined ? [] : [resolved.validate]),\n ...validatorsOf(validate),\n ],\n [needsValue, resolved.validate, validate],\n );\n\n const input = useFieldInput(\n { ...props, required, validate: validators, ref },\n kind,\n {\n startAdornment: hasNode(prefix),\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n mapCaret: options === null ? undefined : maskCaret(options),\n lastCaret:\n options === null\n ? undefined\n : (text: string) => firstEmptySlot(options, text),\n },\n );\n const { controlProps } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const editable = !controlProps.readOnly && !controlProps.disabled;\n const root = classNames(\n \"gridkit-forms-masked-input\",\n monospace && \"is-monospace\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n {input.displayValue}\n {input.hiddenInput}\n </div>\n );\n }\n\n // While focused an empty field shows the template, which is not text to clear.\n const typed =\n options === null ? input.text : maskDetails(options, input.text).raw;\n\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && typed !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n >\n <input\n autoCapitalize={resolved.upperCase ? \"characters\" : undefined}\n autoCorrect=\"off\"\n spellCheck={false}\n {...extraControlProps}\n {...controlProps}\n className=\"gridkit-forms-masked-input-control\"\n type=\"text\"\n dir=\"ltr\"\n placeholder={\n placeholder ??\n (options === null ? undefined : maskTemplate(options))\n }\n autoFocus={autoFocus}\n inputMode={inputMode ?? resolved.inputMode}\n enterKeyHint={enterKeyHint}\n autoComplete={autoComplete ?? resolved.autoComplete ?? \"off\"}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n aria-busy={loading || undefined}\n />\n </ControlBox>\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * A text field laid into a mask: postal codes, IBANs, card numbers, part\n * numbers. Typing fills the mask's slots and skips its literals, a paste\n * keeps what fits, and text an input method composed is laid in once it\n * ends. While focused the empty slots show the prompt character; without\n * focus, the text typed with its literals. The value is a string, the raw\n * characters or (`valueFormat=\"formatted\"`) the text with its literals,\n * only once the mask is complete, and `null` when empty: incomplete text\n * is unreadable and keeps the last complete value. Presets bring their\n * pattern, check, keyboard and value format. It takes every shared input\n * prop: display mode, `readOnly`, `disabled`, messages with their\n * severity, density, prefix and suffix, and the events of\n * `@gridkitjs/forms` with `MaskDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function MaskedInput(props: MaskedInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <MaskedInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n compileMask,\n fieldText,\n filterMaskEdit,\n formatMasked,\n formatText,\n maskDetails,\n maskFormatter,\n maskInputHints,\n maskParser,\n textParser,\n type FieldState,\n type MaskCompileResult,\n type MaskDetails,\n type MaskOptions,\n type MaskPreset,\n type MaskSource,\n type MaskTokens,\n type MaskValueFormat,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport { warnOnce } from \"../dev\";\nimport type { FieldInputKind } from \"../useFieldInput\";\n\n/** Whether the `mask` prop is a preset rather than a pattern, several, or a function. */\nfunction isPreset(mask: MaskSource | MaskPreset): mask is MaskPreset {\n return typeof mask === \"object\" && \"options\" in mask;\n}\n\n/** What a masked input works from: its mask, or `null` when the mask is malformed and it takes plain text. */\nexport interface ResolvedMask {\n readonly options: MaskOptions | null;\n /** A preset's own check. */\n readonly validate: Validator<string> | undefined;\n readonly valueFormat: MaskValueFormat;\n readonly inputMode: \"numeric\" | \"decimal\" | \"text\" | undefined;\n readonly autoComplete: string | undefined;\n /** The mask upper-cases letters. */\n readonly upperCase: boolean;\n}\n\n/** The first malformed pattern of `options`, checked as the engine would compile it. */\nfunction compileError(options: MaskOptions): {\n readonly pattern: string;\n readonly error: Extract<MaskCompileResult, { kind: \"error\" }>;\n} | null {\n const { mask, tokens } = options;\n const patterns =\n typeof mask === \"function\"\n ? [mask(\"\")]\n : typeof mask === \"string\"\n ? [mask]\n : mask;\n for (const pattern of patterns) {\n const compiled = compileMask(pattern, tokens);\n if (compiled.kind === \"error\") {\n return { pattern, error: compiled };\n }\n }\n return null;\n}\n\n/**\n * The mask a masked input works from: a preset's options or the given\n * pattern, with the input's own tokens laid over a preset's, its prompt,\n * and the field's locale unless the preset names one. A malformed pattern\n * warns once in development and leaves the input taking plain text.\n */\nexport function resolveMask(\n mask: MaskSource | MaskPreset,\n overrides: {\n readonly tokens: MaskTokens | undefined;\n readonly promptCharacter: string | undefined;\n readonly valueFormat: MaskValueFormat | undefined;\n },\n locale: Intl.LocalesArgument,\n): ResolvedMask {\n const preset = isPreset(mask) ? mask : null;\n const base: MaskOptions = isPreset(mask) ? mask.options : { mask };\n const options: MaskOptions = {\n ...base,\n tokens:\n overrides.tokens === undefined\n ? base.tokens\n : { ...base.tokens, ...overrides.tokens },\n promptCharacter: overrides.promptCharacter ?? base.promptCharacter,\n locale: base.locale ?? locale,\n };\n const valueFormat = overrides.valueFormat ?? preset?.valueFormat ?? \"raw\";\n const failed = compileError(options);\n if (failed !== null) {\n warnOnce(\n `mask:${failed.pattern}`,\n `MaskedInput: the mask \"${failed.pattern}\" is malformed at ${String(failed.error.position)} (${failed.error.message}), so the input takes plain text.`,\n );\n return {\n options: null,\n validate: preset?.validate,\n valueFormat,\n inputMode: undefined,\n autoComplete: preset?.autoComplete,\n upperCase: false,\n };\n }\n const hints = maskInputHints(options);\n return {\n options,\n validate: preset?.validate,\n valueFormat,\n inputMode: preset?.inputMode ?? hints.inputMode,\n autoComplete: preset?.autoComplete,\n upperCase: hints.upperCase,\n };\n}\n\n/** A masked field's `kind`, its details always given. */\nexport type MaskKind = FieldInputKind<string, MaskDetails> & {\n readonly details: (current: FieldState<string>) => MaskDetails;\n};\n\n/**\n * A masked field's `kind`: forms-core's mask parser, formatter and filter,\n * and `MaskDetails` for the text on screen. Without a mask (a malformed\n * one), plain text, whose details call it complete.\n */\nexport function maskKind(\n options: MaskOptions | null,\n valueFormat: MaskValueFormat,\n): MaskKind {\n if (options === null) {\n return {\n defaultParse: textParser(),\n defaultFormat: formatText,\n serialize: (value) => value,\n details: (current) => {\n const text = fieldText(current, (value) => value ?? \"\");\n return { raw: text, formatted: text, complete: true, pattern: \"\" };\n },\n };\n }\n const display = (value: string | null) =>\n formatMasked(options, value ?? \"\", false).text;\n return {\n defaultParse: maskParser(options, valueFormat),\n defaultFormat: maskFormatter(options),\n serialize: (value) => value,\n details: (current) => maskDetails(options, fieldText(current, display)),\n filterInput: (edit, before) => filterMaskEdit(edit, before, options),\n };\n}\n\n/** Where typing goes on in `text`: the first empty slot, or the end. */\nexport function firstEmptySlot(options: MaskOptions, text: string): number {\n return formatMasked(options, maskDetails(options, text).raw, true).caret;\n}\n\n/**\n * Where the caret goes when a masked field's text is written into the\n * focused control: at its distance from the end, as for any text, but\n * never past the first empty slot, so focus on an empty field puts it in\n * the first slot.\n */\nexport function maskCaret(\n options: MaskOptions,\n): (previousText: string, caret: number, nextText: string) => number {\n return (previousText, caret, nextText) =>\n Math.min(\n Math.max(0, nextText.length - (previousText.length - caret)),\n firstEmptySlot(options, nextText),\n );\n}\n\n/** The template a placeholder shows: the mask with its prompt in every slot, `_` when the prompt is none. */\nexport function maskTemplate(options: MaskOptions): string {\n const prompted =\n options.promptCharacter === \"\"\n ? { ...options, promptCharacter: \"_\" }\n : options;\n return formatMasked(prompted, \"\", true).text;\n}\n","import {\n compareDecimals,\n formatNumber,\n maxRule,\n minRule,\n numberAffixes,\n numberCaret,\n numberSymbols,\n requiredRule,\n stepNumberValue,\n type ChangeCause,\n type DecimalString,\n type NegativeStyle,\n type NumberDetails,\n type NumberOptions,\n type NumberValue,\n type NumberValueType,\n type PercentScale,\n type RoundingMode,\n type StepDirection,\n type StepSize,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachHoldRepeat,\n type AttachedHoldRepeat,\n type HoldRepeatOptions,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n keepFocus,\n OwnMessages,\n useControlElement,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport type { TextInputBaseProps } from \"../text/textInputProps\";\nimport { isFocused, useFieldInput, validatorsOf } from \"../useFieldInput\";\nimport {\n numberKind,\n sameNumber,\n stepSizes,\n takesNegatives,\n toDecimal,\n useLimitsWarning,\n useNumberOptions,\n useStepKeys,\n} from \"./numberKind\";\n\n/** A limit or step: a number, or in decimal mode also an exact decimal string. */\nexport type NumberLimit<T extends NumberValueType> = T extends \"decimal\"\n ? number | DecimalString\n : number;\n\n/** onStep: a step is about to be taken. The change events follow, and may still refuse it. */\nexport interface NumberStepEvent<V> {\n readonly direction: StepDirection;\n readonly size: StepSize;\n readonly via: \"key\" | \"button\" | \"wheel\";\n /** The value the step goes to. */\n readonly value: V | null;\n readonly previousValue: V | null;\n readonly nativeEvent: Event | null;\n}\n\nexport interface NumberInputProps<\n T extends NumberValueType = \"number\",\n> extends TextInputBaseProps<NumberValue<T>, HTMLInputElement, NumberDetails> {\n /** `\"number\"` (default): a JS number. `\"decimal\"`: an exact decimal string (`\"1234.50\"`). */\n readonly valueType?: T | undefined;\n /** Fixed decimals: shown and kept, and typed in place. Sets both the minimum and the maximum. */\n readonly fractionDigits?: number | undefined;\n /** Fraction digits always written; 0 by default (a currency: its minor units). */\n readonly minimumFractionDigits?: number | undefined;\n /** Fraction digits kept; more are rounded. Unset: every digit typed is kept. */\n readonly maximumFractionDigits?: number | undefined;\n /** Whole numbers only: no decimal separator, a numeric keyboard. */\n readonly integer?: boolean | undefined;\n /** `\"halfExpand\"` (ties away from zero) by default; Intl's names. */\n readonly roundingMode?: RoundingMode | undefined;\n /** Refuses a keystroke that would type more fraction digits than allowed, instead of rounding. */\n readonly limitFractionDigits?: boolean | undefined;\n /**\n * With fixed decimals, `\"fixed\"` (default) shows them while typing, the\n * decimal separator jumps into them and they are typed over; `\"free\"`\n * types them as any other field does.\n */\n readonly decimalEntry?: \"fixed\" | \"free\" | undefined;\n /** Group the integer digits when the field does not have focus. On by default. */\n readonly useGrouping?: boolean | undefined;\n /** How a negative number is shown without focus: `\"minus\"` (default), `\"parentheses\"`, `\"trailingMinus\"`. */\n readonly negative?: NegativeStyle | undefined;\n readonly decimalSeparator?: string | undefined;\n readonly groupSeparator?: string | undefined;\n readonly groupSizes?:\n readonly [primary: number, secondary: number] | undefined;\n /** The digits the field writes: `\"latn\"` keeps Latin digits in `ar-EG`. */\n readonly numberingSystem?: string | undefined;\n /** ISO 4217 code; its sign is drawn beside the number, where the locale puts it. */\n readonly currency?: string | undefined;\n readonly currencyDisplay?: NumberOptions[\"currencyDisplay\"];\n /** An Intl unit (`\"kilogram\"`), drawn beside the number. */\n readonly unit?: string | undefined;\n readonly unitDisplay?: NumberOptions[\"unitDisplay\"];\n readonly min?: NumberLimit<T> | undefined;\n readonly max?: NumberLimit<T> | undefined;\n /** What the arrow keys and the stepper add; 1 by default. */\n readonly step?: NumberLimit<T> | undefined;\n /** What PageUp and PageDown add; ten steps by default. */\n readonly largeStep?: NumberLimit<T> | undefined;\n /** `\"keys\"` (default): a spinbutton the arrow keys step. `\"none\"`: a plain text box. */\n readonly stepping?: \"keys\" | \"none\" | undefined;\n /** Stepper buttons: none (default), stacked at the end, or one at each end. */\n readonly stepper?: \"none\" | \"end\" | \"split\" | undefined;\n /** The mouse wheel steps while the field has focus. Off by default. */\n readonly wheel?: boolean | undefined;\n /** Refuses keys that cannot be part of a number and cleans pastes. On by default. */\n readonly cleanInput?: boolean | undefined;\n /** Where the number sits in the box: the end (default) or the start. */\n readonly align?: \"start\" | \"end\" | undefined;\n /** Escape puts back the last committed value; on by default. */\n readonly revertOnEscape?: boolean | undefined;\n readonly onStep?:\n ((event: NumberStepEvent<NumberValue<T>>) => void) | undefined;\n readonly ref?: Ref<HTMLInputElement> | undefined;\n}\n\n/** What `PercentInput` adds to the shared number control. */\nexport interface NumberVariant {\n /** Set for a percent: how its value is scaled. */\n readonly percentScale?: PercentScale | undefined;\n /** The root's classes. */\n readonly rootClassName: string;\n}\n\n/** Options to attach with, before a render's own reach them. */\nconst NO_REPEAT: HoldRepeatOptions = { onRepeat: () => false };\n\nfunction ChevronIcon({ direction }: { readonly direction: StepDirection }) {\n return (\n <svg\n className=\"gridkit-forms-stepper-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d={direction === \"up\" ? \"m6 15 6-6 6 6\" : \"m6 9 6 6 6-6\"} />\n </svg>\n );\n}\n\n/**\n * One stepper button: it steps once when pressed and repeats while held\n * (forms-dom's `attachHoldRepeat`), and a hold ends when the control loses\n * focus. At a limit, or in a read-only field, it is drawn disabled but\n * stays pressable, so a held pointer is never lost.\n */\nfunction StepperButton({\n direction,\n label,\n controlId,\n inactive,\n disabled,\n focused,\n onRepeat,\n}: {\n readonly direction: StepDirection;\n readonly label: string;\n readonly controlId: string;\n /** At a limit, or read-only: drawn disabled. */\n readonly inactive: boolean;\n /** The field is disabled. */\n readonly disabled: boolean;\n /** The control has focus. */\n readonly focused: boolean;\n readonly onRepeat: (nativeEvent: PointerEvent) => boolean;\n}) {\n const [button, setButton] = useState<HTMLButtonElement | null>(null);\n const hold = useRef<AttachedHoldRepeat | null>(null);\n useLayoutEffect(() => {\n if (button === null) {\n return undefined;\n }\n const attached = attachHoldRepeat(button, NO_REPEAT);\n hold.current = attached;\n return () => {\n attached.detach();\n hold.current = null;\n };\n }, [button]);\n // Every render's step, the attaching render's included: this effect runs\n // straight after the one above, before any press can arrive.\n useLayoutEffect(() => {\n hold.current?.setOptions({ onRepeat });\n });\n useEffect(() => {\n if (!focused) {\n hold.current?.cancel();\n }\n }, [focused]);\n\n return (\n <button\n ref={setButton}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-stepper-button\",\n direction === \"up\" ? \"is-increment\" : \"is-decrement\",\n (inactive || disabled) && \"is-disabled\",\n )}\n tabIndex={-1}\n aria-label={label}\n aria-controls={controlId}\n aria-disabled={inactive || undefined}\n disabled={disabled}\n onMouseDown={keepFocus}\n >\n <ChevronIcon direction={direction} />\n </button>\n );\n}\n\n/** The number control `NumberInput` and `PercentInput` share. */\nexport function NumberControl<T extends NumberValueType = \"number\">({\n percentScale,\n rootClassName,\n valueType,\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer = false,\n roundingMode,\n limitFractionDigits,\n decimalEntry,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n min,\n max,\n step,\n largeStep,\n stepping = \"keys\",\n stepper = \"none\",\n wheel = false,\n cleanInput = true,\n align = \"end\",\n revertOnEscape = true,\n onStep,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n selectOnFocus = true,\n inputMode,\n enterKeyHint,\n autoComplete = \"off\",\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: NumberInputProps<T> & NumberVariant) {\n type V = NumberValue<T>;\n const field = useFieldContext();\n const formSettings = useFormSettings();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const needsValue = required === true || field?.required === true;\n const numberOptions = useNumberOptions(\n {\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer,\n roundingMode,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n },\n locale,\n percentScale,\n );\n const symbols = numberSymbols(locale, numberOptions);\n const negatives = takesNegatives(min);\n useLimitsWarning(\"NumberInput\", min, max);\n\n const kind = useMemo(\n () =>\n numberKind<T>(numberOptions, {\n valueType,\n cleanInput,\n negatives,\n limitFractionDigits,\n decimalEntry,\n }),\n [\n numberOptions,\n valueType,\n cleanInput,\n negatives,\n limitFractionDigits,\n decimalEntry,\n ],\n );\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<V>()] : []),\n ...(min === undefined ? [] : [minRule<V>(min, numberOptions)]),\n ...(max === undefined ? [] : [maxRule<V>(max, numberOptions)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, numberOptions, validate],\n );\n const mapCaret = useMemo(() => numberCaret(numberOptions), [numberOptions]);\n const affixes = numberAffixes(numberOptions);\n\n const [element, controlRef] = useControlElement(ref);\n const input = useFieldInput(\n { ...props, required, validate: validators, ref: controlRef },\n kind,\n {\n startAdornment:\n hasNode(prefix) || affixes.prefix !== \"\" || stepper === \"split\",\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n mapCaret,\n decimalKey: integer ? undefined : symbols.decimal,\n },\n );\n const { controlProps, state } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const affixId = `${controlId}-affix`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const editable = !controlProps.readOnly && !controlProps.disabled;\n const display = input.mode === \"display\";\n const focused = isFocused(state.phase);\n const spinbutton = stepping === \"keys\";\n\n const limits = {\n ...stepSizes(step, largeStep, percentScale),\n min: min ?? null,\n max: max ?? null,\n };\n\n /** Takes a step, and says whether the value moved. */\n function takeStep(\n direction: StepDirection,\n size: StepSize,\n via: NumberStepEvent<V>[\"via\"],\n nativeEvent: Event,\n ): boolean {\n if (!editable) {\n return false;\n }\n const previous = input.getValue();\n const next = stepNumberValue<T>(\n previous,\n { direction, size, ...limits },\n { ...numberOptions, valueType },\n );\n if (next === null || (previous !== null && sameNumber(previous, next))) {\n return false;\n }\n onStep?.({\n direction,\n size,\n via,\n value: next,\n previousValue: previous,\n nativeEvent,\n });\n const cause: ChangeCause<Event> = {\n source: \"step\",\n nativeEvent,\n input: null,\n };\n input.change(next, cause);\n if (element !== null && element.ownerDocument.activeElement === element) {\n const end = element.value.length;\n element.setSelectionRange(end, end);\n }\n const now = input.getValue();\n return now === null || previous === null || !sameNumber(now, previous);\n }\n\n useStepKeys(element, spinbutton && editable && !display, {\n onStep: (direction, size, nativeEvent) => {\n takeStep(\n direction,\n size,\n nativeEvent instanceof WheelEvent ? \"wheel\" : \"key\",\n nativeEvent,\n );\n },\n edges: { min: min !== undefined, max: max !== undefined },\n wheel,\n });\n\n const { value } = state;\n const root = classNames(\n rootClassName,\n align === \"start\" && \"is-align-start\",\n stepper === \"end\" && \"is-stepper-end\",\n stepper === \"split\" && \"is-stepper-split\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (display) {\n const text =\n props.format !== undefined || value === null\n ? input.text\n : formatNumber(value, numberOptions, \"full\");\n return (\n <div className={root} style={style}>\n <DisplayValue text={text} emptyText={strings.emptyValue} />\n {input.hiddenInput}\n </div>\n );\n }\n\n function stepperButton(direction: StepDirection): ReactNode {\n const limit = direction === \"up\" ? max : min;\n const atLimit =\n limit !== undefined &&\n value !== null &&\n compareDecimals(toDecimal(value), toDecimal(limit)) *\n (direction === \"up\" ? 1 : -1) >=\n 0;\n return (\n <StepperButton\n direction={direction}\n label={direction === \"up\" ? strings.increase : strings.decrease}\n controlId={controlId}\n inactive={atLimit || controlProps.readOnly === true}\n disabled={controlProps.disabled === true}\n focused={focused}\n onRepeat={(nativeEvent) => {\n if (element === null) {\n return false;\n }\n if (element.ownerDocument.activeElement !== element) {\n element.focus();\n }\n return takeStep(direction, \"step\", \"button\", nativeEvent);\n }}\n />\n );\n }\n\n const affix = (text: string, side: \"start\" | \"end\") =>\n text === \"\" ? null : (\n <span\n className={`gridkit-forms-number-input-affix is-${side}`}\n id={spinbutton ? undefined : affixId}\n aria-hidden={spinbutton || undefined}\n >\n {text}\n </span>\n );\n const hasAffix = affixes.prefix !== \"\" || affixes.suffix !== \"\";\n\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n start={stepper === \"split\" ? stepperButton(\"down\") : undefined}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n end={\n stepper === \"end\" ? (\n <span className=\"gridkit-forms-stepper\">\n {stepperButton(\"up\")}\n {stepperButton(\"down\")}\n </span>\n ) : stepper === \"split\" ? (\n stepperButton(\"up\")\n ) : null\n }\n >\n {affix(affixes.prefix, \"start\")}\n <input\n {...extraControlProps}\n {...controlProps}\n className=\"gridkit-forms-number-input-control\"\n type=\"text\"\n role={spinbutton ? \"spinbutton\" : undefined}\n dir={symbols.numbersLeftToRight ? \"ltr\" : undefined}\n placeholder={placeholder}\n autoFocus={autoFocus}\n inputMode={inputMode ?? (integer ? \"numeric\" : \"decimal\")}\n enterKeyHint={enterKeyHint}\n autoComplete={autoComplete}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n hasNode(prefix) && prefixId,\n !spinbutton && hasAffix && affixId,\n hasNode(suffix) && suffixId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n aria-busy={loading || undefined}\n aria-valuenow={\n spinbutton && value !== null ? Number(value) : undefined\n }\n aria-valuemin={\n spinbutton && min !== undefined ? Number(min) : undefined\n }\n aria-valuemax={\n spinbutton && max !== undefined ? Number(max) : undefined\n }\n aria-valuetext={\n spinbutton && value !== null\n ? formatNumber(value, numberOptions, \"full\")\n : undefined\n }\n />\n {affix(affixes.suffix, \"end\")}\n </ControlBox>\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * A number field: locale-aware entry with the shared events, a JS number\n * or (with `valueType=\"decimal\"`) an exact decimal string as its value,\n * `null` when empty. While it has focus it shows plain digits, and with\n * fixed decimals every decimal, typed in place; without focus, the number\n * grouped and padded, with a currency or unit drawn beside it. It is a\n * spinbutton the arrow keys step, with optional stepper buttons that\n * repeat while held, and takes every shared input prop: display mode,\n * `readOnly`, `disabled`, messages with their severity, density, prefix\n * and suffix, and the events of `@gridkitjs/forms` with `NumberDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function NumberInput<T extends NumberValueType = \"number\">(\n props: NumberInputProps<T>,\n) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <NumberControl<T> {...props} rootClassName=\"gridkit-forms-number-input\" />\n </InputFrame>\n );\n}\n","import {\n compareDecimals,\n endsRule,\n formatNumber,\n formatNumberRange,\n maxRule,\n maxSpanRule,\n minRule,\n minSpanRule,\n numberAffixes,\n numberCaret,\n numberRangeKindOf,\n numberSymbols,\n rangeDetails,\n rangeEnds,\n rangeSpan,\n readRangeEnds,\n requiredRule,\n sameRange,\n stepNumberValue,\n type FieldState,\n type NoFlags,\n type NumberDetails,\n type NumberOptions,\n type NumberValue,\n type NumberValueType,\n type PartController,\n type PartOptions,\n type Range,\n type RangeBounds,\n type RangeDetails,\n type RangeEnd,\n type RangeEnds,\n type StepDirection,\n type StepSize,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport type { TextInputOptions } from \"@gridkitjs/forms-dom\";\nimport {\n useLayoutEffect,\n useMemo,\n useState,\n type HTMLAttributes,\n type Ref,\n} from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n InputFrame,\n joinIds,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport type { TextInputBaseProps } from \"../text/textInputProps\";\nimport {\n useCompositeInput,\n usePartControl,\n type CompositeInputSpec,\n} from \"../useCompositeInput\";\nimport { validatorsOf } from \"../useFieldInput\";\nimport type { NumberInputProps, NumberLimit } from \"./NumberInput\";\nimport {\n numberKind,\n sameNumber,\n stepSizes,\n takesNegatives,\n toDecimal,\n useLimitsWarning,\n useNumberOptions,\n useStepKeys,\n type NumberFormatProps,\n type NumberKind,\n} from \"./numberKind\";\n\n/** A number range: either end `null` when open. */\nexport type NumberRange<T extends NumberValueType = \"number\"> = Range<\n NumberValue<T>\n>;\n\n/** What `NumberRangeInput` adds to every event: the range's details and each end's number details. */\nexport type NumberRangeDetails<T extends NumberValueType = \"number\"> =\n RangeDetails<NumberValue<T>, NoFlags, NumberValue<T>> & {\n readonly startDetails: NumberDetails;\n readonly endDetails: NumberDetails;\n };\n\nexport interface NumberRangeInputProps<T extends NumberValueType = \"number\">\n extends\n Omit<\n TextInputBaseProps<\n NumberRange<T>,\n HTMLInputElement,\n NumberRangeDetails<T>\n >,\n | \"placeholder\"\n | \"prefix\"\n | \"suffix\"\n | \"ref\"\n | \"parse\"\n | \"format\"\n | \"controlProps\"\n >,\n NumberFormatProps<T>,\n Pick<\n NumberInputProps<T>,\n | \"min\"\n | \"max\"\n | \"step\"\n | \"largeStep\"\n | \"stepping\"\n | \"limitFractionDigits\"\n | \"decimalEntry\"\n | \"cleanInput\"\n | \"align\"\n | \"revertOnEscape\"\n > {\n /** `\"[]\"` (default): the end belongs to the range. `\"[)\"`: it does not, so 10–10 is empty. */\n readonly bounds?: RangeBounds | undefined;\n /** An end typed before its start: swapped (default) or an error. */\n readonly reversed?: \"swap\" | \"error\" | undefined;\n /** With `bounds=\"[)\"`, allows a start equal to its end. */\n readonly allowEmpty?: boolean | undefined;\n /** The shortest span allowed, `end - start`. */\n readonly minSpan?: NumberLimit<T> | undefined;\n /** The longest span allowed. */\n readonly maxSpan?: NumberLimit<T> | undefined;\n /** Shows the span after the end (\"Span: 10\"), read with the end. */\n readonly showSpan?: boolean | undefined;\n readonly startPlaceholder?: string | undefined;\n readonly endPlaceholder?: string | undefined;\n /** The start's native control. */\n readonly startRef?: Ref<HTMLInputElement> | undefined;\n /** The end's native control. */\n readonly endRef?: Ref<HTMLInputElement> | undefined;\n}\n\n/** The tighter of two limits: the lower of two upper limits, the higher of two lower ones. */\nfunction tighter<V extends number | string>(\n a: V | null,\n b: V | null,\n side: \"lower\" | \"upper\",\n): V | null {\n if (a === null || b === null) {\n return a ?? b;\n }\n const order = compareDecimals(toDecimal(a), toDecimal(b));\n return (side === \"upper\" ? order <= 0 : order >= 0) ? a : b;\n}\n\n/** A number kind as one part of a composite: how it reads, writes and filters. */\nfunction partOf<V>(kind: NumberKind<V>): PartOptions<V, Event> {\n return {\n defaultParse: kind.defaultParse,\n defaultFormat: kind.defaultFormat,\n equals: kind.equals,\n filterInput: kind.filterInput,\n };\n}\n\n/** What both ends' controls share. */\ninterface EndSettings<V> {\n readonly text: TextInputOptions;\n readonly spinbutton: boolean;\n readonly editable: boolean;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n readonly required: boolean;\n readonly ltr: boolean;\n readonly autoFocus: boolean | undefined;\n readonly attributes: Pick<\n HTMLAttributes<HTMLInputElement>,\n \"inputMode\" | \"enterKeyHint\"\n > & { readonly autoComplete: string | undefined };\n readonly min: number | string | undefined;\n readonly max: number | string | undefined;\n /** The value a step takes an end to, or `null` when it takes none. */\n readonly stepTo: (\n end: RangeEnd,\n direction: StepDirection,\n size: StepSize,\n ) => V | null;\n /** A value as a screen reader says it. */\n readonly valueText: (value: V) => string;\n}\n\n/** One end's control: a number box of its own, typed and stepped as a `NumberInput`. */\nfunction RangeEndControl<V extends number | string>({\n end,\n part,\n controlRef,\n onElement,\n id,\n labelledBy,\n describedBy,\n invalid,\n placeholder,\n settings,\n}: {\n readonly end: RangeEnd;\n readonly part: PartController<V, Event>;\n readonly controlRef: Ref<HTMLInputElement> | undefined;\n /** Told the control once it is in the page, and `null` when it goes. */\n readonly onElement?: ((element: HTMLInputElement | null) => void) | undefined;\n readonly id: string;\n readonly labelledBy: string | undefined;\n readonly describedBy: string | undefined;\n readonly invalid: boolean;\n readonly placeholder: string | undefined;\n readonly settings: EndSettings<V>;\n}) {\n const [element, ref] = usePartControl(part, controlRef, settings.text);\n useLayoutEffect(() => {\n onElement?.(element);\n }, [onElement, element]);\n const { spinbutton, min, max } = settings;\n useStepKeys(element, spinbutton && settings.editable, {\n onStep: (direction, size, nativeEvent) => {\n const next = settings.stepTo(end, direction, size);\n if (next === null) {\n return;\n }\n part.change(next, { source: \"step\", nativeEvent, input: null });\n if (element !== null && element.ownerDocument.activeElement === element) {\n const caret = element.value.length;\n element.setSelectionRange(caret, caret);\n }\n },\n edges: { min: min !== undefined, max: max !== undefined },\n });\n const { value } = part.getState();\n return (\n <input\n {...settings.attributes}\n ref={ref}\n id={id}\n className={`gridkit-forms-number-input-control gridkit-forms-range-${end}`}\n type=\"text\"\n role={spinbutton ? \"spinbutton\" : undefined}\n dir={settings.ltr ? \"ltr\" : undefined}\n defaultValue={part.getText()}\n readOnly={settings.readOnly}\n disabled={settings.disabled}\n placeholder={placeholder}\n autoFocus={end === \"start\" ? settings.autoFocus : undefined}\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n aria-invalid={invalid || undefined}\n aria-required={settings.required || undefined}\n aria-valuenow={spinbutton && value !== null ? Number(value) : undefined}\n aria-valuemin={spinbutton && min !== undefined ? Number(min) : undefined}\n aria-valuemax={spinbutton && max !== undefined ? Number(max) : undefined}\n aria-valuetext={\n spinbutton && value !== null ? settings.valueText(value) : undefined\n }\n />\n );\n}\n\n/** The range as display mode writes it: \"10–20\", \"from 10\", \"up to 20\". */\nfunction displayText<V extends number | string>(\n range: Range<V> | null,\n options: NumberOptions,\n strings: {\n rangeFrom: (start: string) => string;\n rangeUpTo: (end: string) => string;\n },\n): string {\n if (range === null) {\n return \"\";\n }\n const { start, end } = range;\n if (start !== null && end !== null) {\n return formatNumberRange(start, end, options);\n }\n if (start !== null) {\n return strings.rangeFrom(formatNumber(start, options, \"full\"));\n }\n return end === null\n ? \"\"\n : strings.rangeUpTo(formatNumber(end, options, \"full\"));\n}\n\n/** Whether an end's own text or value is at fault: it cannot be read, or lies outside `min` and `max`. */\nfunction endAtFault<V extends number | string>(\n state: FieldState<V>,\n min: number | string | undefined,\n max: number | string | undefined,\n): boolean {\n const { draft, value } = state;\n if (draft.kind === \"text\" && draft.reading.kind === \"unreadable\") {\n return true;\n }\n if (value === null) {\n return false;\n }\n const decimal = toDecimal(value);\n return (\n (min !== undefined && compareDecimals(decimal, toDecimal(min)) < 0) ||\n (max !== undefined && compareDecimals(decimal, toDecimal(max)) > 0)\n );\n}\n\n/** The range control behind `NumberRangeInput`. */\nfunction NumberRangeControl<T extends NumberValueType = \"number\">({\n valueType,\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer = false,\n roundingMode,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n min,\n max,\n step,\n largeStep,\n stepping = \"keys\",\n limitFractionDigits,\n decimalEntry,\n cleanInput = true,\n align = \"end\",\n revertOnEscape = true,\n bounds = \"[]\",\n reversed = \"swap\",\n allowEmpty = false,\n minSpan,\n maxSpan,\n showSpan = false,\n startPlaceholder,\n endPlaceholder,\n startRef,\n endRef,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n clearable = false,\n selectOnFocus = true,\n inputMode,\n enterKeyHint,\n autoComplete = \"off\",\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: NumberRangeInputProps<T>) {\n type V = NumberValue<T>;\n const field = useFieldContext();\n const formSettings = useFormSettings();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const numberOptions = useNumberOptions<T>(\n {\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer,\n roundingMode,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n },\n locale,\n );\n const symbols = numberSymbols(locale, numberOptions);\n const rangeKind = numberRangeKindOf<T>(valueType);\n const negatives = takesNegatives(min);\n useLimitsWarning(\"NumberRangeInput\", min, max);\n\n // One kind per end: each keeps how its own paste was read.\n const kinds = useMemo(() => {\n const entry = {\n valueType,\n cleanInput,\n negatives,\n limitFractionDigits,\n decimalEntry,\n };\n return {\n start: numberKind<T>(numberOptions, entry),\n end: numberKind<T>(numberOptions, entry),\n };\n }, [\n numberOptions,\n valueType,\n cleanInput,\n negatives,\n limitFractionDigits,\n decimalEntry,\n ]);\n const needsValue = required === true || field?.required === true;\n const validators = useMemo(() => {\n // A span limit is a value of the field's own type.\n const spanOf = (limit: number | string) =>\n (valueType === \"decimal\" ? toDecimal(limit) : Number(limit)) as V;\n const writeSpan = (span: V) => formatNumber(span, numberOptions, \"full\");\n const list: Validator<NumberRange<T>>[] = [];\n if (needsValue) {\n list.push(requiredRule<NumberRange<T>>());\n }\n if (min !== undefined) {\n list.push(endsRule(minRule<V>(min, numberOptions)));\n }\n if (max !== undefined) {\n list.push(endsRule(maxRule<V>(max, numberOptions)));\n }\n if (minSpan !== undefined) {\n list.push(\n minSpanRule(rangeKind, spanOf(minSpan), () => undefined, writeSpan),\n );\n }\n if (maxSpan !== undefined) {\n list.push(\n maxSpanRule(rangeKind, spanOf(maxSpan), () => undefined, writeSpan),\n );\n }\n return [...list, ...validatorsOf(validate)];\n }, [\n needsValue,\n min,\n max,\n minSpan,\n maxSpan,\n numberOptions,\n rangeKind,\n valueType,\n validate,\n ]);\n\n const rangeOptions = { bounds, reversed, allowEmpty };\n const spec: CompositeInputSpec<\n NumberRange<T>,\n RangeEnds<V>,\n NumberRangeDetails<T>\n > = {\n parts: { start: partOf(kinds.start), end: partOf(kinds.end) },\n assemble: (ends, context) =>\n readRangeEnds(rangeKind, ends, rangeOptions, undefined, context),\n split: (value) => rangeEnds(rangeKind, value, bounds, undefined),\n join: (texts) => texts.start + settings.messages.rangeSeparator + texts.end,\n equals: (a, b) => sameRange(rangeKind, a, b),\n details: (current, _previous, { changed, parts, texts }) => ({\n ...rangeDetails(\n rangeKind,\n current.value,\n changed,\n texts,\n bounds,\n undefined,\n ),\n startDetails: kinds.start.details(parts.start),\n endDetails: kinds.end.details(parts.end),\n }),\n };\n const [startElement, setStartElement] = useState<HTMLInputElement | null>(\n null,\n );\n const input = useCompositeInput(\n { ...props, required, validate: validators },\n spec,\n startElement,\n );\n const {\n composite,\n state,\n strings,\n severity,\n invalid,\n readOnly,\n disabled,\n describedBy: fieldDescribedBy,\n messages,\n setRoot,\n clear,\n } = input;\n const resolvedDensity = density ?? settings.density;\n const id = input.controlId;\n const editable = !readOnly && !disabled;\n const value = state.field.value;\n const ownMessagesId = useOwnMessagesId(id);\n const mapCaret = useMemo(() => numberCaret(numberOptions), [numberOptions]);\n const root = classNames(\n \"gridkit-forms-number-range-input\",\n align === \"start\" && \"is-align-start\",\n densityClass(resolvedDensity),\n className,\n );\n\n const { name } = props;\n const hiddenInputs =\n name === undefined\n ? null\n : ([\"start\", \"end\"] as const).map((end) => {\n const endValue = value?.[end] ?? null;\n return (\n <input\n key={end}\n type=\"hidden\"\n name={`${name}.${end}`}\n form={props.form}\n disabled={disabled}\n value={endValue === null ? \"\" : toDecimal(endValue)}\n />\n );\n });\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n <DisplayValue\n text={displayText(value, numberOptions, strings)}\n emptyText={strings.emptyValue}\n />\n {hiddenInputs}\n </div>\n );\n }\n\n const sizes = stepSizes(step, largeStep, undefined);\n const endSettings: EndSettings<V> = {\n text: {\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n mapCaret,\n decimalKey: integer ? undefined : symbols.decimal,\n },\n spinbutton: stepping === \"keys\",\n editable,\n readOnly: readOnly,\n disabled: disabled,\n required: input.required,\n ltr: symbols.numbersLeftToRight,\n autoFocus,\n attributes: {\n inputMode: inputMode ?? (integer ? \"numeric\" : \"decimal\"),\n enterKeyHint,\n autoComplete,\n },\n min,\n max,\n stepTo: (end, direction, size) => {\n if (!editable) {\n return null;\n }\n const start = composite.parts.start.getState().value;\n const finish = composite.parts.end.getState().value;\n const lower = min ?? null;\n const upper = max ?? null;\n // A step stops at the other end, so it never reverses the range.\n const limits =\n end === \"start\"\n ? {\n min: lower,\n max: tighter<number | string>(upper, finish, \"upper\"),\n }\n : {\n min: tighter<number | string>(lower, start, \"lower\"),\n max: upper,\n };\n const previous = end === \"start\" ? start : finish;\n const next = stepNumberValue<T>(\n previous,\n { direction, size, ...sizes, ...limits },\n { ...numberOptions, valueType },\n );\n return next === null || (previous !== null && sameNumber(previous, next))\n ? null\n : next;\n },\n valueText: (shown) => formatNumber(shown, numberOptions, \"full\"),\n };\n\n // A message about one end marks that end; one about the range, both.\n const atFault = {\n start: endAtFault(state.parts.start, min, max),\n end: endAtFault(state.parts.end, min, max),\n };\n const invalidEnd = (end: RangeEnd) =>\n invalid && (atFault.start || atFault.end ? atFault[end] : true);\n\n const span =\n showSpan && value !== null ? rangeSpan(rangeKind, value, undefined) : null;\n const spanId = `${id}-span`;\n const nameId = `${id}-name`;\n const labelIds = joinIds(\n field !== null && `${id}-label`,\n ariaLabelledBy,\n ariaLabel !== undefined && nameId,\n );\n // The currency sign or unit beside each end: hidden from a spinbutton,\n // whose value text says it, and a description of a plain text box.\n const affixes = numberAffixes(numberOptions);\n const { spinbutton } = endSettings;\n const affixId = (end: RangeEnd, side: \"start\" | \"end\") =>\n `${id}-${end}-affix-${side}`;\n const affix = (end: RangeEnd, side: \"start\" | \"end\") => {\n const text = side === \"start\" ? affixes.prefix : affixes.suffix;\n return text === \"\" ? null : (\n <span\n className={`gridkit-forms-number-input-affix is-${side}`}\n id={spinbutton ? undefined : affixId(end, side)}\n aria-hidden={spinbutton || undefined}\n >\n {text}\n </span>\n );\n };\n const describedBy = (end: RangeEnd) =>\n joinIds(\n !spinbutton && affixes.prefix !== \"\" && affixId(end, \"start\"),\n !spinbutton && affixes.suffix !== \"\" && affixId(end, \"end\"),\n fieldDescribedBy,\n ownMessagesId,\n end === \"end\" && span !== null && spanId,\n ariaDescribedBy,\n );\n const hasText =\n composite.parts.start.getText() !== \"\" ||\n composite.parts.end.getText() !== \"\";\n\n return (\n <div\n ref={setRoot}\n className={root}\n style={style}\n role=\"group\"\n aria-labelledby={labelIds}\n >\n <ControlBox\n className=\"gridkit-forms-range-control\"\n severity={severity}\n disabled={disabled}\n readOnly={readOnly}\n loading={loading}\n density={resolvedDensity}\n prefix={undefined}\n prefixId={`${id}-prefix`}\n suffix={undefined}\n suffixId={`${id}-suffix`}\n clear={\n clearable && editable && hasText\n ? {\n label: strings.clear,\n onClear: (event) => {\n clear(event.nativeEvent);\n },\n }\n : null\n }\n >\n {affix(\"start\", \"start\")}\n <RangeEndControl<V>\n end=\"start\"\n part={composite.parts.start}\n controlRef={startRef}\n onElement={setStartElement}\n id={id}\n labelledBy={joinIds(labelIds, `${id}-start-label`)}\n describedBy={describedBy(\"start\")}\n invalid={invalidEnd(\"start\")}\n placeholder={startPlaceholder}\n settings={endSettings}\n />\n {affix(\"start\", \"end\")}\n <span className=\"gridkit-forms-range-separator\" aria-hidden=\"true\">\n {strings.rangeSeparator}\n </span>\n {affix(\"end\", \"start\")}\n <RangeEndControl<V>\n end=\"end\"\n part={composite.parts.end}\n controlRef={endRef}\n id={`${id}-end`}\n labelledBy={joinIds(labelIds, `${id}-end-label`)}\n describedBy={describedBy(\"end\")}\n invalid={invalidEnd(\"end\")}\n placeholder={endPlaceholder}\n settings={endSettings}\n />\n {affix(\"end\", \"end\")}\n {span !== null && (\n <span className=\"gridkit-forms-range-span\" id={spanId}>\n {strings.rangeSpanLabel(formatNumber(span, numberOptions, \"full\"))}\n </span>\n )}\n </ControlBox>\n {ariaLabel !== undefined && (\n <span className=\"gridkit-forms-sr-only\" id={nameId}>\n {ariaLabel}\n </span>\n )}\n <span className=\"gridkit-forms-sr-only\" id={`${id}-start-label`}>\n {strings.rangeStart}\n </span>\n <span className=\"gridkit-forms-sr-only\" id={`${id}-end-label`}>\n {strings.rangeEnd}\n </span>\n {hiddenInputs}\n <OwnMessages\n id={`${id}-messages`}\n messages={messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * Two number fields under one label, holding one range: `{ start, end }`,\n * either end `null` when open, and `null` when both are. The value is\n * always ordered: an end typed before its start is swapped (the texts\n * change places on commit) or, with `reversed=\"error\"`, refused with a\n * message. Each end types, pastes and steps as a `NumberInput` (a step\n * stops at the other end); Tab moves between the ends, and the range\n * commits once when focus leaves both, or on Enter. `min` and `max` bound\n * both ends; `minSpan` and `maxSpan` the span, which `showSpan` writes\n * after the end. The end belongs to the range by default (`bounds=\"[]\"`).\n * Every event carries `NumberRangeDetails`: which end changed, the span,\n * and each end's number details.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function NumberRangeInput<T extends NumberValueType = \"number\">(\n props: NumberRangeInputProps<T>,\n) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <NumberRangeControl<T> {...props} />\n </InputFrame>\n );\n}\n","import {\n createCompositeController,\n hasError,\n type CompositeController,\n type CompositeFieldOptions,\n type CompositeState,\n type FieldMessage,\n type FormsMessages,\n type NoDetails,\n type PartController,\n type Severity,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachFocusGroup,\n attachTextInput,\n type AttachedTextInput,\n type TextInputOptions,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type Ref,\n type RefCallback,\n} from \"react\";\nimport { useControlElement } from \"./text/parts\";\nimport type { FieldMode } from \"./settings\";\nimport {\n isFocused,\n useControllerLifecycle,\n useFieldReport,\n useInputSettings,\n useShownMessages,\n validatorsOf,\n type FieldInputProps,\n} from \"./useFieldInput\";\n\n/** The props `useCompositeInput` reads; an input made of parts passes on its own. */\nexport type CompositeInputProps<V, D extends object = NoDetails> = Omit<\n FieldInputProps<V, HTMLInputElement, D>,\n \"parse\" | \"format\" | \"ref\"\n>;\n\n/** How an input made of parts reads its parts and makes its value: the composite's own options. */\nexport type CompositeInputSpec<\n V,\n P extends Record<string, unknown>,\n D extends object = NoDetails,\n> = Pick<\n CompositeFieldOptions<V, P, D, Event>,\n \"parts\" | \"assemble\" | \"split\" | \"join\" | \"equals\" | \"details\"\n>;\n\n/** What `useCompositeInput` gives the input that calls it, to draw. */\nexport interface CompositeInput<\n V,\n P extends Record<string, unknown>,\n D extends object = NoDetails,\n> {\n readonly composite: CompositeController<V, P, D, Event>;\n readonly state: CompositeState<V, P>;\n /** The field's text: the parts' texts, joined. */\n readonly text: string;\n /** As `useFieldInput`'s: the messages to show, and the most serious one's severity. */\n readonly messages: readonly FieldMessage[];\n readonly severity: Severity | null;\n /** Whether a shown error, `invalid` or the `Field` marks the input invalid. */\n readonly invalid: boolean;\n readonly mode: FieldMode;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n /** The input's own `required`, or the `Field`'s. */\n readonly required: boolean;\n /** The first control's `id`: the `Field`'s inside one, so its label points there. */\n readonly controlId: string;\n /** The `Field`'s description and messages, for each control's `aria-describedby`. */\n readonly describedBy: string | undefined;\n readonly strings: FormsMessages;\n readonly locale: Intl.LocalesArgument;\n /** Fires `onClear`, then empties the field and commits it. */\n readonly clear: (nativeEvent: Event | null) => void;\n /** The element around every part: focus leaving it commits the field. */\n readonly setRoot: RefCallback<HTMLElement>;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/**\n * Binds an input made of parts to one field, as `useFieldInput` binds one\n * control: forms-core's composite controller, made once and handed the\n * latest props and `spec` on every render; a controlled `value`; the\n * `Field` and form around it; and forms-dom's focus group on `setRoot`, so\n * focus leaving every part commits the field. Each part's control is\n * attached with `usePartControl`. `focusTarget` is the control\n * `handleRef`'s `focus` moves to.\n */\nexport function useCompositeInput<\n V,\n P extends Record<string, unknown>,\n D extends object = NoDetails,\n>(\n props: CompositeInputProps<V, D>,\n spec: CompositeInputSpec<V, P, D>,\n focusTarget: HTMLInputElement | null,\n): CompositeInput<V, P, D> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const options: CompositeFieldOptions<V, P, D, Event> = {\n ...spec,\n value: props.value,\n defaultValue: props.defaultValue,\n validators: validatorsOf(props.validate),\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [composite] = useState(() => createCompositeController(options));\n composite.setOptions(options);\n const state = useSyncExternalStore(\n composite.subscribe,\n composite.getState,\n composite.getState,\n );\n const controller = composite.field;\n useControllerLifecycle(controller, props.value, form);\n\n const [root, setRoot] = useState<HTMLElement | null>(null);\n useLayoutEffect(() => {\n if (root === null) {\n return undefined;\n }\n const group = attachFocusGroup(root, {\n onLeave: (by, nativeEvent) => {\n composite.leave(by, nativeEvent);\n },\n });\n return () => {\n group.detach();\n };\n }, [root, composite]);\n\n useImperativeHandle(\n props.handleRef,\n () => ({\n element: focusTarget,\n focus: (focusOptions) => {\n focusTarget?.focus(focusOptions);\n },\n blur: () => {\n const active = focusTarget?.ownerDocument.activeElement;\n if (active instanceof HTMLElement && root?.contains(active) === true) {\n active.blur();\n }\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n }),\n [focusTarget, root, controller],\n );\n\n const text = controller.getText();\n // A disabled field is not validated, so it shows none of its own messages.\n const own =\n state.field.revealed && !disabled ? controller.getMessages() : NO_MESSAGES;\n const { shown, severity } = useShownMessages(\n own,\n props.message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n const partTexts = Object.keys(spec.parts).map((name) =>\n composite.parts[name as keyof P].getText(),\n );\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.field.phase),\n empty: partTexts.every((partText) => partText === \"\"),\n required,\n // A resting label would cover the parts and the separator between them.\n startAdornment: true,\n });\n const { onClear } = props;\n\n return {\n composite,\n state,\n text,\n messages: shown,\n severity,\n invalid:\n hasError(shown) || props.invalid === true || field?.invalid === true,\n mode,\n readOnly,\n disabled,\n required: required || field?.required === true,\n controlId: field?.controlId ?? props.id ?? ownId,\n describedBy: field?.describedBy,\n strings: messages,\n locale,\n clear: (nativeEvent) => {\n onClear?.({\n previousValue: controller.getState().value,\n previousText: controller.getText(),\n nativeEvent,\n });\n controller.clear(nativeEvent);\n },\n setRoot: setRoot,\n };\n}\n\n/**\n * Attaches forms-dom's text pipeline to one part's control, handing it\n * every render's options, and points `ref` at the control too. Returns the\n * control, once it is in the page, and the ref to give it.\n */\nexport function usePartControl<T>(\n part: PartController<T, Event>,\n ref: Ref<HTMLInputElement> | undefined,\n options: TextInputOptions,\n): readonly [HTMLInputElement | null, RefCallback<HTMLInputElement>] {\n const [element, controlRef] = useControlElement(ref);\n const pipeline = useRef<AttachedTextInput | null>(null);\n useLayoutEffect(() => {\n if (element === null) {\n return undefined;\n }\n const attached = attachTextInput(element, part);\n pipeline.current = attached;\n return () => {\n attached.detach();\n pipeline.current = null;\n };\n }, [element, part]);\n // Every render's options, the attaching render's included: this effect\n // runs straight after the one above, before any event can arrive.\n useLayoutEffect(() => {\n pipeline.current?.setOptions(options);\n });\n return [element, controlRef];\n}\n","import type { NumberValueType, PercentScale } from \"@gridkitjs/forms-core\";\nimport { InputFrame } from \"../text/parts\";\nimport { NumberControl, type NumberInputProps } from \"./NumberInput\";\n\nexport interface PercentInputProps<\n T extends NumberValueType = \"number\",\n> extends Omit<\n NumberInputProps<T>,\n \"currency\" | \"currencyDisplay\" | \"unit\" | \"unitDisplay\"\n> {\n /**\n * `\"fraction\"` (default): 0.12 is shown as 12 %, as Intl reads a\n * percent. `\"percent\"`: 12 is. `value`, `min`, `max` and `step` are in\n * these units; the default step is one percentage point.\n */\n readonly scale?: PercentScale | undefined;\n}\n\n/**\n * A `NumberInput` for a percentage: the percent sign drawn where the\n * locale puts it (before the number in `tr-TR`), and the value stored as\n * a fraction (0.125 for 12.5 %) or as the percent number itself, by\n * `scale`. Fraction digit props count the digits of the number shown, and\n * a fraction is scaled exactly, so 12.3 % is 0.123.\n */\nexport function PercentInput<T extends NumberValueType = \"number\">({\n scale = \"fraction\",\n ...props\n}: PercentInputProps<T>) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <NumberControl<T>\n {...props}\n percentScale={scale}\n rootClassName=\"gridkit-forms-number-input gridkit-forms-percent-input\"\n />\n </InputFrame>\n );\n}\n","import {\n comparePeriods,\n formatPeriod,\n isPeriod,\n maxPeriodRule,\n minPeriodRule,\n periodDetails,\n periodFormatter,\n periodLayout,\n periodOf,\n periodParser,\n periodParts,\n pivotYear,\n requiredRule,\n type FiscalYear,\n type Period,\n type PeriodDetails,\n type PeriodFieldOptions,\n type PeriodGranularity,\n type PopupOpenChange,\n} from \"@gridkitjs/forms-core\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { todayFor } from \"../date/DateInput\";\nimport { SegmentedControl } from \"../date/SegmentedControl\";\nimport type { SegmentedInputProps } from \"../date/segmentedProps\";\nimport {\n createSegmentsAccess,\n typingSegment,\n type SegmentedKind,\n} from \"../date/useSegmentedInput\";\nimport { warnOnce } from \"../dev\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { CalendarIcon, InputFrame } from \"../text/parts\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { focusedPeriod, PeriodPicker } from \"./PeriodPicker\";\n\nexport interface PeriodInputProps<\n G extends PeriodGranularity = \"month\",\n> extends Omit<SegmentedInputProps<Period<G>, PeriodDetails>, \"displayFormat\"> {\n /** How long a period is: `\"month\"` by default. */\n readonly granularity?: G | undefined;\n /** The first period allowed, inclusive. */\n readonly min?: Period<G> | undefined;\n /** The last period allowed, inclusive. */\n readonly max?: Period<G> | undefined;\n /** The month a fiscal year starts in, 1 to 12; 1 by default. */\n readonly fiscalYearStart?: number | undefined;\n /** Whether \"FY2026\" names the year a fiscal year ends in (default) or starts in. */\n readonly fiscalYearNamedBy?: \"start\" | \"end\" | undefined;\n /** Typing `t`, `+1`, `-1`; on by default. */\n readonly shortcuts?: boolean | undefined;\n /** The zone \"today\" is in, for shortcuts, steps and the two-digit year: the runtime's by default. */\n readonly timeZone?: string | undefined;\n /** The calendar button and its popup, a grid of periods; on by default. */\n readonly picker?: boolean | undefined;\n /** The picker popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n}\n\n/** The fiscal year the props name, January when `start` is no month. */\nfunction useFiscalYear(\n start: number | undefined,\n namedBy: \"start\" | \"end\",\n): FiscalYear {\n const month =\n start !== undefined && Number.isInteger(start) && start >= 1 && start <= 12\n ? start\n : 1;\n const stray = start !== undefined && month !== start;\n useEffect(() => {\n if (stray) {\n warnOnce(\n \"PeriodInput-fiscalYearStart\",\n \"PeriodInput: fiscalYearStart is a month from 1 to 12, so the fiscal year starts in January.\",\n );\n }\n }, [stray]);\n return useMemo(() => ({ start: month, namedBy }), [month, namedBy]);\n}\n\nfunction PeriodInputControl<G extends PeriodGranularity>({\n granularity: granularityProp,\n min,\n max,\n fiscalYearStart,\n fiscalYearNamedBy = \"end\",\n shortcuts = true,\n timeZone,\n picker = true,\n onOpenChange,\n required,\n validate,\n ...props\n}: PeriodInputProps<G>) {\n // Without `granularity`, `G` is its default, \"month\".\n const granularity = granularityProp ?? (\"month\" as G);\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const [segments] = useState(createSegmentsAccess);\n const fiscalYear = useFiscalYear(fiscalYearStart, fiscalYearNamedBy);\n const { numberingSystem } = props;\n const needsValue = required === true || field?.required === true;\n\n const today = todayFor(timeZone);\n const options: PeriodFieldOptions<G> = {\n granularity,\n fiscalYear,\n numberingSystem,\n today,\n shortcuts,\n activeSegment: () => typingSegment(segments),\n };\n const kind: SegmentedKind<Period<G>, PeriodDetails> = {\n name: \"PeriodInput\",\n layout: periodLayout({ locale, granularity, numberingSystem }, messages),\n defaultParse: periodParser(options),\n defaultFormat: periodFormatter({ granularity, numberingSystem }),\n details: (current, _previous, cause) =>\n periodDetails(current, cause, { ...options, locale, messages }),\n display: (value) => formatPeriod(value, locale, messages),\n serialize: (value) => value,\n isValue: (value): value is Period<G> => isPeriod(value, granularity),\n inLimits: (value) =>\n (min === undefined || comparePeriods(value, min) >= 0) &&\n (max === undefined || comparePeriods(value, max) <= 0),\n shortcuts,\n today,\n reference: (type) => {\n const current = periodParts(periodOf(today(), granularity, fiscalYear));\n return type === \"year\" ? current.year : current.index;\n },\n pivot: (digits) => pivotYear(digits, { today: today() }),\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<Period<G>>()] : []),\n ...(min === undefined ? [] : [minPeriodRule<G>(min)]),\n ...(max === undefined ? [] : [maxPeriodRule<G>(max)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, validate],\n );\n\n return (\n <SegmentedControl\n props={{ ...props, required, validate: validators }}\n kind={kind}\n rootClassName=\"gridkit-forms-period-input\"\n segments={segments}\n picker={\n picker\n ? {\n label: messages.choosePeriod,\n icon: <CalendarIcon />,\n buttonClassName: \"gridkit-forms-period-button\",\n popupClassName: \"gridkit-forms-period-popup\",\n onOpenChange,\n initialFocus: focusedPeriod,\n content: ({ value, id, pick, close }) => (\n <PeriodPicker<G>\n id={id}\n granularity={granularity}\n fiscalYear={fiscalYear}\n selected={value}\n min={min}\n max={max}\n today={today}\n locale={locale}\n strings={messages}\n onChoose={(period, nativeEvent) => {\n pick(period, nativeEvent);\n close(\"picker\");\n }}\n />\n ),\n }\n : undefined\n }\n />\n );\n}\n\n/**\n * An accounting or reporting period typed in segments: a month as the\n * locale writes one (`11/2026` in en-US, `2026/11` in ja-JP), a quarter\n * (`Q3 2026`), a year, or a fiscal year, quarter or month (`FY2026`,\n * `FY2026 Q1`, `FY2026 P04`) counted from `fiscalYearStart` and named by\n * the year it ends in unless `fiscalYearNamedBy=\"start\"`. Typing moves on\n * by itself, the arrow keys move between segments and step them, and the\n * field is one Tab stop. A letter or a sign opens a box for shortcuts (`t`\n * this period, `+1` the next, `-1` the previous), and a pasted period in\n * any common form (`2026-Q3`, `Nov 2026`, `FY26 P4`) is read whole. The\n * calendar button, F4 or Alt+ArrowDown opens a grid of the year's periods\n * (twelve years for a year granularity) to choose one from. Its\n * value is a `Period` string of the granularity (`\"2026-11\"`,\n * `\"FY2026-P04\"`), `null` when empty, and every event's\n * `PeriodDetails.range` holds the days it covers, half-open. `min` and\n * `max` add their messages. It takes every shared input prop: display\n * mode, `readOnly`, `disabled`, messages with their severity, density,\n * prefix and suffix, and the events of `@gridkitjs/forms`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function PeriodInput<G extends PeriodGranularity = \"month\">(\n props: PeriodInputProps<G>,\n) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <PeriodInputControl<G> {...props} />\n </InputFrame>\n );\n}\n","import {\n comparePeriods,\n formatMonthName,\n formatPeriodPage,\n formatPeriodPlace,\n periodOf,\n periodPage,\n periodPageYears,\n periodParts,\n type FiscalYear,\n type FormsMessages,\n type Period,\n type PeriodGranularity,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport { useRef, useState, type KeyboardEvent } from \"react\";\nimport { ChevronIcon } from \"../calendar/MonthPanel\";\nimport { nextIndex } from \"../calendar/MonthsView\";\nimport { classNames } from \"../field/parts\";\n\n/** What a period input's picker reads. */\nexport interface PeriodPickerProps<G extends PeriodGranularity> {\n /** The popup's `id`, the prefix of the picker's own ids. */\n readonly id: string;\n readonly granularity: G;\n readonly fiscalYear: FiscalYear;\n /** The period shown chosen, and where focus starts; today's when `null`. */\n readonly selected: Period<G> | null;\n readonly min: Period<G> | undefined;\n readonly max: Period<G> | undefined;\n readonly today: () => PlainDate;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** A period chosen by click, tap, Enter or Space; never one outside the limits. */\n readonly onChoose: (period: Period<G>, nativeEvent: Event) => void;\n}\n\n/** The button that takes focus as a period picker opens: the chosen period, else today's. */\nexport function focusedPeriod(panel: HTMLElement): HTMLElement | null {\n return panel.querySelector<HTMLElement>(\n '.gridkit-forms-period-picker-grid [tabindex=\"0\"]',\n );\n}\n\n/**\n * A period input's picker: a page of periods as a grid of buttons (a\n * year's months, quarters or fiscal periods, three or two to a row, or\n * twelve years) under a header whose buttons move to the year, or the\n * twelve years, before and after. The grid is one Tab stop: the arrows,\n * Home and End move through it, PageUp and PageDown move to the page\n * before and after, and Enter, Space or a click chooses. Periods outside\n * `min` and `max` show disabled; today's is marked.\n */\nexport function PeriodPicker<G extends PeriodGranularity>({\n id,\n granularity,\n fiscalYear,\n selected,\n min,\n max,\n today,\n locale,\n strings,\n onChoose,\n}: PeriodPickerProps<G>) {\n const gridRef = useRef<HTMLDivElement>(null);\n const [current] = useState(() => periodOf(today(), granularity, fiscalYear));\n const start = selected ?? current;\n const [year, setYear] = useState(() => periodParts(start).year);\n const [focusIndex, setFocusIndex] = useState(() =>\n Math.max(periodPage(granularity, year).indexOf(start), 0),\n );\n const page = periodPage(granularity, year);\n const step = periodPageYears(granularity);\n const yearly = step > 1;\n const columns = page.length === 4 ? 2 : 3;\n const shownIndex = Math.min(focusIndex, page.length - 1);\n const titleId = `${id}-title`;\n const title = formatPeriodPage(granularity, year, locale, strings);\n\n const outside = (period: Period<G>) =>\n (min !== undefined && comparePeriods(period, min) < 0) ||\n (max !== undefined && comparePeriods(period, max) > 0);\n /** Whether the page holding `target` has a period within the limits. */\n const canShow = (target: number) => {\n if (target < 1 || target > 9999) {\n return false;\n }\n return periodPage(granularity, target).some((period) => !outside(period));\n };\n\n function turn(by: number): boolean {\n const target = year + by * step;\n if (!canShow(target)) {\n return false;\n }\n setYear(target);\n return true;\n }\n\n function focusButton(index: number) {\n gridRef.current?.querySelectorAll<HTMLElement>(\"button\")[index]?.focus();\n }\n\n function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n if (event.key === \"PageUp\" || event.key === \"PageDown\") {\n event.preventDefault();\n turn(event.key === \"PageUp\" ? -1 : 1);\n return;\n }\n const next = nextIndex(event, shownIndex, page.length, {\n row: columns,\n column: 1,\n });\n if (next !== null) {\n event.preventDefault();\n setFocusIndex(next);\n focusButton(next);\n }\n }\n\n // A fiscal month shows the calendar month it is beside its number.\n const hint = (period: Period<G>) =>\n granularity === \"fiscalMonth\"\n ? formatMonthName(\n ((fiscalYear.start + periodParts(period).index - 2) % 12) + 1,\n locale,\n \"short\",\n )\n : null;\n\n return (\n <div\n className=\"gridkit-forms-period-picker\"\n role=\"group\"\n aria-labelledby={titleId}\n >\n <div className=\"gridkit-forms-period-picker-header\">\n <button\n type=\"button\"\n className=\"gridkit-forms-period-picker-nav is-previous\"\n aria-label={yearly ? strings.previousYears : strings.previousYear}\n disabled={!canShow(year - step)}\n onClick={() => {\n turn(-1);\n }}\n >\n <ChevronIcon side=\"start\" />\n </button>\n <span\n className=\"gridkit-forms-period-picker-title\"\n id={titleId}\n aria-live=\"polite\"\n >\n {title}\n </span>\n <button\n type=\"button\"\n className=\"gridkit-forms-period-picker-nav is-next\"\n aria-label={yearly ? strings.nextYears : strings.nextYear}\n disabled={!canShow(year + step)}\n onClick={() => {\n turn(1);\n }}\n >\n <ChevronIcon side=\"end\" />\n </button>\n </div>\n <div\n ref={gridRef}\n className={classNames(\n \"gridkit-forms-period-picker-grid\",\n columns === 2 && \"is-two-columns\",\n )}\n role=\"group\"\n aria-labelledby={titleId}\n onKeyDown={onKeyDown}\n >\n {page.map((period, index) => {\n const disabled = outside(period);\n const isSelected = period === selected;\n const shownHint = hint(period);\n return (\n // Keyed by place, so the focused button stays as the page turns.\n <button\n key={index}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-period-picker-option\",\n isSelected && \"is-selected\",\n period === current && \"is-today\",\n disabled && \"is-disabled\",\n )}\n data-gridkit-forms-period={period}\n tabIndex={index === shownIndex ? 0 : -1}\n aria-pressed={isSelected}\n aria-disabled={disabled || undefined}\n onClick={(event) => {\n setFocusIndex(index);\n if (!disabled) {\n onChoose(period, event.nativeEvent);\n }\n }}\n >\n {formatPeriodPlace(period, locale, strings)}\n {!yearly && (\n <span className=\"gridkit-forms-sr-only\"> {title}</span>\n )}\n {shownHint !== null && (\n <span\n className=\"gridkit-forms-period-picker-hint\"\n aria-hidden=\"true\"\n >\n {shownHint}\n </span>\n )}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n","import { formatText, requiredRule, textParser } from \"@gridkitjs/forms-core\";\nimport { useMemo, type Ref } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n useFieldInput,\n validatorsOf,\n type FieldInputKind,\n} from \"../useFieldInput\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n OwnMessages,\n SearchIcon,\n useOwnMessagesId,\n} from \"./parts\";\nimport type { TextInputBaseProps } from \"./textInputProps\";\n\nexport interface SearchInputProps extends TextInputBaseProps<string> {\n /**\n * Milliseconds typing must pause before the text is read\n * (`onBeforeChange`, `onChange`, `onValidate`); `onInput` fires at once,\n * and Enter reads at once. None by default.\n */\n readonly debounce?: number | undefined;\n readonly ref?: Ref<HTMLInputElement> | undefined;\n}\n\nconst SEARCH_TEXT: FieldInputKind<string> = {\n defaultParse: textParser(),\n defaultFormat: formatText,\n serialize: (value) => value,\n};\n\nfunction SearchInputControl({\n debounce = 0,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = true,\n selectOnFocus = false,\n inputMode,\n enterKeyHint = \"search\",\n autoComplete,\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: SearchInputProps) {\n const field = useFieldContext();\n const settings = useFormSettings();\n const needsValue = required === true || field?.required === true;\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<string>()] : []),\n ...validatorsOf(validate),\n ],\n [needsValue, validate],\n );\n\n const input = useFieldInput(\n { ...props, required, validate: validators, ref },\n SEARCH_TEXT,\n {\n startAdornment: true,\n changeDelay: debounce,\n selectOnFocus,\n escape: \"clear\",\n },\n );\n const { controlProps } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const root = classNames(\n \"gridkit-forms-search-input\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n {input.displayValue}\n {input.hiddenInput}\n </div>\n );\n }\n\n const editable = !controlProps.readOnly && !controlProps.disabled;\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n start={\n <span className=\"gridkit-forms-search-input-icon\" aria-hidden=\"true\">\n <SearchIcon />\n </span>\n }\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n >\n <input\n {...extraControlProps}\n {...controlProps}\n type=\"search\"\n className=\"gridkit-forms-search-input-control\"\n placeholder={placeholder ?? strings.searchPlaceholder}\n autoFocus={autoFocus}\n inputMode={inputMode}\n enterKeyHint={enterKeyHint}\n autoComplete={autoComplete}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n aria-busy={loading || undefined}\n />\n </ControlBox>\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * A search box: `<input type=\"search\">` (role `searchbox`) with a search\n * icon and a clear button, on the same machinery as `TextInput`. Its value\n * is a string, `null` when empty. Enter commits at once, reading the text\n * first even while a `debounce` is pending; Escape empties it, after\n * `onClear`, and passes on when it is already empty.\n *\n * Search on `onChange` with a `debounce` as the user types, or on\n * `onCommit` for \"search on Enter\".\n */\nexport function SearchInput(props: SearchInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <SearchInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n countCharacters,\n counterAnnouncement,\n formatText,\n maxLengthRule,\n minLengthRule,\n patternRule,\n requiredRule,\n textParser,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachAutoGrow,\n scheduleTimeout,\n type AttachedAutoGrow,\n type TextControl,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type Ref,\n} from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n useFieldInput,\n validatorsOf,\n type FieldInputKind,\n} from \"../useFieldInput\";\nimport {\n ControlBox,\n densityClass,\n EyeIcon,\n hasNode,\n InputFrame,\n joinIds,\n keepFocus,\n OwnMessages,\n useControlElement,\n useOwnMessagesId,\n} from \"./parts\";\nimport type { TextInputBaseProps } from \"./textInputProps\";\n\nexport interface TextInputProps extends TextInputBaseProps<\n string,\n TextControl\n> {\n /**\n * `\"password\"` hides the text and adds a reveal button. Email, phone and\n * URL keyboards come from `inputMode` and `autoComplete`: a native\n * `type=\"email\"` would add the browser's own validation.\n */\n readonly type?: \"text\" | \"password\" | undefined;\n /** A `<textarea>` that grows with its text. */\n readonly multiline?: boolean | undefined;\n /** Multiline: the lines shown when empty. */\n readonly minRows?: number | undefined;\n /** Multiline: the lines it grows to, before it scrolls. */\n readonly maxRows?: number | undefined;\n /**\n * The most characters (code points) the value may have. Typing past it\n * is allowed: the counter marks the overflow and the field shows an\n * error.\n */\n readonly maxLength?: number | undefined;\n readonly minLength?: number | undefined;\n /** The whole value must match. */\n readonly pattern?: RegExp | undefined;\n /** The \"12/50\" counter under the box; on whenever `maxLength` is set. */\n readonly showCounter?: boolean | undefined;\n /**\n * Upper-cases the value as it is read, in the field's locale. The text is\n * shown upper-cased by CSS, so the caret never moves and input methods\n * are left alone; a commit writes the upper-cased text.\n */\n readonly uppercase?: boolean | undefined;\n /** Drops leading and trailing whitespace from the value; never for a password. */\n readonly trim?: boolean | undefined;\n /** The reveal button of a password; on by default. */\n readonly revealable?: boolean | undefined;\n /** Escape puts back the last committed text; on by default. */\n readonly revertOnEscape?: boolean | undefined;\n readonly ref?: Ref<TextControl> | undefined;\n}\n\n/** How long typing must pause before the counter is announced. */\nconst ANNOUNCE_DELAY = 1000;\n\n/** What a password shows in display mode, whatever its length. */\nconst HIDDEN_PASSWORD = \"••••••••\";\n\nconst DEFAULT_MIN_ROWS = 2;\nconst DEFAULT_MAX_ROWS = 8;\n\n/**\n * The \"12/50\" under the box, hidden from screen readers, which read the\n * limit with the control instead (\"Up to 50 characters\") and hear what is\n * left once typing pauses near it, never on every keystroke.\n */\nfunction CharacterCounter({\n labelId,\n count,\n max,\n typing,\n strings,\n}: {\n readonly labelId: string;\n readonly count: number;\n readonly max: number;\n /** The user is editing: only their typing is announced. */\n readonly typing: boolean;\n readonly strings: FormsMessages;\n}) {\n // Stamped with the count it was made for, so the next keystroke empties\n // it and the same words are announced again after the next pause.\n const [announced, setAnnounced] = useState({ count: -1, text: \"\" });\n const lastCount = useRef(count);\n useEffect(() => {\n if (count === lastCount.current) {\n return undefined;\n }\n lastCount.current = count;\n const text = typing ? counterAnnouncement(count, max, strings) : null;\n if (text === null) {\n return undefined;\n }\n return scheduleTimeout(() => {\n setAnnounced({ count, text });\n }, ANNOUNCE_DELAY);\n }, [count, max, typing, strings]);\n\n return (\n <>\n <div\n className={classNames(\n \"gridkit-forms-text-input-counter\",\n count > max && \"is-over-limit\",\n )}\n aria-hidden=\"true\"\n >\n {strings.counter(count, max)}\n </div>\n <span className=\"gridkit-forms-sr-only\" id={labelId}>\n {strings.counterLabel(max)}\n </span>\n <span className=\"gridkit-forms-sr-only\" aria-live=\"polite\">\n {announced.count === count ? announced.text : \"\"}\n </span>\n </>\n );\n}\n\nfunction TextInputControl({\n type = \"text\",\n multiline = false,\n minRows = DEFAULT_MIN_ROWS,\n maxRows = DEFAULT_MAX_ROWS,\n maxLength,\n minLength,\n pattern,\n showCounter = maxLength !== undefined,\n uppercase = false,\n trim = false,\n revealable = true,\n revertOnEscape = true,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n selectOnFocus = false,\n inputMode,\n enterKeyHint,\n autoComplete,\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: TextInputProps) {\n const field = useFieldContext();\n const settings = useFormSettings();\n const password = type === \"password\";\n const needsValue = required === true || field?.required === true;\n\n const kind = useMemo<FieldInputKind<string>>(\n () => ({\n defaultParse: textParser({ uppercase, trim: trim && !password }),\n defaultFormat: formatText,\n serialize: (value) => value,\n }),\n [uppercase, trim, password],\n );\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<string>()] : []),\n ...(minLength === undefined ? [] : [minLengthRule(minLength)]),\n ...(maxLength === undefined ? [] : [maxLengthRule(maxLength)]),\n ...(pattern === undefined ? [] : [patternRule(pattern)]),\n ...validatorsOf(validate),\n ],\n [needsValue, minLength, maxLength, pattern, validate],\n );\n\n const [element, controlRef] = useControlElement(ref);\n const input = useFieldInput(\n { ...props, required, validate: validators, ref: controlRef },\n kind,\n {\n startAdornment: hasNode(prefix),\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n },\n );\n const { controlProps } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const counterLabelId = `${controlId}-counter-label`;\n const ownMessagesId = useOwnMessagesId(controlId);\n\n const [revealed, setRevealed] = useState(false);\n const selection = useRef<readonly [number, number] | null>(null);\n useLayoutEffect(() => {\n const kept = selection.current;\n selection.current = null;\n if (kept !== null && element instanceof HTMLInputElement) {\n // Chromium rebuilds a text control at the first layout after its\n // `type` changes, dropping the selection, so lay out first.\n element.getBoundingClientRect();\n element.setSelectionRange(kept[0], kept[1]);\n }\n }, [revealed, element]);\n\n const autoGrow = useRef<AttachedAutoGrow | null>(null);\n useLayoutEffect(() => {\n if (!(element instanceof HTMLTextAreaElement)) {\n return undefined;\n }\n const attached = attachAutoGrow(element, { minRows, maxRows });\n autoGrow.current = attached;\n return () => {\n attached.detach();\n autoGrow.current = null;\n };\n }, [element, minRows, maxRows]);\n // Text written from code (a clear, a revert, a value from the app) fires\n // no `input` for it to follow.\n useLayoutEffect(() => {\n autoGrow.current?.update();\n }, [input.text]);\n\n const display = input.mode === \"display\";\n const root = classNames(\n \"gridkit-forms-text-input\",\n multiline && \"is-multiline\",\n uppercase && \"is-uppercase\",\n densityClass(resolvedDensity),\n className,\n );\n const ownMessages = (\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n );\n\n if (display) {\n return (\n <div className={root} style={style}>\n {password ? (\n <DisplayValue\n text={input.text === \"\" ? \"\" : HIDDEN_PASSWORD}\n emptyText={strings.emptyValue}\n />\n ) : (\n input.displayValue\n )}\n {input.hiddenInput}\n </div>\n );\n }\n\n const count = countCharacters(input.text);\n const counter =\n showCounter && maxLength !== undefined ? (\n <CharacterCounter\n labelId={counterLabelId}\n count={count}\n max={maxLength}\n typing={input.state.phase.kind !== \"idle\"}\n strings={strings}\n />\n ) : null;\n const editable = !controlProps.readOnly && !controlProps.disabled;\n const sharedProps = {\n ...extraControlProps,\n ...controlProps,\n className: \"gridkit-forms-text-input-control\",\n placeholder,\n autoFocus,\n inputMode,\n enterKeyHint,\n autoComplete,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n counter !== null && counterLabelId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n ),\n \"aria-busy\": loading || undefined,\n };\n\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n end={\n password && revealable ? (\n <button\n type=\"button\"\n className={classNames(\n \"gridkit-forms-text-input-reveal\",\n revealed && \"is-revealed\",\n )}\n aria-pressed={revealed}\n aria-controls={controlId}\n aria-label={strings.showPassword}\n disabled={controlProps.disabled}\n onMouseDown={keepFocus}\n onClick={() => {\n if (\n element instanceof HTMLInputElement &&\n element.ownerDocument.activeElement === element\n ) {\n selection.current = [\n element.selectionStart ?? 0,\n element.selectionEnd ?? 0,\n ];\n }\n setRevealed((current) => !current);\n }}\n >\n <EyeIcon />\n </button>\n ) : null\n }\n >\n {multiline ? (\n <textarea {...sharedProps} rows={minRows} />\n ) : (\n <input\n {...sharedProps}\n type={password && !revealed ? \"password\" : \"text\"}\n />\n )}\n </ControlBox>\n {counter}\n {input.hiddenInput}\n {ownMessages}\n </div>\n );\n}\n\n/**\n * A text field: a single line, a password with a reveal button, or a\n * multiline `<textarea>` that grows with its text. Its value is a string,\n * `null` when empty. It draws the box the grid's controls share, with\n * optional prefix and suffix adornments, a clear button, a spinner and a\n * character counter, and takes every shared input prop: display mode,\n * `readOnly`, `disabled`, messages with their severity, density and the\n * events of `@gridkitjs/forms`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function TextInput(props: TextInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <TextInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n booleanFormatter,\n booleanParser,\n checkedRule,\n CHECKBOX_WORDS,\n SWITCH_WORDS,\n type BooleanWords,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport {\n useFieldInput,\n validatorsOf,\n type FieldInputKind,\n} from \"../useFieldInput\";\nimport type { ToggleBaseProps } from \"./toggleProps\";\n\n/** How each toggle reads, writes and requires its value. */\ninterface ToggleVariant {\n /** The root class, which every part's class starts with. */\n readonly base: \"gridkit-forms-checkbox\" | \"gridkit-forms-switch\";\n /** The native input's class. */\n readonly controlClass: `${ToggleVariant[\"base\"]}-control`;\n /** The label text's class. */\n readonly labelClass: `${ToggleVariant[\"base\"]}-label`;\n readonly kind: FieldInputKind<boolean>;\n /** What `required` says while the value is not `true`. */\n readonly requiredMessage: (messages: FormsMessages) => string;\n}\n\nfunction toggleKind(words: BooleanWords): FieldInputKind<boolean> {\n return {\n defaultParse: booleanParser(words),\n defaultFormat: booleanFormatter(words),\n serialize: (value) => String(value),\n };\n}\n\nexport const CHECKBOX: ToggleVariant = {\n base: \"gridkit-forms-checkbox\",\n controlClass: \"gridkit-forms-checkbox-control\",\n labelClass: \"gridkit-forms-checkbox-label\",\n kind: toggleKind(CHECKBOX_WORDS),\n requiredMessage: (messages) => messages.requiredChecked,\n};\n\nexport const SWITCH: ToggleVariant = {\n base: \"gridkit-forms-switch\",\n controlClass: \"gridkit-forms-switch-control\",\n labelClass: \"gridkit-forms-switch-label\",\n kind: toggleKind(SWITCH_WORDS),\n requiredMessage: (messages) => messages.requiredOn,\n};\n\nfunction CheckIcon({ mixed }: { readonly mixed: boolean }) {\n return (\n <svg\n className=\"gridkit-forms-checkbox-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n {mixed ? <path d=\"M6 12h12\" /> : <path d=\"M20 6 9 17l-5-5\" />}\n </svg>\n );\n}\n\nexport interface ToggleInputProps extends ToggleBaseProps<boolean> {\n readonly variant: ToggleVariant;\n /** Checkbox: a flip can set `null`. */\n readonly threeState?: boolean | undefined;\n /** Switch: \"On\" or \"Off\" beside the track. */\n readonly showStateLabel?: boolean | undefined;\n}\n\nfunction ToggleControl({\n variant,\n threeState = false,\n showStateLabel = false,\n label,\n labelPlacement = \"end\",\n defaultValue,\n required,\n validate,\n density,\n autoFocus,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: ToggleInputProps) {\n const field = useFieldContext();\n const settings = useFormSettings();\n const needsValue = required === true || field?.required === true;\n const { requiredMessage } = variant;\n const validators = useMemo(\n () => [\n ...(needsValue ? [checkedRule(requiredMessage)] : []),\n ...validatorsOf(validate),\n ],\n [needsValue, requiredMessage, validate],\n );\n\n const input = useFieldInput(\n {\n ...props,\n defaultValue: defaultValue === undefined ? false : defaultValue,\n required,\n validate: validators,\n },\n variant.kind,\n { toggle: { threeState } },\n );\n const { controlProps, state } = input;\n const { base, controlClass, labelClass } = variant;\n const controlId = controlProps.id;\n const ownMessagesId = useOwnMessagesId(controlId);\n const hasLabel = hasNode(label);\n const mixed = base === \"gridkit-forms-checkbox\" && state.value === null;\n\n const root = classNames(\n base,\n state.value === true && \"is-checked\",\n mixed && \"is-mixed\",\n controlProps.disabled === true && \"is-disabled\",\n controlProps[\"aria-readonly\"] === true && \"is-readonly\",\n input.severity !== null && `is-${input.severity}`,\n labelPlacement === \"start\" && \"is-label-start\",\n input.mode === \"display\" && \"is-display\",\n densityClass(density ?? settings.density),\n className,\n );\n const labelText = hasLabel && <span className={labelClass}>{label}</span>;\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n {labelText}\n {input.displayValue}\n {input.hiddenInput}\n </div>\n );\n }\n\n return (\n <>\n <label className={root} style={style}>\n <input\n {...controlProps}\n type=\"checkbox\"\n role={base === \"gridkit-forms-switch\" ? \"switch\" : undefined}\n className={controlClass}\n autoFocus={autoFocus}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n />\n {base === \"gridkit-forms-checkbox\" ? (\n <span className=\"gridkit-forms-checkbox-box\" aria-hidden=\"true\">\n <CheckIcon mixed={mixed} />\n </span>\n ) : (\n <span className=\"gridkit-forms-switch-track\" aria-hidden=\"true\">\n <span className=\"gridkit-forms-switch-thumb\" />\n </span>\n )}\n {labelText}\n {showStateLabel && (\n <span className=\"gridkit-forms-switch-state\" aria-hidden=\"true\">\n {input.text}\n </span>\n )}\n {input.hiddenInput}\n </label>\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={settings.messages}\n named={\n hasLabel || ariaLabel !== undefined || ariaLabelledBy !== undefined\n }\n />\n </>\n );\n}\n\n/**\n * The checkbox and the switch: a native `<input type=\"checkbox\">`, real\n * and focusable, laid transparent over the whole row so the label is part\n * of what a press hits, with the box or track drawn under it. Outside a\n * `Field`, a `description` draws one around it; `label` is always the text\n * beside the control.\n */\nexport function ToggleInput(props: ToggleInputProps) {\n return (\n <InputFrame\n label={undefined}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <ToggleControl {...props} />\n </InputFrame>\n );\n}\n","import { CHECKBOX, ToggleInput } from \"./ToggleInput\";\nimport type { ToggleBaseProps } from \"./toggleProps\";\n\nexport interface CheckboxProps extends ToggleBaseProps<boolean> {\n /**\n * A flip can set `null`, drawn indeterminate: `false` → `true` → `null`\n * → `false`. Without it a flip never sets `null`, and an app's `null`\n * checks on the first flip.\n */\n readonly threeState?: boolean | undefined;\n}\n\n/**\n * A checkbox. Its value is `true`, `false` or `null`, which is drawn\n * indeterminate (\"mixed\"); it starts `false`. Every flip, by a press or\n * <kbd>Space</kbd>, fires the change events and commits at once (`source`\n * and `trigger` `\"toggle\"`), with \"Yes\" or \"No\" as its text. `required`\n * means it must be checked; `readOnly` refuses flips and stays focusable;\n * display mode shows \"Yes\", \"No\" or a dash. Named by `label`, the text\n * beside the box, and by the label of a `Field` around it.\n */\nexport function Checkbox(props: CheckboxProps) {\n return <ToggleInput {...props} variant={CHECKBOX} />;\n}\n","import { SWITCH, ToggleInput } from \"./ToggleInput\";\nimport type { ToggleBaseProps } from \"./toggleProps\";\n\nexport interface SwitchProps extends Omit<\n ToggleBaseProps<boolean>,\n \"value\" | \"defaultValue\"\n> {\n /** Present means controlled. A switch is on or off, never empty. */\n readonly value?: boolean | undefined;\n /** Off unless given. */\n readonly defaultValue?: boolean | undefined;\n /**\n * Shows \"On\" or \"Off\" beside the track. Screen readers hear the state\n * from the control, so the words are hidden from them.\n */\n readonly showStateLabel?: boolean | undefined;\n}\n\n/**\n * A switch (`role=\"switch\"`), for a setting that takes effect at once: on\n * or off, with no empty state. Every flip, by a press or <kbd>Space</kbd>,\n * fires the change events and commits (`source` and `trigger` `\"toggle\"`),\n * with \"On\" or \"Off\" as its text. `required` means it must be on;\n * `readOnly` refuses flips and stays focusable; display mode shows \"On\" or\n * \"Off\". The thumb moves to the reading end when on.\n */\nexport function Switch(props: SwitchProps) {\n return <ToggleInput {...props} variant={SWITCH} />;\n}\n","// React form inputs and form structure. The types an app writes against are\n// re-exported from forms-core, so an app imports from this package alone.\nexport type {\n FieldBeforeChangeEvent,\n FieldBeforeCommitEvent,\n FieldBeforeInputEvent,\n FieldChangeEvent,\n FieldClearEvent,\n FieldCommitEvent,\n FieldEventBase,\n FieldFocusEvent,\n FieldHandlers,\n FieldInputEvent,\n FieldValidateEvent,\n} from \"./events\";\nexport { Calendar, type CalendarProps } from \"./calendar/Calendar\";\nexport type {\n CalendarLimitProps,\n CalendarSettings,\n} from \"./calendar/calendarProps\";\nexport {\n RangeCalendar,\n type RangeCalendarDetails,\n type RangeCalendarProps,\n} from \"./calendar/RangeCalendar\";\nexport { DateInput, type DateInputProps } from \"./date/DateInput\";\nexport {\n DateTimeInput,\n type DateTimeInputProps,\n type DateTimeValue,\n type DateTimeValueType,\n type DateTimeZoneProps,\n} from \"./date/DateTimeInput\";\nexport type {\n DayLimits,\n SegmentedInputProps,\n TimeSettings,\n} from \"./date/segmentedProps\";\nexport { TimeInput, type TimeInputProps } from \"./date/TimeInput\";\nexport { Field, type FieldProps } from \"./field/Field\";\nexport type { FieldControlState } from \"./field/fieldContext\";\nexport { FieldGroup, type FieldGroupProps } from \"./field/FieldGroup\";\nexport type { FieldSpan } from \"./field/parts\";\nexport {\n useField,\n type FieldControlProps,\n type UseFieldOptions,\n type UseFieldResult,\n} from \"./field/useField\";\nexport { Form, type FormProps } from \"./form/Form\";\nexport { FormsProvider, type FormsProviderProps } from \"./FormsProvider\";\nexport {\n MessageSummary,\n type MessageSummaryProps,\n} from \"./form/MessageSummary\";\nexport { Fieldset, type FieldsetProps } from \"./layout/Fieldset\";\nexport { FormLayout, type FormLayoutProps } from \"./layout/FormLayout\";\nexport { FormSection, type FormSectionProps } from \"./layout/FormSection\";\nexport type {\n Density,\n FieldMode,\n LabelPosition,\n NecessityIndicator,\n} from \"./settings\";\nexport {\n DurationInput,\n type DurationInputProps,\n} from \"./duration/DurationInput\";\nexport { MaskedInput, type MaskedInputProps } from \"./mask/MaskedInput\";\nexport {\n NumberInput,\n type NumberInputProps,\n type NumberLimit,\n type NumberStepEvent,\n} from \"./number/NumberInput\";\nexport {\n NumberRangeInput,\n type NumberRange,\n type NumberRangeDetails,\n type NumberRangeInputProps,\n} from \"./number/NumberRangeInput\";\nexport { PercentInput, type PercentInputProps } from \"./number/PercentInput\";\nexport { PeriodInput, type PeriodInputProps } from \"./period/PeriodInput\";\nexport { SearchInput, type SearchInputProps } from \"./text/SearchInput\";\nexport { TextInput, type TextInputProps } from \"./text/TextInput\";\nexport type {\n InputBaseProps,\n ManagedControlProps,\n TextInputBaseProps,\n} from \"./text/textInputProps\";\nexport { Checkbox, type CheckboxProps } from \"./toggle/Checkbox\";\nexport { Switch, type SwitchProps } from \"./toggle/Switch\";\nexport type {\n ToggleBaseProps,\n ToggleLabelPlacement,\n} from \"./toggle/toggleProps\";\nexport {\n useFieldInput,\n type FieldControlBinding,\n type FieldInput,\n type FieldInputKind,\n type FieldInputOptions,\n type FieldInputProps,\n type InputHandle,\n} from \"./useFieldInput\";\nexport {\n formatText,\n maskPresets,\n parsed,\n textParser,\n unreadable,\n type CalendarMonth,\n type ChangeSource,\n type CommitTrigger,\n type DateDetails,\n type DateRange,\n type DateReadingInfo,\n type DateSegmentType,\n type DateTimeDetails,\n type DecimalString,\n type DurationDetails,\n type DurationNotation,\n type DurationUnit,\n type FieldDraft,\n type FieldMessage,\n type FieldMessageInput,\n type FieldPhase,\n type FiscalYear,\n type FieldState,\n type FormatContext,\n type Formatter,\n type FormsMessages,\n type Instant,\n type MaskDetails,\n type MaskOptions,\n type MaskPreset,\n type MaskPresets,\n type MaskSource,\n type MaskTokenDefinition,\n type MaskTokens,\n type MaskValueFormat,\n type NegativeStyle,\n type NumberDetails,\n type NumberReadingInfo,\n type NumberValue,\n type NumberValueType,\n type NoDetails,\n type NoFlags,\n type ParseContext,\n type ParseResult,\n type Parser,\n type PercentScale,\n type Period,\n type PeriodDetails,\n type PeriodGranularity,\n type PlainDate,\n type PlainDateTime,\n type PlainTime,\n type PopupCloseReason,\n type PopupOpenChange,\n type PopupOpenReason,\n type Range,\n type RangeBounds,\n type RangeDetails,\n type RangeEnd,\n type RoundingMode,\n type Severity,\n type StepDirection,\n type StepSize,\n type TextInputDetails,\n type TextParseOptions,\n type TextReading,\n type TimeDetails,\n type TimeZoneDisambiguation,\n type ValidationResult,\n type Validator,\n type ValidatorContext,\n type Weekday,\n type WeekNumbering,\n} from \"@gridkitjs/forms-core\";\n"],"mappings":";;;AAAA;AAAA,EACE,qBAAAA;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,yBAAAC;A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AAa,GAAG,OAAO,SAAS,QAAQ;AAClD;;;AC6EA;AAAA,EACE,cAAAC;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,OAqEK;","names":["availableDateRule","dateDetails","dateFormatter","formatDate","isCalendarDayDisabled","isPlainDate","maxDateRule","minDateRule","requiredRule","weekInfo","useCallback","useMemo","formatDate","runtimeTimeZone","todayIn","useMemo","useState","messages","isCalendarDayDisabled","useLayoutEffect","useMemo","calendarMonthParts","useMemo","useMemo","NO_MESSAGES","jsx","useMemo","useLayoutEffect","useRef","useState","useCallback","useState","jsx","jsxs","useRef","useState","useLayoutEffect","years","jsx","jsxs","calendarMonthParts","jsx","useMemo","useLayoutEffect","isCalendarDayDisabled","useCallback","useEffect","useState","useMemo","useRef","useState","createContext","useContext","useLayoutEffect","createContext","useContext","useMemo","jsx","attachOverlay","writingDirection","useLayoutEffect","useState","useCallback","useLayoutEffect","useRef","useState","Fragment","jsx","jsxs","ANCHOR_GAP","useState","useLayoutEffect","attachOverlay","writingDirection","jsx","jsxs","jsx","jsxs","useState","useMemo","useRef","jsx","jsxs","Icon","useState","useCallback","useEffect","mostSevere","resolveFormsMessages","sortFieldMessages","toFieldMessages","useCallback","useEffect","useId","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","jsx","jsxs","jsx","NO_MESSAGES","useId","useMemo","resolveFormsMessages","useLayoutEffect","useEffect","useShownMessages","sortFieldMessages","toFieldMessages","mostSevere","useState","useSyncExternalStore","useCallback","useRef","Fragment","useRef","createPortal","jsx","createPortal","createFieldController","hasError","scheduleTimeout","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","jsx","NO_MESSAGES","value","useEffect","scheduleTimeout","useState","createFieldController","useSyncExternalStore","shown","text","useRef","useLayoutEffect","useImperativeHandle","useMemo","useShownMessages","displayText","hasError","jsx","jsxs","Fragment","useRef","jsx","todayIn","runtimeTimeZone","useState","formatDate","useMemo","createFieldController","hasError","useEffect","useImperativeHandle","useLayoutEffect","useState","useSyncExternalStore","jsx","NO_MESSAGES","value","useEffect","useState","createFieldController","useSyncExternalStore","useLayoutEffect","useImperativeHandle","useShownMessages","hasError","jsx","jsxs","SELECTED","dateFormatter","dateDetails","value","formatDate","isPlainDate","useMemo","requiredRule","minDateRule","maxDateRule","availableDateRule","weekInfo","useCallback","isCalendarDayDisabled","compareDates","formatDate","isCalendarDayDisabled","isPlainDate","requiredRule","weekInfo","useCallback","useLayoutEffect","useMemo","useRef","useState","jsx","jsxs","end","isPlainDate","compareDates","weekInfo","formatDate","useMemo","requiredRule","useState","useRef","useLayoutEffect","useCallback","isCalendarDayDisabled","availableDateRule","dateLayout","pivotYear","requiredRule","useMemo","useState","isCalendarDayDisabled","useLayoutEffect","useRef","useState","jsx","useRef","useState","useLayoutEffect","next","nextIndex","Fragment","jsx","jsxs","isCalendarDayDisabled","jsx","useState","dateLayout","pivotYear","useMemo","requiredRule","availableDateRule","dateLayout","requiredRule","splitDateTime","useEffect","useMemo","useState","setTimeColumn","snapTime","timeColumns","Fragment","jsx","jsxs","timeColumns","setTimeColumn","snapTime","jsx","useState","useEffect","dateLayout","useMemo","requiredRule","splitDateTime","hasError","mostSevere","toFieldMessages","useId","useMemo","useRef","jsx","jsxs","useId","mostSevere","hasError","toFieldMessages","useMemo","useRef","toFieldMessages","useCallback","useId","useLayoutEffect","useRef","useId","useRef","useLayoutEffect","useCallback","toFieldMessages","useCallback","useLayoutEffect","useState","flushSync","jsx","useState","useCallback","useLayoutEffect","flushSync","jsx","useCallback","useId","useMemo","useSyncExternalStore","Fragment","jsx","jsxs","titleId","useId","useSyncExternalStore","useMemo","useCallback","useId","jsx","jsxs","useId","jsx","useCallback","useId","useLayoutEffect","useRef","useState","jsx","jsxs","useId","titleId","useState","useCallback","useRef","useLayoutEffect","requiredRule","useMemo","useEffect","useLayoutEffect","useMemo","useRef","useMemo","useEffect","useRef","useLayoutEffect","jsx","jsxs","useMemo","requiredRule","maskDetails","requiredRule","useMemo","jsx","jsxs","useMemo","requiredRule","maskDetails","compareDecimals","requiredRule","stepNumberValue","useEffect","useLayoutEffect","useMemo","useRef","useState","jsx","jsxs","ChevronIcon","useState","useRef","useLayoutEffect","useEffect","useMemo","requiredRule","stepNumberValue","compareDecimals","compareDecimals","formatNumber","maxRule","minRule","numberAffixes","numberCaret","numberSymbols","rangeDetails","requiredRule","sameRange","stepNumberValue","useLayoutEffect","useMemo","useState","hasError","attachFocusGroup","attachTextInput","useImperativeHandle","useLayoutEffect","useRef","useState","useSyncExternalStore","NO_MESSAGES","useState","useSyncExternalStore","useLayoutEffect","attachFocusGroup","useImperativeHandle","useShownMessages","hasError","useRef","attachTextInput","jsx","jsxs","compareDecimals","useLayoutEffect","formatNumber","numberSymbols","useMemo","span","requiredRule","minRule","maxRule","value","sameRange","rangeDetails","useState","numberCaret","hiddenInputs","stepNumberValue","nameId","numberAffixes","jsx","comparePeriods","periodOf","periodParts","pivotYear","requiredRule","useEffect","useMemo","useState","formatMonthName","useRef","useState","jsx","jsxs","useRef","useState","titleId","formatMonthName","jsx","useEffect","useMemo","useState","comparePeriods","periodParts","periodOf","pivotYear","requiredRule","formatText","requiredRule","textParser","useMemo","jsx","jsxs","textParser","formatText","useMemo","requiredRule","formatText","requiredRule","textParser","scheduleTimeout","useEffect","useLayoutEffect","useMemo","useRef","useState","Fragment","jsx","jsxs","useState","useRef","useEffect","scheduleTimeout","useMemo","textParser","formatText","requiredRule","useLayoutEffect","useMemo","Fragment","jsx","jsxs","useMemo","jsx","jsx","formatText","parsed","textParser","unreadable"]}
|
|
1
|
+
{"version":3,"sources":["../src/calendar/Calendar.tsx","../src/date/DateInput.tsx","../src/field/fieldContext.ts","../src/calendar/PopupCalendar.tsx","../src/calendar/CalendarBody.tsx","../src/calendar/MonthPanel.tsx","../src/field/parts.tsx","../src/calendar/MonthsView.tsx","../src/calendar/useCalendarNavigation.ts","../src/text/parts.tsx","../src/dev.ts","../src/field/Field.tsx","../src/form/formContext.ts","../src/settings.tsx","../src/field/FieldHelp.tsx","../src/picker/usePickerPopup.ts","../src/field/FieldMessages.tsx","../src/refs.ts","../src/useFieldInput.tsx","../src/DisplayValue.tsx","../src/date/SegmentedControl.tsx","../src/picker/PickerPopup.tsx","../src/date/useSegmentedInput.tsx","../src/calendar/usePickerField.tsx","../src/calendar/RangeCalendar.tsx","../src/choice/Select.tsx","../src/choice/selectModel.ts","../src/choice/useChoiceField.tsx","../src/choice/SelectPopup.tsx","../src/choice/ChoicePopup.tsx","../src/choice/ChoiceStatus.tsx","../src/choice/OptionList.tsx","../src/choice/SelectTrigger.tsx","../src/choice/ChipList.tsx","../src/choice/useChoicePopup.ts","../src/choice/useCombobox.ts","../src/choice/useCreateOption.ts","../src/choice/useListActivation.ts","../src/choice/useMultipleChoice.ts","../src/choice/useOptionRows.ts","../src/choice/useSelectField.ts","../src/choice/useChoiceOptions.ts","../src/choice/useOptionSource.ts","../src/choice/useChoiceQuery.ts","../src/date/DateTimeInput.tsx","../src/time/DateTimePicker.tsx","../src/time/TimeColumns.tsx","../src/date/TimeInput.tsx","../src/time/TimePicker.tsx","../src/field/FieldGroup.tsx","../src/field/useField.ts","../src/form/Form.tsx","../src/FormsProvider.tsx","../src/form/MessageSummary.tsx","../src/layout/Fieldset.tsx","../src/layout/FormLayout.tsx","../src/layout/FormSection.tsx","../src/duration/DurationInput.tsx","../src/number/numberKind.ts","../src/mask/MaskedInput.tsx","../src/mask/maskKind.ts","../src/number/NumberInput.tsx","../src/number/NumberRangeInput.tsx","../src/useCompositeInput.tsx","../src/number/PercentInput.tsx","../src/period/PeriodInput.tsx","../src/period/PeriodPicker.tsx","../src/text/SearchInput.tsx","../src/text/TextInput.tsx","../src/toggle/ToggleInput.tsx","../src/toggle/Checkbox.tsx","../src/toggle/Switch.tsx","../src/index.ts"],"sourcesContent":["import {\n availableDateRule,\n dateDetails,\n dateFormatter,\n formatDate,\n isCalendarDayDisabled,\n isPlainDate,\n maxDateRule,\n minDateRule,\n requiredRule,\n weekInfo,\n type CalendarLimits,\n type CalendarMonth,\n type DateDetails,\n type DateFieldOptions,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport { useCallback, useMemo, type RefCallback } from \"react\";\nimport { todayFor } from \"../date/DateInput\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { joinIds, OwnMessages, useOwnMessagesId } from \"../text/parts\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { CalendarBody } from \"./CalendarBody\";\nimport type {\n CalendarBaseProps,\n CalendarLimitProps,\n CalendarSettings,\n} from \"./calendarProps\";\nimport { NO_MARKS, titleId, type CalendarLook } from \"./MonthPanel\";\nimport { useCalendarNavigation, useToday } from \"./useCalendarNavigation\";\nimport {\n hiddenInputs,\n usePickerField,\n type PickerKind,\n} from \"./usePickerField\";\n\nexport interface CalendarProps\n extends\n CalendarBaseProps<PlainDate, DateDetails>,\n CalendarLimitProps,\n CalendarSettings {\n /** The month shown, `\"2026-03\"`; present means controlled. The value's month, else today's, by default. */\n readonly month?: CalendarMonth | undefined;\n /** The month shown first, uncontrolled. */\n readonly defaultMonth?: CalendarMonth | undefined;\n /** The month shown changed: the month buttons, the keys, the month view. */\n readonly onMonthChange?: ((month: CalendarMonth) => void) | undefined;\n}\n\n/** The day in a calendar that takes focus from code: its one Tab stop in the grid. */\nexport function focusedDayIn(root: HTMLElement): HTMLElement | null {\n return root.querySelector<HTMLElement>('[role=\"gridcell\"][tabindex=\"0\"]');\n}\n\nconst SELECTED = { ...NO_MARKS, selected: true };\n\n/**\n * A month grid to choose one day from, following the APG date picker:\n * the arrows move by day and week, Home and End to the week's ends,\n * PageUp and PageDown by month (with Shift, by year), Enter or Space\n * chooses, and the month buttons and the title's month and year view jump\n * further. Weeks start on the locale's first day and may show their\n * numbers; days outside `min` and `max` and those `isDateDisabled` marks\n * take focus but cannot be chosen.\n *\n * Its value is a `PlainDate`, `null` when nothing is chosen. Choosing a\n * day fires the change and commit events with `source` and `trigger`\n * `\"picker\"` and `DateDetails`; moving between days fires only\n * `onMonthChange` when the month changes. It takes the shared input props:\n * display mode, `readOnly` (days take focus, none can be chosen),\n * `disabled`, messages, `name` and the events of `@gridkitjs/forms`.\n */\nexport function Calendar({\n min,\n max,\n isDateDisabled,\n timeZone,\n firstDayOfWeek,\n weekNumbers = false,\n weekNumbering,\n month,\n defaultMonth,\n onMonthChange,\n required,\n validate,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: CalendarProps) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const needsValue = required === true || field?.required === true;\n const today = todayFor(timeZone);\n const options: DateFieldOptions = { today, shortcuts: false, min, max };\n const kind: PickerKind<PlainDate, DateDetails> = {\n name: \"Calendar\",\n defaultFormat: dateFormatter(),\n details: (current, _previous, cause) =>\n dateDetails(current, cause, { ...options, locale, messages }),\n display: (value) => formatDate(value, locale),\n isValue: isPlainDate,\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<PlainDate>()] : []),\n ...(min === undefined ? [] : [minDateRule(min)]),\n ...(max === undefined ? [] : [maxDateRule(max)]),\n ...(isDateDisabled === undefined\n ? []\n : [availableDateRule<PlainDate>(isDateDisabled)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, isDateDisabled, validate],\n );\n const picker = usePickerField(\n { ...props, required, validate: validators },\n kind,\n focusedDayIn,\n );\n const { rootId, readOnly, disabled } = picker;\n const { value } = picker.state;\n\n const limits: CalendarLimits = useMemo(\n () => ({ min, max, isDateDisabled }),\n [min, max, isDateDisabled],\n );\n const firstDay = firstDayOfWeek ?? weekInfo(locale).firstDay;\n const nav = useCalendarNavigation({\n focus: value ?? today(),\n month,\n defaultMonth,\n onMonthChange,\n context: { firstDayOfWeek: firstDay, visibleMonths: 1, limits },\n });\n const { setRoot } = picker;\n const navSetRoot = nav.setRoot;\n const rootRef = useCallback<RefCallback<HTMLDivElement>>(\n (element) => {\n navSetRoot(element);\n setRoot(element);\n },\n [navSetRoot, setRoot],\n );\n const shownToday = useToday(timeZone);\n const ownMessagesId = useOwnMessagesId(rootId);\n const hidden = hiddenInputs(props.name, props.form, disabled, [\n [\"\", value ?? \"\"],\n ]);\n\n if (picker.mode === \"display\") {\n return (\n <div\n className={classNames(\n \"gridkit-forms-calendar\",\n \"is-display\",\n className,\n )}\n style={style}\n >\n <DisplayValue\n text={picker.displayText}\n emptyText={picker.strings.emptyValue}\n />\n {hidden}\n </div>\n );\n }\n\n function choose(date: PlainDate, nativeEvent: Event) {\n if (!readOnly && !disabled && !isCalendarDayDisabled(date, limits)) {\n picker.pick(date, nativeEvent);\n }\n }\n\n const look: CalendarLook = {\n rootId,\n locale,\n strings: picker.strings,\n firstDayOfWeek: firstDay,\n weekNumbering,\n weekNumbers,\n weekend: weekInfo(locale).weekend,\n limits,\n today: shownToday,\n focused: nav.state.focused,\n disabled,\n readOnly,\n range: false,\n marks: (date) => (date === value ? SELECTED : NO_MARKS),\n };\n\n return (\n <div\n ref={rootRef}\n id={rootId}\n className={classNames(\n \"gridkit-forms-calendar\",\n disabled && \"is-disabled\",\n readOnly && \"is-read-only\",\n picker.invalid && \"is-invalid\",\n className,\n )}\n style={style}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy ??\n (ariaLabel === undefined\n ? joinIds(picker.fieldLabelId, titleId(rootId, 0))\n : undefined)\n }\n aria-describedby={joinIds(\n picker.describedBy,\n ownMessagesId,\n ariaDescribedBy,\n )}\n >\n <CalendarBody\n nav={nav}\n look={look}\n visibleMonths={1}\n onDayClick={(date, event) => {\n choose(date, event.nativeEvent);\n }}\n onChooseKey={(date, event) => {\n choose(date, event.nativeEvent);\n }}\n />\n {hidden}\n <OwnMessages\n id={`${rootId}-messages`}\n messages={picker.messages}\n strings={picker.strings}\n named\n />\n </div>\n );\n}\n","import {\n availableDateRule,\n compareDates,\n dateDetails,\n dateFormatter,\n dateLayout,\n dateParser,\n formatDate,\n isPlainDate,\n maxDateRule,\n minDateRule,\n nowIn,\n pivotYear,\n requiredRule,\n runtimeTimeZone,\n todayIn,\n type DateDetails,\n type DateFieldOptions,\n type PlainDate,\n type PlainDateTime,\n type PopupOpenChange,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, useState } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport type { CalendarSettings } from \"../calendar/calendarProps\";\nimport { PopupCalendar } from \"../calendar/PopupCalendar\";\nimport { CalendarIcon, InputFrame } from \"../text/parts\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { SegmentedControl } from \"./SegmentedControl\";\nimport type { DayLimits, SegmentedInputProps } from \"./segmentedProps\";\nimport {\n createSegmentsAccess,\n typingSegment,\n type SegmentedKind,\n} from \"./useSegmentedInput\";\n\nexport interface DateInputProps\n extends\n SegmentedInputProps<PlainDate, DateDetails>,\n DayLimits,\n CalendarSettings {\n /** The calendar button and its popup; on by default. */\n readonly calendar?: boolean | undefined;\n /** The calendar popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n}\n\n/** The day cell that takes focus as a calendar popup opens: the chosen day, else today. */\nexport function focusedDay(panel: HTMLElement): HTMLElement | null {\n return panel.querySelector<HTMLElement>('[role=\"gridcell\"][tabindex=\"0\"]');\n}\n\n/** Today in `timeZone`, or the runtime's zone, read when it is asked for. */\nexport function todayFor(timeZone: string | undefined): () => PlainDate {\n return () => todayIn(timeZone ?? runtimeTimeZone(), Date.now());\n}\n\n/** The wall clock now in `timeZone`, or the runtime's zone, read when it is asked for. */\nexport function nowFor(timeZone: string | undefined): () => PlainDateTime {\n return () => nowIn(timeZone ?? runtimeTimeZone(), Date.now());\n}\n\nfunction DateInputControl({\n min,\n max,\n isDateDisabled,\n shortcuts = true,\n timeZone,\n calendar = true,\n onOpenChange,\n firstDayOfWeek,\n weekNumbers,\n weekNumbering,\n required,\n validate,\n ...props\n}: DateInputProps) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const [segments] = useState(createSegmentsAccess);\n const { numberingSystem, displayFormat } = props;\n const needsValue = required === true || field?.required === true;\n\n const today = todayFor(timeZone);\n const options: DateFieldOptions = {\n today,\n shortcuts,\n min,\n max,\n numberingSystem,\n displayFormat,\n activeSegment: () => typingSegment(segments),\n };\n const kind: SegmentedKind<PlainDate, DateDetails> = {\n name: \"DateInput\",\n layout: dateLayout({ locale, fields: \"date\", numberingSystem }, messages),\n defaultParse: dateParser(options),\n defaultFormat: dateFormatter({ numberingSystem }),\n details: (current, _previous, cause) =>\n dateDetails(current, cause, { ...options, locale, messages }),\n display: (value) => formatDate(value, locale, displayFormat),\n serialize: (value) => value,\n isValue: isPlainDate,\n inLimits: (value) =>\n (min === undefined || compareDates(value, min) >= 0) &&\n (max === undefined || compareDates(value, max) <= 0),\n shortcuts,\n today,\n pivot: (digits) => pivotYear(digits, { today: today(), min, max }),\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<PlainDate>()] : []),\n ...(min === undefined ? [] : [minDateRule(min, displayFormat)]),\n ...(max === undefined ? [] : [maxDateRule(max, displayFormat)]),\n ...(isDateDisabled === undefined\n ? []\n : [availableDateRule<PlainDate>(isDateDisabled)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, displayFormat, isDateDisabled, validate],\n );\n\n return (\n <SegmentedControl\n props={{ ...props, required, validate: validators }}\n kind={kind}\n rootClassName=\"gridkit-forms-date-input\"\n segments={segments}\n picker={\n calendar\n ? {\n label: messages.chooseDate,\n icon: <CalendarIcon />,\n buttonClassName: \"gridkit-forms-calendar-button\",\n popupClassName: \"gridkit-forms-calendar-popup\",\n onOpenChange,\n initialFocus: focusedDay,\n content: ({ value, id, pick, close, setEscapeHandler }) => (\n <PopupCalendar\n id={id}\n selected={value}\n min={min}\n max={max}\n isDateDisabled={isDateDisabled}\n timeZone={timeZone}\n firstDayOfWeek={firstDayOfWeek}\n weekNumbers={weekNumbers}\n weekNumbering={weekNumbering}\n locale={locale}\n strings={messages}\n onChoose={(date, nativeEvent) => {\n pick(date, nativeEvent);\n close(\"picker\");\n }}\n setEscapeHandler={setEscapeHandler}\n />\n ),\n }\n : undefined\n }\n />\n );\n}\n\n/**\n * A date typed in segments in the locale's order (`03/14/2026` in en-US,\n * `14.03.2026` in de-DE, `2026/03/14` in ja-JP): typing moves on by\n * itself, the arrow keys move between segments and step them, separators\n * are optional, and the whole field is one Tab stop. A letter or a sign\n * opens a box for shortcuts (`t` today, `+3`, `-1w`, `s` and `e` for the\n * month's start and end), and a pasted date in any common form is read\n * whole. Its value is a `PlainDate`, an ISO string (`\"2026-03-14\"`),\n * `null` when empty; text that is incomplete or no date keeps the last\n * value and says why. `min`, `max` and `isDateDisabled` add their\n * messages. It takes every shared input prop: display mode, `readOnly`,\n * `disabled`, messages with their severity, density, prefix and suffix,\n * and the events of `@gridkitjs/forms` with `DateDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function DateInput(props: DateInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <DateInputControl {...props} />\n </InputFrame>\n );\n}\n","import type { FieldMessage, Severity } from \"@gridkitjs/forms-core\";\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\nimport type { FormSettings } from \"../settings\";\n\n/**\n * What an input tells the `Field` around it about its control, so a\n * floating label knows whether to rest inside the control or rise above.\n */\nexport interface FieldControlState {\n readonly focused: boolean;\n /** No text in the control. */\n readonly empty: boolean;\n /** Something sits at the control's start, such as a prefix, where a resting label would cover it. */\n readonly startAdornment?: boolean | undefined;\n /** The input needs a value by a `required` of its own, so the field marks its label. */\n readonly required?: boolean | undefined;\n /**\n * The control carries its own label beside it (a checkbox, a switch), so\n * nothing can rest inside it: a floating label sits above, as `top`.\n */\n readonly labelBeside?: boolean | undefined;\n}\n\n/** What a `Field`, or a `FieldGroup`, gives the inputs inside it. */\nexport interface FieldContextValue {\n /**\n * The control's `id`, which the label's `for` names; `null` in a\n * group, whose inputs each keep their own.\n */\n readonly controlId: string | null;\n /** The field's own settings, its props laid over the form's. */\n readonly settings: FormSettings;\n /** `aria-describedby` for the control: the description and the messages. */\n readonly describedBy: string;\n /** The field's `required`: the input checks for a value. */\n readonly required: boolean;\n /**\n * An error is shown under the field: from the app, or in a single field\n * from its input. In a group each input marks only its own errors.\n */\n readonly invalid: boolean;\n /**\n * The most serious message shown under a single field, which its\n * control's border takes; `null` in a group, whose inputs each take\n * their own.\n */\n readonly severity: Severity | null;\n /**\n * The shown messages of the input `reporter` names (its own `useId`),\n * which the field lists with its own; none takes the report back.\n */\n readonly setControlMessages: (\n reporter: string,\n messages: readonly FieldMessage[],\n ) => void;\n /** `null` when the input goes. A group ignores it. */\n readonly setControlState: (state: FieldControlState | null) => void;\n}\n\nexport const FieldContext = createContext<FieldContextValue | null>(null);\n\n/** The `Field` around the caller, or `null` outside one. */\nexport function useFieldContext(): FieldContextValue | null {\n return useContext(FieldContext);\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\nconst NO_REPORTS: ReadonlyMap<string, readonly FieldMessage[]> = new Map();\n\n/**\n * What the inputs inside a field or a group report as their shown\n * messages, in the order they first reported, and the setter they report\n * through.\n */\nexport function useControlMessages(): readonly [\n readonly FieldMessage[],\n FieldContextValue[\"setControlMessages\"],\n] {\n const [reports, setReports] = useState(NO_REPORTS);\n const setControlMessages = useCallback(\n (reporter: string, messages: readonly FieldMessage[]) => {\n setReports((current) => {\n if (messages.length === 0) {\n if (!current.has(reporter)) {\n return current;\n }\n const next = new Map(current);\n next.delete(reporter);\n return next;\n }\n return current.get(reporter) === messages\n ? current\n : new Map(current).set(reporter, messages);\n });\n },\n [],\n );\n const messages = useMemo(\n () => (reports.size === 0 ? NO_MESSAGES : [...reports.values()].flat()),\n [reports],\n );\n return [messages, setControlMessages];\n}\n","import {\n isCalendarDayDisabled,\n weekInfo,\n type CalendarLimits,\n type FormsMessages,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport { useLayoutEffect, useMemo } from \"react\";\nimport { todayFor } from \"../date/DateInput\";\nimport type { CalendarLimitProps, CalendarSettings } from \"./calendarProps\";\nimport { CalendarBody } from \"./CalendarBody\";\nimport { NO_MARKS, titleId, type CalendarLook } from \"./MonthPanel\";\nimport { useCalendarNavigation, useToday } from \"./useCalendarNavigation\";\n\nconst SELECTED = { ...NO_MARKS, selected: true };\n\n/** What a calendar in a picker popup reads. */\nexport interface PopupCalendarProps\n extends CalendarLimitProps, CalendarSettings {\n /** The popup's `id`, the prefix of the calendar's own ids. */\n readonly id: string;\n /** The day shown chosen, and where focus starts; today when `null`. */\n readonly selected: PlainDate | null;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** A day chosen by click, tap, Enter or Space; never a disabled one. */\n readonly onChoose: (date: PlainDate, nativeEvent: Event) => void;\n /** Takes Escape while the month view shows, which goes back to the days. */\n readonly setEscapeHandler: (handler: (() => boolean) | null) => void;\n}\n\n/**\n * The calendar a date input's popup shows: one month, the keys, the month\n * buttons and the month and year view of `Calendar`, without a field of\n * its own. Choosing a day calls `onChoose`, which the input turns into a\n * pick; focus starts on the chosen day, else today.\n */\nexport function PopupCalendar({\n id,\n selected,\n min,\n max,\n isDateDisabled,\n timeZone,\n firstDayOfWeek,\n weekNumbers = false,\n weekNumbering,\n locale,\n strings,\n onChoose,\n setEscapeHandler,\n}: PopupCalendarProps) {\n const limits: CalendarLimits = useMemo(\n () => ({ min, max, isDateDisabled }),\n [min, max, isDateDisabled],\n );\n const firstDay = firstDayOfWeek ?? weekInfo(locale).firstDay;\n const nav = useCalendarNavigation({\n focus: selected ?? todayFor(timeZone)(),\n context: { firstDayOfWeek: firstDay, visibleMonths: 1, limits },\n });\n const shownToday = useToday(timeZone);\n const { setRoot } = nav;\n\n useLayoutEffect(() => {\n setEscapeHandler(() => {\n if (nav.state.view.kind !== \"months\") {\n return false;\n }\n nav.dispatch({ type: \"closeMonths\" });\n nav.focusDay();\n return true;\n });\n return () => {\n setEscapeHandler(null);\n };\n });\n\n function choose(date: PlainDate, nativeEvent: Event) {\n if (!isCalendarDayDisabled(date, limits)) {\n onChoose(date, nativeEvent);\n }\n }\n\n const rootId = `${id}-calendar`;\n const look: CalendarLook = {\n rootId,\n locale,\n strings,\n firstDayOfWeek: firstDay,\n weekNumbering,\n weekNumbers,\n weekend: weekInfo(locale).weekend,\n limits,\n today: shownToday,\n focused: nav.state.focused,\n disabled: false,\n readOnly: false,\n range: false,\n marks: (date) => (date === selected ? SELECTED : NO_MARKS),\n };\n\n return (\n <div\n ref={setRoot}\n id={rootId}\n className=\"gridkit-forms-calendar\"\n role=\"group\"\n aria-labelledby={titleId(rootId, 0)}\n >\n <CalendarBody\n nav={nav}\n look={look}\n visibleMonths={1}\n onDayClick={(date, event) => {\n choose(date, event.nativeEvent);\n }}\n onChooseKey={(date, event) => {\n choose(date, event.nativeEvent);\n }}\n />\n </div>\n );\n}\n","import {\n calendarMonth,\n calendarMonthParts,\n type CalendarMonth,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport {\n Fragment,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from \"react\";\nimport {\n MonthGridTable,\n MonthHeader,\n monthTitle,\n titleId,\n type CalendarLook,\n} from \"./MonthPanel\";\nimport { MonthsView } from \"./MonthsView\";\nimport {\n calendarKeyMove,\n isRightToLeft,\n type CalendarNavigation,\n} from \"./useCalendarNavigation\";\n\n/** The month `months` after `month`. */\nfunction monthAfter(month: CalendarMonth, months: number): CalendarMonth {\n const parts = calendarMonthParts(month);\n const index = parts.year * 12 + parts.month - 1 + months;\n const year = Math.floor(index / 12);\n return calendarMonth(year, index - year * 12 + 1);\n}\n\n/**\n * What a calendar draws inside its root: each month shown with its header\n * and grid (wrapped in its own `gridkit-forms-calendar` in a range\n * calendar), or the month view in their place. It wires the keys, the\n * month buttons and the month view to `nav`; what choosing a day does is\n * the calendar's.\n */\nexport function CalendarBody({\n nav,\n look,\n visibleMonths,\n onDayClick,\n onChooseKey,\n onFocusMoved,\n onOtherKey,\n}: {\n readonly nav: CalendarNavigation;\n readonly look: CalendarLook;\n readonly visibleMonths: number;\n /** A day clicked or tapped; focus is already on it. */\n readonly onDayClick: (date: PlainDate, event: MouseEvent) => void;\n /** Enter or Space on the focused day. */\n readonly onChooseKey: (date: PlainDate, event: KeyboardEvent) => void;\n /** A key moved focus to `date`. */\n readonly onFocusMoved?: ((date: PlainDate) => void) | undefined;\n /** Any other key in a grid. */\n readonly onOtherKey?: ((event: KeyboardEvent) => void) | undefined;\n}) {\n const { state } = nav;\n\n function onKeyDown(event: KeyboardEvent<HTMLTableElement>) {\n const move = calendarKeyMove(event, isRightToLeft(event.currentTarget));\n if (move !== null) {\n event.preventDefault();\n const next = nav.dispatch({ type: \"move\", move });\n nav.focusDay();\n onFocusMoved?.(next.focused);\n return;\n }\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n onChooseKey(state.focused, event);\n return;\n }\n onOtherKey?.(event);\n }\n\n function page(months: -1 | 1) {\n const next = nav.dispatch({ type: \"page\", months });\n // The button disables at the last month it reaches, which would drop focus.\n if (!nav.canPage(months, next)) {\n nav.focusDay();\n }\n }\n\n const Panel = look.range ? RangePanel : Fragment;\n\n if (state.view.kind === \"months\") {\n const { year, panel } = state.view;\n const shown = monthAfter(state.month, panel);\n const parts = calendarMonthParts(shown);\n const close = () => {\n nav.dispatch({ type: \"closeMonths\" });\n nav.focusDay();\n };\n return (\n <Panel>\n <MonthHeader\n look={look}\n panel={panel}\n title={monthTitle(look, shown)}\n expanded\n previous={null}\n next={null}\n onTitle={close}\n />\n <MonthsView\n year={year}\n shownMonth={parts.month}\n shownYear={parts.year}\n limits={look.limits}\n locale={look.locale}\n strings={look.strings}\n labelId={titleId(look.rootId, panel)}\n onYear={(chosen) => {\n nav.dispatch({ type: \"showYear\", year: chosen });\n }}\n onMonth={(chosen) => {\n nav.dispatch({ type: \"chooseMonth\", month: chosen });\n nav.focusDay();\n }}\n onClose={close}\n />\n </Panel>\n );\n }\n\n return Array.from({ length: visibleMonths }, (_, panel) => {\n const month = monthAfter(state.month, panel);\n return (\n <Panel key={panel}>\n <MonthHeader\n look={look}\n panel={panel}\n title={monthTitle(look, month)}\n expanded={false}\n previous={\n panel === 0\n ? {\n enabled: nav.canPage(-1),\n onClick: () => {\n page(-1);\n },\n }\n : null\n }\n next={\n panel === visibleMonths - 1\n ? {\n enabled: nav.canPage(1),\n onClick: () => {\n page(1);\n },\n }\n : null\n }\n onTitle={() => {\n nav.dispatch({ type: \"openMonths\", panel });\n }}\n />\n <MonthGridTable\n look={look}\n month={month}\n panel={panel}\n onKeyDown={onKeyDown}\n onDayClick={(date, event) => {\n nav.dispatch({ type: \"focus\", date });\n nav.focusDay();\n onDayClick(date, event);\n }}\n />\n </Panel>\n );\n });\n}\n\nfunction RangePanel({ children }: { readonly children: ReactNode }) {\n return <div className=\"gridkit-forms-calendar is-range\">{children}</div>;\n}\n","import {\n calendarMonthParts,\n formatCalendarMonth,\n formatDate,\n formatDayOfMonth,\n formatWeekday,\n isCalendarDayDisabled,\n monthGrid,\n type CalendarLimits,\n type CalendarMonth,\n type FormsMessages,\n type PlainDate,\n type Weekday,\n type WeekNumbering,\n} from \"@gridkitjs/forms-core\";\nimport {\n useMemo,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n} from \"react\";\nimport { classNames } from \"../field/parts\";\n\n/** How a day shows: chosen, an end or the middle of a range, a range previewed. */\nexport interface DayMarks {\n readonly selected: boolean;\n readonly rangeStart: boolean;\n readonly rangeEnd: boolean;\n readonly inRange: boolean;\n readonly preview: boolean;\n}\n\nexport const NO_MARKS: DayMarks = {\n selected: false,\n rangeStart: false,\n rangeEnd: false,\n inRange: false,\n preview: false,\n};\n\n/** What every month of one calendar shares. */\nexport interface CalendarLook {\n readonly rootId: string;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n readonly firstDayOfWeek: Weekday;\n readonly weekNumbering: WeekNumbering | undefined;\n readonly weekNumbers: boolean;\n readonly weekend: readonly Weekday[];\n readonly limits: CalendarLimits;\n readonly today: PlainDate | null;\n /** The day that takes focus in the grid. */\n readonly focused: PlainDate;\n readonly disabled: boolean;\n readonly readOnly: boolean;\n /** A range calendar's grid selects several days. */\n readonly range: boolean;\n readonly marks: (date: PlainDate) => DayMarks;\n}\n\n/** The id of a month's title, which names its grid. */\nexport function titleId(rootId: string, panel: number): string {\n return `${rootId}-title-${String(panel)}`;\n}\n\n/** The date of the day cell an event happened in, if any. */\nexport function dateOf(target: EventTarget | null): PlainDate | null {\n if (!(target instanceof Element)) {\n return null;\n }\n const cell = target.closest<HTMLElement>(\"[data-gridkit-forms-date]\");\n return (cell?.dataset.gridkitFormsDate as PlainDate | undefined) ?? null;\n}\n\nexport function ChevronIcon({ side }: { readonly side: \"start\" | \"end\" }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d={side === \"start\" ? \"m15 18-6-6 6-6\" : \"m9 18 6-6-6-6\"} />\n </svg>\n );\n}\n\n/**\n * A month's header: the previous and next buttons where `canPage` says\n * this month has them, and the title, a button that opens the month view\n * (`expanded` while it shows), read politely as it changes.\n */\nexport function MonthHeader({\n look,\n panel,\n title,\n expanded,\n previous,\n next,\n onTitle,\n}: {\n readonly look: CalendarLook;\n readonly panel: number;\n readonly title: string;\n readonly expanded: boolean;\n /** The previous month button, or `null` where this month has none. */\n readonly previous: NavButton | null;\n readonly next: NavButton | null;\n readonly onTitle: () => void;\n}) {\n const { strings, disabled } = look;\n return (\n <div className=\"gridkit-forms-calendar-header\">\n {previous !== null && (\n <button\n type=\"button\"\n className=\"gridkit-forms-calendar-nav is-previous\"\n aria-label={strings.previousMonth}\n disabled={disabled || !previous.enabled}\n onClick={previous.onClick}\n >\n <ChevronIcon side=\"start\" />\n </button>\n )}\n <button\n type=\"button\"\n className=\"gridkit-forms-calendar-title\"\n id={titleId(look.rootId, panel)}\n aria-live=\"polite\"\n aria-expanded={expanded}\n disabled={disabled}\n onClick={onTitle}\n >\n {title}\n </button>\n {next !== null && (\n <button\n type=\"button\"\n className=\"gridkit-forms-calendar-nav is-next\"\n aria-label={strings.nextMonth}\n disabled={disabled || !next.enabled}\n onClick={next.onClick}\n >\n <ChevronIcon side=\"end\" />\n </button>\n )}\n </div>\n );\n}\n\n/** A month button in a header: whether it can move, and what it does. */\nexport interface NavButton {\n readonly enabled: boolean;\n readonly onClick: (event: MouseEvent<HTMLButtonElement>) => void;\n}\n\n/** A day's accessible name: the full date, and its place in a range. */\nfunction dayLabel(look: CalendarLook, date: PlainDate, marks: DayMarks) {\n const full = formatDate(date, look.locale, { dateStyle: \"full\" });\n if (!look.range) {\n return full;\n }\n const ends = [\n marks.rangeStart && look.strings.calendarRangeStart,\n marks.rangeEnd && look.strings.calendarRangeEnd,\n ].filter(Boolean);\n return [full, ...ends].join(\", \");\n}\n\nconst WEEKDAYS: readonly Weekday[] = [1, 2, 3, 4, 5, 6, 7];\n\n/**\n * How weekday headers are written: the short names (\"Mon\", \"Mo.\"), unless\n * one is longer than four characters, as Arabic's are, which would not\n * fit a cell; then the narrow ones.\n */\nfunction weekdayHeaderWidth(locale: Intl.LocalesArgument): \"short\" | \"narrow\" {\n return WEEKDAYS.every(\n (weekday) => formatWeekday(weekday, locale, \"short\").length <= 4,\n )\n ? \"short\"\n : \"narrow\";\n}\n\n/**\n * One month as a grid (the APG date picker's): weekday headers from\n * `Intl`, week numbers when asked, six weeks of days with the days of the\n * months either side, the focused day the grid's one Tab stop.\n */\nexport function MonthGridTable({\n look,\n month,\n panel,\n onKeyDown,\n onDayClick,\n}: {\n readonly look: CalendarLook;\n readonly month: CalendarMonth;\n readonly panel: number;\n readonly onKeyDown: (event: KeyboardEvent<HTMLTableElement>) => void;\n readonly onDayClick: (date: PlainDate, event: MouseEvent) => void;\n}) {\n const { firstDayOfWeek, weekNumbering } = look;\n // The month's 42 days are laid out again only when the month or the week settings change.\n const grid = useMemo(() => {\n const { year, month: monthNumber } = calendarMonthParts(month);\n return monthGrid(year, monthNumber, { firstDayOfWeek, weekNumbering });\n }, [month, firstDayOfWeek, weekNumbering]);\n const weekNumber = new Intl.NumberFormat(look.locale, { useGrouping: false });\n const headerWidth = weekdayHeaderWidth(look.locale);\n return (\n <table\n className=\"gridkit-forms-calendar-grid\"\n role=\"grid\"\n aria-labelledby={titleId(look.rootId, panel)}\n aria-multiselectable={look.range || undefined}\n aria-readonly={look.readOnly || undefined}\n aria-disabled={look.disabled || undefined}\n onKeyDown={onKeyDown}\n >\n <thead>\n <tr>\n {look.weekNumbers && (\n <th className=\"gridkit-forms-calendar-week-number\" scope=\"col\">\n <span className=\"gridkit-forms-sr-only\">\n {look.strings.weekColumn}\n </span>\n </th>\n )}\n {grid.weekdays.map((weekday) => (\n <th\n key={weekday}\n className=\"gridkit-forms-calendar-weekday\"\n scope=\"col\"\n abbr={formatWeekday(weekday, look.locale, \"long\")}\n >\n {formatWeekday(weekday, look.locale, headerWidth)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {grid.weeks.map(({ week, days }) => (\n <tr key={`${String(week.year)}-${String(week.week)}`}>\n {look.weekNumbers && (\n <th\n className=\"gridkit-forms-calendar-week-number\"\n scope=\"row\"\n aria-label={look.strings.weekLabel(week.week)}\n >\n {weekNumber.format(week.week)}\n </th>\n )}\n {days.map(({ date, weekday, inMonth }) => (\n <Day\n key={date}\n look={look}\n date={date}\n weekday={weekday}\n inMonth={inMonth}\n onClick={onDayClick}\n />\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n\nfunction Day({\n look,\n date,\n weekday,\n inMonth,\n onClick,\n}: {\n readonly look: CalendarLook;\n readonly date: PlainDate;\n readonly weekday: Weekday;\n readonly inMonth: boolean;\n readonly onClick: (date: PlainDate, event: MouseEvent) => void;\n}): ReactNode {\n const marks = look.marks(date);\n const disabled = isCalendarDayDisabled(date, look.limits);\n const today = date === look.today;\n const tabStop = inMonth && date === look.focused;\n return (\n <td\n role=\"gridcell\"\n className={classNames(\n \"gridkit-forms-calendar-day\",\n today && \"is-today\",\n marks.selected && \"is-selected\",\n !inMonth && \"is-outside\",\n disabled && \"is-disabled\",\n look.weekend.includes(weekday) && \"is-weekend\",\n marks.rangeStart && \"is-range-start\",\n marks.rangeEnd && \"is-range-end\",\n marks.inRange && \"is-in-range\",\n marks.preview && \"is-preview\",\n )}\n data-gridkit-forms-date={date}\n tabIndex={look.disabled ? undefined : tabStop ? 0 : -1}\n aria-selected={marks.selected}\n aria-disabled={disabled || undefined}\n aria-current={today ? \"date\" : undefined}\n aria-label={dayLabel(look, date, marks)}\n onClick={(event) => {\n onClick(date, event);\n }}\n >\n {formatDayOfMonth(date, look.locale)}\n </td>\n );\n}\n\n/** A month's title: \"March 2026\". */\nexport function monthTitle(look: CalendarLook, month: CalendarMonth): string {\n return formatCalendarMonth(month, look.locale);\n}\n","import {\n sortFieldMessages,\n toFieldMessages,\n type FieldMessage,\n type FieldMessageInput,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, type CSSProperties } from \"react\";\nimport type { NecessityIndicator } from \"../settings\";\n\n/** Columns a field, a group or a fieldset takes in a `FormLayout`. */\nexport type FieldSpan = 1 | 2 | 3 | 4 | \"full\";\n\n/** The state class for `span`; none for one column. */\nexport function spanClass(span: FieldSpan | undefined): string | false {\n return span !== undefined && span !== 1 && `is-span-${String(span)}`;\n}\n\n/** `style` with the label column's width set, when there is one. */\nexport function withLabelWidth(\n style: CSSProperties | undefined,\n labelWidth: string | undefined,\n): CSSProperties | undefined {\n return labelWidth === undefined\n ? style\n : ({\n ...style,\n \"--gridkit-forms-label-width\": labelWidth,\n } as CSSProperties);\n}\n\n/** Joins the class names that are set. */\nexport function classNames(...names: (string | false | undefined)[]): string {\n return names.filter(Boolean).join(\" \");\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/**\n * The messages a field or group shows: its inputs' and the app's, most\n * serious first, each text of a severity once, as when two inputs of a\n * group both lack a value. A disabled one shows only the app's.\n */\nexport function useShownMessages(\n controlMessages: readonly FieldMessage[],\n message: FieldMessageInput | readonly FieldMessageInput[] | undefined,\n disabled: boolean,\n): readonly FieldMessage[] {\n return useMemo(() => {\n const seen = new Set<string>();\n return sortFieldMessages([\n ...(disabled ? NO_MESSAGES : controlMessages),\n ...toFieldMessages(message, \"app\"),\n ]).filter((shown) => {\n const key = `${shown.severity}:${shown.text}`;\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n }, [disabled, controlMessages, message]);\n}\n\n/**\n * The marker after a label: a star for a required field, hidden from\n * screen readers since the control's `aria-required` says it, or\n * \"(optional)\" for the others, read as part of the label.\n */\nexport function NecessityMarker({\n required,\n indicator,\n strings,\n}: {\n readonly required: boolean;\n readonly indicator: NecessityIndicator;\n readonly strings: FormsMessages;\n}) {\n if (required && indicator === \"required\") {\n return (\n <span className=\"gridkit-forms-field-required\" aria-hidden=\"true\">\n *\n </span>\n );\n }\n if (!required && indicator === \"optional\") {\n return (\n <span className=\"gridkit-forms-field-optional\">\n {` (${strings.optional})`}\n </span>\n );\n }\n return null;\n}\n","import {\n calendarYears,\n formatCalendarYear,\n formatMonthName,\n isCalendarMonthDisabled,\n type CalendarLimits,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport { useLayoutEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport { classNames } from \"../field/parts\";\nimport { isRightToLeft } from \"./useCalendarNavigation\";\n\nconst MONTHS = Array.from({ length: 12 }, (_, index) => index + 1);\nconst COLUMNS = 3;\n\n/** Moves focus among `buttons` from `index` by the key, or returns `null` for a key that moves nothing. */\nexport function nextIndex(\n event: KeyboardEvent,\n index: number,\n count: number,\n steps: { readonly row: number; readonly column: number },\n): number | null {\n const rtl = isRightToLeft(event.currentTarget);\n const moves: Readonly<Record<string, number>> = {\n ArrowLeft: rtl ? steps.column : -steps.column,\n ArrowRight: rtl ? -steps.column : steps.column,\n ArrowUp: -steps.row,\n ArrowDown: steps.row,\n Home: -index,\n End: count - 1 - index,\n };\n const move = moves[event.key];\n if (move === undefined || move === 0) {\n return move === 0 ? index : null;\n }\n return Math.min(Math.max(index + move, 0), count - 1);\n}\n\n/**\n * A calendar's month view, in place of one month's days: its year's\n * twelve months as a grid of buttons, and the years to choose from as a\n * scrolling list. Each is one Tab stop moved through with the arrows; a\n * month chosen goes back to the days, Escape goes back unchanged.\n */\nexport function MonthsView({\n year,\n shownMonth,\n shownYear,\n limits,\n locale,\n strings,\n labelId,\n onYear,\n onMonth,\n onClose,\n}: {\n readonly year: number;\n /** The month and year of the days this view replaced. */\n readonly shownMonth: number;\n readonly shownYear: number;\n readonly limits: CalendarLimits;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** The title's id, which names the months. */\n readonly labelId: string;\n readonly onYear: (year: number) => void;\n readonly onMonth: (month: number) => void;\n readonly onClose: () => void;\n}) {\n const monthsRef = useRef<HTMLDivElement>(null);\n const yearsRef = useRef<HTMLDivElement>(null);\n const [monthFocus, setMonthFocus] = useState(() =>\n year === shownYear\n ? shownMonth\n : (MONTHS.find(\n (month) => !isCalendarMonthDisabled(year, month, limits),\n ) ?? 1),\n );\n // The list stays around the year it opened on, so choosing a year never scrolls it away.\n const [listYear] = useState(year);\n const range = calendarYears(listYear, limits);\n const years = Array.from(\n { length: range.last - range.first + 1 },\n (_, index) => range.first + index,\n );\n\n // On opening, focus goes to the month shown, and the year list scrolls to its year.\n useLayoutEffect(() => {\n monthsRef.current\n ?.querySelector<HTMLElement>('[tabindex=\"0\"]')\n ?.focus({ preventScroll: true });\n const years = yearsRef.current;\n const chosen = years?.querySelector<HTMLElement>('[tabindex=\"0\"]');\n if (years !== null && chosen !== null && chosen !== undefined) {\n years.scrollTop =\n chosen.offsetTop - (years.clientHeight - chosen.offsetHeight) / 2;\n }\n }, []);\n\n function onKeyDown(event: KeyboardEvent<HTMLElement>) {\n if (event.key === \"Escape\") {\n event.preventDefault();\n onClose();\n }\n }\n\n function focusButton(container: HTMLElement | null, index: number) {\n container?.querySelectorAll<HTMLElement>(\"button\")[index]?.focus();\n }\n\n return (\n <div onKeyDown={onKeyDown}>\n <div\n ref={monthsRef}\n className=\"gridkit-forms-calendar-months\"\n role=\"group\"\n aria-labelledby={labelId}\n onKeyDown={(event) => {\n const next = nextIndex(event, monthFocus - 1, 12, {\n row: COLUMNS,\n column: 1,\n });\n if (next !== null) {\n event.preventDefault();\n setMonthFocus(next + 1);\n focusButton(monthsRef.current, next);\n }\n }}\n >\n {MONTHS.map((month) => {\n const current = month === shownMonth && year === shownYear;\n return (\n <button\n key={month}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-calendar-month\",\n current && \"is-selected\",\n )}\n tabIndex={month === monthFocus ? 0 : -1}\n aria-current={current || undefined}\n disabled={isCalendarMonthDisabled(year, month, limits)}\n onClick={() => {\n onMonth(month);\n }}\n >\n {formatMonthName(month, locale, \"long\")}\n </button>\n );\n })}\n </div>\n <div\n ref={yearsRef}\n className=\"gridkit-forms-calendar-years\"\n role=\"group\"\n aria-label={strings.calendarYears}\n onKeyDown={(event) => {\n const index = years.indexOf(year);\n const next = nextIndex(event, index, years.length, {\n row: 1,\n column: 0,\n });\n if (next !== null && next !== index) {\n event.preventDefault();\n const chosen = years[next];\n if (chosen !== undefined) {\n onYear(chosen);\n }\n focusButton(yearsRef.current, next);\n }\n }}\n >\n {years.map((listed) => (\n <button\n key={listed}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-calendar-year\",\n listed === year && \"is-selected\",\n )}\n tabIndex={listed === year ? 0 : -1}\n aria-pressed={listed === year}\n onClick={() => {\n onYear(listed);\n }}\n >\n {formatCalendarYear(listed, locale)}\n </button>\n ))}\n </div>\n </div>\n );\n}\n","import {\n calendarReducer,\n calendarStart,\n runtimeTimeZone,\n todayIn,\n type CalendarAction,\n type CalendarContext,\n type CalendarMonth,\n type CalendarMove,\n type CalendarState,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport {\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type KeyboardEvent,\n} from \"react\";\n\n/** The key's move in a calendar's grid, ArrowLeft and ArrowRight mirrored right to left; `null` for any other key. */\nexport function calendarKeyMove(\n event: KeyboardEvent,\n rtl: boolean,\n): CalendarMove | null {\n if (event.altKey || event.ctrlKey || event.metaKey) {\n return null;\n }\n switch (event.key) {\n case \"ArrowLeft\":\n return rtl ? \"nextDay\" : \"previousDay\";\n case \"ArrowRight\":\n return rtl ? \"previousDay\" : \"nextDay\";\n case \"ArrowUp\":\n return \"previousWeek\";\n case \"ArrowDown\":\n return \"nextWeek\";\n case \"Home\":\n return \"startOfWeek\";\n case \"End\":\n return \"endOfWeek\";\n case \"PageUp\":\n return event.shiftKey ? \"previousYear\" : \"previousMonth\";\n case \"PageDown\":\n return event.shiftKey ? \"nextYear\" : \"nextMonth\";\n default:\n return null;\n }\n}\n\n/** Whether `element` lays out right to left. */\nexport function isRightToLeft(element: Element): boolean {\n return getComputedStyle(element).direction === \"rtl\";\n}\n\nconst noSubscription = () => () => undefined;\n\n/**\n * Today in `timeZone`, or the runtime's zone; `null` on the server and\n * while hydrating, so the page the server sent never marks another day.\n */\nexport function useToday(timeZone: string | undefined): PlainDate | null {\n return useSyncExternalStore(\n noSubscription,\n () => todayIn(timeZone ?? runtimeTimeZone(), Date.now()),\n () => null,\n );\n}\n\n/** The selector of the grid cell holding `date` in its own month. */\nexport function dayCellSelector(date: PlainDate): string {\n return `[data-gridkit-forms-date=\"${date}\"]:not(.is-outside)`;\n}\n\n/** What `useCalendarNavigation` reads. */\nexport interface CalendarNavigationOptions {\n /** The day focus starts on: the value's, else today. */\n readonly focus: PlainDate;\n /** The app's first month shown; present means controlled. */\n readonly month?: CalendarMonth | undefined;\n readonly defaultMonth?: CalendarMonth | undefined;\n readonly onMonthChange?: ((month: CalendarMonth) => void) | undefined;\n readonly context: CalendarContext;\n}\n\n/** What `useCalendarNavigation` gives the calendar that calls it. */\nexport interface CalendarNavigation {\n readonly state: CalendarState;\n /** Applies `action`, telling `onMonthChange` when the first month shown changes, and returns the new state. */\n readonly dispatch: (action: CalendarAction) => CalendarState;\n /** Moves focus to the focused day once the calendar has drawn. */\n readonly focusDay: () => void;\n /** Whether the previous (`-1`) or next (`1`) month button would move the months shown, from `from` or now. */\n readonly canPage: (months: -1 | 1, from?: CalendarState) => boolean;\n /** Points at the calendar's root, which the focused day is looked for in; the same function on every render. */\n readonly setRoot: (root: HTMLElement | null) => void;\n}\n\nfunction sameState(a: CalendarState, b: CalendarState): boolean {\n return a.month === b.month && a.focused === b.focused && a.view === b.view;\n}\n\n/**\n * Holds where a calendar is (forms-core's `calendarReducer`): the months\n * shown, the focused day and the month view. A controlled `month` is\n * followed on every render, and the state is fitted to the latest limits\n * and number of months. `focusDay` asks for focus on the focused day after\n * the next draw, for a key or a click that moved it.\n */\nexport function useCalendarNavigation({\n focus,\n month,\n defaultMonth,\n onMonthChange,\n context,\n}: CalendarNavigationOptions): CalendarNavigation {\n const [stored, setStored] = useState(() =>\n calendarStart(focus, month ?? defaultMonth, context),\n );\n let state = stored;\n const fitted = calendarReducer(\n stored,\n { type: \"show\", month: month ?? stored.month },\n context,\n );\n if (!sameState(fitted, stored)) {\n state = fitted;\n setStored(fitted);\n }\n const latest = useRef(state);\n const root = useRef<HTMLElement | null>(null);\n const setRoot = useCallback((element: HTMLElement | null) => {\n root.current = element;\n }, []);\n const focusPending = useRef(false);\n useLayoutEffect(() => {\n latest.current = state;\n if (!focusPending.current) {\n return;\n }\n focusPending.current = false;\n root.current\n ?.querySelector<HTMLElement>(dayCellSelector(state.focused))\n ?.focus();\n });\n\n return {\n state,\n dispatch: (action) => {\n const current = latest.current;\n const next = calendarReducer(current, action, context);\n if (next === current) {\n return current;\n }\n latest.current = next;\n setStored(next);\n if (next.month !== current.month) {\n onMonthChange?.(next.month);\n }\n return next;\n },\n focusDay: () => {\n focusPending.current = true;\n },\n canPage: (months, from = state) =>\n calendarReducer(from, { type: \"page\", months }, context).month !==\n from.month,\n setRoot,\n };\n}\n","import type {\n FieldMessage,\n FormsMessages,\n Severity,\n} from \"@gridkitjs/forms-core\";\nimport {\n useCallback,\n useEffect,\n useState,\n type MouseEvent,\n type ReactNode,\n type Ref,\n type RefCallback,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport { Field } from \"../field/Field\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { FieldMessages } from \"../field/FieldMessages\";\nimport { classNames } from \"../field/parts\";\nimport { setRef } from \"../refs\";\nimport type { Density, FieldMode } from \"../settings\";\nimport type { TextControl } from \"@gridkitjs/forms-dom\";\n\nfunction Icon({ children }: { readonly children: ReactNode }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n {children}\n </svg>\n );\n}\n\nexport function ClearIcon() {\n return (\n <Icon>\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </Icon>\n );\n}\n\nexport function EyeIcon() {\n return (\n <Icon>\n <path d=\"M2.06 12.35a1 1 0 0 1 0-.7 10.75 10.75 0 0 1 19.88 0 1 1 0 0 1 0 .7 10.75 10.75 0 0 1-19.88 0\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </Icon>\n );\n}\n\nexport function SearchIcon() {\n return (\n <Icon>\n <circle cx=\"11\" cy=\"11\" r=\"8\" />\n <path d=\"m21 21-4.3-4.3\" />\n </Icon>\n );\n}\n\nexport function ClockIcon() {\n return (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 6v6l4 2\" />\n </Icon>\n );\n}\n\nexport function ChevronDownIcon() {\n return (\n <Icon>\n <path d=\"m6 9 6 6 6-6\" />\n </Icon>\n );\n}\n\nexport function CheckIcon() {\n return (\n <Icon>\n <path d=\"M20 6 9 17l-5-5\" />\n </Icon>\n );\n}\n\n/** A tick box's mixed state: some, not all, ticked. */\nexport function MixedIcon() {\n return (\n <Icon>\n <path d=\"M5 12h14\" />\n </Icon>\n );\n}\n\nexport function CalendarIcon() {\n return (\n <Icon>\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\" />\n <path d=\"M16 2v4\" />\n <path d=\"M8 2v4\" />\n <path d=\"M3 10h18\" />\n </Icon>\n );\n}\n\n/**\n * Keeps focus, and the selection, in the control when a button in its box\n * is pressed, by a mouse or, through the mouse events that follow a tap,\n * a finger. Not on `pointerdown`: WebKit fires no `click` after a touch\n * whose `pointerdown` was prevented.\n */\nexport function keepFocus(event: MouseEvent): void {\n event.preventDefault();\n}\n\n/** The density state class; none for `standard`. */\nexport function densityClass(density: Density): string | false {\n return density !== \"standard\" && `is-${density}`;\n}\n\n/** Joins the ids that are set into one `aria-describedby`, or `undefined` for none. */\nexport function joinIds(\n ...ids: (string | false | undefined)[]\n): string | undefined {\n const joined = ids.filter(Boolean).join(\" \");\n return joined === \"\" ? undefined : joined;\n}\n\n/**\n * The native control, in state for the input's own behaviours, and one\n * ref that also points the app's `ref` at it.\n */\nexport function useControlElement<E extends TextControl>(\n ref: Ref<E> | undefined,\n): readonly [E | null, RefCallback<E>] {\n const [element, setElement] = useState<E | null>(null);\n const merged = useCallback<RefCallback<E>>(\n (control) => {\n setElement(control);\n const release = setRef(ref, control);\n return () => {\n setElement(null);\n release?.();\n };\n },\n [ref],\n );\n return [element, merged];\n}\n\n/**\n * Outside a `Field`, an input given a `label` or a `description` draws a\n * `Field` around itself with them; otherwise it draws only itself.\n */\nexport function InputFrame({\n label,\n description,\n id,\n mode,\n density,\n readOnly,\n disabled,\n children,\n}: {\n readonly label: ReactNode;\n readonly description: ReactNode;\n readonly id: string | undefined;\n readonly mode: FieldMode | undefined;\n readonly density: Density | undefined;\n readonly readOnly: boolean | undefined;\n readonly disabled: boolean | undefined;\n readonly children: ReactNode;\n}) {\n const field = useFieldContext();\n const hasLabel = label !== undefined && label !== null;\n const hasDescription = description !== undefined && description !== null;\n if (field !== null || (!hasLabel && !hasDescription)) {\n return children;\n }\n return (\n <Field\n label={label}\n description={description}\n id={id}\n mode={mode}\n density={density}\n readOnly={readOnly}\n disabled={disabled}\n >\n {children}\n </Field>\n );\n}\n\n/**\n * A bare input's own message area, outside any `Field`; a `Field` lists\n * the messages itself, so inside one this draws nothing. Warns once in\n * development when the bare input has no name at all.\n */\nexport function OwnMessages({\n id,\n messages,\n strings,\n named,\n}: {\n readonly id: string;\n readonly messages: readonly FieldMessage[];\n readonly strings: FormsMessages;\n /** The control has an `aria-label` or an `aria-labelledby`. */\n readonly named: boolean;\n}) {\n const inField = useFieldContext() !== null;\n useEffect(() => {\n if (!inField && !named) {\n warnOnce(\n \"input-label\",\n \"An input outside a Field has no label, aria-label or aria-labelledby, so it has no name. Give it one of them (a placeholder is not a name).\",\n );\n }\n }, [inField, named]);\n return inField ? null : (\n <FieldMessages id={id} messages={messages} strings={strings} />\n );\n}\n\n/** The id of a bare input's own message area, when it has one. */\nexport function useOwnMessagesId(controlId: string): string | undefined {\n return useFieldContext() === null ? `${controlId}-messages` : undefined;\n}\n\n/**\n * The drawn box around a text control: its border, background and focus\n * ring, in the colour of the most serious message shown, with the\n * adornments, the clear button and the spinner inside it.\n */\nexport function ControlBox({\n className,\n boxRef,\n severity,\n disabled,\n readOnly,\n loading,\n density,\n start,\n prefix,\n prefixId,\n suffix,\n suffixId,\n clear,\n end,\n children,\n}: {\n /** More classes for the box, beside its own. */\n readonly className?: string | undefined;\n /** The box itself: what a picker popup opens beside. */\n readonly boxRef?: Ref<HTMLDivElement> | undefined;\n readonly severity: Severity | null;\n readonly disabled: boolean;\n readonly readOnly: boolean;\n readonly loading: boolean;\n readonly density: Density;\n /** Before the prefix: the search icon. */\n readonly start?: ReactNode;\n readonly prefix: ReactNode;\n readonly prefixId: string;\n readonly suffix: ReactNode;\n readonly suffixId: string;\n /** The clear button's name and action, while it shows. */\n readonly clear: {\n readonly label: string;\n readonly onClear: (event: MouseEvent) => void;\n } | null;\n /** After the spinner: the password's reveal button. */\n readonly end?: ReactNode;\n /** The native control. */\n readonly children: ReactNode;\n}) {\n return (\n <div\n ref={boxRef}\n className={classNames(\n \"gridkit-forms-control\",\n className,\n severity !== null && `is-${severity}`,\n disabled && \"is-disabled\",\n readOnly && \"is-readonly\",\n loading && \"is-loading\",\n densityClass(density),\n )}\n >\n {start}\n {hasNode(prefix) && (\n <span className=\"gridkit-forms-prefix\" id={prefixId}>\n {prefix}\n </span>\n )}\n {children}\n {clear !== null && (\n <button\n type=\"button\"\n className=\"gridkit-forms-clear-button\"\n tabIndex={-1}\n aria-label={clear.label}\n onMouseDown={keepFocus}\n onClick={clear.onClear}\n >\n <ClearIcon />\n </button>\n )}\n {loading && <span className=\"gridkit-forms-spinner\" aria-hidden=\"true\" />}\n {end}\n {hasNode(suffix) && (\n <span className=\"gridkit-forms-suffix\" id={suffixId}>\n {suffix}\n </span>\n )}\n </div>\n );\n}\n\nexport function hasNode(node: ReactNode): boolean {\n return node !== undefined && node !== null && node !== false && node !== \"\";\n}\n","// Bundlers replace `process.env.NODE_ENV` with a string; without one, as in\n// a browser loading the files unbundled, `process` does not exist.\ndeclare const process: { readonly env: { readonly NODE_ENV?: string } };\n\nfunction isDevelopment(): boolean {\n try {\n return process.env.NODE_ENV !== \"production\";\n } catch {\n return false;\n }\n}\n\nconst warned = new Set<string>();\n\n/** Warns once per page about `key`, in a development build only. */\nexport function warnOnce(key: string, message: string): void {\n if (warned.has(key) || !isDevelopment()) {\n return;\n }\n warned.add(key);\n console.warn(`@gridkitjs/forms: ${message}`);\n}\n","import { mostSevere, type FieldMessageInput } from \"@gridkitjs/forms-core\";\nimport {\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport { useSummaryEntry } from \"../form/formContext\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type FieldMode,\n type LabelPosition,\n type NecessityIndicator,\n} from \"../settings\";\nimport {\n FieldContext,\n useControlMessages,\n type FieldContextValue,\n type FieldControlState,\n} from \"./fieldContext\";\nimport { FieldHelp } from \"./FieldHelp\";\nimport { FieldMessages } from \"./FieldMessages\";\nimport {\n classNames,\n NecessityMarker,\n spanClass,\n useShownMessages,\n withLabelWidth,\n type FieldSpan,\n} from \"./parts\";\n\nexport interface FieldProps {\n /**\n * Names the input. Leave it out only when the input has an `aria-label`;\n * `labelPosition=\"hidden\"` keeps a label out of sight.\n */\n readonly label?: ReactNode;\n /** Help text under the control, read as part of its description. */\n readonly description?: ReactNode;\n /**\n * Longer help behind a button after the label, shown in a small panel\n * beside it and read out as it opens.\n */\n readonly help?: ReactNode;\n /** The app's messages, always shown; a string is an error. */\n readonly message?:\n FieldMessageInput | readonly FieldMessageInput[] | undefined;\n /** Marks the label, and tells the input a value is required. */\n readonly required?: boolean | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly necessityIndicator?: NecessityIndicator | undefined;\n readonly density?: Density | undefined;\n readonly mode?: FieldMode | undefined;\n readonly readOnly?: boolean | undefined;\n readonly disabled?: boolean | undefined;\n /** Columns taken in a `FormLayout`. */\n readonly span?: FieldSpan | undefined;\n /** The control's `id`; one is generated without it. */\n readonly id?: string | undefined;\n /** On the field's root. */\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n /** One input: a forms input, or the app's own through `useField`. */\n readonly children?: ReactNode;\n}\n\n/** Whether a floating label sits above the control rather than inside it. */\nfunction isRaised(state: FieldControlState | null, mode: FieldMode): boolean {\n if (mode === \"display\") {\n return true;\n }\n return (\n state !== null &&\n (state.focused || !state.empty || state.startAdornment === true)\n );\n}\n\n/**\n * One input with its label, required or optional marker, help button,\n * description and messages, wired to it for assistive technology: the label\n * names the control, the description and messages describe it, and\n * `aria-invalid` and `aria-required` follow the field. The input reads all of it from\n * context, so an app's own input gets the same through `useField`.\n *\n * The messages shown are the app's (`message`) and the input's own shown\n * ones, most serious first; the most serious sets the field's severity\n * class. A disabled field shows only the app's. Inside a `Form` they are\n * listed in its `MessageSummary`.\n */\nexport function Field({\n label,\n description,\n help,\n message,\n required = false,\n labelPosition,\n labelWidth,\n necessityIndicator,\n density,\n mode,\n readOnly,\n disabled,\n span,\n id,\n className,\n style,\n children,\n}: FieldProps) {\n const settings = useResolvedSettings({\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n });\n const generatedId = useId();\n const controlId = id ?? generatedId;\n const labelId = `${controlId}-label`;\n const descriptionId = `${controlId}-description`;\n const messagesId = `${controlId}-messages`;\n const hasLabel = label !== undefined && label !== null;\n const hasDescription = description !== undefined && description !== null;\n const hasHelp = help !== undefined && help !== null;\n\n const [controlMessages, setControlMessages] = useControlMessages();\n const [controlState, setControlState] = useState<FieldControlState | null>(\n null,\n );\n const shown = useShownMessages(controlMessages, message, settings.disabled);\n const severity = mostSevere(\n shown.map((shownMessage) => shownMessage.severity),\n );\n const describedBy = hasDescription\n ? `${descriptionId} ${messagesId}`\n : messagesId;\n\n const context = useMemo<FieldContextValue>(\n () => ({\n controlId,\n settings,\n describedBy,\n required,\n invalid: severity === \"error\",\n severity,\n setControlMessages,\n setControlState,\n }),\n [controlId, settings, describedBy, required, severity, setControlMessages],\n );\n\n // Marked when either the field or its input asks for a value.\n const marked = required || controlState?.required === true;\n const display = settings.mode === \"display\";\n const position =\n settings.labelPosition === \"floating\" && controlState?.labelBeside === true\n ? \"top\"\n : settings.labelPosition;\n const raised =\n position === \"floating\" && isRaised(controlState, settings.mode);\n\n const root = useRef<HTMLDivElement>(null);\n useSummaryEntry(controlId, hasLabel ? label : null, shown, root);\n useEffect(() => {\n if (hasLabel || display) {\n return;\n }\n const control = root.current?.ownerDocument.getElementById(controlId);\n if (\n control !== null &&\n control !== undefined &&\n !control.hasAttribute(\"aria-label\") &&\n !control.hasAttribute(\"aria-labelledby\") &&\n // A checkbox named by the label wrapped around it.\n !(\n control instanceof HTMLInputElement && (control.labels?.length ?? 0) > 0\n )\n ) {\n warnOnce(\n \"field-label\",\n 'A Field has no label and its input no aria-label, so the input has no name. Give the Field a label (labelPosition=\"hidden\" keeps it out of sight) or the input an aria-label.',\n );\n }\n }, [hasLabel, display, controlId]);\n\n const marker = (\n <NecessityMarker\n required={marked}\n indicator={settings.necessityIndicator}\n strings={settings.messages}\n />\n );\n const labelClass = classNames(\n \"gridkit-forms-field-label\",\n position === \"hidden\" && \"gridkit-forms-sr-only\",\n );\n // In display mode there is no control for a <label> to point at.\n const labelElement = !hasLabel ? null : display ? (\n <span className={labelClass} id={labelId}>\n {label}\n {marker}\n </span>\n ) : (\n <label className={labelClass} id={labelId} htmlFor={controlId}>\n {label}\n {marker}\n </label>\n );\n const labelInside = position === \"floating\" && !display;\n // The label and its help button on one line. A floating label stays in\n // the control, leaving the button alone on the row.\n const heading = hasHelp ? (\n <div className=\"gridkit-forms-field-label-row\">\n {!labelInside && labelElement}\n <FieldHelp\n id={`${controlId}-help`}\n label={settings.messages.fieldHelp}\n describedBy={hasLabel ? labelId : undefined}\n help={help}\n />\n </div>\n ) : (\n !labelInside && labelElement\n );\n\n return (\n <div\n ref={root}\n className={classNames(\n \"gridkit-forms-field\",\n `is-label-${position}`,\n raised && \"is-label-raised\",\n marked && \"is-required\",\n severity !== null && `is-${severity}`,\n settings.disabled && \"is-disabled\",\n settings.readOnly && \"is-readonly\",\n display && \"is-display\",\n settings.density !== \"standard\" && `is-${settings.density}`,\n spanClass(span),\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n role={display && hasLabel ? \"group\" : undefined}\n aria-labelledby={display && hasLabel ? labelId : undefined}\n aria-describedby={display ? describedBy : undefined}\n >\n {heading}\n <div className=\"gridkit-forms-field-control\">\n {labelInside && labelElement}\n <FormSettingsProvider settings={settings}>\n <FieldContext value={context}>{children}</FieldContext>\n </FormSettingsProvider>\n </div>\n {hasDescription && (\n <p className=\"gridkit-forms-field-description\" id={descriptionId}>\n {description}\n </p>\n )}\n <FieldMessages\n id={messagesId}\n messages={shown}\n strings={settings.messages}\n />\n </div>\n );\n}\n","import {\n createFieldRegistry,\n type FieldMessage,\n type FieldRegistry,\n type RegisteredField,\n} from \"@gridkitjs/forms-core\";\nimport { compareDocumentOrder } from \"@gridkitjs/forms-dom\";\nimport {\n createContext,\n useContext,\n useLayoutEffect,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\n\n/** A field as a `MessageSummary` lists it. */\nexport interface SummaryField extends RegisteredField {\n /** What the summary names the field by; `null` lists its messages alone. */\n readonly label: ReactNode;\n /** The field's root, which places it in document order. */\n readonly element: HTMLElement;\n}\n\n/** A collapsible `FormSection`, which opens before focus moves inside it. */\nexport interface CollapsibleSection {\n readonly element: HTMLElement;\n readonly expand: () => void;\n}\n\n/** What a `Form` shares with the fields, sections and summary inside it. */\nexport interface FormContextValue {\n readonly registry: FieldRegistry<SummaryField>;\n /** Adds a collapsible section, and returns what removes it. */\n readonly addSection: (section: CollapsibleSection) => () => void;\n /**\n * Sets the form's `MessageSummary` element while it shows, which a\n * refused submit focuses, and returns what unsets it.\n */\n readonly setSummary: (element: HTMLElement) => () => void;\n readonly getSummary: () => HTMLElement | null;\n /** Opens every collapsed section around `control`, then focuses it. */\n readonly focusControl: (control: HTMLElement) => void;\n}\n\n/** The context of one `Form`, made once when it mounts. */\nexport function createFormContext(): FormContextValue {\n const sections = new Set<CollapsibleSection>();\n let summary: HTMLElement | null = null;\n return {\n registry: createFieldRegistry<SummaryField>((a, b) =>\n compareDocumentOrder(a.element, b.element),\n ),\n addSection(section) {\n sections.add(section);\n return () => {\n sections.delete(section);\n };\n },\n setSummary(element) {\n summary = element;\n return () => {\n if (summary === element) {\n summary = null;\n }\n };\n },\n getSummary: () => summary,\n focusControl(control) {\n // A control in a collapsed section is hidden and takes no focus\n // until the section has opened, so the opening renders first.\n flushSync(() => {\n for (const section of sections) {\n if (section.element.contains(control)) {\n section.expand();\n }\n }\n });\n control.focus();\n },\n };\n}\n\nexport const FormContext = createContext<FormContextValue | null>(null);\n\n/** The `Form` around the caller, or `null` outside one. */\nexport function useFormContext(): FormContextValue | null {\n return useContext(FormContext);\n}\n\n/**\n * Lists a field's shown `messages` in its form's summary, under `id` (the\n * element a summary link points at) and `label`, while it has any.\n */\nexport function useSummaryEntry(\n id: string,\n label: ReactNode,\n messages: readonly FieldMessage[],\n root: RefObject<HTMLElement | null>,\n): void {\n const form = useFormContext();\n useLayoutEffect(() => {\n const element = root.current;\n if (form === null || element === null || messages.length === 0) {\n return undefined;\n }\n return form.registry.register({ id, label, messages, element });\n }, [form, id, label, messages, root]);\n}\n","import {\n defaultFormsMessages,\n resolveFormsMessages,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport { createContext, useContext, useMemo, type ReactNode } from \"react\";\n\n/** How tightly fields are drawn. */\nexport type Density = \"compact\" | \"standard\" | \"comfortable\";\n\n/** `\"display\"` shows a field's value as text, with no control to operate. */\nexport type FieldMode = \"edit\" | \"display\";\n\n/**\n * Where a field's label sits: above the control (`\"top\"`), inside it until\n * the field is focused or filled (`\"floating\"`), beside it (`\"start\"`), or\n * nowhere visible while still naming the control (`\"hidden\"`).\n */\nexport type LabelPosition = \"top\" | \"floating\" | \"start\" | \"hidden\";\n\n/**\n * Which fields a label marks: required ones with an asterisk\n * (`\"required\"`), the others with \"(optional)\" (`\"optional\"`), or none.\n */\nexport type NecessityIndicator = \"required\" | \"optional\" | \"none\";\n\n/** What every field under a level of a form shares, worked out for that level. */\nexport interface FormSettings {\n readonly mode: FieldMode;\n readonly density: Density;\n readonly labelPosition: LabelPosition;\n readonly necessityIndicator: NecessityIndicator;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n readonly locale: Intl.LocalesArgument;\n /** The app's strings, laid over the defaults; `undefined` for none. */\n readonly messageOverrides: Partial<FormsMessages> | undefined;\n /** Every string, the overrides laid over the defaults for `locale`. */\n readonly messages: FormsMessages;\n}\n\n/** What one level (a form, a section, a field) sets; `undefined` takes the level above's. */\nexport interface FormSettingsOverrides {\n readonly mode?: FieldMode | undefined;\n readonly density?: Density | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n readonly necessityIndicator?: NecessityIndicator | undefined;\n readonly readOnly?: boolean | undefined;\n readonly disabled?: boolean | undefined;\n readonly locale?: Intl.LocalesArgument;\n readonly messages?: Partial<FormsMessages> | undefined;\n}\n\nconst DEFAULT_SETTINGS: FormSettings = {\n mode: \"edit\",\n density: \"standard\",\n labelPosition: \"top\",\n necessityIndicator: \"required\",\n readOnly: false,\n disabled: false,\n locale: undefined,\n messageOverrides: undefined,\n messages: defaultFormsMessages,\n};\n\nconst FormSettingsContext = createContext<FormSettings>(DEFAULT_SETTINGS);\n\n/** The settings of the nearest level above, or the defaults outside any. */\nexport function useFormSettings(): FormSettings {\n return useContext(FormSettingsContext);\n}\n\n/**\n * `overrides` laid over `parent`: the nearest level wins, except that\n * `readOnly` and `disabled` set anywhere above stay set.\n */\nexport function resolveFormSettings(\n parent: FormSettings,\n overrides: FormSettingsOverrides,\n): FormSettings {\n const locale = overrides.locale ?? parent.locale;\n const messageOverrides =\n overrides.messages === undefined\n ? parent.messageOverrides\n : { ...parent.messageOverrides, ...overrides.messages };\n return {\n mode: overrides.mode ?? parent.mode,\n density: overrides.density ?? parent.density,\n labelPosition: overrides.labelPosition ?? parent.labelPosition,\n necessityIndicator:\n overrides.necessityIndicator ?? parent.necessityIndicator,\n readOnly: parent.readOnly || overrides.readOnly === true,\n disabled: parent.disabled || overrides.disabled === true,\n locale,\n messageOverrides,\n messages:\n locale === parent.locale && messageOverrides === parent.messageOverrides\n ? parent.messages\n : resolveFormsMessages(messageOverrides, locale),\n };\n}\n\n/**\n * The settings of the level above with `overrides` laid over them,\n * memoized on each override, so a level re-rendering with the same props\n * re-renders none of its fields.\n */\nexport function useResolvedSettings(\n overrides: FormSettingsOverrides,\n): FormSettings {\n const parent = useFormSettings();\n const {\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n locale,\n messages,\n } = overrides;\n return useMemo(\n () =>\n resolveFormSettings(parent, {\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n locale,\n messages,\n }),\n [\n parent,\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n locale,\n messages,\n ],\n );\n}\n\n/** Gives every field under it `settings`. */\nexport function FormSettingsProvider({\n settings,\n children,\n}: {\n readonly settings: FormSettings;\n readonly children: ReactNode;\n}) {\n return <FormSettingsContext value={settings}>{children}</FormSettingsContext>;\n}\n","import { attachOverlay, writingDirection } from \"@gridkitjs/forms-dom\";\nimport { useLayoutEffect, useReducer, useState, type ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { colorSchemeOf, type PickerScope } from \"../picker/usePickerPopup\";\nimport { classNames } from \"./parts\";\n\n/**\n * Where a field's help is: `closed`; `opening`, its panel drawn with the\n * live region in it still empty; `open`, the text in that region. The text\n * goes in a frame after the region appears, because a screen reader reads\n * what changes in a live region, not what it held as it appeared.\n */\ntype HelpState =\n | { readonly kind: \"closed\" }\n | { readonly kind: \"opening\"; readonly scope: PickerScope }\n | { readonly kind: \"open\"; readonly scope: PickerScope };\n\ntype HelpAction =\n | { readonly type: \"open\"; readonly scope: PickerScope }\n | { readonly type: \"fill\" }\n | { readonly type: \"close\" };\n\nconst CLOSED: HelpState = { kind: \"closed\" };\n\nfunction helpReducer(state: HelpState, action: HelpAction): HelpState {\n switch (action.type) {\n case \"open\":\n return state.kind === \"closed\"\n ? { kind: \"opening\", scope: action.scope }\n : state;\n case \"fill\":\n return state.kind === \"opening\"\n ? { kind: \"open\", scope: state.scope }\n : state;\n case \"close\":\n return CLOSED;\n }\n}\n\n/** The space between the button and the panel, for its shadow. */\nconst ANCHOR_GAP = 4;\n\nfunction HelpIcon() {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3\" />\n <path d=\"M12 17h.01\" />\n </svg>\n );\n}\n\n/**\n * A field's help toggletip: a button after the label, outside the\n * `<label>` so it never joins the control's name, that shows `help` in a\n * small panel beside it. The panel is portalled into `document.body`, so\n * no scrolling ancestor clips it, in the button's colour scheme and `dir`,\n * and its text sits in a `role=\"status\"` region, read out as it opens\n * while focus stays on the button. Pressing the button again, Escape, a\n * press outside or focus leaving closes it, through forms-dom's\n * `attachOverlay`.\n */\nexport function FieldHelp({\n id,\n label,\n describedBy,\n help,\n}: {\n /** The panel's id. */\n readonly id: string;\n /** The button's accessible name. */\n readonly label: string;\n /** The field label's id, read after the button's name. */\n readonly describedBy: string | undefined;\n readonly help: ReactNode;\n}) {\n const [state, dispatch] = useReducer(helpReducer, CLOSED);\n const [button, setButton] = useState<HTMLButtonElement | null>(null);\n const [panel, setPanel] = useState<HTMLElement | null>(null);\n\n useLayoutEffect(() => {\n if (button === null || panel === null) {\n return undefined;\n }\n const frame = requestAnimationFrame(() => {\n dispatch({ type: \"fill\" });\n });\n const detach = attachOverlay(button, panel, {\n placement: \"bottom-start\",\n gap: ANCHOR_GAP,\n initialFocus: \"none\",\n // Focus never enters the panel, so it has nothing to give back, and\n // closing as focus leaves the button must not pull it back there.\n returnFocusTo: null,\n onDismiss: () => {\n dispatch({ type: \"close\" });\n },\n });\n return () => {\n cancelAnimationFrame(frame);\n detach();\n };\n }, [button, panel]);\n\n const opened = state.kind !== \"closed\";\n return (\n <>\n <button\n ref={setButton}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-field-help-button\",\n opened && \"is-open\",\n )}\n aria-label={label}\n aria-describedby={describedBy}\n aria-expanded={opened}\n aria-controls={opened ? id : undefined}\n onClick={(event) => {\n const target = event.currentTarget;\n dispatch(\n opened\n ? { type: \"close\" }\n : {\n type: \"open\",\n scope: {\n scheme: colorSchemeOf(target),\n direction: writingDirection(target),\n },\n },\n );\n }}\n // The overlay watches focus leaving its panel, which focus never\n // enters here, so focus moving on from the button closes it. Focus\n // going nowhere, as a press on the panel's text sends it, does not.\n onBlur={(event) => {\n const next = event.relatedTarget;\n if (opened && next !== null && panel?.contains(next) !== true) {\n dispatch({ type: \"close\" });\n }\n }}\n >\n <HelpIcon />\n </button>\n {opened &&\n createPortal(\n <div\n ref={setPanel}\n id={id}\n className={classNames(\n \"gridkit-forms-field-help\",\n state.scope.scheme !== null && `is-${state.scope.scheme}`,\n )}\n dir={state.scope.direction}\n role=\"status\"\n >\n {state.kind === \"open\" ? help : null}\n </div>,\n document.body,\n )}\n </>\n );\n}\n","import {\n POPUP_CLOSED,\n popupReducer,\n type PopupAction,\n type PopupCloseReason,\n type PopupOpenChange,\n type PopupOpenReason,\n type PopupState,\n type WritingDirection,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachOverlay,\n writingDirection,\n type OverlayDismissReason,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n type RefCallback,\n} from \"react\";\n\n/**\n * What a popup portalled out of its field copies from it, read as it\n * opens: the field's colour scheme where a palette pins one (the theme\n * pins the popup to it with `is-light` or `is-dark`), else `null` to\n * follow the page, and the writing direction, which lays out its content\n * and places it.\n */\nexport interface PickerScope {\n readonly scheme: \"light\" | \"dark\" | null;\n readonly direction: WritingDirection;\n}\n\n/** A list is never narrower than its field, whose options it offers. */\nfunction matchAnchorWidth(panel: HTMLElement, anchor: HTMLElement): void {\n panel.style.minWidth = `${String(anchor.getBoundingClientRect().width)}px`;\n}\n\n/**\n * How a popup takes focus: a dialog moves it in and keeps it there with\n * Tab; a list (a choice input's options) leaves it in the field, as the\n * WAI-ARIA combobox does, and its field points into it with\n * `aria-activedescendant`.\n */\nexport type PickerPopupMode = \"dialog\" | \"list\";\n\n/** What `usePickerPopup` reads, on every render. */\nexport interface PickerPopupOptions {\n /** `\"dialog\"` by default. */\n readonly mode?: PickerPopupMode | undefined;\n /** Whether the field can show its popup now: drawn, enabled and not read-only. */\n readonly enabled: boolean;\n /** The popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n /**\n * A dialog's element in the field focus goes back to as the popup closes\n * when focus was not on a control in `anchor` as it opened: the first\n * segment. Focus never leaves the field for a list.\n */\n readonly returnFocusTo?:\n ((anchor: HTMLElement) => HTMLElement | null) | undefined;\n /** Where focus goes in a dialog as it opens: its chosen day; its first control by default. */\n readonly initialFocus?:\n ((panel: HTMLElement) => HTMLElement | null) | undefined;\n}\n\n/** What `usePickerPopup` gives the field that calls it. */\nexport interface PickerPopup {\n readonly state: PopupState;\n /** Read as the popup opened; `null` while it is closed. */\n readonly scope: PickerScope | null;\n readonly open: (reason: PopupOpenReason) => void;\n /**\n * Closes it, handing focus back to the field unless it left for\n * somewhere else: to `returnTo` when given (the picker button, for Tab\n * out of the popup), else to where it was as the popup opened.\n */\n readonly close: (reason: PopupCloseReason, returnTo?: HTMLElement) => void;\n /** Its button: opens it, or closes it. */\n readonly toggle: () => void;\n /** Whether `node` is in the popup, which the field's focus group counts as inside the field. */\n readonly isInside: (node: Node) => boolean;\n /**\n * What Escape in the popup does before it closes it: a handler that\n * returns `true` has dealt with the key (a calendar's month view going\n * back to the days), and the popup stays open. `null` removes it.\n */\n readonly setEscapeHandler: (handler: (() => boolean) | null) => void;\n /** The element the popup opens beside: the field's box. */\n readonly setAnchor: RefCallback<HTMLElement>;\n /** The popup's panel, drawn while it is open. */\n readonly setPanel: RefCallback<HTMLElement>;\n}\n\n/** The space between the field's box and the popup, for its shadow. */\nconst ANCHOR_GAP = 4;\n\n/** The colour scheme `element` is drawn in, when it is exactly one. */\nexport function colorSchemeOf(element: Element): PickerScope[\"scheme\"] {\n const { colorScheme } = getComputedStyle(element);\n return colorScheme === \"light\" || colorScheme === \"dark\" ? colorScheme : null;\n}\n\n/**\n * A field's picker popup: whether it is open (forms-core's\n * `popupReducer`, telling `onOpenChange` each change once), and, while its\n * panel is drawn, forms-dom's `attachOverlay` on it, below the field's box:\n * in `\"dialog\"` mode with focus moved in and kept there by Tab, in\n * `\"list\"` mode with focus left in the field and nothing to return.\n *\n * Closing detaches the overlay at once, so after a press outside focus\n * goes back to the field before the browser moves it for the press, and\n * the field then blurs as it would without a popup. Focus leaving the\n * popup for somewhere else (`\"blur\"`) closes it without taking focus\n * back. A field that stops being `enabled` closes it with `\"disabled\"`.\n */\nexport function usePickerPopup(options: PickerPopupOptions): PickerPopup {\n const [state, setState] = useState<PopupState>(POPUP_CLOSED);\n const [scope, setScope] = useState<PickerScope | null>(null);\n const [anchor, setAnchor] = useState<HTMLElement | null>(null);\n const [panel, setPanel] = useState<HTMLElement | null>(null);\n const latestState = useRef(state);\n const latestOptions = useRef(options);\n const panelRef = useRef<HTMLElement | null>(null);\n const escapeHandler = useRef<(() => boolean) | null>(null);\n const returnTarget = useRef<HTMLElement | null>(null);\n const closing = useRef<PopupCloseReason | null>(null);\n const detachOverlay = useRef<(() => void) | null>(null);\n useLayoutEffect(() => {\n latestOptions.current = options;\n panelRef.current = panel;\n });\n\n const dispatch = useCallback((action: PopupAction): void => {\n const step = popupReducer(latestState.current, action);\n if (step.change === null) {\n return;\n }\n latestState.current = step.state;\n setState(step.state);\n if (!step.change.open) {\n closing.current = step.change.reason;\n // Detached now rather than once the panel leaves the page, so focus\n // is back in the field before the press that closed it moves it on.\n detachOverlay.current?.();\n detachOverlay.current = null;\n setScope(null);\n }\n latestOptions.current.onOpenChange?.(step.change);\n }, []);\n\n const open = useCallback(\n (reason: PopupOpenReason): void => {\n if (\n anchor === null ||\n !latestOptions.current.enabled ||\n latestState.current.kind === \"open\"\n ) {\n return;\n }\n const active = anchor.ownerDocument.activeElement;\n returnTarget.current =\n active instanceof HTMLElement &&\n anchor.contains(active) &&\n active.matches(\"input\")\n ? active\n : (latestOptions.current.returnFocusTo?.(anchor) ?? null);\n closing.current = null;\n setScope({\n scheme: colorSchemeOf(anchor),\n direction: writingDirection(anchor),\n });\n dispatch({ type: \"open\", reason });\n },\n [anchor, dispatch],\n );\n\n const close = useCallback(\n (reason: PopupCloseReason, returnTo?: HTMLElement): void => {\n if (returnTo !== undefined && latestState.current.kind === \"open\") {\n returnTarget.current = returnTo;\n }\n dispatch({ type: \"close\", reason });\n },\n [dispatch],\n );\n\n const toggle = useCallback((): void => {\n if (latestState.current.kind === \"open\") {\n close(\"button\");\n } else {\n open(\"button\");\n }\n }, [open, close]);\n\n const isOpen = state.kind === \"open\";\n const { enabled } = options;\n useLayoutEffect(() => {\n if (!enabled && isOpen) {\n close(\"disabled\");\n }\n }, [enabled, isOpen, close]);\n\n useLayoutEffect(() => {\n if (anchor === null || panel === null) {\n return undefined;\n }\n const onDismiss = (reason: OverlayDismissReason): void => {\n if (reason === \"escape\" && escapeHandler.current?.() === true) {\n return;\n }\n close(reason);\n };\n const list = latestOptions.current.mode === \"list\";\n if (list) {\n matchAnchorWidth(panel, anchor);\n }\n const detach = attachOverlay(anchor, panel, {\n placement: \"bottom-start\",\n gap: ANCHOR_GAP,\n trapFocus: !list,\n initialFocus: list\n ? \"none\"\n : (latestOptions.current.initialFocus?.(panel) ?? \"first\"),\n returnFocusTo: null,\n // Focus moving out of the panel has gone somewhere, and stays there;\n // the window losing focus leaves it in the panel, to come back to the\n // field. A list never had focus to give back.\n returnFocusFallback: () =>\n list ||\n (closing.current === \"blur\" &&\n !panel.contains(panel.ownerDocument.activeElement))\n ? null\n : returnTarget.current,\n onDismiss,\n });\n detachOverlay.current = detach;\n return () => {\n detach();\n if (detachOverlay.current === detach) {\n detachOverlay.current = null;\n }\n };\n }, [anchor, panel, close]);\n\n return {\n state,\n scope,\n open,\n close,\n toggle,\n isInside: useCallback(\n (node: Node) => panelRef.current?.contains(node) === true,\n [],\n ),\n setEscapeHandler: useCallback((handler: (() => boolean) | null) => {\n escapeHandler.current = handler;\n }, []),\n setAnchor,\n setPanel,\n };\n}\n","import type {\n FieldMessage,\n FormsMessages,\n Severity,\n} from \"@gridkitjs/forms-core\";\nimport type { ReactNode } from \"react\";\n\nfunction Icon({ children }: { readonly children: ReactNode }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n {children}\n </svg>\n );\n}\n\n/**\n * A different shape for each severity, so it never rests on colour alone:\n * a cross, an exclamation mark in a triangle, an \"i\" and a tick.\n */\nexport function SeverityIcon({ severity }: { readonly severity: Severity }) {\n switch (severity) {\n case \"error\":\n return (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"m15 9-6 6\" />\n <path d=\"m9 9 6 6\" />\n </Icon>\n );\n case \"warning\":\n return (\n <Icon>\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n </Icon>\n );\n case \"info\":\n return (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n </Icon>\n );\n case \"success\":\n return (\n <Icon>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"m9 12 2 2 4-4\" />\n </Icon>\n );\n }\n}\n\n/**\n * A field's message area: always in the page, empty when there is nothing\n * to say, and a polite live region, so a message that appears as the user\n * leaves the field is read without moving focus. Each message is read\n * after its severity's name, which is visually hidden; the icon says it to\n * the eye.\n */\nexport function FieldMessages({\n id,\n messages,\n strings,\n}: {\n readonly id: string;\n readonly messages: readonly FieldMessage[];\n readonly strings: FormsMessages;\n}) {\n return (\n <div className=\"gridkit-forms-field-messages\" id={id} aria-live=\"polite\">\n {messages.map((message, index) => (\n <p\n // Messages carry no id, and two may share a text.\n key={`${String(index)}:${message.text}`}\n className={`gridkit-forms-message is-${message.severity}`}\n >\n <span className=\"gridkit-forms-message-icon\" aria-hidden=\"true\">\n <SeverityIcon severity={message.severity} />\n </span>\n <span className=\"gridkit-forms-sr-only\">\n {`${strings.severityLabel(message.severity)}: `}\n </span>\n <span className=\"gridkit-forms-message-text\">{message.text}</span>\n </p>\n ))}\n </div>\n );\n}\n","import type { Ref } from \"react\";\n\n/** Points `ref` at `element`, and returns what lets go of it again. */\nexport function setRef<T>(\n ref: Ref<T> | undefined,\n element: T,\n): (() => void) | null {\n if (typeof ref === \"function\") {\n const cleanup = ref(element);\n return typeof cleanup === \"function\"\n ? cleanup\n : () => {\n ref(null);\n };\n }\n if (ref === undefined || ref === null) {\n return null;\n }\n ref.current = element;\n return () => {\n ref.current = null;\n };\n}\n","import {\n createFieldController,\n hasError,\n mostSevere,\n resolveFormsMessages,\n sortFieldMessages,\n toFieldMessages,\n type FieldController,\n type FieldMessage,\n type FieldMessageInput,\n type FieldOptions,\n type ChangeCause,\n type FieldPhase,\n type FieldState,\n type FormatContext,\n type InputFilter,\n type Formatter,\n type FormsMessages,\n type NoDetails,\n type ParseContext,\n type ParseResult,\n type Parser,\n type Severity,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachTextInput,\n attachToggle,\n scheduleTimeout,\n type AttachedTextInput,\n type AttachedToggle,\n type TextControl,\n type TextInputOptions,\n type ToggleOptions,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactElement,\n type Ref,\n type RefCallback,\n} from \"react\";\nimport { DisplayValue } from \"./DisplayValue\";\nimport type { FieldClearEvent, FieldHandlers } from \"./events\";\nimport {\n useFieldContext,\n type FieldContextValue,\n type FieldControlState,\n} from \"./field/fieldContext\";\nimport { useFormContext, type FormContextValue } from \"./form/formContext\";\nimport { setRef } from \"./refs\";\nimport { useFormSettings, type FieldMode } from \"./settings\";\n\n/** What an input does from code: focus it, read it, change it. */\nexport interface InputHandle<V> {\n /** The focusable element, while it is in the page. */\n readonly element: HTMLElement | null;\n focus(options?: FocusOptions): void;\n blur(): void;\n getValue(): V | null;\n getText(): string;\n /** `onBeforeChange`, `onChange` and `onValidate`, with `source: \"api\"`; no commit. */\n setValue(value: V | null): void;\n /** Back to `defaultValue`, or `null`, as `setValue` changes it. */\n reset(): void;\n /** Shows the field's messages from now on, as a commit attempt would. */\n revealMessages(): void;\n}\n\n/** How an input reads, writes and submits its value. */\nexport interface FieldInputKind<V, D extends object = NoDetails> {\n /** The input's own reading of text, which a `parse` prop can wrap. */\n readonly defaultParse: (\n text: string,\n context: ParseContext<V>,\n ) => ParseResult<V>;\n /** The input's own writing of the value, which a `format` prop can wrap. */\n readonly defaultFormat: (\n value: V | null,\n context: FormatContext<V>,\n ) => string;\n /**\n * The value as its hidden input submits it, the same in every locale.\n * Never called with `null`, which submits `\"\"`.\n */\n readonly serialize: (value: V) => string;\n /** Whether two values are one; `Object.is` by default. Never called with `null`. */\n readonly equals?: ((a: V, b: V) => boolean) | undefined;\n /** The input's own details, added to every event it fires. */\n readonly details?:\n ((current: FieldState<V>, previous: FieldState<V>) => D) | undefined;\n /**\n * The input's own judgement of each edit the app's `onBeforeInput` lets\n * through: a number input refusing letters and typing its decimals.\n */\n readonly filterInput?: InputFilter<Event> | undefined;\n}\n\n/** The props `useFieldInput` reads; an input passes on its own. */\nexport interface FieldInputProps<\n V,\n E extends TextControl = HTMLInputElement,\n D extends object = NoDetails,\n> extends FieldHandlers<V, D> {\n /** Present, `null` included, means controlled. */\n readonly value?: V | null | undefined;\n /** The value of an uncontrolled field at first, and what `reset` returns to. */\n readonly defaultValue?: V | null | undefined;\n /** The app's reading of typed text; `context.defaultParse` is the input's own. */\n readonly parse?: Parser<V> | undefined;\n /** The app's writing of the value; `context.defaultFormat` is the input's own. */\n readonly format?: Formatter<V> | undefined;\n readonly validate?: Validator<V> | readonly Validator<V>[] | undefined;\n /**\n * The control needs a value: it sets `aria-required` and marks the label\n * of the `Field` around it. The input adds the check to `validate`.\n */\n readonly required?: boolean | undefined;\n /** The app's messages, always shown with the field's own; a string is an error. */\n readonly message?:\n FieldMessageInput | readonly FieldMessageInput[] | undefined;\n /** Shows the error state with no message, for a form library that shows its errors elsewhere. */\n readonly invalid?: boolean | undefined;\n /** Called first when the field is cleared, before its change and commit. */\n readonly onClear?: ((event: FieldClearEvent<V>) => void) | undefined;\n /** Submits the value under this name, through a hidden input. */\n readonly name?: string | undefined;\n /** The `id` of a `<form>` elsewhere in the page that the value belongs to. */\n readonly form?: string | undefined;\n readonly readOnly?: boolean | undefined;\n /** Disabled, and not submitted. */\n readonly disabled?: boolean | undefined;\n /** `\"display\"` shows the value as text; the `Field` or form around it sets it otherwise. */\n readonly mode?: FieldMode | undefined;\n /** The control's `id` outside a `Field`; inside one, the field's is used. */\n readonly id?: string | undefined;\n readonly locale?: Intl.LocalesArgument;\n /** Strings laid over the default English ones. */\n readonly messages?: Partial<FormsMessages> | undefined;\n /** The native control. */\n readonly ref?: Ref<E> | undefined;\n readonly handleRef?: Ref<InputHandle<V>> | undefined;\n}\n\n/** How the input that calls `useFieldInput` behaves, which its own props decide. */\nexport interface FieldInputOptions extends TextInputOptions {\n /**\n * Something sits at the control's start (a prefix, an icon), where a\n * resting floating label would cover it, so the label stays raised.\n */\n readonly startAdornment?: boolean | undefined;\n /**\n * Milliseconds typing must pause before the text is read (`onChange`),\n * for a search box; `onInput` fires at once and a commit reads at once.\n */\n readonly changeDelay?: number | undefined;\n /**\n * The control is a checkbox, flipped whole, rather than text: forms-dom's\n * toggle behaviour drives it, every flip commits, leaving commits nothing\n * more, and its label sits beside it, so a `Field`'s floating label stays\n * above. `readOnly` is passed on by the hook.\n */\n readonly toggle?: Omit<ToggleOptions, \"readOnly\"> | undefined;\n}\n\n/** The props `useFieldInput` gives the native control. */\nexport interface FieldControlBinding<E extends TextControl> {\n readonly ref: RefCallback<E>;\n readonly id: string;\n /**\n * The text on screen, for a text control. The control's live text is\n * forms-dom's, so it is never a controlled `value`.\n */\n readonly defaultValue: string | undefined;\n /** Whether a toggle is checked when it is first drawn; forms-dom keeps it after. */\n readonly defaultChecked: boolean | undefined;\n /** A text control's native `readOnly`; a toggle, which ignores it, has `aria-readonly`. */\n readonly readOnly: boolean | undefined;\n readonly \"aria-readonly\": true | undefined;\n readonly disabled: boolean | undefined;\n readonly \"aria-invalid\": true | undefined;\n /** The description and messages of the `Field` around it. */\n readonly \"aria-describedby\": string | undefined;\n readonly \"aria-required\": true | undefined;\n}\n\n/** What `useFieldInput` gives the input that calls it, to draw. */\nexport interface FieldInput<V, E extends TextControl = HTMLInputElement> {\n readonly state: FieldState<V>;\n /** The text on screen. */\n readonly text: string;\n /**\n * The messages to show: the app's `message`, and the field's own from\n * the first commit attempt or `revealMessages` on, except while\n * disabled. A `Field` around the input lists them itself.\n */\n readonly messages: readonly FieldMessage[];\n /**\n * The most serious message shown, under the input or anywhere in the\n * `Field` around it, or `\"error\"` for `invalid`: the control box's\n * border colour.\n */\n readonly severity: Severity | null;\n /** Fires `onClear`, then empties the field and commits it (`source` and `trigger` `\"clear\"`). */\n readonly clear: (nativeEvent: Event | null) => void;\n /** The value now, read at the moment of the call rather than at render. */\n readonly getValue: () => V | null;\n /**\n * The change chain to `value`, with `cause`'s source and native event,\n * and no commit: a step, a part of a composite input.\n */\n readonly change: (value: V | null, cause: ChangeCause<Event>) => void;\n /** The props', the `Field`'s or the form's. */\n readonly mode: FieldMode;\n /** The value as text, to draw in place of the control in display mode. */\n readonly displayValue: ReactElement;\n /** Spread onto the native control. */\n readonly controlProps: FieldControlBinding<E>;\n /** The hidden input carrying `name`, to draw beside the control; `null` without one. */\n readonly hiddenInput: ReactElement | null;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/** Whether the control has focus, from where the field is in an edit. */\nexport function isFocused(phase: FieldPhase<unknown>): boolean {\n switch (phase.kind) {\n case \"editing\":\n case \"leaving\":\n return true;\n case \"checking\":\n return !phase.leaving;\n default:\n return false;\n }\n}\n\n/** The forms-dom behaviour driving the control. */\ntype AttachedBehaviour =\n | { readonly kind: \"text\"; readonly handle: AttachedTextInput }\n | { readonly kind: \"toggle\"; readonly handle: AttachedToggle };\n\nfunction attachBehaviour<V, D extends object>(\n control: TextControl,\n controller: FieldController<V, D, Event>,\n toggle: boolean,\n): AttachedBehaviour {\n if (!toggle) {\n return { kind: \"text\", handle: attachTextInput(control, controller) };\n }\n if (!(control instanceof HTMLInputElement)) {\n throw new TypeError(\"A toggle's control must be an <input>.\");\n }\n // A toggle input's value is always a boolean: `Checkbox` and `Switch`\n // are its only callers, and each is typed so.\n const toggleController = controller as unknown as FieldController<\n boolean,\n D,\n Event\n >;\n return { kind: \"toggle\", handle: attachToggle(control, toggleController) };\n}\n\n/** `validate` as a list. */\nexport function validatorsOf<V>(\n validate: Validator<V> | readonly Validator<V>[] | undefined,\n): readonly Validator<V>[] {\n if (validate === undefined) {\n return [];\n }\n return typeof validate === \"function\" ? [validate] : validate;\n}\n\n/** The settings an input takes from its own props, its `Field` and its form. */\nexport function useInputSettings(\n props: Pick<\n FieldInputProps<unknown>,\n \"readOnly\" | \"disabled\" | \"mode\" | \"locale\" | \"messages\"\n >,\n) {\n const field = useFieldContext();\n const form = useFormContext();\n const formSettings = useFormSettings();\n const ownId = useId();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const messages = useMemo(\n () =>\n props.messages === undefined && props.locale === undefined\n ? settings.messages\n : resolveFormsMessages(\n { ...settings.messageOverrides, ...props.messages },\n locale,\n ),\n [props.messages, props.locale, settings, locale],\n );\n return {\n field,\n form,\n settings,\n ownId,\n readOnly: props.readOnly === true || settings.readOnly,\n disabled: props.disabled === true || settings.disabled,\n mode: props.mode ?? settings.mode,\n locale,\n messages,\n };\n}\n\n/**\n * Passes a controlled `value` to the field after every render, takes a\n * form's reveal for the field while it is in one, and cancels what the\n * field waits for on unmount.\n */\nexport function useControllerLifecycle<V>(\n controller: Pick<FieldController<V>, \"sync\" | \"reveal\" | \"destroy\">,\n value: V | null | undefined,\n form: FormContextValue | null,\n): void {\n useLayoutEffect(() => {\n if (value !== undefined) {\n controller.sync(value);\n }\n });\n useEffect(\n () => () => {\n controller.destroy();\n },\n [controller],\n );\n useLayoutEffect(\n () => form?.registry.addRevealer(controller.reveal),\n [form, controller],\n );\n}\n\n/**\n * The messages an input shows (`own`, the field's, and the app's\n * `message`) and the most serious among them and the `Field`'s, or\n * `\"error\"` for `invalid`.\n */\nexport function useShownMessages(\n own: readonly FieldMessage[],\n message: FieldInputProps<unknown>[\"message\"],\n invalid: boolean | undefined,\n field: FieldContextValue | null,\n): {\n readonly shown: readonly FieldMessage[];\n readonly severity: Severity | null;\n} {\n const shown = useMemo(\n () =>\n message === undefined\n ? own\n : sortFieldMessages([...own, ...toFieldMessages(message, \"app\")]),\n [own, message],\n );\n const fieldSeverity = field?.severity ?? null;\n const severity =\n invalid === true\n ? \"error\"\n : mostSevere([\n ...shown.map((shownMessage) => shownMessage.severity),\n ...(fieldSeverity === null ? [] : [fieldSeverity]),\n ]);\n return { shown, severity };\n}\n\n/** Tells the `Field` around an input its shown messages and its control's state, until it goes. */\nexport function useFieldReport(\n field: FieldContextValue | null,\n ownId: string,\n shown: readonly FieldMessage[],\n {\n focused,\n empty,\n required = false,\n startAdornment = false,\n labelBeside = false,\n }: FieldControlState,\n): void {\n const setControlMessages = field?.setControlMessages;\n useLayoutEffect(() => {\n if (setControlMessages === undefined) {\n return undefined;\n }\n setControlMessages(ownId, shown);\n return () => {\n setControlMessages(ownId, NO_MESSAGES);\n };\n }, [setControlMessages, ownId, shown]);\n\n const setControlState = field?.setControlState;\n useLayoutEffect(() => {\n if (setControlState === undefined) {\n return undefined;\n }\n setControlState({\n focused,\n empty,\n required,\n startAdornment,\n labelBeside,\n });\n return () => {\n setControlState(null);\n };\n }, [setControlState, focused, empty, required, startAdornment, labelBeside]);\n}\n\n/**\n * Binds a native text control, or with `options.toggle` a checkbox, to a\n * field: the value and draft model, the\n * events in their order, controlled and imperative changes, validation and\n * the hidden input that submits the value. The input that calls it draws\n * the control with `controlProps` spread on it, and `hiddenInput` beside\n * it; it renders nothing itself.\n *\n * It only wires: forms-core's controller decides every event, and forms-dom\n * connects it to the control once the control is in the page. The latest\n * props reach the controller on every render. A controlled `value` is\n * passed on after every render and adopted whenever the user is not\n * typing, with no event; `handleRef`'s `setValue` and `reset` fire the\n * change events with `source: \"api\"`.\n *\n * Inside a `Field` the control takes the field's `id`, description,\n * required and invalid states, and `readOnly`, `disabled` and `mode` from\n * the field and the form, and the hook tells the field its shown messages\n * and whether the control is focused, empty and required. `options` are\n * the calling input's own behaviour; the latest reach forms-dom after\n * every render.\n */\nexport function useFieldInput<\n V,\n E extends TextControl = HTMLInputElement,\n D extends object = NoDetails,\n>(\n props: FieldInputProps<V, E, D>,\n kind: FieldInputKind<V, D>,\n options: FieldInputOptions = {},\n): FieldInput<V, E> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const toggle = options.toggle !== undefined;\n const fieldOptions: FieldOptions<V, D, Event> = {\n value: props.value,\n defaultValue: props.defaultValue,\n parse: props.parse,\n format: props.format,\n defaultParse: kind.defaultParse,\n defaultFormat: kind.defaultFormat,\n equals: kind.equals,\n details: kind.details,\n filterInput: kind.filterInput,\n validators: validatorsOf(props.validate),\n schedule: scheduleTimeout,\n changeDelay: options.changeDelay,\n commitOnLeave: !toggle,\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [controller] = useState(() => createFieldController(fieldOptions));\n controller.setOptions(fieldOptions);\n const state = useSyncExternalStore(\n controller.subscribe,\n controller.getState,\n controller.getState,\n );\n\n useControllerLifecycle(controller, props.value, form);\n\n // The control in state, not a ref, so that a new `ref` prop rebinds the\n // app's ref without detaching the pipeline mid-edit.\n const [control, setControl] = useState<E | null>(null);\n const { ref } = props;\n const controlRef = useCallback<RefCallback<E>>(\n (element) => {\n setControl(element);\n const release = setRef(ref, element);\n return () => {\n setControl(null);\n release?.();\n };\n },\n [ref],\n );\n const { onClear } = props;\n function fireClear(nativeEvent: Event | null): void {\n onClear?.({\n previousValue: controller.getState().value,\n previousText: controller.getText(),\n nativeEvent,\n });\n }\n const textOptions: TextInputOptions = {\n selectOnFocus: options.selectOnFocus,\n escape: options.escape,\n onClear: fireClear,\n mapCaret: options.mapCaret,\n decimalKey: options.decimalKey,\n lastCaret: options.lastCaret,\n };\n const toggleOptions: ToggleOptions = { ...options.toggle, readOnly };\n const behaviour = useRef<AttachedBehaviour | null>(null);\n useLayoutEffect(() => {\n if (control === null) {\n return undefined;\n }\n const attached = attachBehaviour(control, controller, toggle);\n behaviour.current = attached;\n return () => {\n attached.handle.detach();\n behaviour.current = null;\n };\n }, [control, controller, toggle]);\n // Every render's options, the attaching render's included: this effect\n // runs straight after the one above, before any event can arrive.\n useLayoutEffect(() => {\n const attached = behaviour.current;\n if (attached?.kind === \"text\") {\n attached.handle.setOptions(textOptions);\n } else if (attached?.kind === \"toggle\") {\n attached.handle.setOptions(toggleOptions);\n }\n });\n\n useImperativeHandle(\n props.handleRef,\n () => ({\n element: control,\n focus: (focusOptions) => {\n control?.focus(focusOptions);\n },\n blur: () => {\n control?.blur();\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n }),\n [control, controller],\n );\n\n const text = controller.getText();\n // A disabled field is not validated, so it shows none of its own messages.\n const own =\n state.revealed && !disabled ? controller.getMessages() : NO_MESSAGES;\n const { shown, severity } = useShownMessages(\n own,\n props.message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.phase),\n empty: text === \"\",\n required,\n startAdornment: options.startAdornment === true,\n labelBeside: toggle,\n });\n\n return {\n state,\n text,\n messages: shown,\n severity,\n clear: (nativeEvent) => {\n fireClear(nativeEvent);\n controller.clear(nativeEvent);\n },\n getValue: () => controller.getState().value,\n change: controller.change,\n mode,\n displayValue: <DisplayValue text={text} emptyText={messages.emptyValue} />,\n controlProps: {\n ref: controlRef,\n id: field?.controlId ?? props.id ?? ownId,\n defaultValue: toggle ? undefined : text,\n defaultChecked: toggle ? state.value === true : undefined,\n readOnly: toggle ? undefined : readOnly,\n \"aria-readonly\": (toggle && readOnly) || undefined,\n disabled,\n \"aria-invalid\":\n hasError(shown) ||\n props.invalid === true ||\n field?.invalid === true ||\n undefined,\n \"aria-describedby\": field?.describedBy,\n \"aria-required\": required || field?.required === true || undefined,\n },\n hiddenInput:\n props.name === undefined ? null : (\n <input\n type=\"hidden\"\n name={props.name}\n form={props.form}\n disabled={disabled}\n value={state.value === null ? \"\" : kind.serialize(state.value)}\n />\n ),\n };\n}\n","/**\n * A value in display mode: its text, as a document shows it, or for an\n * empty value a dash that is read as `emptyText`.\n */\nexport function DisplayValue({\n text,\n emptyText,\n}: {\n readonly text: string;\n readonly emptyText: string;\n}) {\n if (text !== \"\") {\n return <span className=\"gridkit-forms-display-value\">{text}</span>;\n }\n return (\n <span className=\"gridkit-forms-display-value gridkit-forms-display-empty\">\n <span aria-hidden=\"true\">—</span>\n <span className=\"gridkit-forms-sr-only\">{emptyText}</span>\n </span>\n );\n}\n","import {\n segmentRuns,\n splitSegments,\n type DateLayout,\n type PopupCloseReason,\n type PopupOpenChange,\n type SegmentType,\n} from \"@gridkitjs/forms-core\";\nimport { Fragment, useRef, type ReactNode, type Ref } from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { PickerButton, PickerPopup } from \"../picker/PickerPopup\";\nimport { usePickerPopup } from \"../picker/usePickerPopup\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n joinIds,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport { useInputSettings } from \"../useFieldInput\";\nimport type { SegmentedInputProps } from \"./segmentedProps\";\nimport {\n useSegmentedInput,\n type SegmentedKind,\n type SegmentsAccess,\n} from \"./useSegmentedInput\";\n\n/** What a segmented input's picker content is given while its popup is open. */\nexport interface PickerContext<V> {\n /** The field's value now. */\n readonly value: V | null;\n /** The popup's `id`, a prefix for the content's own ids. */\n readonly id: string;\n /** Chooses `value` whole and commits it: the change and commit events with `source` and `trigger` `\"picker\"`. */\n readonly pick: (value: V | null, nativeEvent: Event) => void;\n /** Closes the popup; after a pick, with `\"picker\"`. Focus goes back to the segments. */\n readonly close: (reason: PopupCloseReason) => void;\n /** What Escape does before it closes the popup; see `PickerPopup.setEscapeHandler`. */\n readonly setEscapeHandler: (handler: (() => boolean) | null) => void;\n}\n\n/**\n * A segmented input's picker: the button in its box, after the segments,\n * that opens a popup (as F4 and Alt+ArrowDown in a segment do), and what\n * the popup draws. The popup counts as inside the field, so opening it\n * neither commits nor blurs it.\n */\nexport interface SegmentedPicker<V> {\n /** The button's and the popup's name: \"Choose date\". */\n readonly label: string;\n readonly icon: ReactNode;\n /** The button's class beside `gridkit-forms-picker-button`: `gridkit-forms-calendar-button`. */\n readonly buttonClassName: string;\n /** The popup's class beside `gridkit-forms-picker-popup`: `gridkit-forms-calendar-popup`. */\n readonly popupClassName: string;\n /** The popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n /** Where focus goes in the popup as it opens; its first control by default. */\n readonly initialFocus?:\n ((panel: HTMLElement) => HTMLElement | null) | undefined;\n /**\n * Whether Tab leaves the popup at its ends: Tab from its last stop goes\n * on to the button, Shift+Tab from its first back to the segments, and\n * either closes it (`\"blur\"`). Without, Tab stays inside it.\n */\n readonly tabOut?: boolean | undefined;\n /** The popup's content, drawn while it is open. */\n readonly content: (context: PickerContext<V>) => ReactNode;\n}\n\n/** Where focus goes back to in a field's box: the free-text box while it shows, else the first segment. */\nfunction fieldFocusTarget(box: HTMLElement): HTMLElement | null {\n return box.querySelector<HTMLElement>(\n \"[data-gridkit-forms-segment-text]:not([hidden]), [data-gridkit-forms-segments]:not([hidden]) input[data-gridkit-forms-segment]\",\n );\n}\n\n/** A segment's state class: `is-month`, `is-day-period`. */\nfunction segmentClass(type: SegmentType): string {\n return `is-${type.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;\n}\n\n/** What every segment input shares, beside its own place in the layout. */\ninterface SegmentShared {\n readonly controlId: string;\n readonly texts: readonly string[] | null;\n readonly labelledBy: string | undefined;\n readonly describedBy: string | undefined;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n readonly invalid: boolean;\n readonly required: boolean;\n readonly loading: boolean;\n readonly autoFocus: boolean | undefined;\n readonly autoComplete: string | undefined;\n readonly enterKeyHint: SegmentedInputProps<unknown, object>[\"enterKeyHint\"];\n readonly firstRef: Ref<HTMLInputElement> | undefined;\n}\n\n/** The id of the hidden text naming segment `type`: \"month\". */\nfunction nameId(controlId: string, type: SegmentType): string {\n return `${controlId}-name-${type}`;\n}\n\n/** Segment `index`'s native control: a spinbutton typed into through forms-dom. */\nfunction SegmentInput({\n layout,\n index,\n shared,\n}: {\n readonly layout: DateLayout;\n readonly index: number;\n readonly shared: SegmentShared;\n}) {\n const segment = layout.segments[index];\n if (segment === undefined) {\n return null;\n }\n const first = index === 0;\n return (\n <input\n ref={first ? shared.firstRef : undefined}\n id={first ? shared.controlId : `${shared.controlId}-${segment.type}`}\n className={classNames(\n \"gridkit-forms-segment\",\n segmentClass(segment.type),\n )}\n data-gridkit-forms-segment={segment.type}\n type=\"text\"\n role=\"spinbutton\"\n inputMode={segment.type === \"dayPeriod\" ? \"text\" : \"numeric\"}\n autoComplete={shared.autoComplete ?? \"off\"}\n autoCorrect=\"off\"\n spellCheck={false}\n enterKeyHint={shared.enterKeyHint}\n autoFocus={first ? shared.autoFocus : undefined}\n tabIndex={first ? 0 : -1}\n size={Math.max(segment.width, segment.placeholder.length)}\n placeholder={segment.placeholder}\n defaultValue={shared.texts?.[index] ?? \"\"}\n readOnly={shared.readOnly}\n disabled={shared.disabled}\n aria-labelledby={joinIds(\n shared.labelledBy,\n nameId(shared.controlId, segment.type),\n )}\n aria-describedby={shared.describedBy}\n aria-invalid={shared.invalid || undefined}\n aria-required={(first && shared.required) || undefined}\n aria-busy={shared.loading || undefined}\n />\n );\n}\n\n/**\n * The segments in the layout's order with the literals between them, each\n * run of number segments that reads left to right wrapped in `dir=\"ltr\"`,\n * so a right-to-left field orders them as the locale writes them; in a\n * left-to-right field the wrapper changes nothing.\n */\nfunction SegmentList({\n layout,\n shared,\n hidden,\n}: {\n readonly layout: DateLayout;\n readonly shared: SegmentShared;\n readonly hidden: boolean;\n}) {\n const part = (partIndex: number): ReactNode => {\n const layoutPart = layout.parts[partIndex];\n if (layoutPart === undefined) {\n return null;\n }\n return layoutPart.kind === \"literal\" ? (\n <span\n key={partIndex}\n className=\"gridkit-forms-segment-literal\"\n aria-hidden=\"true\"\n >\n {layoutPart.text}\n </span>\n ) : (\n <SegmentInput\n key={partIndex}\n layout={layout}\n index={layoutPart.index}\n shared={shared}\n />\n );\n };\n return (\n <span\n className=\"gridkit-forms-segments\"\n data-gridkit-forms-segments=\"\"\n hidden={hidden}\n >\n {segmentRuns(layout, \"rtl\").map((run, runIndex) =>\n run.leftToRight ? (\n <span key={runIndex} className=\"gridkit-forms-segment-run\" dir=\"ltr\">\n {run.parts.map(part)}\n </span>\n ) : (\n <Fragment key={runIndex}>{run.parts.map(part)}</Fragment>\n ),\n )}\n </span>\n );\n}\n\n/**\n * The drawing every segmented input shares: the group with its box, the\n * segments, the free-text box for shortcuts, each segment's hidden name,\n * the hidden input and a bare input's own messages; in display mode, the\n * value as text.\n */\nexport function SegmentedControl<V, D extends object>({\n props: {\n loading = false,\n density,\n autoFocus,\n prefix,\n suffix,\n clearable = false,\n autoComplete,\n enterKeyHint,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n },\n kind,\n rootClassName,\n segments,\n picker,\n}: {\n readonly props: SegmentedInputProps<V, D>;\n readonly kind: SegmentedKind<V, D>;\n /** The input's own class: `gridkit-forms-date-input`. */\n readonly rootClassName: string;\n /** Where forms-dom's segments are held, for the kind's reading. */\n readonly segments: SegmentsAccess;\n /** The input's picker button and popup; none without. */\n readonly picker?: SegmentedPicker<V> | undefined;\n}) {\n const field = useFieldContext();\n const settings = useFormSettings();\n const buttonRef = useRef<HTMLButtonElement>(null);\n // Read before the field binds, which needs the popup's `isInside`.\n const { readOnly, disabled, mode } = useInputSettings(props);\n const popup = usePickerPopup({\n enabled:\n picker !== undefined && mode !== \"display\" && !readOnly && !disabled,\n onOpenChange: picker?.onOpenChange,\n returnFocusTo: fieldFocusTarget,\n initialFocus: picker?.initialFocus,\n });\n const input = useSegmentedInput(props, kind, segments, {\n startAdornment: hasNode(prefix),\n picker:\n picker === undefined\n ? undefined\n : {\n onOpen: () => {\n popup.open(\"keyboard\");\n },\n isInside: popup.isInside,\n },\n });\n const { controlId, strings, setGroup } = input;\n const ownMessagesId = useOwnMessagesId(controlId);\n const resolvedDensity = density ?? settings.density;\n const root = classNames(\n rootClassName,\n densityClass(resolvedDensity),\n className,\n );\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n <DisplayValue text={input.displayText} emptyText={strings.emptyValue} />\n {input.hiddenInput}\n </div>\n );\n }\n\n const groupId = `${controlId}-group`;\n const popupId = `${controlId}-picker`;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const fieldLabelId =\n field?.controlId === null || field === null\n ? undefined\n : `${controlId}-label`;\n const groupLabelledBy =\n ariaLabelledBy ?? (ariaLabel === undefined ? fieldLabelId : undefined);\n const describedBy = joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n input.describedBy,\n ownMessagesId,\n ariaDescribedBy,\n );\n const texts = splitSegments(kind.layout, input.text);\n const shared: SegmentShared = {\n controlId,\n texts,\n labelledBy: ariaLabel === undefined ? groupLabelledBy : groupId,\n describedBy,\n readOnly: input.readOnly,\n disabled: input.disabled,\n invalid: input.invalid,\n required: input.required,\n loading,\n autoFocus,\n autoComplete,\n enterKeyHint,\n firstRef: ref,\n };\n const editable = !input.readOnly && !input.disabled;\n\n return (\n <div\n ref={setGroup}\n className={root}\n style={style}\n role=\"group\"\n id={groupId}\n aria-label={ariaLabel}\n aria-labelledby={groupLabelledBy}\n aria-describedby={describedBy}\n >\n <ControlBox\n boxRef={popup.setAnchor}\n severity={input.severity}\n disabled={input.disabled}\n readOnly={input.readOnly}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n end={\n picker !== undefined &&\n !input.readOnly && (\n <PickerButton\n buttonRef={buttonRef}\n picker={popup}\n popupId={popupId}\n label={picker.label}\n className={picker.buttonClassName}\n disabled={input.disabled}\n icon={picker.icon}\n />\n )\n }\n >\n <SegmentList\n layout={kind.layout}\n shared={shared}\n hidden={texts === null}\n />\n <input\n className=\"gridkit-forms-date-text\"\n data-gridkit-forms-segment-text=\"\"\n type=\"text\"\n hidden={texts !== null}\n defaultValue={texts === null ? input.text : \"\"}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n enterKeyHint={enterKeyHint}\n readOnly={input.readOnly}\n disabled={input.disabled}\n aria-label={groupLabelledBy === undefined ? ariaLabel : undefined}\n aria-labelledby={groupLabelledBy}\n aria-describedby={describedBy}\n aria-invalid={input.invalid || undefined}\n />\n </ControlBox>\n {picker !== undefined && (\n <PickerPopup\n picker={popup}\n id={popupId}\n label={picker.label}\n className={picker.popupClassName}\n onTabOut={\n picker.tabOut === true\n ? (backward) => {\n const button = backward ? null : buttonRef.current;\n popup.close(\"blur\", button ?? undefined);\n }\n : undefined\n }\n >\n {picker.content({\n value: input.state.value,\n id: popupId,\n pick: input.pick,\n close: popup.close,\n setEscapeHandler: popup.setEscapeHandler,\n })}\n </PickerPopup>\n )}\n {kind.layout.segments.map((segment) => (\n <span\n key={segment.type}\n className=\"gridkit-forms-sr-only\"\n id={nameId(controlId, segment.type)}\n >\n {segment.label}\n </span>\n ))}\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n","import type { KeyboardEvent, ReactNode, Ref } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { classNames } from \"../field/parts\";\nimport { keepFocus } from \"../text/parts\";\nimport type { PickerPopup as PickerPopupState } from \"./usePickerPopup\";\n\n/** What Tab stops on in `panel`, in document order. */\nfunction tabStops(panel: HTMLElement): HTMLElement[] {\n return Array.from(\n panel.querySelectorAll<HTMLElement>(\"button, input, [tabindex]\"),\n ).filter((element) => element.tabIndex >= 0 && !element.matches(\":disabled\"));\n}\n\n/**\n * A field's picker popup, portalled into `document.body` so no scrolling\n * ancestor clips it, while it is open: a modal dialog named `label`,\n * in the field's colour scheme and `dir`. `usePickerPopup` places it\n * and moves focus in. Tab stays inside it, unless `onTabOut` is given:\n * then Tab from its last stop, or Shift+Tab from its first, calls that\n * instead.\n */\nexport function PickerPopup({\n picker,\n id,\n label,\n className,\n onTabOut,\n children,\n}: {\n readonly picker: PickerPopupState;\n readonly id: string;\n readonly label: string;\n /** The popup's own class beside `gridkit-forms-picker-popup`: `gridkit-forms-calendar-popup`. */\n readonly className: string;\n readonly onTabOut?: ((backward: boolean) => void) | undefined;\n readonly children: ReactNode;\n}) {\n const { scope, state, setPanel } = picker;\n if (state.kind !== \"open\" || scope === null) {\n return null;\n }\n // In the capture phase, so it runs before the overlay's focus trap on the panel.\n const onKeyDownCapture =\n onTabOut === undefined\n ? undefined\n : (event: KeyboardEvent<HTMLElement>) => {\n if (\n event.key !== \"Tab\" ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey\n ) {\n return;\n }\n const stops = tabStops(event.currentTarget);\n const edge = event.shiftKey ? stops[0] : stops.at(-1);\n if (edge !== undefined && edge === event.target) {\n event.preventDefault();\n onTabOut(event.shiftKey);\n }\n };\n return createPortal(\n <div\n ref={setPanel}\n id={id}\n className={classNames(\n \"gridkit-forms-picker-popup\",\n className,\n scope.scheme !== null && `is-${scope.scheme}`,\n )}\n dir={scope.direction}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={label}\n onKeyDownCapture={onKeyDownCapture}\n >\n {children}\n </div>,\n document.body,\n );\n}\n\n/**\n * The button in a field's box that opens its picker popup and closes it\n * again. A press keeps focus in the field, so the popup hands focus back\n * to the segment the user was in.\n */\nexport function PickerButton({\n picker,\n popupId,\n label,\n className,\n disabled,\n icon,\n buttonRef,\n}: {\n readonly picker: PickerPopupState;\n readonly popupId: string;\n readonly buttonRef?: Ref<HTMLButtonElement> | undefined;\n readonly label: string;\n /** The button's own class beside `gridkit-forms-picker-button`: `gridkit-forms-calendar-button`. */\n readonly className: string;\n readonly disabled: boolean;\n readonly icon: ReactNode;\n}) {\n const open = picker.state.kind === \"open\";\n return (\n <button\n ref={buttonRef}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-picker-button\",\n className,\n open && \"is-open\",\n )}\n aria-label={label}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? popupId : undefined}\n disabled={disabled}\n onMouseDown={keepFocus}\n onClick={picker.toggle}\n >\n {icon}\n </button>\n );\n}\n","import {\n createFieldController,\n dateParts,\n hasError,\n joinSegments,\n type ChangeCause,\n type DateLayout,\n type FieldMessage,\n type FieldMessageInput,\n type FieldOptions,\n type FieldState,\n type FormatContext,\n type FormsMessages,\n type ParseContext,\n type ParseResult,\n type PlainDate,\n type SegmentState,\n type SegmentType,\n type Severity,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachSegments,\n scheduleTimeout,\n type AttachedSegments,\n type SegmentsOptions,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactElement,\n type RefCallback,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport type { FieldMode } from \"../settings\";\nimport {\n isFocused,\n useControllerLifecycle,\n useFieldReport,\n useInputSettings,\n useShownMessages,\n validatorsOf,\n type FieldInputProps,\n} from \"../useFieldInput\";\n\n/** How a segmented input reads, writes, shows and limits its value. */\nexport interface SegmentedKind<V, D extends object> {\n /** The component's name, for warnings. */\n readonly name: string;\n readonly layout: DateLayout;\n readonly defaultParse: (\n text: string,\n context: ParseContext<V>,\n ) => ParseResult<V>;\n /** The value in the field's segments. */\n readonly defaultFormat: (\n value: V | null,\n context: FormatContext<V>,\n ) => string;\n readonly details: (\n current: FieldState<V>,\n previous: FieldState<V>,\n cause: ChangeCause<Event>,\n ) => D;\n /** The value as display mode writes it, before the app's `format`. */\n readonly display: (value: V) => string;\n /** The value as its hidden input submits it: the ISO string. */\n readonly serialize: (value: V) => string;\n /** Whether a value from the app is one; anything else is treated as empty, with a warning. */\n readonly isValue: (value: unknown) => value is V;\n /** Whether `value` lies within the input's `min` and `max`: a step never leaves them. */\n readonly inLimits: (value: V) => boolean;\n /** Whether letters and signs open the free-text box. */\n readonly shortcuts: boolean;\n readonly minuteStep?: number | undefined;\n /** Today in the input's zone, read when a step or a shortcut needs it. */\n readonly today: () => PlainDate;\n /**\n * Where an empty segment steps from, read when a step needs it: today's\n * year, month or day and 0 for a time unless given (a period steps from\n * today's period).\n */\n readonly reference?: ((type: SegmentType) => number) | undefined;\n /** The year one or two digits left in the year segment mean. */\n readonly pivot: (digits: number) => number;\n /** A message shown beside the field's own while it holds `value`: an instant's skipped hour. */\n readonly note?: ((value: V | null) => FieldMessageInput | null) | undefined;\n}\n\n/** What the segments know of the input's picker popup. */\nexport interface SegmentsPicker {\n /** F4 or Alt+ArrowDown in a segment. */\n readonly onOpen: (nativeEvent: KeyboardEvent) => void;\n /** Whether `node` is in the popup, so focus moving there does not leave the field. */\n readonly isInside: (node: Node) => boolean;\n}\n\n/** The props `useSegmentedInput` reads. */\nexport type SegmentedHookProps<V, D extends object> = Omit<\n FieldInputProps<V, HTMLInputElement, D>,\n \"ref\"\n> & {\n readonly revertOnEscape?: boolean | undefined;\n};\n\n/** What `useSegmentedInput` gives the input that calls it, to draw. */\nexport interface SegmentedInput<V> {\n readonly state: FieldState<V>;\n /** The segments' text, or the free text. */\n readonly text: string;\n readonly messages: readonly FieldMessage[];\n readonly severity: Severity | null;\n readonly invalid: boolean;\n readonly mode: FieldMode;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n /** The input's own `required`, or the `Field`'s. */\n readonly required: boolean;\n /** The first segment's `id`: the `Field`'s inside one, so its label points there. */\n readonly controlId: string;\n /** The `Field`'s description and messages. */\n readonly describedBy: string | undefined;\n readonly strings: FormsMessages;\n /** The value as display mode shows it, through the app's `format`; `\"\"` when empty. */\n readonly displayText: string;\n /** Fires `onClear`, then empties the field and commits it. */\n readonly clear: (nativeEvent: Event | null) => void;\n /** The value chosen whole in a picker, then committed: `source` and `trigger` `\"picker\"`. */\n readonly pick: (value: V | null, nativeEvent: Event) => void;\n /** The element around the segments and the free-text box. */\n readonly setGroup: RefCallback<HTMLElement>;\n /** The hidden input carrying `name` and the ISO value; `null` without a `name`. */\n readonly hiddenInput: ReactElement | null;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n// `Array.isArray` does not narrow a readonly array, hence the guard.\nfunction isMessageList(\n message: FieldMessageInput | readonly FieldMessageInput[],\n): message is readonly FieldMessageInput[] {\n return Array.isArray(message);\n}\nconst DATE_SEGMENTS = new Set([\"year\", \"month\", \"day\"]);\n\n/**\n * Where forms-dom's segments are held once attached, so a kind's reading\n * can ask where typing stands. An input makes one with `useState` and\n * hands it to `useSegmentedInput`, which attaches and releases it.\n */\nexport interface SegmentsAccess {\n readonly attach: (attached: AttachedSegments | null) => void;\n readonly setOptions: (options: SegmentsOptions) => void;\n readonly getState: () => SegmentState | null;\n}\n\nexport function createSegmentsAccess(): SegmentsAccess {\n let current: AttachedSegments | null = null;\n return {\n attach: (attached) => {\n current = attached;\n },\n setOptions: (options) => {\n current?.setOptions(options);\n },\n getState: () => current?.getState() ?? null,\n };\n}\n\n/** The segment typing is in, or `null`: a short year there is not pivoted yet. */\nexport function typingSegment(segments: SegmentsAccess): number | null {\n const entry = segments.getState()?.entry;\n return entry?.kind === \"active\" ||\n entry?.kind === \"typing\" ||\n entry?.kind === \"composing\"\n ? entry.segment\n : null;\n}\n\n/** The segments' text typing works on: the text the free-text box opened over while it shows. */\nexport function typedSegments(segments: SegmentsAccess): string {\n const state = segments.getState();\n if (state === null) {\n return \"\";\n }\n return state.entry.kind === \"text\" ? state.entry.before : state.text;\n}\n\n/**\n * Binds a segmented input to one field, as `useFieldInput` binds one\n * control: forms-core's controller, made once and handed the latest props\n * and `kind` on every render; a controlled `value` (one that is not a\n * value of the kind is empty, with a warning); the `Field` and form around\n * it; and forms-dom's `attachSegments` on `setGroup`, held in `segments`\n * so the kind's reading can ask where typing stands.\n *\n * The app's `format` writes display mode's text only: the segments are not\n * free text. Its `parse` reads the segments, pastes and free text, around\n * the kind's own.\n */\nexport function useSegmentedInput<V, D extends object>(\n props: SegmentedHookProps<V, D>,\n kind: SegmentedKind<V, D>,\n segments: SegmentsAccess,\n {\n startAdornment,\n picker,\n }: {\n /** Something sits at the box's start, where a resting floating label would cover it. */\n readonly startAdornment: boolean;\n /** The input's picker popup: F4 and Alt+ArrowDown open it, and focus in it stays in the field. */\n readonly picker?: SegmentsPicker | undefined;\n },\n): SegmentedInput<V> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const valueOf = (value: V | null | undefined): V | null | undefined =>\n value === undefined || value === null || kind.isValue(value) ? value : null;\n const value = valueOf(props.value);\n const defaultValue = valueOf(props.defaultValue);\n const strayValue =\n (value === null && props.value !== null && props.value !== undefined) ||\n (defaultValue === null &&\n props.defaultValue !== null &&\n props.defaultValue !== undefined);\n useEffect(() => {\n if (strayValue) {\n warnOnce(\n `${kind.name}-value`,\n `${kind.name} was given a value that is not one it holds (an ISO string such as \"2026-03-14\"), so it shows nothing.`,\n );\n }\n }, [strayValue, kind.name]);\n\n const fieldOptions: FieldOptions<V, D, Event> = {\n value,\n defaultValue,\n parse: props.parse,\n defaultParse: kind.defaultParse,\n defaultFormat: kind.defaultFormat,\n details: kind.details,\n validators: validatorsOf(props.validate),\n schedule: scheduleTimeout,\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [controller] = useState(() => createFieldController(fieldOptions));\n controller.setOptions(fieldOptions);\n const state = useSyncExternalStore(\n controller.subscribe,\n controller.getState,\n controller.getState,\n );\n useControllerLifecycle(controller, value, form);\n\n const formatContext: FormatContext<V> = {\n defaultFormat: (shown) => kind.defaultFormat(shown, formatContext),\n locale,\n messages,\n purpose: \"edit\",\n };\n const segmentOptions: SegmentsOptions = {\n context: {\n layout: kind.layout,\n reference: (type) => {\n if (kind.reference !== undefined) {\n return kind.reference(type);\n }\n if (!DATE_SEGMENTS.has(type)) {\n return 0;\n }\n const today = dateParts(kind.today());\n return type === \"year\"\n ? today.year\n : type === \"month\"\n ? today.month\n : today.day;\n },\n pivotYear: kind.pivot,\n shortcuts: kind.shortcuts,\n readWhole: (text) => {\n const result = controller.read(text);\n return result.kind === \"value\" && result.value !== null\n ? kind.defaultFormat(result.value, formatContext)\n : null;\n },\n minuteStep: kind.minuteStep,\n allows: (texts) => {\n const result = controller.read(joinSegments(kind.layout, texts));\n return (\n result.kind !== \"value\" ||\n result.value === null ||\n kind.inLimits(result.value)\n );\n },\n },\n locale,\n messages,\n escape: props.revertOnEscape === false ? \"none\" : \"revert\",\n onOpenPicker: picker?.onOpen,\n isInside: picker?.isInside,\n };\n\n const [group, setGroup] = useState<HTMLElement | null>(null);\n const latestOptions = useRef(segmentOptions);\n // Every render's options; on the first, before the effect below attaches.\n useLayoutEffect(() => {\n latestOptions.current = segmentOptions;\n segments.setOptions(segmentOptions);\n });\n useLayoutEffect(() => {\n if (group === null) {\n return undefined;\n }\n const attached = attachSegments(group, controller, latestOptions.current);\n segments.attach(attached);\n return () => {\n attached.detach();\n segments.attach(null);\n };\n }, [group, controller, segments]);\n\n useImperativeHandle(\n props.handleRef,\n () => {\n const firstSegment = (): HTMLInputElement | null =>\n group?.querySelector<HTMLInputElement>(\n \"input[data-gridkit-forms-segment]\",\n ) ?? null;\n return {\n get element() {\n return firstSegment();\n },\n focus: (focusOptions) => {\n firstSegment()?.focus(focusOptions);\n },\n blur: () => {\n const active = group?.ownerDocument.activeElement;\n if (\n active instanceof HTMLElement &&\n group?.contains(active) === true\n ) {\n active.blur();\n }\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n };\n },\n [group, controller],\n );\n\n const text = controller.getText();\n // A disabled field is not validated, so it shows none of its own messages.\n const own =\n state.revealed && !disabled ? controller.getMessages() : NO_MESSAGES;\n const note = kind.note?.(state.value) ?? null;\n const { message: appMessage } = props;\n const message = useMemo(() => {\n if (note === null) {\n return appMessage;\n }\n if (appMessage === undefined) {\n return note;\n }\n return [...(isMessageList(appMessage) ? appMessage : [appMessage]), note];\n }, [appMessage, note]);\n const { shown, severity } = useShownMessages(\n own,\n message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.phase),\n empty: text === \"\",\n required,\n startAdornment,\n });\n\n const { format, onClear } = props;\n const displayText =\n format === undefined\n ? state.value === null\n ? \"\"\n : kind.display(state.value)\n : format(state.value, {\n defaultFormat: (shown) => (shown === null ? \"\" : kind.display(shown)),\n locale,\n messages,\n purpose: \"display\",\n });\n\n return {\n state,\n text,\n messages: shown,\n severity,\n invalid:\n hasError(shown) || props.invalid === true || field?.invalid === true,\n mode,\n readOnly,\n disabled,\n required: required || field?.required === true,\n controlId: field?.controlId ?? props.id ?? ownId,\n describedBy: field?.describedBy,\n strings: messages,\n displayText,\n clear: (nativeEvent) => {\n onClear?.({\n previousValue: controller.getState().value,\n previousText: controller.getText(),\n nativeEvent,\n });\n controller.clear(nativeEvent);\n },\n pick: (picked, nativeEvent) => {\n controller.pick(picked, \"picker\", \"picker\", nativeEvent);\n },\n setGroup,\n hiddenInput:\n props.name === undefined ? null : (\n <input\n type=\"hidden\"\n name={props.name}\n form={props.form}\n disabled={disabled}\n value={state.value === null ? \"\" : kind.serialize(state.value)}\n />\n ),\n };\n}\n","import {\n createFieldController,\n hasError,\n parsed,\n unreadable,\n type ChangeCause,\n type FieldController,\n type FieldMessage,\n type FieldOptions,\n type FieldState,\n type FormatContext,\n type FormsMessages,\n type Severity,\n} from \"@gridkitjs/forms-core\";\nimport { attachFocusGroup } from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useState,\n useSyncExternalStore,\n type ReactElement,\n type RefCallback,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport type { FieldMode } from \"../settings\";\nimport {\n isFocused,\n useControllerLifecycle,\n useFieldReport,\n useInputSettings,\n useShownMessages,\n validatorsOf,\n type FieldInputProps,\n} from \"../useFieldInput\";\n\n/** How an input whose value is only ever chosen whole (a calendar) writes, shows and checks it. */\nexport interface PickerKind<V, D extends object> {\n /** The component's name, for warnings. */\n readonly name: string;\n /** The value as the events' `text` carries it. */\n readonly defaultFormat: (\n value: V | null,\n context: FormatContext<V>,\n ) => string;\n readonly details: (\n current: FieldState<V>,\n previous: FieldState<V>,\n cause: ChangeCause<Event>,\n ) => D;\n /** The value as display mode writes it. */\n readonly display: (value: V) => string;\n /** Whether a value from the app is one; anything else is treated as empty, with a warning. */\n readonly isValue: (value: unknown) => value is V;\n readonly equals?: ((a: V, b: V) => boolean) | undefined;\n}\n\n/** The props `usePickerField` reads. */\nexport type PickerFieldProps<V, D extends object> = Omit<\n FieldInputProps<V, HTMLInputElement, D>,\n \"ref\" | \"parse\" | \"format\" | \"onBeforeInput\" | \"onInput\"\n>;\n\n/** What `usePickerField` gives the input that calls it, to draw. */\nexport interface PickerField<V, D extends object> {\n readonly controller: FieldController<V, D, Event>;\n readonly state: FieldState<V>;\n readonly messages: readonly FieldMessage[];\n readonly severity: Severity | null;\n readonly invalid: boolean;\n readonly mode: FieldMode;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n /** The input's own `required`, or the `Field`'s. */\n readonly required: boolean;\n /** The root's `id`: the props', else one of its own. */\n readonly rootId: string;\n /** The `Field`'s label, when the input is in one. */\n readonly fieldLabelId: string | undefined;\n /** The `Field`'s description and messages. */\n readonly describedBy: string | undefined;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** The value as display mode shows it; `\"\"` when empty. */\n readonly displayText: string;\n /** The value chosen whole, then committed: `source` and `trigger` `\"picker\"`. */\n readonly pick: (value: V | null, nativeEvent: Event) => void;\n /** The element around every focusable part: focus leaving it blurs the field. */\n readonly setRoot: RefCallback<HTMLElement>;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/**\n * Binds an input whose value is chosen whole, never typed (a calendar), to\n * one field, as `useFieldInput` binds a text control: forms-core's\n * controller, made once and handed the latest props on every render; a\n * controlled `value` (one that is not a value of the kind is empty, with a\n * warning); the `Field` and form around it. Focus entering the root starts\n * the field's edit and leaving it (forms-dom's focus group) ends it, so\n * `onFocus` and `onBlur` fire once for the whole input. `focusTarget`\n * finds the element `handleRef`'s `focus` moves to.\n */\nexport function usePickerField<V, D extends object>(\n props: PickerFieldProps<V, D>,\n kind: PickerKind<V, D>,\n focusTarget: (root: HTMLElement) => HTMLElement | null,\n): PickerField<V, D> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const valueOf = (value: V | null | undefined): V | null | undefined =>\n value === undefined || value === null || kind.isValue(value) ? value : null;\n const value = valueOf(props.value);\n const defaultValue = valueOf(props.defaultValue);\n const strayValue =\n (value === null && props.value !== null && props.value !== undefined) ||\n (defaultValue === null &&\n props.defaultValue !== null &&\n props.defaultValue !== undefined);\n useEffect(() => {\n if (strayValue) {\n warnOnce(\n `${kind.name}-value`,\n `${kind.name} was given a value that is not one it holds, so it shows nothing.`,\n );\n }\n }, [strayValue, kind.name]);\n\n const fieldOptions: FieldOptions<V, D, Event> = {\n value,\n defaultValue,\n // Nothing is typed into a picker, so its text never needs reading.\n defaultParse: (text) =>\n text === \"\" ? parsed(null) : unreadable(messages.unreadable),\n defaultFormat: kind.defaultFormat,\n // Every pick commits, so leaving has nothing more to commit.\n commitOnLeave: false,\n equals: kind.equals,\n details: kind.details,\n validators: validatorsOf(props.validate),\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [controller] = useState(() => createFieldController(fieldOptions));\n controller.setOptions(fieldOptions);\n const state = useSyncExternalStore(\n controller.subscribe,\n controller.getState,\n controller.getState,\n );\n useControllerLifecycle(controller, value, form);\n\n const [root, setRoot] = useState<HTMLElement | null>(null);\n useLayoutEffect(() => {\n if (root === null) {\n return undefined;\n }\n const onFocusIn = (event: FocusEvent) => {\n if (!isFocused(controller.getState().phase)) {\n controller.focus(event);\n }\n };\n root.addEventListener(\"focusin\", onFocusIn);\n // A focused day can leave the page as the months change, which moves\n // focus nowhere until the calendar focuses the new day; focus is only\n // gone once it has not come back by then.\n const group = attachFocusGroup(root, {\n onLeave: (_by, nativeEvent) => {\n queueMicrotask(() => {\n if (!root.contains(root.ownerDocument.activeElement)) {\n controller.blur(nativeEvent);\n }\n });\n },\n });\n return () => {\n root.removeEventListener(\"focusin\", onFocusIn);\n group.detach();\n };\n }, [root, controller]);\n\n useImperativeHandle(\n props.handleRef,\n () => ({\n get element() {\n return root === null ? null : focusTarget(root);\n },\n focus: (focusOptions) => {\n if (root !== null) {\n focusTarget(root)?.focus(focusOptions);\n }\n },\n blur: () => {\n const active = root?.ownerDocument.activeElement;\n if (active instanceof HTMLElement && root?.contains(active) === true) {\n active.blur();\n }\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n }),\n [root, controller, focusTarget],\n );\n\n // A disabled field is not validated, so it shows none of its own messages.\n const own =\n state.revealed && !disabled ? controller.getMessages() : NO_MESSAGES;\n const { shown, severity } = useShownMessages(\n own,\n props.message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.phase),\n empty: state.value === null,\n required,\n startAdornment: false,\n });\n\n return {\n controller,\n state,\n messages: shown,\n severity,\n invalid:\n hasError(shown) || props.invalid === true || field?.invalid === true,\n mode,\n readOnly,\n disabled,\n required: required || field?.required === true,\n rootId: field?.controlId ?? props.id ?? ownId,\n fieldLabelId:\n field === null || field.controlId === null\n ? undefined\n : `${field.controlId}-label`,\n describedBy: field?.describedBy,\n locale,\n strings: messages,\n displayText: state.value === null ? \"\" : kind.display(state.value),\n pick: (picked, nativeEvent) => {\n controller.pick(picked, \"picker\", \"picker\", nativeEvent);\n },\n setRoot,\n };\n}\n\n/** The hidden inputs that submit `values` under `name`, or `null` without a name. */\nexport function hiddenInputs(\n name: string | undefined,\n form: string | undefined,\n disabled: boolean,\n values: readonly (readonly [suffix: string, value: string])[],\n): ReactElement[] | null {\n if (name === undefined) {\n return null;\n }\n return values.map(([suffix, submitted]) => (\n <input\n key={suffix}\n type=\"hidden\"\n name={`${name}${suffix}`}\n form={form}\n disabled={disabled}\n value={submitted}\n />\n ));\n}\n","import {\n addDays,\n compareDates,\n dateRangeKind,\n formatDate,\n formatDateRange,\n isCalendarDayDisabled,\n isPlainDate,\n pickedDays,\n rangeDetails,\n rangePickPreview,\n rangePickReducer,\n requiredRule,\n sameRange,\n weekInfo,\n type CalendarLimits,\n type DateRange,\n type DateRuleContext,\n type NoFlags,\n type PickedDays,\n type PlainDate,\n type RangeBounds,\n type RangeDetails,\n type RangePick,\n type RangePickAction,\n type RelativeDateRule,\n} from \"@gridkitjs/forms-core\";\nimport { attachFitCount } from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type PointerEvent,\n type RefCallback,\n} from \"react\";\nimport { todayFor } from \"../date/DateInput\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { joinIds, OwnMessages, useOwnMessagesId } from \"../text/parts\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { focusedDayIn } from \"./Calendar\";\nimport { CalendarBody } from \"./CalendarBody\";\nimport type {\n CalendarBaseProps,\n CalendarLimitProps,\n CalendarSettings,\n} from \"./calendarProps\";\nimport {\n dateOf,\n NO_MARKS,\n titleId,\n type CalendarLook,\n type DayMarks,\n} from \"./MonthPanel\";\nimport { useCalendarNavigation, useToday } from \"./useCalendarNavigation\";\nimport {\n hiddenInputs,\n usePickerField,\n type PickerKind,\n} from \"./usePickerField\";\n\n/**\n * What a range calendar adds to every event: the range's details, with\n * `changedEnd` always `\"both\"` and `rule` always `null` (a calendar holds\n * fixed days).\n */\nexport type RangeCalendarDetails = RangeDetails<\n PlainDate,\n NoFlags,\n number,\n RelativeDateRule\n>;\n\nexport interface RangeCalendarProps\n extends\n CalendarBaseProps<DateRange, RangeCalendarDetails>,\n CalendarLimitProps,\n CalendarSettings {\n /** Months side by side; by default 2 where two fit beside each other, else 1. */\n readonly visibleMonths?: 1 | 2 | 3 | undefined;\n /** `\"[)\"` by default: the value's `end` is the day after the last day picked. `\"[]\"` stores the last day. */\n readonly bounds?: RangeBounds | undefined;\n}\n\n/** Whether `value` is a range of days a range calendar can hold. */\nfunction isDateRange(value: unknown): value is DateRange {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const { start, end } = value as Record<string, unknown>;\n const isEnd = (end: unknown) => end === null || isPlainDate(end);\n return isEnd(start) && isEnd(end) && (start !== null || end !== null);\n}\n\n/** The last day a stored range covers: the day before a half-open `end`. */\nfunction lastDayOf(range: DateRange, bounds: RangeBounds): PlainDate | null {\n return range.end === null || bounds === \"[]\"\n ? range.end\n : addDays(range.end, -1);\n}\n\n/** The days a stored range covers, its ends included; an open end shows the other alone. */\nfunction daysOf(range: DateRange, bounds: RangeBounds): PickedDays | null {\n const last = lastDayOf(range, bounds);\n const first = range.start ?? last;\n return first === null ? null : pickedDays(first, last ?? first);\n}\n\n/** How a day in `days` shows; `preview` while the range is still being picked. */\nfunction marksIn(\n days: PickedDays | null,\n date: PlainDate,\n preview: boolean,\n): DayMarks {\n if (\n days === null ||\n compareDates(date, days.first) < 0 ||\n compareDates(date, days.last) > 0\n ) {\n return NO_MARKS;\n }\n const rangeStart = date === days.first;\n const rangeEnd = date === days.last;\n return {\n selected: true,\n rangeStart,\n rangeEnd,\n inRange: !rangeStart && !rangeEnd,\n preview,\n };\n}\n\nconst IDLE: RangePick = { kind: \"idle\" };\n\n/**\n * Months side by side to pick a range of days from: a first day chosen\n * (click, tap, Enter or Space) anchors the range, moving the pointer or\n * focus previews it, and a second choice finishes it; an end before the\n * start swaps them. With a mouse or pen, a press dragged across days\n * picks the range in one gesture. Escape drops a range in progress. Keys,\n * limits, week numbers and the month view are `Calendar`'s.\n *\n * Its value is a `DateRange`, stored half-open: picking 1 to 14 March\n * gives `{ start: \"2026-03-01\", end: \"2026-03-15\" }`, and the days shown\n * are the 1st to the 14th. The range commits once, when its end is\n * chosen, with `source` and `trigger` `\"picker\"`.\n */\nexport function RangeCalendar({\n min,\n max,\n isDateDisabled,\n timeZone,\n firstDayOfWeek,\n weekNumbers = false,\n weekNumbering,\n visibleMonths,\n bounds = \"[)\",\n required,\n validate,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: RangeCalendarProps) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const needsValue = required === true || field?.required === true;\n const today = todayFor(timeZone);\n const firstDay = firstDayOfWeek ?? weekInfo(locale).firstDay;\n const ruleContext: DateRuleContext = {\n today,\n firstDayOfWeek: firstDay,\n fiscalYearStart: 1,\n };\n const write = (range: DateRange) =>\n formatDateRange(range, { locale, messages, bounds });\n const writeEnd = (date: PlainDate | null) =>\n date === null ? \"\" : formatDate(date, locale);\n const kind: PickerKind<DateRange, RangeCalendarDetails> = {\n name: \"RangeCalendar\",\n defaultFormat: (range) => (range === null ? \"\" : write(range)),\n details: ({ value: range }) =>\n rangeDetails(\n dateRangeKind,\n range,\n \"all\",\n {\n start: writeEnd(range?.start ?? null),\n end: writeEnd(range === null ? null : lastDayOf(range, bounds)),\n },\n bounds,\n ruleContext,\n ),\n display: write,\n isValue: isDateRange,\n equals: (a, b) => sameRange(dateRangeKind, a, b),\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<DateRange>()] : []),\n ...validatorsOf(validate),\n ],\n [needsValue, validate],\n );\n const picker = usePickerField(\n { ...props, required, validate: validators },\n kind,\n focusedDayIn,\n );\n const { rootId, readOnly, disabled } = picker;\n const { value } = picker.state;\n\n const [fitted, setFitted] = useState(2);\n const shownMonths = visibleMonths ?? fitted;\n const limits: CalendarLimits = useMemo(\n () => ({ min, max, isDateDisabled }),\n [min, max, isDateDisabled],\n );\n const nav = useCalendarNavigation({\n focus: value?.start ?? value?.end ?? today(),\n context: { firstDayOfWeek: firstDay, visibleMonths: shownMonths, limits },\n });\n\n const [pick, setPick] = useState<RangePick>(IDLE);\n const latestPick = useRef(pick);\n useLayoutEffect(() => {\n latestPick.current = pick;\n });\n const [announcement, setAnnouncement] = useState(\"\");\n // A mouse or pen press picks through its pointer events, so the click that follows it is not a choice.\n const pointerPicked = useRef(false);\n\n const [root, setRootElement] = useState<HTMLDivElement | null>(null);\n const { setRoot } = picker;\n const navSetRoot = nav.setRoot;\n const rootRef = useCallback<RefCallback<HTMLDivElement>>(\n (element) => {\n navSetRoot(element);\n setRoot(element);\n setRootElement(element);\n },\n [navSetRoot, setRoot],\n );\n const automatic = visibleMonths === undefined;\n useLayoutEffect(() => {\n if (root === null || !automatic) {\n return undefined;\n }\n const watch = attachFitCount(root, { max: 2, onCount: setFitted });\n return () => {\n watch.detach();\n };\n }, [root, automatic]);\n\n const shownToday = useToday(timeZone);\n const ownMessagesId = useOwnMessagesId(rootId);\n const hidden = hiddenInputs(props.name, props.form, disabled, [\n [\".start\", value?.start ?? \"\"],\n [\".end\", value?.end ?? \"\"],\n ]);\n\n if (picker.mode === \"display\") {\n return (\n <div\n className={classNames(\n \"gridkit-forms-range-calendar\",\n \"is-display\",\n className,\n )}\n style={style}\n >\n <DisplayValue\n text={picker.displayText}\n emptyText={picker.strings.emptyValue}\n />\n {hidden}\n </div>\n );\n }\n\n const selectable = (date: PlainDate) =>\n !readOnly && !disabled && !isCalendarDayDisabled(date, limits);\n\n function run(action: RangePickAction, nativeEvent: Event | null) {\n const step = rangePickReducer(latestPick.current, action, selectable);\n if (step.state !== latestPick.current) {\n latestPick.current = step.state;\n setPick(step.state);\n }\n if (step.picked === null) {\n return;\n }\n const { first, last } = step.picked;\n const range: DateRange = {\n start: first,\n end: bounds === \"[)\" ? addDays(last, 1) : last,\n };\n if (nativeEvent !== null) {\n picker.pick(range, nativeEvent);\n }\n setAnnouncement(\n formatDateRange(range, {\n locale,\n messages: picker.strings,\n bounds,\n displayFormat: { dateStyle: \"long\" },\n }),\n );\n }\n\n function onPointerDown(event: PointerEvent<HTMLDivElement>) {\n const date = dateOf(event.target);\n pointerPicked.current = false;\n if (event.pointerType === \"touch\" || event.button !== 0 || date === null) {\n return;\n }\n pointerPicked.current = true;\n run({ type: \"press\", date }, event.nativeEvent);\n if (latestPick.current.kind === \"dragging\") {\n event.currentTarget.setPointerCapture(event.pointerId);\n }\n }\n\n /** The day under the pointer: a captured pointer's events all go to the root. */\n function dayAt(event: PointerEvent): PlainDate | null {\n return latestPick.current.kind === \"dragging\"\n ? dateOf(document.elementFromPoint(event.clientX, event.clientY))\n : dateOf(event.target);\n }\n\n function onPointerMove(event: PointerEvent<HTMLDivElement>) {\n if (event.pointerType === \"touch\") {\n return;\n }\n const date = dayAt(event);\n if (date !== null) {\n run({ type: \"preview\", date }, event.nativeEvent);\n }\n }\n\n function onPointerUp(event: PointerEvent<HTMLDivElement>) {\n if (latestPick.current.kind !== \"dragging\") {\n return;\n }\n const date = dayAt(event);\n if (date !== null) {\n run({ type: \"preview\", date }, event.nativeEvent);\n }\n run({ type: \"release\" }, event.nativeEvent);\n if (date !== null) {\n nav.dispatch({ type: \"focus\", date });\n nav.focusDay();\n }\n }\n\n const preview = rangePickPreview(pick);\n const shown = preview ?? (value === null ? null : daysOf(value, bounds));\n const look: CalendarLook = {\n rootId,\n locale,\n strings: picker.strings,\n firstDayOfWeek: firstDay,\n weekNumbering,\n weekNumbers,\n weekend: weekInfo(locale).weekend,\n limits,\n today: shownToday,\n focused: nav.state.focused,\n disabled,\n readOnly,\n range: true,\n marks: (date) => marksIn(shown, date, preview !== null),\n };\n\n return (\n <div\n ref={rootRef}\n id={rootId}\n className={classNames(\n \"gridkit-forms-range-calendar\",\n pick.kind !== \"idle\" && \"is-picking\",\n disabled && \"is-disabled\",\n readOnly && \"is-read-only\",\n picker.invalid && \"is-invalid\",\n className,\n )}\n style={style}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy ??\n (ariaLabel === undefined\n ? joinIds(picker.fieldLabelId, titleId(rootId, 0))\n : undefined)\n }\n aria-describedby={joinIds(\n picker.describedBy,\n ownMessagesId,\n ariaDescribedBy,\n )}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={(event) => {\n run({ type: \"lose\" }, event.nativeEvent);\n }}\n onLostPointerCapture={(event) => {\n run({ type: \"lose\" }, event.nativeEvent);\n }}\n >\n <CalendarBody\n nav={nav}\n look={look}\n visibleMonths={shownMonths}\n onDayClick={(date, event) => {\n if (pointerPicked.current) {\n pointerPicked.current = false;\n return;\n }\n run({ type: \"choose\", date }, event.nativeEvent);\n }}\n onChooseKey={(date, event) => {\n run({ type: \"choose\", date }, event.nativeEvent);\n }}\n onFocusMoved={(date) => {\n run({ type: \"preview\", date }, null);\n }}\n onOtherKey={(event) => {\n if (event.key === \"Escape\" && latestPick.current.kind !== \"idle\") {\n event.preventDefault();\n run({ type: \"cancel\" }, event.nativeEvent);\n }\n }}\n />\n <span className=\"gridkit-forms-sr-only\" aria-live=\"polite\">\n {announcement}\n </span>\n {hidden}\n <OwnMessages\n id={`${rootId}-messages`}\n messages={picker.messages}\n strings={picker.strings}\n named\n />\n </div>\n );\n}\n","import {\n addKeys,\n clearKeys,\n DEFAULT_MATCH_FIELDS,\n type ChangeSource,\n type ChoiceOption,\n type OptionKey,\n type PopupCloseReason,\n} from \"@gridkitjs/forms-core\";\nimport type { ListboxChoice } from \"@gridkitjs/forms-dom\";\nimport { useLayoutEffect, useState } from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n densityClass,\n InputFrame,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport {\n COMMITTING_CLOSES,\n multipleShape,\n NO_OPTIONS,\n selectAllScope,\n singleShape,\n} from \"./selectModel\";\nimport type {\n MultipleSelectProps,\n SelectControlProps,\n SelectProps,\n SingleSelectProps,\n} from \"./selectProps\";\nimport { SelectPopup } from \"./SelectPopup\";\nimport { SelectTrigger } from \"./SelectTrigger\";\nimport { useChoiceHandle, useChoicePopup } from \"./useChoicePopup\";\nimport { useChoiceAnnouncer, useChoiceCombobox } from \"./useCombobox\";\nimport { useCreateOption } from \"./useCreateOption\";\nimport { useListActivation } from \"./useListActivation\";\nimport { useChipsFocus, useMultipleChoice } from \"./useMultipleChoice\";\nimport { chooseRow, useOptionRows } from \"./useOptionRows\";\nimport { useSelectField } from \"./useSelectField\";\n\nexport type {\n ChoiceHandle,\n MultipleSelectProps,\n SelectCommonProps,\n SelectProps,\n SingleSelectProps,\n} from \"./selectProps\";\n\nfunction SelectControl<K extends OptionKey, T, F, V, D extends object>({\n shape,\n options = NO_OPTIONS,\n source,\n filters,\n valueOptions = NO_OPTIONS,\n cache,\n match = \"contains\",\n matchFields = DEFAULT_MATCH_FIELDS,\n renderOption,\n virtualize,\n disabledOptions = \"skip\",\n searchable = false,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n columns,\n renderValue,\n onOpenChange,\n onQueryChange,\n onHighlightChange,\n onLoadError,\n onCreate,\n allowCustomValue = false,\n maxCount,\n minCount,\n selectAll: selectAllRow = false,\n maxChips,\n ref,\n handleRef,\n validate,\n loading = false,\n density,\n autoFocus,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: SelectControlProps<K, T, F, V, D>) {\n type O = ChoiceOption<K, T>;\n const { multiple } = shape;\n const settings = useFormSettings();\n const selectField = useSelectField<K, T, F, V, D>({\n field: props,\n ref,\n shape,\n options,\n valueOptions,\n source,\n filters,\n cache,\n match,\n matchFields,\n onLoadError,\n searchable,\n allowCustomValue,\n creates: onCreate !== undefined,\n maxCount,\n minCount,\n validate,\n onQueryChange,\n onQuery: askSource,\n });\n const { choice, chosenKeys, catalog, search, byLabel, locale } = selectField;\n const { searchText, customValue } = selectField;\n const { controller: sourceController, sourced, listed } = catalog;\n const { pagedMore, optionOf, lookupOf } = catalog;\n const { controller, state, control, strings } = choice;\n const { query, current: currentQuery, setTyped } = search;\n\n const display = choice.mode === \"display\";\n const interactive = !display && !choice.readOnly && !choice.disabled;\n const resolvedDensity = density ?? settings.density;\n const controlId = choice.controlId;\n const listId = `${controlId}-list`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const [root, setRoot] = useState<HTMLDivElement | null>(null);\n const focus = useChipsFocus(controller);\n const announcer = useChoiceAnnouncer(\n root,\n strings,\n catalog.failed ? catalog.state : null,\n );\n\n const { value } = state;\n const limit = multiple ? (maxCount ?? null) : null;\n\n const list = useChoicePopup<O>({\n enabled: interactive,\n onOpenChange,\n onHighlightChange,\n onOpening: (reason) => {\n activation.opened(reason);\n // Labels that failed to load are asked again.\n catalog.askAgain();\n },\n onOpened: (reason) => {\n catalog.opened(reason === \"typing\", currentQuery());\n },\n onClosed: (reason, changed) => {\n afterClose(reason, changed);\n },\n });\n const { popup, open, listbox: shownListbox, active } = list;\n\n /** Typing asks the source for the search text while the list shows. */\n function askSource(query: string, source: ChangeSource): void {\n if (list.isOpen()) {\n catalog.searched(query, source);\n }\n }\n\n const multi = useMultipleChoice<K, T, F, V, D>({\n shape,\n controller,\n chosenKeys,\n limit,\n strings,\n showChips: multiple && renderValue === undefined,\n optionOf,\n lookupOf,\n announcer,\n isOpen: list.isOpen,\n onChangedWhileOpen: list.markChanged,\n allKeys: source?.allKeys ?? null,\n query: () => ({ text: currentQuery(), filters: filters as F }),\n });\n const { changeKeys, chips, removeChip } = multi;\n\n /** An option chosen with one value: commits it and closes. */\n function pickOne(key: K, nativeEvent: Event | null): void {\n // A Tab that chooses is the commit: the one that follows commits nothing more.\n const tab =\n nativeEvent instanceof KeyboardEvent && nativeEvent.key === \"Tab\";\n choice.pick(shape.fromKeys([key]), tab ? \"tab\" : \"picker\", nativeEvent);\n popup.close(\"picker\");\n }\n\n /** An option the app made from the search text: known from now on, and chosen. */\n const creator = useCreateOption<O>(onCreate, (option, nativeEvent) => {\n sourceController.getCache().addOptions([option]);\n if (!multiple) {\n pickOne(option.value, nativeEvent);\n return;\n }\n const held = shape.keys(controller.getState().value);\n changeKeys(addKeys(held, [option.value], limit), \"picker\", nativeEvent);\n if (searchable) {\n setTyped(\"\", \"picker\", nativeEvent);\n }\n });\n\n /** What closing does besides closing: drops the search text and the list, and commits ticks. */\n function afterClose(reason: PopupCloseReason, changed: boolean): void {\n announcer()?.cancel();\n sourceController.close();\n creator.cancel();\n multi.cancelSelectAll();\n dropList();\n search.drop(reason);\n if (multiple && changed && COMMITTING_CLOSES.has(reason)) {\n controller.commit(\"picker\", null);\n }\n }\n\n const optionRows = useOptionRows<K, T>({\n listed,\n query,\n match,\n matchFields,\n locale,\n sourced,\n chosenKeys,\n limit,\n byLabel,\n canCreate: onCreate !== undefined && searchable,\n selectAll: selectAllScope(\n multiple && selectAllRow,\n pagedMore,\n source?.allKeys !== undefined,\n ),\n retry: catalog.failed,\n strings,\n selectingAll: multi.selectingAll,\n creating: creator.creation.kind === \"waiting\",\n });\n const { rows, shownOptions, isDisabled } = optionRows;\n\n const activation = useListActivation({\n listbox: shownListbox,\n // What the list has settled on: its query, once a source answered it.\n settled: !sourced\n ? query\n : catalog.state.kind === \"loaded\"\n ? catalog.state.query.text\n : null,\n searchable,\n rows: optionRows.navigableRows,\n chosenRow: optionRows.chosenRow,\n typingHighlights: !customValue,\n disabledOptions,\n resultCount: shownOptions.length,\n announcer,\n });\n\n function onChoose(row: number, picked: ListboxChoice, event: Event): void {\n chooseRow(optionRows, row, event, {\n selectAll: (nativeEvent) => {\n multi.chooseAll(shownOptions, pagedMore, nativeEvent);\n },\n create: creator.create,\n retry: sourceController.retry,\n option: (option, nativeEvent) => {\n const disabled = isDisabled(option);\n if (multiple) {\n multi.chooseOption(\n {\n rows,\n row,\n option,\n picked,\n disabled,\n shown: shownOptions,\n pagedMore,\n },\n nativeEvent,\n );\n } else if (!disabled) {\n pickOne(option.value, nativeEvent);\n }\n },\n });\n }\n\n const dropList = useChoiceCombobox({\n control,\n controller,\n enabled: !display,\n listbox: shownListbox,\n root,\n editable: searchable,\n multiple,\n drivesField: !searchText,\n // A search box chooses on Tab only once something was typed.\n tabChooses: !customValue && (!searchable || query !== \"\"),\n readOnly: !interactive,\n onOpenRequest: (reason, nativeEvent) => {\n activation.request(reason, nativeEvent);\n popup.open(reason);\n },\n onClose: popup.close,\n onChipKey: chips.length > 0 && interactive ? multi.chipKey : undefined,\n });\n\n // Changes made from code end the search too.\n useLayoutEffect(() => {\n search.report(\"api\", null);\n });\n\n useChoiceHandle(handleRef, control, controller, popup, sourceController);\n\n const rootClass = classNames(\n \"gridkit-forms-select\",\n multiple && \"is-multiple\",\n searchable && \"is-searchable\",\n open && \"is-open\",\n value === null && \"is-empty\",\n display && \"is-display\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (display) {\n return (\n <div className={rootClass} style={style}>\n <DisplayValue text={choice.text} emptyText={strings.emptyValue} />\n {choice.hiddenInputs}\n </div>\n );\n }\n\n function clearValue(nativeEvent: Event): void {\n const kept = clearKeys(\n chosenKeys,\n (key) => optionOf(key)?.disabled === true,\n );\n choice.clear(nativeEvent, kept === null ? null : shape.fromKeys(kept));\n }\n\n return (\n <div\n ref={setRoot}\n className={rootClass}\n style={style}\n onFocus={focus.onFocus}\n onBlur={focus.onBlur}\n >\n <SelectTrigger\n choice={choice}\n popup={popup}\n open={open}\n active={active}\n searchable={searchable}\n searchText={searchText}\n customValue={customValue}\n interactive={interactive}\n clearable={clearable}\n onClear={clearValue}\n keys={chosenKeys}\n multiple={multiple}\n renderValue={renderValue}\n placeholder={placeholder}\n optionOf={optionOf}\n lookupOf={lookupOf}\n chips={chips}\n collapsed={!focus.focusWithin}\n maxChips={maxChips}\n onRemoveChip={removeChip}\n chipList={multi.chipList}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n suffix={suffix}\n autoFocus={autoFocus}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n ownMessagesId={ownMessagesId}\n listId={listId}\n />\n {choice.hiddenInputs}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={choice.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n <SelectPopup\n popup={popup}\n density={resolvedDensity}\n optionRows={optionRows}\n catalog={catalog}\n minQueryLength={source?.minQueryLength ?? 0}\n creation={creator.creation}\n limit={limit}\n strings={strings}\n id={listId}\n query={query}\n multiple={multiple}\n active={active}\n columns={columns}\n renderOption={renderOption}\n virtualize={virtualize}\n locale={locale}\n disabledOptions={disabledOptions}\n typeahead={!searchable}\n aria-label={choice.fieldLabelId === undefined ? ariaLabel : undefined}\n aria-labelledby={choice.fieldLabelId ?? ariaLabelledBy}\n onListbox={list.setListbox}\n onActiveChange={list.onActiveChange}\n onChoose={onChoose}\n />\n </div>\n );\n}\n\nfunction SingleSelect<K extends OptionKey, T, F>(\n props: SingleSelectProps<K, T, F>,\n) {\n const [shape] = useState(singleShape<K, T>);\n return <SelectControl {...props} shape={shape} />;\n}\n\nfunction MultipleSelect<K extends OptionKey, T, F>(\n props: MultipleSelectProps<K, T, F>,\n) {\n const [shape] = useState(multipleShape<K, T>);\n return <SelectControl {...props} shape={shape} />;\n}\n\n/**\n * A choice from a list of options: a button-like control that opens the\n * list, or with `searchable` a text box that filters it as it is typed in.\n * Its value is the chosen option's key (`option.value`), `null` when\n * nothing is chosen; with `multiple`, the chosen keys in the order chosen,\n * shown as chips. Options can sit in groups, show a description or extra\n * columns, or be drawn by `renderOption`; long lists draw only the options\n * in view, and a `source` loads them page by page from a server. It\n * follows the WAI-ARIA combobox, with focus kept in the control, and takes\n * every shared input prop: display mode, `readOnly`, `disabled`, messages\n * with their severity, density and the events of `@gridkitjs/forms`,\n * whose details carry the chosen options.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function Select<K extends OptionKey, T = unknown, F = undefined>(\n props: SelectProps<K, T, F>,\n) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n {props.multiple === true ? (\n <MultipleSelect {...props} />\n ) : (\n <SingleSelect {...props} />\n )}\n </InputFrame>\n );\n}\n","import {\n choiceDetails,\n maxCountRule,\n minCountRule,\n requiredChoiceRule,\n foldText,\n keyText,\n parsed,\n sameKey,\n sameKeys,\n singleChoiceDetails,\n toKeyList,\n valueKeys,\n type ChoiceDetails,\n type ChoiceOption,\n type FieldState,\n type OptionKey,\n type ParseResult,\n type PopupCloseReason,\n type SingleChoiceDetails,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport { validatorsOf } from \"../useFieldInput\";\nimport { queryOf, type ChoiceKind } from \"./useChoiceField\";\n\n/** How a select's value holds its keys: one, or several. */\nexport interface SelectShape<K extends OptionKey, T, V, D extends object> {\n readonly multiple: boolean;\n readonly keys: (value: V | null) => readonly K[];\n readonly fromKeys: (keys: readonly K[]) => V | null;\n readonly details: (\n value: V | null,\n previous: V | null,\n optionOf: (key: K) => ChoiceOption<K, T> | null,\n query: string,\n ) => D;\n readonly equals?: ((a: V, b: V) => boolean) | undefined;\n}\n\nexport function singleShape<K extends OptionKey, T>(): SelectShape<\n K,\n T,\n K,\n SingleChoiceDetails<ChoiceOption<K, T>>\n> {\n return {\n multiple: false,\n keys: (value) => (value === null ? [] : [value]),\n fromKeys: (keys) => keys.at(-1) ?? null,\n details: singleChoiceDetails,\n };\n}\n\nexport function multipleShape<K extends OptionKey, T>(): SelectShape<\n K,\n T,\n readonly K[],\n ChoiceDetails<ChoiceOption<K, T>>\n> {\n return {\n multiple: true,\n keys: valueKeys,\n fromKeys: toKeyList,\n details: choiceDetails,\n equals: sameKeys,\n };\n}\n\n/** A validator of keys run on a select's value, whatever its shape. */\nexport function countRule<K extends OptionKey, T, V, D extends object>(\n rule: Validator<readonly K[]>,\n shape: SelectShape<K, T, V, D>,\n): Validator<V> {\n return (value, context) => rule(toKeyList(shape.keys(value)), context);\n}\n\n/** Above this many rows, a local list draws only the rows in view. */\nexport const VIRTUALIZE_ABOVE = 100;\n\n/** Closing for these leaves focus in the field, so a multiple select commits its ticks as it closes. */\nexport const COMMITTING_CLOSES: ReadonlySet<PopupCloseReason> = new Set([\n \"escape\",\n \"button\",\n \"scroll\",\n \"resize\",\n]);\n\nexport const NO_OPTIONS: readonly never[] = [];\n\n/** The option a key stands for, among `options`: the first that holds it. */\nexport function optionFinder<K extends OptionKey, T>(\n options: readonly ChoiceOption<K, T>[],\n): (key: K) => ChoiceOption<K, T> | null {\n const byText = new Map<string, ChoiceOption<K, T>>();\n for (const option of options) {\n const text = keyText(option.value);\n if (!byText.has(text)) {\n byText.set(text, option);\n }\n }\n return (key) => {\n const option = byText.get(keyText(key));\n return option !== undefined && sameKey(option.value, key) ? option : null;\n };\n}\n\n/** Formats chosen labels as one text, \"Red, Green and Blue\", per locale. */\nconst listFormats = new Map<string, Intl.ListFormat>();\n\nfunction listFormat(locale: Intl.LocalesArgument): Intl.ListFormat {\n const key = locale === undefined ? \"\" : String(locale);\n let format = listFormats.get(key);\n if (format === undefined) {\n format = new Intl.ListFormat(locale, { type: \"conjunction\" });\n listFormats.set(key, format);\n }\n return format;\n}\n\n/** What a select's `ChoiceKind` is made from. */\nexport interface SelectKindOptions<\n K extends OptionKey,\n T,\n V,\n D extends object,\n> {\n readonly shape: SelectShape<K, T, V, D>;\n readonly optionOf: (key: K) => ChoiceOption<K, T> | null;\n /** The search box's text is the field's own: one value. */\n readonly searchText: boolean;\n /** Free text no label matches commits as the key: `allowCustomValue`. */\n readonly customValue: boolean;\n /** Options by their folded label, for free text that names one. */\n readonly byLabel: ReadonlyMap<string, ChoiceOption<K, T>>;\n readonly locale: Intl.LocalesArgument;\n /** The typed query of a search box holding only a query. */\n readonly typedQuery: () => string;\n}\n\n/**\n * A select's `ChoiceKind`: its labels as text (a list of them with several\n * values), typed text as a search unless it is free text, its details and\n * the keys a form submits.\n */\nexport function selectKind<K extends OptionKey, T, V, D extends object>({\n shape,\n optionOf,\n searchText,\n customValue,\n byLabel,\n locale,\n typedQuery,\n}: SelectKindOptions<K, T, V, D>): ChoiceKind<V, D> {\n const { multiple } = shape;\n return {\n defaultFormat: (value, context) => {\n const labels = shape\n .keys(value)\n .map((key) => optionOf(key)?.label ?? keyText(key));\n return multiple\n ? listFormat(context.locale).format(labels)\n : (labels[0] ?? \"\");\n },\n defaultParse: (text, current): ParseResult<V> => {\n if (!customValue) {\n // Only a pick changes the value: typed text is a search.\n return parsed(current);\n }\n const wanted = foldText(text.trim(), locale).text;\n if (wanted === \"\") {\n return parsed(null);\n }\n const exact = byLabel.get(wanted);\n // `allowCustomValue` is for string keys, as its docs say: the text\n // is the key.\n const key = exact?.value ?? (text.trim() as K);\n return parsed(shape.fromKeys([key]));\n },\n details: (current: FieldState<V>, previous: FieldState<V>) =>\n shape.details(\n current.value,\n previous.value,\n optionOf,\n searchText ? queryOf(current) : typedQuery(),\n ),\n submitted: (value) => {\n const keys = shape.keys(value).map(keyText);\n return multiple ? keys : [keys[0] ?? \"\"];\n },\n equals: shape.equals,\n };\n}\n\nexport function isThenable<R>(value: R | Promise<R>): value is Promise<R> {\n return value instanceof Promise;\n}\n\n/** What a select validates: a value when required, the count with several, and the app's rules. */\nexport function selectValidators<K extends OptionKey, T, V, D extends object>({\n shape,\n needsValue,\n maxCount,\n minCount,\n validate,\n}: {\n readonly shape: SelectShape<K, T, V, D>;\n readonly needsValue: boolean;\n readonly maxCount: number | undefined;\n readonly minCount: number | undefined;\n readonly validate: Validator<V> | readonly Validator<V>[] | undefined;\n}): readonly Validator<V>[] {\n const { multiple } = shape;\n return [\n ...(needsValue ? [requiredChoiceRule<V>()] : []),\n ...(multiple && maxCount !== undefined\n ? [countRule(maxCountRule<K>(maxCount), shape)]\n : []),\n ...(multiple && minCount !== undefined\n ? [countRule(minCountRule<K>(minCount), shape)]\n : []),\n ...validatorsOf(validate),\n ];\n}\n\n/** The scope of a multiple select's \"Select all\" row, or `null` without one. */\nexport function selectAllScope(\n shown: boolean,\n pagedMore: boolean,\n everyKey: boolean,\n): \"matching\" | \"loaded\" | \"all\" | null {\n if (!shown) {\n return null;\n }\n if (!pagedMore) {\n return \"matching\";\n }\n return everyKey ? \"all\" : \"loaded\";\n}\n","import {\n createFieldController,\n hasError,\n sortFieldMessages,\n type ChangeCause,\n type CommitTrigger,\n type FieldController,\n type FieldMessage,\n type FieldOptions,\n type FieldState,\n type FormatContext,\n type FormsMessages,\n type ParseResult,\n type Severity,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachTextInput,\n attachValidityCarrier,\n type AttachedTextInput,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactElement,\n type Ref,\n type RefCallback,\n} from \"react\";\nimport type { FieldClearEvent } from \"../events\";\nimport { setRef } from \"../refs\";\nimport type { FieldMode } from \"../settings\";\nimport {\n isFocused,\n useControllerLifecycle,\n useFieldReport,\n useInputSettings,\n useShownMessages,\n type FieldInputProps,\n} from \"../useFieldInput\";\n\n/** How a choice input reads, writes and submits its value. */\nexport interface ChoiceKind<V, D extends object> {\n /** The value as text: the chosen labels, what events carry as `text`. */\n readonly defaultFormat: (\n value: V | null,\n context: FormatContext<V>,\n ) => string;\n /**\n * What the search box's text reads as when it is committed, given the\n * value held: a select keeps its value whatever is typed, since only a\n * pick changes it.\n */\n readonly defaultParse: (text: string, current: V | null) => ParseResult<V>;\n readonly details: (\n current: FieldState<V>,\n previous: FieldState<V>,\n cause: ChangeCause<Event>,\n ) => D;\n /** The hidden inputs' values: one per key, `[\"\"]` for an empty single value. */\n readonly submitted: (value: V | null) => readonly string[];\n readonly equals?: ((a: V, b: V) => boolean) | undefined;\n}\n\n/** The props `useChoiceField` reads. */\nexport type ChoiceFieldProps<V, D extends object> = Omit<\n FieldInputProps<V, HTMLInputElement, D>,\n \"ref\" | \"handleRef\" | \"parse\" | \"format\" | \"validate\"\n> & {\n /** The validators, the input's own `required` check among them. */\n readonly validators: FieldOptions<V, D, Event>[\"validators\"];\n /**\n * Messages the input finds itself beside the validators': a chosen key\n * whose option no longer exists. They describe the value as it came,\n * so they show at once, not only once the validators' are revealed.\n * Memoized: it is asked again only when it or the state changes.\n */\n readonly notices?:\n | ((value: V | null, messages: FormsMessages) => readonly FieldMessage[])\n | undefined;\n};\n\n/** What `useChoiceField` gives the input that calls it, to draw. */\nexport interface ChoiceField<V, D extends object> {\n readonly controller: FieldController<V, D, Event>;\n readonly state: FieldState<V>;\n /** The text the control shows: the chosen labels, or the typed search text. */\n readonly text: string;\n /** The search text typed since the last commit; `\"\"` when the labels show. */\n readonly query: string;\n readonly messages: readonly FieldMessage[];\n readonly severity: Severity | null;\n readonly invalid: boolean;\n readonly mode: FieldMode;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n /** The input's own `required`, or the `Field`'s. */\n readonly required: boolean;\n /** The control's `id`: the `Field`'s, the props', else one of its own. */\n readonly controlId: string;\n /** The `Field`'s label, when the input is in one. */\n readonly fieldLabelId: string | undefined;\n /** The `Field`'s description and messages. */\n readonly describedBy: string | undefined;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** The focusable control, while it is in the page. */\n readonly control: HTMLElement | null;\n /** The ref of the control: the search box, or the select-only button. */\n readonly setControl: RefCallback<HTMLElement>;\n /** The ref of the hidden input a select-only control's errors are held on. */\n readonly setCarrier: RefCallback<HTMLInputElement>;\n /** A value chosen whole, then committed with `trigger`: `source` `\"picker\"`. */\n readonly pick: (\n value: V | null,\n trigger: CommitTrigger,\n nativeEvent: Event | null,\n ) => void;\n /**\n * Fires `onClear`, then empties the field and commits it (`source` and\n * `trigger` `\"clear\"`), down to `kept` when given: the chosen options\n * the user may not remove.\n */\n readonly clear: (nativeEvent: Event | null, kept?: V | null) => void;\n /** The hidden inputs carrying `name`; `null` without one. */\n readonly hiddenInputs: ReactElement[] | null;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/** The search text a choice field's state holds: typed text not yet committed. */\nexport function queryOf<V>(state: FieldState<V>): string {\n return state.draft.kind === \"text\" ? state.draft.text : \"\";\n}\n\n/**\n * Binds a choice input (a select) to one field, as `useFieldInput` binds a\n * text control: forms-core's controller, made once and handed the latest\n * props on every render, a controlled `value`, and the `Field` and form\n * around it.\n *\n * With `searchText`, the control is a search box whose text is the\n * field's: forms-dom's text pipeline drives it, so its typing is the\n * field's draft (the query), read with `kind.defaultParse` when it\n * commits, and it is written again whenever the labels change without the\n * field changing. Without, the control is a select-only button, or a\n * search box holding only a query (several values, shown as chips): the\n * combobox calls the controller's focus, blur and commits, and its errors\n * are held on the hidden carrier input.\n */\nexport function useChoiceField<V, D extends object>(\n props: ChoiceFieldProps<V, D>,\n kind: ChoiceKind<V, D>,\n searchText: boolean,\n ref: Ref<HTMLElement> | undefined,\n): ChoiceField<V, D> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const fieldOptions: FieldOptions<V, D, Event> = {\n value: props.value,\n defaultValue: props.defaultValue,\n // Called only once the controller exists, as typed text is read.\n defaultParse: (text) =>\n kind.defaultParse(text, controller.getState().value),\n defaultFormat: kind.defaultFormat,\n equals: kind.equals,\n details: kind.details,\n validators: props.validators,\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [controller] = useState(() => createFieldController(fieldOptions));\n controller.setOptions(fieldOptions);\n const state = useSyncExternalStore(\n controller.subscribe,\n controller.getState,\n controller.getState,\n );\n useControllerLifecycle(controller, props.value, form);\n\n const [control, setControlElement] = useState<HTMLElement | null>(null);\n const setControl = useCallback<RefCallback<HTMLElement>>(\n (element) => {\n setControlElement(element);\n const release = setRef(ref, element);\n return () => {\n setControlElement(null);\n release?.();\n };\n },\n [ref],\n );\n const [carrier, setCarrier] = useState<HTMLInputElement | null>(null);\n\n const { onClear } = props;\n const fireClear = (nativeEvent: Event | null): void => {\n const event: FieldClearEvent<V> = {\n previousValue: controller.getState().value,\n previousText: controller.getText(),\n nativeEvent,\n };\n onClear?.(event);\n };\n\n const pipeline = useRef<AttachedTextInput | null>(null);\n useLayoutEffect(() => {\n if (!searchText || !(control instanceof HTMLInputElement)) {\n return undefined;\n }\n const attached = attachTextInput(control, controller, {\n escape: \"revert\",\n });\n pipeline.current = attached;\n return () => {\n attached.detach();\n pipeline.current = null;\n };\n }, [searchText, control, controller]);\n // The labels can change with the options while the field does not, so\n // nothing else would write the search box again.\n useLayoutEffect(() => {\n pipeline.current?.refresh();\n });\n\n useLayoutEffect(() => {\n if (searchText || control === null || carrier === null) {\n return undefined;\n }\n return attachValidityCarrier(carrier, control, controller).detach;\n }, [searchText, control, carrier, controller]);\n\n const text = controller.getText();\n // A disabled field is not validated, so it shows none of its own messages.\n const { notices } = props;\n const own = useMemo(() => {\n if (disabled) {\n return NO_MESSAGES;\n }\n const validated = state.revealed ? controller.getMessages() : NO_MESSAGES;\n const noticed = notices?.(state.value, messages) ?? NO_MESSAGES;\n return noticed.length === 0\n ? validated\n : sortFieldMessages([...validated, ...noticed]);\n }, [state, disabled, notices, messages, controller]);\n const { shown, severity } = useShownMessages(\n own,\n props.message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.phase),\n empty: text === \"\",\n required,\n });\n\n return {\n controller,\n state,\n text,\n query: queryOf(state),\n messages: shown,\n severity,\n invalid:\n hasError(shown) || props.invalid === true || field?.invalid === true,\n mode,\n readOnly,\n disabled,\n required: required || field?.required === true,\n controlId: field?.controlId ?? props.id ?? ownId,\n fieldLabelId:\n field === null || field.controlId === null\n ? undefined\n : `${field.controlId}-label`,\n describedBy: field?.describedBy,\n locale,\n strings: messages,\n control,\n setControl,\n setCarrier,\n pick: (value, trigger, nativeEvent) => {\n controller.pick(value, \"picker\", trigger, nativeEvent);\n },\n clear: (nativeEvent, kept = null) => {\n fireClear(nativeEvent);\n if (kept === null) {\n controller.clear(nativeEvent);\n } else {\n controller.pick(kept, \"clear\", \"clear\", nativeEvent);\n }\n },\n hiddenInputs:\n props.name === undefined\n ? null\n : kind\n .submitted(state.value)\n .map((submitted, index) => (\n <input\n key={index}\n type=\"hidden\"\n name={props.name}\n form={props.form}\n disabled={disabled}\n value={submitted}\n />\n )),\n };\n}\n","import {\n flattenOptions,\n type ChoiceOption,\n type FormsMessages,\n type OptionKey,\n} from \"@gridkitjs/forms-core\";\nimport type { ListboxActivation } from \"@gridkitjs/forms-dom\";\nimport { useMemo } from \"react\";\nimport { classNames } from \"../field/parts\";\nimport type { PickerPopup } from \"../picker/usePickerPopup\";\nimport type { Density } from \"../settings\";\nimport { densityClass } from \"../text/parts\";\nimport { ChoicePopup } from \"./ChoicePopup\";\nimport { ChoiceStatus, choiceStatus } from \"./ChoiceStatus\";\nimport { VIRTUALIZE_ABOVE } from \"./selectModel\";\nimport { OptionList, type OptionListProps } from \"./OptionList\";\nimport type { ChoiceOptions } from \"./useChoiceOptions\";\nimport type { Creation } from \"./useCreateOption\";\nimport type { OptionRows } from \"./useOptionRows\";\n\n/** What a select's popup draws from: the list's own props, and where its rows and source stand. */\nexport type SelectPopupProps<K extends OptionKey, T, F> = Omit<\n OptionListProps<ChoiceOption<K, T>>,\n | \"rows\"\n | \"matches\"\n | \"isSelected\"\n | \"isDisabled\"\n | \"describeAction\"\n | \"stale\"\n | \"busy\"\n | \"setSize\"\n | \"onNearEnd\"\n | \"onActiveChange\"\n | \"virtualize\"\n> & {\n /** Draws only the rows in view; by default with a source or a long list. */\n readonly virtualize: boolean | undefined;\n readonly popup: PickerPopup;\n readonly density: Density;\n readonly optionRows: OptionRows<K, T>;\n readonly catalog: ChoiceOptions<K, T, F>;\n /** The source's `minQueryLength`. */\n readonly minQueryLength: number;\n readonly creation: Creation;\n /** The most keys the value may hold, or `null`. */\n readonly limit: number | null;\n readonly strings: FormsMessages;\n /** The active row moved, onto `option` or a row that is not one. */\n readonly onActiveChange: (\n row: number | null,\n option: ChoiceOption<K, T> | null,\n by: ListboxActivation,\n ) => void;\n};\n\n/**\n * A select's popup: its option list, the source's next page asked for as\n * the list nears its end, and the status lines under it.\n */\nexport function SelectPopup<K extends OptionKey, T, F>({\n popup,\n density,\n optionRows,\n catalog,\n minQueryLength,\n creation,\n limit,\n strings,\n onActiveChange,\n virtualize,\n ...list\n}: SelectPopupProps<K, T, F>) {\n const { rows, shownOptions } = optionRows;\n const { sourced, loaded, pagedMore, listed } = catalog;\n const allRowCount = useMemo(\n () => (sourced ? 0 : flattenOptions(listed).length),\n [sourced, listed],\n );\n const optionCount = shownOptions.length;\n return (\n <ChoicePopup\n picker={popup}\n className={classNames(\n \"gridkit-forms-select-popup\",\n densityClass(density),\n )}\n >\n <OptionList\n {...list}\n virtualize={virtualize ?? (sourced || allRowCount > VIRTUALIZE_ABOVE)}\n rows={rows}\n matches={optionRows.matches}\n isSelected={optionRows.isSelected}\n isDisabled={optionRows.isDisabled}\n describeAction={optionRows.describeAction}\n stale={(catalog.busy || catalog.failed) && loaded !== null}\n busy={catalog.busy}\n setSize={\n sourced ? (loaded?.total ?? (pagedMore ? -1 : optionCount)) : null\n }\n onNearEnd={\n pagedMore\n ? () => {\n catalog.controller.loadMore();\n }\n : undefined\n }\n onActiveChange={(row, by) => {\n const shown = row === null ? undefined : rows[row];\n onActiveChange(\n row,\n shown?.kind === \"option\" ? shown.option : null,\n by,\n );\n }}\n />\n <ChoiceStatus\n status={choiceStatus({\n query: list.query,\n source: sourced ? catalog.state : null,\n minLength: sourced ? minQueryLength : 0,\n creation,\n optionCount,\n createRow: optionRows.createText !== null,\n strings,\n })}\n limitHint={\n optionRows.atLimit && limit !== null\n ? strings.maxChoicesReached(limit)\n : null\n }\n />\n </ChoicePopup>\n );\n}\n","import type { ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { classNames } from \"../field/parts\";\nimport type { PickerPopup } from \"../picker/usePickerPopup\";\n\n/**\n * A choice input's popup, portalled into `document.body` so no scrolling\n * ancestor clips it, while it is open: a plain panel, in the field's colour\n * scheme and `dir`, around the `role=\"listbox\"` that is the popup itself.\n * `usePickerPopup`, in `\"list\"` mode, places it and leaves focus in the\n * field.\n */\nexport function ChoicePopup({\n picker,\n className,\n children,\n}: {\n readonly picker: PickerPopup;\n /** The popup's own class beside `gridkit-forms-picker-popup`: `gridkit-forms-select-popup`. */\n readonly className: string;\n readonly children: ReactNode;\n}) {\n const { scope, state, setPanel } = picker;\n if (state.kind !== \"open\" || scope === null) {\n return null;\n }\n return createPortal(\n <div\n ref={setPanel}\n className={classNames(\n \"gridkit-forms-picker-popup\",\n className,\n scope.scheme !== null && `is-${scope.scheme}`,\n )}\n dir={scope.direction}\n >\n {children}\n </div>,\n document.body,\n );\n}\n","import type { FormsMessages, SourceState } from \"@gridkitjs/forms-core\";\nimport { classNames } from \"../field/parts\";\nimport type { Creation } from \"./useCreateOption\";\n\n/** What the status line under the list says. */\nexport interface Status {\n readonly kind: \"loading\" | \"empty\" | \"error\" | \"hint\";\n readonly text: string;\n}\n\n/** Where a choice list stands, for its status line. */\nexport interface StatusContext<O, F> {\n readonly query: string;\n /** The source's state, or `null` for a local list. */\n readonly source: SourceState<O, F> | null;\n /** The source's `minQueryLength`. */\n readonly minLength: number;\n readonly creation: Creation;\n readonly optionCount: number;\n /** A \"Create\" row shows. */\n readonly createRow: boolean;\n readonly strings: FormsMessages;\n}\n\n/**\n * The status line under a choice list, or `null` for none: asking for a\n * longer query, a failure, loading, or no options.\n */\nexport function choiceStatus<O, F>({\n query,\n source,\n minLength,\n creation,\n optionCount,\n createRow,\n strings,\n}: StatusContext<O, F>): Status | null {\n if (source !== null && query.trim().length < minLength) {\n return { kind: \"hint\", text: strings.typeMore(minLength) };\n }\n if (source?.kind === \"failed\") {\n return { kind: \"error\", text: strings.optionsFailed };\n }\n if (creation.kind === \"failed\") {\n return { kind: \"error\", text: strings.createFailed(creation.text) };\n }\n if (source?.kind === \"waiting\" || source?.kind === \"loading\") {\n return { kind: \"loading\", text: `${strings.loading}…` };\n }\n if (optionCount === 0 && !createRow) {\n return {\n kind: \"empty\",\n text: query === \"\" ? strings.noOptions : strings.noMatches(query),\n };\n }\n return null;\n}\n\n/** The lines under a choice list: its status, and the limit reached. */\nexport function ChoiceStatus({\n status,\n limitHint,\n}: {\n readonly status: Status | null;\n /** The text saying the most choices are made, or `null`. */\n readonly limitHint: string | null;\n}) {\n return (\n <>\n {status !== null && (\n <div\n className={classNames(\n \"gridkit-forms-choice-status\",\n `is-${status.kind}`,\n )}\n aria-hidden=\"true\"\n >\n {status.text}\n </div>\n )}\n {limitHint !== null && (\n <div className=\"gridkit-forms-choice-status is-hint\" aria-hidden=\"true\">\n {limitHint}\n </div>\n )}\n </>\n );\n}\n","import {\n foldText,\n keyText,\n type ChoiceOption,\n type DisabledOptions,\n type OptionAction,\n type OptionMatch,\n type OptionRow,\n type TextRange,\n type VisibleRange,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachListbox,\n createRowVirtualizer,\n type AttachedListbox,\n type ListboxActivation,\n type ListboxAlign,\n type ListboxChoice,\n type ListboxOptions,\n type ListboxRow,\n type RowVirtualizer,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { classNames } from \"../field/parts\";\nimport { CheckIcon, MixedIcon } from \"../text/parts\";\n\n/** A column of a multi-column option list. */\nexport interface OptionColumn {\n /** `\"label\"`, `\"description\"`, or a key of the options' `columns`. */\n readonly id: string;\n /** Drawn above the column; screen readers read each option's cells instead. */\n readonly header: string;\n /** A CSS grid track: `\"6rem\"`, `\"2fr\"`; `minmax(0, 1fr)` by default. */\n readonly width?: string | undefined;\n readonly align?: \"start\" | \"end\" | undefined;\n}\n\n/** What `renderOption` is told about the option it draws. */\nexport interface OptionState {\n /** The keys or the pointer are on it. */\n readonly active: boolean;\n /** It is in the value. */\n readonly selected: boolean;\n readonly disabled: boolean;\n /** Where the search text matched it; `null` with no search text. */\n readonly match: OptionMatch | null;\n /** The search text; `\"\"` without one. */\n readonly query: string;\n}\n\n/** How an action row (\"Select all\", \"Create\", \"Try again\") is drawn. */\nexport interface ActionState {\n readonly label: string;\n /** A \"Select all\" row's tick: every option, some or none; `null` for no tick. */\n readonly checked: boolean | \"mixed\" | null;\n /** Waiting on the app: drawn with a spinner. */\n readonly busy: boolean;\n readonly disabled: boolean;\n}\n\n/** What `OptionList` reads, on every render. */\nexport interface OptionListProps<O extends ChoiceOption> {\n /** The listbox's `id`; each row's is `${id}-row-${index}`. */\n readonly id: string;\n readonly rows: readonly OptionRow<O>[];\n /** Where the search text matched each option shown. */\n readonly matches: ReadonlyMap<O, OptionMatch>;\n readonly query: string;\n readonly isSelected: (option: O) => boolean;\n /**\n * Whether an option can be chosen: a disabled one, or an unchosen one\n * once the most allowed are chosen. Memoized, as the rows are.\n */\n readonly isDisabled: (option: O) => boolean;\n /** How each action row is drawn. Memoized, as the rows are. */\n readonly describeAction: (action: OptionAction) => ActionState;\n /** Several values: options carry `aria-checked`, Space and clicks toggle. */\n readonly multiple: boolean;\n /** The options shown are an earlier query's, while a newer one loads. */\n readonly stale: boolean;\n /** A source is loading the options. */\n readonly busy: boolean;\n /**\n * How many options there are in all, when not all are in the list (a\n * source's pages): `-1` when unknown. `null` for the options shown.\n */\n readonly setSize: number | null;\n /** One of the last rows mounted or became active: a source's next page. */\n readonly onNearEnd: (() => void) | undefined;\n /** The active row, as `attachListbox` last reported it. */\n readonly active: number | null;\n readonly columns: readonly OptionColumn[] | undefined;\n readonly renderOption:\n ((option: O, state: OptionState) => ReactNode) | undefined;\n /** Only the rows in view are drawn. */\n readonly virtualize: boolean;\n readonly locale: Intl.LocalesArgument;\n readonly disabledOptions: DisabledOptions;\n /** Printable keys find an option by its label: off for a search box. */\n readonly typeahead: boolean;\n readonly \"aria-label\": string | undefined;\n readonly \"aria-labelledby\": string | undefined;\n /** The listbox attached as the list mounted, then `null` as it goes. */\n readonly onListbox: (listbox: AttachedListbox | null) => void;\n readonly onActiveChange: (\n index: number | null,\n by: ListboxActivation,\n ) => void;\n readonly onChoose: (\n index: number,\n choice: ListboxChoice,\n nativeEvent: Event,\n ) => void;\n}\n\n/** The state class of each kind of action row. */\nconst ACTION_CLASSES: Readonly<Record<OptionAction[\"kind\"], string>> = {\n selectAll: \"select-all\",\n create: \"create\",\n retry: \"retry\",\n};\n\n/** The height a row is taken to have until one is measured. */\nconst ESTIMATED_ROW_HEIGHT = 32;\nconst OVERSCAN = 5;\n\nconst ALL_ROWS = (count: number): VisibleRange => ({\n startIndex: 0,\n endIndex: count - 1,\n offsetBefore: 0,\n offsetAfter: 0,\n});\n\n/** The listbox's key for a row: an option's key as text, a header's label. */\nfunction rowKey<O extends ChoiceOption>(row: OptionRow<O>): string {\n switch (row.kind) {\n case \"option\":\n return keyText(row.option.value);\n case \"header\":\n return `header:${row.label}`;\n case \"action\":\n return `action:${row.action.kind}`;\n }\n}\n\nfunction rowLabel<O extends ChoiceOption>(row: OptionRow<O>): string {\n switch (row.kind) {\n case \"option\":\n return row.option.label;\n case \"header\":\n return row.label;\n case \"action\":\n return \"\";\n }\n}\n\n/** `text` with the parts in `ranges` drawn as matches. */\nfunction Highlighted({\n text,\n ranges,\n}: {\n readonly text: string;\n readonly ranges: readonly TextRange[] | undefined;\n}): ReactNode {\n if (ranges === undefined || ranges.length === 0) {\n return text;\n }\n const parts: ReactNode[] = [];\n let at = 0;\n for (const [start, end] of ranges) {\n if (start > at) {\n parts.push(text.slice(at, start));\n }\n parts.push(\n <mark key={start} className=\"gridkit-forms-match\">\n {text.slice(start, end)}\n </mark>,\n );\n at = end;\n }\n if (at < text.length) {\n parts.push(text.slice(at));\n }\n return parts;\n}\n\n/** The grid tracks of a multi-column row: the tick, then each column. */\nfunction columnTracks(columns: readonly OptionColumn[]): string {\n return [\n \"auto\",\n ...columns.map((column) => column.width ?? \"minmax(0, 1fr)\"),\n ].join(\" \");\n}\n\n/** The text of `option` in `column`. */\nfunction cellText(option: ChoiceOption, column: OptionColumn): string {\n switch (column.id) {\n case \"label\":\n return option.label;\n case \"description\":\n return option.description ?? \"\";\n default:\n return option.columns?.[column.id] ?? \"\";\n }\n}\n\n/**\n * Brings row `index` of a list drawn whole into view, scrolling the list\n * alone: `scrollIntoView` would scroll the page too, which closes a popup.\n */\nfunction scrollRowIntoView(\n list: HTMLElement,\n index: number,\n align: ListboxAlign,\n): void {\n const row = list.querySelector<HTMLElement>(\n `[data-gridkit-forms-row=\"${String(index)}\"]`,\n );\n if (row === null) {\n return;\n }\n const top =\n row.getBoundingClientRect().top -\n list.getBoundingClientRect().top -\n list.clientTop +\n list.scrollTop;\n const height = row.offsetHeight;\n if (align === \"center\") {\n list.scrollTop = top - (list.clientHeight - height) / 2;\n } else if (top < list.scrollTop) {\n list.scrollTop = top;\n } else if (top + height > list.scrollTop + list.clientHeight) {\n list.scrollTop = top + height - list.clientHeight;\n }\n}\n\n/** The listbox's options from the latest props. */\nfunction listboxOptions<O extends ChoiceOption>(\n list: HTMLElement,\n latest: RefObject<OptionListProps<O>>,\n virtualizer: RefObject<RowVirtualizer | null>,\n): ListboxOptions {\n const { typeahead, locale, disabledOptions, multiple } = latest.current;\n return {\n focus: \"active-descendant\",\n multiple,\n typeahead,\n locale,\n disabledOptions,\n onActiveChange: (index, by) => {\n latest.current.onActiveChange(index, by);\n },\n onChoose: (index, choice, nativeEvent) => {\n latest.current.onChoose(index, choice, nativeEvent);\n },\n onNearEnd: () => {\n latest.current.onNearEnd?.();\n },\n scrollToIndex: (index, align) => {\n const windowed = virtualizer.current;\n if (windowed === null) {\n scrollRowIntoView(list, index, align);\n } else {\n windowed.scrollToIndex(index, { block: align });\n }\n },\n };\n}\n\n/**\n * The `role=\"listbox\"` of a choice popup: its rows (groups under their\n * headers, multi-column options under a header row, the rows that act\n * such as \"Select all\" and \"Create\"), only those in view with\n * `virtualize`, ticked with `aria-checked` when `multiple`, and\n * forms-dom's `attachListbox` on it in\n * `\"active-descendant\"` mode, handed to the input through `onListbox`. It\n * holds the listbox and the virtualizer while it is drawn, releasing both\n * as it goes.\n */\nexport function OptionList<O extends ChoiceOption>(props: OptionListProps<O>) {\n const {\n id,\n rows,\n matches,\n query,\n isSelected,\n active,\n columns,\n renderOption,\n virtualize,\n locale,\n isDisabled,\n describeAction,\n multiple,\n } = props;\n const [list, setList] = useState<HTMLDivElement | null>(null);\n // The window to draw, with the virtualizer that measures its rows.\n const [view, setView] = useState<{\n readonly range: VisibleRange;\n readonly rows: RowVirtualizer;\n } | null>(null);\n const latest = useRef(props);\n const listbox = useRef<AttachedListbox | null>(null);\n const virtualizer = useRef<RowVirtualizer | null>(null);\n useLayoutEffect(() => {\n latest.current = props;\n });\n\n // Folded once per option and locale: a search shows the same options\n // again and again.\n const folded = useRef<{\n locale: Intl.LocalesArgument;\n texts: WeakMap<object, string>;\n } | null>(null);\n\n useLayoutEffect(() => {\n if (list === null) {\n return undefined;\n }\n // The first window, reported as the virtualizer is made, is of no rows:\n // the rows' count, set below, reports the one to draw.\n const windowed = virtualize\n ? createRowVirtualizer(list, {\n estimatedRowHeight: ESTIMATED_ROW_HEIGHT,\n overscan: OVERSCAN,\n onRange: (range) => {\n const rows = virtualizer.current;\n if (rows !== null) {\n setView({ range, rows });\n }\n },\n })\n : null;\n virtualizer.current = windowed;\n const attached = attachListbox(\n list,\n listboxOptions(list, latest, virtualizer),\n );\n listbox.current = attached;\n return () => {\n latest.current.onListbox(null);\n listbox.current = null;\n virtualizer.current = null;\n attached.detach();\n windowed?.destroy();\n setView(null);\n };\n }, [list, virtualize]);\n\n // The rows first, then the listbox to the input, so what it activates\n // as the popup opens is there. Heights measured for other rows say\n // nothing about these.\n const announced = useRef<AttachedListbox | null>(null);\n const measuredRows = useRef<readonly OptionRow<O>[] | null>(null);\n useLayoutEffect(() => {\n const attached = listbox.current;\n if (attached === null) {\n announced.current = null;\n return;\n }\n let cache = folded.current;\n if (cache === null || cache.locale !== locale) {\n cache = { locale, texts: new WeakMap() };\n folded.current = cache;\n }\n const { texts } = cache;\n const described = rows.map((row): ListboxRow => {\n const source = row.kind === \"option\" ? row.option : row;\n let typeahead = texts.get(source);\n if (typeahead === undefined) {\n typeahead = foldText(rowLabel(row), locale).text;\n texts.set(source, typeahead);\n }\n return {\n kind: row.kind,\n key: rowKey(row),\n disabled:\n row.kind === \"option\"\n ? isDisabled(row.option)\n : row.kind === \"action\" && describeAction(row.action).disabled,\n typeahead,\n };\n });\n const windowed = virtualizer.current;\n if (announced.current === attached && measuredRows.current !== rows) {\n windowed?.resetHeights();\n }\n measuredRows.current = rows;\n windowed?.setRowCount(described.length);\n attached.setRows(described);\n if (announced.current !== attached) {\n announced.current = attached;\n latest.current.onListbox(attached);\n }\n }, [rows, locale, list, virtualize, isDisabled, describeAction]);\n\n const { typeahead, disabledOptions } = props;\n useLayoutEffect(() => {\n if (list !== null) {\n listbox.current?.setOptions(listboxOptions(list, latest, virtualizer));\n }\n }, [typeahead, disabledOptions, locale, multiple, list]);\n\n const measuring = virtualize ? (view?.rows ?? null) : null;\n const shown = virtualize ? (view?.range ?? null) : ALL_ROWS(rows.length);\n const optionCount = rows.filter((row) => row.kind === \"option\").length;\n const positioned = virtualize || props.setSize !== null;\n const setSize = props.setSize ?? optionCount;\n const tracks: CSSProperties | undefined =\n columns === undefined\n ? undefined\n : { gridTemplateColumns: columnTracks(columns) };\n\n function renderRow(index: number, row: OptionRow<O>): ReactNode {\n const measure = measuring?.measureRow(index);\n const rowId = `${id}-row-${String(index)}`;\n if (row.kind === \"header\") {\n return (\n <div\n key={rowKey(row)}\n ref={measure}\n id={rowId}\n className=\"gridkit-forms-option-group-label\"\n data-gridkit-forms-row={index}\n aria-hidden=\"true\"\n >\n {row.label}\n </div>\n );\n }\n if (row.kind === \"action\") {\n const action = describeAction(row.action);\n return (\n <div\n key={rowKey(row)}\n ref={measure}\n id={rowId}\n role=\"option\"\n className={classNames(\n \"gridkit-forms-option\",\n \"is-action\",\n `is-${ACTION_CLASSES[row.action.kind]}`,\n index === active && \"is-active\",\n action.disabled && \"is-disabled\",\n )}\n data-gridkit-forms-row={index}\n aria-selected={multiple ? undefined : index === active}\n aria-checked={action.checked ?? undefined}\n aria-disabled={action.disabled || undefined}\n aria-busy={action.busy || undefined}\n >\n <span className=\"gridkit-forms-option-check\" aria-hidden=\"true\">\n {action.busy ? (\n <span className=\"gridkit-forms-spinner\" />\n ) : action.checked === true ? (\n <CheckIcon />\n ) : action.checked === \"mixed\" ? (\n <MixedIcon />\n ) : null}\n </span>\n <span className=\"gridkit-forms-option-label\">{action.label}</span>\n </div>\n );\n }\n const { option } = row;\n const match = matches.get(option) ?? null;\n const state: OptionState = {\n active: index === active,\n selected: isSelected(option),\n disabled: isDisabled(option),\n match: query === \"\" ? null : match,\n query,\n };\n const ranges = state.match?.fields;\n let content: ReactNode;\n if (renderOption !== undefined) {\n content = (\n <span className=\"gridkit-forms-option-label\">\n {renderOption(option, state)}\n </span>\n );\n } else if (columns !== undefined) {\n content = columns.map((column) => (\n <span\n key={column.id}\n className={classNames(\n \"gridkit-forms-option-cell\",\n column.align === \"end\" && \"is-end\",\n )}\n >\n <Highlighted\n text={cellText(option, column)}\n ranges={ranges?.[column.id]}\n />\n </span>\n ));\n } else {\n content = (\n <>\n <span className=\"gridkit-forms-option-label\">\n <Highlighted text={option.label} ranges={ranges?.label} />\n </span>\n {option.description !== undefined && (\n <span className=\"gridkit-forms-option-description\">\n <Highlighted\n text={option.description}\n ranges={ranges?.description}\n />\n </span>\n )}\n </>\n );\n }\n return (\n <div\n key={rowKey(row)}\n ref={measure}\n id={rowId}\n role=\"option\"\n className={classNames(\n \"gridkit-forms-option\",\n state.active && \"is-active\",\n state.selected && \"is-selected\",\n state.disabled && \"is-disabled\",\n )}\n style={tracks}\n data-gridkit-forms-row={index}\n aria-selected={multiple ? undefined : state.active}\n aria-checked={multiple ? state.selected : undefined}\n aria-disabled={state.disabled || undefined}\n aria-setsize={positioned ? setSize : undefined}\n aria-posinset={positioned ? row.position + 1 : undefined}\n >\n <span className=\"gridkit-forms-option-check\" aria-hidden=\"true\">\n {state.selected && <CheckIcon />}\n </span>\n {content}\n </div>\n );\n }\n\n /** The rows in view, each run of one group inside its labelled group. */\n function renderWindow(window: VisibleRange): ReactNode[] {\n const runs: { group: string | null; indexes: number[] }[] = [];\n for (let index = window.startIndex; index <= window.endIndex; index++) {\n const row = rows[index];\n if (row === undefined) {\n continue;\n }\n const group =\n row.kind === \"header\"\n ? row.label\n : row.kind === \"option\"\n ? row.group\n : null;\n const last = runs.at(-1);\n if (last !== undefined && last.group === group) {\n last.indexes.push(index);\n } else {\n runs.push({ group, indexes: [index] });\n }\n }\n return runs.flatMap((run): ReactNode[] => {\n const drawn = run.indexes.map((index) => {\n const row = rows[index];\n return row === undefined ? null : renderRow(index, row);\n });\n return run.group === null\n ? drawn\n : [\n <div\n key={`group:${run.group}:${String(run.indexes[0])}`}\n className=\"gridkit-forms-option-group\"\n role=\"group\"\n aria-label={run.group}\n >\n {drawn}\n </div>,\n ];\n });\n }\n\n return (\n <div\n ref={setList}\n id={id}\n className={classNames(\n \"gridkit-forms-option-list\",\n columns !== undefined && \"is-columns\",\n virtualize && \"is-virtual\",\n multiple && \"is-multiple\",\n props.stale && \"is-stale\",\n )}\n role=\"listbox\"\n aria-multiselectable={multiple || undefined}\n aria-busy={props.busy || undefined}\n aria-label={props[\"aria-label\"]}\n aria-labelledby={props[\"aria-labelledby\"]}\n >\n {columns !== undefined && rows.length > 0 && (\n <div\n className=\"gridkit-forms-option-columns\"\n style={tracks}\n aria-hidden=\"true\"\n >\n <span className=\"gridkit-forms-option-check\" />\n {columns.map((column) => (\n <span\n key={column.id}\n className={classNames(\n \"gridkit-forms-option-column-header\",\n column.align === \"end\" && \"is-end\",\n )}\n >\n {column.header}\n </span>\n ))}\n </div>\n )}\n {shown !== null && virtualize && (\n <div\n className=\"gridkit-forms-option-spacer\"\n role=\"presentation\"\n style={{ height: shown.offsetBefore }}\n />\n )}\n {shown !== null && renderWindow(shown)}\n {shown !== null && virtualize && (\n <div\n className=\"gridkit-forms-option-spacer\"\n role=\"presentation\"\n style={{ height: shown.offsetAfter }}\n />\n )}\n </div>\n );\n}\n","import {\n keyText,\n type ChoiceOption,\n type FormsMessages,\n type KeyLookup,\n type OptionKey,\n type Severity,\n} from \"@gridkitjs/forms-core\";\nimport type {\n KeyboardEvent as ReactKeyboardEvent,\n MouseEvent as ReactMouseEvent,\n ReactNode,\n Ref,\n RefCallback,\n} from \"react\";\nimport { classNames } from \"../field/parts\";\nimport type { PickerPopup } from \"../picker/usePickerPopup\";\nimport type { Density } from \"../settings\";\nimport {\n ChevronDownIcon,\n ControlBox,\n hasNode,\n joinIds,\n keepFocus,\n} from \"../text/parts\";\nimport { ChipList, type Chip, type ChipListHandle } from \"./ChipList\";\nimport type { ChoiceField } from \"./useChoiceField\";\n\n/** The attributes a select's control has, whether a search box or a button. */\ninterface SelectControlAttributes {\n readonly id: string;\n readonly disabled: boolean;\n readonly autoFocus: boolean | undefined;\n readonly \"aria-label\": string | undefined;\n readonly \"aria-labelledby\": string | undefined;\n readonly \"aria-describedby\": string | undefined;\n readonly \"aria-required\": true | undefined;\n readonly \"aria-invalid\": true | undefined;\n readonly \"aria-busy\": true | undefined;\n}\n\n/** What either control of a select draws from. */\ninterface SelectControlElementProps {\n readonly attributes: SelectControlAttributes;\n readonly controlRef: RefCallback<HTMLElement>;\n readonly readOnly: boolean;\n readonly onKeyDown: (event: ReactKeyboardEvent) => void;\n}\n\n/** The control of a searchable select: a text box whose typing searches. */\nfunction SelectSearchBox({\n attributes,\n controlRef,\n readOnly,\n onKeyDown,\n placeholder,\n defaultValue,\n}: SelectControlElementProps & {\n readonly placeholder: string | undefined;\n /** Its text as it mounts; forms-dom keeps it after. */\n readonly defaultValue: string;\n}) {\n return (\n <input\n {...attributes}\n ref={controlRef}\n className=\"gridkit-forms-select-control\"\n role=\"combobox\"\n // The markup's starting point, before the combobox attaches and keeps\n // it current; React never writes it again.\n aria-expanded={false}\n type=\"text\"\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n readOnly={readOnly}\n placeholder={placeholder}\n defaultValue={defaultValue}\n onKeyDown={onKeyDown}\n />\n );\n}\n\n// Safari does not focus a button that is pressed, and moves focus out of\n// it instead; the list's keys and the field's commit on leaving both need\n// focus in the control.\nfunction focusOnPress(event: ReactMouseEvent<HTMLButtonElement>): void {\n if (event.button === 0) {\n event.preventDefault();\n event.currentTarget.focus();\n }\n}\n\n/** The control of a select-only select: a button showing the value. */\nfunction SelectButton({\n attributes,\n controlRef,\n readOnly,\n onKeyDown,\n children,\n}: SelectControlElementProps & { readonly children: ReactNode }) {\n return (\n <button\n {...attributes}\n ref={controlRef}\n className=\"gridkit-forms-select-control\"\n role=\"combobox\"\n // As the search box's: the combobox keeps it current.\n aria-expanded={false}\n type=\"button\"\n aria-haspopup=\"listbox\"\n aria-readonly={readOnly || undefined}\n onKeyDown={onKeyDown}\n onMouseDown={focusOnPress}\n >\n {children}\n </button>\n );\n}\n\n/** What a select-only button shows of its value. */\ninterface ChosenValueProps<K extends OptionKey, T> {\n readonly keys: readonly K[];\n readonly multiple: boolean;\n readonly renderValue:\n ((options: readonly ChoiceOption<K, T>[]) => ReactNode) | undefined;\n readonly placeholder: string | undefined;\n /** The value as text, read by a screen reader beside the chips. */\n readonly text: string;\n readonly optionOf: (key: K) => ChoiceOption<K, T> | null;\n readonly lookupOf: (key: K) => KeyLookup<ChoiceOption<K, T>>[\"kind\"];\n readonly strings: FormsMessages;\n}\n\n/**\n * A select-only button's content: the placeholder, the chosen label (or\n * \"Loading…\" while it is asked for), `renderValue`'s drawing, or with\n * chips beside it, the value as text for a screen reader alone.\n */\nfunction ChosenValue<K extends OptionKey, T>({\n keys,\n multiple,\n renderValue,\n placeholder,\n text,\n optionOf,\n lookupOf,\n strings,\n}: ChosenValueProps<K, T>) {\n const chosen = keys.map((key) => optionOf(key));\n const firstKey = keys[0];\n if (firstKey === undefined) {\n return (\n <span className=\"gridkit-forms-select-placeholder\">{placeholder}</span>\n );\n }\n if (multiple && renderValue === undefined) {\n // The chips beside it show the value; a combobox holds no buttons.\n return <span className=\"gridkit-forms-sr-only\">{text}</span>;\n }\n if (renderValue !== undefined && chosen.every((option) => option !== null)) {\n return (\n <span className=\"gridkit-forms-select-value\">{renderValue(chosen)}</span>\n );\n }\n const status = lookupOf(firstKey);\n return (\n <span\n className={classNames(\n \"gridkit-forms-select-value\",\n status !== \"known\" && `is-${status}`,\n )}\n >\n {status === \"resolving\"\n ? `${strings.loading}…`\n : (chosen[0]?.label ?? keyText(firstKey))}\n </span>\n );\n}\n\n/**\n * The chevron at the end of a select's box. Beside a search box it is a\n * button of its own that toggles the list; beside a select-only button it\n * only passes a press to the control.\n */\nfunction SelectChevron({\n searchable,\n open,\n listId,\n label,\n interactive,\n onToggle,\n onPress,\n}: {\n readonly searchable: boolean;\n readonly open: boolean;\n readonly listId: string;\n readonly label: string;\n readonly interactive: boolean;\n readonly onToggle: () => void;\n readonly onPress: (event: ReactMouseEvent) => void;\n}) {\n if (!searchable) {\n return (\n <span\n className=\"gridkit-forms-select-chevron\"\n aria-hidden=\"true\"\n onMouseDown={onPress}\n >\n <ChevronDownIcon />\n </span>\n );\n }\n return (\n <button\n type=\"button\"\n className={classNames(\"gridkit-forms-choice-button\", open && \"is-open\")}\n tabIndex={-1}\n aria-label={label}\n aria-expanded={open}\n aria-controls={open ? listId : undefined}\n disabled={!interactive}\n onMouseDown={keepFocus}\n onClick={onToggle}\n >\n <ChevronDownIcon />\n </button>\n );\n}\n\n/** What a select's box draws from. */\ninterface SelectBoxProps {\n readonly popup: PickerPopup;\n readonly open: boolean;\n readonly control: HTMLElement | null;\n readonly searchable: boolean;\n readonly interactive: boolean;\n readonly disabled: boolean;\n readonly readOnly: boolean;\n readonly severity: Severity | null;\n readonly loading: boolean;\n readonly density: Density;\n readonly prefix: ReactNode;\n readonly prefixId: string;\n readonly suffix: ReactNode;\n readonly suffixId: string;\n readonly listId: string;\n readonly strings: FormsMessages;\n /** Clears the value; `null` while the clear button does not show. */\n readonly onClear: ((nativeEvent: Event) => void) | null;\n readonly chips: readonly Chip[];\n /** The chips keep to one line: focus is outside the select. */\n readonly collapsed: boolean;\n readonly maxChips: number | undefined;\n readonly onRemoveChip: (chip: Chip, nativeEvent: Event) => void;\n readonly chipList: Ref<ChipListHandle>;\n /** The control: `SelectSearchBox` or `SelectButton`. */\n readonly children: ReactNode;\n}\n\n/**\n * A select's box: the chips, then the control, then the clear button and\n * the chevron. The box is what the popup opens beside, and a press on it\n * beside the control is a press on the control.\n */\nfunction SelectBox({\n popup,\n open,\n control,\n searchable,\n interactive,\n disabled,\n readOnly,\n severity,\n loading,\n density,\n prefix,\n prefixId,\n suffix,\n suffixId,\n listId,\n strings,\n onClear,\n chips,\n collapsed,\n maxChips,\n onRemoveChip,\n chipList,\n children,\n}: SelectBoxProps) {\n /** A press on the box beside the control (the chevron, the chips' gaps): as a press on it. */\n function pressBox(event: ReactMouseEvent): void {\n if (event.button !== 0 || disabled) {\n return;\n }\n event.preventDefault();\n control?.focus();\n if (interactive && (!searchable || !open)) {\n popup.toggle();\n }\n }\n\n return (\n <ControlBox\n boxRef={popup.setAnchor}\n severity={severity}\n disabled={disabled}\n readOnly={readOnly}\n loading={loading}\n density={density}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n onClear === null\n ? null\n : {\n label: strings.clear,\n onClear: (event) => {\n onClear(event.nativeEvent);\n },\n }\n }\n end={\n <SelectChevron\n searchable={searchable}\n open={open}\n listId={listId}\n label={strings.showOptions}\n interactive={interactive}\n onToggle={() => {\n control?.focus();\n popup.toggle();\n }}\n onPress={pressBox}\n />\n }\n >\n {chips.length > 0 && (\n <ChipList\n chips={chips}\n collapsed={collapsed}\n maxChips={maxChips}\n readOnly={!interactive}\n strings={strings}\n onRemove={onRemoveChip}\n onExit={() => {\n control?.focus();\n }}\n onPress={pressBox}\n handle={chipList}\n />\n )}\n {children}\n </ControlBox>\n );\n}\n\n/** What a select's trigger draws from. */\nexport interface SelectTriggerProps<\n K extends OptionKey,\n T,\n V,\n D extends object,\n> {\n readonly choice: ChoiceField<V, D>;\n readonly popup: PickerPopup;\n readonly open: boolean;\n /** The active row: Enter on free text with none closes the list. */\n readonly active: number | null;\n readonly searchable: boolean;\n /** The search box's text is the field's own: no validity carrier. */\n readonly searchText: boolean;\n readonly customValue: boolean;\n readonly interactive: boolean;\n readonly clearable: boolean;\n /** Clears the value: the clear button, or Delete on a select-only button. */\n readonly onClear: (nativeEvent: Event) => void;\n readonly keys: readonly K[];\n readonly multiple: boolean;\n readonly renderValue:\n ((options: readonly ChoiceOption<K, T>[]) => ReactNode) | undefined;\n readonly placeholder: string | undefined;\n readonly optionOf: (key: K) => ChoiceOption<K, T> | null;\n readonly lookupOf: (key: K) => KeyLookup<ChoiceOption<K, T>>[\"kind\"];\n readonly chips: readonly Chip[];\n /** The chips keep to one line: focus is outside the select. */\n readonly collapsed: boolean;\n readonly maxChips: number | undefined;\n readonly onRemoveChip: (chip: Chip, nativeEvent: Event) => void;\n readonly chipList: Ref<ChipListHandle>;\n readonly loading: boolean;\n readonly density: Density;\n readonly prefix: ReactNode;\n readonly suffix: ReactNode;\n readonly autoFocus: boolean | undefined;\n readonly \"aria-label\": string | undefined;\n readonly \"aria-labelledby\": string | undefined;\n readonly \"aria-describedby\": string | undefined;\n /** The id of the messages the select shows itself. */\n readonly ownMessagesId: string | undefined;\n readonly listId: string;\n}\n\n/**\n * What a select draws in its box: a search box, or a select-only button\n * showing the value, with the chips, the clear button and the chevron. A\n * select-only button's errors sit on a hidden input beside it, for the\n * form to read.\n */\nexport function SelectTrigger<K extends OptionKey, T, V, D extends object>({\n choice,\n popup,\n open,\n active,\n searchable,\n searchText,\n customValue,\n interactive,\n clearable,\n onClear,\n keys,\n multiple,\n renderValue,\n placeholder,\n optionOf,\n lookupOf,\n chips,\n collapsed,\n maxChips,\n onRemoveChip,\n chipList,\n loading,\n density,\n prefix,\n suffix,\n autoFocus,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ownMessagesId,\n listId,\n}: SelectTriggerProps<K, T, V, D>) {\n const {\n strings,\n controlId,\n control,\n text,\n disabled,\n readOnly,\n required,\n invalid,\n severity,\n describedBy,\n setControl,\n setCarrier,\n } = choice;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const resolving = keys.some((key) => lookupOf(key) === \"resolving\");\n\n function onKeyDown(event: ReactKeyboardEvent): void {\n if (\n event.key === \"Delete\" &&\n !searchable &&\n clearable &&\n interactive &&\n !open &&\n keys.length > 0\n ) {\n event.preventDefault();\n onClear(event.nativeEvent);\n }\n // Free text read by the pipeline's Enter: the list closes on it.\n if (event.key === \"Enter\" && customValue && open && active === null) {\n popup.close(\"picker\");\n }\n }\n\n const controlProps: SelectControlElementProps = {\n attributes: {\n id: controlId,\n disabled: disabled,\n autoFocus,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n describedBy,\n ownMessagesId,\n ariaDescribedBy,\n ),\n \"aria-required\": required || undefined,\n \"aria-invalid\": invalid || undefined,\n \"aria-busy\": loading || resolving || undefined,\n },\n controlRef: setControl,\n readOnly: readOnly,\n onKeyDown,\n };\n\n return (\n <>\n <SelectBox\n popup={popup}\n open={open}\n control={control}\n searchable={searchable}\n interactive={interactive}\n disabled={disabled}\n readOnly={readOnly}\n severity={severity}\n loading={loading}\n density={density}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n listId={listId}\n strings={strings}\n onClear={clearable && interactive && keys.length > 0 ? onClear : null}\n chips={chips}\n collapsed={collapsed}\n maxChips={maxChips}\n onRemoveChip={onRemoveChip}\n chipList={chipList}\n >\n {searchable ? (\n <SelectSearchBox\n {...controlProps}\n placeholder={chips.length > 0 ? undefined : placeholder}\n defaultValue={searchText ? text : \"\"}\n />\n ) : (\n <SelectButton {...controlProps}>\n <ChosenValue\n keys={keys}\n multiple={multiple}\n renderValue={renderValue}\n placeholder={placeholder}\n text={text}\n optionOf={optionOf}\n lookupOf={lookupOf}\n strings={strings}\n />\n </SelectButton>\n )}\n </SelectBox>\n {!searchText && (\n <input\n ref={setCarrier}\n className=\"gridkit-forms-sr-only\"\n data-gridkit-forms-validity=\"\"\n tabIndex={-1}\n aria-hidden=\"true\"\n disabled={disabled}\n readOnly={readOnly}\n />\n )}\n </>\n );\n}\n","import type { FormsMessages, KeyLookup } from \"@gridkitjs/forms-core\";\nimport {\n attachOverflowCount,\n attachRovingFocus,\n writingDirection,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n type MouseEvent as ReactMouseEvent,\n type Ref,\n} from \"react\";\nimport { classNames } from \"../field/parts\";\nimport { ClearIcon, keepFocus } from \"../text/parts\";\n\n/** One chosen option as a chip. */\nexport interface Chip {\n /** The option's key as text: what tells chips apart. */\n readonly id: string;\n readonly label: string;\n /** What is known of its option: a stand-in reads as its key. */\n readonly lookup: KeyLookup<unknown>[\"kind\"];\n /** The user may remove it: not a chosen disabled option. */\n readonly removable: boolean;\n}\n\n/** What the input asks of its chips. */\nexport interface ChipListHandle {\n /** Focuses the last chip's remove button; false when no chip has one. */\n readonly focusLast: () => boolean;\n}\n\nconst REMOVE = \".gridkit-forms-chip-remove\";\n\n/**\n * The chosen options of a choice input with several values, as a\n * `role=\"list\"` of chips beside its control. While the field is not\n * focused (`collapsed`) they keep to one line: the chips that fit, as\n * forms-dom's `attachOverflowCount` measures them (at most `maxChips`),\n * then \"+3\"; the others stay in the page, out of the line, so they can\n * still be measured. Focused, they wrap and all show.\n *\n * Each chip's remove button is out of the tab order: the combobox hands\n * focus to the last one (`focusLast`), and forms-dom's `attachRovingFocus`\n * moves it along with ← and →; → past the last chip and Escape go back to\n * the control (`onExit`), and Backspace or Delete removes the chip,\n * focusing the next one or the control.\n */\nexport function ChipList({\n chips,\n collapsed,\n maxChips,\n readOnly,\n strings,\n onRemove,\n onExit,\n onPress,\n handle,\n}: {\n readonly chips: readonly Chip[];\n readonly collapsed: boolean;\n readonly maxChips: number | undefined;\n readonly readOnly: boolean;\n readonly strings: FormsMessages;\n readonly onRemove: (chip: Chip, nativeEvent: Event) => void;\n readonly onExit: () => void;\n /** A press on the chips but not on a remove button: as a press on the control. */\n readonly onPress: (event: ReactMouseEvent) => void;\n readonly handle: Ref<ChipListHandle>;\n}) {\n const [list, setList] = useState<HTMLDivElement | null>(null);\n const [fit, setFit] = useState(chips.length);\n const latest = useRef({ chips, onRemove, onExit });\n useLayoutEffect(() => {\n latest.current = { chips, onRemove, onExit };\n });\n\n useLayoutEffect(() => {\n if (list === null) {\n return undefined;\n }\n return attachOverflowCount(list, {\n items: \".gridkit-forms-chip\",\n reserve: \".gridkit-forms-chips-more\",\n onCount: setFit,\n }).detach;\n }, [list]);\n\n const roving = useRef<ReturnType<typeof attachRovingFocus> | null>(null);\n useLayoutEffect(() => {\n if (list === null) {\n return undefined;\n }\n const buttons = (): HTMLElement[] =>\n Array.from(list.querySelectorAll<HTMLElement>(REMOVE));\n const attached = attachRovingFocus(list, {\n items: REMOVE,\n orientation: \"horizontal\",\n wrap: false,\n tabStop: false,\n onKey: (item, event) => {\n const all = buttons();\n const index = all.indexOf(item);\n const forward =\n writingDirection(list) === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\";\n if (event.key === \"Escape\" || event.key === forward) {\n event.preventDefault();\n latest.current.onExit();\n return;\n }\n if (event.key !== \"Backspace\" && event.key !== \"Delete\") {\n return;\n }\n event.preventDefault();\n const chip = latest.current.chips.find(\n (candidate) => candidate.id === item.dataset.gridkitFormsChip,\n );\n if (chip === undefined) {\n return;\n }\n const next = all[index + 1] ?? all[index - 1];\n if (next === undefined) {\n latest.current.onExit();\n } else {\n attached.focusItem(next);\n }\n latest.current.onRemove(chip, event);\n },\n });\n roving.current = attached;\n return () => {\n roving.current = null;\n attached.detach();\n };\n }, [list]);\n\n useImperativeHandle(\n handle,\n () => ({\n focusLast: () => {\n const last = list?.querySelectorAll<HTMLElement>(REMOVE);\n const button = last?.[last.length - 1];\n if (button === undefined || roving.current === null) {\n return false;\n }\n roving.current.focusItem(button);\n return true;\n },\n }),\n [list],\n );\n\n const shown = collapsed\n ? Math.min(maxChips ?? chips.length, Math.max(fit, 1), chips.length)\n : chips.length;\n const hidden = chips.length - shown;\n\n return (\n <div\n ref={setList}\n className={classNames(\"gridkit-forms-chips\", collapsed && \"is-collapsed\")}\n role=\"list\"\n aria-label={strings.chosenList}\n onMouseDown={(event) => {\n if (\n !(event.target instanceof Element) ||\n event.target.closest(REMOVE) === null\n ) {\n onPress(event);\n }\n }}\n >\n {chips.map((chip, index) => (\n <div\n key={chip.id}\n className={classNames(\n \"gridkit-forms-chip\",\n !chip.removable && \"is-disabled\",\n chip.lookup === \"missing\" && \"is-missing\",\n chip.lookup === \"resolving\" && \"is-resolving\",\n index >= shown && \"is-overflow\",\n )}\n role=\"listitem\"\n >\n <span className=\"gridkit-forms-chip-label\">{chip.label}</span>\n {chip.removable && !readOnly && (\n <button\n type=\"button\"\n className=\"gridkit-forms-chip-remove\"\n tabIndex={-1}\n aria-label={strings.removeChoice(chip.label)}\n data-gridkit-forms-chip={chip.id}\n onMouseDown={keepFocus}\n onClick={(event) => {\n onRemove(chip, event.nativeEvent);\n }}\n >\n <ClearIcon />\n </button>\n )}\n </div>\n ))}\n {hidden > 0 && (\n <div className=\"gridkit-forms-chips-more\" role=\"listitem\">\n <span aria-hidden=\"true\">{strings.moreChosen(hidden)}</span>\n <span className=\"gridkit-forms-sr-only\">\n {strings.moreChosenLabel(hidden)}\n </span>\n </div>\n )}\n </div>\n );\n}\n","import {\n sameKey,\n type FieldController,\n type ChoiceOption,\n type HighlightChangeEvent,\n type PopupCloseReason,\n type PopupOpenChange,\n type PopupOpenReason,\n} from \"@gridkitjs/forms-core\";\nimport type { AttachedListbox, ListboxActivation } from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useImperativeHandle,\n useRef,\n useState,\n type Ref,\n} from \"react\";\nimport { usePickerPopup, type PickerPopup } from \"../picker/usePickerPopup\";\nimport type { ChoiceHandle } from \"./selectProps\";\n\n/** What `useChoicePopup` reads, on every render. */\nexport interface ChoicePopupOptions<O extends ChoiceOption> {\n readonly enabled: boolean;\n readonly onOpenChange: ((change: PopupOpenChange) => void) | undefined;\n readonly onHighlightChange:\n ((event: HighlightChangeEvent<O, Event>) => void) | undefined;\n /** The popup is opening, before `onOpenChange` hears it. */\n readonly onOpening: (reason: PopupOpenReason) => void;\n /** The popup opened, after `onOpenChange` heard it. */\n readonly onOpened: (reason: PopupOpenReason) => void;\n /**\n * The popup closed, after `onOpenChange` heard it, with whether the\n * value changed while it showed.\n */\n readonly onClosed: (reason: PopupCloseReason, changed: boolean) => void;\n}\n\n/** What `useChoicePopup` gives the input. */\nexport interface ChoicePopupState<O extends ChoiceOption> {\n readonly popup: PickerPopup;\n readonly open: boolean;\n /** The listbox while the popup shows it, else `null`. */\n readonly listbox: AttachedListbox | null;\n readonly setListbox: (listbox: AttachedListbox | null) => void;\n /** The active row. */\n readonly active: number | null;\n /** The active row moved, onto `option` or a row that is not one. */\n readonly onActiveChange: (\n row: number | null,\n option: O | null,\n by: ListboxActivation,\n ) => void;\n /** Whether the popup shows now, between renders. */\n readonly isOpen: () => boolean;\n /** The value changed while the popup shows. */\n readonly markChanged: () => void;\n}\n\n/**\n * A choice input's list popup: `usePickerPopup` in `\"list\"` mode, the\n * listbox it shows and its active row, telling `onHighlightChange` each\n * new option made active. Closing drops the listbox and the active row.\n */\nexport function useChoicePopup<O extends ChoiceOption>({\n enabled,\n onOpenChange,\n onHighlightChange,\n onOpening,\n onOpened,\n onClosed,\n}: ChoicePopupOptions<O>): ChoicePopupState<O> {\n const [listbox, setListbox] = useState<AttachedListbox | null>(null);\n const [active, setActive] = useState<number | null>(null);\n const opened = useRef(false);\n const changed = useRef(false);\n const highlighted = useRef<O | null>(null);\n\n const popup = usePickerPopup({\n mode: \"list\",\n enabled,\n onOpenChange: (change) => {\n if (change.open) {\n opened.current = true;\n changed.current = false;\n onOpening(change.reason);\n onOpenChange?.(change);\n onOpened(change.reason);\n return;\n }\n onOpenChange?.(change);\n opened.current = false;\n setListbox(null);\n setActive(null);\n highlighted.current = null;\n onClosed(change.reason, changed.current);\n changed.current = false;\n },\n });\n const open = popup.state.kind === \"open\";\n\n const onActiveChange = (\n row: number | null,\n option: O | null,\n by: ListboxActivation,\n ): void => {\n setActive(row);\n const previousOption = highlighted.current;\n if (\n option === previousOption ||\n (option !== null &&\n previousOption !== null &&\n sameKey(option.value, previousOption.value))\n ) {\n return;\n }\n highlighted.current = option;\n onHighlightChange?.({\n option,\n previousOption,\n by: by === \"list\" ? \"typing\" : by,\n nativeEvent: null,\n });\n };\n const isOpen = useCallback(() => opened.current, []);\n const markChanged = useCallback(() => {\n changed.current = true;\n }, []);\n\n return {\n popup,\n open,\n listbox: open ? listbox : null,\n setListbox,\n active,\n onActiveChange,\n isOpen,\n markChanged,\n };\n}\n\n/**\n * A choice input's handle: what every input's does, opening and closing\n * the popup, and reloading the source through `reload`.\n */\nexport function useChoiceHandle<V, D extends object>(\n handleRef: Ref<ChoiceHandle<V>> | undefined,\n control: HTMLElement | null,\n controller: FieldController<V, D, Event>,\n popup: PickerPopup,\n source: { readonly invalidate: () => void },\n): void {\n const { open, close } = popup;\n useImperativeHandle(\n handleRef,\n () => ({\n element: control,\n focus: (focusOptions) => {\n control?.focus(focusOptions);\n },\n blur: () => {\n control?.blur();\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n open: () => {\n control?.focus();\n open(\"button\");\n },\n close: () => {\n close(\"button\");\n },\n reload: () => {\n source.invalidate();\n },\n }),\n [control, controller, open, close, source],\n );\n}\n","import type {\n FieldController,\n FormsMessages,\n PopupCloseReason,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachCombobox,\n createChoiceAnnouncer,\n type AttachedCombobox,\n type AttachedListbox,\n type ChoiceAnnouncer,\n type ComboboxOptions,\n} from \"@gridkitjs/forms-dom\";\nimport { useCallback, useEffect, useLayoutEffect, useRef } from \"react\";\n\n/** What `useChoiceCombobox` reads, on every render. */\nexport interface ChoiceComboboxProps<V, D extends object> {\n readonly control: HTMLElement | null;\n readonly controller: FieldController<V, D, Event>;\n readonly enabled: boolean;\n /** The listbox while the popup shows it, else `null`. */\n readonly listbox: AttachedListbox | null;\n /** The input's root: chips inside it count as inside the combobox. */\n readonly root: HTMLElement | null;\n readonly editable: boolean;\n readonly multiple: boolean;\n readonly drivesField: boolean;\n readonly tabChooses: boolean;\n readonly readOnly: boolean;\n readonly onOpenRequest: ComboboxOptions[\"onOpenRequest\"];\n readonly onClose: (reason: PopupCloseReason) => void;\n readonly onChipKey: ComboboxOptions[\"onChipKey\"];\n}\n\nfunction optionsOf<V, D extends object>({\n listbox,\n root,\n multiple,\n onClose,\n ...props\n}: ChoiceComboboxProps<V, D>): ComboboxOptions {\n return {\n listbox,\n panel: listbox?.element.parentElement ?? null,\n editable: props.editable,\n multiple,\n drivesField: props.drivesField,\n isInside: (element) =>\n element.closest(\".gridkit-forms-chips\") !== null &&\n root?.contains(element) === true,\n tabChooses: props.tabChooses,\n readOnly: props.readOnly,\n onOpenRequest: props.onOpenRequest,\n onCloseRequest: (reason, nativeEvent) => {\n // Alt+↑ chooses the active option as it closes a one-value list.\n if (\n !multiple &&\n nativeEvent instanceof KeyboardEvent &&\n nativeEvent.altKey &&\n nativeEvent.key === \"ArrowUp\"\n ) {\n listbox?.chooseActive(nativeEvent);\n }\n onClose(reason);\n },\n onChipKey: props.onChipKey,\n };\n}\n\n/**\n * Attaches forms-dom's `attachCombobox` to a choice input's control once\n * per control, in a layout effect that detaches it, and hands it the\n * latest options after every render. The function it returns takes the\n * list from it at once, as the popup closes.\n */\nexport function useChoiceCombobox<V, D extends object>(\n props: ChoiceComboboxProps<V, D>,\n): () => void {\n const { control, controller, enabled } = props;\n const combobox = useRef<AttachedCombobox | null>(null);\n const latest = useRef(props);\n useLayoutEffect(() => {\n latest.current = props;\n });\n useLayoutEffect(() => {\n if (control === null || !enabled) {\n return undefined;\n }\n const attached = attachCombobox(\n control,\n controller,\n optionsOf(latest.current),\n );\n combobox.current = attached;\n return () => {\n attached.detach();\n combobox.current = null;\n };\n }, [control, controller, enabled]);\n useLayoutEffect(() => {\n combobox.current?.setOptions(optionsOf(props));\n });\n return useCallback(() => {\n combobox.current?.setOptions({\n ...optionsOf(latest.current),\n listbox: null,\n panel: null,\n });\n }, []);\n}\n\n/**\n * forms-dom's `createChoiceAnnouncer` on `root`, made in a layout effect\n * that destroys it, which announces each new `failure` of the source. The\n * getter it returns reads it, or `null` while there is none.\n */\nexport function useChoiceAnnouncer(\n root: HTMLElement | null,\n strings: FormsMessages,\n failure: object | null,\n): () => ChoiceAnnouncer | null {\n const announcer = useRef<ChoiceAnnouncer | null>(null);\n useLayoutEffect(() => {\n if (root === null) {\n return undefined;\n }\n const created = createChoiceAnnouncer(root, { messages: strings });\n announcer.current = created;\n return () => {\n announcer.current = null;\n created.destroy();\n };\n }, [root, strings]);\n useEffect(() => {\n if (failure !== null) {\n announcer.current?.announce(strings.optionsFailed);\n }\n }, [failure, strings]);\n return useCallback(() => announcer.current, []);\n}\n","import {\n foldText,\n type ChoiceOption,\n type CreateEvent,\n} from \"@gridkitjs/forms-core\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { isThenable } from \"./selectModel\";\n\n/** An option the user asked to create: answered at once, awaited, or refused. */\nexport type Creation =\n | { readonly kind: \"idle\" }\n | { readonly kind: \"waiting\"; readonly text: string }\n | { readonly kind: \"failed\"; readonly text: string };\n\nconst NOT_CREATING: Creation = { kind: \"idle\" };\n\n/** An app's `onCreate`: the option made from the text, at once or awaited, or `null`. */\nexport type CreateHandler<O> = (\n event: CreateEvent<Event>,\n) => O | null | Promise<O | null>;\n\n/** What `useCreateOption` gives the input. */\nexport interface CreateOption {\n readonly creation: Creation;\n /** Asks `onCreate` for an option made from `text`; one at a time. */\n readonly create: (text: string, nativeEvent: Event) => void;\n /** Drops a creation still awaited, and a failure shown. */\n readonly cancel: () => void;\n}\n\n/**\n * Creating an option from search text through the app's `onCreate`. An\n * answer at once is adopted at once; an awaited one shows as `waiting`,\n * then is adopted or shows as `failed`. An answer that arrives after\n * `cancel` or unmount is ignored.\n */\nexport function useCreateOption<O>(\n onCreate: CreateHandler<O> | undefined,\n adopt: (option: O, nativeEvent: Event | null) => void,\n): CreateOption {\n const [creation, setCreation] = useState<Creation>(NOT_CREATING);\n const pending = useRef<{ cancelled: boolean } | null>(null);\n useEffect(\n () => () => {\n if (pending.current !== null) {\n pending.current.cancelled = true;\n }\n },\n [],\n );\n\n const cancel = (): void => {\n if (pending.current !== null) {\n pending.current.cancelled = true;\n pending.current = null;\n }\n setCreation(NOT_CREATING);\n };\n\n const create = (text: string, nativeEvent: Event): void => {\n if (onCreate === undefined || creation.kind === \"waiting\") {\n return;\n }\n const answer = onCreate({ text, nativeEvent });\n if (!isThenable(answer)) {\n if (answer !== null) {\n adopt(answer, nativeEvent);\n }\n return;\n }\n if (pending.current !== null) {\n pending.current.cancelled = true;\n }\n const request = { cancelled: false };\n pending.current = request;\n setCreation({ kind: \"waiting\", text });\n answer.then(\n (option) => {\n if (request.cancelled) {\n return;\n }\n pending.current = null;\n setCreation(NOT_CREATING);\n if (option !== null) {\n adopt(option, null);\n }\n },\n () => {\n if (!request.cancelled) {\n pending.current = null;\n setCreation({ kind: \"failed\", text });\n }\n },\n );\n };\n\n return { creation, create, cancel };\n}\n\n/**\n * Options by their folded label, the first of each, for free text that\n * names one: built only when `wanted`.\n */\nexport function useOptionsByLabel<O extends ChoiceOption>(\n options: readonly O[],\n locale: Intl.LocalesArgument,\n wanted: boolean,\n): ReadonlyMap<string, O> {\n return useMemo(() => {\n const found = new Map<string, O>();\n if (wanted) {\n for (const option of options) {\n const label = foldText(option.label, locale).text;\n if (!found.has(label)) {\n found.set(label, option);\n }\n }\n }\n return found;\n }, [options, locale, wanted]);\n}\n","import {\n moveActive,\n type DisabledOptions,\n type NavigableRow,\n type PopupOpenReason,\n} from \"@gridkitjs/forms-core\";\nimport type { AttachedListbox, ChoiceAnnouncer } from \"@gridkitjs/forms-dom\";\nimport { useCallback, useLayoutEffect, useRef } from \"react\";\n\n/** What asked for the popup, for where its active option starts. */\ninterface Opening {\n readonly reason: PopupOpenReason;\n readonly key: string | null;\n readonly altKey: boolean;\n}\n\n/**\n * Where the active option starts as the popup opens. A select-only\n * control opens on the chosen option, else the first (Home and End on\n * the first and last; a printable key leaves it to type-ahead). A search\n * box opens on the first match as it is typed in, on the chosen option or\n * the first or last with ↓ or ↑, on the chosen option from a press, and\n * on nothing with Alt+↓ or F4.\n */\nfunction openingRow(\n opening: Opening,\n searchable: boolean,\n rows: readonly NavigableRow[],\n chosen: number | null,\n query: string,\n typingHighlights: boolean,\n disabledOptions: DisabledOptions,\n): number | null {\n const first = (): number | null =>\n moveActive(rows, null, { kind: \"first\" }, disabledOptions);\n const last = (): number | null =>\n moveActive(rows, null, { kind: \"last\" }, disabledOptions);\n if (opening.reason === \"typing\") {\n return searchable && query !== \"\" && typingHighlights ? first() : null;\n }\n if (!searchable) {\n switch (opening.key) {\n case \"Home\":\n return first();\n case \"End\":\n return last();\n default:\n return chosen ?? first();\n }\n }\n if (opening.key === \"ArrowDown\" && !opening.altKey) {\n return chosen ?? first();\n }\n if (opening.key === \"ArrowUp\") {\n return chosen ?? last();\n }\n return opening.reason === \"button\" ? chosen : null;\n}\n\n/** What `useListActivation` reads, on every render. */\nexport interface ListActivationProps {\n /** The listbox while the popup shows it, else `null`. */\n readonly listbox: AttachedListbox | null;\n /** The query the list has settled on, or `null` while a source answers it. */\n readonly settled: string | null;\n readonly searchable: boolean;\n readonly rows: readonly NavigableRow[];\n readonly chosenRow: number | null;\n /** Typing makes the first match active; not when free text is the value. */\n readonly typingHighlights: boolean;\n readonly disabledOptions: DisabledOptions;\n /** How many options the query leaves, announced as it settles. */\n readonly resultCount: number;\n readonly announcer: () => ChoiceAnnouncer | null;\n}\n\n/** What `useListActivation` gives the input. */\nexport interface ListActivation {\n /** The combobox asked for the popup, with the key that asked. */\n readonly request: (\n reason: PopupOpenReason,\n nativeEvent: Event | null,\n ) => void;\n /** The popup opened, for `reason` unless a request said more. */\n readonly opened: (reason: PopupOpenReason) => void;\n}\n\n/**\n * The active option of a choice list: set as the popup opens, from what\n * opened it, and again each time the search settles on new options, which\n * it announces.\n */\nexport function useListActivation({\n listbox,\n settled,\n searchable,\n rows,\n chosenRow,\n typingHighlights,\n disabledOptions,\n resultCount,\n announcer,\n}: ListActivationProps): ListActivation {\n const opening = useRef<Opening | null>(null);\n const activatedQuery = useRef<string | null>(null);\n\n useLayoutEffect(() => {\n if (listbox === null || settled === null) {\n return;\n }\n const opened = opening.current;\n if (opened !== null) {\n opening.current = null;\n activatedQuery.current = settled;\n listbox.activate(\n openingRow(\n opened,\n searchable,\n rows,\n chosenRow,\n settled,\n typingHighlights,\n disabledOptions,\n ),\n opened.reason === \"typing\" ? \"typing\" : \"open\",\n );\n } else if (settled !== activatedQuery.current) {\n activatedQuery.current = settled;\n listbox.activate(\n settled === \"\" || !typingHighlights\n ? null\n : moveActive(rows, null, { kind: \"first\" }, disabledOptions),\n \"typing\",\n );\n } else {\n return;\n }\n if (settled !== \"\") {\n announcer()?.results(settled, resultCount);\n }\n }, [\n listbox,\n settled,\n searchable,\n rows,\n chosenRow,\n typingHighlights,\n disabledOptions,\n resultCount,\n announcer,\n ]);\n\n const request = useCallback(\n (reason: PopupOpenReason, nativeEvent: Event | null): void => {\n opening.current = {\n reason,\n key: nativeEvent instanceof KeyboardEvent ? nativeEvent.key : null,\n altKey: nativeEvent instanceof KeyboardEvent && nativeEvent.altKey,\n };\n },\n [],\n );\n const opened = useCallback((reason: PopupOpenReason): void => {\n opening.current ??= { reason, key: null, altKey: false };\n activatedQuery.current = null;\n }, []);\n return { request, opened };\n}\n","import {\n addKeys,\n rangeKeys,\n toggleKey,\n type OptionRow,\n keyText,\n removeKeys,\n sameKeys,\n selectAll,\n valueKeys,\n hasKey,\n type ChangeSource,\n type ChoiceOption,\n type FieldController,\n type FormsMessages,\n type KeyList,\n type KeyLookup,\n type OptionKey,\n type OptionQuery,\n} from \"@gridkitjs/forms-core\";\nimport {\n abortSignals,\n type ChoiceAnnouncer,\n type ListboxChoice,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n type FocusEvent as ReactFocusEvent,\n type RefObject,\n} from \"react\";\nimport type { Chip, ChipListHandle } from \"./ChipList\";\nimport type { SelectShape } from \"./selectModel\";\n\n/** What `useMultipleChoice` reads, on every render. */\nexport interface MultipleChoiceProps<\n K extends OptionKey,\n T,\n F,\n V,\n D extends object,\n> {\n readonly shape: SelectShape<K, T, V, D>;\n readonly controller: FieldController<V, D, Event>;\n readonly chosenKeys: readonly K[];\n /** The most keys the value may hold, or `null`. */\n readonly limit: number | null;\n readonly strings: FormsMessages;\n /** Whether chips show: several values, and no `renderValue`. */\n readonly showChips: boolean;\n readonly optionOf: (key: K) => ChoiceOption<K, T> | null;\n readonly lookupOf: (key: K) => KeyLookup<ChoiceOption<K, T>>[\"kind\"];\n readonly announcer: () => ChoiceAnnouncer | null;\n /** Whether the list shows: a change then waits for it to close to commit. */\n readonly isOpen: () => boolean;\n /** A change made while the list shows, for it to commit as it closes. */\n readonly onChangedWhileOpen: () => void;\n /** Every key matching the query, past the loaded pages: the source's `allKeys`. */\n readonly allKeys:\n | ((query: OptionQuery<F>, signal: AbortSignal) => Promise<readonly K[]>)\n | null;\n /** The query `allKeys` is asked for. */\n readonly query: () => OptionQuery<F>;\n}\n\n/** An option row chosen in the list, as the listbox chose it. */\nexport interface OptionChoice<K extends OptionKey, T> {\n readonly rows: readonly OptionRow<ChoiceOption<K, T>>[];\n readonly row: number;\n readonly option: ChoiceOption<K, T>;\n /** One, a toggle, a range from an anchor row, or all. */\n readonly picked: ListboxChoice;\n readonly disabled: boolean;\n /** The options shown, which \"all\" chooses. */\n readonly shown: readonly ChoiceOption<K, T>[];\n readonly pagedMore: boolean;\n}\n\n/** What `useMultipleChoice` gives the input. */\nexport interface MultipleChoice<K extends OptionKey, T> {\n /** The change to `next`, committed as the list closes or the field is left. */\n readonly changeKeys: (\n next: KeyList<K>,\n source: ChangeSource,\n nativeEvent: Event | null,\n ) => void;\n /** A key removed: committed at once while the list is closed. */\n readonly removeKey: (key: K, nativeEvent: Event | null) => void;\n /** \"Select all\" over `shown`, or over every key `allKeys` gives when `pagedMore`. */\n readonly chooseAll: (\n shown: readonly ChoiceOption<K>[],\n pagedMore: boolean,\n nativeEvent: Event | null,\n ) => void;\n /** An option row chosen: ticked or unticked, a range from the anchor added, or all shown. */\n readonly chooseOption: (\n choice: OptionChoice<K, T>,\n nativeEvent: Event,\n ) => void;\n /** An `allKeys` request is awaited. */\n readonly selectingAll: boolean;\n /** Drops an `allKeys` request still awaited. */\n readonly cancelSelectAll: () => void;\n readonly chips: readonly Chip[];\n readonly removeChip: (chip: Chip, nativeEvent: Event) => void;\n /** The combobox's keys towards the chips: ← to the last, Backspace removes it. */\n readonly chipKey: (\n key: \"previous\" | \"remove-last\",\n nativeEvent: Event,\n ) => void;\n readonly chipList: RefObject<ChipListHandle | null>;\n}\n\n/**\n * The several values of a choice input: ticking and unticking keys while\n * the list shows (committed as it closes), removing chips (committed at\n * once while it is closed), \"select all\", and the chips drawn for the\n * value. Each change announces the count chosen, or the limit reached.\n */\nexport function useMultipleChoice<\n K extends OptionKey,\n T,\n F,\n V,\n D extends object,\n>({\n shape,\n controller,\n chosenKeys,\n limit,\n strings,\n showChips,\n optionOf,\n lookupOf,\n announcer,\n isOpen,\n onChangedWhileOpen,\n allKeys,\n query,\n}: MultipleChoiceProps<K, T, F, V, D>): MultipleChoice<K, T> {\n const [selectingAll, setSelectingAll] = useState(false);\n const pending = useRef<{ readonly abort: () => void } | null>(null);\n const chipList = useRef<ChipListHandle>(null);\n useEffect(\n () => () => {\n pending.current?.abort();\n },\n [],\n );\n\n const cancelSelectAll = (): void => {\n pending.current?.abort();\n pending.current = null;\n setSelectingAll(false);\n };\n\n const changeKeys = (\n next: KeyList<K>,\n source: ChangeSource,\n nativeEvent: Event | null,\n ): void => {\n const before = shape.keys(controller.getState().value);\n if (sameKeys(before, next)) {\n return;\n }\n controller.change(shape.fromKeys(valueKeys(next)), {\n source,\n nativeEvent,\n input: null,\n });\n onChangedWhileOpen();\n const count = valueKeys(next).length;\n if (limit !== null && count >= limit && before.length < limit) {\n announcer()?.announce(strings.maxChoicesReached(limit));\n } else {\n announcer()?.selected(count);\n }\n };\n\n const removeKey = (key: K, nativeEvent: Event | null): void => {\n const before = shape.keys(controller.getState().value);\n const next = removeKeys(before, [key]);\n if (next === before) {\n return;\n }\n const kept = shape.fromKeys(valueKeys(next));\n if (isOpen()) {\n controller.change(kept, { source: \"remove\", nativeEvent, input: null });\n onChangedWhileOpen();\n } else {\n controller.pick(kept, \"remove\", \"remove\", nativeEvent);\n }\n announcer()?.announce(\n strings.choiceRemoved(optionOf(key)?.label ?? keyText(key)),\n );\n };\n\n const chooseAll = (\n shown: readonly ChoiceOption<K>[],\n pagedMore: boolean,\n nativeEvent: Event | null,\n ): void => {\n if (!pagedMore || allKeys === null) {\n changeKeys(selectAll(chosenKeys, shown, limit), \"picker\", nativeEvent);\n return;\n }\n pending.current?.abort();\n const { signal, abort } = abortSignals();\n pending.current = { abort };\n setSelectingAll(true);\n allKeys(query(), signal).then(\n (found) => {\n if (signal.aborted) {\n return;\n }\n pending.current = null;\n setSelectingAll(false);\n const held = shape.keys(controller.getState().value);\n const missing = found.filter((key) => !hasKey(held, key));\n if (missing.length === 0) {\n changeKeys(removeKeys(held, found), \"picker\", null);\n } else if (limit === null || held.length + missing.length <= limit) {\n changeKeys(addKeys(held, missing), \"picker\", null);\n }\n },\n () => {\n if (!signal.aborted) {\n pending.current = null;\n setSelectingAll(false);\n }\n },\n );\n };\n\n const chooseOption = (\n {\n rows,\n row,\n option,\n picked,\n disabled,\n shown,\n pagedMore,\n }: OptionChoice<K, T>,\n nativeEvent: Event,\n ): void => {\n switch (picked.kind) {\n case \"all\":\n chooseAll(shown, pagedMore, nativeEvent);\n return;\n case \"range\":\n changeKeys(\n addKeys(chosenKeys, rangeKeys(rows, picked.anchor, row), limit),\n \"picker\",\n nativeEvent,\n );\n return;\n case \"one\":\n case \"toggle\":\n if (!disabled) {\n changeKeys(\n toggleKey(chosenKeys, option.value, limit),\n \"picker\",\n nativeEvent,\n );\n }\n }\n };\n\n const chips = useMemo(\n (): readonly Chip[] =>\n !showChips\n ? []\n : chosenKeys.map((key) => {\n const status = lookupOf(key);\n const option = optionOf(key);\n return {\n id: keyText(key),\n label:\n status === \"resolving\"\n ? `${strings.loading}…`\n : (option?.label ?? keyText(key)),\n lookup: status,\n removable: option?.disabled !== true,\n };\n }),\n [showChips, chosenKeys, lookupOf, optionOf, strings],\n );\n\n const removeChip = (chip: Chip, nativeEvent: Event): void => {\n const key = chosenKeys.find((held) => keyText(held) === chip.id);\n if (key !== undefined) {\n removeKey(key, nativeEvent);\n }\n };\n\n const chipKey = (key: \"previous\" | \"remove-last\", nativeEvent: Event) => {\n if (key === \"previous\") {\n chipList.current?.focusLast();\n return;\n }\n const last = chips.findLast((chip) => chip.removable);\n if (last !== undefined) {\n removeChip(last, nativeEvent);\n }\n };\n\n return {\n changeKeys,\n removeKey,\n chooseAll,\n chooseOption,\n selectingAll,\n cancelSelectAll,\n chips,\n removeChip,\n chipKey,\n chipList,\n };\n}\n\n/**\n * Whether focus is inside a choice input, for its chips, which keep to one\n * line outside it, and the handlers that tell it, for the input's root.\n * Focus leaving from a chip blurs the field: the combobox did not see it go.\n */\nexport function useChipsFocus(controller: {\n readonly blur: (event: Event) => void;\n}): {\n readonly focusWithin: boolean;\n readonly onFocus: () => void;\n readonly onBlur: (event: ReactFocusEvent) => void;\n} {\n const [focusWithin, setFocusWithin] = useState(false);\n return {\n focusWithin,\n onFocus: () => {\n setFocusWithin(true);\n },\n onBlur: (event) => {\n const to = event.relatedTarget;\n if (to instanceof Node && event.currentTarget.contains(to)) {\n return;\n }\n setFocusWithin(false);\n if (\n event.target instanceof Element &&\n event.target.closest(\".gridkit-forms-chips\") !== null\n ) {\n controller.blur(event.nativeEvent);\n }\n },\n };\n}\n","import {\n canSelectAll,\n createOptionIndex,\n flattenOptions,\n foldText,\n hasKey,\n scopeState,\n type ChoiceOption,\n type FormsMessages,\n type MatchMode,\n type NavigableRow,\n type OptionAction,\n type OptionKey,\n type OptionMatch,\n type OptionMatcher,\n type OptionRow,\n} from \"@gridkitjs/forms-core\";\nimport { useCallback, useMemo } from \"react\";\nimport type { ActionState } from \"./OptionList\";\n\n/** What `useOptionRows` reads, on every render. */\nexport interface OptionRowsProps<K extends OptionKey, T> {\n /** The options the list is made from. */\n readonly listed: readonly ChoiceOption<K, T>[];\n readonly query: string;\n readonly match: MatchMode | OptionMatcher<ChoiceOption<K, T>>;\n readonly matchFields: readonly string[];\n readonly locale: Intl.LocalesArgument;\n /** A source filters by itself: its options all show, the matches marked. */\n readonly sourced: boolean;\n readonly chosenKeys: readonly K[];\n /** The most keys the value may hold, or `null`. */\n readonly limit: number | null;\n /** Options by their folded label: a query naming one creates nothing. */\n readonly byLabel: ReadonlyMap<string, ChoiceOption<K, T>>;\n /** A query no label matches may be created: `onCreate`, with a search box. */\n readonly canCreate: boolean;\n /** The \"Select all\" row's scope, shown above any options, or `null` for none. */\n readonly selectAll: \"matching\" | \"loaded\" | \"all\" | null;\n /** A \"Try again\" row: the source failed. */\n readonly retry: boolean;\n readonly strings: FormsMessages;\n /** \"Select all\" waits on the source. */\n readonly selectingAll: boolean;\n /** A creation waits on the app. */\n readonly creating: boolean;\n}\n\n/** The rows a choice list draws, and how each stands. */\nexport interface OptionRows<K extends OptionKey, T> {\n /** The options the search leaves, in order. */\n readonly shownOptions: readonly ChoiceOption<K, T>[];\n readonly matches: ReadonlyMap<ChoiceOption<K, T>, OptionMatch>;\n readonly rows: readonly OptionRow<ChoiceOption<K, T>>[];\n readonly navigableRows: readonly NavigableRow[];\n /** The first chosen option's row, or `null`. */\n readonly chosenRow: number | null;\n /** The value holds as many keys as it may. */\n readonly atLimit: boolean;\n /** The text a \"Create\" row would create, or `null` for none. */\n readonly createText: string | null;\n /** Disabled, or past the limit and not chosen. */\n readonly isDisabled: (option: ChoiceOption<K, T>) => boolean;\n readonly isSelected: (option: ChoiceOption<K, T>) => boolean;\n /** A row that acts as the list draws it: its label, tick, spinner and whether it can be chosen. */\n readonly describeAction: (action: OptionAction) => ActionState;\n}\n\n/**\n * The rows of a choice list: the options the query leaves (all of a\n * source's, which filters by itself), under their groups, between the\n * rows that act (\"Select all\" first, \"Try again\" and \"Create\" last).\n */\nexport function useOptionRows<K extends OptionKey, T>({\n listed,\n query,\n match,\n matchFields,\n locale,\n sourced,\n chosenKeys,\n limit,\n byLabel,\n canCreate,\n selectAll,\n retry,\n strings,\n selectingAll,\n creating,\n}: OptionRowsProps<K, T>): OptionRows<K, T> {\n type O = ChoiceOption<K, T>;\n const index = useMemo(\n () => createOptionIndex(listed, matchFields, locale),\n [listed, matchFields, locale],\n );\n const { shownOptions, matches } = useMemo(() => {\n const found = new Map<O, OptionMatch>();\n if (query.trim() === \"\") {\n return { shownOptions: listed, matches: found };\n }\n const hits =\n typeof match === \"function\"\n ? index.search(query, \"contains\", match)\n : index.search(query, match);\n for (const hit of hits) {\n found.set(hit.option, hit.match);\n }\n return {\n shownOptions: sourced ? listed : hits.map((hit) => hit.option),\n matches: found,\n };\n }, [index, listed, query, match, sourced]);\n\n const atLimit = limit !== null && chosenKeys.length >= limit;\n const isDisabled = useCallback(\n (option: O): boolean =>\n option.disabled === true ||\n (atLimit && !hasKey(chosenKeys, option.value)),\n [atLimit, chosenKeys],\n );\n const isSelected = useCallback(\n (option: O): boolean => hasKey(chosenKeys, option.value),\n [chosenKeys],\n );\n\n const exactMatch = byLabel.get(foldText(query.trim(), locale).text) ?? null;\n const createText =\n canCreate && query.trim() !== \"\" && exactMatch === null\n ? query.trim()\n : null;\n const rows = useMemo(\n () =>\n flattenOptions(shownOptions, {\n start:\n selectAll === null || shownOptions.length === 0\n ? []\n : [{ kind: \"selectAll\", scope: selectAll }],\n end: [\n ...(retry ? [{ kind: \"retry\" } as const] : []),\n ...(createText === null\n ? []\n : [{ kind: \"create\", text: createText } as const]),\n ],\n }),\n [shownOptions, selectAll, retry, createText],\n );\n const navigableRows = useMemo(\n () =>\n rows.map((row) => ({\n kind: row.kind,\n disabled: row.kind === \"option\" && isDisabled(row.option),\n })),\n [rows, isDisabled],\n );\n const chosenRow = useMemo(() => {\n const found = rows.findIndex(\n (row) => row.kind === \"option\" && hasKey(chosenKeys, row.option.value),\n );\n return found === -1 ? null : found;\n }, [rows, chosenKeys]);\n\n const describeAction = useCallback(\n (action: OptionAction): ActionState => {\n switch (action.kind) {\n case \"selectAll\": {\n const scope = scopeState(chosenKeys, shownOptions);\n return {\n label:\n action.scope === \"loaded\"\n ? strings.selectAllLoaded(shownOptions.length)\n : strings.selectAll,\n checked:\n scope === \"all\" ? true : scope === \"some\" ? \"mixed\" : false,\n busy: selectingAll,\n disabled:\n scope !== \"all\" && !canSelectAll(chosenKeys, shownOptions, limit),\n };\n }\n case \"create\":\n return {\n label: strings.createOption(action.text),\n checked: null,\n busy: creating,\n disabled: false,\n };\n case \"retry\":\n return {\n label: strings.retry,\n checked: null,\n busy: false,\n disabled: false,\n };\n }\n },\n [chosenKeys, shownOptions, strings, selectingAll, limit, creating],\n );\n\n return {\n shownOptions,\n matches,\n rows,\n navigableRows,\n chosenRow,\n atLimit,\n createText,\n isDisabled,\n isSelected,\n describeAction,\n };\n}\n\n/** What choosing each kind of row does. */\nexport interface RowChoosers<K extends OptionKey, T> {\n readonly selectAll: (nativeEvent: Event) => void;\n readonly create: (text: string, nativeEvent: Event) => void;\n readonly retry: () => void;\n readonly option: (option: ChoiceOption<K, T>, nativeEvent: Event) => void;\n}\n\n/** Chooses the row at `row`: an option, or a row that acts unless it is disabled. Headers choose nothing. */\nexport function chooseRow<K extends OptionKey, T>(\n { rows, describeAction }: OptionRows<K, T>,\n row: number,\n nativeEvent: Event,\n choosers: RowChoosers<K, T>,\n): void {\n const shown = rows[row];\n if (shown === undefined || shown.kind === \"header\") {\n return;\n }\n if (shown.kind === \"option\") {\n choosers.option(shown.option, nativeEvent);\n return;\n }\n const { action } = shown;\n if (describeAction(action).disabled) {\n return;\n }\n switch (action.kind) {\n case \"selectAll\":\n choosers.selectAll(nativeEvent);\n return;\n case \"create\":\n choosers.create(action.text, nativeEvent);\n return;\n case \"retry\":\n choosers.retry();\n return;\n }\n}\n","import {\n findDuplicateKeys,\n type ChangeSource,\n type ChoiceOption,\n type FormsMessages,\n type LoadErrorEvent,\n type MatchMode,\n type OptionCache,\n type OptionKey,\n type OptionMatcher,\n type QueryChangeEvent,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n type Ref,\n} from \"react\";\nimport { warnOnce } from \"../dev\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { useFormSettings } from \"../settings\";\nimport { selectKind, selectValidators, type SelectShape } from \"./selectModel\";\nimport {\n useChoiceField,\n type ChoiceField,\n type ChoiceFieldProps,\n} from \"./useChoiceField\";\nimport { useChoiceOptions, type ChoiceOptions } from \"./useChoiceOptions\";\nimport {\n useChoiceQuery,\n useQueryText,\n type ChoiceQuery,\n} from \"./useChoiceQuery\";\nimport { useOptionsByLabel } from \"./useCreateOption\";\nimport type { OptionSource } from \"./useOptionSource\";\n\n/** What `useSelectField` reads, on every render. */\nexport interface SelectFieldProps<\n K extends OptionKey,\n T,\n F,\n V,\n D extends object,\n> {\n /** The props the field reads, but for its validators and notices. */\n readonly field: Omit<ChoiceFieldProps<V, D>, \"validators\" | \"notices\">;\n readonly ref: Ref<HTMLElement> | undefined;\n readonly shape: SelectShape<K, T, V, D>;\n readonly options: readonly ChoiceOption<K, T>[];\n readonly valueOptions: readonly ChoiceOption<K, T>[];\n readonly source: OptionSource<ChoiceOption<K, T>, F> | undefined;\n readonly filters: F | undefined;\n readonly cache: OptionCache<ChoiceOption<K, T>> | undefined;\n readonly match: MatchMode | OptionMatcher<ChoiceOption<K, T>>;\n readonly matchFields: readonly string[];\n readonly onLoadError: ((event: LoadErrorEvent<F>) => void) | undefined;\n readonly searchable: boolean;\n readonly allowCustomValue: boolean;\n /** Options can be created from the search text: `onCreate`. */\n readonly creates: boolean;\n readonly maxCount: number | undefined;\n readonly minCount: number | undefined;\n readonly validate: Validator<V> | readonly Validator<V>[] | undefined;\n readonly onQueryChange:\n ((event: QueryChangeEvent<Event>) => void) | undefined;\n /** The search text changed, after `onQueryChange` heard it. */\n readonly onQuery: (query: string, source: ChangeSource) => void;\n}\n\n/** What `useSelectField` gives the select. */\nexport interface SelectField<K extends OptionKey, T, F, V, D extends object> {\n readonly choice: ChoiceField<V, D>;\n /** The keys of the value. */\n readonly chosenKeys: readonly K[];\n readonly catalog: ChoiceOptions<K, T, F>;\n readonly search: ChoiceQuery;\n /** Options by their folded label, while free text or a creation can name one. */\n readonly byLabel: ReadonlyMap<string, ChoiceOption<K, T>>;\n readonly locale: Intl.LocalesArgument;\n /** The search box's text is the field's own: one value. */\n readonly searchText: boolean;\n /** Free text no label matches commits as the key. */\n readonly customValue: boolean;\n}\n\n/**\n * A select bound to its field: its options and their labels, its\n * `ChoiceKind` and validators through `useChoiceField`, and its search\n * text. A key whose option the source no longer has warns beside the\n * validators' messages.\n */\nexport function useSelectField<K extends OptionKey, T, F, V, D extends object>({\n field,\n ref,\n shape,\n options,\n valueOptions,\n source,\n filters,\n cache,\n match,\n matchFields,\n onLoadError,\n searchable,\n allowCustomValue,\n creates,\n maxCount,\n minCount,\n validate,\n onQueryChange,\n onQuery,\n}: SelectFieldProps<K, T, F, V, D>): SelectField<K, T, F, V, D> {\n const settings = useFormSettings();\n const context = useFieldContext();\n const needsValue = field.required === true || context?.required === true;\n // The search box's text is the field's own only with one value: chips\n // hold several, and the box holds only the query.\n const searchText = searchable && !shape.multiple;\n const customValue = allowCustomValue && searchText;\n // The locale `useChoiceField` settles on, wanted before it is called.\n const locale = field.locale ?? (context?.settings ?? settings).locale;\n\n useEffect(() => {\n const duplicates = findDuplicateKeys(options);\n if (duplicates.length > 0) {\n warnOnce(\n `select-duplicates:${duplicates.join(\",\")}`,\n `Select was given more than one option with the key ${duplicates.map((key) => `\"${key}\"`).join(\", \")}; the first gives the label.`,\n );\n }\n }, [options]);\n useEffect(() => {\n if (allowCustomValue && !searchText) {\n warnOnce(\n \"select-custom-value\",\n \"Select takes allowCustomValue only with searchable and one value; it is ignored.\",\n );\n }\n }, [allowCustomValue, searchText]);\n\n const catalog = useChoiceOptions<K, T, F>({\n options,\n valueOptions,\n source,\n filters,\n cache,\n match,\n matchFields,\n locale,\n onLoadError,\n resolves: !customValue,\n });\n const { optionOf, missingNotices } = catalog;\n // The query of a search box holding only a query: several values.\n const typed = useQueryText();\n const byLabel = useOptionsByLabel(\n catalog.listed,\n locale,\n customValue || creates,\n );\n const kind = useMemo(\n () =>\n selectKind({\n shape,\n optionOf,\n searchText,\n customValue,\n byLabel,\n locale,\n typedQuery: typed.read,\n }),\n [shape, optionOf, searchText, customValue, byLabel, locale, typed.read],\n );\n const validators = useMemo(\n () => selectValidators({ shape, needsValue, maxCount, minCount, validate }),\n [shape, needsValue, maxCount, minCount, validate],\n );\n const notices = useCallback(\n (value: V | null, messages: FormsMessages) =>\n missingNotices(shape.keys(value), messages),\n [missingNotices, shape],\n );\n const choice = useChoiceField(\n {\n ...field,\n validators,\n notices,\n onInput: (event) => {\n field.onInput?.(event);\n reportInput(event.source, event.nativeEvent);\n },\n },\n kind,\n searchText,\n ref,\n );\n const search = useChoiceQuery({\n searchable,\n searchText,\n keepsFreeText: customValue,\n controller: choice.controller,\n draft: choice.query,\n typed,\n control: choice.control,\n onQueryChange,\n onQuery,\n });\n function reportInput(source: ChangeSource, nativeEvent: Event | null): void {\n search.report(source, nativeEvent);\n }\n\n const { value } = choice.state;\n const chosenKeys = useMemo(() => shape.keys(value), [shape, value]);\n // Keys of the value whose labels nothing holds yet are asked of the\n // source; each once, until the list opens again.\n const { resolveMissing } = catalog;\n useLayoutEffect(() => {\n resolveMissing(chosenKeys);\n }, [resolveMissing, chosenKeys]);\n\n return {\n choice,\n chosenKeys,\n catalog,\n search,\n byLabel,\n locale,\n searchText,\n customValue,\n };\n}\n","import {\n keyText,\n type ChangeSource,\n matchOption,\n type ChoiceOption,\n type FieldMessage,\n type FormsMessages,\n type KeyLookup,\n type LoadedOptions,\n type LoadErrorEvent,\n type MatchMode,\n type OptionCache,\n type OptionKey,\n type OptionMatcher,\n type OptionSourceController,\n type SourceState,\n} from \"@gridkitjs/forms-core\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { NO_OPTIONS, optionFinder } from \"./selectModel\";\nimport { useOptionSource, type OptionSource } from \"./useOptionSource\";\n\n/** What `useChoiceOptions` reads, on every render. */\nexport interface ChoiceOptionsProps<K extends OptionKey, T, F> {\n readonly options: readonly ChoiceOption<K, T>[];\n readonly valueOptions: readonly ChoiceOption<K, T>[];\n readonly source: OptionSource<ChoiceOption<K, T>, F> | undefined;\n readonly filters: F | undefined;\n readonly cache: OptionCache<ChoiceOption<K, T>> | undefined;\n readonly match: MatchMode | OptionMatcher<ChoiceOption<K, T>>;\n readonly matchFields: readonly string[];\n readonly locale: Intl.LocalesArgument;\n readonly onLoadError: ((event: LoadErrorEvent<F>) => void) | undefined;\n /**\n * Whether keys of the value no option holds are asked of the source's\n * `resolve`; not when free text is a key.\n */\n readonly resolves: boolean;\n}\n\n/** Where a choice input's options and their labels stand, as a render reads them. */\nexport interface ChoiceOptions<K extends OptionKey, T, F> {\n readonly controller: OptionSourceController<\n ChoiceOption<K, T>,\n F,\n AbortSignal\n >;\n readonly sourced: boolean;\n readonly state: SourceState<ChoiceOption<K, T>, F>;\n /** The source's result shown: its last answer, kept while a newer one loads. */\n readonly loaded: LoadedOptions<ChoiceOption<K, T>> | null;\n /** The options the list is made from: the local ones, or the source's loaded ones. */\n readonly listed: readonly ChoiceOption<K, T>[];\n /** The source has another page. */\n readonly pagedMore: boolean;\n readonly busy: boolean;\n readonly failed: boolean;\n /** The option of a key: a local one, one of `valueOptions`, or one the source's cache holds. */\n readonly optionOf: (key: K) => ChoiceOption<K, T> | null;\n /** What is known of a key's option: `unresolved` without a source's `resolve`. */\n readonly lookupOf: (key: K) => KeyLookup<ChoiceOption<K, T>>[\"kind\"];\n /** Asks the source for the labels of `keys` no option holds, each once until `askAgain`. */\n readonly resolveMissing: (keys: readonly K[]) => void;\n /** Keys whose labels failed to load may be asked again. */\n readonly askAgain: () => void;\n /** The list opened: a source is asked for `query`, at once unless the list opened from typing. */\n readonly opened: (typing: boolean, query: string) => void;\n /**\n * The search text changed while the list shows: a source is asked for\n * it, unless the change only dropped or settled it.\n */\n readonly searched: (query: string, source: ChangeSource) => void;\n /** A warning for each of `keys` the source no longer has. */\n readonly missingNotices: (\n keys: readonly K[],\n messages: FormsMessages,\n ) => readonly FieldMessage[];\n}\n\n/** What a list shows from a source's state: its result, or the one it keeps while loading. */\nfunction loadedOf<O, F>(state: SourceState<O, F>): LoadedOptions<O> | null {\n switch (state.kind) {\n case \"idle\":\n return null;\n case \"loaded\":\n return state.result;\n case \"waiting\":\n case \"loading\":\n case \"failed\":\n return state.shown;\n }\n}\n\n/**\n * A choice input's options, local or from a `source` through\n * `useOptionSource`, and the labels of its value: from the options, from\n * `valueOptions`, or asked of the source's `resolve`. A key the source no\n * longer has stays, with a warning.\n */\nexport function useChoiceOptions<K extends OptionKey, T, F>({\n options,\n valueOptions,\n source,\n filters,\n cache,\n match,\n matchFields,\n locale,\n onLoadError,\n resolves,\n}: ChoiceOptionsProps<K, T, F>): ChoiceOptions<K, T, F> {\n type O = ChoiceOption<K, T>;\n const matchesOption = useCallback(\n (option: O, text: string): boolean => {\n const context = {\n mode: \"contains\" as const,\n locale,\n fields: matchFields,\n };\n if (typeof match !== \"function\") {\n return matchOption(option, text, { ...context, mode: match }) !== null;\n }\n const found = match(option, text, {\n ...context,\n defaultMatch: (candidate, query) =>\n matchOption(candidate, query, context),\n });\n return found !== null && found !== false;\n },\n [match, matchFields, locale],\n );\n const view = useOptionSource<O, F>({\n source,\n // Without filters of the app's, `F` is `undefined`.\n filters: filters as F,\n cache,\n match: matchesOption,\n onLoadError,\n });\n const { controller, sourced, lookup, state } = view;\n const resolvable = sourced && source?.resolve !== undefined && resolves;\n\n const knownOption = useMemo(\n () => optionFinder([...options, ...valueOptions]),\n [options, valueOptions],\n );\n // Labels arrive in the source's cache, and `lookup` changes with each.\n const optionOf = useCallback(\n (key: K): O | null => {\n const local = knownOption(key);\n if (local !== null) {\n return local;\n }\n const found = lookup(key);\n return found.kind === \"known\" ? found.option : null;\n },\n [knownOption, lookup],\n );\n const lookupOf = useCallback(\n (key: K): KeyLookup<O>[\"kind\"] => {\n if (optionOf(key) !== null) {\n return \"known\";\n }\n return resolvable ? lookup(key).kind : \"unresolved\";\n },\n [optionOf, resolvable, lookup],\n );\n\n // Keys whose labels were asked of the source since the list last opened.\n const asked = useRef(new Set<string>());\n const resolveMissing = useCallback(\n (keys: readonly K[]): void => {\n if (!resolvable) {\n return;\n }\n const ask = keys.filter(\n (key) =>\n knownOption(key) === null &&\n lookup(key).kind === \"unresolved\" &&\n !asked.current.has(keyText(key)),\n );\n if (ask.length > 0) {\n controller.resolve(ask);\n for (const key of ask) {\n asked.current.add(keyText(key));\n }\n }\n },\n [resolvable, knownOption, lookup, controller],\n );\n const askAgain = useCallback(() => {\n asked.current.clear();\n }, []);\n\n const missingNotices = useCallback(\n (keys: readonly K[], messages: FormsMessages): readonly FieldMessage[] =>\n resolvable\n ? keys\n .filter((key) => lookupOf(key) === \"missing\")\n .map((key) => ({\n severity: \"warning\",\n text: messages.optionMissing(keyText(key)),\n code: \"optionMissing\",\n source: \"validate\",\n }))\n : [],\n [resolvable, lookupOf],\n );\n\n const opened = (typing: boolean, query: string): void => {\n if (!sourced) {\n return;\n }\n if (typing) {\n controller.query(query);\n } else {\n controller.queryNow(query);\n }\n };\n const searched = (query: string, source: ChangeSource): void => {\n if (\n sourced &&\n source !== \"revert\" &&\n source !== \"picker\" &&\n source !== \"api\"\n ) {\n controller.query(query);\n }\n };\n\n const loaded = sourced ? loadedOf(state) : null;\n return {\n controller,\n sourced,\n state,\n loaded,\n listed: sourced ? (loaded?.options ?? NO_OPTIONS) : options,\n pagedMore: loaded !== null && loaded.next !== null,\n busy: state.kind === \"waiting\" || state.kind === \"loading\",\n failed: state.kind === \"failed\",\n optionOf,\n lookupOf,\n resolveMissing,\n askAgain,\n opened,\n searched,\n missingNotices,\n };\n}\n","import {\n createOptionSourceController,\n SOURCE_IDLE,\n type ChoiceOption,\n type KeyLookup,\n type KeyOf,\n type OptionSource as CoreOptionSource,\n type LoadErrorEvent,\n type OptionCache,\n type OptionQuery,\n type OptionSourceController,\n type OptionSourceOptions,\n type SourceState,\n} from \"@gridkitjs/forms-core\";\nimport { abortSignals, scheduleTimeout } from \"@gridkitjs/forms-dom\";\nimport { useEffect, useRef, useState, useSyncExternalStore } from \"react\";\n\n/**\n * Where a choice input's options come from when they are not a local\n * list: forms-core's `OptionSource` with the browser's `AbortSignal`, so\n * `search` passes its `signal` straight to `fetch`.\n */\nexport type OptionSource<\n O extends ChoiceOption,\n F = undefined,\n> = CoreOptionSource<O, F, AbortSignal>;\n\n/** What `useOptionSource` reads, on every render. */\nexport interface OptionSourceProps<O extends ChoiceOption, F> {\n readonly source: OptionSource<O, F> | undefined;\n readonly filters: F;\n readonly cache: OptionCache<O> | undefined;\n /** The input's matcher, for a source that leaves matching to the input. */\n readonly match: (option: O, text: string) => boolean;\n readonly onLoadError: ((event: LoadErrorEvent<F>) => void) | undefined;\n}\n\n/** A source's state as a render reads it. */\nexport interface OptionSourceView<O extends ChoiceOption, F> {\n /**\n * The controller, made whether or not there is a source: without one\n * it never asks anything, and its cache still holds the options an\n * input learns, such as one it created.\n */\n readonly controller: OptionSourceController<O, F, AbortSignal>;\n /** Whether the props hold a source. */\n readonly sourced: boolean;\n readonly state: SourceState<O, F>;\n /**\n * What the cache knows of a key. A new function each time labels\n * arrive, so what reads them through it draws again.\n */\n readonly lookup: (key: KeyOf<O>) => KeyLookup<O>;\n}\n\ninterface SourceSnapshot<O extends ChoiceOption, F> {\n readonly state: SourceState<O, F>;\n readonly version: number;\n readonly lookup: (key: KeyOf<O>) => KeyLookup<O>;\n}\n\n/** The source of an input with none: never asked. */\nfunction noSource<O extends ChoiceOption, F>(): OptionSource<O, F> {\n return { search: () => Promise.resolve([]) };\n}\n\n/**\n * Binds a choice input to its `source` through forms-core's option source\n * controller, made once and handed the latest props on every render\n * (`setOptions` is silent): requests with the browser's `AbortSignal` and\n * timers, the input's cache, and the view of its state to draw. The\n * controller aborts what is in flight as the input unmounts, and stays\n * usable for a second mount.\n */\nexport function useOptionSource<O extends ChoiceOption, F>(\n props: OptionSourceProps<O, F>,\n): OptionSourceView<O, F> {\n const { onLoadError } = props;\n const options: OptionSourceOptions<O, F, AbortSignal> = {\n source: props.source ?? noSource<O, F>(),\n filters: props.filters,\n abort: abortSignals,\n schedule: scheduleTimeout,\n cache: props.cache,\n match: props.match,\n onError: (error: unknown, query: OptionQuery<F>) => {\n onLoadError?.({ error, query });\n },\n };\n const [controller] = useState(() => createOptionSourceController(options));\n controller.setOptions(options);\n\n const snapshot = useRef<SourceSnapshot<O, F> | null>(null);\n // On the server no source is asked, so the list never loads.\n const [serverView] = useState<SourceSnapshot<O, F>>(() => ({\n state: SOURCE_IDLE,\n version: 0,\n lookup: (key) => controller.lookup(key),\n }));\n const view = useSyncExternalStore(\n controller.subscribe,\n () => {\n const state = controller.getState();\n const version = controller.getCache().getVersion();\n const last = snapshot.current;\n if (last?.state === state && last.version === version) {\n return last;\n }\n const next: SourceSnapshot<O, F> = {\n state,\n version,\n lookup: (key) => controller.lookup(key),\n };\n snapshot.current = next;\n return next;\n },\n () => serverView,\n );\n\n useEffect(\n () => () => {\n controller.destroy();\n },\n [controller],\n );\n\n return {\n controller,\n sourced: props.source !== undefined,\n state: view.state,\n lookup: view.lookup,\n };\n}\n","import type {\n ChangeSource,\n FieldController,\n PopupCloseReason,\n QueryChangeEvent,\n} from \"@gridkitjs/forms-core\";\nimport { useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport { queryOf } from \"./useChoiceField\";\n\n/** A search box's query held apart from the field: a choice input with several values. */\nexport interface QueryText {\n /** The query, as the last render drew it. */\n readonly text: string;\n /** The query now, between renders. */\n readonly read: () => string;\n /** Sets the query, writing it into `input`, the box. */\n readonly write: (text: string, input: HTMLInputElement | null) => void;\n}\n\n/**\n * The query of a search box whose text is not the field's: the field\n * holds several values as chips, and the box only searches.\n */\nexport function useQueryText(): QueryText {\n const typed = useRef(\"\");\n const [text, setText] = useState(\"\");\n const read = useCallback(() => typed.current, []);\n const write = useCallback((next: string, input: HTMLInputElement | null) => {\n if (input !== null && input.value !== next) {\n input.value = next;\n }\n typed.current = next;\n setText(next);\n }, []);\n return { text, read, write };\n}\n\nfunction changeSourceOf(event: Event): ChangeSource {\n if (event instanceof InputEvent) {\n if (event.inputType === \"insertFromPaste\") {\n return \"paste\";\n }\n if (event.inputType === \"insertFromDrop\") {\n return \"drop\";\n }\n }\n return \"typing\";\n}\n\n/** What `useChoiceQuery` reads, on every render. */\nexport interface ChoiceQueryProps<V, D extends object> {\n readonly searchable: boolean;\n /** The search box's text is the field's draft: one value. */\n readonly searchText: boolean;\n /** Free text left in the box stays as the list closes on leaving, for the commit on leaving. */\n readonly keepsFreeText: boolean;\n readonly controller: FieldController<V, D, Event>;\n /** The field's draft as the last render drew it. */\n readonly draft: string;\n /** The query held apart from the field, with several values. */\n readonly typed: QueryText;\n readonly control: HTMLElement | null;\n readonly onQueryChange:\n ((event: QueryChangeEvent<Event>) => void) | undefined;\n /** The query changed, after `onQueryChange` heard it. */\n readonly onQuery: (query: string, source: ChangeSource) => void;\n}\n\n/** What `useChoiceQuery` gives the input. */\nexport interface ChoiceQuery {\n /** The query, as this render draws it. */\n readonly query: string;\n /** The query now, between renders. */\n readonly current: () => string;\n /** Tells `onQueryChange` the query, when it changed since it last heard. */\n readonly report: (source: ChangeSource, nativeEvent: Event | null) => void;\n /** Sets the query held apart from the field. */\n readonly setTyped: (\n text: string,\n source: ChangeSource,\n nativeEvent: Event | null,\n ) => void;\n /** Drops the query as the list closes for `reason`. */\n readonly drop: (reason: PopupCloseReason) => void;\n}\n\n/**\n * A choice input's search text: the field's draft with one value, or with\n * several a query of its own, read from the search box's `input` listener\n * (a layout effect that removes it), which is heard before the combobox\n * hears the same input open the list.\n */\nexport function useChoiceQuery<V, D extends object>({\n searchable,\n searchText,\n keepsFreeText,\n controller,\n draft,\n typed,\n control,\n onQueryChange,\n onQuery,\n}: ChoiceQueryProps<V, D>): ChoiceQuery {\n const last = useRef(\"\");\n // No control while rendering on the server, where `HTMLInputElement`\n // does not exist.\n const input =\n !searchText && control !== null && control instanceof HTMLInputElement\n ? control\n : null;\n\n const current = (): string =>\n searchText ? queryOf(controller.getState()) : typed.read();\n\n const report = (source: ChangeSource, nativeEvent: Event | null): void => {\n const query = current();\n const previousQuery = last.current;\n if (query === previousQuery) {\n return;\n }\n last.current = query;\n onQueryChange?.({ query, previousQuery, source, nativeEvent });\n onQuery(query, source);\n };\n\n const setTyped = (\n text: string,\n source: ChangeSource,\n nativeEvent: Event | null,\n ): void => {\n typed.write(text, input);\n report(source, nativeEvent);\n };\n\n const drop = (reason: PopupCloseReason): void => {\n const dropped = reason === \"picker\" ? \"picker\" : \"revert\";\n if (searchText) {\n const state = controller.getState();\n const keepsText =\n keepsFreeText && (reason === \"blur\" || reason === \"outside\");\n if (queryOf(state) !== \"\" && !keepsText) {\n controller.change(state.value, {\n source: \"revert\",\n nativeEvent: null,\n input: null,\n });\n }\n report(dropped, null);\n } else if (searchable && typed.read() !== \"\") {\n setTyped(\"\", dropped, null);\n }\n };\n\n const latestSetTyped = useRef(setTyped);\n useLayoutEffect(() => {\n latestSetTyped.current = setTyped;\n });\n useLayoutEffect(() => {\n if (input === null) {\n return undefined;\n }\n const events = new AbortController();\n const read = (event: Event): void => {\n if (event instanceof InputEvent && event.isComposing) {\n return;\n }\n latestSetTyped.current(input.value, changeSourceOf(event), event);\n };\n input.addEventListener(\"input\", read, { signal: events.signal });\n input.addEventListener(\"compositionend\", read, { signal: events.signal });\n return () => {\n events.abort();\n };\n }, [input]);\n\n return {\n query: searchable ? (searchText ? draft : typed.text) : \"\",\n current,\n report,\n setTyped,\n drop,\n };\n}\n","import {\n availableDateRule,\n compareDateTimes,\n compareInstants,\n dateLayout,\n dateTimeDetails,\n dateTimeFormatter,\n dateTimeParser,\n exactInstantOf,\n formatDateTime,\n formatInstant,\n instantDetails,\n instantFormatter,\n instantParser,\n instantZoneMessage,\n isInstant,\n isPlainDateTime,\n maxDateTimeRule,\n maxInstantRule,\n minDateTimeRule,\n minInstantRule,\n pivotYear,\n requiredRule,\n segmentsTime,\n wallClockOf,\n type DateTimeDetails,\n type DateTimeFieldOptions,\n type FieldMessageInput,\n type Instant,\n type InstantFieldOptions,\n type PlainDate,\n type PlainDateTime,\n type PlainTime,\n type PopupOpenChange,\n type TimeZoneDisambiguation,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, useState } from \"react\";\nimport type { CalendarSettings } from \"../calendar/calendarProps\";\nimport type { FieldChangeEvent } from \"../events\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { CalendarIcon, InputFrame } from \"../text/parts\";\nimport { DateTimePicker } from \"../time/DateTimePicker\";\nimport { segmentTimeOption } from \"../time/TimeColumns\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { focusedDay, nowFor, todayFor } from \"./DateInput\";\nimport { SegmentedControl, type SegmentedPicker } from \"./SegmentedControl\";\nimport type {\n DayLimits,\n SegmentedInputProps,\n TimeSettings,\n} from \"./segmentedProps\";\nimport {\n createSegmentsAccess,\n typedSegments,\n typingSegment,\n type SegmentedKind,\n} from \"./useSegmentedInput\";\n\n/** What a date-time input holds: a wall clock (`\"local\"`) or an exact moment (`\"instant\"`). */\nexport type DateTimeValueType = \"local\" | \"instant\";\n\n/** The value of a date-time input of `T`. */\nexport type DateTimeValue<T extends DateTimeValueType> = T extends \"instant\"\n ? Instant\n : PlainDateTime;\n\ninterface DateTimeOwnProps<T extends DateTimeValueType>\n extends\n SegmentedInputProps<DateTimeValue<T>, DateTimeDetails>,\n Omit<DayLimits, \"min\" | \"max\" | \"timeZone\">,\n CalendarSettings,\n TimeSettings {\n /** The calendar button and its popup of a calendar and time columns; on by default. */\n readonly calendar?: boolean | undefined;\n /** The popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n /** The earliest moment allowed, inclusive. */\n readonly min?: DateTimeValue<T> | undefined;\n /** The latest moment allowed, inclusive. */\n readonly max?: DateTimeValue<T> | undefined;\n /** The time a date gets when its time is left empty; `\"00:00\"` by default. */\n readonly defaultTime?: PlainTime | undefined;\n /** Which moment a wall clock in a skipped or repeated hour means; `\"compatible\"` by default, as Temporal's. */\n readonly disambiguation?: TimeZoneDisambiguation | undefined;\n /** `\"local\"` (default): a wall clock, `PlainDateTime`. `\"instant\"`: an exact moment, typed in `timeZone`. */\n readonly valueType?: T | undefined;\n}\n\n/** The zone a value is typed and shown in: required for an instant, where \"today\" is for a wall clock. */\nexport type DateTimeZoneProps<T extends DateTimeValueType> = T extends \"instant\"\n ? { readonly timeZone: string }\n : { readonly timeZone?: string | undefined };\n\nexport type DateTimeInputProps<T extends DateTimeValueType = \"local\"> =\n DateTimeOwnProps<T> & DateTimeZoneProps<T>;\n\ntype LocalProps = DateTimeInputProps;\ntype InstantProps = DateTimeInputProps<\"instant\">;\n\n/** The day of a wall clock. */\nfunction dayOf(dateTime: PlainDateTime): PlainDate {\n return dateTime.slice(0, 10) as PlainDate;\n}\n\n/**\n * What both kinds of date-time input share: settings, the layout, today,\n * and the time a date gets when only the date was given, which is the\n * time already typed in the segments, else `defaultTime`. So a shortcut\n * (`t`, `+3`) or a pasted date sets the date and keeps the time.\n */\nfunction useDateTimeSetup(\n props: LocalProps | InstantProps,\n todayZone: string | undefined,\n) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const [segments] = useState(createSegmentsAccess);\n const { hourCycle, precision, numberingSystem, displayFormat } = props;\n const layout = dateLayout(\n { locale, fields: \"dateTime\", hourCycle, precision, numberingSystem },\n messages,\n );\n const today = todayFor(todayZone);\n const base = {\n today,\n shortcuts: props.shortcuts ?? true,\n hourCycle,\n precision,\n numberingSystem,\n displayFormat,\n activeSegment: () => typingSegment(segments),\n } satisfies Partial<DateTimeFieldOptions>;\n const keptTime = (): PlainTime =>\n segmentsTime(layout, typedSegments(segments)) ??\n props.defaultTime ??\n \"00:00\";\n return {\n locale,\n messages,\n segments,\n layout,\n today,\n base,\n keptTime,\n needsValue: props.required === true || field?.required === true,\n };\n}\n\n/** How a date-time input's value reads as a wall clock in its zone, and back. */\ninterface WallClockView<V> {\n readonly toWall: (value: V) => PlainDateTime;\n readonly fromWall: (wall: PlainDateTime) => V;\n readonly zone: string | undefined;\n}\n\n/**\n * A date-time input's picker: a calendar and time columns working on the\n * wall clock its value shows, unless `calendar` is `false`.\n */\nfunction dateTimePicker<V>(\n props: LocalProps | InstantProps,\n setup: ReturnType<typeof useDateTimeSetup>,\n view: WallClockView<V>,\n limits: { readonly min: V | undefined; readonly max: V | undefined },\n): SegmentedPicker<V> | undefined {\n if (props.calendar === false) {\n return undefined;\n }\n const { locale, messages, layout, today, keptTime } = setup;\n const wallOf = (value: V | undefined) =>\n value === undefined ? null : view.toWall(value);\n return {\n label: messages.chooseDateTime,\n icon: <CalendarIcon />,\n buttonClassName: \"gridkit-forms-calendar-button\",\n popupClassName: \"gridkit-forms-date-time-popup\",\n onOpenChange: props.onOpenChange,\n initialFocus: (panel) => segmentTimeOption(panel) ?? focusedDay(panel),\n content: ({ value, id, pick, close, setEscapeHandler }) => (\n <DateTimePicker\n id={id}\n value={value === null ? null : view.toWall(value)}\n layout={layout}\n minuteStep={props.minuteStep}\n min={wallOf(limits.min)}\n max={wallOf(limits.max)}\n isDateDisabled={props.isDateDisabled}\n timeZone={view.zone}\n firstDayOfWeek={props.firstDayOfWeek}\n weekNumbers={props.weekNumbers}\n weekNumbering={props.weekNumbering}\n locale={locale}\n strings={messages}\n today={today}\n now={nowFor(view.zone)}\n keptTime={keptTime}\n onPick={(wall, nativeEvent) => {\n pick(view.fromWall(wall), nativeEvent);\n }}\n close={close}\n setEscapeHandler={setEscapeHandler}\n />\n ),\n };\n}\n\nfunction LocalDateTimeControl(props: LocalProps) {\n const { min, max, isDateDisabled, validate, minuteStep, timeZone } = props;\n const setup = useDateTimeSetup(props, timeZone);\n const { locale, messages, base, today } = setup;\n const { displayFormat } = props;\n const options = (): DateTimeFieldOptions => ({\n ...base,\n min,\n max,\n defaultTime: setup.keptTime(),\n });\n const kind: SegmentedKind<PlainDateTime, DateTimeDetails> = {\n name: \"DateTimeInput\",\n layout: setup.layout,\n defaultParse: (text, context) => dateTimeParser(options())(text, context),\n defaultFormat: dateTimeFormatter(base),\n details: (current, _previous, cause) =>\n dateTimeDetails(current, cause, { ...options(), locale, messages }),\n display: (value) => formatDateTime(value, locale, displayFormat),\n serialize: (value) => value,\n isValue: isPlainDateTime,\n inLimits: (value) =>\n (min === undefined || compareDateTimes(value, min) >= 0) &&\n (max === undefined || compareDateTimes(value, max) <= 0),\n shortcuts: base.shortcuts,\n minuteStep,\n today,\n pivot: (digits) =>\n pivotYear(digits, {\n today: today(),\n min: min === undefined ? null : dayOf(min),\n max: max === undefined ? null : dayOf(max),\n }),\n };\n const { needsValue } = setup;\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<PlainDateTime>()] : []),\n ...(min === undefined ? [] : [minDateTimeRule(min, displayFormat)]),\n ...(max === undefined ? [] : [maxDateTimeRule(max, displayFormat)]),\n ...(isDateDisabled === undefined\n ? []\n : [availableDateRule<PlainDateTime>(isDateDisabled)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, displayFormat, isDateDisabled, validate],\n );\n\n return (\n <SegmentedControl\n props={{ ...props, validate: validators }}\n kind={kind}\n rootClassName=\"gridkit-forms-date-time-input\"\n segments={setup.segments}\n picker={dateTimePicker(\n props,\n setup,\n {\n toWall: (value: PlainDateTime) => value,\n fromWall: (wall) => wall,\n zone: timeZone,\n },\n { min, max },\n )}\n />\n );\n}\n\n/** The info message for a wall clock read across a daylight-saving change, while the field holds what it was read as. */\ninterface ZoneNote {\n readonly value: Instant | null;\n readonly message: FieldMessageInput;\n}\n\n/** Keeps the info message an instant's typed wall clock earns, from the change that read it until the value changes. */\nfunction useZoneNote(\n options: () => InstantFieldOptions,\n locale: Intl.LocalesArgument,\n messages: ReturnType<typeof useInputSettings>[\"messages\"],\n onChange: InstantProps[\"onChange\"],\n) {\n const [note, setNote] = useState<ZoneNote | null>(null);\n return {\n note: (value: Instant | null) =>\n note !== null && note.value === value ? note.message : null,\n onChange: (event: FieldChangeEvent<Instant, DateTimeDetails>) => {\n const text = instantZoneMessage(event.text, {\n ...options(),\n locale,\n messages,\n });\n setNote(\n text === null\n ? null\n : { value: event.value, message: { text, severity: \"info\" } },\n );\n onChange?.(event);\n },\n };\n}\n\nfunction InstantControl(props: InstantProps) {\n const {\n min,\n max,\n isDateDisabled,\n validate,\n minuteStep,\n timeZone,\n disambiguation,\n } = props;\n const setup = useDateTimeSetup(props, timeZone);\n const { locale, messages, base, today } = setup;\n const { displayFormat } = props;\n const options = (): InstantFieldOptions => ({\n ...base,\n timeZone,\n disambiguation,\n min,\n max,\n defaultTime: setup.keptTime(),\n });\n const zone = useZoneNote(options, locale, messages, props.onChange);\n const wallDay = (limit: Instant | undefined) =>\n limit === undefined ? null : dayOf(wallClockOf(limit, timeZone));\n const kind: SegmentedKind<Instant, DateTimeDetails> = {\n name: \"DateTimeInput\",\n layout: setup.layout,\n defaultParse: (text, context) => instantParser(options())(text, context),\n defaultFormat: instantFormatter({ ...base, timeZone }),\n details: (current, _previous, cause) =>\n instantDetails(current, cause, { ...options(), locale, messages }),\n display: (value) => formatInstant(value, timeZone, locale, displayFormat),\n serialize: (value) => value,\n isValue: isInstant,\n inLimits: (value) =>\n (min === undefined || compareInstants(value, min) >= 0) &&\n (max === undefined || compareInstants(value, max) <= 0),\n shortcuts: base.shortcuts,\n minuteStep,\n today,\n pivot: (digits) =>\n pivotYear(digits, {\n today: today(),\n min: wallDay(min),\n max: wallDay(max),\n }),\n note: zone.note,\n };\n const { needsValue } = setup;\n const validators = useMemo(() => {\n const available: Validator<PlainDateTime> | null =\n isDateDisabled === undefined ? null : availableDateRule(isDateDisabled);\n return [\n ...(needsValue ? [requiredRule<Instant>()] : []),\n ...(min === undefined\n ? []\n : [minInstantRule(min, timeZone, displayFormat)]),\n ...(max === undefined\n ? []\n : [maxInstantRule(max, timeZone, displayFormat)]),\n ...(available === null\n ? []\n : [\n ((value, context) =>\n available(\n value === null ? null : wallClockOf(value, timeZone),\n context,\n )) satisfies Validator<Instant>,\n ]),\n ...validatorsOf(validate),\n ];\n }, [needsValue, min, max, timeZone, displayFormat, isDateDisabled, validate]);\n\n return (\n <SegmentedControl\n props={{ ...props, validate: validators, onChange: zone.onChange }}\n kind={kind}\n rootClassName=\"gridkit-forms-date-time-input\"\n segments={setup.segments}\n picker={dateTimePicker(\n props,\n setup,\n {\n toWall: (value: Instant) => wallClockOf(value, timeZone),\n fromWall: (wall) => exactInstantOf(wall, timeZone, disambiguation),\n zone: timeZone,\n },\n { min, max },\n )}\n />\n );\n}\n\n/** Whether `props` are an instant input's. */\nfunction isInstantProps(\n props: LocalProps | InstantProps,\n): props is InstantProps {\n return props.valueType === \"instant\";\n}\n\n/**\n * A date and a time typed in segments in the locale's order\n * (`03/14/2026, 3:05 PM` in en-US): `DateInput`'s keys and shortcuts for\n * the date, `TimeInput`'s for the time, one Tab stop for both. A shortcut\n * or a pasted date sets the date and keeps a time already typed; a date\n * whose time is left empty takes `defaultTime`. The calendar button, F4 or\n * Alt+ArrowDown opens a calendar with time columns beside it, to choose\n * both with the mouse alone. Its value is a wall clock,\n * a `PlainDateTime` (`\"2026-03-14T15:05\"`), or with `valueType=\"instant\"`\n * an exact moment, an `Instant` (`\"2026-03-14T14:05:00.000Z\"`) typed and\n * shown in the `timeZone` it requires. A wall clock in an hour the zone\n * skips or repeats is read as `disambiguation` says, with an info message\n * until the value changes. It takes every shared input prop and the\n * events of `@gridkitjs/forms` with `DateTimeDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function DateTimeInput<T extends DateTimeValueType = \"local\">(\n props: DateTimeInputProps<T>,\n) {\n // `T` is decided by `valueType` alone, so it tells the two apart.\n const known = props as unknown as LocalProps | InstantProps;\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n {isInstantProps(known) ? (\n <InstantControl {...known} />\n ) : (\n <LocalDateTimeControl {...known} />\n )}\n </InputFrame>\n );\n}\n","import {\n clampCalendarDate,\n clampTime,\n dayTimeLimits,\n isCalendarDayDisabled,\n plainDateTime,\n setTimeColumn,\n snapTime,\n splitDateTime,\n timeColumns,\n type DateLayout,\n type FormsMessages,\n type PlainDate,\n type PlainDateTime,\n type PlainTime,\n type PopupCloseReason,\n} from \"@gridkitjs/forms-core\";\nimport type { CalendarSettings } from \"../calendar/calendarProps\";\nimport { PopupCalendar } from \"../calendar/PopupCalendar\";\nimport { TimeColumns } from \"./TimeColumns\";\n\n/** What a date-time input's popup reads, in wall-clock terms whatever the input holds. */\nexport interface DateTimePickerProps extends CalendarSettings {\n /** The popup's `id`, the prefix of its own ids. */\n readonly id: string;\n readonly value: PlainDateTime | null;\n readonly layout: DateLayout;\n readonly minuteStep?: number | undefined;\n readonly min: PlainDateTime | null;\n readonly max: PlainDateTime | null;\n readonly isDateDisabled?: ((date: PlainDate) => boolean) | undefined;\n /** The zone \"today\" is in, for the calendar. */\n readonly timeZone: string | undefined;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** Today, and the wall clock now, read when asked for. */\n readonly today: () => PlainDate;\n readonly now: () => PlainDateTime;\n /** The time a day chosen with no value yet gets: the time typed, else `defaultTime`. */\n readonly keptTime: () => PlainTime;\n readonly onPick: (value: PlainDateTime, nativeEvent: Event) => void;\n readonly close: (reason: PopupCloseReason) => void;\n readonly setEscapeHandler: (handler: (() => boolean) | null) => void;\n}\n\n/**\n * What a date-time input's popup shows: the calendar, with forms-core's\n * time columns beside it, and \"Now\" and \"Done\" buttons. A day chosen by a\n * click or Space keeps the time (the one typed, else `defaultTime`, while\n * the field is empty) and leaves the popup open for the time; a choice in\n * a column sets that part of the time at once. Enter, on a day or in a\n * column, closes it after its choice, as \"Done\" does; \"Now\" picks the\n * time it is now and closes it. Times outside `min` and `max` on the day\n * shown are disabled, and a day chosen brings its time within them.\n */\nexport function DateTimePicker({\n id,\n value,\n layout,\n minuteStep,\n min,\n max,\n isDateDisabled,\n timeZone,\n firstDayOfWeek,\n weekNumbers,\n weekNumbering,\n locale,\n strings,\n today,\n now,\n keptTime,\n onPick,\n close,\n setEscapeHandler,\n}: DateTimePickerProps) {\n const chosen = value === null ? null : splitDateTime(value);\n const dayLimits = {\n min: min === null ? undefined : splitDateTime(min).date,\n max: max === null ? undefined : splitDateTime(max).date,\n isDateDisabled,\n };\n // The day the columns set a time on: the value's, else today within the limits.\n const day = chosen?.date ?? clampCalendarDate(today(), dayLimits);\n const columnOptions = (on: PlainDate) => ({\n layout,\n minuteStep,\n ...dayTimeLimits(on, min, max),\n });\n const nowDay = splitDateTime(now()).date;\n\n return (\n <>\n <div className=\"gridkit-forms-date-time-picker\">\n <PopupCalendar\n id={id}\n selected={chosen?.date ?? null}\n min={dayLimits.min}\n max={dayLimits.max}\n isDateDisabled={isDateDisabled}\n timeZone={timeZone}\n firstDayOfWeek={firstDayOfWeek}\n weekNumbers={weekNumbers}\n weekNumbering={weekNumbering}\n locale={locale}\n strings={strings}\n onChoose={(date, nativeEvent) => {\n const time = clampTime(\n chosen?.time ?? keptTime(),\n dayTimeLimits(date, min, max),\n );\n onPick(plainDateTime(date, time), nativeEvent);\n if (\n nativeEvent instanceof KeyboardEvent &&\n nativeEvent.key === \"Enter\"\n ) {\n close(\"picker\");\n }\n }}\n setEscapeHandler={setEscapeHandler}\n />\n <TimeColumns\n id={id}\n columns={timeColumns(chosen?.time ?? null, columnOptions(day))}\n onSet={(type, part, nativeEvent) => {\n const time = setTimeColumn(\n chosen?.time ?? keptTime(),\n type,\n part,\n columnOptions(day),\n );\n onPick(plainDateTime(day, time), nativeEvent);\n }}\n onDone={() => {\n close(\"picker\");\n }}\n />\n </div>\n <div className=\"gridkit-forms-picker-footer\">\n <button\n type=\"button\"\n className=\"gridkit-forms-picker-action\"\n disabled={isCalendarDayDisabled(nowDay, dayLimits)}\n onClick={(event) => {\n const { date, time } = splitDateTime(now());\n onPick(\n plainDateTime(date, snapTime(time, columnOptions(date))),\n event.nativeEvent,\n );\n close(\"picker\");\n }}\n >\n {strings.pickerNow}\n </button>\n <button\n type=\"button\"\n className=\"gridkit-forms-picker-action is-done\"\n onClick={() => {\n close(\"picker\");\n }}\n >\n {strings.pickerDone}\n </button>\n </div>\n </>\n );\n}\n","import type {\n TimeColumn,\n TimeColumnOption,\n TimeColumnType,\n} from \"@gridkitjs/forms-core\";\nimport { useLayoutEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport { isRightToLeft } from \"../calendar/useCalendarNavigation\";\nimport { classNames } from \"../field/parts\";\n\n/** How many options PageUp and PageDown move. */\nconst PAGE = 5;\n\nconst COLUMN_SELECTOR = \"[data-gridkit-forms-time-column]\";\nconst ACTIVE_OPTION = '[role=\"option\"][tabindex=\"0\"]';\n\n/** A column's state class: `is-hour`, `is-day-period`. */\nfunction columnClass(type: TimeColumnType): string {\n return type === \"dayPeriod\" ? \"is-day-period\" : `is-${type}`;\n}\n\n/** Moves focus to `option`, scrolling its column only as far as it takes. */\nfunction focusOption(option: Element | null | undefined): void {\n if (option instanceof HTMLElement) {\n option.focus({ preventScroll: true });\n option.scrollIntoView({ block: \"nearest\" });\n }\n}\n\n/**\n * The option a time picker's focus starts on: in the column of the time\n * segment that had focus as the popup opened, else `null`.\n */\nexport function segmentTimeOption(panel: HTMLElement): HTMLElement | null {\n const active = panel.ownerDocument.activeElement;\n const type =\n active instanceof HTMLElement\n ? active.dataset.gridkitFormsSegment\n : undefined;\n if (type === undefined) {\n return null;\n }\n return panel.querySelector<HTMLElement>(\n `[data-gridkit-forms-time-column=\"${type}\"] ${ACTIVE_OPTION}`,\n );\n}\n\n/** The option of a time picker's first column that takes focus. */\nexport function firstTimeOption(panel: HTMLElement): HTMLElement | null {\n return panel.querySelector<HTMLElement>(\n `${COLUMN_SELECTOR} ${ACTIVE_OPTION}`,\n );\n}\n\n/** The option that takes focus when the column has none chosen: the first enabled one. */\nfunction fallbackOf(options: readonly TimeColumnOption[]): number {\n return (options.find((option) => !option.disabled) ?? options[0])?.value ?? 0;\n}\n\n/** Where a key moves in a column of `count` options from `index`, or `null` for a key that moves nothing. */\nfunction movedIndex(key: string, index: number, count: number): number | null {\n const moves: Readonly<Record<string, number>> = {\n ArrowDown: index + 1,\n ArrowUp: index - 1,\n PageDown: index + PAGE,\n PageUp: index - PAGE,\n Home: 0,\n End: count - 1,\n };\n const move = moves[key];\n return move === undefined ? null : Math.min(Math.max(move, 0), count - 1);\n}\n\n/**\n * One column of a time picker: a listbox of its options, one Tab stop,\n * whose chosen option scrolls into the middle as it appears. The arrows,\n * Home, End, PageUp and PageDown move through it and choose the option\n * they land on unless it is disabled; Space chooses, Enter chooses and\n * calls `onDone`; ArrowLeft and ArrowRight move to the columns either side.\n */\nfunction TimeColumnList({\n id,\n column,\n onSet,\n onDone,\n}: {\n readonly id: string;\n readonly column: TimeColumn;\n readonly onSet: (value: number, nativeEvent: Event) => void;\n readonly onDone: (nativeEvent: Event) => void;\n}) {\n const listRef = useRef<HTMLDivElement>(null);\n // Where focus moved to without choosing: a disabled option.\n const [moved, setMoved] = useState<number | null>(null);\n const { options, selected } = column;\n const active = moved ?? selected ?? fallbackOf(options);\n\n useLayoutEffect(() => {\n const list = listRef.current;\n const option = list?.querySelector<HTMLElement>(ACTIVE_OPTION);\n if (list === null || option === null || option === undefined) {\n return;\n }\n const listBox = list.getBoundingClientRect();\n const optionBox = option.getBoundingClientRect();\n list.scrollTop +=\n optionBox.top - listBox.top - (list.clientHeight - optionBox.height) / 2;\n }, []);\n\n function choose(option: TimeColumnOption, nativeEvent: Event): void {\n setMoved(option.disabled ? option.value : null);\n if (!option.disabled && option.value !== selected) {\n onSet(option.value, nativeEvent);\n }\n }\n\n function optionElement(value: number): Element | null | undefined {\n return listRef.current?.querySelector(\n `[data-gridkit-forms-time-value=\"${String(value)}\"]`,\n );\n }\n\n function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n if (event.altKey || event.ctrlKey || event.metaKey) {\n return;\n }\n const index = options.findIndex((option) => option.value === active);\n const current = options[index];\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n if (current !== undefined) {\n choose(current, event.nativeEvent);\n }\n if (event.key === \"Enter\") {\n onDone(event.nativeEvent);\n }\n return;\n }\n if (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\") {\n const columns = Array.from(\n event.currentTarget\n .closest(\".gridkit-forms-time-columns\")\n ?.querySelectorAll(COLUMN_SELECTOR) ?? [],\n );\n const forward =\n (event.key === \"ArrowRight\") !== isRightToLeft(event.currentTarget);\n const next =\n columns[columns.indexOf(event.currentTarget) + (forward ? 1 : -1)];\n if (next !== undefined) {\n event.preventDefault();\n focusOption(next.querySelector(ACTIVE_OPTION));\n }\n return;\n }\n const nextIndex = movedIndex(event.key, index, options.length);\n const next = nextIndex === null ? undefined : options[nextIndex];\n if (next !== undefined) {\n event.preventDefault();\n choose(next, event.nativeEvent);\n focusOption(optionElement(next.value));\n }\n }\n\n return (\n <div\n ref={listRef}\n className={classNames(\n \"gridkit-forms-time-column\",\n columnClass(column.type),\n )}\n data-gridkit-forms-time-column={column.type}\n role=\"listbox\"\n aria-label={column.label}\n // Firefox makes a scrolling box a Tab stop of its own; the option is the column's one.\n tabIndex={-1}\n onKeyDown={onKeyDown}\n >\n {options.map((option) => {\n const isSelected = option.value === selected;\n return (\n <div\n key={option.value}\n id={`${id}-${column.type}-${String(option.value)}`}\n className={classNames(\n \"gridkit-forms-time-option\",\n isSelected && \"is-selected\",\n option.disabled && \"is-disabled\",\n )}\n data-gridkit-forms-time-value={option.value}\n role=\"option\"\n tabIndex={option.value === active ? 0 : -1}\n aria-selected={isSelected}\n aria-disabled={option.disabled || undefined}\n onClick={(event) => {\n choose(option, event.nativeEvent);\n }}\n >\n {option.text}\n </div>\n );\n })}\n </div>\n );\n}\n\n/**\n * A time picker's columns side by side, in the field's order and\n * direction: each a listbox from forms-core's `timeColumns`. A click or a\n * key that lands on an option calls `onSet` with its column and value at\n * once; Enter calls `onDone`.\n */\nexport function TimeColumns({\n id,\n columns,\n onSet,\n onDone,\n}: {\n /** The prefix of the options' ids. */\n readonly id: string;\n readonly columns: readonly TimeColumn[];\n readonly onSet: (\n type: TimeColumnType,\n value: number,\n nativeEvent: Event,\n ) => void;\n readonly onDone: (nativeEvent: Event) => void;\n}) {\n return (\n <div className=\"gridkit-forms-time-columns\">\n {columns.map((column) => (\n <TimeColumnList\n key={column.type}\n id={id}\n column={column}\n onSet={(value, nativeEvent) => {\n onSet(column.type, value, nativeEvent);\n }}\n onDone={onDone}\n />\n ))}\n </div>\n );\n}\n","import {\n compareTimes,\n dateLayout,\n formatTime,\n isPlainTime,\n maxTimeRule,\n minTimeRule,\n requiredRule,\n splitDateTime,\n timeDetails,\n timeFormatter,\n timeParser,\n type PlainDate,\n type PlainTime,\n type PopupOpenChange,\n type TimeDetails,\n type TimeFieldOptions,\n} from \"@gridkitjs/forms-core\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { warnOnce } from \"../dev\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { ClockIcon, InputFrame } from \"../text/parts\";\nimport { firstTimeOption, segmentTimeOption } from \"../time/TimeColumns\";\nimport { TimePicker } from \"../time/TimePicker\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { nowFor } from \"./DateInput\";\nimport { SegmentedControl } from \"./SegmentedControl\";\nimport type { SegmentedInputProps, TimeSettings } from \"./segmentedProps\";\nimport { createSegmentsAccess, type SegmentedKind } from \"./useSegmentedInput\";\n\nexport interface TimeInputProps\n extends SegmentedInputProps<PlainTime, TimeDetails>, TimeSettings {\n /** The earliest time allowed, inclusive. */\n readonly min?: PlainTime | undefined;\n /** The latest time allowed, inclusive. */\n readonly max?: PlainTime | undefined;\n /** The clock button and its popup of time columns; on by default. */\n readonly picker?: boolean | undefined;\n /** The time columns' popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n}\n\n/** A time field has no days; its segments step from 0. */\nconst NO_DAY: PlainDate = \"2000-01-01\";\n\nfunction TimeInputControl({\n min,\n max,\n hourCycle,\n precision,\n minuteStep,\n picker = true,\n onOpenChange,\n required,\n validate,\n ...props\n}: TimeInputProps) {\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const [segments] = useState(createSegmentsAccess);\n const { numberingSystem, displayFormat } = props;\n const needsValue = required === true || field?.required === true;\n const overMidnight =\n min !== undefined && max !== undefined && compareTimes(min, max) > 0;\n useEffect(() => {\n if (overMidnight) {\n warnOnce(\n \"time-input-window\",\n \"TimeInput's min is after its max, which no time of day satisfies. A window over midnight is a TimeRangeInput's.\",\n );\n }\n }, [overMidnight]);\n\n const options: TimeFieldOptions = {\n hourCycle,\n precision,\n numberingSystem,\n displayFormat,\n };\n const kind: SegmentedKind<PlainTime, TimeDetails> = {\n name: \"TimeInput\",\n layout: dateLayout(\n { locale, fields: \"time\", hourCycle, precision, numberingSystem },\n messages,\n ),\n defaultParse: timeParser(options),\n defaultFormat: timeFormatter(options),\n details: (current, _previous, cause) =>\n timeDetails(current, cause, { ...options, locale, messages }),\n display: (value) => formatTime(value, locale, displayFormat),\n serialize: (value) => value,\n isValue: isPlainTime,\n inLimits: (value) =>\n (min === undefined || compareTimes(value, min) >= 0) &&\n (max === undefined || compareTimes(value, max) <= 0),\n shortcuts: false,\n minuteStep,\n today: () => NO_DAY,\n pivot: (digits) => digits,\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<PlainTime>()] : []),\n ...(min === undefined ? [] : [minTimeRule(min, displayFormat)]),\n ...(max === undefined ? [] : [maxTimeRule(max, displayFormat)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, displayFormat, validate],\n );\n\n return (\n <SegmentedControl\n props={{ ...props, required, validate: validators }}\n kind={kind}\n rootClassName=\"gridkit-forms-time-input\"\n segments={segments}\n picker={\n picker\n ? {\n label: messages.chooseTime,\n icon: <ClockIcon />,\n buttonClassName: \"gridkit-forms-time-button\",\n popupClassName: \"gridkit-forms-time-popup\",\n onOpenChange,\n initialFocus: (panel) =>\n segmentTimeOption(panel) ?? firstTimeOption(panel),\n tabOut: true,\n content: ({ value, id, pick, close }) => (\n <TimePicker\n id={id}\n value={value}\n options={{\n layout: kind.layout,\n minuteStep,\n min: min ?? null,\n max: max ?? null,\n }}\n strings={messages}\n now={() => splitDateTime(nowFor(undefined)()).time}\n onPick={pick}\n close={close}\n />\n ),\n }\n : undefined\n }\n />\n );\n}\n\n/**\n * A time of day typed in segments, in the locale's hour cycle (`3:05 PM`\n * in en-US, `15:05` in de-DE) unless `hourCycle` sets one: typing moves on\n * by itself, the arrow keys move between segments and step them (minutes\n * by `minuteStep`), `a` and `p` set the day period, and a pasted time in\n * any common form is read whole. The clock button, F4 or Alt+ArrowDown\n * opens columns of hours, minutes, seconds and day periods to choose from,\n * each choice set at once. Its value is a `PlainTime`, an ISO string\n * (`\"15:05\"`, with seconds under `precision=\"second\"`), `null` when empty.\n * `min` and `max` add their messages. It takes every shared input prop and\n * the events of `@gridkitjs/forms` with `TimeDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function TimeInput(props: TimeInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <TimeInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n setTimeColumn,\n snapTime,\n timeColumns,\n type FormsMessages,\n type PlainTime,\n type PopupCloseReason,\n type TimeColumnsOptions,\n} from \"@gridkitjs/forms-core\";\nimport { TimeColumns } from \"./TimeColumns\";\n\n/**\n * What a time input's popup shows: forms-core's time columns for the\n * field's layout, step and limits, and a \"Now\" button. A choice in a\n * column picks the time with that part set at once and leaves the popup\n * open; Enter closes it, and \"Now\" picks the time it is now (to the step,\n * within the limits) and closes it.\n */\nexport function TimePicker({\n id,\n value,\n options,\n strings,\n now,\n onPick,\n close,\n}: {\n /** The popup's `id`, the prefix of the options' ids. */\n readonly id: string;\n readonly value: PlainTime | null;\n readonly options: TimeColumnsOptions;\n readonly strings: FormsMessages;\n /** The time it is now, read as \"Now\" is pressed. */\n readonly now: () => PlainTime;\n readonly onPick: (time: PlainTime, nativeEvent: Event) => void;\n readonly close: (reason: PopupCloseReason) => void;\n}) {\n return (\n <>\n <TimeColumns\n id={id}\n columns={timeColumns(value, options)}\n onSet={(type, part, nativeEvent) => {\n onPick(setTimeColumn(value, type, part, options), nativeEvent);\n }}\n onDone={() => {\n close(\"picker\");\n }}\n />\n <div className=\"gridkit-forms-picker-footer\">\n <button\n type=\"button\"\n className=\"gridkit-forms-picker-action\"\n onClick={(event) => {\n onPick(snapTime(now(), options), event.nativeEvent);\n close(\"picker\");\n }}\n >\n {strings.pickerNow}\n </button>\n </div>\n </>\n );\n}\n","import {\n hasError,\n mostSevere,\n toFieldMessages,\n type FieldMessageInput,\n} from \"@gridkitjs/forms-core\";\nimport {\n useId,\n useMemo,\n useRef,\n type CSSProperties,\n type ReactNode,\n} from \"react\";\nimport { useSummaryEntry } from \"../form/formContext\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type LabelPosition,\n type NecessityIndicator,\n} from \"../settings\";\nimport {\n FieldContext,\n useControlMessages,\n type FieldContextValue,\n} from \"./fieldContext\";\nimport { FieldMessages } from \"./FieldMessages\";\nimport {\n classNames,\n NecessityMarker,\n spanClass,\n useShownMessages,\n withLabelWidth,\n type FieldSpan,\n} from \"./parts\";\n\nexport interface FieldGroupProps {\n /** Names the group; each input in it needs an `aria-label` of its own. */\n readonly label: ReactNode;\n /** Help text under the inputs, read as part of each one's description. */\n readonly description?: ReactNode;\n /** The app's messages, always shown; a string is an error. */\n readonly message?:\n FieldMessageInput | readonly FieldMessageInput[] | undefined;\n /** Marks the label, and tells every input a value is required. */\n readonly required?: boolean | undefined;\n /** `\"floating\"` is drawn as `\"top\"`: the label names no one control. */\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly necessityIndicator?: NecessityIndicator | undefined;\n /** Columns taken in a `FormLayout`. */\n readonly span?: FieldSpan | undefined;\n /** The group's `id`, which a summary link points at; generated without it. */\n readonly id?: string | undefined;\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n /** Several inputs, each with its own `aria-label`. */\n readonly children?: ReactNode;\n}\n\nfunction ignoreControlState(): void {\n // A group's label names no one control, so it does not float.\n}\n\n/**\n * Several inputs under one label and one message area, such as a postal\n * code and a city: a group the label names, laid out as a field is. Every\n * input is described by the group's description and messages, and lists\n * its own messages in the group's message area.\n */\nexport function FieldGroup({\n label,\n description,\n message,\n required = false,\n labelPosition,\n labelWidth,\n necessityIndicator,\n span,\n id,\n className,\n style,\n children,\n}: FieldGroupProps) {\n const settings = useResolvedSettings({ labelPosition, necessityIndicator });\n const generatedId = useId();\n const groupId = id ?? generatedId;\n const labelId = `${groupId}-label`;\n const descriptionId = `${groupId}-description`;\n const messagesId = `${groupId}-messages`;\n const hasDescription = description !== undefined && description !== null;\n\n const [controlMessages, setControlMessages] = useControlMessages();\n const shown = useShownMessages(controlMessages, message, settings.disabled);\n const severity = mostSevere(\n shown.map((shownMessage) => shownMessage.severity),\n );\n const describedBy = hasDescription\n ? `${descriptionId} ${messagesId}`\n : messagesId;\n // Only the app's error is the whole group's; an input's is its own.\n const invalid = hasError(toFieldMessages(message, \"app\"));\n\n const context = useMemo<FieldContextValue>(\n () => ({\n controlId: null,\n settings,\n describedBy,\n required,\n invalid,\n severity: null,\n setControlMessages,\n setControlState: ignoreControlState,\n }),\n [settings, describedBy, required, invalid, setControlMessages],\n );\n\n const root = useRef<HTMLDivElement>(null);\n useSummaryEntry(groupId, label, shown, root);\n\n const position =\n settings.labelPosition === \"floating\" ? \"top\" : settings.labelPosition;\n\n return (\n <div\n ref={root}\n id={groupId}\n role=\"group\"\n aria-labelledby={labelId}\n className={classNames(\n \"gridkit-forms-field\",\n \"gridkit-forms-field-group\",\n `is-label-${position}`,\n required && \"is-required\",\n severity !== null && `is-${severity}`,\n settings.disabled && \"is-disabled\",\n settings.readOnly && \"is-readonly\",\n settings.mode === \"display\" && \"is-display\",\n settings.density !== \"standard\" && `is-${settings.density}`,\n spanClass(span),\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n >\n <span\n className={classNames(\n \"gridkit-forms-field-label\",\n position === \"hidden\" && \"gridkit-forms-sr-only\",\n )}\n id={labelId}\n >\n {label}\n <NecessityMarker\n required={required}\n indicator={settings.necessityIndicator}\n strings={settings.messages}\n />\n </span>\n <div className=\"gridkit-forms-field-control gridkit-forms-field-group-controls\">\n <FormSettingsProvider settings={settings}>\n <FieldContext value={context}>{children}</FieldContext>\n </FormSettingsProvider>\n </div>\n {hasDescription && (\n <p className=\"gridkit-forms-field-description\" id={descriptionId}>\n {description}\n </p>\n )}\n <FieldMessages\n id={messagesId}\n messages={shown}\n strings={settings.messages}\n />\n </div>\n );\n}\n","import { toFieldMessages, type FieldMessageInput } from \"@gridkitjs/forms-core\";\nimport { useCallback, useId, useLayoutEffect, useRef } from \"react\";\nimport { useFormContext } from \"../form/formContext\";\nimport { useFormSettings, type Density, type FieldMode } from \"../settings\";\nimport { useFieldContext, type FieldControlState } from \"./fieldContext\";\n\n/** The attributes `useField` gives an app's own control, to spread on it. */\nexport interface FieldControlProps {\n readonly id: string;\n readonly \"aria-describedby\": string | undefined;\n readonly \"aria-invalid\": true | undefined;\n readonly \"aria-required\": true | undefined;\n readonly disabled: boolean;\n readonly readOnly: boolean;\n}\n\n/** What an app's own input tells `useField`. */\nexport interface UseFieldOptions {\n /**\n * Called when the `Form` around the input reveals every field's\n * messages, on a submit attempt, so the input shows its own messages as\n * a commit would. The form looks for an invalid control right after, so\n * a native constraint or `setCustomValidity` set here refuses the submit.\n */\n readonly onReveal?: (() => void) | undefined;\n}\n\n/** What `useField` gives an app's own input. */\nexport interface UseFieldResult {\n /** Spread onto the control. */\n readonly controlProps: FieldControlProps;\n readonly mode: FieldMode;\n readonly density: Density;\n /** The field is marked required: the input checks for a value itself. */\n readonly required: boolean;\n /**\n * Lists the input's own messages under the field, with the field's. Call\n * it from an effect, with `null` once there are none.\n */\n readonly reportMessages: (\n messages: FieldMessageInput | readonly FieldMessageInput[] | null,\n ) => void;\n /**\n * Tells the field whether the control is focused and empty, which a\n * floating label follows, and whether the input needs a value by a\n * `required` of its own, which marks the label. Call it from an effect\n * whenever any of them changes.\n */\n readonly reportControlState: (state: FieldControlState) => void;\n}\n\n/**\n * Wires an app's own input into the `Field` around it: the control's `id`\n * that the label names, its description, the invalid and required states,\n * and `readOnly` and `disabled` from the field and the form. Outside a\n * `Field` it gives the form's settings and an `id` of its own, and the\n * reports go nowhere.\n */\nexport function useField(options: UseFieldOptions = {}): UseFieldResult {\n const field = useFieldContext();\n const form = useFormContext();\n const formSettings = useFormSettings();\n const ownId = useId();\n\n // The latest callback, read when the form reveals, so a new function on\n // every render does not add the input to the form again.\n const onReveal = useRef(options.onReveal);\n useLayoutEffect(() => {\n onReveal.current = options.onReveal;\n });\n useLayoutEffect(\n () =>\n form?.registry.addRevealer(() => {\n onReveal.current?.();\n }),\n [form],\n );\n const settings = field?.settings ?? formSettings;\n const setControlMessages = field?.setControlMessages;\n const setControlState = field?.setControlState;\n\n const reportMessages = useCallback(\n (messages: FieldMessageInput | readonly FieldMessageInput[] | null) => {\n setControlMessages?.(ownId, toFieldMessages(messages, \"app\"));\n },\n [setControlMessages, ownId],\n );\n const reportControlState = useCallback(\n (state: FieldControlState) => {\n setControlState?.(state);\n },\n [setControlState],\n );\n\n return {\n controlProps: {\n id: field?.controlId ?? ownId,\n \"aria-describedby\": field?.describedBy,\n \"aria-invalid\": field?.invalid === true || undefined,\n \"aria-required\": field?.required === true || undefined,\n disabled: settings.disabled,\n readOnly: settings.readOnly,\n },\n mode: settings.mode,\n density: settings.density,\n required: field?.required ?? false,\n reportMessages,\n reportControlState,\n };\n}\n","import type { FormsMessages } from \"@gridkitjs/forms-core\";\nimport {\n attachEnterNavigation,\n findFirstInvalidControl,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useLayoutEffect,\n useState,\n type CSSProperties,\n type ReactNode,\n type Ref,\n type RefCallback,\n type SubmitEvent,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { classNames, withLabelWidth } from \"../field/parts\";\nimport { setRef } from \"../refs\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type FieldMode,\n type LabelPosition,\n type NecessityIndicator,\n} from \"../settings\";\nimport { createFormContext, FormContext } from \"./formContext\";\n\nexport interface FormProps {\n /** `\"display\"` shows every field as text. */\n readonly mode?: FieldMode | undefined;\n readonly density?: Density | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly necessityIndicator?: NecessityIndicator | undefined;\n /**\n * Enter in a single-line field, a checkbox or a switch moves to the next\n * field rather than submitting; from the last one it submits.\n */\n readonly enterMovesToNextField?: boolean | undefined;\n readonly readOnly?: boolean | undefined;\n readonly disabled?: boolean | undefined;\n readonly locale?: Intl.LocalesArgument;\n /** Strings laid over the default English ones. */\n readonly messages?: Partial<FormsMessages> | undefined;\n /**\n * Lets every submit through without checking the fields, for a form\n * library that validates itself.\n */\n readonly noValidate?: boolean | undefined;\n /** Called only for a submit the form lets through. */\n readonly onSubmit?:\n ((event: SubmitEvent<HTMLFormElement>) => void) | undefined;\n /**\n * The form's `action`: a URL, or a React form action, which runs only\n * for a submit the form lets through.\n */\n readonly action?:\n string | ((formData: FormData) => void | Promise<void>) | undefined;\n readonly ref?: Ref<HTMLFormElement> | undefined;\n readonly id?: string | undefined;\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n readonly \"aria-label\"?: string | undefined;\n readonly \"aria-labelledby\"?: string | undefined;\n readonly children?: ReactNode;\n}\n\n/**\n * A `<form>` whose fields share its mode, density, label position and\n * width, necessity indicator, `readOnly` and `disabled`, and which refuses\n * a submit while a field holds an error.\n *\n * On a submit it reveals every field's messages, then looks for the first\n * invalid control in document order: a field showing an error, or a native\n * constraint of an app's own control. If there is one it cancels the\n * submit, so neither `onSubmit` nor a React form action runs, and moves\n * focus to the form's `MessageSummary` if it shows, or else to that\n * control, opening a collapsed section around it first. The browser's own\n * validation bubbles never show: the fields show their messages instead.\n */\nexport function Form({\n mode,\n density,\n labelPosition,\n labelWidth,\n necessityIndicator,\n enterMovesToNextField = false,\n readOnly,\n disabled,\n locale,\n messages,\n noValidate = false,\n onSubmit,\n action,\n ref,\n id,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n children,\n}: FormProps) {\n const settings = useResolvedSettings({\n mode,\n density,\n labelPosition,\n necessityIndicator,\n readOnly,\n disabled,\n locale,\n messages,\n });\n const [context] = useState(createFormContext);\n\n const [form, setForm] = useState<HTMLFormElement | null>(null);\n const formRef = useCallback<RefCallback<HTMLFormElement>>(\n (element) => {\n setForm(element);\n const release = setRef(ref, element);\n return () => {\n setForm(null);\n release?.();\n };\n },\n [ref],\n );\n useLayoutEffect(() => {\n if (form === null || !enterMovesToNextField) {\n return undefined;\n }\n return attachEnterNavigation(form).detach;\n }, [form, enterMovesToNextField]);\n\n function handleSubmit(event: SubmitEvent<HTMLFormElement>): void {\n if (!noValidate) {\n // Rendered at once, so the summary lists the messages before it is\n // focused.\n flushSync(() => {\n context.registry.revealAll();\n });\n const invalid = findFirstInvalidControl(event.currentTarget);\n if (invalid !== null) {\n event.preventDefault();\n const summary = context.getSummary();\n if (summary === null) {\n context.focusControl(invalid);\n } else {\n summary.focus();\n }\n return;\n }\n }\n onSubmit?.(event);\n }\n\n return (\n <form\n ref={formRef}\n id={id}\n noValidate\n action={action}\n onSubmit={handleSubmit}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className={classNames(\n \"gridkit-forms-form\",\n settings.mode === \"display\" && \"is-display\",\n settings.density !== \"standard\" && `is-${settings.density}`,\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n >\n <FormContext value={context}>\n <FormSettingsProvider settings={settings}>\n {children}\n </FormSettingsProvider>\n </FormContext>\n </form>\n );\n}\n","import type { FormsMessages } from \"@gridkitjs/forms-core\";\nimport type { ReactNode } from \"react\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n} from \"./settings\";\n\nexport interface FormsProviderProps {\n /** Formats counts, for every forms component under it. */\n readonly locale?: Intl.LocalesArgument;\n /** Strings laid over the default English ones. */\n readonly messages?: Partial<FormsMessages> | undefined;\n readonly density?: Density | undefined;\n readonly children?: ReactNode;\n}\n\n/**\n * Sets the locale, strings and density of every forms component under it,\n * inside a `Form` or not. A `Form`, a layout level, a field or an input\n * that sets one of them itself wins over the provider.\n */\nexport function FormsProvider({\n locale,\n messages,\n density,\n children,\n}: FormsProviderProps) {\n const settings = useResolvedSettings({ locale, messages, density });\n return (\n <FormSettingsProvider settings={settings}>{children}</FormSettingsProvider>\n );\n}\n","import { summarizeMessages, type Severity } from \"@gridkitjs/forms-core\";\nimport { focusTargetIn } from \"@gridkitjs/forms-dom\";\nimport {\n useCallback,\n useId,\n useMemo,\n useSyncExternalStore,\n type MouseEvent,\n type ReactNode,\n type RefCallback,\n} from \"react\";\nimport { SeverityIcon } from \"../field/FieldMessages\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport { useFormContext, type FormContextValue } from \"./formContext\";\n\nexport interface MessageSummaryProps {\n /** In place of \"There are 2 problems with this form\". */\n readonly title?: ReactNode;\n /** The heading element the title is. */\n readonly headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined;\n /** Which messages it lists. */\n readonly severities?: readonly Severity[] | undefined;\n readonly className?: string | undefined;\n}\n\nconst DEFAULT_SEVERITIES: readonly Severity[] = [\"error\", \"warning\"];\n\nfunction subscribeToNothing() {\n return () => undefined;\n}\n\nconst NO_FIELDS: readonly never[] = [];\n\n/**\n * Every message the fields of its `Form` show, of the chosen severities,\n * field by field in document order, each a link that focuses its field\n * (opening a collapsed section around it), under a title with the count\n * and a count per severity. It renders nothing while there is nothing to\n * list. A refused submit moves focus to it, so the count is read first.\n */\nexport function MessageSummary({\n title,\n headingLevel = 2,\n severities = DEFAULT_SEVERITIES,\n className,\n}: MessageSummaryProps) {\n const form = useFormContext();\n const { messages } = useFormSettings();\n const titleId = useId();\n const fields = useSyncExternalStore(\n form?.registry.subscribe ?? subscribeToNothing,\n () => form?.registry.getFields() ?? NO_FIELDS,\n () => NO_FIELDS,\n );\n const { items, counts } = useMemo(\n () => summarizeMessages(fields, severities),\n [fields, severities],\n );\n const summaryRef = useCallback<RefCallback<HTMLDivElement>>(\n (element) => (element === null ? undefined : form?.setSummary(element)),\n [form],\n );\n\n if (form === null || items.length === 0) {\n return null;\n }\n const Heading = `h${String(headingLevel)}` as\n \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n\n return (\n <div\n ref={summaryRef}\n role=\"region\"\n aria-labelledby={titleId}\n tabIndex={-1}\n className={classNames(\n \"gridkit-forms-message-summary\",\n `is-${counts[0]?.severity ?? \"error\"}`,\n className,\n )}\n >\n <Heading className=\"gridkit-forms-message-summary-title\" id={titleId}>\n {title ?? messages.messageSummaryTitle(items.length)}\n </Heading>\n <p className=\"gridkit-forms-message-summary-counts\">\n {counts.map(({ severity, count }, index) => (\n <span key={severity}>\n {index > 0 && \", \"}\n <span\n className={`gridkit-forms-message-summary-count is-${severity}`}\n >\n {messages.severityCount(severity, count)}\n </span>\n </span>\n ))}\n </p>\n <ul className=\"gridkit-forms-message-summary-list\">\n {items.map(({ field, message }, index) => (\n <li\n // A field may show two messages with one text.\n key={`${field.id}:${String(index)}`}\n className={`gridkit-forms-message-summary-item is-${message.severity}`}\n >\n <span className=\"gridkit-forms-message-icon\" aria-hidden=\"true\">\n <SeverityIcon severity={message.severity} />\n </span>\n <a\n className=\"gridkit-forms-message-summary-link\"\n href={`#${field.id}`}\n onClick={(event) => {\n focusField(event, form, field.id);\n }}\n >\n {field.label === null ? (\n message.text\n ) : (\n <>\n {field.label}: {message.text}\n </>\n )}\n </a>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n\n/**\n * Focuses the field a summary link points at, rather than only scrolling\n * to it, when it is in the page.\n */\nfunction focusField(\n event: MouseEvent<HTMLAnchorElement>,\n form: FormContextValue,\n id: string,\n): void {\n const target = event.currentTarget.ownerDocument.getElementById(id);\n const control = target === null ? null : focusTargetIn(target);\n if (control !== null) {\n event.preventDefault();\n form.focusControl(control);\n }\n}\n","import { useId, type CSSProperties, type ReactNode } from \"react\";\nimport {\n classNames,\n spanClass,\n withLabelWidth,\n type FieldSpan,\n} from \"../field/parts\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type FieldMode,\n type LabelPosition,\n} from \"../settings\";\n\nexport interface FieldsetProps {\n /** Names the fields inside, as a native `<legend>`. */\n readonly legend: ReactNode;\n /** Under the legend, describing the fieldset. */\n readonly description?: ReactNode;\n readonly mode?: FieldMode | undefined;\n readonly density?: Density | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly readOnly?: boolean | undefined;\n /** Disables every control inside, natively as well. */\n readonly disabled?: boolean | undefined;\n /** Columns taken in a `FormLayout`. */\n readonly span?: FieldSpan | undefined;\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n readonly children?: ReactNode;\n}\n\n/**\n * Several fields under a legend, such as a delivery address, with\n * settings for the fields inside. Usually holds a `FormLayout`.\n */\nexport function Fieldset({\n legend,\n description,\n mode,\n density,\n labelPosition,\n labelWidth,\n readOnly,\n disabled,\n span,\n className,\n style,\n children,\n}: FieldsetProps) {\n const settings = useResolvedSettings({\n mode,\n density,\n labelPosition,\n readOnly,\n disabled,\n });\n const descriptionId = useId();\n const hasDescription = description !== undefined && description !== null;\n return (\n <fieldset\n disabled={disabled}\n aria-describedby={hasDescription ? descriptionId : undefined}\n className={classNames(\n \"gridkit-forms-fieldset\",\n spanClass(span),\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n >\n <legend className=\"gridkit-forms-fieldset-legend\">{legend}</legend>\n {hasDescription && (\n <p className=\"gridkit-forms-fieldset-description\" id={descriptionId}>\n {description}\n </p>\n )}\n <FormSettingsProvider settings={settings}>\n {children}\n </FormSettingsProvider>\n </fieldset>\n );\n}\n","import type { CSSProperties, ReactNode } from \"react\";\nimport { classNames, withLabelWidth } from \"../field/parts\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type LabelPosition,\n} from \"../settings\";\n\nexport interface FormLayoutProps {\n /** The most columns it lays fields out in; fewer as it narrows. */\n readonly columns?: 1 | 2 | 3 | 4 | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n /** The label column's width for `labelPosition=\"start\"`, as a CSS length. */\n readonly labelWidth?: string | undefined;\n readonly density?: Density | undefined;\n readonly className?: string | undefined;\n readonly style?: CSSProperties | undefined;\n /** Fields, groups and fieldsets, each taking its `span` of columns. */\n readonly children?: ReactNode;\n}\n\n/**\n * Lays fields out in up to four columns, which drop to fewer as the layout\n * itself narrows: one below 32rem, at most two below 48rem, at most three\n * below 64rem. A field's `span` never takes more columns than the layout\n * has at its width, and start labels stack on top below 30rem. The columns\n * follow the writing direction.\n */\nexport function FormLayout({\n columns = 1,\n labelPosition,\n labelWidth,\n density,\n className,\n style,\n children,\n}: FormLayoutProps) {\n const settings = useResolvedSettings({ labelPosition, density });\n return (\n <div\n className={classNames(\n \"gridkit-forms-layout\",\n columns !== 1 && `is-columns-${String(columns)}`,\n className,\n )}\n style={withLabelWidth(style, labelWidth)}\n >\n {/* The columns respond to the outer element's width, which a\n container query cannot read from the grid itself. */}\n <div className=\"gridkit-forms-layout-grid\">\n <FormSettingsProvider settings={settings}>\n {children}\n </FormSettingsProvider>\n </div>\n </div>\n );\n}\n","import {\n useCallback,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { classNames } from \"../field/parts\";\nimport { useFormContext } from \"../form/formContext\";\nimport {\n FormSettingsProvider,\n useResolvedSettings,\n type Density,\n type FieldMode,\n type LabelPosition,\n} from \"../settings\";\n\nexport interface FormSectionProps {\n readonly title: ReactNode;\n /** The heading element the title is. */\n readonly headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined;\n /** Under the title. */\n readonly description?: ReactNode;\n /** The title becomes a button that shows and hides the section's body. */\n readonly collapsible?: boolean | undefined;\n /** Whether a collapsible section is open; present means controlled. */\n readonly expanded?: boolean | undefined;\n /** Whether an uncontrolled collapsible section starts open. */\n readonly defaultExpanded?: boolean | undefined;\n readonly onExpandedChange?: ((expanded: boolean) => void) | undefined;\n readonly mode?: FieldMode | undefined;\n readonly density?: Density | undefined;\n readonly labelPosition?: LabelPosition | undefined;\n readonly readOnly?: boolean | undefined;\n readonly disabled?: boolean | undefined;\n /** The section's `id`; the title's and the body's are made from it. */\n readonly id?: string | undefined;\n readonly className?: string | undefined;\n readonly children?: ReactNode;\n}\n\nfunction Chevron() {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n );\n}\n\n/**\n * A titled part of a long form, with settings for the fields in it. A\n * collapsible one follows the disclosure pattern: its title is a button\n * that shows and hides the body, which stays mounted while hidden, so its\n * fields keep their values. Focus moving to a field inside a collapsed\n * section of a `Form` (a summary link, a refused submit) opens it first.\n */\nexport function FormSection({\n title,\n headingLevel = 2,\n description,\n collapsible = false,\n expanded,\n defaultExpanded = true,\n onExpandedChange,\n mode,\n density,\n labelPosition,\n readOnly,\n disabled,\n id,\n className,\n children,\n}: FormSectionProps) {\n const settings = useResolvedSettings({\n mode,\n density,\n labelPosition,\n readOnly,\n disabled,\n });\n const generatedId = useId();\n const sectionId = id ?? generatedId;\n const titleId = `${sectionId}-title`;\n const bodyId = `${sectionId}-body`;\n const descriptionId = `${sectionId}-description`;\n const hasDescription = description !== undefined && description !== null;\n\n const [ownExpanded, setOwnExpanded] = useState(defaultExpanded);\n const open = !collapsible || (expanded ?? ownExpanded);\n const setOpen = useCallback(\n (next: boolean) => {\n if (expanded === undefined) {\n setOwnExpanded(next);\n }\n onExpandedChange?.(next);\n },\n [expanded, onExpandedChange],\n );\n\n const root = useRef<HTMLElement>(null);\n const form = useFormContext();\n useLayoutEffect(() => {\n const element = root.current;\n if (form === null || element === null || !collapsible) {\n return undefined;\n }\n return form.addSection({\n element,\n expand: () => {\n if (!open) {\n setOpen(true);\n }\n },\n });\n }, [form, collapsible, open, setOpen]);\n\n const Heading = `h${String(headingLevel)}` as\n \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n\n return (\n <section\n ref={root}\n id={sectionId}\n aria-labelledby={titleId}\n aria-describedby={hasDescription ? descriptionId : undefined}\n className={classNames(\n \"gridkit-forms-section\",\n collapsible && \"is-collapsible\",\n !open && \"is-collapsed\",\n className,\n )}\n >\n <div className=\"gridkit-forms-section-header\">\n <Heading className=\"gridkit-forms-section-title\" id={titleId}>\n {collapsible ? (\n <button\n type=\"button\"\n className=\"gridkit-forms-section-toggle\"\n aria-expanded={open}\n aria-controls={bodyId}\n onClick={() => {\n setOpen(!open);\n }}\n >\n <span\n className=\"gridkit-forms-section-toggle-icon\"\n aria-hidden=\"true\"\n >\n <Chevron />\n </span>\n {title}\n </button>\n ) : (\n title\n )}\n </Heading>\n {hasDescription && (\n <p className=\"gridkit-forms-section-description\" id={descriptionId}>\n {description}\n </p>\n )}\n </div>\n <div className=\"gridkit-forms-section-body\" id={bodyId} hidden={!open}>\n <FormSettingsProvider settings={settings}>\n {children}\n </FormSettingsProvider>\n </div>\n </section>\n );\n}\n","import {\n convertDuration,\n durationDetails,\n durationFormatter,\n durationParser,\n formatDuration,\n maxDurationRule,\n minDurationRule,\n requiredRule,\n stepNumberValue,\n type ChangeCause,\n type DurationDetails,\n type DurationNotation,\n type DurationOptions,\n type DurationUnit,\n type StepDirection,\n type StepSize,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, type Ref } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport type { NumberStepEvent } from \"../number/NumberInput\";\nimport { useStepKeys } from \"../number/numberKind\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n OwnMessages,\n useControlElement,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport type { TextInputBaseProps } from \"../text/textInputProps\";\nimport {\n useFieldInput,\n validatorsOf,\n type FieldInputKind,\n} from \"../useFieldInput\";\n\nexport interface DurationInputProps extends TextInputBaseProps<\n number,\n HTMLInputElement,\n DurationDetails\n> {\n /** The unit the value is held in; `\"minute\"` by default, so timesheet values stay whole. */\n readonly valueUnit?: DurationUnit | undefined;\n /** What a bare number means: `\"hour\"` by default, so \"1.5\" is an hour and a half. */\n readonly inputUnit?: \"minute\" | \"hour\" | undefined;\n /** The smallest part that can be typed; finer parts round half up to it. `\"minute\"` by default. */\n readonly precision?: \"minute\" | \"second\" | undefined;\n /** How the value is written: `\"units\"` (\"1h 30m\", default), `\"clock\"` (\"1:30\") or `\"decimal\"` hours (\"1.5\"). */\n readonly notation?: DurationNotation | undefined;\n /** How many hours `d` is: 24 by default, 8 for a working day. */\n readonly hoursPerDay?: number | undefined;\n /** Whether a duration may be negative; off by default. */\n readonly allowNegative?: boolean | undefined;\n /** The shortest duration allowed, in `valueUnit`, inclusive. */\n readonly min?: number | undefined;\n /** The longest duration allowed, in `valueUnit`, inclusive. */\n readonly max?: number | undefined;\n /** What ArrowUp and ArrowDown add, in `valueUnit`: 15 minutes by default. */\n readonly step?: number | undefined;\n /** What PageUp and PageDown add, in `valueUnit`: an hour by default. */\n readonly largeStep?: number | undefined;\n /** Escape puts back the last committed value; on by default. */\n readonly revertOnEscape?: boolean | undefined;\n readonly onStep?: ((event: NumberStepEvent<number>) => void) | undefined;\n readonly ref?: Ref<HTMLInputElement> | undefined;\n}\n\n/** A duration field's `kind`: forms-core's duration parser, formatter and details. */\nfunction durationKind(\n options: DurationOptions,\n): FieldInputKind<number, DurationDetails> {\n return {\n defaultParse: durationParser(options),\n defaultFormat: durationFormatter(options),\n serialize: (value) => String(value),\n details: (current) => durationDetails(current, options),\n };\n}\n\nfunction DurationInputControl({\n valueUnit = \"minute\",\n inputUnit,\n precision,\n notation,\n hoursPerDay,\n allowNegative = false,\n min,\n max,\n step,\n largeStep,\n revertOnEscape = true,\n onStep,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n selectOnFocus = true,\n inputMode = \"text\",\n enterKeyHint,\n autoComplete = \"off\",\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: DurationInputProps) {\n const field = useFieldContext();\n const formSettings = useFormSettings();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const needsValue = required === true || field?.required === true;\n\n const options = useMemo<DurationOptions>(\n () => ({\n locale,\n valueUnit,\n inputUnit,\n precision,\n notation,\n hoursPerDay,\n allowNegative,\n }),\n [\n locale,\n valueUnit,\n inputUnit,\n precision,\n notation,\n hoursPerDay,\n allowNegative,\n ],\n );\n const kind = useMemo(() => durationKind(options), [options]);\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<number>()] : []),\n ...(min === undefined ? [] : [minDurationRule(min, options)]),\n ...(max === undefined ? [] : [maxDurationRule(max, options)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, options, validate],\n );\n\n const [element, controlRef] = useControlElement(ref);\n const input = useFieldInput(\n { ...props, required, validate: validators, ref: controlRef },\n kind,\n {\n startAdornment: hasNode(prefix),\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n },\n );\n const { controlProps, state } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const editable = !controlProps.readOnly && !controlProps.disabled;\n const display = input.mode === \"display\";\n\n const limits = {\n step: step ?? convertDuration(15, \"minute\", valueUnit),\n largeStep: largeStep ?? convertDuration(60, \"minute\", valueUnit),\n // A step never goes below zero in a field that takes no negatives.\n min: allowNegative ? (min ?? null) : Math.max(min ?? 0, 0),\n max: max ?? null,\n };\n\n function takeStep(\n direction: StepDirection,\n size: StepSize,\n nativeEvent: KeyboardEvent | WheelEvent,\n ): void {\n const previous = input.getValue();\n const next = stepNumberValue(previous, { direction, size, ...limits });\n if (next === null || next === previous) {\n return;\n }\n onStep?.({\n direction,\n size,\n via: nativeEvent instanceof WheelEvent ? \"wheel\" : \"key\",\n value: next,\n previousValue: previous,\n nativeEvent,\n });\n const cause: ChangeCause<Event> = {\n source: \"step\",\n nativeEvent,\n input: null,\n };\n input.change(next, cause);\n if (element !== null && element.ownerDocument.activeElement === element) {\n const end = element.value.length;\n element.setSelectionRange(end, end);\n }\n }\n\n useStepKeys(element, editable && !display, {\n onStep: takeStep,\n edges: { min: min !== undefined, max: max !== undefined },\n });\n\n const root = classNames(\n \"gridkit-forms-duration-input\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (display) {\n return (\n <div className={root} style={style}>\n {input.displayValue}\n {input.hiddenInput}\n </div>\n );\n }\n\n const { value } = state;\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n >\n <input\n autoCorrect=\"off\"\n spellCheck={false}\n {...extraControlProps}\n {...controlProps}\n className=\"gridkit-forms-duration-input-control\"\n type=\"text\"\n role=\"spinbutton\"\n placeholder={placeholder}\n autoFocus={autoFocus}\n inputMode={inputMode}\n enterKeyHint={enterKeyHint}\n autoComplete={autoComplete}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n aria-busy={loading || undefined}\n aria-valuenow={value ?? undefined}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuetext={\n value === null ? undefined : formatDuration(value, options)\n }\n />\n </ControlBox>\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * An amount of time typed freely, for timesheets and estimates: `1h 30m`,\n * `1h30`, `90m`, `1:30` or a bare `1.5` (hours, unless `inputUnit` says\n * minutes) all read as 90 minutes, unit words in the locale or English,\n * and a commit rewrites the text in `notation` (\"1h 30m\", \"1:30\" or\n * \"1.5\"). Its value is a number in `valueUnit` (minutes by default),\n * `null` when empty; text that is no duration keeps the last value and\n * says why. It is a spinbutton the arrow keys step by `step` (15\n * minutes) and PageUp and PageDown by `largeStep` (an hour), reporting\n * `onStep` as `NumberInput` does. `min` and `max` add their messages and\n * bound the steps. It takes every shared input prop: display mode,\n * `readOnly`, `disabled`, messages with their severity, density, prefix\n * and suffix, and the events of `@gridkitjs/forms` with `DurationDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function DurationInput(props: DurationInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <DurationInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n compareDecimals,\n filterNumberEdit,\n normalizeDecimal,\n numberDetails,\n numberFormatter,\n numberParser,\n numberToDecimal,\n shiftDecimal,\n type DecimalString,\n type FieldState,\n type NumberDetails,\n type NumberOptions,\n type NumberReadingInfo,\n type NumberValue,\n type NumberValueType,\n type PercentScale,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachStepKeys,\n type AttachedStepKeys,\n type StepKeysOptions,\n} from \"@gridkitjs/forms-dom\";\nimport { useEffect, useLayoutEffect, useMemo, useRef } from \"react\";\nimport { warnOnce } from \"../dev\";\nimport type { FieldInputKind } from \"../useFieldInput\";\nimport type { NumberInputProps } from \"./NumberInput\";\n\n/** The props that decide how a number field reads and writes its text. */\nexport type NumberFormatProps<T extends NumberValueType> = Pick<\n NumberInputProps<T>,\n | \"valueType\"\n | \"fractionDigits\"\n | \"minimumFractionDigits\"\n | \"maximumFractionDigits\"\n | \"integer\"\n | \"roundingMode\"\n | \"useGrouping\"\n | \"negative\"\n | \"decimalSeparator\"\n | \"groupSeparator\"\n | \"groupSizes\"\n | \"numberingSystem\"\n | \"currency\"\n | \"currencyDisplay\"\n | \"unit\"\n | \"unitDisplay\"\n>;\n\n/** A number value as an exact decimal string. */\nexport function toDecimal(value: number | string): DecimalString {\n return typeof value === \"number\"\n ? numberToDecimal(value)\n : (normalizeDecimal(value) ?? value);\n}\n\n/** Whether two numbers are the same, compared exactly. */\nexport function sameNumber(a: number | string, b: number | string): boolean {\n return compareDecimals(toDecimal(a), toDecimal(b)) === 0;\n}\n\nconst supported = new Map<string, boolean>();\n\n/** Whether Intl knows the currency code or unit; a dev warning otherwise. */\nfunction isSupported(style: \"currency\" | \"unit\", code: string): boolean {\n const key = `${style}:${code}`;\n let known = supported.get(key);\n if (known === undefined) {\n try {\n new Intl.NumberFormat(\"en\", { style, [style]: code });\n known = true;\n } catch {\n known = false;\n warnOnce(\n key,\n `NumberInput: ${style} \"${code}\" is not one Intl knows, so it is ignored.`,\n );\n }\n supported.set(key, known);\n }\n return known;\n}\n\n/** The style a number field writes in: a percent, else a currency (which wins over a unit), else a unit. */\nfunction numberStyle(\n percentScale: PercentScale | undefined,\n currency: string | undefined,\n unit: string | undefined,\n): NumberOptions[\"style\"] {\n if (percentScale !== undefined) {\n return \"percent\";\n }\n if (currency !== undefined && unit !== undefined) {\n warnOnce(\n \"number-currency-unit\",\n \"NumberInput: both currency and unit are set; the currency is shown.\",\n );\n }\n if (currency !== undefined && isSupported(\"currency\", currency)) {\n return \"currency\";\n }\n if (unit !== undefined && isSupported(\"unit\", unit)) {\n return \"unit\";\n }\n return \"decimal\";\n}\n\n/** How a number field with these props reads and writes, memoized on them. */\nexport function useNumberOptions<T extends NumberValueType>(\n {\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer = false,\n roundingMode,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n }: NumberFormatProps<T>,\n locale: Intl.LocalesArgument,\n percentScale?: PercentScale,\n): NumberOptions {\n const style = numberStyle(percentScale, currency, unit);\n return useMemo<NumberOptions>(\n () => ({\n locale,\n style,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n minimumFractionDigits: integer\n ? 0\n : (fractionDigits ?? minimumFractionDigits),\n maximumFractionDigits: integer\n ? 0\n : (fractionDigits ?? maximumFractionDigits),\n roundingMode,\n useGrouping,\n negative,\n percentScale,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n }),\n [\n locale,\n style,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n integer,\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n roundingMode,\n useGrouping,\n negative,\n percentScale,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n ],\n );\n}\n\n/** A number field's `kind`, its details always given. */\nexport type NumberKind<V> = FieldInputKind<V, NumberDetails> & {\n readonly details: (current: FieldState<V>) => NumberDetails;\n};\n\n/** How a number field's text is judged as it is typed. */\nexport interface NumberEntrySettings<T extends NumberValueType> {\n readonly valueType: T | undefined;\n /** Refuses keys that cannot be part of a number, and cleans pastes. */\n readonly cleanInput: boolean;\n /** Whether a minus may be typed: no `min`, or one below zero. */\n readonly negatives: boolean;\n readonly limitFractionDigits: boolean | undefined;\n readonly decimalEntry: \"fixed\" | \"free\" | undefined;\n}\n\n/**\n * A number field's `kind`: forms-core's parser and formatter, an exact\n * `equals`, `NumberDetails`, and `filterNumberEdit` as its filter. It\n * keeps how clean-up read the paste on screen, until the next edit, for\n * the details, so each field takes a kind of its own.\n */\nexport function numberKind<T extends NumberValueType>(\n options: NumberOptions,\n entry: NumberEntrySettings<T>,\n): NumberKind<NumberValue<T>> {\n let pasted: NumberReadingInfo | null = null;\n return {\n defaultParse: numberParser<T>({ ...options, valueType: entry.valueType }),\n defaultFormat: numberFormatter<NumberValue<T>>(options),\n serialize: (value) => toDecimal(value),\n equals: sameNumber,\n details: (current) => numberDetails(current, options, pasted),\n filterInput: entry.cleanInput\n ? (edit, before) => {\n const result = filterNumberEdit(edit, before, {\n ...options,\n negatives: entry.negatives,\n limitFractionDigits: entry.limitFractionDigits,\n decimalEntry: entry.decimalEntry,\n });\n pasted = result.pasted;\n return result.decision;\n }\n : undefined,\n };\n}\n\n/** Whether a field with this `min` takes negative numbers. */\nexport function takesNegatives(min: number | string | undefined): boolean {\n return min === undefined || compareDecimals(toDecimal(min), \"0\") < 0;\n}\n\n/** A development warning when `min` is above `max`. */\nexport function useLimitsWarning(\n name: string,\n min: number | string | undefined,\n max: number | string | undefined,\n): void {\n useEffect(() => {\n if (\n min !== undefined &&\n max !== undefined &&\n compareDecimals(toDecimal(min), toDecimal(max)) > 0\n ) {\n warnOnce(\n \"number-min-max\",\n `${name}: min is above max, so no value can satisfy both.`,\n );\n }\n }, [name, min, max]);\n}\n\n/** What a step adds: `step` (one, or a percentage point), and `largeStep` (ten steps). */\nexport function stepSizes(\n step: number | string | undefined,\n largeStep: number | string | undefined,\n percentScale: PercentScale | undefined,\n): { readonly step: DecimalString; readonly largeStep: DecimalString } {\n const size =\n step === undefined\n ? percentScale === \"fraction\"\n ? \"0.01\"\n : \"1\"\n : toDecimal(step);\n return {\n step: size,\n largeStep:\n largeStep === undefined ? shiftDecimal(size, 1) : toDecimal(largeStep),\n };\n}\n\n/** Options to attach with, before a render's own reach them. */\nconst NO_STEP_KEYS: StepKeysOptions = { onStep: () => undefined };\n\n/**\n * Attaches forms-dom's step keys to `element` while `on`, and hands them\n * every render's options.\n */\nexport function useStepKeys(\n element: HTMLInputElement | null,\n on: boolean,\n options: StepKeysOptions,\n): void {\n const stepKeys = useRef<AttachedStepKeys | null>(null);\n useLayoutEffect(() => {\n if (element === null || !on) {\n return undefined;\n }\n const attached = attachStepKeys(element, NO_STEP_KEYS);\n stepKeys.current = attached;\n return () => {\n attached.detach();\n stepKeys.current = null;\n };\n }, [element, on]);\n // Every render's options, the attaching render's included: this effect\n // runs straight after the one above, before any key can arrive.\n useLayoutEffect(() => {\n stepKeys.current?.setOptions(options);\n });\n}\n","import {\n maskDetails,\n requiredRule,\n type MaskDetails,\n type MaskOptions,\n type MaskPreset,\n type MaskSource,\n type MaskValueFormat,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo, type Ref } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport type { TextInputBaseProps } from \"../text/textInputProps\";\nimport { useFieldInput, validatorsOf } from \"../useFieldInput\";\nimport {\n firstEmptySlot,\n maskCaret,\n maskKind,\n maskTemplate,\n resolveMask,\n} from \"./maskKind\";\n\nexport interface MaskedInputProps\n extends\n TextInputBaseProps<string, HTMLInputElement, MaskDetails>,\n Partial<Pick<MaskOptions, \"tokens\" | \"promptCharacter\">> {\n /**\n * A pattern (`\"(000) 000-0000\"`), several tried in order as the text\n * grows, a function choosing one from the raw text, or a preset from\n * `maskPresets`.\n */\n readonly mask: MaskSource | MaskPreset;\n /**\n * `\"raw\"` (default): only the characters typed. `\"formatted\"`: with the\n * literals. A preset sets its own, which this overrides.\n */\n readonly valueFormat?: MaskValueFormat | undefined;\n /** A fixed-width font, so the slots line up down a column of fields. */\n readonly monospace?: boolean | undefined;\n /** Escape puts back the last committed value; on by default. */\n readonly revertOnEscape?: boolean | undefined;\n readonly ref?: Ref<HTMLInputElement> | undefined;\n}\n\nfunction MaskedInputControl({\n mask,\n tokens,\n promptCharacter,\n valueFormat,\n monospace = false,\n revertOnEscape = true,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n selectOnFocus = false,\n inputMode,\n enterKeyHint,\n autoComplete,\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: MaskedInputProps) {\n const field = useFieldContext();\n const formSettings = useFormSettings();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const needsValue = required === true || field?.required === true;\n\n const resolved = useMemo(\n () => resolveMask(mask, { tokens, promptCharacter, valueFormat }, locale),\n [mask, tokens, promptCharacter, valueFormat, locale],\n );\n const { options } = resolved;\n const kind = useMemo(\n () => maskKind(options, resolved.valueFormat),\n [options, resolved.valueFormat],\n );\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<string>()] : []),\n ...(resolved.validate === undefined ? [] : [resolved.validate]),\n ...validatorsOf(validate),\n ],\n [needsValue, resolved.validate, validate],\n );\n\n const input = useFieldInput(\n { ...props, required, validate: validators, ref },\n kind,\n {\n startAdornment: hasNode(prefix),\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n mapCaret: options === null ? undefined : maskCaret(options),\n lastCaret:\n options === null\n ? undefined\n : (text: string) => firstEmptySlot(options, text),\n },\n );\n const { controlProps } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const editable = !controlProps.readOnly && !controlProps.disabled;\n const root = classNames(\n \"gridkit-forms-masked-input\",\n monospace && \"is-monospace\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n {input.displayValue}\n {input.hiddenInput}\n </div>\n );\n }\n\n // While focused an empty field shows the template, which is not text to clear.\n const typed =\n options === null ? input.text : maskDetails(options, input.text).raw;\n\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && typed !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n >\n <input\n autoCapitalize={resolved.upperCase ? \"characters\" : undefined}\n autoCorrect=\"off\"\n spellCheck={false}\n {...extraControlProps}\n {...controlProps}\n className=\"gridkit-forms-masked-input-control\"\n type=\"text\"\n dir=\"ltr\"\n placeholder={\n placeholder ??\n (options === null ? undefined : maskTemplate(options))\n }\n autoFocus={autoFocus}\n inputMode={inputMode ?? resolved.inputMode}\n enterKeyHint={enterKeyHint}\n autoComplete={autoComplete ?? resolved.autoComplete ?? \"off\"}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n aria-busy={loading || undefined}\n />\n </ControlBox>\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * A text field laid into a mask: postal codes, IBANs, card numbers, part\n * numbers. Typing fills the mask's slots and skips its literals, a paste\n * keeps what fits, and text an input method composed is laid in once it\n * ends. While focused the empty slots show the prompt character; without\n * focus, the text typed with its literals. The value is a string, the raw\n * characters or (`valueFormat=\"formatted\"`) the text with its literals,\n * only once the mask is complete, and `null` when empty: incomplete text\n * is unreadable and keeps the last complete value. Presets bring their\n * pattern, check, keyboard and value format. It takes every shared input\n * prop: display mode, `readOnly`, `disabled`, messages with their\n * severity, density, prefix and suffix, and the events of\n * `@gridkitjs/forms` with `MaskDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function MaskedInput(props: MaskedInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <MaskedInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n compileMask,\n fieldText,\n filterMaskEdit,\n formatMasked,\n formatText,\n maskDetails,\n maskFormatter,\n maskInputHints,\n maskParser,\n textParser,\n type FieldState,\n type MaskCompileResult,\n type MaskDetails,\n type MaskOptions,\n type MaskPreset,\n type MaskSource,\n type MaskTokens,\n type MaskValueFormat,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport { warnOnce } from \"../dev\";\nimport type { FieldInputKind } from \"../useFieldInput\";\n\n/** Whether the `mask` prop is a preset rather than a pattern, several, or a function. */\nfunction isPreset(mask: MaskSource | MaskPreset): mask is MaskPreset {\n return typeof mask === \"object\" && \"options\" in mask;\n}\n\n/** What a masked input works from: its mask, or `null` when the mask is malformed and it takes plain text. */\nexport interface ResolvedMask {\n readonly options: MaskOptions | null;\n /** A preset's own check. */\n readonly validate: Validator<string> | undefined;\n readonly valueFormat: MaskValueFormat;\n readonly inputMode: \"numeric\" | \"decimal\" | \"text\" | undefined;\n readonly autoComplete: string | undefined;\n /** The mask upper-cases letters. */\n readonly upperCase: boolean;\n}\n\n/** The first malformed pattern of `options`, checked as the engine would compile it. */\nfunction compileError(options: MaskOptions): {\n readonly pattern: string;\n readonly error: Extract<MaskCompileResult, { kind: \"error\" }>;\n} | null {\n const { mask, tokens } = options;\n const patterns =\n typeof mask === \"function\"\n ? [mask(\"\")]\n : typeof mask === \"string\"\n ? [mask]\n : mask;\n for (const pattern of patterns) {\n const compiled = compileMask(pattern, tokens);\n if (compiled.kind === \"error\") {\n return { pattern, error: compiled };\n }\n }\n return null;\n}\n\n/**\n * The mask a masked input works from: a preset's options or the given\n * pattern, with the input's own tokens laid over a preset's, its prompt,\n * and the field's locale unless the preset names one. A malformed pattern\n * warns once in development and leaves the input taking plain text.\n */\nexport function resolveMask(\n mask: MaskSource | MaskPreset,\n overrides: {\n readonly tokens: MaskTokens | undefined;\n readonly promptCharacter: string | undefined;\n readonly valueFormat: MaskValueFormat | undefined;\n },\n locale: Intl.LocalesArgument,\n): ResolvedMask {\n const preset = isPreset(mask) ? mask : null;\n const base: MaskOptions = isPreset(mask) ? mask.options : { mask };\n const options: MaskOptions = {\n ...base,\n tokens:\n overrides.tokens === undefined\n ? base.tokens\n : { ...base.tokens, ...overrides.tokens },\n promptCharacter: overrides.promptCharacter ?? base.promptCharacter,\n locale: base.locale ?? locale,\n };\n const valueFormat = overrides.valueFormat ?? preset?.valueFormat ?? \"raw\";\n const failed = compileError(options);\n if (failed !== null) {\n warnOnce(\n `mask:${failed.pattern}`,\n `MaskedInput: the mask \"${failed.pattern}\" is malformed at ${String(failed.error.position)} (${failed.error.message}), so the input takes plain text.`,\n );\n return {\n options: null,\n validate: preset?.validate,\n valueFormat,\n inputMode: undefined,\n autoComplete: preset?.autoComplete,\n upperCase: false,\n };\n }\n const hints = maskInputHints(options);\n return {\n options,\n validate: preset?.validate,\n valueFormat,\n inputMode: preset?.inputMode ?? hints.inputMode,\n autoComplete: preset?.autoComplete,\n upperCase: hints.upperCase,\n };\n}\n\n/** A masked field's `kind`, its details always given. */\nexport type MaskKind = FieldInputKind<string, MaskDetails> & {\n readonly details: (current: FieldState<string>) => MaskDetails;\n};\n\n/**\n * A masked field's `kind`: forms-core's mask parser, formatter and filter,\n * and `MaskDetails` for the text on screen. Without a mask (a malformed\n * one), plain text, whose details call it complete.\n */\nexport function maskKind(\n options: MaskOptions | null,\n valueFormat: MaskValueFormat,\n): MaskKind {\n if (options === null) {\n return {\n defaultParse: textParser(),\n defaultFormat: formatText,\n serialize: (value) => value,\n details: (current) => {\n const text = fieldText(current, (value) => value ?? \"\");\n return { raw: text, formatted: text, complete: true, pattern: \"\" };\n },\n };\n }\n const display = (value: string | null) =>\n formatMasked(options, value ?? \"\", false).text;\n return {\n defaultParse: maskParser(options, valueFormat),\n defaultFormat: maskFormatter(options),\n serialize: (value) => value,\n details: (current) => maskDetails(options, fieldText(current, display)),\n filterInput: (edit, before) => filterMaskEdit(edit, before, options),\n };\n}\n\n/** Where typing goes on in `text`: the first empty slot, or the end. */\nexport function firstEmptySlot(options: MaskOptions, text: string): number {\n return formatMasked(options, maskDetails(options, text).raw, true).caret;\n}\n\n/**\n * Where the caret goes when a masked field's text is written into the\n * focused control: at its distance from the end, as for any text, but\n * never past the first empty slot, so focus on an empty field puts it in\n * the first slot.\n */\nexport function maskCaret(\n options: MaskOptions,\n): (previousText: string, caret: number, nextText: string) => number {\n return (previousText, caret, nextText) =>\n Math.min(\n Math.max(0, nextText.length - (previousText.length - caret)),\n firstEmptySlot(options, nextText),\n );\n}\n\n/** The template a placeholder shows: the mask with its prompt in every slot, `_` when the prompt is none. */\nexport function maskTemplate(options: MaskOptions): string {\n const prompted =\n options.promptCharacter === \"\"\n ? { ...options, promptCharacter: \"_\" }\n : options;\n return formatMasked(prompted, \"\", true).text;\n}\n","import {\n compareDecimals,\n formatNumber,\n maxRule,\n minRule,\n numberAffixes,\n numberCaret,\n numberSymbols,\n requiredRule,\n stepNumberValue,\n type ChangeCause,\n type DecimalString,\n type NegativeStyle,\n type NumberDetails,\n type NumberOptions,\n type NumberValue,\n type NumberValueType,\n type PercentScale,\n type RoundingMode,\n type StepDirection,\n type StepSize,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachHoldRepeat,\n type AttachedHoldRepeat,\n type HoldRepeatOptions,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n keepFocus,\n OwnMessages,\n useControlElement,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport type { TextInputBaseProps } from \"../text/textInputProps\";\nimport { isFocused, useFieldInput, validatorsOf } from \"../useFieldInput\";\nimport {\n numberKind,\n sameNumber,\n stepSizes,\n takesNegatives,\n toDecimal,\n useLimitsWarning,\n useNumberOptions,\n useStepKeys,\n} from \"./numberKind\";\n\n/** A limit or step: a number, or in decimal mode also an exact decimal string. */\nexport type NumberLimit<T extends NumberValueType> = T extends \"decimal\"\n ? number | DecimalString\n : number;\n\n/** onStep: a step is about to be taken. The change events follow, and may still refuse it. */\nexport interface NumberStepEvent<V> {\n readonly direction: StepDirection;\n readonly size: StepSize;\n readonly via: \"key\" | \"button\" | \"wheel\";\n /** The value the step goes to. */\n readonly value: V | null;\n readonly previousValue: V | null;\n readonly nativeEvent: Event | null;\n}\n\nexport interface NumberInputProps<\n T extends NumberValueType = \"number\",\n> extends TextInputBaseProps<NumberValue<T>, HTMLInputElement, NumberDetails> {\n /** `\"number\"` (default): a JS number. `\"decimal\"`: an exact decimal string (`\"1234.50\"`). */\n readonly valueType?: T | undefined;\n /** Fixed decimals: shown and kept, and typed in place. Sets both the minimum and the maximum. */\n readonly fractionDigits?: number | undefined;\n /** Fraction digits always written; 0 by default (a currency: its minor units). */\n readonly minimumFractionDigits?: number | undefined;\n /** Fraction digits kept; more are rounded. Unset: every digit typed is kept. */\n readonly maximumFractionDigits?: number | undefined;\n /** Whole numbers only: no decimal separator, a numeric keyboard. */\n readonly integer?: boolean | undefined;\n /** `\"halfExpand\"` (ties away from zero) by default; Intl's names. */\n readonly roundingMode?: RoundingMode | undefined;\n /** Refuses a keystroke that would type more fraction digits than allowed, instead of rounding. */\n readonly limitFractionDigits?: boolean | undefined;\n /**\n * With fixed decimals, `\"fixed\"` (default) shows them while typing, the\n * decimal separator jumps into them and they are typed over; `\"free\"`\n * types them as any other field does.\n */\n readonly decimalEntry?: \"fixed\" | \"free\" | undefined;\n /** Group the integer digits when the field does not have focus. On by default. */\n readonly useGrouping?: boolean | undefined;\n /** How a negative number is shown without focus: `\"minus\"` (default), `\"parentheses\"`, `\"trailingMinus\"`. */\n readonly negative?: NegativeStyle | undefined;\n readonly decimalSeparator?: string | undefined;\n readonly groupSeparator?: string | undefined;\n readonly groupSizes?:\n readonly [primary: number, secondary: number] | undefined;\n /** The digits the field writes: `\"latn\"` keeps Latin digits in `ar-EG`. */\n readonly numberingSystem?: string | undefined;\n /** ISO 4217 code; its sign is drawn beside the number, where the locale puts it. */\n readonly currency?: string | undefined;\n readonly currencyDisplay?: NumberOptions[\"currencyDisplay\"];\n /** An Intl unit (`\"kilogram\"`), drawn beside the number. */\n readonly unit?: string | undefined;\n readonly unitDisplay?: NumberOptions[\"unitDisplay\"];\n readonly min?: NumberLimit<T> | undefined;\n readonly max?: NumberLimit<T> | undefined;\n /** What the arrow keys and the stepper add; 1 by default. */\n readonly step?: NumberLimit<T> | undefined;\n /** What PageUp and PageDown add; ten steps by default. */\n readonly largeStep?: NumberLimit<T> | undefined;\n /** `\"keys\"` (default): a spinbutton the arrow keys step. `\"none\"`: a plain text box. */\n readonly stepping?: \"keys\" | \"none\" | undefined;\n /** Stepper buttons: none (default), stacked at the end, or one at each end. */\n readonly stepper?: \"none\" | \"end\" | \"split\" | undefined;\n /** The mouse wheel steps while the field has focus. Off by default. */\n readonly wheel?: boolean | undefined;\n /** Refuses keys that cannot be part of a number and cleans pastes. On by default. */\n readonly cleanInput?: boolean | undefined;\n /** Where the number sits in the box: the end (default) or the start. */\n readonly align?: \"start\" | \"end\" | undefined;\n /** Escape puts back the last committed value; on by default. */\n readonly revertOnEscape?: boolean | undefined;\n readonly onStep?:\n ((event: NumberStepEvent<NumberValue<T>>) => void) | undefined;\n readonly ref?: Ref<HTMLInputElement> | undefined;\n}\n\n/** What `PercentInput` adds to the shared number control. */\nexport interface NumberVariant {\n /** Set for a percent: how its value is scaled. */\n readonly percentScale?: PercentScale | undefined;\n /** The root's classes. */\n readonly rootClassName: string;\n}\n\n/** Options to attach with, before a render's own reach them. */\nconst NO_REPEAT: HoldRepeatOptions = { onRepeat: () => false };\n\nfunction ChevronIcon({ direction }: { readonly direction: StepDirection }) {\n return (\n <svg\n className=\"gridkit-forms-stepper-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d={direction === \"up\" ? \"m6 15 6-6 6 6\" : \"m6 9 6 6 6-6\"} />\n </svg>\n );\n}\n\n/**\n * One stepper button: it steps once when pressed and repeats while held\n * (forms-dom's `attachHoldRepeat`), and a hold ends when the control loses\n * focus. At a limit, or in a read-only field, it is drawn disabled but\n * stays pressable, so a held pointer is never lost.\n */\nfunction StepperButton({\n direction,\n label,\n controlId,\n inactive,\n disabled,\n focused,\n onRepeat,\n}: {\n readonly direction: StepDirection;\n readonly label: string;\n readonly controlId: string;\n /** At a limit, or read-only: drawn disabled. */\n readonly inactive: boolean;\n /** The field is disabled. */\n readonly disabled: boolean;\n /** The control has focus. */\n readonly focused: boolean;\n readonly onRepeat: (nativeEvent: PointerEvent) => boolean;\n}) {\n const [button, setButton] = useState<HTMLButtonElement | null>(null);\n const hold = useRef<AttachedHoldRepeat | null>(null);\n useLayoutEffect(() => {\n if (button === null) {\n return undefined;\n }\n const attached = attachHoldRepeat(button, NO_REPEAT);\n hold.current = attached;\n return () => {\n attached.detach();\n hold.current = null;\n };\n }, [button]);\n // Every render's step, the attaching render's included: this effect runs\n // straight after the one above, before any press can arrive.\n useLayoutEffect(() => {\n hold.current?.setOptions({ onRepeat });\n });\n useEffect(() => {\n if (!focused) {\n hold.current?.cancel();\n }\n }, [focused]);\n\n return (\n <button\n ref={setButton}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-stepper-button\",\n direction === \"up\" ? \"is-increment\" : \"is-decrement\",\n (inactive || disabled) && \"is-disabled\",\n )}\n tabIndex={-1}\n aria-label={label}\n aria-controls={controlId}\n aria-disabled={inactive || undefined}\n disabled={disabled}\n onMouseDown={keepFocus}\n >\n <ChevronIcon direction={direction} />\n </button>\n );\n}\n\n/** The number control `NumberInput` and `PercentInput` share. */\nexport function NumberControl<T extends NumberValueType = \"number\">({\n percentScale,\n rootClassName,\n valueType,\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer = false,\n roundingMode,\n limitFractionDigits,\n decimalEntry,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n min,\n max,\n step,\n largeStep,\n stepping = \"keys\",\n stepper = \"none\",\n wheel = false,\n cleanInput = true,\n align = \"end\",\n revertOnEscape = true,\n onStep,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n selectOnFocus = true,\n inputMode,\n enterKeyHint,\n autoComplete = \"off\",\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: NumberInputProps<T> & NumberVariant) {\n type V = NumberValue<T>;\n const field = useFieldContext();\n const formSettings = useFormSettings();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const needsValue = required === true || field?.required === true;\n const numberOptions = useNumberOptions(\n {\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer,\n roundingMode,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n },\n locale,\n percentScale,\n );\n const symbols = numberSymbols(locale, numberOptions);\n const negatives = takesNegatives(min);\n useLimitsWarning(\"NumberInput\", min, max);\n\n const kind = useMemo(\n () =>\n numberKind<T>(numberOptions, {\n valueType,\n cleanInput,\n negatives,\n limitFractionDigits,\n decimalEntry,\n }),\n [\n numberOptions,\n valueType,\n cleanInput,\n negatives,\n limitFractionDigits,\n decimalEntry,\n ],\n );\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<V>()] : []),\n ...(min === undefined ? [] : [minRule<V>(min, numberOptions)]),\n ...(max === undefined ? [] : [maxRule<V>(max, numberOptions)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, numberOptions, validate],\n );\n const mapCaret = useMemo(() => numberCaret(numberOptions), [numberOptions]);\n const affixes = numberAffixes(numberOptions);\n\n const [element, controlRef] = useControlElement(ref);\n const input = useFieldInput(\n { ...props, required, validate: validators, ref: controlRef },\n kind,\n {\n startAdornment:\n hasNode(prefix) || affixes.prefix !== \"\" || stepper === \"split\",\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n mapCaret,\n decimalKey: integer ? undefined : symbols.decimal,\n },\n );\n const { controlProps, state } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const affixId = `${controlId}-affix`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const editable = !controlProps.readOnly && !controlProps.disabled;\n const display = input.mode === \"display\";\n const focused = isFocused(state.phase);\n const spinbutton = stepping === \"keys\";\n\n const limits = {\n ...stepSizes(step, largeStep, percentScale),\n min: min ?? null,\n max: max ?? null,\n };\n\n /** Takes a step, and says whether the value moved. */\n function takeStep(\n direction: StepDirection,\n size: StepSize,\n via: NumberStepEvent<V>[\"via\"],\n nativeEvent: Event,\n ): boolean {\n if (!editable) {\n return false;\n }\n const previous = input.getValue();\n const next = stepNumberValue<T>(\n previous,\n { direction, size, ...limits },\n { ...numberOptions, valueType },\n );\n if (next === null || (previous !== null && sameNumber(previous, next))) {\n return false;\n }\n onStep?.({\n direction,\n size,\n via,\n value: next,\n previousValue: previous,\n nativeEvent,\n });\n const cause: ChangeCause<Event> = {\n source: \"step\",\n nativeEvent,\n input: null,\n };\n input.change(next, cause);\n if (element !== null && element.ownerDocument.activeElement === element) {\n const end = element.value.length;\n element.setSelectionRange(end, end);\n }\n const now = input.getValue();\n return now === null || previous === null || !sameNumber(now, previous);\n }\n\n useStepKeys(element, spinbutton && editable && !display, {\n onStep: (direction, size, nativeEvent) => {\n takeStep(\n direction,\n size,\n nativeEvent instanceof WheelEvent ? \"wheel\" : \"key\",\n nativeEvent,\n );\n },\n edges: { min: min !== undefined, max: max !== undefined },\n wheel,\n });\n\n const { value } = state;\n const root = classNames(\n rootClassName,\n align === \"start\" && \"is-align-start\",\n stepper === \"end\" && \"is-stepper-end\",\n stepper === \"split\" && \"is-stepper-split\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (display) {\n const text =\n props.format !== undefined || value === null\n ? input.text\n : formatNumber(value, numberOptions, \"full\");\n return (\n <div className={root} style={style}>\n <DisplayValue text={text} emptyText={strings.emptyValue} />\n {input.hiddenInput}\n </div>\n );\n }\n\n function stepperButton(direction: StepDirection): ReactNode {\n const limit = direction === \"up\" ? max : min;\n const atLimit =\n limit !== undefined &&\n value !== null &&\n compareDecimals(toDecimal(value), toDecimal(limit)) *\n (direction === \"up\" ? 1 : -1) >=\n 0;\n return (\n <StepperButton\n direction={direction}\n label={direction === \"up\" ? strings.increase : strings.decrease}\n controlId={controlId}\n inactive={atLimit || controlProps.readOnly === true}\n disabled={controlProps.disabled === true}\n focused={focused}\n onRepeat={(nativeEvent) => {\n if (element === null) {\n return false;\n }\n if (element.ownerDocument.activeElement !== element) {\n element.focus();\n }\n return takeStep(direction, \"step\", \"button\", nativeEvent);\n }}\n />\n );\n }\n\n const affix = (text: string, side: \"start\" | \"end\") =>\n text === \"\" ? null : (\n <span\n className={`gridkit-forms-number-input-affix is-${side}`}\n id={spinbutton ? undefined : affixId}\n aria-hidden={spinbutton || undefined}\n >\n {text}\n </span>\n );\n const hasAffix = affixes.prefix !== \"\" || affixes.suffix !== \"\";\n\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n start={stepper === \"split\" ? stepperButton(\"down\") : undefined}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n end={\n stepper === \"end\" ? (\n <span className=\"gridkit-forms-stepper\">\n {stepperButton(\"up\")}\n {stepperButton(\"down\")}\n </span>\n ) : stepper === \"split\" ? (\n stepperButton(\"up\")\n ) : null\n }\n >\n {affix(affixes.prefix, \"start\")}\n <input\n {...extraControlProps}\n {...controlProps}\n className=\"gridkit-forms-number-input-control\"\n type=\"text\"\n role={spinbutton ? \"spinbutton\" : undefined}\n dir={symbols.numbersLeftToRight ? \"ltr\" : undefined}\n placeholder={placeholder}\n autoFocus={autoFocus}\n inputMode={inputMode ?? (integer ? \"numeric\" : \"decimal\")}\n enterKeyHint={enterKeyHint}\n autoComplete={autoComplete}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n hasNode(prefix) && prefixId,\n !spinbutton && hasAffix && affixId,\n hasNode(suffix) && suffixId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n aria-busy={loading || undefined}\n aria-valuenow={\n spinbutton && value !== null ? Number(value) : undefined\n }\n aria-valuemin={\n spinbutton && min !== undefined ? Number(min) : undefined\n }\n aria-valuemax={\n spinbutton && max !== undefined ? Number(max) : undefined\n }\n aria-valuetext={\n spinbutton && value !== null\n ? formatNumber(value, numberOptions, \"full\")\n : undefined\n }\n />\n {affix(affixes.suffix, \"end\")}\n </ControlBox>\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * A number field: locale-aware entry with the shared events, a JS number\n * or (with `valueType=\"decimal\"`) an exact decimal string as its value,\n * `null` when empty. While it has focus it shows plain digits, and with\n * fixed decimals every decimal, typed in place; without focus, the number\n * grouped and padded, with a currency or unit drawn beside it. It is a\n * spinbutton the arrow keys step, with optional stepper buttons that\n * repeat while held, and takes every shared input prop: display mode,\n * `readOnly`, `disabled`, messages with their severity, density, prefix\n * and suffix, and the events of `@gridkitjs/forms` with `NumberDetails`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function NumberInput<T extends NumberValueType = \"number\">(\n props: NumberInputProps<T>,\n) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <NumberControl<T> {...props} rootClassName=\"gridkit-forms-number-input\" />\n </InputFrame>\n );\n}\n","import {\n compareDecimals,\n endsRule,\n formatNumber,\n formatNumberRange,\n maxRule,\n maxSpanRule,\n minRule,\n minSpanRule,\n numberAffixes,\n numberCaret,\n numberRangeKindOf,\n numberSymbols,\n rangeDetails,\n rangeEnds,\n rangeSpan,\n readRangeEnds,\n requiredRule,\n sameRange,\n stepNumberValue,\n type FieldState,\n type NoFlags,\n type NumberDetails,\n type NumberOptions,\n type NumberValue,\n type NumberValueType,\n type PartController,\n type PartOptions,\n type Range,\n type RangeBounds,\n type RangeDetails,\n type RangeEnd,\n type RangeEnds,\n type StepDirection,\n type StepSize,\n type Validator,\n} from \"@gridkitjs/forms-core\";\nimport type { TextInputOptions } from \"@gridkitjs/forms-dom\";\nimport {\n useLayoutEffect,\n useMemo,\n useState,\n type HTMLAttributes,\n type Ref,\n} from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n ControlBox,\n densityClass,\n InputFrame,\n joinIds,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport type { TextInputBaseProps } from \"../text/textInputProps\";\nimport {\n useCompositeInput,\n usePartControl,\n type CompositeInputSpec,\n} from \"../useCompositeInput\";\nimport { validatorsOf } from \"../useFieldInput\";\nimport type { NumberInputProps, NumberLimit } from \"./NumberInput\";\nimport {\n numberKind,\n sameNumber,\n stepSizes,\n takesNegatives,\n toDecimal,\n useLimitsWarning,\n useNumberOptions,\n useStepKeys,\n type NumberFormatProps,\n type NumberKind,\n} from \"./numberKind\";\n\n/** A number range: either end `null` when open. */\nexport type NumberRange<T extends NumberValueType = \"number\"> = Range<\n NumberValue<T>\n>;\n\n/** What `NumberRangeInput` adds to every event: the range's details and each end's number details. */\nexport type NumberRangeDetails<T extends NumberValueType = \"number\"> =\n RangeDetails<NumberValue<T>, NoFlags, NumberValue<T>> & {\n readonly startDetails: NumberDetails;\n readonly endDetails: NumberDetails;\n };\n\nexport interface NumberRangeInputProps<T extends NumberValueType = \"number\">\n extends\n Omit<\n TextInputBaseProps<\n NumberRange<T>,\n HTMLInputElement,\n NumberRangeDetails<T>\n >,\n | \"placeholder\"\n | \"prefix\"\n | \"suffix\"\n | \"ref\"\n | \"parse\"\n | \"format\"\n | \"controlProps\"\n >,\n NumberFormatProps<T>,\n Pick<\n NumberInputProps<T>,\n | \"min\"\n | \"max\"\n | \"step\"\n | \"largeStep\"\n | \"stepping\"\n | \"limitFractionDigits\"\n | \"decimalEntry\"\n | \"cleanInput\"\n | \"align\"\n | \"revertOnEscape\"\n > {\n /** `\"[]\"` (default): the end belongs to the range. `\"[)\"`: it does not, so 10–10 is empty. */\n readonly bounds?: RangeBounds | undefined;\n /** An end typed before its start: swapped (default) or an error. */\n readonly reversed?: \"swap\" | \"error\" | undefined;\n /** With `bounds=\"[)\"`, allows a start equal to its end. */\n readonly allowEmpty?: boolean | undefined;\n /** The shortest span allowed, `end - start`. */\n readonly minSpan?: NumberLimit<T> | undefined;\n /** The longest span allowed. */\n readonly maxSpan?: NumberLimit<T> | undefined;\n /** Shows the span after the end (\"Span: 10\"), read with the end. */\n readonly showSpan?: boolean | undefined;\n readonly startPlaceholder?: string | undefined;\n readonly endPlaceholder?: string | undefined;\n /** The start's native control. */\n readonly startRef?: Ref<HTMLInputElement> | undefined;\n /** The end's native control. */\n readonly endRef?: Ref<HTMLInputElement> | undefined;\n}\n\n/** The tighter of two limits: the lower of two upper limits, the higher of two lower ones. */\nfunction tighter<V extends number | string>(\n a: V | null,\n b: V | null,\n side: \"lower\" | \"upper\",\n): V | null {\n if (a === null || b === null) {\n return a ?? b;\n }\n const order = compareDecimals(toDecimal(a), toDecimal(b));\n return (side === \"upper\" ? order <= 0 : order >= 0) ? a : b;\n}\n\n/** A number kind as one part of a composite: how it reads, writes and filters. */\nfunction partOf<V>(kind: NumberKind<V>): PartOptions<V, Event> {\n return {\n defaultParse: kind.defaultParse,\n defaultFormat: kind.defaultFormat,\n equals: kind.equals,\n filterInput: kind.filterInput,\n };\n}\n\n/** What both ends' controls share. */\ninterface EndSettings<V> {\n readonly text: TextInputOptions;\n readonly spinbutton: boolean;\n readonly editable: boolean;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n readonly required: boolean;\n readonly ltr: boolean;\n readonly autoFocus: boolean | undefined;\n readonly attributes: Pick<\n HTMLAttributes<HTMLInputElement>,\n \"inputMode\" | \"enterKeyHint\"\n > & { readonly autoComplete: string | undefined };\n readonly min: number | string | undefined;\n readonly max: number | string | undefined;\n /** The value a step takes an end to, or `null` when it takes none. */\n readonly stepTo: (\n end: RangeEnd,\n direction: StepDirection,\n size: StepSize,\n ) => V | null;\n /** A value as a screen reader says it. */\n readonly valueText: (value: V) => string;\n}\n\n/** One end's control: a number box of its own, typed and stepped as a `NumberInput`. */\nfunction RangeEndControl<V extends number | string>({\n end,\n part,\n controlRef,\n onElement,\n id,\n labelledBy,\n describedBy,\n invalid,\n placeholder,\n settings,\n}: {\n readonly end: RangeEnd;\n readonly part: PartController<V, Event>;\n readonly controlRef: Ref<HTMLInputElement> | undefined;\n /** Told the control once it is in the page, and `null` when it goes. */\n readonly onElement?: ((element: HTMLInputElement | null) => void) | undefined;\n readonly id: string;\n readonly labelledBy: string | undefined;\n readonly describedBy: string | undefined;\n readonly invalid: boolean;\n readonly placeholder: string | undefined;\n readonly settings: EndSettings<V>;\n}) {\n const [element, ref] = usePartControl(part, controlRef, settings.text);\n useLayoutEffect(() => {\n onElement?.(element);\n }, [onElement, element]);\n const { spinbutton, min, max } = settings;\n useStepKeys(element, spinbutton && settings.editable, {\n onStep: (direction, size, nativeEvent) => {\n const next = settings.stepTo(end, direction, size);\n if (next === null) {\n return;\n }\n part.change(next, { source: \"step\", nativeEvent, input: null });\n if (element !== null && element.ownerDocument.activeElement === element) {\n const caret = element.value.length;\n element.setSelectionRange(caret, caret);\n }\n },\n edges: { min: min !== undefined, max: max !== undefined },\n });\n const { value } = part.getState();\n return (\n <input\n {...settings.attributes}\n ref={ref}\n id={id}\n className={`gridkit-forms-number-input-control gridkit-forms-range-${end}`}\n type=\"text\"\n role={spinbutton ? \"spinbutton\" : undefined}\n dir={settings.ltr ? \"ltr\" : undefined}\n defaultValue={part.getText()}\n readOnly={settings.readOnly}\n disabled={settings.disabled}\n placeholder={placeholder}\n autoFocus={end === \"start\" ? settings.autoFocus : undefined}\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n aria-invalid={invalid || undefined}\n aria-required={settings.required || undefined}\n aria-valuenow={spinbutton && value !== null ? Number(value) : undefined}\n aria-valuemin={spinbutton && min !== undefined ? Number(min) : undefined}\n aria-valuemax={spinbutton && max !== undefined ? Number(max) : undefined}\n aria-valuetext={\n spinbutton && value !== null ? settings.valueText(value) : undefined\n }\n />\n );\n}\n\n/** The range as display mode writes it: \"10–20\", \"from 10\", \"up to 20\". */\nfunction displayText<V extends number | string>(\n range: Range<V> | null,\n options: NumberOptions,\n strings: {\n rangeFrom: (start: string) => string;\n rangeUpTo: (end: string) => string;\n },\n): string {\n if (range === null) {\n return \"\";\n }\n const { start, end } = range;\n if (start !== null && end !== null) {\n return formatNumberRange(start, end, options);\n }\n if (start !== null) {\n return strings.rangeFrom(formatNumber(start, options, \"full\"));\n }\n return end === null\n ? \"\"\n : strings.rangeUpTo(formatNumber(end, options, \"full\"));\n}\n\n/** Whether an end's own text or value is at fault: it cannot be read, or lies outside `min` and `max`. */\nfunction endAtFault<V extends number | string>(\n state: FieldState<V>,\n min: number | string | undefined,\n max: number | string | undefined,\n): boolean {\n const { draft, value } = state;\n if (draft.kind === \"text\" && draft.reading.kind === \"unreadable\") {\n return true;\n }\n if (value === null) {\n return false;\n }\n const decimal = toDecimal(value);\n return (\n (min !== undefined && compareDecimals(decimal, toDecimal(min)) < 0) ||\n (max !== undefined && compareDecimals(decimal, toDecimal(max)) > 0)\n );\n}\n\n/** The range control behind `NumberRangeInput`. */\nfunction NumberRangeControl<T extends NumberValueType = \"number\">({\n valueType,\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer = false,\n roundingMode,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n min,\n max,\n step,\n largeStep,\n stepping = \"keys\",\n limitFractionDigits,\n decimalEntry,\n cleanInput = true,\n align = \"end\",\n revertOnEscape = true,\n bounds = \"[]\",\n reversed = \"swap\",\n allowEmpty = false,\n minSpan,\n maxSpan,\n showSpan = false,\n startPlaceholder,\n endPlaceholder,\n startRef,\n endRef,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n clearable = false,\n selectOnFocus = true,\n inputMode,\n enterKeyHint,\n autoComplete = \"off\",\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: NumberRangeInputProps<T>) {\n type V = NumberValue<T>;\n const field = useFieldContext();\n const formSettings = useFormSettings();\n const settings = field?.settings ?? formSettings;\n const locale = props.locale ?? settings.locale;\n const numberOptions = useNumberOptions<T>(\n {\n fractionDigits,\n minimumFractionDigits,\n maximumFractionDigits,\n integer,\n roundingMode,\n useGrouping,\n negative,\n decimalSeparator,\n groupSeparator,\n groupSizes,\n numberingSystem,\n currency,\n currencyDisplay,\n unit,\n unitDisplay,\n },\n locale,\n );\n const symbols = numberSymbols(locale, numberOptions);\n const rangeKind = numberRangeKindOf<T>(valueType);\n const negatives = takesNegatives(min);\n useLimitsWarning(\"NumberRangeInput\", min, max);\n\n // One kind per end: each keeps how its own paste was read.\n const kinds = useMemo(() => {\n const entry = {\n valueType,\n cleanInput,\n negatives,\n limitFractionDigits,\n decimalEntry,\n };\n return {\n start: numberKind<T>(numberOptions, entry),\n end: numberKind<T>(numberOptions, entry),\n };\n }, [\n numberOptions,\n valueType,\n cleanInput,\n negatives,\n limitFractionDigits,\n decimalEntry,\n ]);\n const needsValue = required === true || field?.required === true;\n const validators = useMemo(() => {\n // A span limit is a value of the field's own type.\n const spanOf = (limit: number | string) =>\n (valueType === \"decimal\" ? toDecimal(limit) : Number(limit)) as V;\n const writeSpan = (span: V) => formatNumber(span, numberOptions, \"full\");\n const list: Validator<NumberRange<T>>[] = [];\n if (needsValue) {\n list.push(requiredRule<NumberRange<T>>());\n }\n if (min !== undefined) {\n list.push(endsRule(minRule<V>(min, numberOptions)));\n }\n if (max !== undefined) {\n list.push(endsRule(maxRule<V>(max, numberOptions)));\n }\n if (minSpan !== undefined) {\n list.push(\n minSpanRule(rangeKind, spanOf(minSpan), () => undefined, writeSpan),\n );\n }\n if (maxSpan !== undefined) {\n list.push(\n maxSpanRule(rangeKind, spanOf(maxSpan), () => undefined, writeSpan),\n );\n }\n return [...list, ...validatorsOf(validate)];\n }, [\n needsValue,\n min,\n max,\n minSpan,\n maxSpan,\n numberOptions,\n rangeKind,\n valueType,\n validate,\n ]);\n\n const rangeOptions = { bounds, reversed, allowEmpty };\n const spec: CompositeInputSpec<\n NumberRange<T>,\n RangeEnds<V>,\n NumberRangeDetails<T>\n > = {\n parts: { start: partOf(kinds.start), end: partOf(kinds.end) },\n assemble: (ends, context) =>\n readRangeEnds(rangeKind, ends, rangeOptions, undefined, context),\n split: (value) => rangeEnds(rangeKind, value, bounds, undefined),\n join: (texts) => texts.start + settings.messages.rangeSeparator + texts.end,\n equals: (a, b) => sameRange(rangeKind, a, b),\n details: (current, _previous, { changed, parts, texts }) => ({\n ...rangeDetails(\n rangeKind,\n current.value,\n changed,\n texts,\n bounds,\n undefined,\n ),\n startDetails: kinds.start.details(parts.start),\n endDetails: kinds.end.details(parts.end),\n }),\n };\n const [startElement, setStartElement] = useState<HTMLInputElement | null>(\n null,\n );\n const input = useCompositeInput(\n { ...props, required, validate: validators },\n spec,\n startElement,\n );\n const {\n composite,\n state,\n strings,\n severity,\n invalid,\n readOnly,\n disabled,\n describedBy: fieldDescribedBy,\n messages,\n setRoot,\n clear,\n } = input;\n const resolvedDensity = density ?? settings.density;\n const id = input.controlId;\n const editable = !readOnly && !disabled;\n const value = state.field.value;\n const ownMessagesId = useOwnMessagesId(id);\n const mapCaret = useMemo(() => numberCaret(numberOptions), [numberOptions]);\n const root = classNames(\n \"gridkit-forms-number-range-input\",\n align === \"start\" && \"is-align-start\",\n densityClass(resolvedDensity),\n className,\n );\n\n const { name } = props;\n const hiddenInputs =\n name === undefined\n ? null\n : ([\"start\", \"end\"] as const).map((end) => {\n const endValue = value?.[end] ?? null;\n return (\n <input\n key={end}\n type=\"hidden\"\n name={`${name}.${end}`}\n form={props.form}\n disabled={disabled}\n value={endValue === null ? \"\" : toDecimal(endValue)}\n />\n );\n });\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n <DisplayValue\n text={displayText(value, numberOptions, strings)}\n emptyText={strings.emptyValue}\n />\n {hiddenInputs}\n </div>\n );\n }\n\n const sizes = stepSizes(step, largeStep, undefined);\n const endSettings: EndSettings<V> = {\n text: {\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n mapCaret,\n decimalKey: integer ? undefined : symbols.decimal,\n },\n spinbutton: stepping === \"keys\",\n editable,\n readOnly: readOnly,\n disabled: disabled,\n required: input.required,\n ltr: symbols.numbersLeftToRight,\n autoFocus,\n attributes: {\n inputMode: inputMode ?? (integer ? \"numeric\" : \"decimal\"),\n enterKeyHint,\n autoComplete,\n },\n min,\n max,\n stepTo: (end, direction, size) => {\n if (!editable) {\n return null;\n }\n const start = composite.parts.start.getState().value;\n const finish = composite.parts.end.getState().value;\n const lower = min ?? null;\n const upper = max ?? null;\n // A step stops at the other end, so it never reverses the range.\n const limits =\n end === \"start\"\n ? {\n min: lower,\n max: tighter<number | string>(upper, finish, \"upper\"),\n }\n : {\n min: tighter<number | string>(lower, start, \"lower\"),\n max: upper,\n };\n const previous = end === \"start\" ? start : finish;\n const next = stepNumberValue<T>(\n previous,\n { direction, size, ...sizes, ...limits },\n { ...numberOptions, valueType },\n );\n return next === null || (previous !== null && sameNumber(previous, next))\n ? null\n : next;\n },\n valueText: (shown) => formatNumber(shown, numberOptions, \"full\"),\n };\n\n // A message about one end marks that end; one about the range, both.\n const atFault = {\n start: endAtFault(state.parts.start, min, max),\n end: endAtFault(state.parts.end, min, max),\n };\n const invalidEnd = (end: RangeEnd) =>\n invalid && (atFault.start || atFault.end ? atFault[end] : true);\n\n const span =\n showSpan && value !== null ? rangeSpan(rangeKind, value, undefined) : null;\n const spanId = `${id}-span`;\n const nameId = `${id}-name`;\n const labelIds = joinIds(\n field !== null && `${id}-label`,\n ariaLabelledBy,\n ariaLabel !== undefined && nameId,\n );\n // The currency sign or unit beside each end: hidden from a spinbutton,\n // whose value text says it, and a description of a plain text box.\n const affixes = numberAffixes(numberOptions);\n const { spinbutton } = endSettings;\n const affixId = (end: RangeEnd, side: \"start\" | \"end\") =>\n `${id}-${end}-affix-${side}`;\n const affix = (end: RangeEnd, side: \"start\" | \"end\") => {\n const text = side === \"start\" ? affixes.prefix : affixes.suffix;\n return text === \"\" ? null : (\n <span\n className={`gridkit-forms-number-input-affix is-${side}`}\n id={spinbutton ? undefined : affixId(end, side)}\n aria-hidden={spinbutton || undefined}\n >\n {text}\n </span>\n );\n };\n const describedBy = (end: RangeEnd) =>\n joinIds(\n !spinbutton && affixes.prefix !== \"\" && affixId(end, \"start\"),\n !spinbutton && affixes.suffix !== \"\" && affixId(end, \"end\"),\n fieldDescribedBy,\n ownMessagesId,\n end === \"end\" && span !== null && spanId,\n ariaDescribedBy,\n );\n const hasText =\n composite.parts.start.getText() !== \"\" ||\n composite.parts.end.getText() !== \"\";\n\n return (\n <div\n ref={setRoot}\n className={root}\n style={style}\n role=\"group\"\n aria-labelledby={labelIds}\n >\n <ControlBox\n className=\"gridkit-forms-range-control\"\n severity={severity}\n disabled={disabled}\n readOnly={readOnly}\n loading={loading}\n density={resolvedDensity}\n prefix={undefined}\n prefixId={`${id}-prefix`}\n suffix={undefined}\n suffixId={`${id}-suffix`}\n clear={\n clearable && editable && hasText\n ? {\n label: strings.clear,\n onClear: (event) => {\n clear(event.nativeEvent);\n },\n }\n : null\n }\n >\n {affix(\"start\", \"start\")}\n <RangeEndControl<V>\n end=\"start\"\n part={composite.parts.start}\n controlRef={startRef}\n onElement={setStartElement}\n id={id}\n labelledBy={joinIds(labelIds, `${id}-start-label`)}\n describedBy={describedBy(\"start\")}\n invalid={invalidEnd(\"start\")}\n placeholder={startPlaceholder}\n settings={endSettings}\n />\n {affix(\"start\", \"end\")}\n <span className=\"gridkit-forms-range-separator\" aria-hidden=\"true\">\n {strings.rangeSeparator}\n </span>\n {affix(\"end\", \"start\")}\n <RangeEndControl<V>\n end=\"end\"\n part={composite.parts.end}\n controlRef={endRef}\n id={`${id}-end`}\n labelledBy={joinIds(labelIds, `${id}-end-label`)}\n describedBy={describedBy(\"end\")}\n invalid={invalidEnd(\"end\")}\n placeholder={endPlaceholder}\n settings={endSettings}\n />\n {affix(\"end\", \"end\")}\n {span !== null && (\n <span className=\"gridkit-forms-range-span\" id={spanId}>\n {strings.rangeSpanLabel(formatNumber(span, numberOptions, \"full\"))}\n </span>\n )}\n </ControlBox>\n {ariaLabel !== undefined && (\n <span className=\"gridkit-forms-sr-only\" id={nameId}>\n {ariaLabel}\n </span>\n )}\n <span className=\"gridkit-forms-sr-only\" id={`${id}-start-label`}>\n {strings.rangeStart}\n </span>\n <span className=\"gridkit-forms-sr-only\" id={`${id}-end-label`}>\n {strings.rangeEnd}\n </span>\n {hiddenInputs}\n <OwnMessages\n id={`${id}-messages`}\n messages={messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * Two number fields under one label, holding one range: `{ start, end }`,\n * either end `null` when open, and `null` when both are. The value is\n * always ordered: an end typed before its start is swapped (the texts\n * change places on commit) or, with `reversed=\"error\"`, refused with a\n * message. Each end types, pastes and steps as a `NumberInput` (a step\n * stops at the other end); Tab moves between the ends, and the range\n * commits once when focus leaves both, or on Enter. `min` and `max` bound\n * both ends; `minSpan` and `maxSpan` the span, which `showSpan` writes\n * after the end. The end belongs to the range by default (`bounds=\"[]\"`).\n * Every event carries `NumberRangeDetails`: which end changed, the span,\n * and each end's number details.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function NumberRangeInput<T extends NumberValueType = \"number\">(\n props: NumberRangeInputProps<T>,\n) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <NumberRangeControl<T> {...props} />\n </InputFrame>\n );\n}\n","import {\n createCompositeController,\n hasError,\n type CompositeController,\n type CompositeFieldOptions,\n type CompositeState,\n type FieldMessage,\n type FormsMessages,\n type NoDetails,\n type PartController,\n type Severity,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachFocusGroup,\n attachTextInput,\n type AttachedTextInput,\n type TextInputOptions,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type Ref,\n type RefCallback,\n} from \"react\";\nimport { useControlElement } from \"./text/parts\";\nimport type { FieldMode } from \"./settings\";\nimport {\n isFocused,\n useControllerLifecycle,\n useFieldReport,\n useInputSettings,\n useShownMessages,\n validatorsOf,\n type FieldInputProps,\n} from \"./useFieldInput\";\n\n/** The props `useCompositeInput` reads; an input made of parts passes on its own. */\nexport type CompositeInputProps<V, D extends object = NoDetails> = Omit<\n FieldInputProps<V, HTMLInputElement, D>,\n \"parse\" | \"format\" | \"ref\"\n>;\n\n/** How an input made of parts reads its parts and makes its value: the composite's own options. */\nexport type CompositeInputSpec<\n V,\n P extends Record<string, unknown>,\n D extends object = NoDetails,\n> = Pick<\n CompositeFieldOptions<V, P, D, Event>,\n \"parts\" | \"assemble\" | \"split\" | \"join\" | \"equals\" | \"details\"\n>;\n\n/** What `useCompositeInput` gives the input that calls it, to draw. */\nexport interface CompositeInput<\n V,\n P extends Record<string, unknown>,\n D extends object = NoDetails,\n> {\n readonly composite: CompositeController<V, P, D, Event>;\n readonly state: CompositeState<V, P>;\n /** The field's text: the parts' texts, joined. */\n readonly text: string;\n /** As `useFieldInput`'s: the messages to show, and the most serious one's severity. */\n readonly messages: readonly FieldMessage[];\n readonly severity: Severity | null;\n /** Whether a shown error, `invalid` or the `Field` marks the input invalid. */\n readonly invalid: boolean;\n readonly mode: FieldMode;\n readonly readOnly: boolean;\n readonly disabled: boolean;\n /** The input's own `required`, or the `Field`'s. */\n readonly required: boolean;\n /** The first control's `id`: the `Field`'s inside one, so its label points there. */\n readonly controlId: string;\n /** The `Field`'s description and messages, for each control's `aria-describedby`. */\n readonly describedBy: string | undefined;\n readonly strings: FormsMessages;\n readonly locale: Intl.LocalesArgument;\n /** Fires `onClear`, then empties the field and commits it. */\n readonly clear: (nativeEvent: Event | null) => void;\n /** The element around every part: focus leaving it commits the field. */\n readonly setRoot: RefCallback<HTMLElement>;\n}\n\nconst NO_MESSAGES: readonly FieldMessage[] = [];\n\n/**\n * Binds an input made of parts to one field, as `useFieldInput` binds one\n * control: forms-core's composite controller, made once and handed the\n * latest props and `spec` on every render; a controlled `value`; the\n * `Field` and form around it; and forms-dom's focus group on `setRoot`, so\n * focus leaving every part commits the field. Each part's control is\n * attached with `usePartControl`. `focusTarget` is the control\n * `handleRef`'s `focus` moves to.\n */\nexport function useCompositeInput<\n V,\n P extends Record<string, unknown>,\n D extends object = NoDetails,\n>(\n props: CompositeInputProps<V, D>,\n spec: CompositeInputSpec<V, P, D>,\n focusTarget: HTMLInputElement | null,\n): CompositeInput<V, P, D> {\n const { field, form, ownId, readOnly, disabled, mode, locale, messages } =\n useInputSettings(props);\n const options: CompositeFieldOptions<V, P, D, Event> = {\n ...spec,\n value: props.value,\n defaultValue: props.defaultValue,\n validators: validatorsOf(props.validate),\n locale,\n messages,\n onFocus: props.onFocus,\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n onBeforeChange: props.onBeforeChange,\n onChange: props.onChange,\n onValidate: props.onValidate,\n onBeforeCommit: props.onBeforeCommit,\n onCommit: props.onCommit,\n onBlur: props.onBlur,\n };\n const [composite] = useState(() => createCompositeController(options));\n composite.setOptions(options);\n const state = useSyncExternalStore(\n composite.subscribe,\n composite.getState,\n composite.getState,\n );\n const controller = composite.field;\n useControllerLifecycle(controller, props.value, form);\n\n const [root, setRoot] = useState<HTMLElement | null>(null);\n useLayoutEffect(() => {\n if (root === null) {\n return undefined;\n }\n const group = attachFocusGroup(root, {\n onLeave: (by, nativeEvent) => {\n composite.leave(by, nativeEvent);\n },\n });\n return () => {\n group.detach();\n };\n }, [root, composite]);\n\n useImperativeHandle(\n props.handleRef,\n () => ({\n element: focusTarget,\n focus: (focusOptions) => {\n focusTarget?.focus(focusOptions);\n },\n blur: () => {\n const active = focusTarget?.ownerDocument.activeElement;\n if (active instanceof HTMLElement && root?.contains(active) === true) {\n active.blur();\n }\n },\n getValue: () => controller.getState().value,\n getText: controller.getText,\n setValue: controller.setValue,\n reset: controller.reset,\n revealMessages: controller.reveal,\n }),\n [focusTarget, root, controller],\n );\n\n const text = controller.getText();\n // A disabled field is not validated, so it shows none of its own messages.\n const own =\n state.field.revealed && !disabled ? controller.getMessages() : NO_MESSAGES;\n const { shown, severity } = useShownMessages(\n own,\n props.message,\n props.invalid,\n field,\n );\n const required = props.required === true;\n const partTexts = Object.keys(spec.parts).map((name) =>\n composite.parts[name as keyof P].getText(),\n );\n useFieldReport(field, ownId, shown, {\n focused: isFocused(state.field.phase),\n empty: partTexts.every((partText) => partText === \"\"),\n required,\n // A resting label would cover the parts and the separator between them.\n startAdornment: true,\n });\n const { onClear } = props;\n\n return {\n composite,\n state,\n text,\n messages: shown,\n severity,\n invalid:\n hasError(shown) || props.invalid === true || field?.invalid === true,\n mode,\n readOnly,\n disabled,\n required: required || field?.required === true,\n controlId: field?.controlId ?? props.id ?? ownId,\n describedBy: field?.describedBy,\n strings: messages,\n locale,\n clear: (nativeEvent) => {\n onClear?.({\n previousValue: controller.getState().value,\n previousText: controller.getText(),\n nativeEvent,\n });\n controller.clear(nativeEvent);\n },\n setRoot: setRoot,\n };\n}\n\n/**\n * Attaches forms-dom's text pipeline to one part's control, handing it\n * every render's options, and points `ref` at the control too. Returns the\n * control, once it is in the page, and the ref to give it.\n */\nexport function usePartControl<T>(\n part: PartController<T, Event>,\n ref: Ref<HTMLInputElement> | undefined,\n options: TextInputOptions,\n): readonly [HTMLInputElement | null, RefCallback<HTMLInputElement>] {\n const [element, controlRef] = useControlElement(ref);\n const pipeline = useRef<AttachedTextInput | null>(null);\n useLayoutEffect(() => {\n if (element === null) {\n return undefined;\n }\n const attached = attachTextInput(element, part);\n pipeline.current = attached;\n return () => {\n attached.detach();\n pipeline.current = null;\n };\n }, [element, part]);\n // Every render's options, the attaching render's included: this effect\n // runs straight after the one above, before any event can arrive.\n useLayoutEffect(() => {\n pipeline.current?.setOptions(options);\n });\n return [element, controlRef];\n}\n","import type { NumberValueType, PercentScale } from \"@gridkitjs/forms-core\";\nimport { InputFrame } from \"../text/parts\";\nimport { NumberControl, type NumberInputProps } from \"./NumberInput\";\n\nexport interface PercentInputProps<\n T extends NumberValueType = \"number\",\n> extends Omit<\n NumberInputProps<T>,\n \"currency\" | \"currencyDisplay\" | \"unit\" | \"unitDisplay\"\n> {\n /**\n * `\"fraction\"` (default): 0.12 is shown as 12 %, as Intl reads a\n * percent. `\"percent\"`: 12 is. `value`, `min`, `max` and `step` are in\n * these units; the default step is one percentage point.\n */\n readonly scale?: PercentScale | undefined;\n}\n\n/**\n * A `NumberInput` for a percentage: the percent sign drawn where the\n * locale puts it (before the number in `tr-TR`), and the value stored as\n * a fraction (0.125 for 12.5 %) or as the percent number itself, by\n * `scale`. Fraction digit props count the digits of the number shown, and\n * a fraction is scaled exactly, so 12.3 % is 0.123.\n */\nexport function PercentInput<T extends NumberValueType = \"number\">({\n scale = \"fraction\",\n ...props\n}: PercentInputProps<T>) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <NumberControl<T>\n {...props}\n percentScale={scale}\n rootClassName=\"gridkit-forms-number-input gridkit-forms-percent-input\"\n />\n </InputFrame>\n );\n}\n","import {\n comparePeriods,\n formatPeriod,\n isPeriod,\n maxPeriodRule,\n minPeriodRule,\n periodDetails,\n periodFormatter,\n periodLayout,\n periodOf,\n periodParser,\n periodParts,\n pivotYear,\n requiredRule,\n type FiscalYear,\n type Period,\n type PeriodDetails,\n type PeriodFieldOptions,\n type PeriodGranularity,\n type PopupOpenChange,\n} from \"@gridkitjs/forms-core\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { todayFor } from \"../date/DateInput\";\nimport { SegmentedControl } from \"../date/SegmentedControl\";\nimport type { SegmentedInputProps } from \"../date/segmentedProps\";\nimport {\n createSegmentsAccess,\n typingSegment,\n type SegmentedKind,\n} from \"../date/useSegmentedInput\";\nimport { warnOnce } from \"../dev\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { CalendarIcon, InputFrame } from \"../text/parts\";\nimport { useInputSettings, validatorsOf } from \"../useFieldInput\";\nimport { focusedPeriod, PeriodPicker } from \"./PeriodPicker\";\n\nexport interface PeriodInputProps<\n G extends PeriodGranularity = \"month\",\n> extends Omit<SegmentedInputProps<Period<G>, PeriodDetails>, \"displayFormat\"> {\n /** How long a period is: `\"month\"` by default. */\n readonly granularity?: G | undefined;\n /** The first period allowed, inclusive. */\n readonly min?: Period<G> | undefined;\n /** The last period allowed, inclusive. */\n readonly max?: Period<G> | undefined;\n /** The month a fiscal year starts in, 1 to 12; 1 by default. */\n readonly fiscalYearStart?: number | undefined;\n /** Whether \"FY2026\" names the year a fiscal year ends in (default) or starts in. */\n readonly fiscalYearNamedBy?: \"start\" | \"end\" | undefined;\n /** Typing `t`, `+1`, `-1`; on by default. */\n readonly shortcuts?: boolean | undefined;\n /** The zone \"today\" is in, for shortcuts, steps and the two-digit year: the runtime's by default. */\n readonly timeZone?: string | undefined;\n /** The calendar button and its popup, a grid of periods; on by default. */\n readonly picker?: boolean | undefined;\n /** The picker popup opened or closed, with why. */\n readonly onOpenChange?: ((change: PopupOpenChange) => void) | undefined;\n}\n\n/** The fiscal year the props name, January when `start` is no month. */\nfunction useFiscalYear(\n start: number | undefined,\n namedBy: \"start\" | \"end\",\n): FiscalYear {\n const month =\n start !== undefined && Number.isInteger(start) && start >= 1 && start <= 12\n ? start\n : 1;\n const stray = start !== undefined && month !== start;\n useEffect(() => {\n if (stray) {\n warnOnce(\n \"PeriodInput-fiscalYearStart\",\n \"PeriodInput: fiscalYearStart is a month from 1 to 12, so the fiscal year starts in January.\",\n );\n }\n }, [stray]);\n return useMemo(() => ({ start: month, namedBy }), [month, namedBy]);\n}\n\nfunction PeriodInputControl<G extends PeriodGranularity>({\n granularity: granularityProp,\n min,\n max,\n fiscalYearStart,\n fiscalYearNamedBy = \"end\",\n shortcuts = true,\n timeZone,\n picker = true,\n onOpenChange,\n required,\n validate,\n ...props\n}: PeriodInputProps<G>) {\n // Without `granularity`, `G` is its default, \"month\".\n const granularity = granularityProp ?? (\"month\" as G);\n const field = useFieldContext();\n const { locale, messages } = useInputSettings(props);\n const [segments] = useState(createSegmentsAccess);\n const fiscalYear = useFiscalYear(fiscalYearStart, fiscalYearNamedBy);\n const { numberingSystem } = props;\n const needsValue = required === true || field?.required === true;\n\n const today = todayFor(timeZone);\n const options: PeriodFieldOptions<G> = {\n granularity,\n fiscalYear,\n numberingSystem,\n today,\n shortcuts,\n activeSegment: () => typingSegment(segments),\n };\n const kind: SegmentedKind<Period<G>, PeriodDetails> = {\n name: \"PeriodInput\",\n layout: periodLayout({ locale, granularity, numberingSystem }, messages),\n defaultParse: periodParser(options),\n defaultFormat: periodFormatter({ granularity, numberingSystem }),\n details: (current, _previous, cause) =>\n periodDetails(current, cause, { ...options, locale, messages }),\n display: (value) => formatPeriod(value, locale, messages),\n serialize: (value) => value,\n isValue: (value): value is Period<G> => isPeriod(value, granularity),\n inLimits: (value) =>\n (min === undefined || comparePeriods(value, min) >= 0) &&\n (max === undefined || comparePeriods(value, max) <= 0),\n shortcuts,\n today,\n reference: (type) => {\n const current = periodParts(periodOf(today(), granularity, fiscalYear));\n return type === \"year\" ? current.year : current.index;\n },\n pivot: (digits) => pivotYear(digits, { today: today() }),\n };\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<Period<G>>()] : []),\n ...(min === undefined ? [] : [minPeriodRule<G>(min)]),\n ...(max === undefined ? [] : [maxPeriodRule<G>(max)]),\n ...validatorsOf(validate),\n ],\n [needsValue, min, max, validate],\n );\n\n return (\n <SegmentedControl\n props={{ ...props, required, validate: validators }}\n kind={kind}\n rootClassName=\"gridkit-forms-period-input\"\n segments={segments}\n picker={\n picker\n ? {\n label: messages.choosePeriod,\n icon: <CalendarIcon />,\n buttonClassName: \"gridkit-forms-period-button\",\n popupClassName: \"gridkit-forms-period-popup\",\n onOpenChange,\n initialFocus: focusedPeriod,\n content: ({ value, id, pick, close }) => (\n <PeriodPicker<G>\n id={id}\n granularity={granularity}\n fiscalYear={fiscalYear}\n selected={value}\n min={min}\n max={max}\n today={today}\n locale={locale}\n strings={messages}\n onChoose={(period, nativeEvent) => {\n pick(period, nativeEvent);\n close(\"picker\");\n }}\n />\n ),\n }\n : undefined\n }\n />\n );\n}\n\n/**\n * An accounting or reporting period typed in segments: a month as the\n * locale writes one (`11/2026` in en-US, `2026/11` in ja-JP), a quarter\n * (`Q3 2026`), a year, or a fiscal year, quarter or month (`FY2026`,\n * `FY2026 Q1`, `FY2026 P04`) counted from `fiscalYearStart` and named by\n * the year it ends in unless `fiscalYearNamedBy=\"start\"`. Typing moves on\n * by itself, the arrow keys move between segments and step them, and the\n * field is one Tab stop. A letter or a sign opens a box for shortcuts (`t`\n * this period, `+1` the next, `-1` the previous), and a pasted period in\n * any common form (`2026-Q3`, `Nov 2026`, `FY26 P4`) is read whole. The\n * calendar button, F4 or Alt+ArrowDown opens a grid of the year's periods\n * (twelve years for a year granularity) to choose one from. Its\n * value is a `Period` string of the granularity (`\"2026-11\"`,\n * `\"FY2026-P04\"`), `null` when empty, and every event's\n * `PeriodDetails.range` holds the days it covers, half-open. `min` and\n * `max` add their messages. It takes every shared input prop: display\n * mode, `readOnly`, `disabled`, messages with their severity, density,\n * prefix and suffix, and the events of `@gridkitjs/forms`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function PeriodInput<G extends PeriodGranularity = \"month\">(\n props: PeriodInputProps<G>,\n) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <PeriodInputControl<G> {...props} />\n </InputFrame>\n );\n}\n","import {\n comparePeriods,\n formatMonthName,\n formatPeriodPage,\n formatPeriodPlace,\n periodOf,\n periodPage,\n periodPageYears,\n periodParts,\n type FiscalYear,\n type FormsMessages,\n type Period,\n type PeriodGranularity,\n type PlainDate,\n} from \"@gridkitjs/forms-core\";\nimport { useRef, useState, type KeyboardEvent } from \"react\";\nimport { ChevronIcon } from \"../calendar/MonthPanel\";\nimport { nextIndex } from \"../calendar/MonthsView\";\nimport { classNames } from \"../field/parts\";\n\n/** What a period input's picker reads. */\nexport interface PeriodPickerProps<G extends PeriodGranularity> {\n /** The popup's `id`, the prefix of the picker's own ids. */\n readonly id: string;\n readonly granularity: G;\n readonly fiscalYear: FiscalYear;\n /** The period shown chosen, and where focus starts; today's when `null`. */\n readonly selected: Period<G> | null;\n readonly min: Period<G> | undefined;\n readonly max: Period<G> | undefined;\n readonly today: () => PlainDate;\n readonly locale: Intl.LocalesArgument;\n readonly strings: FormsMessages;\n /** A period chosen by click, tap, Enter or Space; never one outside the limits. */\n readonly onChoose: (period: Period<G>, nativeEvent: Event) => void;\n}\n\n/** The button that takes focus as a period picker opens: the chosen period, else today's. */\nexport function focusedPeriod(panel: HTMLElement): HTMLElement | null {\n return panel.querySelector<HTMLElement>(\n '.gridkit-forms-period-picker-grid [tabindex=\"0\"]',\n );\n}\n\n/**\n * A period input's picker: a page of periods as a grid of buttons (a\n * year's months, quarters or fiscal periods, three or two to a row, or\n * twelve years) under a header whose buttons move to the year, or the\n * twelve years, before and after. The grid is one Tab stop: the arrows,\n * Home and End move through it, PageUp and PageDown move to the page\n * before and after, and Enter, Space or a click chooses. Periods outside\n * `min` and `max` show disabled; today's is marked.\n */\nexport function PeriodPicker<G extends PeriodGranularity>({\n id,\n granularity,\n fiscalYear,\n selected,\n min,\n max,\n today,\n locale,\n strings,\n onChoose,\n}: PeriodPickerProps<G>) {\n const gridRef = useRef<HTMLDivElement>(null);\n const [current] = useState(() => periodOf(today(), granularity, fiscalYear));\n const start = selected ?? current;\n const [year, setYear] = useState(() => periodParts(start).year);\n const [focusIndex, setFocusIndex] = useState(() =>\n Math.max(periodPage(granularity, year).indexOf(start), 0),\n );\n const page = periodPage(granularity, year);\n const step = periodPageYears(granularity);\n const yearly = step > 1;\n const columns = page.length === 4 ? 2 : 3;\n const shownIndex = Math.min(focusIndex, page.length - 1);\n const titleId = `${id}-title`;\n const title = formatPeriodPage(granularity, year, locale, strings);\n\n const outside = (period: Period<G>) =>\n (min !== undefined && comparePeriods(period, min) < 0) ||\n (max !== undefined && comparePeriods(period, max) > 0);\n /** Whether the page holding `target` has a period within the limits. */\n const canShow = (target: number) => {\n if (target < 1 || target > 9999) {\n return false;\n }\n return periodPage(granularity, target).some((period) => !outside(period));\n };\n\n function turn(by: number): boolean {\n const target = year + by * step;\n if (!canShow(target)) {\n return false;\n }\n setYear(target);\n return true;\n }\n\n function focusButton(index: number) {\n gridRef.current?.querySelectorAll<HTMLElement>(\"button\")[index]?.focus();\n }\n\n function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n if (event.key === \"PageUp\" || event.key === \"PageDown\") {\n event.preventDefault();\n turn(event.key === \"PageUp\" ? -1 : 1);\n return;\n }\n const next = nextIndex(event, shownIndex, page.length, {\n row: columns,\n column: 1,\n });\n if (next !== null) {\n event.preventDefault();\n setFocusIndex(next);\n focusButton(next);\n }\n }\n\n // A fiscal month shows the calendar month it is beside its number.\n const hint = (period: Period<G>) =>\n granularity === \"fiscalMonth\"\n ? formatMonthName(\n ((fiscalYear.start + periodParts(period).index - 2) % 12) + 1,\n locale,\n \"short\",\n )\n : null;\n\n return (\n <div\n className=\"gridkit-forms-period-picker\"\n role=\"group\"\n aria-labelledby={titleId}\n >\n <div className=\"gridkit-forms-period-picker-header\">\n <button\n type=\"button\"\n className=\"gridkit-forms-period-picker-nav is-previous\"\n aria-label={yearly ? strings.previousYears : strings.previousYear}\n disabled={!canShow(year - step)}\n onClick={() => {\n turn(-1);\n }}\n >\n <ChevronIcon side=\"start\" />\n </button>\n <span\n className=\"gridkit-forms-period-picker-title\"\n id={titleId}\n aria-live=\"polite\"\n >\n {title}\n </span>\n <button\n type=\"button\"\n className=\"gridkit-forms-period-picker-nav is-next\"\n aria-label={yearly ? strings.nextYears : strings.nextYear}\n disabled={!canShow(year + step)}\n onClick={() => {\n turn(1);\n }}\n >\n <ChevronIcon side=\"end\" />\n </button>\n </div>\n <div\n ref={gridRef}\n className={classNames(\n \"gridkit-forms-period-picker-grid\",\n columns === 2 && \"is-two-columns\",\n )}\n role=\"group\"\n aria-labelledby={titleId}\n onKeyDown={onKeyDown}\n >\n {page.map((period, index) => {\n const disabled = outside(period);\n const isSelected = period === selected;\n const shownHint = hint(period);\n return (\n // Keyed by place, so the focused button stays as the page turns.\n <button\n key={index}\n type=\"button\"\n className={classNames(\n \"gridkit-forms-period-picker-option\",\n isSelected && \"is-selected\",\n period === current && \"is-today\",\n disabled && \"is-disabled\",\n )}\n data-gridkit-forms-period={period}\n tabIndex={index === shownIndex ? 0 : -1}\n aria-pressed={isSelected}\n aria-disabled={disabled || undefined}\n onClick={(event) => {\n setFocusIndex(index);\n if (!disabled) {\n onChoose(period, event.nativeEvent);\n }\n }}\n >\n {formatPeriodPlace(period, locale, strings)}\n {!yearly && (\n <span className=\"gridkit-forms-sr-only\"> {title}</span>\n )}\n {shownHint !== null && (\n <span\n className=\"gridkit-forms-period-picker-hint\"\n aria-hidden=\"true\"\n >\n {shownHint}\n </span>\n )}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n","import { formatText, requiredRule, textParser } from \"@gridkitjs/forms-core\";\nimport { useMemo, type Ref } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n useFieldInput,\n validatorsOf,\n type FieldInputKind,\n} from \"../useFieldInput\";\nimport {\n ControlBox,\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n OwnMessages,\n SearchIcon,\n useOwnMessagesId,\n} from \"./parts\";\nimport type { TextInputBaseProps } from \"./textInputProps\";\n\nexport interface SearchInputProps extends TextInputBaseProps<string> {\n /**\n * Milliseconds typing must pause before the text is read\n * (`onBeforeChange`, `onChange`, `onValidate`); `onInput` fires at once,\n * and Enter reads at once. None by default.\n */\n readonly debounce?: number | undefined;\n readonly ref?: Ref<HTMLInputElement> | undefined;\n}\n\nconst SEARCH_TEXT: FieldInputKind<string> = {\n defaultParse: textParser(),\n defaultFormat: formatText,\n serialize: (value) => value,\n};\n\nfunction SearchInputControl({\n debounce = 0,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = true,\n selectOnFocus = false,\n inputMode,\n enterKeyHint = \"search\",\n autoComplete,\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: SearchInputProps) {\n const field = useFieldContext();\n const settings = useFormSettings();\n const needsValue = required === true || field?.required === true;\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<string>()] : []),\n ...validatorsOf(validate),\n ],\n [needsValue, validate],\n );\n\n const input = useFieldInput(\n { ...props, required, validate: validators, ref },\n SEARCH_TEXT,\n {\n startAdornment: true,\n changeDelay: debounce,\n selectOnFocus,\n escape: \"clear\",\n },\n );\n const { controlProps } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const ownMessagesId = useOwnMessagesId(controlId);\n const root = classNames(\n \"gridkit-forms-search-input\",\n densityClass(resolvedDensity),\n className,\n );\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n {input.displayValue}\n {input.hiddenInput}\n </div>\n );\n }\n\n const editable = !controlProps.readOnly && !controlProps.disabled;\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n start={\n <span className=\"gridkit-forms-search-input-icon\" aria-hidden=\"true\">\n <SearchIcon />\n </span>\n }\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n >\n <input\n {...extraControlProps}\n {...controlProps}\n type=\"search\"\n className=\"gridkit-forms-search-input-control\"\n placeholder={placeholder ?? strings.searchPlaceholder}\n autoFocus={autoFocus}\n inputMode={inputMode}\n enterKeyHint={enterKeyHint}\n autoComplete={autoComplete}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n aria-busy={loading || undefined}\n />\n </ControlBox>\n {input.hiddenInput}\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n </div>\n );\n}\n\n/**\n * A search box: `<input type=\"search\">` (role `searchbox`) with a search\n * icon and a clear button, on the same machinery as `TextInput`. Its value\n * is a string, `null` when empty. Enter commits at once, reading the text\n * first even while a `debounce` is pending; Escape empties it, after\n * `onClear`, and passes on when it is already empty.\n *\n * Search on `onChange` with a `debounce` as the user types, or on\n * `onCommit` for \"search on Enter\".\n */\nexport function SearchInput(props: SearchInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <SearchInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n countCharacters,\n counterAnnouncement,\n formatText,\n maxLengthRule,\n minLengthRule,\n patternRule,\n requiredRule,\n textParser,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport {\n attachAutoGrow,\n scheduleTimeout,\n type AttachedAutoGrow,\n type TextControl,\n} from \"@gridkitjs/forms-dom\";\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type Ref,\n} from \"react\";\nimport { DisplayValue } from \"../DisplayValue\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n useFieldInput,\n validatorsOf,\n type FieldInputKind,\n} from \"../useFieldInput\";\nimport {\n ControlBox,\n densityClass,\n EyeIcon,\n hasNode,\n InputFrame,\n joinIds,\n keepFocus,\n OwnMessages,\n useControlElement,\n useOwnMessagesId,\n} from \"./parts\";\nimport type { TextInputBaseProps } from \"./textInputProps\";\n\nexport interface TextInputProps extends TextInputBaseProps<\n string,\n TextControl\n> {\n /**\n * `\"password\"` hides the text and adds a reveal button. Email, phone and\n * URL keyboards come from `inputMode` and `autoComplete`: a native\n * `type=\"email\"` would add the browser's own validation.\n */\n readonly type?: \"text\" | \"password\" | undefined;\n /** A `<textarea>` that grows with its text. */\n readonly multiline?: boolean | undefined;\n /** Multiline: the lines shown when empty. */\n readonly minRows?: number | undefined;\n /** Multiline: the lines it grows to, before it scrolls. */\n readonly maxRows?: number | undefined;\n /**\n * The most characters (code points) the value may have. Typing past it\n * is allowed: the counter marks the overflow and the field shows an\n * error.\n */\n readonly maxLength?: number | undefined;\n readonly minLength?: number | undefined;\n /** The whole value must match. */\n readonly pattern?: RegExp | undefined;\n /** The \"12/50\" counter under the box; on whenever `maxLength` is set. */\n readonly showCounter?: boolean | undefined;\n /**\n * Upper-cases the value as it is read, in the field's locale. The text is\n * shown upper-cased by CSS, so the caret never moves and input methods\n * are left alone; a commit writes the upper-cased text.\n */\n readonly uppercase?: boolean | undefined;\n /** Drops leading and trailing whitespace from the value; never for a password. */\n readonly trim?: boolean | undefined;\n /** The reveal button of a password; on by default. */\n readonly revealable?: boolean | undefined;\n /** Escape puts back the last committed text; on by default. */\n readonly revertOnEscape?: boolean | undefined;\n readonly ref?: Ref<TextControl> | undefined;\n}\n\n/** How long typing must pause before the counter is announced. */\nconst ANNOUNCE_DELAY = 1000;\n\n/** What a password shows in display mode, whatever its length. */\nconst HIDDEN_PASSWORD = \"••••••••\";\n\nconst DEFAULT_MIN_ROWS = 2;\nconst DEFAULT_MAX_ROWS = 8;\n\n/**\n * The \"12/50\" under the box, hidden from screen readers, which read the\n * limit with the control instead (\"Up to 50 characters\") and hear what is\n * left once typing pauses near it, never on every keystroke.\n */\nfunction CharacterCounter({\n labelId,\n count,\n max,\n typing,\n strings,\n}: {\n readonly labelId: string;\n readonly count: number;\n readonly max: number;\n /** The user is editing: only their typing is announced. */\n readonly typing: boolean;\n readonly strings: FormsMessages;\n}) {\n // Stamped with the count it was made for, so the next keystroke empties\n // it and the same words are announced again after the next pause.\n const [announced, setAnnounced] = useState({ count: -1, text: \"\" });\n const lastCount = useRef(count);\n useEffect(() => {\n if (count === lastCount.current) {\n return undefined;\n }\n lastCount.current = count;\n const text = typing ? counterAnnouncement(count, max, strings) : null;\n if (text === null) {\n return undefined;\n }\n return scheduleTimeout(() => {\n setAnnounced({ count, text });\n }, ANNOUNCE_DELAY);\n }, [count, max, typing, strings]);\n\n return (\n <>\n <div\n className={classNames(\n \"gridkit-forms-text-input-counter\",\n count > max && \"is-over-limit\",\n )}\n aria-hidden=\"true\"\n >\n {strings.counter(count, max)}\n </div>\n <span className=\"gridkit-forms-sr-only\" id={labelId}>\n {strings.counterLabel(max)}\n </span>\n <span className=\"gridkit-forms-sr-only\" aria-live=\"polite\">\n {announced.count === count ? announced.text : \"\"}\n </span>\n </>\n );\n}\n\nfunction TextInputControl({\n type = \"text\",\n multiline = false,\n minRows = DEFAULT_MIN_ROWS,\n maxRows = DEFAULT_MAX_ROWS,\n maxLength,\n minLength,\n pattern,\n showCounter = maxLength !== undefined,\n uppercase = false,\n trim = false,\n revealable = true,\n revertOnEscape = true,\n required,\n validate,\n loading = false,\n density,\n autoFocus,\n placeholder,\n prefix,\n suffix,\n clearable = false,\n selectOnFocus = false,\n inputMode,\n enterKeyHint,\n autoComplete,\n controlProps: extraControlProps,\n className,\n style,\n ref,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: TextInputProps) {\n const field = useFieldContext();\n const settings = useFormSettings();\n const password = type === \"password\";\n const needsValue = required === true || field?.required === true;\n\n const kind = useMemo<FieldInputKind<string>>(\n () => ({\n defaultParse: textParser({ uppercase, trim: trim && !password }),\n defaultFormat: formatText,\n serialize: (value) => value,\n }),\n [uppercase, trim, password],\n );\n const validators = useMemo(\n () => [\n ...(needsValue ? [requiredRule<string>()] : []),\n ...(minLength === undefined ? [] : [minLengthRule(minLength)]),\n ...(maxLength === undefined ? [] : [maxLengthRule(maxLength)]),\n ...(pattern === undefined ? [] : [patternRule(pattern)]),\n ...validatorsOf(validate),\n ],\n [needsValue, minLength, maxLength, pattern, validate],\n );\n\n const [element, controlRef] = useControlElement(ref);\n const input = useFieldInput(\n { ...props, required, validate: validators, ref: controlRef },\n kind,\n {\n startAdornment: hasNode(prefix),\n selectOnFocus,\n escape: revertOnEscape ? \"revert\" : \"none\",\n },\n );\n const { controlProps } = input;\n const strings = settings.messages;\n const resolvedDensity = density ?? settings.density;\n const controlId = controlProps.id;\n const prefixId = `${controlId}-prefix`;\n const suffixId = `${controlId}-suffix`;\n const counterLabelId = `${controlId}-counter-label`;\n const ownMessagesId = useOwnMessagesId(controlId);\n\n const [revealed, setRevealed] = useState(false);\n const selection = useRef<readonly [number, number] | null>(null);\n useLayoutEffect(() => {\n const kept = selection.current;\n selection.current = null;\n if (kept !== null && element instanceof HTMLInputElement) {\n // Chromium rebuilds a text control at the first layout after its\n // `type` changes, dropping the selection, so lay out first.\n element.getBoundingClientRect();\n element.setSelectionRange(kept[0], kept[1]);\n }\n }, [revealed, element]);\n\n const autoGrow = useRef<AttachedAutoGrow | null>(null);\n useLayoutEffect(() => {\n if (!(element instanceof HTMLTextAreaElement)) {\n return undefined;\n }\n const attached = attachAutoGrow(element, { minRows, maxRows });\n autoGrow.current = attached;\n return () => {\n attached.detach();\n autoGrow.current = null;\n };\n }, [element, minRows, maxRows]);\n // Text written from code (a clear, a revert, a value from the app) fires\n // no `input` for it to follow.\n useLayoutEffect(() => {\n autoGrow.current?.update();\n }, [input.text]);\n\n const display = input.mode === \"display\";\n const root = classNames(\n \"gridkit-forms-text-input\",\n multiline && \"is-multiline\",\n uppercase && \"is-uppercase\",\n densityClass(resolvedDensity),\n className,\n );\n const ownMessages = (\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={strings}\n named={ariaLabel !== undefined || ariaLabelledBy !== undefined}\n />\n );\n\n if (display) {\n return (\n <div className={root} style={style}>\n {password ? (\n <DisplayValue\n text={input.text === \"\" ? \"\" : HIDDEN_PASSWORD}\n emptyText={strings.emptyValue}\n />\n ) : (\n input.displayValue\n )}\n {input.hiddenInput}\n </div>\n );\n }\n\n const count = countCharacters(input.text);\n const counter =\n showCounter && maxLength !== undefined ? (\n <CharacterCounter\n labelId={counterLabelId}\n count={count}\n max={maxLength}\n typing={input.state.phase.kind !== \"idle\"}\n strings={strings}\n />\n ) : null;\n const editable = !controlProps.readOnly && !controlProps.disabled;\n const sharedProps = {\n ...extraControlProps,\n ...controlProps,\n className: \"gridkit-forms-text-input-control\",\n placeholder,\n autoFocus,\n inputMode,\n enterKeyHint,\n autoComplete,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": joinIds(\n hasNode(prefix) && prefixId,\n hasNode(suffix) && suffixId,\n counter !== null && counterLabelId,\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n ),\n \"aria-busy\": loading || undefined,\n };\n\n return (\n <div className={root} style={style}>\n <ControlBox\n severity={input.severity}\n disabled={controlProps.disabled === true}\n readOnly={controlProps.readOnly === true}\n loading={loading}\n density={resolvedDensity}\n prefix={prefix}\n prefixId={prefixId}\n suffix={suffix}\n suffixId={suffixId}\n clear={\n clearable && editable && input.text !== \"\"\n ? {\n label: strings.clear,\n onClear: (event) => {\n input.clear(event.nativeEvent);\n },\n }\n : null\n }\n end={\n password && revealable ? (\n <button\n type=\"button\"\n className={classNames(\n \"gridkit-forms-text-input-reveal\",\n revealed && \"is-revealed\",\n )}\n aria-pressed={revealed}\n aria-controls={controlId}\n aria-label={strings.showPassword}\n disabled={controlProps.disabled}\n onMouseDown={keepFocus}\n onClick={() => {\n if (\n element instanceof HTMLInputElement &&\n element.ownerDocument.activeElement === element\n ) {\n selection.current = [\n element.selectionStart ?? 0,\n element.selectionEnd ?? 0,\n ];\n }\n setRevealed((current) => !current);\n }}\n >\n <EyeIcon />\n </button>\n ) : null\n }\n >\n {multiline ? (\n <textarea {...sharedProps} rows={minRows} />\n ) : (\n <input\n {...sharedProps}\n type={password && !revealed ? \"password\" : \"text\"}\n />\n )}\n </ControlBox>\n {counter}\n {input.hiddenInput}\n {ownMessages}\n </div>\n );\n}\n\n/**\n * A text field: a single line, a password with a reveal button, or a\n * multiline `<textarea>` that grows with its text. Its value is a string,\n * `null` when empty. It draws the box the grid's controls share, with\n * optional prefix and suffix adornments, a clear button, a spinner and a\n * character counter, and takes every shared input prop: display mode,\n * `readOnly`, `disabled`, messages with their severity, density and the\n * events of `@gridkitjs/forms`.\n *\n * Inside a `Field` it takes the field's label, description and messages;\n * outside one, `label` and `description` draw a `Field` around it.\n */\nexport function TextInput(props: TextInputProps) {\n return (\n <InputFrame\n label={props.label}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <TextInputControl {...props} />\n </InputFrame>\n );\n}\n","import {\n booleanFormatter,\n booleanParser,\n checkedRule,\n CHECKBOX_WORDS,\n SWITCH_WORDS,\n type BooleanWords,\n type FormsMessages,\n} from \"@gridkitjs/forms-core\";\nimport { useMemo } from \"react\";\nimport { useFieldContext } from \"../field/fieldContext\";\nimport { classNames } from \"../field/parts\";\nimport { useFormSettings } from \"../settings\";\nimport {\n densityClass,\n hasNode,\n InputFrame,\n joinIds,\n OwnMessages,\n useOwnMessagesId,\n} from \"../text/parts\";\nimport {\n useFieldInput,\n validatorsOf,\n type FieldInputKind,\n} from \"../useFieldInput\";\nimport type { ToggleBaseProps } from \"./toggleProps\";\n\n/** How each toggle reads, writes and requires its value. */\ninterface ToggleVariant {\n /** The root class, which every part's class starts with. */\n readonly base: \"gridkit-forms-checkbox\" | \"gridkit-forms-switch\";\n /** The native input's class. */\n readonly controlClass: `${ToggleVariant[\"base\"]}-control`;\n /** The label text's class. */\n readonly labelClass: `${ToggleVariant[\"base\"]}-label`;\n readonly kind: FieldInputKind<boolean>;\n /** What `required` says while the value is not `true`. */\n readonly requiredMessage: (messages: FormsMessages) => string;\n}\n\nfunction toggleKind(words: BooleanWords): FieldInputKind<boolean> {\n return {\n defaultParse: booleanParser(words),\n defaultFormat: booleanFormatter(words),\n serialize: (value) => String(value),\n };\n}\n\nexport const CHECKBOX: ToggleVariant = {\n base: \"gridkit-forms-checkbox\",\n controlClass: \"gridkit-forms-checkbox-control\",\n labelClass: \"gridkit-forms-checkbox-label\",\n kind: toggleKind(CHECKBOX_WORDS),\n requiredMessage: (messages) => messages.requiredChecked,\n};\n\nexport const SWITCH: ToggleVariant = {\n base: \"gridkit-forms-switch\",\n controlClass: \"gridkit-forms-switch-control\",\n labelClass: \"gridkit-forms-switch-label\",\n kind: toggleKind(SWITCH_WORDS),\n requiredMessage: (messages) => messages.requiredOn,\n};\n\nfunction CheckIcon({ mixed }: { readonly mixed: boolean }) {\n return (\n <svg\n className=\"gridkit-forms-checkbox-icon\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={3}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n {mixed ? <path d=\"M6 12h12\" /> : <path d=\"M20 6 9 17l-5-5\" />}\n </svg>\n );\n}\n\nexport interface ToggleInputProps extends ToggleBaseProps<boolean> {\n readonly variant: ToggleVariant;\n /** Checkbox: a flip can set `null`. */\n readonly threeState?: boolean | undefined;\n /** Switch: \"On\" or \"Off\" beside the track. */\n readonly showStateLabel?: boolean | undefined;\n}\n\nfunction ToggleControl({\n variant,\n threeState = false,\n showStateLabel = false,\n label,\n labelPlacement = \"end\",\n defaultValue,\n required,\n validate,\n density,\n autoFocus,\n className,\n style,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...props\n}: ToggleInputProps) {\n const field = useFieldContext();\n const settings = useFormSettings();\n const needsValue = required === true || field?.required === true;\n const { requiredMessage } = variant;\n const validators = useMemo(\n () => [\n ...(needsValue ? [checkedRule(requiredMessage)] : []),\n ...validatorsOf(validate),\n ],\n [needsValue, requiredMessage, validate],\n );\n\n const input = useFieldInput(\n {\n ...props,\n defaultValue: defaultValue === undefined ? false : defaultValue,\n required,\n validate: validators,\n },\n variant.kind,\n { toggle: { threeState } },\n );\n const { controlProps, state } = input;\n const { base, controlClass, labelClass } = variant;\n const controlId = controlProps.id;\n const ownMessagesId = useOwnMessagesId(controlId);\n const hasLabel = hasNode(label);\n const mixed = base === \"gridkit-forms-checkbox\" && state.value === null;\n\n const root = classNames(\n base,\n state.value === true && \"is-checked\",\n mixed && \"is-mixed\",\n controlProps.disabled === true && \"is-disabled\",\n controlProps[\"aria-readonly\"] === true && \"is-readonly\",\n input.severity !== null && `is-${input.severity}`,\n labelPlacement === \"start\" && \"is-label-start\",\n input.mode === \"display\" && \"is-display\",\n densityClass(density ?? settings.density),\n className,\n );\n const labelText = hasLabel && <span className={labelClass}>{label}</span>;\n\n if (input.mode === \"display\") {\n return (\n <div className={root} style={style}>\n {labelText}\n {input.displayValue}\n {input.hiddenInput}\n </div>\n );\n }\n\n return (\n <>\n <label className={root} style={style}>\n <input\n {...controlProps}\n type=\"checkbox\"\n role={base === \"gridkit-forms-switch\" ? \"switch\" : undefined}\n className={controlClass}\n autoFocus={autoFocus}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={joinIds(\n controlProps[\"aria-describedby\"],\n ownMessagesId,\n ariaDescribedBy,\n )}\n />\n {base === \"gridkit-forms-checkbox\" ? (\n <span className=\"gridkit-forms-checkbox-box\" aria-hidden=\"true\">\n <CheckIcon mixed={mixed} />\n </span>\n ) : (\n <span className=\"gridkit-forms-switch-track\" aria-hidden=\"true\">\n <span className=\"gridkit-forms-switch-thumb\" />\n </span>\n )}\n {labelText}\n {showStateLabel && (\n <span className=\"gridkit-forms-switch-state\" aria-hidden=\"true\">\n {input.text}\n </span>\n )}\n {input.hiddenInput}\n </label>\n <OwnMessages\n id={`${controlId}-messages`}\n messages={input.messages}\n strings={settings.messages}\n named={\n hasLabel || ariaLabel !== undefined || ariaLabelledBy !== undefined\n }\n />\n </>\n );\n}\n\n/**\n * The checkbox and the switch: a native `<input type=\"checkbox\">`, real\n * and focusable, laid transparent over the whole row so the label is part\n * of what a press hits, with the box or track drawn under it. Outside a\n * `Field`, a `description` draws one around it; `label` is always the text\n * beside the control.\n */\nexport function ToggleInput(props: ToggleInputProps) {\n return (\n <InputFrame\n label={undefined}\n description={props.description}\n id={props.id}\n mode={props.mode}\n density={props.density}\n readOnly={props.readOnly}\n disabled={props.disabled}\n >\n <ToggleControl {...props} />\n </InputFrame>\n );\n}\n","import { CHECKBOX, ToggleInput } from \"./ToggleInput\";\nimport type { ToggleBaseProps } from \"./toggleProps\";\n\nexport interface CheckboxProps extends ToggleBaseProps<boolean> {\n /**\n * A flip can set `null`, drawn indeterminate: `false` → `true` → `null`\n * → `false`. Without it a flip never sets `null`, and an app's `null`\n * checks on the first flip.\n */\n readonly threeState?: boolean | undefined;\n}\n\n/**\n * A checkbox. Its value is `true`, `false` or `null`, which is drawn\n * indeterminate (\"mixed\"); it starts `false`. Every flip, by a press or\n * <kbd>Space</kbd>, fires the change events and commits at once (`source`\n * and `trigger` `\"toggle\"`), with \"Yes\" or \"No\" as its text. `required`\n * means it must be checked; `readOnly` refuses flips and stays focusable;\n * display mode shows \"Yes\", \"No\" or a dash. Named by `label`, the text\n * beside the box, and by the label of a `Field` around it.\n */\nexport function Checkbox(props: CheckboxProps) {\n return <ToggleInput {...props} variant={CHECKBOX} />;\n}\n","import { SWITCH, ToggleInput } from \"./ToggleInput\";\nimport type { ToggleBaseProps } from \"./toggleProps\";\n\nexport interface SwitchProps extends Omit<\n ToggleBaseProps<boolean>,\n \"value\" | \"defaultValue\"\n> {\n /** Present means controlled. A switch is on or off, never empty. */\n readonly value?: boolean | undefined;\n /** Off unless given. */\n readonly defaultValue?: boolean | undefined;\n /**\n * Shows \"On\" or \"Off\" beside the track. Screen readers hear the state\n * from the control, so the words are hidden from them.\n */\n readonly showStateLabel?: boolean | undefined;\n}\n\n/**\n * A switch (`role=\"switch\"`), for a setting that takes effect at once: on\n * or off, with no empty state. Every flip, by a press or <kbd>Space</kbd>,\n * fires the change events and commits (`source` and `trigger` `\"toggle\"`),\n * with \"On\" or \"Off\" as its text. `required` means it must be on;\n * `readOnly` refuses flips and stays focusable; display mode shows \"On\" or\n * \"Off\". The thumb moves to the reading end when on.\n */\nexport function Switch(props: SwitchProps) {\n return <ToggleInput {...props} variant={SWITCH} />;\n}\n","// React form inputs and form structure. The types an app writes against are\n// re-exported from forms-core, so an app imports from this package alone.\nexport type {\n FieldBeforeChangeEvent,\n FieldBeforeCommitEvent,\n FieldBeforeInputEvent,\n FieldChangeEvent,\n FieldClearEvent,\n FieldCommitEvent,\n FieldEventBase,\n FieldFocusEvent,\n FieldHandlers,\n FieldInputEvent,\n FieldValidateEvent,\n} from \"./events\";\nexport { Calendar, type CalendarProps } from \"./calendar/Calendar\";\nexport type {\n CalendarLimitProps,\n CalendarSettings,\n} from \"./calendar/calendarProps\";\nexport {\n RangeCalendar,\n type RangeCalendarDetails,\n type RangeCalendarProps,\n} from \"./calendar/RangeCalendar\";\nexport type { OptionColumn, OptionState } from \"./choice/OptionList\";\nexport {\n Select,\n type ChoiceHandle,\n type MultipleSelectProps,\n type SelectCommonProps,\n type SelectProps,\n type SingleSelectProps,\n} from \"./choice/Select\";\nexport type { OptionSource } from \"./choice/useOptionSource\";\nexport { DateInput, type DateInputProps } from \"./date/DateInput\";\nexport {\n DateTimeInput,\n type DateTimeInputProps,\n type DateTimeValue,\n type DateTimeValueType,\n type DateTimeZoneProps,\n} from \"./date/DateTimeInput\";\nexport type {\n DayLimits,\n SegmentedInputProps,\n TimeSettings,\n} from \"./date/segmentedProps\";\nexport { TimeInput, type TimeInputProps } from \"./date/TimeInput\";\nexport { Field, type FieldProps } from \"./field/Field\";\nexport type { FieldControlState } from \"./field/fieldContext\";\nexport { FieldGroup, type FieldGroupProps } from \"./field/FieldGroup\";\nexport type { FieldSpan } from \"./field/parts\";\nexport {\n useField,\n type FieldControlProps,\n type UseFieldOptions,\n type UseFieldResult,\n} from \"./field/useField\";\nexport { Form, type FormProps } from \"./form/Form\";\nexport { FormsProvider, type FormsProviderProps } from \"./FormsProvider\";\nexport {\n MessageSummary,\n type MessageSummaryProps,\n} from \"./form/MessageSummary\";\nexport { Fieldset, type FieldsetProps } from \"./layout/Fieldset\";\nexport { FormLayout, type FormLayoutProps } from \"./layout/FormLayout\";\nexport { FormSection, type FormSectionProps } from \"./layout/FormSection\";\nexport type {\n Density,\n FieldMode,\n LabelPosition,\n NecessityIndicator,\n} from \"./settings\";\nexport {\n DurationInput,\n type DurationInputProps,\n} from \"./duration/DurationInput\";\nexport { MaskedInput, type MaskedInputProps } from \"./mask/MaskedInput\";\nexport {\n NumberInput,\n type NumberInputProps,\n type NumberLimit,\n type NumberStepEvent,\n} from \"./number/NumberInput\";\nexport {\n NumberRangeInput,\n type NumberRange,\n type NumberRangeDetails,\n type NumberRangeInputProps,\n} from \"./number/NumberRangeInput\";\nexport { PercentInput, type PercentInputProps } from \"./number/PercentInput\";\nexport { PeriodInput, type PeriodInputProps } from \"./period/PeriodInput\";\nexport { SearchInput, type SearchInputProps } from \"./text/SearchInput\";\nexport { TextInput, type TextInputProps } from \"./text/TextInput\";\nexport type {\n InputBaseProps,\n ManagedControlProps,\n TextInputBaseProps,\n} from \"./text/textInputProps\";\nexport { Checkbox, type CheckboxProps } from \"./toggle/Checkbox\";\nexport { Switch, type SwitchProps } from \"./toggle/Switch\";\nexport type {\n ToggleBaseProps,\n ToggleLabelPlacement,\n} from \"./toggle/toggleProps\";\nexport {\n useFieldInput,\n type FieldControlBinding,\n type FieldInput,\n type FieldInputKind,\n type FieldInputOptions,\n type FieldInputProps,\n type InputHandle,\n} from \"./useFieldInput\";\nexport {\n createOptionCache,\n formatText,\n keyText,\n maskPresets,\n parsed,\n textParser,\n unreadable,\n type CalendarMonth,\n type ChangeSource,\n type ChoiceDetails,\n type ChoiceOption,\n type CommitTrigger,\n type CreateEvent,\n type DateDetails,\n type DateRange,\n type DateReadingInfo,\n type DateSegmentType,\n type DateTimeDetails,\n type DecimalString,\n type DisabledOptions,\n type DurationDetails,\n type DurationNotation,\n type DurationUnit,\n type FieldDraft,\n type FieldMessage,\n type FieldMessageInput,\n type FieldPhase,\n type FiscalYear,\n type FieldState,\n type FormatContext,\n type Formatter,\n type FormsMessages,\n type HighlightChangeEvent,\n type Instant,\n type LoadErrorEvent,\n type LoadedOptions,\n type MatchContext,\n type MatchMode,\n type MaskDetails,\n type MaskOptions,\n type MaskPreset,\n type MaskPresets,\n type MaskSource,\n type MaskTokenDefinition,\n type MaskTokens,\n type MaskValueFormat,\n type NegativeStyle,\n type NumberDetails,\n type NumberReadingInfo,\n type NumberValue,\n type NumberValueType,\n type NoDetails,\n type NoFlags,\n type OptionCache,\n type OptionKey,\n type OptionMatch,\n type OptionMatcher,\n type OptionPage,\n type OptionQuery,\n type OptionSearch,\n type ParseContext,\n type ParseResult,\n type Parser,\n type PercentScale,\n type Period,\n type PeriodDetails,\n type PeriodGranularity,\n type PlainDate,\n type PlainDateTime,\n type PlainTime,\n type PopupCloseReason,\n type PopupOpenChange,\n type PopupOpenReason,\n type QueryChangeEvent,\n type Range,\n type RangeBounds,\n type RangeDetails,\n type RangeEnd,\n type RoundingMode,\n type Severity,\n type SingleChoiceDetails,\n type StepDirection,\n type StepSize,\n type TextInputDetails,\n type TextParseOptions,\n type TextRange,\n type TextReading,\n type TimeDetails,\n type TimeZoneDisambiguation,\n type ValidationResult,\n type Validator,\n type ValidatorContext,\n type Weekday,\n type WeekNumbering,\n} from \"@gridkitjs/forms-core\";\n"],"mappings":";;;AAAA;AAAA,EACE,qBAAAA;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,YAAAC;AAAA,OAMK;AACP,SAAS,eAAAC,cAAa,WAAAC,iBAAiC;;;ACjBvD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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O,SAAS,QAAQ;AAClD;;;ACuFA;AAAA,EACE;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,OAwFK;","names":["availableDateRule","dateDetails","dateFormatter","formatDate","isCalendarDayDisabled","isPlainDate","maxDateRule","minDateRule","requiredRule","weekInfo","useCallback","useMemo","formatDate","runtimeTimeZone","todayIn","useMemo","useState","messages","isCalendarDayDisabled","useLayoutEffect","useMemo","calendarMonthParts","useMemo","useMemo","NO_MESSAGES","jsx","useMemo","useLayoutEffect","useRef","useState","useCallback","useState","jsx","jsxs","useRef","useState","useLayoutEffect","years","jsx","jsxs","calendarMonthParts","jsx","useMemo","useLayoutEffect","isCalendarDayDisabled","useCallback","useEffect","useState","useMemo","useRef","useState","createContext","useContext","useLayoutEffect","createContext","useContext","useMemo","jsx","attachOverlay","writingDirection","useLayoutEffect","useState","useCallback","useLayoutEffect","useRef","useState","Fragment","jsx","jsxs","ANCHOR_GAP","useState","useLayoutEffect","attachOverlay","writingDirection","jsx","jsxs","jsx","jsxs","useState","useMemo","useRef","jsx","jsxs","Icon","useState","useCallback","useEffect","mostSevere","resolveFormsMessages","sortFieldMessages","toFieldMessages","useCallback","useEffect","useId","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","jsx","jsxs","jsx","NO_MESSAGES","useId","useMemo","resolveFormsMessages","useLayoutEffect","useEffect","useShownMessages","sortFieldMessages","toFieldMessages","mostSevere","useState","useSyncExternalStore","useCallback","useRef","Fragment","useRef","createPortal","jsx","createPortal","createFieldController","hasError","scheduleTimeout","useEffect","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","jsx","NO_MESSAGES","value","useEffect","scheduleTimeout","useState","createFieldController","useSyncExternalStore","shown","text","useRef","useLayoutEffect","useImperativeHandle","useMemo","useShownMessages","displayText","hasError","jsx","jsxs","Fragment","useRef","jsx","todayIn","runtimeTimeZone","useState","formatDate","useMemo","createFieldController","hasError","useEffect","useImperativeHandle","useLayoutEffect","useState","useSyncExternalStore","jsx","NO_MESSAGES","value","useEffect","useState","createFieldController","useSyncExternalStore","useLayoutEffect","useImperativeHandle","useShownMessages","hasError","jsx","jsxs","SELECTED","dateFormatter","dateDetails","value","formatDate","isPlainDate","useMemo","requiredRule","minDateRule","maxDateRule","availableDateRule","weekInfo","useCallback","isCalendarDayDisabled","compareDates","formatDate","isCalendarDayDisabled","isPlainDate","requiredRule","weekInfo","useCallback","useLayoutEffect","useMemo","useRef","useState","jsx","jsxs","end","isPlainDate","compareDates","weekInfo","formatDate","useMemo","requiredRule","useState","useRef","useLayoutEffect","useCallback","isCalendarDayDisabled","addKeys","useLayoutEffect","useState","parsed","createFieldController","hasError","sortFieldMessages","attachTextInput","useCallback","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","jsx","NO_MESSAGES","text","useState","createFieldController","useSyncExternalStore","useCallback","useRef","useLayoutEffect","attachTextInput","useMemo","sortFieldMessages","useShownMessages","hasError","parsed","useMemo","createPortal","jsx","createPortal","Fragment","jsx","jsxs","foldText","keyText","useLayoutEffect","useRef","useState","Fragment","jsx","jsxs","keyText","useState","useRef","useLayoutEffect","rows","typeahead","foldText","jsx","jsxs","useMemo","keyText","writingDirection","useImperativeHandle","useLayoutEffect","useRef","useState","jsx","jsxs","useState","useRef","useLayoutEffect","writingDirection","useImperativeHandle","Fragment","jsx","jsxs","keyText","sameKey","useCallback","useImperativeHandle","useRef","useState","useState","useRef","sameKey","useCallback","useImperativeHandle","useCallback","useEffect","useLayoutEffect","useRef","foldText","useEffect","useMemo","useRef","useState","useState","useRef","useEffect","useMemo","foldText","useCallback","useLayoutEffect","useRef","opened","keyText","sameKeys","valueKeys","useEffect","useMemo","useRef","useState","flattenOptions","foldText","hasKey","useCallback","useMemo","selectAll","useCallback","useEffect","useLayoutEffect","useMemo","keyText","useCallback","useMemo","useRef","abortSignals","scheduleTimeout","useEffect","useRef","useState","useSyncExternalStore","useCallback","useMemo","useRef","keyText","source","useCallback","useLayoutEffect","useRef","useState","useRef","useState","useCallback","useLayoutEffect","useEffect","useMemo","useCallback","value","source","useLayoutEffect","jsx","jsxs","useState","query","source","addKeys","useLayoutEffect","availableDateRule","dateLayout","pivotYear","requiredRule","useMemo","useState","isCalendarDayDisabled","useLayoutEffect","useRef","useState","jsx","useRef","useState","useLayoutEffect","next","nextIndex","Fragment","jsx","jsxs","isCalendarDayDisabled","jsx","useState","dateLayout","pivotYear","useMemo","requiredRule","availableDateRule","dateLayout","requiredRule","splitDateTime","useEffect","useMemo","useState","setTimeColumn","snapTime","timeColumns","Fragment","jsx","jsxs","timeColumns","setTimeColumn","snapTime","jsx","useState","useEffect","dateLayout","useMemo","requiredRule","splitDateTime","hasError","mostSevere","toFieldMessages","useId","useMemo","useRef","jsx","jsxs","useId","mostSevere","hasError","toFieldMessages","useMemo","useRef","toFieldMessages","useCallback","useId","useLayoutEffect","useRef","useId","useRef","useLayoutEffect","useCallback","toFieldMessages","useCallback","useLayoutEffect","useState","flushSync","jsx","useState","useCallback","useLayoutEffect","flushSync","jsx","useCallback","useId","useMemo","useSyncExternalStore","Fragment","jsx","jsxs","titleId","useId","useSyncExternalStore","useMemo","useCallback","useId","jsx","jsxs","useId","jsx","useCallback","useId","useLayoutEffect","useRef","useState","jsx","jsxs","useId","titleId","useState","useCallback","useRef","useLayoutEffect","requiredRule","useMemo","useEffect","useLayoutEffect","useMemo","useRef","useMemo","useEffect","useRef","useLayoutEffect","jsx","jsxs","useMemo","requiredRule","maskDetails","requiredRule","useMemo","jsx","jsxs","useMemo","requiredRule","maskDetails","compareDecimals","requiredRule","stepNumberValue","useEffect","useLayoutEffect","useMemo","useRef","useState","jsx","jsxs","ChevronIcon","useState","useRef","useLayoutEffect","useEffect","useMemo","requiredRule","stepNumberValue","compareDecimals","compareDecimals","formatNumber","maxRule","minRule","numberAffixes","numberCaret","numberSymbols","rangeDetails","requiredRule","sameRange","stepNumberValue","useLayoutEffect","useMemo","useState","hasError","attachFocusGroup","attachTextInput","useImperativeHandle","useLayoutEffect","useRef","useState","useSyncExternalStore","NO_MESSAGES","useState","useSyncExternalStore","useLayoutEffect","attachFocusGroup","useImperativeHandle","useShownMessages","hasError","useRef","attachTextInput","jsx","jsxs","compareDecimals","useLayoutEffect","formatNumber","numberSymbols","useMemo","span","requiredRule","minRule","maxRule","value","sameRange","rangeDetails","useState","numberCaret","hiddenInputs","stepNumberValue","nameId","numberAffixes","jsx","comparePeriods","periodOf","periodParts","pivotYear","requiredRule","useEffect","useMemo","useState","formatMonthName","useRef","useState","jsx","jsxs","useRef","useState","titleId","formatMonthName","jsx","useEffect","useMemo","useState","comparePeriods","periodParts","periodOf","pivotYear","requiredRule","formatText","requiredRule","textParser","useMemo","jsx","jsxs","textParser","formatText","useMemo","requiredRule","formatText","requiredRule","textParser","scheduleTimeout","useEffect","useLayoutEffect","useMemo","useRef","useState","Fragment","jsx","jsxs","useState","useRef","useEffect","scheduleTimeout","useMemo","textParser","formatText","requiredRule","useLayoutEffect","useMemo","Fragment","jsx","jsxs","CheckIcon","useMemo","jsx","jsx","formatText","keyText","parsed","textParser","unreadable"]}
|