@cscfi/csc-ui 4.0.0-alpha.27 → 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,7 +4,7 @@ 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, CDatePickerValue, CDatePickerWeekday, } from './components/c-date-picker/CDatePicker.vue';
7
+ export type { CDatePickerDisabledDate, CDatePickerProps, CDatePickerRange, CDatePickerText, CDatePickerTexts, CDatePickerType, CDatePickerValue, CDatePickerWeekday, } from './components/c-date-picker/CDatePicker.vue';
8
8
  export type { CIconButtonProps, CIconButtonSize, } from './components/c-icon-button/CIconButton.vue';
9
9
  export type { CLoginCardActionsAlign, CLoginCardActionsJustify, CLoginCardActionsProps, } from './components/c-login-card-actions/CLoginCardActions.vue';
10
10
  export type { CLoginCardBlendMode, CLoginCardProps, } from './components/c-login-card/CLoginCard.vue';
@@ -19,6 +19,7 @@ export type { CTabsJustify, CTabsProps } from './components/c-tabs/CTabs.vue';
19
19
  export type { CTagProps, CTagSize } from './components/c-tag/CTag.vue';
20
20
  export type { CTagsProps, CTagsSize } from './components/c-tags/CTags.vue';
21
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';
22
23
  export type { CToastProps } from './components/c-toast/CToast.vue';
23
24
  export type { CToastsHorizontal, CToastsProps, CToastsVertical, } from './components/c-toasts/CToasts.vue';
24
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
+ };
@@ -12,6 +12,11 @@
12
12
  * plain text. A typed character that is the next literal (or one of its
13
13
  * `aliases`) is consumed as that literal.
14
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
+ *
15
20
  * An **optional section** (`[…]`, trailing only) holds optional slots: its
16
21
  * tokens take zero or one character (`min: 0`) and its literals are marked
17
22
  * `optional`. Completeness and the mask guide count required slots only.
@@ -49,6 +54,10 @@ export type MaskSlot = {
49
54
  max: number;
50
55
  /** `0` for an optional token. */
51
56
  min: number;
57
+ } | {
58
+ kind: 'word';
59
+ /** The words the slot takes, matched case-insensitively and shown as written here. */
60
+ words: string[];
52
61
  };
53
62
  /**
54
63
  * Compile a `c-text-field` mask: `#` a digit, `A` a letter, `*` a letter or
@@ -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>;
@@ -15,6 +15,7 @@ import type { CDataTableCellContent, CDataTableColumn, CDataTableExpandedContext
15
15
  import type { CDatePickerDisabledDate, CDatePickerText, CDatePickerTexts, CDatePickerValue } from './components/c-date-picker/CDatePicker.vue';
16
16
  import type { CPaginationOptions } from './components/c-pagination/CPagination.vue';
17
17
  import type { CSelectTexts, CSelectValue } from './components/c-select/CSelect.vue';
18
+ import type { CTimePickerText, CTimePickerTexts, CTimePickerValue } from './components/c-time-picker/CTimePicker.vue';
18
19
  import type { CTreeSelectFilter, CTreeSelectItem, CTreeSelectTexts, CTreeSelectValue } from './components/c-tree-select/CTreeSelect.vue';
19
20
  import type { CSelectItem, CToastMessage } from './types';
20
21
  type AccordionPrimitive = number | string;
@@ -543,7 +544,7 @@ export interface CDatePickerElementEventMap {
543
544
  'update:value': CustomEvent<CDatePickerValue>;
544
545
  }
545
546
  /** A date field that takes a typed date, or opens a calendar panel for picking one, or a start and end date under `range`. */
546
- export interface CDatePickerElement extends Omit<HTMLElement, 'clearable' | 'disabled' | 'disabledDates' | 'errorMessage' | 'firstDayOfWeek' | 'format' | 'hideDetails' | 'hint' | 'hostId' | 'isDateDisabled' | 'label' | 'labelOnTop' | 'max' | 'min' | 'name' | 'placeholder' | 'range' | 'required' | 'shadow' | 'showWeekNumbers' | 'size' | 'texts' | 'valid' | 'value'> {
547
+ export interface CDatePickerElement extends Omit<HTMLElement, 'clearable' | 'disabled' | 'disabledDates' | 'errorMessage' | 'firstDayOfWeek' | 'format' | 'hideDetails' | 'hint' | 'hostId' | 'isDateDisabled' | 'label' | 'labelOnTop' | 'max' | 'min' | 'name' | 'placeholder' | 'range' | 'required' | 'shadow' | 'showWeekNumbers' | 'size' | 'texts' | 'type' | 'valid' | 'value'> {
547
548
  /** Make the value clearable */
548
549
  clearable?: boolean;
549
550
  /** Disable the field */
@@ -616,11 +617,16 @@ export interface CDatePickerElement extends Omit<HTMLElement, 'clearable' | 'dis
616
617
  * bind as a DOM property
617
618
  */
618
619
  texts?: CDatePickerTexts;
620
+ /**
621
+ * What the field picks: a calendar date, or a year and a month
622
+ * (`'YYYY-MM'`)
623
+ */
624
+ type?: 'date' | 'month';
619
625
  /** Set the validity of the field */
620
626
  valid?: boolean;
621
627
  /**
622
- * The date as an ISO `YYYY-MM-DD` string, or `{ start, end }` under
623
- * `range`; `null` when empty
628
+ * The date as an ISO `YYYY-MM-DD` string (an ISO `YYYY-MM` month under
629
+ * `type="month"`), or `{ start, end }` under `range`; `null` when empty
624
630
  */
625
631
  value?: CDatePickerValue;
626
632
  /** Whether the committed text names no date that can be picked — the value is then `null` (CONTEXT.md "Bad input"). */
@@ -1831,6 +1837,99 @@ export interface CTextFieldElement extends Omit<HTMLElement, 'autocomplete' | 'a
1831
1837
  removeEventListener<K extends keyof CTextFieldElementEventMap>(type: K, listener: (this: CTextFieldElement, ev: CTextFieldElementEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
1832
1838
  removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
1833
1839
  }
1840
+ /** Events dispatched by `<c-time-picker>`. */
1841
+ export interface CTimePickerElementEventMap {
1842
+ /**
1843
+ * Fired when the value changes — a row is picked or moved to in a column,
1844
+ * typed text is committed, or the field is cleared — carrying the new
1845
+ * value: an ISO `HH:mm` time, `{ start, end }` under `range`, or `null`.
1846
+ */
1847
+ change: CustomEvent<CTimePickerValue>;
1848
+ /**
1849
+ * Fired on every commit of typed text (Enter or leaving the input) with the
1850
+ * text as typed — `{ start, end }` under `range`. Read `badInput` to tell
1851
+ * whether it named a time that can be picked.
1852
+ */
1853
+ 'change:text': CustomEvent<CTimePickerText>;
1854
+ /**
1855
+ * Native bubbling input event dispatched alongside every value change so a
1856
+ * plain `v-model` stays in sync. Carries no detail.
1857
+ */
1858
+ input: CustomEvent<void>;
1859
+ /** Fired alongside `change` with the same detail — the `v-model` contract. */
1860
+ 'update:value': CustomEvent<CTimePickerValue>;
1861
+ }
1862
+ /** A time field that takes a typed time, or opens hour and minute columns for picking one, or a start and end time under `range`. */
1863
+ export interface CTimePickerElement extends Omit<HTMLElement, 'clearable' | 'disabled' | 'errorMessage' | 'format' | 'hideDetails' | 'hint' | 'hostId' | 'label' | 'labelOnTop' | 'max' | 'min' | 'minuteStep' | 'name' | 'placeholder' | 'range' | 'required' | 'shadow' | 'size' | 'texts' | 'valid' | 'value'> {
1864
+ /** Make the value clearable */
1865
+ clearable?: boolean;
1866
+ /** Disable the field */
1867
+ disabled?: boolean;
1868
+ /** Error message shown in place of the hint while the field is invalid */
1869
+ errorMessage?: string;
1870
+ /**
1871
+ * How times are shown and read from typing: a pattern of the tokens `H`,
1872
+ * `HH` (24-hour), `h`, `hh` (12-hour, with the period `a`) and `mm` with
1873
+ * any separators, e.g. `HH:mm` or `h:mm a`
1874
+ */
1875
+ format?: string;
1876
+ /** Hide the hint and error messages */
1877
+ hideDetails?: boolean;
1878
+ /** Hint text for the field */
1879
+ hint?: string;
1880
+ /** Id of the element */
1881
+ hostId?: string;
1882
+ /** Element label */
1883
+ label?: string;
1884
+ /** Label on top of the field */
1885
+ labelOnTop?: boolean;
1886
+ /** The latest time that can be picked or typed, as an ISO `HH:mm` time */
1887
+ max?: string;
1888
+ /**
1889
+ * The earliest time that can be picked or typed, as an ISO `HH:mm` time;
1890
+ * a `min` after `max` is invalid and both are ignored
1891
+ */
1892
+ min?: string;
1893
+ /**
1894
+ * Minutes between the minute column's rows; typed times need not fall on
1895
+ * the step
1896
+ */
1897
+ minuteStep?: number;
1898
+ /** Input field name */
1899
+ name?: string;
1900
+ /** Placeholder of the input; the `format` pattern when empty */
1901
+ placeholder?: string;
1902
+ /**
1903
+ * Pick a range: the value becomes `{ start, end }` and the field holds two
1904
+ * inputs
1905
+ */
1906
+ range?: boolean;
1907
+ /** Set the field as required */
1908
+ required?: boolean;
1909
+ /** Shadow variant */
1910
+ shadow?: boolean;
1911
+ /** Field height: the 52px default (the shared control height) or the 36px `small` box */
1912
+ size?: 'default' | 'small';
1913
+ /**
1914
+ * UI text overrides (i18n), merged over the AM/PM texts `Intl` gives for
1915
+ * the page's `lang` and the English defaults. Objects have no attribute
1916
+ * form — bind as a DOM property
1917
+ */
1918
+ texts?: CTimePickerTexts;
1919
+ /** Set the validity of the field */
1920
+ valid?: boolean;
1921
+ /**
1922
+ * The time as an ISO `HH:mm` string on a 24-hour clock, or `{ start, end }`
1923
+ * under `range`; `null` when empty
1924
+ */
1925
+ value?: CTimePickerValue;
1926
+ /** Whether the committed text names no time that can be picked — the value is then `null` (CONTEXT.md "Bad input"). */
1927
+ readonly badInput: boolean;
1928
+ addEventListener<K extends keyof CTimePickerElementEventMap>(type: K, listener: (this: CTimePickerElement, ev: CTimePickerElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
1929
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
1930
+ removeEventListener<K extends keyof CTimePickerElementEventMap>(type: K, listener: (this: CTimePickerElement, ev: CTimePickerElementEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
1931
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
1932
+ }
1834
1933
  /** Events dispatched by `<c-toast>`. */
1835
1934
  export interface CToastElementEventMap {
1836
1935
  /**
@@ -2023,6 +2122,7 @@ export interface AppDefaults {
2023
2122
  'c-number-field'?: Partial<Pick<CNumberFieldElement, 'decimalSeparator' | 'decimals' | 'fixedDecimals' | 'groupSeparator' | 'hideDetails' | 'labelOnTop' | 'shadow' | 'size'>>;
2024
2123
  'c-select'?: Partial<Pick<CSelectElement, 'hideDetails' | 'itemsPerPage' | 'labelOnTop' | 'shadow' | 'size' | 'texts'>>;
2025
2124
  'c-text-field'?: Partial<Pick<CTextFieldElement, 'hideDetails' | 'labelOnTop' | 'shadow' | 'size'>>;
2125
+ 'c-time-picker'?: Partial<Pick<CTimePickerElement, 'format' | 'hideDetails' | 'labelOnTop' | 'shadow' | 'size' | 'texts'>>;
2026
2126
  'c-tree-select'?: Partial<Pick<CTreeSelectElement, 'hideDetails' | 'itemsPerPage' | 'labelOnTop' | 'shadow' | 'size' | 'texts'>>;
2027
2127
  }
2028
2128
  /** Runtime allow-list behind `applyDefaults()` validation — the same data as `AppDefaults`. */
@@ -2033,10 +2133,11 @@ export declare const DEFAULTABLE_PROPS: {
2033
2133
  readonly 'c-number-field': readonly ["decimalSeparator", "decimals", "fixedDecimals", "groupSeparator", "hideDetails", "labelOnTop", "shadow", "size"];
2034
2134
  readonly 'c-select': readonly ["hideDetails", "itemsPerPage", "labelOnTop", "shadow", "size", "texts"];
2035
2135
  readonly 'c-text-field': readonly ["hideDetails", "labelOnTop", "shadow", "size"];
2136
+ readonly 'c-time-picker': readonly ["format", "hideDetails", "labelOnTop", "shadow", "size", "texts"];
2036
2137
  readonly 'c-tree-select': readonly ["hideDetails", "itemsPerPage", "labelOnTop", "shadow", "size", "texts"];
2037
2138
  };
2038
2139
  /** Tags dispatching the v-model contract event `update:value` — the value controls (CONTEXT.md). */
2039
- export declare const VALUE_TAGS: readonly ["c-accordion", "c-autocomplete", "c-button-group", "c-checkbox", "c-date-picker", "c-modal", "c-number-field", "c-otp-input", "c-pagination", "c-radio-group", "c-select", "c-slider", "c-switch", "c-tabs", "c-text-field", "c-tree-select"];
2140
+ export declare const VALUE_TAGS: readonly ["c-accordion", "c-autocomplete", "c-button-group", "c-checkbox", "c-date-picker", "c-modal", "c-number-field", "c-otp-input", "c-pagination", "c-radio-group", "c-select", "c-slider", "c-switch", "c-tabs", "c-text-field", "c-time-picker", "c-tree-select"];
2040
2141
  declare global {
2041
2142
  interface HTMLElementTagNameMap {
2042
2143
  'c-accordion': CAccordionElement;
@@ -2108,6 +2209,7 @@ declare global {
2108
2209
  'c-tag': CTagElement;
2109
2210
  'c-tags': CTagsElement;
2110
2211
  'c-text-field': CTextFieldElement;
2212
+ 'c-time-picker': CTimePickerElement;
2111
2213
  'c-toast': CToastElement;
2112
2214
  'c-toasts': CToastsElement;
2113
2215
  'c-toolbar': CToolbarElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cscfi/csc-ui",
3
- "version": "4.0.0-alpha.27",
3
+ "version": "4.0.0-alpha.28",
4
4
  "description": "Vue 3-based replacement for @cscfi/csc-ui — same custom element tag names, Vue v-model contract.",
5
5
  "type": "module",
6
6
  "main": "./dist/csc-ui.js",