@4sh/ui-kit 0.9.0 → 0.11.0
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/README.fr.md +10 -9
- package/README.md +10 -9
- package/fesm2022/4sh-ui-kit-base-ui-image.mjs +338 -14
- package/fesm2022/4sh-ui-kit-base-ui-image.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-forms-ui-datepicker.mjs +1 -76
- package/fesm2022/4sh-ui-kit-forms-ui-datepicker.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-forms-ui-input-date.mjs +225 -0
- package/fesm2022/4sh-ui-kit-forms-ui-input-date.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-forms.mjs +99 -1
- package/fesm2022/4sh-ui-kit-forms.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-informative-ui-alert.mjs +2 -2
- package/fesm2022/4sh-ui-kit-informative-ui-alert.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-informative-ui-toast.mjs +2 -2
- package/fesm2022/4sh-ui-kit-informative-ui-toast.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-layout-ui-bottom-sheet.mjs +3 -27
- package/fesm2022/4sh-ui-kit-layout-ui-bottom-sheet.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-layout-ui-drawer.mjs +3 -27
- package/fesm2022/4sh-ui-kit-layout-ui-drawer.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-layout-ui-modal.mjs +3 -27
- package/fesm2022/4sh-ui-kit-layout-ui-modal.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-navigation-ui-sidebar.mjs +1 -25
- package/fesm2022/4sh-ui-kit-navigation-ui-sidebar.mjs.map +1 -1
- package/fesm2022/4sh-ui-kit-overlay.mjs +60 -2
- package/fesm2022/4sh-ui-kit-overlay.mjs.map +1 -1
- package/mcp/data/text-search-docs.json +240 -10
- package/mcp/data/ui-config.json +835 -41
- package/mcp/package.json +1 -1
- package/package.json +5 -1
- package/styles/component-vars.scss +54 -1
- package/types/4sh-ui-kit-base-ui-image.d.ts +151 -6
- package/types/4sh-ui-kit-forms-ui-input-date.d.ts +132 -0
- package/types/4sh-ui-kit-forms.d.ts +43 -1
- package/types/4sh-ui-kit-overlay.d.ts +35 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, numberAttribute, booleanAttribute, output, contentChild, viewChild, computed, forwardRef, Component } from '@angular/core';
|
|
3
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
4
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
5
|
+
import { BaseFormField, startOfDay, toIsoTime, toIsoDateTime, toIsoDate, parseIsoTime, parseIsoDateTime, parseIsoDate } from '@4sh/ui-kit/forms';
|
|
6
|
+
import { UiField } from '@4sh/ui-kit/forms/ui-field';
|
|
7
|
+
import { UiIcon } from '@4sh/ui-kit/base/ui-icon';
|
|
8
|
+
|
|
9
|
+
/** `mode` → the native `type` that draws the OS picker. */
|
|
10
|
+
const NATIVE_TYPE = {
|
|
11
|
+
date: 'date',
|
|
12
|
+
time: 'time',
|
|
13
|
+
datetime: 'datetime-local',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* ui-input-date — **native** date/time field on the `ui-field` shell (label + box + helper).
|
|
17
|
+
*
|
|
18
|
+
* The picker belongs to the OS: the system wheel on mobile — which no overlay matches —
|
|
19
|
+
* and the browser's own calendar on desktop. That is the whole reason this component
|
|
20
|
+
* exists next to [`ui-datepicker`](../ui-datepicker), which owns the opposite trade: a
|
|
21
|
+
* calendar carried by the design system, with ranges, multi-month and inline modes.
|
|
22
|
+
*
|
|
23
|
+
* It is a sibling of `ui-input`, not a variant of it: three things a text field cannot do
|
|
24
|
+
* are settled here.
|
|
25
|
+
*
|
|
26
|
+
* 1. **The value is a date, not a string.** `valueType` commits to `Date` or to an ISO
|
|
27
|
+
* string, exactly as `ui-datepicker` does — that alignment is what lets a host branch
|
|
28
|
+
* between the two on viewport without converting anything.
|
|
29
|
+
* 2. **It emits on `change`, never on `input`.** A native temporal control blanks its own
|
|
30
|
+
* value while the entry is incomplete, so an `input`-driven field fires a burst of
|
|
31
|
+
* empty values as the user types — indistinguishable from clearing the field, and quite
|
|
32
|
+
* visible on an autosave or a dependent control.
|
|
33
|
+
* 3. **The label stays raised.** The browser draws its own `jj/mm/aaaa` template in the
|
|
34
|
+
* box, so a floating label at rest would land on top of it.
|
|
35
|
+
*
|
|
36
|
+
* No `placeholder`: the browser ignores it on these types, that template holding the spot.
|
|
37
|
+
*
|
|
38
|
+
* Standalone, `[(ngModel)]` or reactive forms (ControlValueAccessor via BaseFormField).
|
|
39
|
+
*/
|
|
40
|
+
class UiInputDate extends BaseFormField {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
/** Granularity: a day, a time of day, or both. */
|
|
44
|
+
this.mode = input('date', /* @ts-ignore */
|
|
45
|
+
...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
46
|
+
/**
|
|
47
|
+
* Shape of the emitted value: `'date'` (a plain `Date`) or `'iso'` (`yyyy-MM-dd`, or
|
|
48
|
+
* `yyyy-MM-ddTHH:mm` as soon as a time is part of it). Incoming values are accepted in
|
|
49
|
+
* **either** shape whatever this says — only the emitted side commits.
|
|
50
|
+
*/
|
|
51
|
+
this.valueType = input('date', /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "valueType" }] : /* istanbul ignore next */ []));
|
|
53
|
+
/** Earliest accepted value, as a `Date` or in the ISO shape of the current `mode`. */
|
|
54
|
+
this.min = input(/* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [undefined, { debugName: "min" }] : /* istanbul ignore next */ []));
|
|
56
|
+
/** Latest accepted value, same two shapes as {@link min}. */
|
|
57
|
+
this.max = input(/* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [undefined, { debugName: "max" }] : /* istanbul ignore next */ []));
|
|
59
|
+
/**
|
|
60
|
+
* Native `step`: days on `date`, **seconds** on `time` / `datetime` (`900` = quarters of
|
|
61
|
+
* an hour; the browser's own default is `60`, i.e. whole minutes).
|
|
62
|
+
*/
|
|
63
|
+
this.step = input(undefined, { ...(ngDevMode ? { debugName: "step" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
64
|
+
this.icon = input(/* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
66
|
+
this.showIcon = input(true, { ...(ngDevMode ? { debugName: "showIcon" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
67
|
+
/** Accessible name of the picker button. Defaults per {@link mode}. */
|
|
68
|
+
this.iconAriaLabel = input(/* @ts-ignore */
|
|
69
|
+
...(ngDevMode ? [undefined, { debugName: "iconAriaLabel" }] : /* istanbul ignore next */ []));
|
|
70
|
+
/** Custom icon, as an input: same context as `ui-input`'s / `ui-datepicker`'s. */
|
|
71
|
+
this.iconTemplate = input(/* @ts-ignore */
|
|
72
|
+
...(ngDevMode ? [undefined, { debugName: "iconTemplate" }] : /* istanbul ignore next */ []));
|
|
73
|
+
/** Emitted when the browser commits a value — never mid-entry. */
|
|
74
|
+
this.valueChange = output();
|
|
75
|
+
/** Emitted when the field receives focus. */
|
|
76
|
+
this.inputFocus = output();
|
|
77
|
+
/** Emitted when the field loses focus. */
|
|
78
|
+
this.inputBlur = output();
|
|
79
|
+
/** Custom icon: `<ng-template #icon let-name let-size="size">`. */
|
|
80
|
+
this.iconTemplateContent = contentChild('icon', /* @ts-ignore */
|
|
81
|
+
...(ngDevMode ? [{ debugName: "iconTemplateContent" }] : /* istanbul ignore next */ []));
|
|
82
|
+
/** @ignore */
|
|
83
|
+
this.inputEl = viewChild.required('inputEl', /* @ts-ignore */
|
|
84
|
+
...(ngDevMode ? [{ debugName: "inputEl" }] : /* istanbul ignore next */ []));
|
|
85
|
+
/** @ignore Icon size aligned with the field size, same pairing as `ui-input`. */
|
|
86
|
+
this.iconSize = computed(() => (this.size() === 'small' ? 'sm' : 'md'), /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "iconSize" }] : /* istanbul ignore next */ []));
|
|
88
|
+
/** @ignore Calendar, or clock when the field only carries a time. */
|
|
89
|
+
this.resolvedIcon = computed(() => this.icon() ?? (this.mode() === 'time' ? 'clock' : 'calendar'), /* @ts-ignore */
|
|
90
|
+
...(ngDevMode ? [{ debugName: "resolvedIcon" }] : /* istanbul ignore next */ []));
|
|
91
|
+
/** @ignore */
|
|
92
|
+
this.resolvedIconAriaLabel = computed(() => this.iconAriaLabel() ??
|
|
93
|
+
(this.mode() === 'time' ? "Ouvrir le sélecteur d'heure" : 'Ouvrir le calendrier'), /* @ts-ignore */
|
|
94
|
+
...(ngDevMode ? [{ debugName: "resolvedIconAriaLabel" }] : /* istanbul ignore next */ []));
|
|
95
|
+
/** @ignore Input wins over the projected `#icon` template. */
|
|
96
|
+
this.resolvedIconTemplate = computed(() => this.iconTemplate() ?? this.iconTemplateContent(), /* @ts-ignore */
|
|
97
|
+
...(ngDevMode ? [{ debugName: "resolvedIconTemplate" }] : /* istanbul ignore next */ []));
|
|
98
|
+
/** @ignore */
|
|
99
|
+
this.iconContext = computed(() => ({
|
|
100
|
+
$implicit: this.resolvedIcon(),
|
|
101
|
+
size: this.iconSize(),
|
|
102
|
+
disabled: this.isDisabled(),
|
|
103
|
+
}), /* @ts-ignore */
|
|
104
|
+
...(ngDevMode ? [{ debugName: "iconContext" }] : /* istanbul ignore next */ []));
|
|
105
|
+
/** @ignore The native `type` the OS picker hangs off. */
|
|
106
|
+
this.nativeType = computed(() => NATIVE_TYPE[this.mode()], /* @ts-ignore */
|
|
107
|
+
...(ngDevMode ? [{ debugName: "nativeType" }] : /* istanbul ignore next */ []));
|
|
108
|
+
/** @ignore Whether the value carries a time — decides both serializers. */
|
|
109
|
+
this.hasTimeComponent = computed(() => this.mode() !== 'date', /* @ts-ignore */
|
|
110
|
+
...(ngDevMode ? [{ debugName: "hasTimeComponent" }] : /* istanbul ignore next */ []));
|
|
111
|
+
/** @ignore Model → the string the native control reads, `''` when there is no value. */
|
|
112
|
+
this.nativeValue = computed(() => {
|
|
113
|
+
const date = this.parseValue(this.modelValue() ?? null);
|
|
114
|
+
return date ? this.toNative(date) : '';
|
|
115
|
+
}, /* @ts-ignore */
|
|
116
|
+
...(ngDevMode ? [{ debugName: "nativeValue" }] : /* istanbul ignore next */ []));
|
|
117
|
+
/** @ignore Bounds go through the same serializer as the value: a caller may hand a `Date`
|
|
118
|
+
* or an already-native string, the attribute only ever sees the latter. */
|
|
119
|
+
this.nativeMin = computed(() => this.toNativeBound(this.min()), /* @ts-ignore */
|
|
120
|
+
...(ngDevMode ? [{ debugName: "nativeMin" }] : /* istanbul ignore next */ []));
|
|
121
|
+
/** @ignore */
|
|
122
|
+
this.nativeMax = computed(() => this.toNativeBound(this.max()), /* @ts-ignore */
|
|
123
|
+
...(ngDevMode ? [{ debugName: "nativeMax" }] : /* istanbul ignore next */ []));
|
|
124
|
+
/** @ignore Full `aria-describedby`: the message id, only when a message is rendered. */
|
|
125
|
+
this.resolvedAriaDescribedBy = computed(() => this.displayMessage() ? this.messageId() : null, /* @ts-ignore */
|
|
126
|
+
...(ngDevMode ? [{ debugName: "resolvedAriaDescribedBy" }] : /* istanbul ignore next */ []));
|
|
127
|
+
}
|
|
128
|
+
/** Focuses the field. */
|
|
129
|
+
focus(options) {
|
|
130
|
+
this.inputEl().nativeElement.focus(options);
|
|
131
|
+
}
|
|
132
|
+
openPicker() {
|
|
133
|
+
if (this.isDisabled() || this.readonly())
|
|
134
|
+
return;
|
|
135
|
+
const el = this.inputEl().nativeElement;
|
|
136
|
+
el.focus();
|
|
137
|
+
try {
|
|
138
|
+
el.showPicker();
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
/* no picker to show */
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** Native `<input>` element, for a composite host that needs direct DOM access. */
|
|
145
|
+
nativeInputElement() {
|
|
146
|
+
return this.inputEl().nativeElement;
|
|
147
|
+
}
|
|
148
|
+
/** @ignore */
|
|
149
|
+
uidPrefix() {
|
|
150
|
+
return 'ui-input-date';
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @ignore The browser committed a value — a complete one, or an empty one because the
|
|
154
|
+
* field was cleared. This is the only place a value leaves the component: `input` fires
|
|
155
|
+
* on every keystroke with the blanks in between, and is deliberately not listened to.
|
|
156
|
+
*/
|
|
157
|
+
onNativeChange() {
|
|
158
|
+
const raw = this.inputEl().nativeElement.value;
|
|
159
|
+
const date = raw ? this.fromNative(raw) : null;
|
|
160
|
+
const value = date ? this.serializeValue(date) : null;
|
|
161
|
+
this.modelValue.set(value);
|
|
162
|
+
this.emitChange(value);
|
|
163
|
+
this.valueChange.emit(value);
|
|
164
|
+
}
|
|
165
|
+
/** @ignore */
|
|
166
|
+
onBlur(event) {
|
|
167
|
+
this.emitTouch();
|
|
168
|
+
this.inputBlur.emit(event);
|
|
169
|
+
}
|
|
170
|
+
/** @ignore Internal `Date` → the shape `valueType` commits to. Mirrors `ui-datepicker`'s
|
|
171
|
+
* own `serializeValue`, down to the fresh instance: the caller never gets a reference it
|
|
172
|
+
* could mutate behind our back. */
|
|
173
|
+
serializeValue(date) {
|
|
174
|
+
if (this.valueType() === 'iso')
|
|
175
|
+
return this.toNative(date);
|
|
176
|
+
return this.hasTimeComponent() ? new Date(date) : startOfDay(date);
|
|
177
|
+
}
|
|
178
|
+
/** @ignore Incoming value, `Date` or ISO string, auto-detected — cloned when already a
|
|
179
|
+
* `Date`, symmetric with {@link serializeValue}. */
|
|
180
|
+
parseValue(value) {
|
|
181
|
+
if (value === undefined || value === null || value === '')
|
|
182
|
+
return null;
|
|
183
|
+
return value instanceof Date ? new Date(value) : this.fromNative(value);
|
|
184
|
+
}
|
|
185
|
+
/** @ignore `Date` → the exact string the native control of this `mode` accepts. */
|
|
186
|
+
toNative(date) {
|
|
187
|
+
if (this.mode() === 'time')
|
|
188
|
+
return toIsoTime(date);
|
|
189
|
+
return this.hasTimeComponent() ? toIsoDateTime(date) : toIsoDate(date);
|
|
190
|
+
}
|
|
191
|
+
/** @ignore The reverse. `null` on anything malformed — a bad value degrades to "no value"
|
|
192
|
+
* rather than throwing, the browser being the one that produced it. */
|
|
193
|
+
fromNative(value) {
|
|
194
|
+
if (this.mode() === 'time')
|
|
195
|
+
return parseIsoTime(value);
|
|
196
|
+
return this.hasTimeComponent() ? parseIsoDateTime(value) : parseIsoDate(value);
|
|
197
|
+
}
|
|
198
|
+
/** @ignore A bound is optional, and a string one is already native. */
|
|
199
|
+
toNativeBound(bound) {
|
|
200
|
+
if (!bound)
|
|
201
|
+
return null;
|
|
202
|
+
return bound instanceof Date ? this.toNative(bound) : bound;
|
|
203
|
+
}
|
|
204
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: UiInputDate, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
205
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: UiInputDate, isStandalone: true, selector: "ui-input-date", inputs: { mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, valueType: { classPropertyName: "valueType", publicName: "valueType", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, showIcon: { classPropertyName: "showIcon", publicName: "showIcon", isSignal: true, isRequired: false, transformFunction: null }, iconAriaLabel: { classPropertyName: "iconAriaLabel", publicName: "iconAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, iconTemplate: { classPropertyName: "iconTemplate", publicName: "iconTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", inputFocus: "inputFocus", inputBlur: "inputBlur" }, providers: [
|
|
206
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiInputDate), multi: true },
|
|
207
|
+
], queries: [{ propertyName: "iconTemplateContent", first: true, predicate: ["icon"], descendants: true, isSignal: true }], viewQueries: [{ propertyName: "inputEl", first: true, predicate: ["inputEl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<ui-field\n [label]=\"label()\"\n [for]=\"resolvedId()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [floatLabel]=\"floatLabel()\"\n [filled]=\"true\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n [showMessageIcon]=\"showMessageIcon()\"\n [messageIcon]=\"messageIcon()\"\n>\n <!-- `filled` is hard-coded above, and it is not a shortcut: the browser draws its own\n `jj/mm/aaaa` template in the box, so this field is never visually empty. A floating\n label at rest would sit on top of that template. -->\n <input\n #inputEl\n class=\"ui-input-date-native\"\n [class._small]=\"size() === 'small'\"\n [type]=\"nativeType()\"\n [id]=\"resolvedId()\"\n [value]=\"nativeValue()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [attr.name]=\"name() || null\"\n [attr.tabindex]=\"tabindex()\"\n [attr.min]=\"nativeMin()\"\n [attr.max]=\"nativeMax()\"\n [attr.step]=\"step() ?? null\"\n [attr.aria-label]=\"label() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"resolvedAriaDescribedBy()\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n (change)=\"onNativeChange()\"\n (focus)=\"inputFocus.emit($event)\"\n (blur)=\"onBlur($event)\"\n />\n\n @if (showIcon()) {\n <button\n uiFieldSuffix\n type=\"button\"\n tabindex=\"-1\"\n class=\"ui-input-date-action\"\n [attr.aria-label]=\"resolvedIconAriaLabel()\"\n [disabled]=\"isDisabled()\"\n (click)=\"openPicker()\"\n >\n @if (resolvedIconTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"iconContext()\" />\n } @else {\n <ui-icon [name]=\"resolvedIcon()\" [size]=\"iconSize()\" />\n }\n </button>\n }\n</ui-field>\n", styles: [".ui-input-date-native{flex:1 1 auto;align-self:stretch;min-width:0;margin:0;padding:0;border:none;border-radius:inherit;background:transparent;outline:none;font-family:var(--ui-form-field-font-family, var(--fontfamily-base));font-size:var(--size-typography-text-default);color:var(--ui-form-field-color, var(--form-high-content-default))}.ui-input-date-native:first-child{padding-inline-start:var(--ui-form-field-padding-x, var(--units-md))}.ui-input-date-native:last-child{padding-inline-end:var(--ui-form-field-padding-x, var(--units-md))}.ui-input-date-native{padding-block-start:calc(0px + var(--_field-inset-block-start, 0px))}.ui-input-date-native::placeholder{color:var(--ui-form-field-placeholder-color, var(--form-low-content-default));opacity:1}.ui-input-date-native:disabled{cursor:not-allowed;color:var(--ui-form-field-color-disabled, var(--form-high-content-disabled))}.ui-input-date-native._small{font-size:var(--ui-input-date-font-size-small, var(--size-typography-text-md))}.ui-input-date-native{-webkit-appearance:none;appearance:none}.ui-input-date-native::-webkit-date-and-time-value{text-align:left;margin:0}.ui-input-date-native::-webkit-calendar-picker-indicator{display:none}.ui-input-date-native{margin-inline-end:-2.5rem;clip-path:inset(0 2.5rem 0 0)}.ui-input-date-action{display:flex;align-items:center;justify-content:center;align-self:stretch;aspect-ratio:1;flex-shrink:0;padding:0;border:none;background:none;border-radius:0 calc(var(--ui-form-field-radius, var(--radius-sm)) - var(--ui-control-stroke-width, var(--stroke-default))) calc(var(--ui-form-field-radius, var(--radius-sm)) - var(--ui-control-stroke-width, var(--stroke-default))) 0;color:var(--ui-form-field-action-color, var(--form-low-content-default));cursor:pointer;transition:color var(--ui-control-transition-duration, var(--transition-default)) var(--ui-control-transition-easing, var(--transition-easeinout)),background-color var(--ui-control-transition-duration, var(--transition-default)) var(--ui-control-transition-easing, var(--transition-easeinout))}.ui-input-date-action:hover:not(:disabled){color:var(--ui-form-field-action-color-hover, var(--form-high-content-hover));background-color:var(--ui-form-field-action-surface-hover, var(--form-high-surface-hover))}.ui-input-date-action:focus-visible{outline:none;color:var(--ui-form-field-action-color-focus, var(--form-high-content-focused));background-color:var(--ui-form-field-action-surface-focus, var(--form-high-surface-focused))}.ui-input-date-action:disabled{cursor:not-allowed;color:var(--ui-form-field-action-color-disabled, var(--form-high-content-disabled))}:host-context([dir=rtl]) .ui-input-date-native{clip-path:inset(0 0 0 2.5rem)}:host-context([data-theme=dark]) .ui-input-date-native{color-scheme:dark}\n"], dependencies: [{ kind: "component", type: UiField, selector: "ui-field", inputs: ["label", "for", "required", "size", "level", "floatLabel", "filled", "disabled", "readonly", "multiline", "autoHeight", "message", "messageId", "showMessageIcon", "messageIcon", "hasFooter", "hasPrefix"] }, { kind: "component", type: UiIcon, selector: "ui-icon", inputs: ["name", "size", "type", "family", "decorative", "ariaLabel"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
208
|
+
}
|
|
209
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: UiInputDate, decorators: [{
|
|
210
|
+
type: Component,
|
|
211
|
+
args: [{ selector: 'ui-input-date', imports: [UiField, UiIcon, NgTemplateOutlet], providers: [
|
|
212
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiInputDate), multi: true },
|
|
213
|
+
], template: "<ui-field\n [label]=\"label()\"\n [for]=\"resolvedId()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [floatLabel]=\"floatLabel()\"\n [filled]=\"true\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n [showMessageIcon]=\"showMessageIcon()\"\n [messageIcon]=\"messageIcon()\"\n>\n <!-- `filled` is hard-coded above, and it is not a shortcut: the browser draws its own\n `jj/mm/aaaa` template in the box, so this field is never visually empty. A floating\n label at rest would sit on top of that template. -->\n <input\n #inputEl\n class=\"ui-input-date-native\"\n [class._small]=\"size() === 'small'\"\n [type]=\"nativeType()\"\n [id]=\"resolvedId()\"\n [value]=\"nativeValue()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [attr.name]=\"name() || null\"\n [attr.tabindex]=\"tabindex()\"\n [attr.min]=\"nativeMin()\"\n [attr.max]=\"nativeMax()\"\n [attr.step]=\"step() ?? null\"\n [attr.aria-label]=\"label() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"resolvedAriaDescribedBy()\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n (change)=\"onNativeChange()\"\n (focus)=\"inputFocus.emit($event)\"\n (blur)=\"onBlur($event)\"\n />\n\n @if (showIcon()) {\n <button\n uiFieldSuffix\n type=\"button\"\n tabindex=\"-1\"\n class=\"ui-input-date-action\"\n [attr.aria-label]=\"resolvedIconAriaLabel()\"\n [disabled]=\"isDisabled()\"\n (click)=\"openPicker()\"\n >\n @if (resolvedIconTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"iconContext()\" />\n } @else {\n <ui-icon [name]=\"resolvedIcon()\" [size]=\"iconSize()\" />\n }\n </button>\n }\n</ui-field>\n", styles: [".ui-input-date-native{flex:1 1 auto;align-self:stretch;min-width:0;margin:0;padding:0;border:none;border-radius:inherit;background:transparent;outline:none;font-family:var(--ui-form-field-font-family, var(--fontfamily-base));font-size:var(--size-typography-text-default);color:var(--ui-form-field-color, var(--form-high-content-default))}.ui-input-date-native:first-child{padding-inline-start:var(--ui-form-field-padding-x, var(--units-md))}.ui-input-date-native:last-child{padding-inline-end:var(--ui-form-field-padding-x, var(--units-md))}.ui-input-date-native{padding-block-start:calc(0px + var(--_field-inset-block-start, 0px))}.ui-input-date-native::placeholder{color:var(--ui-form-field-placeholder-color, var(--form-low-content-default));opacity:1}.ui-input-date-native:disabled{cursor:not-allowed;color:var(--ui-form-field-color-disabled, var(--form-high-content-disabled))}.ui-input-date-native._small{font-size:var(--ui-input-date-font-size-small, var(--size-typography-text-md))}.ui-input-date-native{-webkit-appearance:none;appearance:none}.ui-input-date-native::-webkit-date-and-time-value{text-align:left;margin:0}.ui-input-date-native::-webkit-calendar-picker-indicator{display:none}.ui-input-date-native{margin-inline-end:-2.5rem;clip-path:inset(0 2.5rem 0 0)}.ui-input-date-action{display:flex;align-items:center;justify-content:center;align-self:stretch;aspect-ratio:1;flex-shrink:0;padding:0;border:none;background:none;border-radius:0 calc(var(--ui-form-field-radius, var(--radius-sm)) - var(--ui-control-stroke-width, var(--stroke-default))) calc(var(--ui-form-field-radius, var(--radius-sm)) - var(--ui-control-stroke-width, var(--stroke-default))) 0;color:var(--ui-form-field-action-color, var(--form-low-content-default));cursor:pointer;transition:color var(--ui-control-transition-duration, var(--transition-default)) var(--ui-control-transition-easing, var(--transition-easeinout)),background-color var(--ui-control-transition-duration, var(--transition-default)) var(--ui-control-transition-easing, var(--transition-easeinout))}.ui-input-date-action:hover:not(:disabled){color:var(--ui-form-field-action-color-hover, var(--form-high-content-hover));background-color:var(--ui-form-field-action-surface-hover, var(--form-high-surface-hover))}.ui-input-date-action:focus-visible{outline:none;color:var(--ui-form-field-action-color-focus, var(--form-high-content-focused));background-color:var(--ui-form-field-action-surface-focus, var(--form-high-surface-focused))}.ui-input-date-action:disabled{cursor:not-allowed;color:var(--ui-form-field-action-color-disabled, var(--form-high-content-disabled))}:host-context([dir=rtl]) .ui-input-date-native{clip-path:inset(0 0 0 2.5rem)}:host-context([data-theme=dark]) .ui-input-date-native{color-scheme:dark}\n"] }]
|
|
214
|
+
}], propDecorators: { mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], valueType: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueType", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], showIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "showIcon", required: false }] }], iconAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconAriaLabel", required: false }] }], iconTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconTemplate", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], inputFocus: [{ type: i0.Output, args: ["inputFocus"] }], inputBlur: [{ type: i0.Output, args: ["inputBlur"] }], iconTemplateContent: [{ type: i0.ContentChild, args: ['icon', { isSignal: true }] }], inputEl: [{ type: i0.ViewChild, args: ['inputEl', { isSignal: true }] }] } });
|
|
215
|
+
|
|
216
|
+
/*
|
|
217
|
+
* Public API Surface of ui-kit/ui-input-date
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Generated bundle index. Do not edit.
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
export { UiInputDate };
|
|
225
|
+
//# sourceMappingURL=4sh-ui-kit-forms-ui-input-date.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"4sh-ui-kit-forms-ui-input-date.mjs","sources":["../../../projects/ui-kit/forms/ui-input-date/src/lib/ui-input-date.ts","../../../projects/ui-kit/forms/ui-input-date/src/lib/ui-input-date.html","../../../projects/ui-kit/forms/ui-input-date/src/public-api.ts","../../../projects/ui-kit/forms/ui-input-date/src/4sh-ui-kit-forms-ui-input-date.ts"],"sourcesContent":["import {\n booleanAttribute,\n Component,\n computed,\n contentChild,\n ElementRef,\n forwardRef,\n input,\n numberAttribute,\n output,\n TemplateRef,\n viewChild,\n} from '@angular/core';\nimport { NgTemplateOutlet } from '@angular/common';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\nimport {\n BaseFormField,\n parseIsoDate,\n parseIsoDateTime,\n parseIsoTime,\n startOfDay,\n toIsoDate,\n toIsoDateTime,\n toIsoTime,\n} from '@4sh/ui-kit/forms';\nimport { UiField } from '@4sh/ui-kit/forms/ui-field';\nimport type { UiInputIconContext } from '@4sh/ui-kit/forms/ui-input';\nimport { UiIcon, type UiIconSize } from '@4sh/ui-kit/base/ui-icon';\n\n/** Granularity of the field — picks which native control the browser renders. */\nexport type InputDateMode = 'date' | 'time' | 'datetime';\n\n/**\n * Shape of the emitted value. **Identical to `ui-datepicker`'s**, so a host can swap one for\n * the other (native picker on mobile, overlay on desktop) without converting anything.\n */\nexport type InputDateValueType = 'date' | 'iso';\n\n/** Value carried by the field, whichever `valueType` is in force. */\nexport type InputDateValue = Date | string | null;\n\n/** `mode` → the native `type` that draws the OS picker. */\nconst NATIVE_TYPE: Record<InputDateMode, string> = {\n date: 'date',\n time: 'time',\n datetime: 'datetime-local',\n};\n\n/**\n * ui-input-date — **native** date/time field on the `ui-field` shell (label + box + helper).\n *\n * The picker belongs to the OS: the system wheel on mobile — which no overlay matches —\n * and the browser's own calendar on desktop. That is the whole reason this component\n * exists next to [`ui-datepicker`](../ui-datepicker), which owns the opposite trade: a\n * calendar carried by the design system, with ranges, multi-month and inline modes.\n *\n * It is a sibling of `ui-input`, not a variant of it: three things a text field cannot do\n * are settled here.\n *\n * 1. **The value is a date, not a string.** `valueType` commits to `Date` or to an ISO\n * string, exactly as `ui-datepicker` does — that alignment is what lets a host branch\n * between the two on viewport without converting anything.\n * 2. **It emits on `change`, never on `input`.** A native temporal control blanks its own\n * value while the entry is incomplete, so an `input`-driven field fires a burst of\n * empty values as the user types — indistinguishable from clearing the field, and quite\n * visible on an autosave or a dependent control.\n * 3. **The label stays raised.** The browser draws its own `jj/mm/aaaa` template in the\n * box, so a floating label at rest would land on top of it.\n *\n * No `placeholder`: the browser ignores it on these types, that template holding the spot.\n *\n * Standalone, `[(ngModel)]` or reactive forms (ControlValueAccessor via BaseFormField).\n */\n@Component({\n selector: 'ui-input-date',\n imports: [UiField, UiIcon, NgTemplateOutlet],\n templateUrl: './ui-input-date.html',\n styleUrl: './ui-input-date.scss',\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiInputDate), multi: true },\n ],\n})\nexport class UiInputDate extends BaseFormField<InputDateValue> {\n /** Granularity: a day, a time of day, or both. */\n mode = input<InputDateMode>('date');\n /**\n * Shape of the emitted value: `'date'` (a plain `Date`) or `'iso'` (`yyyy-MM-dd`, or\n * `yyyy-MM-ddTHH:mm` as soon as a time is part of it). Incoming values are accepted in\n * **either** shape whatever this says — only the emitted side commits.\n */\n valueType = input<InputDateValueType>('date');\n /** Earliest accepted value, as a `Date` or in the ISO shape of the current `mode`. */\n min = input<Date | string>();\n /** Latest accepted value, same two shapes as {@link min}. */\n max = input<Date | string>();\n /**\n * Native `step`: days on `date`, **seconds** on `time` / `datetime` (`900` = quarters of\n * an hour; the browser's own default is `60`, i.e. whole minutes).\n */\n step = input<number, unknown>(undefined, { transform: numberAttribute });\n\n icon = input<string>();\n showIcon = input(true, { transform: booleanAttribute });\n /** Accessible name of the picker button. Defaults per {@link mode}. */\n iconAriaLabel = input<string>();\n /** Custom icon, as an input: same context as `ui-input`'s / `ui-datepicker`'s. */\n iconTemplate = input<TemplateRef<UiInputIconContext>>();\n\n /** Emitted when the browser commits a value — never mid-entry. */\n valueChange = output<InputDateValue>();\n /** Emitted when the field receives focus. */\n inputFocus = output<FocusEvent>();\n /** Emitted when the field loses focus. */\n inputBlur = output<FocusEvent>();\n\n /** Custom icon: `<ng-template #icon let-name let-size=\"size\">`. */\n private readonly iconTemplateContent = contentChild<TemplateRef<UiInputIconContext>>('icon');\n\n /** @ignore */\n private readonly inputEl = viewChild.required<ElementRef<HTMLInputElement>>('inputEl');\n\n /** @ignore Icon size aligned with the field size, same pairing as `ui-input`. */\n protected readonly iconSize = computed<UiIconSize>(() => (this.size() === 'small' ? 'sm' : 'md'));\n /** @ignore Calendar, or clock when the field only carries a time. */\n protected readonly resolvedIcon = computed(\n () => this.icon() ?? (this.mode() === 'time' ? 'clock' : 'calendar'),\n );\n /** @ignore */\n protected readonly resolvedIconAriaLabel = computed(\n () =>\n this.iconAriaLabel() ??\n (this.mode() === 'time' ? \"Ouvrir le sélecteur d'heure\" : 'Ouvrir le calendrier'),\n );\n /** @ignore Input wins over the projected `#icon` template. */\n protected readonly resolvedIconTemplate = computed(\n () => this.iconTemplate() ?? this.iconTemplateContent(),\n );\n /** @ignore */\n protected readonly iconContext = computed<UiInputIconContext>(() => ({\n $implicit: this.resolvedIcon(),\n size: this.iconSize(),\n disabled: this.isDisabled(),\n }));\n\n /** @ignore The native `type` the OS picker hangs off. */\n protected readonly nativeType = computed(() => NATIVE_TYPE[this.mode()]);\n /** @ignore Whether the value carries a time — decides both serializers. */\n private readonly hasTimeComponent = computed(() => this.mode() !== 'date');\n\n /** @ignore Model → the string the native control reads, `''` when there is no value. */\n protected readonly nativeValue = computed(() => {\n const date = this.parseValue(this.modelValue() ?? null);\n return date ? this.toNative(date) : '';\n });\n /** @ignore Bounds go through the same serializer as the value: a caller may hand a `Date`\n * or an already-native string, the attribute only ever sees the latter. */\n protected readonly nativeMin = computed(() => this.toNativeBound(this.min()));\n /** @ignore */\n protected readonly nativeMax = computed(() => this.toNativeBound(this.max()));\n\n /** @ignore Full `aria-describedby`: the message id, only when a message is rendered. */\n protected readonly resolvedAriaDescribedBy = computed(() =>\n this.displayMessage() ? this.messageId() : null,\n );\n\n /** Focuses the field. */\n focus(options?: FocusOptions): void {\n this.inputEl().nativeElement.focus(options);\n }\n\n openPicker(): void {\n if (this.isDisabled() || this.readonly()) return;\n const el = this.inputEl().nativeElement;\n el.focus();\n try {\n el.showPicker();\n } catch {\n /* no picker to show */\n }\n }\n\n /** Native `<input>` element, for a composite host that needs direct DOM access. */\n nativeInputElement(): HTMLInputElement {\n return this.inputEl().nativeElement;\n }\n\n /** @ignore */\n protected override uidPrefix(): string {\n return 'ui-input-date';\n }\n\n /**\n * @ignore The browser committed a value — a complete one, or an empty one because the\n * field was cleared. This is the only place a value leaves the component: `input` fires\n * on every keystroke with the blanks in between, and is deliberately not listened to.\n */\n protected onNativeChange(): void {\n const raw = this.inputEl().nativeElement.value;\n const date = raw ? this.fromNative(raw) : null;\n const value = date ? this.serializeValue(date) : null;\n this.modelValue.set(value);\n this.emitChange(value);\n this.valueChange.emit(value);\n }\n\n /** @ignore */\n protected onBlur(event: FocusEvent): void {\n this.emitTouch();\n this.inputBlur.emit(event);\n }\n\n /** @ignore Internal `Date` → the shape `valueType` commits to. Mirrors `ui-datepicker`'s\n * own `serializeValue`, down to the fresh instance: the caller never gets a reference it\n * could mutate behind our back. */\n private serializeValue(date: Date): InputDateValue {\n if (this.valueType() === 'iso') return this.toNative(date);\n return this.hasTimeComponent() ? new Date(date) : startOfDay(date);\n }\n\n /** @ignore Incoming value, `Date` or ISO string, auto-detected — cloned when already a\n * `Date`, symmetric with {@link serializeValue}. */\n private parseValue(value: InputDateValue | undefined): Date | null {\n if (value === undefined || value === null || value === '') return null;\n return value instanceof Date ? new Date(value) : this.fromNative(value);\n }\n\n /** @ignore `Date` → the exact string the native control of this `mode` accepts. */\n private toNative(date: Date): string {\n if (this.mode() === 'time') return toIsoTime(date);\n return this.hasTimeComponent() ? toIsoDateTime(date) : toIsoDate(date);\n }\n\n /** @ignore The reverse. `null` on anything malformed — a bad value degrades to \"no value\"\n * rather than throwing, the browser being the one that produced it. */\n private fromNative(value: string): Date | null {\n if (this.mode() === 'time') return parseIsoTime(value);\n return this.hasTimeComponent() ? parseIsoDateTime(value) : parseIsoDate(value);\n }\n\n /** @ignore A bound is optional, and a string one is already native. */\n private toNativeBound(bound: Date | string | undefined): string | null {\n if (!bound) return null;\n return bound instanceof Date ? this.toNative(bound) : bound;\n }\n}\n","<ui-field\n [label]=\"label()\"\n [for]=\"resolvedId()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [floatLabel]=\"floatLabel()\"\n [filled]=\"true\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n [showMessageIcon]=\"showMessageIcon()\"\n [messageIcon]=\"messageIcon()\"\n>\n <!-- `filled` is hard-coded above, and it is not a shortcut: the browser draws its own\n `jj/mm/aaaa` template in the box, so this field is never visually empty. A floating\n label at rest would sit on top of that template. -->\n <input\n #inputEl\n class=\"ui-input-date-native\"\n [class._small]=\"size() === 'small'\"\n [type]=\"nativeType()\"\n [id]=\"resolvedId()\"\n [value]=\"nativeValue()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [attr.name]=\"name() || null\"\n [attr.tabindex]=\"tabindex()\"\n [attr.min]=\"nativeMin()\"\n [attr.max]=\"nativeMax()\"\n [attr.step]=\"step() ?? null\"\n [attr.aria-label]=\"label() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"resolvedAriaDescribedBy()\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n (change)=\"onNativeChange()\"\n (focus)=\"inputFocus.emit($event)\"\n (blur)=\"onBlur($event)\"\n />\n\n @if (showIcon()) {\n <button\n uiFieldSuffix\n type=\"button\"\n tabindex=\"-1\"\n class=\"ui-input-date-action\"\n [attr.aria-label]=\"resolvedIconAriaLabel()\"\n [disabled]=\"isDisabled()\"\n (click)=\"openPicker()\"\n >\n @if (resolvedIconTemplate(); as tpl) {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"iconContext()\" />\n } @else {\n <ui-icon [name]=\"resolvedIcon()\" [size]=\"iconSize()\" />\n }\n </button>\n }\n</ui-field>\n","/*\n * Public API Surface of ui-kit/ui-input-date\n */\n\nexport * from './lib/ui-input-date';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAyCA;AACA,MAAM,WAAW,GAAkC;AACjD,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,QAAQ,EAAE,gBAAgB;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AAUG,MAAO,WAAY,SAAQ,aAA6B,CAAA;AAT9D,IAAA,WAAA,GAAA;;;QAWE,IAAA,CAAA,IAAI,GAAG,KAAK,CAAgB,MAAM;iFAAC;AACnC;;;;AAIG;QACH,IAAA,CAAA,SAAS,GAAG,KAAK,CAAqB,MAAM;sFAAC;;AAE7C,QAAA,IAAA,CAAA,GAAG,GAAG,KAAK;2FAAiB;;AAE5B,QAAA,IAAA,CAAA,GAAG,GAAG,KAAK;2FAAiB;AAC5B;;;AAGG;QACH,IAAA,CAAA,IAAI,GAAG,KAAK,CAAkB,SAAS,4EAAI,SAAS,EAAE,eAAe,EAAA,CAAG;AAExE,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK;4FAAU;QACtB,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAC,IAAI,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;;AAEvD,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK;qGAAU;;AAE/B,QAAA,IAAA,CAAA,YAAY,GAAG,KAAK;oGAAmC;;QAGvD,IAAA,CAAA,WAAW,GAAG,MAAM,EAAkB;;QAEtC,IAAA,CAAA,UAAU,GAAG,MAAM,EAAc;;QAEjC,IAAA,CAAA,SAAS,GAAG,MAAM,EAAc;;QAGf,IAAA,CAAA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,EAAA,aAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,eAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,cAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,WAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,aAAA,CAAA,EAAA,CAAA,EAAA,UAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,YAAA,CAAA,EAAA,CAAA,EAAA,SAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,WAAA,CAAA,EAAA,CAAA,EAAA,mBAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,YAAA,EAAA,IAAA,EAAA,CAAA,MAAM,iEAGf,SAAS,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEvHvF;;AAEG;;ACFH;;AAEG;;"}
|
|
@@ -462,6 +462,104 @@ function autoFormatSegments(slots, data, { enforceBounds = true } = {}) {
|
|
|
462
462
|
return { text, tokenIndices, dataEnd };
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
/**
|
|
466
|
+
* Pure date helpers (no framework dependency), shared by every field that has to cross
|
|
467
|
+
* the `Date` ↔ ISO-string boundary — `ui-datepicker`, which parses what the user types,
|
|
468
|
+
* and `ui-input-date`, which reads what the browser's native picker hands back.
|
|
469
|
+
*
|
|
470
|
+
* They lived inside `ui-datepicker`'s entry point while it was the only caller (FSHSP-209
|
|
471
|
+
* moved them here). Two entry points must never import each other, so the second caller
|
|
472
|
+
* left one choice: the shared `forms/` entry point, which exists for exactly this — the
|
|
473
|
+
* helpers a field is built on. Serializing a `Date` from its LOCAL components rather than
|
|
474
|
+
* through `toISOString()` is the subtle part, and it must not be re-derived twice.
|
|
475
|
+
*/
|
|
476
|
+
function startOfDay(d) {
|
|
477
|
+
const x = new Date(d);
|
|
478
|
+
x.setHours(0, 0, 0, 0);
|
|
479
|
+
return x;
|
|
480
|
+
}
|
|
481
|
+
function firstOfMonth(d) {
|
|
482
|
+
return new Date(d.getFullYear(), d.getMonth(), 1);
|
|
483
|
+
}
|
|
484
|
+
function isSameDay(a, b) {
|
|
485
|
+
if (!a || !b)
|
|
486
|
+
return false;
|
|
487
|
+
return (a.getFullYear() === b.getFullYear() &&
|
|
488
|
+
a.getMonth() === b.getMonth() &&
|
|
489
|
+
a.getDate() === b.getDate());
|
|
490
|
+
}
|
|
491
|
+
function addDays(d, n) {
|
|
492
|
+
const x = new Date(d);
|
|
493
|
+
x.setDate(x.getDate() + n);
|
|
494
|
+
return x;
|
|
495
|
+
}
|
|
496
|
+
function addMonths(d, n) {
|
|
497
|
+
return new Date(d.getFullYear(), d.getMonth() + n, 1);
|
|
498
|
+
}
|
|
499
|
+
/** Build a Date and reject overflowed components (e.g. 31 Feb). */
|
|
500
|
+
function finalizeParsed(year, month, day, h, min) {
|
|
501
|
+
if (month < 0 || month > 11 || day < 1 || day > 31 || h > 23 || min > 59)
|
|
502
|
+
return null;
|
|
503
|
+
const d = new Date(year, month, day, h, min, 0, 0);
|
|
504
|
+
if (d.getFullYear() !== year || d.getMonth() !== month || d.getDate() !== day)
|
|
505
|
+
return null;
|
|
506
|
+
return d;
|
|
507
|
+
}
|
|
508
|
+
const ISO_DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
509
|
+
const ISO_DATETIME_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/;
|
|
510
|
+
const ISO_TIME_RE = /^(\d{2}):(\d{2})$/;
|
|
511
|
+
function pad2(n) {
|
|
512
|
+
return String(n).padStart(2, '0');
|
|
513
|
+
}
|
|
514
|
+
/** Serialize a `Date` to `"yyyy-MM-dd"` from its LOCAL components — never `toISOString()`
|
|
515
|
+
* (which converts to UTC and can shift the day by ±1 depending on the timezone). */
|
|
516
|
+
function toIsoDate(d) {
|
|
517
|
+
return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
|
|
518
|
+
}
|
|
519
|
+
/** `"HH:mm"` — the shape a native `<input type="time">` reads and writes. */
|
|
520
|
+
function toIsoTime(d) {
|
|
521
|
+
return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
|
|
522
|
+
}
|
|
523
|
+
/** `"yyyy-MM-ddTHH:mm"` — date part built the same local, never-UTC way as {@link toIsoDate}. */
|
|
524
|
+
function toIsoDateTime(d) {
|
|
525
|
+
return `${toIsoDate(d)}T${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
|
|
526
|
+
}
|
|
527
|
+
/** Strict `"yyyy-MM-dd"` parser (rejects anything else, incl. overflowed dates via `finalizeParsed`). */
|
|
528
|
+
function parseIsoDate(s) {
|
|
529
|
+
const m = ISO_DATE_RE.exec(s);
|
|
530
|
+
if (!m)
|
|
531
|
+
return null;
|
|
532
|
+
return finalizeParsed(Number(m[1]), Number(m[2]) - 1, Number(m[3]), 0, 0);
|
|
533
|
+
}
|
|
534
|
+
/** Strict `"yyyy-MM-ddTHH:mm"` parser (`showTime`/`timeOnly` round-trip). */
|
|
535
|
+
function parseIsoDateTime(s) {
|
|
536
|
+
const m = ISO_DATETIME_RE.exec(s);
|
|
537
|
+
if (!m)
|
|
538
|
+
return null;
|
|
539
|
+
return finalizeParsed(Number(m[1]), Number(m[2]) - 1, Number(m[3]), Number(m[4]), Number(m[5]));
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Strict `"HH:mm"` parser, anchored on `reference` (default: today).
|
|
543
|
+
*
|
|
544
|
+
* A bare time is not a point in time; the caller has to say on which day it lands. Mirrors
|
|
545
|
+
* what `ui-datepicker` does in `timeOnly` mode — it too carries a full `Date` — so both
|
|
546
|
+
* components hand back the same shape.
|
|
547
|
+
*/
|
|
548
|
+
function parseIsoTime(s, reference = new Date()) {
|
|
549
|
+
const m = ISO_TIME_RE.exec(s);
|
|
550
|
+
if (!m)
|
|
551
|
+
return null;
|
|
552
|
+
return finalizeParsed(reference.getFullYear(), reference.getMonth(), reference.getDate(), Number(m[1]), Number(m[2]));
|
|
553
|
+
}
|
|
554
|
+
/** Accepts a `Date` as-is, or parses a `"yyyy-MM-dd"` string — used to let config inputs
|
|
555
|
+
* (`minDate`/`maxDate`/`disabledDates`) take either shape. Invalid strings degrade to `null`
|
|
556
|
+
* (no constraint) rather than throwing: a malformed config shouldn't crash the picker. */
|
|
557
|
+
function normalizeDateInput(v) {
|
|
558
|
+
if (!v)
|
|
559
|
+
return null;
|
|
560
|
+
return v instanceof Date ? v : parseIsoDate(v);
|
|
561
|
+
}
|
|
562
|
+
|
|
465
563
|
/**
|
|
466
564
|
* Shared option-resolution helpers for list-based form fields
|
|
467
565
|
* (`ui-select`, `ui-autocomplete`, `ui-input-tags`).
|
|
@@ -549,5 +647,5 @@ function warnMissingAccessibleName(componentTag, message) {
|
|
|
549
647
|
* Generated bundle index. Do not edit.
|
|
550
648
|
*/
|
|
551
649
|
|
|
552
|
-
export { BaseControlValueAccessor, BaseFieldControl, BaseFormField, MASK_TOKENS, acceptsMaskChar, applyMaskTemplate, autoFormatSegments, buildMaskSlots, caretForMask, createOptionResolver, dropdownOverlayPositions, extractMaskData, formatLabel, parseMaskRanges, warnMissingAccessibleName };
|
|
650
|
+
export { BaseControlValueAccessor, BaseFieldControl, BaseFormField, MASK_TOKENS, acceptsMaskChar, addDays, addMonths, applyMaskTemplate, autoFormatSegments, buildMaskSlots, caretForMask, createOptionResolver, dropdownOverlayPositions, extractMaskData, finalizeParsed, firstOfMonth, formatLabel, isSameDay, normalizeDateInput, parseIsoDate, parseIsoDateTime, parseIsoTime, parseMaskRanges, startOfDay, toIsoDate, toIsoDateTime, toIsoTime, warnMissingAccessibleName };
|
|
553
651
|
//# sourceMappingURL=4sh-ui-kit-forms.mjs.map
|