@cscfi/csc-ui 4.0.0-alpha.26 → 4.0.0-alpha.28

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.
@@ -0,0 +1,199 @@
1
+ import type { CFieldSize } from '../../types';
2
+ export interface CTimePickerProps {
3
+ /**
4
+ * Make the value clearable
5
+ */
6
+ clearable?: boolean;
7
+ /**
8
+ * Disable the field
9
+ */
10
+ disabled?: boolean;
11
+ /**
12
+ * Error message shown in place of the hint while the field is invalid
13
+ *
14
+ * @freeform
15
+ */
16
+ errorMessage?: string;
17
+ /**
18
+ * How times are shown and read from typing: a pattern of the tokens `H`,
19
+ * `HH` (24-hour), `h`, `hh` (12-hour, with the period `a`) and `mm` with
20
+ * any separators, e.g. `HH:mm` or `h:mm a`
21
+ *
22
+ * @defaultable 'HH.mm'
23
+ * @freeform
24
+ */
25
+ format?: string;
26
+ /**
27
+ * Hide the hint and error messages
28
+ *
29
+ * @defaultable false
30
+ */
31
+ hideDetails?: boolean;
32
+ /**
33
+ * Hint text for the field
34
+ *
35
+ * @freeform
36
+ */
37
+ hint?: string;
38
+ /**
39
+ * Id of the element
40
+ *
41
+ * @freeform
42
+ */
43
+ hostId?: string;
44
+ /**
45
+ * Element label
46
+ *
47
+ * @freeform
48
+ */
49
+ label?: string;
50
+ /**
51
+ * Label on top of the field
52
+ *
53
+ * @defaultable false
54
+ */
55
+ labelOnTop?: boolean;
56
+ /**
57
+ * The latest time that can be picked or typed, as an ISO `HH:mm` time
58
+ *
59
+ * @freeform
60
+ */
61
+ max?: string;
62
+ /**
63
+ * The earliest time that can be picked or typed, as an ISO `HH:mm` time;
64
+ * a `min` after `max` is invalid and both are ignored
65
+ *
66
+ * @freeform
67
+ */
68
+ min?: string;
69
+ /**
70
+ * Minutes between the minute column's rows; typed times need not fall on
71
+ * the step
72
+ */
73
+ minuteStep?: number;
74
+ /**
75
+ * Input field name
76
+ *
77
+ * @freeform
78
+ */
79
+ name?: string;
80
+ /**
81
+ * Placeholder of the input; the `format` pattern when empty
82
+ *
83
+ * @freeform
84
+ */
85
+ placeholder?: string;
86
+ /**
87
+ * Pick a range: the value becomes `{ start, end }` and the field holds two
88
+ * inputs
89
+ */
90
+ range?: boolean;
91
+ /**
92
+ * Set the field as required
93
+ */
94
+ required?: boolean;
95
+ /**
96
+ * Shadow variant
97
+ *
98
+ * @defaultable false
99
+ */
100
+ shadow?: boolean;
101
+ /**
102
+ * Field height: the 52px default (the shared control height) or the 36px `small` box
103
+ *
104
+ * @defaultable 'default'
105
+ */
106
+ size?: CFieldSize;
107
+ /**
108
+ * UI text overrides (i18n), merged over the AM/PM texts `Intl` gives for
109
+ * the page's `lang` and the English defaults. Objects have no attribute
110
+ * form — bind as a DOM property
111
+ *
112
+ * @defaultable {}
113
+ */
114
+ texts?: CTimePickerTexts;
115
+ /**
116
+ * Set the validity of the field
117
+ */
118
+ valid?: boolean;
119
+ /**
120
+ * The time as an ISO `HH:mm` string on a 24-hour clock, or `{ start, end }`
121
+ * under `range`; `null` when empty
122
+ */
123
+ value?: CTimePickerValue;
124
+ }
125
+ /** A time range: ISO `HH:mm` ends, either of which may be `null` while only one is typed; an end before the start spans midnight. */
126
+ export interface CTimePickerRange {
127
+ /** The end of the range; earlier than the start for an overnight range. */
128
+ end: null | string;
129
+ /** The start of the range. */
130
+ start: null | string;
131
+ }
132
+ /**
133
+ * The text committed from the field, as typed: a string, or both ends'
134
+ * texts under `range`.
135
+ */
136
+ export type CTimePickerText = {
137
+ end: string;
138
+ start: string;
139
+ } | string;
140
+ /**
141
+ * UI texts of `c-time-picker`, merged key by key over the AM/PM texts
142
+ * `Intl` gives for the page's `lang` and the English defaults.
143
+ */
144
+ export interface CTimePickerTexts {
145
+ /** The period before noon in a 12-hour `format`. */
146
+ am?: string;
147
+ /** Accessible name of the dialog when the field has no label. */
148
+ chooseTime?: string;
149
+ /** Accessible label of the clear button. */
150
+ clearSelection?: string;
151
+ /** Accessible label of the close button in the fullscreen panel (narrow viewports). */
152
+ closePanel?: string;
153
+ /** Name of the end input and the end tab under `range`. */
154
+ end?: string;
155
+ /** Accessible name of the hour column. */
156
+ hours?: string;
157
+ /** Accessible name of the minute column. */
158
+ minutes?: string;
159
+ /** Accessible label of the clock button. */
160
+ openClock?: string;
161
+ /** Accessible name of the AM/PM column. */
162
+ period?: string;
163
+ /** The period from noon in a 12-hour `format`. */
164
+ pm?: string;
165
+ /** Name of the start input and the start tab under `range`. */
166
+ start?: string;
167
+ }
168
+ /**
169
+ * Value of `c-time-picker`: an ISO `HH:mm` string, a
170
+ * {@link CTimePickerRange} under `range`, or `null` when empty.
171
+ */
172
+ export type CTimePickerValue = CTimePickerRange | null | string;
173
+ declare const _default: typeof __VLS_export;
174
+ export default _default;
175
+ declare const __VLS_export: import("vue").DefineComponent<CTimePickerProps, {
176
+ badInput: import("vue").ComputedRef<boolean>;
177
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<CTimePickerProps> & Readonly<{}>, {
178
+ label: string;
179
+ value: CTimePickerValue;
180
+ name: string;
181
+ required: boolean;
182
+ disabled: boolean;
183
+ size: CFieldSize;
184
+ clearable: boolean;
185
+ errorMessage: string;
186
+ hideDetails: boolean;
187
+ hint: string;
188
+ hostId: string;
189
+ labelOnTop: boolean;
190
+ placeholder: string;
191
+ shadow: boolean;
192
+ texts: CTimePickerTexts;
193
+ valid: boolean;
194
+ format: string;
195
+ max: string;
196
+ min: string;
197
+ range: boolean;
198
+ minuteStep: number;
199
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Time-of-day helpers for `c-time-picker` (ADR-0061). Pure functions over
3
+ * ISO `HH:mm` strings on a 24-hour clock — no seconds, no date, no zone.
4
+ * Arithmetic works in minutes since midnight.
5
+ */
6
+ import type { MaskSlot } from '../../shared/inputMask';
7
+ /** The two period texts of a 12-hour format, as shown. */
8
+ export interface CTimePickerPeriods {
9
+ am: string;
10
+ pm: string;
11
+ }
12
+ /** `min` / `max` in minutes since midnight; `null` where unbounded. */
13
+ export interface CTimePickerBounds {
14
+ max: null | number;
15
+ min: null | number;
16
+ }
17
+ export declare const isTime: (value: unknown) => value is string;
18
+ export declare const toMinutes: (time: string) => number;
19
+ export declare const fromMinutes: (minutes: number) => string;
20
+ /** The current local time, as ISO. */
21
+ export declare const nowTime: () => string;
22
+ /**
23
+ * Whether `pattern` is usable: one hour token then `mm`, a literal between
24
+ * them, and the period `a` exactly when the hour is 12-hour (`h`, `hh`) —
25
+ * before or after the time. No other letters. Anything else falls back to
26
+ * the built-in pattern.
27
+ */
28
+ export declare const isValidPattern: (pattern: string) => boolean;
29
+ /** Whether a valid pattern shows a 12-hour clock with a period. */
30
+ export declare const isTwelveHour: (pattern: string) => boolean;
31
+ /** Whether a valid pattern pads the hour to two digits. */
32
+ export declare const padsHour: (pattern: string) => boolean;
33
+ /** The hour as its column row shows it under `pattern`: `0`–`23`, or `12`, `1`–`11`. */
34
+ export declare const hourLabel: (hour24: number, pattern: string) => string;
35
+ export declare const formatTime: (time: string, pattern: string, periods: CTimePickerPeriods) => string;
36
+ /**
37
+ * Read typed text as a time (ADR-0061). Lenient: any run of `.`, `:` or
38
+ * spaces separates the hour from the minutes; a bare hour reads as on the
39
+ * hour (`9` → `09:00`); three or four digits split as hour and minutes
40
+ * (`930` → `09:30`); a minute of one digit is that minute (`9.3` →
41
+ * `09:03`). A period — the resolved AM/PM texts or English `a` / `p` —
42
+ * makes the hour 12-hour whatever the pattern; a 12-hour pattern also
43
+ * takes a 24-hour time, and reads an hour without a period as AM. Returns
44
+ * the ISO time, or `null`.
45
+ */
46
+ export declare const parseTime: (text: string, pattern: string, periods: CTimePickerPeriods) => null | string;
47
+ /**
48
+ * The input mask typing follows under a pattern (ADR-0061, ADR-0059): the
49
+ * hour and the minutes take one or two digits, closing early on a typed
50
+ * separator or on a first digit no two-digit value starts with (an hour
51
+ * 3–9, 2–9 on a 12-hour clock; a minute 6–9); the period is a word slot
52
+ * over the resolved AM/PM texts, so `p` shows the whole PM text. A
53
+ * separator of the pattern also accepts any of `. : space` typed in its
54
+ * place and shows as the pattern's own.
55
+ */
56
+ export declare const compileTimeMask: (pattern: string, periods: CTimePickerPeriods) => MaskSlot[];
57
+ /**
58
+ * `min` / `max` read as minutes. A bound that is not an ISO time is
59
+ * unbounded; `min` after `max` is invalid — `null` — not an overnight wrap.
60
+ */
61
+ export declare const readBounds: (min: unknown, max: unknown) => CTimePickerBounds | null;
62
+ export declare const inBounds: (minutes: number, b: CTimePickerBounds) => boolean;
63
+ export declare const clampToBounds: (minutes: number, b: CTimePickerBounds) => number;
64
+ /** Whether no minute of the hour (0–23) is inside the bounds. */
65
+ export declare const hourDisabled: (hour: number, b: CTimePickerBounds) => boolean;
66
+ /** Whether no minute of the half day is inside the bounds. */
67
+ export declare const periodDisabled: (period: "am" | "pm", b: CTimePickerBounds) => boolean;
68
+ /** The hour column's hours (0–23) in row order: `0…23`, or `12, 1…11` of one half day. */
69
+ export declare const hourRows: (twelve: boolean, pm?: boolean) => number[];
70
+ /**
71
+ * The minute column's minutes: every `step` from 0, plus `current` sorted in
72
+ * when it is off the step (ADR-0061: a step shapes the column, never the
73
+ * value). A step that is not a positive integer is 1.
74
+ */
75
+ export declare const minuteRows: (step: number, current: null | number) => number[];
76
+ /** The minute row nearest `minute` on the step, never past the last row. */
77
+ export declare const roundToStep: (minute: number, step: number) => number;
78
+ /**
79
+ * The AM/PM texts for `lang` from `Intl.DateTimeFormat`'s `dayPeriod` — the
80
+ * fallback under `texts` (ADR-0061). `null` without a language or `Intl`.
81
+ */
82
+ export declare const intlPeriods: (lang: string) => CTimePickerPeriods | null;
@@ -4,9 +4,11 @@ export type { CButtonGroupProps, CButtonGroupSize, CButtonGroupValue, } from './
4
4
  export type { CButtonProps, CButtonSize, CButtonType, } from './components/c-button/CButton.vue';
5
5
  export type { CCardActionsAlign, CCardActionsJustify, CCardActionsProps, } from './components/c-card-actions/CCardActions.vue';
6
6
  export type { CDataTableAlign, CDataTableCellContent, CDataTableCellContext, CDataTableColumn, CDataTableColumnExpansion, CDataTableColumnPin, CDataTableExpandedContext, CDataTableFooterContext, CDataTableProps, CDataTableRow, CDataTableSelectionMode, CDataTableSort, CDataTableSortDirection, CDataTableTexts, } from './components/c-data-table/CDataTable.vue';
7
+ export type { CDatePickerDisabledDate, CDatePickerProps, CDatePickerRange, CDatePickerText, CDatePickerTexts, CDatePickerType, CDatePickerValue, CDatePickerWeekday, } from './components/c-date-picker/CDatePicker.vue';
7
8
  export type { CIconButtonProps, CIconButtonSize, } from './components/c-icon-button/CIconButton.vue';
8
9
  export type { CLoginCardActionsAlign, CLoginCardActionsJustify, CLoginCardActionsProps, } from './components/c-login-card-actions/CLoginCardActions.vue';
9
10
  export type { CLoginCardBlendMode, CLoginCardProps, } from './components/c-login-card/CLoginCard.vue';
11
+ export type { CNumberFieldProps } from './components/c-number-field/CNumberField.vue';
10
12
  export type { CPaginationOptions, CPaginationProps, CPaginationSize, } from './components/c-pagination/CPagination.vue';
11
13
  export type { CPopoverProps } from './components/c-popover/CPopover.vue';
12
14
  export type { CProgressCircleProps } from './components/c-progress-circle/CProgressCircle.vue';
@@ -17,6 +19,7 @@ export type { CTabsJustify, CTabsProps } from './components/c-tabs/CTabs.vue';
17
19
  export type { CTagProps, CTagSize } from './components/c-tag/CTag.vue';
18
20
  export type { CTagsProps, CTagsSize } from './components/c-tags/CTags.vue';
19
21
  export type { CTextFieldAutocapitalize, CTextFieldProps, CTextFieldType, } from './components/c-text-field/CTextField.vue';
22
+ export type { CTimePickerProps, CTimePickerRange, CTimePickerText, CTimePickerTexts, CTimePickerValue, } from './components/c-time-picker/CTimePicker.vue';
20
23
  export type { CToastProps } from './components/c-toast/CToast.vue';
21
24
  export type { CToastsHorizontal, CToastsProps, CToastsVertical, } from './components/c-toasts/CToasts.vue';
22
25
  export type { CTooltipProps } from './components/c-tooltip/CTooltip.vue';
@@ -0,0 +1,40 @@
1
+ import type { CFieldSize } from '../types';
2
+ import { type TypedField } from './useTypedField';
3
+ type __VLS_Props = {
4
+ /** The `anchor-name` style from `useAnchoredPanel`. */
5
+ anchorStyle: string;
6
+ /** Accessible label of the clear button. */
7
+ clearLabel: string;
8
+ clearable: boolean;
9
+ disabled: boolean;
10
+ errorMessage: string;
11
+ /** The `useTypedField` state this field renders. */
12
+ field: TypedField;
13
+ hideDetails: boolean;
14
+ hint: string;
15
+ inputId: string;
16
+ /** The virtual keyboard the inputs ask for. */
17
+ inputmode: 'numeric' | 'text';
18
+ label: string;
19
+ labelOnTop: boolean;
20
+ name: string;
21
+ /** Whether the host's panel is open — the field stays active. */
22
+ open: boolean;
23
+ required: boolean;
24
+ shadow: boolean;
25
+ size: CFieldSize;
26
+ valid: boolean;
27
+ };
28
+ declare var __VLS_20: {};
29
+ type __VLS_Slots = {} & {
30
+ trigger?: (props: typeof __VLS_20) => any;
31
+ };
32
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
36
+ type __VLS_WithSlots<T, S> = T & {
37
+ new (): {
38
+ $slots: S;
39
+ };
40
+ };
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Input masks (CONTEXT.md "Input mask"; ADR-0059): conform typed text to a
3
+ * pattern as it is typed. One engine behind `c-text-field`'s `mask` and
4
+ * `c-date-picker`'s `format`.
5
+ *
6
+ * A mask compiles to a list of slots. A **token** slot takes one to `max`
7
+ * characters its `accepts` predicate allows — a `c-text-field` token takes
8
+ * exactly one; a date part takes one or two digits, and closes early on a
9
+ * typed separator or a first digit no longer value can start. A **literal**
10
+ * slot is a fixed character, inserted lazily: only when a later token
11
+ * character arrives, so an empty field stays `''` and Backspace behaves like
12
+ * plain text. A typed character that is the next literal (or one of its
13
+ * `aliases`) is consumed as that literal.
14
+ *
15
+ * A **word** slot takes one of a few words — a time's AM/PM period — typed
16
+ * by its first letters: once they name one word, the slot shows the whole
17
+ * word and closes. Its characters all count as typed, and a deleting edit
18
+ * that leaves a word partial clears it, so one Backspace removes it.
19
+ *
20
+ * An **optional section** (`[…]`, trailing only) holds optional slots: its
21
+ * tokens take zero or one character (`min: 0`) and its literals are marked
22
+ * `optional`. Completeness and the mask guide count required slots only.
23
+ */
24
+ export interface MaskResult {
25
+ /** The caret position in `text`. */
26
+ caret: number;
27
+ /** Whether every required token slot is filled. */
28
+ complete: boolean;
29
+ /**
30
+ * What the mask still asks for after `text` — the **mask guide**: each
31
+ * unfilled required token drawn as `_`, literals as themselves; optional
32
+ * slots are never drawn. `''` once complete.
33
+ */
34
+ rest: string;
35
+ /** The conformed text. */
36
+ text: string;
37
+ /** Per character of `text`: whether it fills a token slot (not a literal). */
38
+ tokenAt: boolean[];
39
+ /** Only the characters filling token slots. */
40
+ unmasked: string;
41
+ }
42
+ export type MaskSlot = {
43
+ /** Other typed characters that stand for this literal. */
44
+ aliases?: string;
45
+ kind: 'literal';
46
+ /** Part of an optional section: never drawn in the guide, never appended. */
47
+ optional?: boolean;
48
+ text: string;
49
+ } | {
50
+ accepts: (ch: string) => boolean;
51
+ /** Closes the slot early once its characters so far are `value`. */
52
+ closesAfter?: (value: string) => boolean;
53
+ kind: 'token';
54
+ max: number;
55
+ /** `0` for an optional token. */
56
+ min: number;
57
+ } | {
58
+ kind: 'word';
59
+ /** The words the slot takes, matched case-insensitively and shown as written here. */
60
+ words: string[];
61
+ };
62
+ /**
63
+ * Compile a `c-text-field` mask: `#` a digit, `A` a letter, `*` a letter or
64
+ * a digit, `\` escapes the next character, `[…]` wraps a trailing optional
65
+ * section; everything else is a literal. Returns `null` for a mask that
66
+ * breaks the section rules: a nested, unclosed or stray bracket, or anything
67
+ * but another section after the first one.
68
+ */
69
+ export declare const compileMask: (pattern: string) => MaskSlot[] | null;
70
+ /** Say once per pattern, page-wide, that a mask was ignored as invalid. */
71
+ export declare const warnInvalidMask: (tag: string, pattern: string) => void;
72
+ /** Whether every token of a mask takes only digits (a numeric keyboard fits). */
73
+ export declare const isNumericMask: (pattern: string) => boolean;
74
+ /**
75
+ * Conform `text` to `slots`, mapping `caret` (a position in `text`) onto the
76
+ * result. Characters that fit no slot are dropped. `deleting` marks an edit
77
+ * that removed text: trailing literals are then trimmed, so Backspace never
78
+ * sticks on a separator. Otherwise literals that end the mask are appended
79
+ * once the last token is filled.
80
+ */
81
+ export declare const conformMask: (slots: MaskSlot[], text: string, caret?: number, deleting?: boolean) => MaskResult;
82
+ /** Rewrites text to its conformed form, mapping a caret position onto it. */
83
+ export type Conformer<R extends ConformResult = ConformResult> = (text: string, caret?: number, deleting?: boolean) => R;
84
+ /** The part of a conform result the caret machinery needs. */
85
+ export interface ConformResult {
86
+ caret: number;
87
+ text: string;
88
+ /** Per character of `text`: whether it is typed content (not an inserted literal or separator). */
89
+ tokenAt: boolean[];
90
+ }
91
+ /**
92
+ * Conform an `<input>` after a native `input` event: rewrite its text and
93
+ * caret in place and return the result. `previous` is the text shown before
94
+ * the edit — a Backspace (Delete) that only removed an inserted character (a
95
+ * literal, a group separator) removes the typed character before (after) it
96
+ * instead. Returns `null`, leaving the input untouched, during IME
97
+ * composition, or on a paste or drop when `skipPaste` is set (the date picker
98
+ * reads pasted text leniently instead).
99
+ */
100
+ export declare const applyConform: <R extends ConformResult>(input: HTMLInputElement, event: Event, conform: Conformer<R>, previous: string, { skipPaste }?: {
101
+ skipPaste?: boolean | undefined;
102
+ }) => null | R;
103
+ /** `applyConform` over mask slots. */
104
+ export declare const applyMask: (input: HTMLInputElement, event: Event, slots: MaskSlot[], previous: string, options?: {
105
+ skipPaste?: boolean;
106
+ }) => MaskResult | null;
@@ -2,8 +2,9 @@
2
2
  * Anchored field panel (CONTEXT.md "Autocomplete", "Tree select", "Top
3
3
  * layer", "Fullscreen panel"; ADR-0008, ADR-0009, ADR-0047, ADR-0050): the
4
4
  * lifecycle shared by the value-selection fields that keep a readonly value
5
- * field in place and open a native popover panel — `c-autocomplete` and
6
- * `c-tree-select`. One panel, two layouts: **anchored** under the field, or
5
+ * field in place and open a native popover panel — `c-autocomplete`,
6
+ * `c-tree-select` and `c-date-picker` (whose field is editable and whose
7
+ * calendar keeps its own width: `matchWidth: false`, ADR-0058). One panel, two layouts: **anchored** under the field, or
7
8
  * — on a **narrow viewport** — a **fullscreen panel** covering the viewport.
8
9
  *
9
10
  * What it owns:
@@ -87,6 +88,8 @@ export interface UseAnchoredPanelOptions {
87
88
  fullscreen?: Readonly<Ref<boolean>>;
88
89
  /** The custom element host: light dismiss keeps gestures whose composed path includes it; it is what the page lock keeps interactive. */
89
90
  host: HTMLElement | null;
91
+ /** Pin the anchored panel's width to the anchor's (default `true`). `false` lets the card size the panel — a calendar keeps its own width whatever the field's. */
92
+ matchWidth?: boolean;
90
93
  /** Runs inside the native `toggle` handler once closed, before focus returns. */
91
94
  onClosed?: () => void;
92
95
  /** Runs inside the native `toggle` handler once open, after the fallback positioning / page lock and the dismiss listener — the consumer's open sequence goes here. */
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The typed half of a picker whose value field holds editable text
3
+ * (ADR-0057, ADR-0058, ADR-0059): one input, or a start and an end input in
4
+ * one field box under `range`. Text is masked while typed and read by the
5
+ * codec only on Enter or blur; text that names no usable value is kept as
6
+ * typed and flags **bad input** (CONTEXT.md). Programmatic values re-sync the
7
+ * text and never emit; commits emit through `emitModelChange`.
8
+ *
9
+ * Generic over the value's codec, so `c-date-picker` and `c-time-picker`
10
+ * share one commit model. The anatomy lives in `TypedField.vue`, which binds
11
+ * the element refs returned here.
12
+ */
13
+ import { type Ref } from 'vue';
14
+ import { type MaskSlot } from './inputMask';
15
+ export type TypedFieldEnd = 'end' | 'start';
16
+ export interface TypedFieldEnds {
17
+ end: null | string;
18
+ start: null | string;
19
+ }
20
+ /** The text committed from the field, as typed: both ends' texts under `range`. */
21
+ export type TypedFieldText = {
22
+ end: string;
23
+ start: string;
24
+ } | string;
25
+ export interface TypedFieldCodec {
26
+ /** The committed value shown as text under `pattern`. */
27
+ format(value: string, pattern: string): string;
28
+ /** Whether a value set from outside is one this field holds (anything else is "no value"). */
29
+ isValue(value: unknown): value is string;
30
+ /** A parsed value that can still not be committed (disabled, out of range) — bad input. */
31
+ isUsable(value: string): boolean;
32
+ /** Typed text read under `pattern`; `null` when it names no value. */
33
+ parse(text: string, pattern: string): null | string;
34
+ }
35
+ export interface UseTypedFieldOptions {
36
+ codec: TypedFieldCodec;
37
+ /** The custom element host: the model events dispatch from it. */
38
+ host: HTMLElement | null;
39
+ /** The field label (props.label). */
40
+ label: () => string;
41
+ /** Whether the label rests on top of the field (the resolved app default). */
42
+ labelOnTop: Readonly<Ref<boolean>>;
43
+ /** The typing mask derived from `pattern`. */
44
+ mask: Readonly<Ref<MaskSlot[]>>;
45
+ /** The end inputs' accessible names under `range`. */
46
+ names: () => {
47
+ end: string;
48
+ start: string;
49
+ };
50
+ /** Fired on every commit of typed text, as typed — the host's `change:text`. */
51
+ onTextCommit: (text: TypedFieldText) => void;
52
+ /** Alt+↓ in an input, after committing its text: open the panel. */
53
+ onOpenRequest: () => void;
54
+ /** The display and parse pattern. */
55
+ pattern: Readonly<Ref<string>>;
56
+ /** The consumer's placeholder (props.placeholder). */
57
+ placeholder: () => string;
58
+ /** Whether the field holds a start and an end. */
59
+ range: Readonly<Ref<boolean>>;
60
+ /** What a committed range with its start after its end becomes: swapped, or kept as typed. */
61
+ reversed: 'keep' | 'swap';
62
+ /** The host's `value` prop. */
63
+ value: () => unknown;
64
+ }
65
+ export declare const useTypedField: (options: UseTypedFieldOptions) => {
66
+ anchor: import("vue").ShallowRef<HTMLElement | null, HTMLElement | null>;
67
+ badEnd: Ref<boolean, boolean>;
68
+ badInput: import("vue").ComputedRef<boolean>;
69
+ badStart: Ref<boolean, boolean>;
70
+ commitAll: () => void;
71
+ commitText: (end: TypedFieldEnd) => void;
72
+ commitValue: (next: TypedFieldEnds) => void;
73
+ endInput: import("vue").ShallowRef<HTMLInputElement | null, HTMLInputElement | null>;
74
+ endText: Ref<string, string>;
75
+ ends: Ref<{
76
+ end: null | string;
77
+ start: null | string;
78
+ }, TypedFieldEnds | {
79
+ end: null | string;
80
+ start: null | string;
81
+ }>;
82
+ field: import("vue").ShallowRef<HTMLElement | null, HTMLElement | null>;
83
+ focused: Ref<boolean, boolean>;
84
+ hasContent: import("vue").ComputedRef<boolean>;
85
+ hasText: import("vue").ComputedRef<boolean>;
86
+ inputLabel: (end: TypedFieldEnd) => string | undefined;
87
+ inputOf: (end: TypedFieldEnd) => HTMLInputElement | null;
88
+ lastInput: Ref<TypedFieldEnd, TypedFieldEnd>;
89
+ onClear: (event?: Event) => void;
90
+ onFocusOut: (event: FocusEvent) => void;
91
+ onKeyDown: (end: TypedFieldEnd, event: KeyboardEvent) => void;
92
+ onTextInput: (end: TypedFieldEnd, event: Event) => void;
93
+ placeholder: import("vue").ComputedRef<string | undefined>;
94
+ range: Readonly<Ref<boolean, boolean>>;
95
+ showSeparator: import("vue").ComputedRef<boolean>;
96
+ startInput: import("vue").ShallowRef<HTMLInputElement | null, HTMLInputElement | null>;
97
+ startText: Ref<string, string>;
98
+ startWidth: import("vue").ComputedRef<{
99
+ width: string;
100
+ } | undefined>;
101
+ };
102
+ /** The state `TypedField.vue` renders. */
103
+ export type TypedField = ReturnType<typeof useTypedField>;