@commmerce/ui 1.1.1 → 1.3.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/dist/calendar.d.ts +38 -0
- package/dist/calendar.js +109 -0
- package/dist/cdn.js +1010 -533
- package/dist/components/board.d.ts +338 -0
- package/dist/components/board.js +1017 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +25 -0
- package/dist/components/card.d.ts +7 -1
- package/dist/components/card.js +58 -7
- package/dist/components/color-field.d.ts +153 -0
- package/dist/components/color-field.js +369 -0
- package/dist/components/combobox.d.ts +17 -4
- package/dist/components/combobox.js +55 -23
- package/dist/components/date-picker.d.ts +49 -5
- package/dist/components/date-picker.js +211 -48
- package/dist/components/empty-state.d.ts +19 -4
- package/dist/components/empty-state.js +59 -5
- package/dist/components/file-upload.d.ts +33 -0
- package/dist/components/file-upload.js +80 -9
- package/dist/components/global-search.js +2 -7
- package/dist/components/metric.d.ts +97 -0
- package/dist/components/metric.js +168 -0
- package/dist/components/nested-list.d.ts +33 -1
- package/dist/components/nested-list.js +197 -18
- package/dist/components/option-group.d.ts +15 -6
- package/dist/components/option-group.js +25 -6
- package/dist/components/page-header.js +3 -2
- package/dist/components/resource-list.d.ts +14 -2
- package/dist/components/resource-list.js +48 -6
- package/dist/components/select.d.ts +20 -3
- package/dist/components/select.js +35 -11
- package/dist/components/table-header.d.ts +14 -0
- package/dist/components/table-header.js +21 -0
- package/dist/components/text-field.d.ts +36 -2
- package/dist/components/text-field.js +86 -14
- package/dist/components/timeline.d.ts +210 -0
- package/dist/components/timeline.js +380 -0
- package/dist/custom-elements.json +9371 -4963
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/move-model.d.ts +93 -0
- package/dist/move-model.js +169 -0
- package/dist/popover.d.ts +24 -0
- package/dist/popover.js +59 -0
- package/package.json +3 -3
|
@@ -28,6 +28,22 @@ declare const strings: {
|
|
|
28
28
|
rangeOverflow: string;
|
|
29
29
|
/** Validation: a date in `disabled-dates` or refused by `isDateDisabled`. */
|
|
30
30
|
unavailable: string;
|
|
31
|
+
/** With `time`: accessible name of the time box. */
|
|
32
|
+
time: string;
|
|
33
|
+
/** With `time`: accessible name of the time box when the field has a label. */
|
|
34
|
+
timeFor: string;
|
|
35
|
+
/** With `time`: letters for hours and minutes in the time placeholder, e.g. hh:mm am. */
|
|
36
|
+
patternHour: string;
|
|
37
|
+
patternMinute: string;
|
|
38
|
+
/** With `time`, validation: the text in the time box is not a time. `{pattern}` is e.g. hh:mm am. */
|
|
39
|
+
badTime: string;
|
|
40
|
+
/** With `time`, validation: a date is set but no time. */
|
|
41
|
+
timeMissing: string;
|
|
42
|
+
/** With `time`, validation: a time off the `step`. `{count}` is the step in minutes. */
|
|
43
|
+
stepMismatch: {
|
|
44
|
+
one: string;
|
|
45
|
+
other: string;
|
|
46
|
+
};
|
|
31
47
|
};
|
|
32
48
|
declare module '../localize.js' {
|
|
33
49
|
interface CmStrings {
|
|
@@ -35,7 +51,8 @@ declare module '../localize.js' {
|
|
|
35
51
|
}
|
|
36
52
|
}
|
|
37
53
|
/**
|
|
38
|
-
* Date field: type a date or pick one from a calendar.
|
|
54
|
+
* Date field: type a date or pick one from a calendar. With `time`, a time box sits next to it and the value is a
|
|
55
|
+
* local date and time, `yyyy-mm-ddThh:mm`. Follows the WAI-ARIA APG "date picker dialog" pattern:
|
|
39
56
|
* the calendar button opens a month grid where arrows move by day and week, Page Up/Down by month, Shift+Page Up/Down
|
|
40
57
|
* by year, Home/End to the start and end of the week, Enter picks and Escape closes. Month and weekday names come
|
|
41
58
|
* from `Intl` in the page's language. Participates in native forms with an ISO `yyyy-mm-dd` value.
|
|
@@ -45,6 +62,8 @@ declare module '../localize.js' {
|
|
|
45
62
|
* @csspart box - The bordered box around the text input and calendar button.
|
|
46
63
|
* @csspart input - The text input.
|
|
47
64
|
* @csspart calendar - The month grid.
|
|
65
|
+
* @csspart time-box - With `time`: the bordered box around the time input.
|
|
66
|
+
* @csspart time-input - With `time`: the time input.
|
|
48
67
|
*/
|
|
49
68
|
export declare class CmDatePicker extends CmLocalizedElement {
|
|
50
69
|
#private;
|
|
@@ -102,6 +121,16 @@ export declare class CmDatePicker extends CmLocalizedElement {
|
|
|
102
121
|
size: {
|
|
103
122
|
reflect: boolean;
|
|
104
123
|
};
|
|
124
|
+
time: {
|
|
125
|
+
type: BooleanConstructor;
|
|
126
|
+
reflect: boolean;
|
|
127
|
+
};
|
|
128
|
+
step: {
|
|
129
|
+
type: NumberConstructor;
|
|
130
|
+
};
|
|
131
|
+
hourCycle: {
|
|
132
|
+
attribute: string;
|
|
133
|
+
};
|
|
105
134
|
_text: {
|
|
106
135
|
state: boolean;
|
|
107
136
|
};
|
|
@@ -117,11 +146,17 @@ export declare class CmDatePicker extends CmLocalizedElement {
|
|
|
117
146
|
error: string;
|
|
118
147
|
/** Form field name. */
|
|
119
148
|
name: string;
|
|
120
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* The date as ISO `yyyy-mm-dd`; empty when no date is set. With `time`: the local date and time
|
|
151
|
+
* `yyyy-mm-ddThh:mm` (no time zone or offset), empty until both a date and a time are set.
|
|
152
|
+
*/
|
|
121
153
|
value: string;
|
|
122
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Earliest date that can be chosen, ISO `yyyy-mm-dd`. With `time` it may include a time, `yyyy-mm-ddThh:mm`,
|
|
156
|
+
* or be `now` (the current minute, checked again whenever the field is validated).
|
|
157
|
+
*/
|
|
123
158
|
min: string;
|
|
124
|
-
/** Latest date that can be chosen, ISO `yyyy-mm-dd`. */
|
|
159
|
+
/** Latest date that can be chosen, ISO `yyyy-mm-dd`. With `time`, also `yyyy-mm-ddThh:mm` or `now`. */
|
|
125
160
|
max: string;
|
|
126
161
|
/** Shown in the empty box. Defaults to the locale's pattern, e.g. "dd/mm/yyyy". */
|
|
127
162
|
placeholder: string;
|
|
@@ -146,6 +181,15 @@ export declare class CmDatePicker extends CmLocalizedElement {
|
|
|
146
181
|
open: boolean;
|
|
147
182
|
/** `small`: 12px label, 14px value (filter panels). */
|
|
148
183
|
size: 'default' | 'small';
|
|
184
|
+
/**
|
|
185
|
+
* Adds a time box next to the date box, so the field holds a date and a time. Times are typed (`3:30 pm`, `15:30`)
|
|
186
|
+
* and shown in the locale's clock (12-hour with am/pm for `en-IN`); Up and Down change the time by `step`.
|
|
187
|
+
*/
|
|
188
|
+
time: boolean;
|
|
189
|
+
/** With `time`: minutes between allowed times, counted from midnight (15 allows :00, :15, :30, :45). Up and Down in the time box move by it. Default 1. */
|
|
190
|
+
step: number;
|
|
191
|
+
/** With `time`: `h12` or `h23` to force a 12- or 24-hour clock. Empty: the locale's clock. */
|
|
192
|
+
hourCycle: '' | 'h12' | 'h23';
|
|
149
193
|
_text: string;
|
|
150
194
|
_focus: Date;
|
|
151
195
|
static styles: import("lit").CSSResult[];
|
|
@@ -154,7 +198,7 @@ export declare class CmDatePicker extends CmLocalizedElement {
|
|
|
154
198
|
get form(): HTMLFormElement | null;
|
|
155
199
|
get validity(): ValidityState;
|
|
156
200
|
get validationMessage(): string;
|
|
157
|
-
/** The value as a local Date, or null. */
|
|
201
|
+
/** The value as a local Date (with `time`, at that time), or null. */
|
|
158
202
|
get valueAsDate(): Date | null;
|
|
159
203
|
checkValidity(): boolean;
|
|
160
204
|
reportValidity(): boolean;
|
|
@@ -9,12 +9,12 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _CmDatePicker_instances, _CmDatePicker_localeProp, _CmDatePicker_internals, _CmDatePicker_id, _CmDatePicker_defaultValue, _CmDatePicker_keepText, _CmDatePicker_focusGrid, _CmDatePicker_locale_get, _CmDatePicker_fmt_get, _CmDatePicker_firstDay_get, _CmDatePicker_pattern_get, _CmDatePicker_format, _CmDatePicker_prepareFocus, _CmDatePicker_setValue, _CmDatePicker_commitText, _CmDatePicker_pick, _CmDatePicker_focusTrigger, _CmDatePicker_toggle, _CmDatePicker_onInputKey, _CmDatePicker_onGridKey, _CmDatePicker_onPopKey, _CmDatePicker_onMonth, _CmDatePicker_onOutside;
|
|
12
|
+
var _CmDatePicker_instances, _CmDatePicker_localeProp, _CmDatePicker_internals, _CmDatePicker_id, _CmDatePicker_defaultValue, _CmDatePicker_keepText, _CmDatePicker_focusGrid, _CmDatePicker_date, _CmDatePicker_time, _CmDatePicker_keepTime, _CmDatePicker_timeTextValue, _CmDatePicker_timeText_get, _CmDatePicker_timeText_set, _CmDatePicker_ownValue, _CmDatePicker_locale_get, _CmDatePicker_fmt_get, _CmDatePicker_tf_get, _CmDatePicker_dateValue_get, _CmDatePicker_limit, _CmDatePicker_minDate_get, _CmDatePicker_maxDate_get, _CmDatePicker_step_get, _CmDatePicker_firstDay_get, _CmDatePicker_pattern_get, _CmDatePicker_format, _CmDatePicker_formatTime, _CmDatePicker_timePattern_get, _CmDatePicker_split, _CmDatePicker_prepareFocus, _CmDatePicker_validate, _CmDatePicker_validateTime, _CmDatePicker_setValue, _CmDatePicker_setParts, _CmDatePicker_setDate, _CmDatePicker_commitText, _CmDatePicker_commitTime, _CmDatePicker_stepTime, _CmDatePicker_onTimeKey, _CmDatePicker_pick, _CmDatePicker_focusTrigger, _CmDatePicker_toggle, _CmDatePicker_onInputKey, _CmDatePicker_onGridKey, _CmDatePicker_onPopKey, _CmDatePicker_onMonth, _CmDatePicker_onOutside;
|
|
13
13
|
import { LitElement, html, css, nothing } from 'lit';
|
|
14
14
|
import { live } from 'lit/directives/live.js';
|
|
15
15
|
import { base, define, nextId, logicalKey } from '../base.js';
|
|
16
16
|
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
17
|
-
import { fromISO, toISO, addMonths, startOfMonth, clamp, trapTab, dateFieldStyles, gridKey, renderGrid, calendarStyles, dateFormat, parseDate, resolveLocale, localeFirstDay, listConverter, asList, datePattern, } from '../calendar.js';
|
|
17
|
+
import { fromISO, toISO, addMonths, startOfMonth, clamp, trapTab, dateFieldStyles, gridKey, renderGrid, calendarStyles, dateFormat, parseDate, resolveLocale, localeFirstDay, listConverter, asList, datePattern, splitDateTime, fromISODateTime, timeToMinutes, minutesToTime, nowISO, timeFormat, timePattern, parseTime, } from '../calendar.js';
|
|
18
18
|
import './icon.js';
|
|
19
19
|
const strings = defineStrings('datePicker', {
|
|
20
20
|
/** Calendar button while no date is set. */
|
|
@@ -43,9 +43,23 @@ const strings = defineStrings('datePicker', {
|
|
|
43
43
|
rangeOverflow: 'Choose {date} or earlier.',
|
|
44
44
|
/** Validation: a date in `disabled-dates` or refused by `isDateDisabled`. */
|
|
45
45
|
unavailable: 'This date isn\'t available. Choose another date.',
|
|
46
|
+
/** With `time`: accessible name of the time box. */
|
|
47
|
+
time: 'Time',
|
|
48
|
+
/** With `time`: accessible name of the time box when the field has a label. */
|
|
49
|
+
timeFor: 'Time for {label}',
|
|
50
|
+
/** With `time`: letters for hours and minutes in the time placeholder, e.g. hh:mm am. */
|
|
51
|
+
patternHour: 'hh',
|
|
52
|
+
patternMinute: 'mm',
|
|
53
|
+
/** With `time`, validation: the text in the time box is not a time. `{pattern}` is e.g. hh:mm am. */
|
|
54
|
+
badTime: 'Enter a time like {pattern}.',
|
|
55
|
+
/** With `time`, validation: a date is set but no time. */
|
|
56
|
+
timeMissing: 'Enter a time.',
|
|
57
|
+
/** With `time`, validation: a time off the `step`. `{count}` is the step in minutes. */
|
|
58
|
+
stepMismatch: { one: 'Choose a time on the minute.', other: 'Choose a time in steps of {count} minutes.' },
|
|
46
59
|
});
|
|
47
60
|
/**
|
|
48
|
-
* Date field: type a date or pick one from a calendar.
|
|
61
|
+
* Date field: type a date or pick one from a calendar. With `time`, a time box sits next to it and the value is a
|
|
62
|
+
* local date and time, `yyyy-mm-ddThh:mm`. Follows the WAI-ARIA APG "date picker dialog" pattern:
|
|
49
63
|
* the calendar button opens a month grid where arrows move by day and week, Page Up/Down by month, Shift+Page Up/Down
|
|
50
64
|
* by year, Home/End to the start and end of the week, Enter picks and Escape closes. Month and weekday names come
|
|
51
65
|
* from `Intl` in the page's language. Participates in native forms with an ISO `yyyy-mm-dd` value.
|
|
@@ -55,6 +69,8 @@ const strings = defineStrings('datePicker', {
|
|
|
55
69
|
* @csspart box - The bordered box around the text input and calendar button.
|
|
56
70
|
* @csspart input - The text input.
|
|
57
71
|
* @csspart calendar - The month grid.
|
|
72
|
+
* @csspart time-box - With `time`: the bordered box around the time input.
|
|
73
|
+
* @csspart time-input - With `time`: the time input.
|
|
58
74
|
*/
|
|
59
75
|
export class CmDatePicker extends CmLocalizedElement {
|
|
60
76
|
constructor() {
|
|
@@ -68,11 +84,17 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
68
84
|
this.error = '';
|
|
69
85
|
/** Form field name. */
|
|
70
86
|
this.name = '';
|
|
71
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* The date as ISO `yyyy-mm-dd`; empty when no date is set. With `time`: the local date and time
|
|
89
|
+
* `yyyy-mm-ddThh:mm` (no time zone or offset), empty until both a date and a time are set.
|
|
90
|
+
*/
|
|
72
91
|
this.value = '';
|
|
73
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Earliest date that can be chosen, ISO `yyyy-mm-dd`. With `time` it may include a time, `yyyy-mm-ddThh:mm`,
|
|
94
|
+
* or be `now` (the current minute, checked again whenever the field is validated).
|
|
95
|
+
*/
|
|
74
96
|
this.min = '';
|
|
75
|
-
/** Latest date that can be chosen, ISO `yyyy-mm-dd`. */
|
|
97
|
+
/** Latest date that can be chosen, ISO `yyyy-mm-dd`. With `time`, also `yyyy-mm-ddThh:mm` or `now`. */
|
|
76
98
|
this.max = '';
|
|
77
99
|
/** Shown in the empty box. Defaults to the locale's pattern, e.g. "dd/mm/yyyy". */
|
|
78
100
|
this.placeholder = '';
|
|
@@ -87,6 +109,15 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
87
109
|
this.open = false;
|
|
88
110
|
/** `small`: 12px label, 14px value (filter panels). */
|
|
89
111
|
this.size = 'default';
|
|
112
|
+
/**
|
|
113
|
+
* Adds a time box next to the date box, so the field holds a date and a time. Times are typed (`3:30 pm`, `15:30`)
|
|
114
|
+
* and shown in the locale's clock (12-hour with am/pm for `en-IN`); Up and Down change the time by `step`.
|
|
115
|
+
*/
|
|
116
|
+
this.time = false;
|
|
117
|
+
/** With `time`: minutes between allowed times, counted from midnight (15 allows :00, :15, :30, :45). Up and Down in the time box move by it. Default 1. */
|
|
118
|
+
this.step = 1;
|
|
119
|
+
/** With `time`: `h12` or `h23` to force a 12- or 24-hour clock. Empty: the locale's clock. */
|
|
120
|
+
this.hourCycle = '';
|
|
90
121
|
this._text = '';
|
|
91
122
|
this._focus = new Date();
|
|
92
123
|
_CmDatePicker_internals.set(this, this.attachInternals());
|
|
@@ -94,6 +125,20 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
94
125
|
_CmDatePicker_defaultValue.set(this, null);
|
|
95
126
|
_CmDatePicker_keepText.set(this, false);
|
|
96
127
|
_CmDatePicker_focusGrid.set(this, false);
|
|
128
|
+
/** With `time`: the date and time parts, kept while the other part is still missing (the value is then empty). */
|
|
129
|
+
_CmDatePicker_date.set(this, '');
|
|
130
|
+
_CmDatePicker_time.set(this, '');
|
|
131
|
+
_CmDatePicker_keepTime.set(this, false);
|
|
132
|
+
_CmDatePicker_timeTextValue.set(this, '');
|
|
133
|
+
_CmDatePicker_ownValue.set(this, false);
|
|
134
|
+
_CmDatePicker_onTimeKey.set(this, (e) => {
|
|
135
|
+
if (e.key === 'Enter')
|
|
136
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_commitTime).call(this);
|
|
137
|
+
else if ((e.key === 'ArrowUp' || e.key === 'ArrowDown') && !e.altKey) {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_stepTime).call(this, e.key === 'ArrowUp' ? 1 : -1);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
97
142
|
_CmDatePicker_toggle.set(this, () => {
|
|
98
143
|
if (this.disabled)
|
|
99
144
|
return;
|
|
@@ -122,7 +167,7 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
122
167
|
const next = gridKey(logicalKey(e, this), e, this._focus, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_firstDay_get));
|
|
123
168
|
if (next) {
|
|
124
169
|
e.preventDefault();
|
|
125
|
-
this._focus = clamp(next,
|
|
170
|
+
this._focus = clamp(next, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_minDate_get), __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_maxDate_get));
|
|
126
171
|
__classPrivateFieldSet(this, _CmDatePicker_focusGrid, true, "f");
|
|
127
172
|
return;
|
|
128
173
|
}
|
|
@@ -142,7 +187,7 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
142
187
|
trapTab(e, e.currentTarget);
|
|
143
188
|
});
|
|
144
189
|
_CmDatePicker_onMonth.set(this, (step) => {
|
|
145
|
-
this._focus = clamp(addMonths(this._focus, step),
|
|
190
|
+
this._focus = clamp(addMonths(this._focus, step), __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_minDate_get), __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_maxDate_get));
|
|
146
191
|
});
|
|
147
192
|
_CmDatePicker_onOutside.set(this, (e) => {
|
|
148
193
|
if (this.open && !e.composedPath().includes(this))
|
|
@@ -169,11 +214,19 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
169
214
|
get form() { return __classPrivateFieldGet(this, _CmDatePicker_internals, "f").form; }
|
|
170
215
|
get validity() { return __classPrivateFieldGet(this, _CmDatePicker_internals, "f").validity; }
|
|
171
216
|
get validationMessage() { return __classPrivateFieldGet(this, _CmDatePicker_internals, "f").validationMessage; }
|
|
172
|
-
/** The value as a local Date, or null. */
|
|
173
|
-
get valueAsDate() { return fromISO(this.value); }
|
|
174
|
-
checkValidity() { return __classPrivateFieldGet(this, _CmDatePicker_internals, "f").checkValidity(); }
|
|
175
|
-
reportValidity() { return __classPrivateFieldGet(this, _CmDatePicker_internals, "f").reportValidity(); }
|
|
176
|
-
formResetCallback() {
|
|
217
|
+
/** The value as a local Date (with `time`, at that time), or null. */
|
|
218
|
+
get valueAsDate() { return this.time ? (this.value ? fromISODateTime(this.value) : null) : fromISO(this.value); }
|
|
219
|
+
checkValidity() { __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_validate).call(this); return __classPrivateFieldGet(this, _CmDatePicker_internals, "f").checkValidity(); }
|
|
220
|
+
reportValidity() { __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_validate).call(this); return __classPrivateFieldGet(this, _CmDatePicker_internals, "f").reportValidity(); }
|
|
221
|
+
formResetCallback() {
|
|
222
|
+
this.value = __classPrivateFieldGet(this, _CmDatePicker_defaultValue, "f") ?? '';
|
|
223
|
+
if (this.time) {
|
|
224
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_split).call(this, this.value);
|
|
225
|
+
__classPrivateFieldSet(this, _CmDatePicker_instances, __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_formatTime).call(this, __classPrivateFieldGet(this, _CmDatePicker_time, "f")), "a", _CmDatePicker_timeText_set);
|
|
226
|
+
}
|
|
227
|
+
this._text = __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_format).call(this, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get));
|
|
228
|
+
this.open = false;
|
|
229
|
+
}
|
|
177
230
|
formDisabledCallback(d) { this.disabled = d; if (d)
|
|
178
231
|
this.open = false; }
|
|
179
232
|
formStateRestoreCallback(state) { this.value = state ?? ''; }
|
|
@@ -189,37 +242,30 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
189
242
|
const d = fromISO(iso);
|
|
190
243
|
if (!d)
|
|
191
244
|
return true;
|
|
192
|
-
const min =
|
|
245
|
+
const min = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_minDate_get), max = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_maxDate_get);
|
|
193
246
|
if ((min && d < min) || (max && d > max))
|
|
194
247
|
return true;
|
|
195
248
|
return asList(this.disabledDates).includes(iso) || !!this.isDateDisabled?.(iso);
|
|
196
249
|
}
|
|
197
250
|
willUpdate(changed) {
|
|
198
|
-
if (changed.has('value') && !__classPrivateFieldGet(this,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
251
|
+
if (this.time && (changed.has('value') || changed.has('time')) && !__classPrivateFieldGet(this, _CmDatePicker_ownValue, "f")) {
|
|
252
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_split).call(this, this.value);
|
|
253
|
+
if (!__classPrivateFieldGet(this, _CmDatePicker_keepTime, "f"))
|
|
254
|
+
__classPrivateFieldSet(this, _CmDatePicker_instances, __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_formatTime).call(this, __classPrivateFieldGet(this, _CmDatePicker_time, "f")), "a", _CmDatePicker_timeText_set);
|
|
255
|
+
}
|
|
256
|
+
else if (this.time && (changed.has('locale') || changed.has('hourCycle')) && __classPrivateFieldGet(this, _CmDatePicker_time, "f"))
|
|
257
|
+
__classPrivateFieldSet(this, _CmDatePicker_instances, __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_formatTime).call(this, __classPrivateFieldGet(this, _CmDatePicker_time, "f")), "a", _CmDatePicker_timeText_set);
|
|
258
|
+
if ((changed.has('value') || changed.has('time')) && !__classPrivateFieldGet(this, _CmDatePicker_keepText, "f"))
|
|
259
|
+
this._text = __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_format).call(this, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get));
|
|
260
|
+
else if (changed.has('locale') && fromISO(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get)))
|
|
261
|
+
this._text = __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_format).call(this, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get));
|
|
202
262
|
__classPrivateFieldSet(this, _CmDatePicker_keepText, false, "f");
|
|
263
|
+
__classPrivateFieldSet(this, _CmDatePicker_keepTime, false, "f");
|
|
264
|
+
__classPrivateFieldSet(this, _CmDatePicker_ownValue, false, "f");
|
|
203
265
|
}
|
|
204
266
|
updated(changed) {
|
|
205
|
-
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setFormValue(this.value || null, this._text);
|
|
206
|
-
|
|
207
|
-
const d = fromISO(this.value);
|
|
208
|
-
const fmt = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_fmt_get);
|
|
209
|
-
if (this.error)
|
|
210
|
-
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ customError: true }, this.error, input);
|
|
211
|
-
else if (this._text.trim() && !d)
|
|
212
|
-
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ badInput: true }, this.t('badInput', { pattern: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_pattern_get) }), input);
|
|
213
|
-
else if (this.required && !d)
|
|
214
|
-
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ valueMissing: true }, this.t('required'), input);
|
|
215
|
-
else if (d && fromISO(this.min) && d < fromISO(this.min))
|
|
216
|
-
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ rangeUnderflow: true }, this.t('rangeUnderflow', { date: fmt.medium(fromISO(this.min)) }), input);
|
|
217
|
-
else if (d && fromISO(this.max) && d > fromISO(this.max))
|
|
218
|
-
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ rangeOverflow: true }, this.t('rangeOverflow', { date: fmt.medium(fromISO(this.max)) }), input);
|
|
219
|
-
else if (d && this.isUnavailable(this.value))
|
|
220
|
-
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ customError: true }, this.t('unavailable'), input);
|
|
221
|
-
else
|
|
222
|
-
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({});
|
|
267
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setFormValue(this.value || null, this.time ? this.value : this._text);
|
|
268
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_validate).call(this);
|
|
223
269
|
if (this.open && __classPrivateFieldGet(this, _CmDatePicker_focusGrid, "f")) {
|
|
224
270
|
__classPrivateFieldSet(this, _CmDatePicker_focusGrid, false, "f");
|
|
225
271
|
this.renderRoot.querySelector('td[tabindex="0"]')?.focus();
|
|
@@ -229,7 +275,7 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
229
275
|
}
|
|
230
276
|
render() {
|
|
231
277
|
const fmt = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_fmt_get);
|
|
232
|
-
const value = fromISO(this
|
|
278
|
+
const value = fromISO(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get));
|
|
233
279
|
const described = [this.error && `${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-err`, this.helpText && `${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-help`].filter(Boolean).join(' ');
|
|
234
280
|
const hostLabel = this.getAttribute('aria-label');
|
|
235
281
|
const name = this.label || hostLabel || '';
|
|
@@ -238,7 +284,7 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
238
284
|
${this.label
|
|
239
285
|
? html `<label class="label" for="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-in" part="label">${this.label}${this.required ? html `<span class="req" aria-hidden="true">*</span>` : nothing}</label>`
|
|
240
286
|
: nothing}
|
|
241
|
-
<div class="wrap">
|
|
287
|
+
<div class="wrap ${this.time ? 'timed' : ''}">
|
|
242
288
|
<div class="box" part="box">
|
|
243
289
|
<input id="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-in" part="input" type="text" autocomplete="off" spellcheck="false"
|
|
244
290
|
.value=${live(this._text)} placeholder=${this.placeholder || __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_pattern_get)}
|
|
@@ -252,13 +298,22 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
252
298
|
aria-haspopup="dialog" aria-expanded=${this.open ? 'true' : 'false'} aria-controls="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-pop"
|
|
253
299
|
@click=${__classPrivateFieldGet(this, _CmDatePicker_toggle, "f")}><cm-icon name="calendar" size="18"></cm-icon></button>
|
|
254
300
|
</div>
|
|
301
|
+
${this.time ? html `<div class="box time" part="time-box">
|
|
302
|
+
<input class="time-in" part="time-input" type="text" autocomplete="off" spellcheck="false"
|
|
303
|
+
.value=${live(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timeText_get))} placeholder=${__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timePattern_get)}
|
|
304
|
+
aria-label=${this.t(name ? 'timeFor' : 'time', { label: name })}
|
|
305
|
+
?required=${this.required} ?disabled=${this.disabled}
|
|
306
|
+
aria-invalid=${this.error ? 'true' : nothing} aria-describedby=${described || nothing}
|
|
307
|
+
@input=${(e) => { e.stopPropagation(); __classPrivateFieldSet(this, _CmDatePicker_instances, e.target.value, "a", _CmDatePicker_timeText_set); }}
|
|
308
|
+
@change=${() => __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_commitTime).call(this)} @keydown=${__classPrivateFieldGet(this, _CmDatePicker_onTimeKey, "f")} />
|
|
309
|
+
</div>` : nothing}
|
|
255
310
|
<div class="pop" id="${__classPrivateFieldGet(this, _CmDatePicker_id, "f")}-pop" part="popover" role="dialog" aria-modal="true" aria-label=${this.t('dialog')}
|
|
256
311
|
?hidden=${!this.open} @keydown=${__classPrivateFieldGet(this, _CmDatePicker_onPopKey, "f")}>
|
|
257
312
|
${this.open ? html `<div class="cal">${renderGrid({
|
|
258
313
|
id: __classPrivateFieldGet(this, _CmDatePicker_id, "f"), fmt, firstDay: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_firstDay_get), month, focus: this._focus,
|
|
259
|
-
min:
|
|
314
|
+
min: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_minDate_get), max: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_maxDate_get),
|
|
260
315
|
isDisabled: (d) => this.isUnavailable(toISO(d)),
|
|
261
|
-
mark: (d) => (value && toISO(d) === this
|
|
316
|
+
mark: (d) => (value && toISO(d) === __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get) ? 'selected' : ''),
|
|
262
317
|
onPick: (d) => __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_pick).call(this, d), onKey: __classPrivateFieldGet(this, _CmDatePicker_onGridKey, "f"), onMonth: __classPrivateFieldGet(this, _CmDatePicker_onMonth, "f"),
|
|
263
318
|
previousLabel: this.t('previousMonth'), nextLabel: this.t('nextMonth'),
|
|
264
319
|
})}</div>` : nothing}
|
|
@@ -269,46 +324,151 @@ export class CmDatePicker extends CmLocalizedElement {
|
|
|
269
324
|
</div>`;
|
|
270
325
|
}
|
|
271
326
|
}
|
|
272
|
-
_CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(), _CmDatePicker_id = new WeakMap(), _CmDatePicker_defaultValue = new WeakMap(), _CmDatePicker_keepText = new WeakMap(), _CmDatePicker_focusGrid = new WeakMap(), _CmDatePicker_toggle = new WeakMap(), _CmDatePicker_onInputKey = new WeakMap(), _CmDatePicker_onGridKey = new WeakMap(), _CmDatePicker_onPopKey = new WeakMap(), _CmDatePicker_onMonth = new WeakMap(), _CmDatePicker_onOutside = new WeakMap(), _CmDatePicker_instances = new WeakSet(),
|
|
327
|
+
_CmDatePicker_localeProp = new WeakMap(), _CmDatePicker_internals = new WeakMap(), _CmDatePicker_id = new WeakMap(), _CmDatePicker_defaultValue = new WeakMap(), _CmDatePicker_keepText = new WeakMap(), _CmDatePicker_focusGrid = new WeakMap(), _CmDatePicker_date = new WeakMap(), _CmDatePicker_time = new WeakMap(), _CmDatePicker_keepTime = new WeakMap(), _CmDatePicker_timeTextValue = new WeakMap(), _CmDatePicker_ownValue = new WeakMap(), _CmDatePicker_onTimeKey = new WeakMap(), _CmDatePicker_toggle = new WeakMap(), _CmDatePicker_onInputKey = new WeakMap(), _CmDatePicker_onGridKey = new WeakMap(), _CmDatePicker_onPopKey = new WeakMap(), _CmDatePicker_onMonth = new WeakMap(), _CmDatePicker_onOutside = new WeakMap(), _CmDatePicker_instances = new WeakSet(), _CmDatePicker_timeText_get = function _CmDatePicker_timeText_get() { return __classPrivateFieldGet(this, _CmDatePicker_timeTextValue, "f"); }, _CmDatePicker_timeText_set = function _CmDatePicker_timeText_set(v) { if (v !== __classPrivateFieldGet(this, _CmDatePicker_timeTextValue, "f")) {
|
|
328
|
+
__classPrivateFieldSet(this, _CmDatePicker_timeTextValue, v, "f");
|
|
329
|
+
this.requestUpdate();
|
|
330
|
+
} }, _CmDatePicker_locale_get = function _CmDatePicker_locale_get() { return resolveLocale(this, this.locale); }, _CmDatePicker_fmt_get = function _CmDatePicker_fmt_get() { return dateFormat(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_locale_get)); }, _CmDatePicker_tf_get = function _CmDatePicker_tf_get() { return timeFormat(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_locale_get), this.hourCycle); }, _CmDatePicker_dateValue_get = function _CmDatePicker_dateValue_get() { return this.time ? __classPrivateFieldGet(this, _CmDatePicker_date, "f") : this.value; }, _CmDatePicker_limit = function _CmDatePicker_limit(v) { return this.time && v.trim().toLowerCase() === 'now' ? nowISO() : v; }, _CmDatePicker_minDate_get = function _CmDatePicker_minDate_get() { return fromISO(splitDateTime(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.min)).date || this.min); }, _CmDatePicker_maxDate_get = function _CmDatePicker_maxDate_get() { return fromISO(splitDateTime(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.max)).date || this.max); }, _CmDatePicker_step_get = function _CmDatePicker_step_get() { const n = Math.trunc(Number(this.step)); return n >= 1 && n <= 1440 ? n : 1; }, _CmDatePicker_firstDay_get = function _CmDatePicker_firstDay_get() {
|
|
273
331
|
const n = Number(this.firstDayOfWeek);
|
|
274
332
|
return this.firstDayOfWeek == null || Number.isNaN(n) ? localeFirstDay(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_locale_get)) : ((Math.trunc(n) % 7) + 7) % 7;
|
|
275
333
|
}, _CmDatePicker_pattern_get = function _CmDatePicker_pattern_get() { return datePattern(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_fmt_get), { d: this.t('patternDay'), m: this.t('patternMonth'), y: this.t('patternYear') }); }, _CmDatePicker_format = function _CmDatePicker_format(v) {
|
|
276
334
|
const d = fromISO(v);
|
|
277
335
|
return d ? __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_fmt_get).short(d) : v;
|
|
336
|
+
}, _CmDatePicker_formatTime = function _CmDatePicker_formatTime(t) {
|
|
337
|
+
const minutes = timeToMinutes(t);
|
|
338
|
+
return minutes === null ? '' : __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_tf_get).format(minutes);
|
|
339
|
+
}, _CmDatePicker_timePattern_get = function _CmDatePicker_timePattern_get() { return timePattern(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_tf_get), { h: this.t('patternHour'), m: this.t('patternMinute') }); }, _CmDatePicker_split = function _CmDatePicker_split(v) {
|
|
340
|
+
const { date, time } = splitDateTime(v);
|
|
341
|
+
__classPrivateFieldSet(this, _CmDatePicker_date, date, "f");
|
|
342
|
+
__classPrivateFieldSet(this, _CmDatePicker_time, date ? time : '', "f");
|
|
278
343
|
}, _CmDatePicker_prepareFocus = function _CmDatePicker_prepareFocus() {
|
|
279
344
|
const today = new Date();
|
|
280
|
-
const start = fromISO(this
|
|
281
|
-
this._focus = clamp(start,
|
|
345
|
+
const start = fromISO(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get)) ?? new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
346
|
+
this._focus = clamp(start, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_minDate_get), __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_maxDate_get));
|
|
282
347
|
__classPrivateFieldSet(this, _CmDatePicker_focusGrid, true, "f");
|
|
348
|
+
}, _CmDatePicker_validate = function _CmDatePicker_validate() {
|
|
349
|
+
const input = this.renderRoot.querySelector('input') ?? undefined;
|
|
350
|
+
const d = fromISO(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_dateValue_get));
|
|
351
|
+
const fmt = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_fmt_get);
|
|
352
|
+
if (this.error)
|
|
353
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ customError: true }, this.error, input);
|
|
354
|
+
else if (this._text.trim() && !d)
|
|
355
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ badInput: true }, this.t('badInput', { pattern: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_pattern_get) }), input);
|
|
356
|
+
else if (this.time)
|
|
357
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_validateTime).call(this, d, input);
|
|
358
|
+
else if (this.required && !d)
|
|
359
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ valueMissing: true }, this.t('required'), input);
|
|
360
|
+
else if (d && __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_minDate_get) && d < __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_minDate_get))
|
|
361
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ rangeUnderflow: true }, this.t('rangeUnderflow', { date: fmt.medium(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_minDate_get)) }), input);
|
|
362
|
+
else if (d && __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_maxDate_get) && d > __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_maxDate_get))
|
|
363
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ rangeOverflow: true }, this.t('rangeOverflow', { date: fmt.medium(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_maxDate_get)) }), input);
|
|
364
|
+
else if (d && this.isUnavailable(this.value))
|
|
365
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({ customError: true }, this.t('unavailable'), input);
|
|
366
|
+
else
|
|
367
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({});
|
|
368
|
+
}, _CmDatePicker_validateTime = function _CmDatePicker_validateTime(d, dateInput) {
|
|
369
|
+
const timeInput = this.renderRoot.querySelector('input.time-in') ?? dateInput;
|
|
370
|
+
const set = (flags, key, vars, anchor = dateInput) => __classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity(flags, this.t(key, vars), anchor);
|
|
371
|
+
const minutes = timeToMinutes(__classPrivateFieldGet(this, _CmDatePicker_time, "f"));
|
|
372
|
+
if (__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timeText_get).trim() && minutes === null)
|
|
373
|
+
return set({ badInput: true }, 'badTime', { pattern: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timePattern_get) }, timeInput);
|
|
374
|
+
if (!d && minutes === null) {
|
|
375
|
+
if (this.required)
|
|
376
|
+
return set({ valueMissing: true }, 'required');
|
|
377
|
+
return __classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({});
|
|
378
|
+
}
|
|
379
|
+
if (!d)
|
|
380
|
+
return set({ badInput: true }, 'required');
|
|
381
|
+
if (minutes === null)
|
|
382
|
+
return set({ badInput: true }, 'timeMissing', undefined, timeInput);
|
|
383
|
+
const at = fromISODateTime(`${__classPrivateFieldGet(this, _CmDatePicker_date, "f")}T${__classPrivateFieldGet(this, _CmDatePicker_time, "f")}`);
|
|
384
|
+
const min = fromISODateTime(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.min)), max = fromISODateTime(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.max), true);
|
|
385
|
+
const show = (limit, v) => (splitDateTime(limit).time ? __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_tf_get).dateTime(v) : __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_fmt_get).medium(v));
|
|
386
|
+
if (min && at < min)
|
|
387
|
+
return set({ rangeUnderflow: true }, 'rangeUnderflow', { date: show(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.min), min) }, timeInput);
|
|
388
|
+
if (max && at > max)
|
|
389
|
+
return set({ rangeOverflow: true }, 'rangeOverflow', { date: show(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.max), max) }, timeInput);
|
|
390
|
+
if (minutes % __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_step_get))
|
|
391
|
+
return set({ stepMismatch: true }, 'stepMismatch', { count: __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_step_get) }, timeInput);
|
|
392
|
+
if (this.isUnavailable(__classPrivateFieldGet(this, _CmDatePicker_date, "f")))
|
|
393
|
+
return set({ customError: true }, 'unavailable');
|
|
394
|
+
__classPrivateFieldGet(this, _CmDatePicker_internals, "f").setValidity({});
|
|
283
395
|
}, _CmDatePicker_setValue = function _CmDatePicker_setValue(v) {
|
|
284
396
|
if (v === this.value)
|
|
285
397
|
return;
|
|
286
398
|
this.value = v;
|
|
287
399
|
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
288
400
|
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
401
|
+
}, _CmDatePicker_setParts = function _CmDatePicker_setParts(date, time) {
|
|
402
|
+
__classPrivateFieldSet(this, _CmDatePicker_date, date, "f");
|
|
403
|
+
__classPrivateFieldSet(this, _CmDatePicker_time, time, "f");
|
|
404
|
+
const v = date && time ? `${date}T${time}` : '';
|
|
405
|
+
__classPrivateFieldSet(this, _CmDatePicker_ownValue, true, "f");
|
|
406
|
+
this.requestUpdate();
|
|
407
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setValue).call(this, v);
|
|
408
|
+
}, _CmDatePicker_setDate = function _CmDatePicker_setDate(iso) {
|
|
409
|
+
if (this.time)
|
|
410
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setParts).call(this, iso, __classPrivateFieldGet(this, _CmDatePicker_time, "f"));
|
|
411
|
+
else
|
|
412
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setValue).call(this, iso);
|
|
289
413
|
}, _CmDatePicker_commitText = function _CmDatePicker_commitText() {
|
|
290
414
|
const text = this._text.trim();
|
|
291
415
|
if (!text) {
|
|
292
|
-
__classPrivateFieldGet(this, _CmDatePicker_instances, "m",
|
|
416
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setDate).call(this, '');
|
|
293
417
|
return;
|
|
294
418
|
}
|
|
295
419
|
const iso = parseDate(text, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_fmt_get));
|
|
296
420
|
if (iso) {
|
|
297
|
-
__classPrivateFieldGet(this, _CmDatePicker_instances, "m",
|
|
421
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setDate).call(this, iso);
|
|
298
422
|
this._text = __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_format).call(this, iso);
|
|
299
423
|
}
|
|
300
424
|
else {
|
|
301
425
|
__classPrivateFieldSet(this, _CmDatePicker_keepText, true, "f");
|
|
302
|
-
__classPrivateFieldGet(this, _CmDatePicker_instances, "m",
|
|
426
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setDate).call(this, '');
|
|
427
|
+
}
|
|
428
|
+
}, _CmDatePicker_commitTime = function _CmDatePicker_commitTime() {
|
|
429
|
+
const text = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timeText_get).trim();
|
|
430
|
+
const t = text ? parseTime(text, __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_tf_get)) : '';
|
|
431
|
+
__classPrivateFieldSet(this, _CmDatePicker_keepText, true, "f");
|
|
432
|
+
if (t === null) {
|
|
433
|
+
__classPrivateFieldSet(this, _CmDatePicker_keepTime, true, "f");
|
|
434
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setParts).call(this, __classPrivateFieldGet(this, _CmDatePicker_date, "f"), '');
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setParts).call(this, __classPrivateFieldGet(this, _CmDatePicker_date, "f"), t);
|
|
438
|
+
__classPrivateFieldSet(this, _CmDatePicker_instances, __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_formatTime).call(this, t), "a", _CmDatePicker_timeText_set);
|
|
439
|
+
}, _CmDatePicker_stepTime = function _CmDatePicker_stepTime(dir) {
|
|
440
|
+
const step = __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_step_get);
|
|
441
|
+
let current = parseTime(__classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_timeText_get), __classPrivateFieldGet(this, _CmDatePicker_instances, "a", _CmDatePicker_tf_get));
|
|
442
|
+
if (!current) {
|
|
443
|
+
const min = splitDateTime(__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_limit).call(this, this.min));
|
|
444
|
+
const now = new Date();
|
|
445
|
+
current = min.time && (!__classPrivateFieldGet(this, _CmDatePicker_date, "f") || __classPrivateFieldGet(this, _CmDatePicker_date, "f") === min.date) ? min.time : minutesToTime(now.getHours() * 60 + now.getMinutes());
|
|
446
|
+
const m = timeToMinutes(current);
|
|
447
|
+
if (m % step === 0) {
|
|
448
|
+
__classPrivateFieldSet(this, _CmDatePicker_keepText, true, "f");
|
|
449
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setParts).call(this, __classPrivateFieldGet(this, _CmDatePicker_date, "f"), current);
|
|
450
|
+
__classPrivateFieldSet(this, _CmDatePicker_instances, __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_formatTime).call(this, current), "a", _CmDatePicker_timeText_set);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
dir = 1;
|
|
303
454
|
}
|
|
455
|
+
const m = timeToMinutes(current);
|
|
456
|
+
const next = dir > 0 ? (Math.floor(m / step) + 1) * step : (Math.ceil(m / step) - 1) * step;
|
|
457
|
+
const t = minutesToTime(next >= 1440 ? 0 : next < 0 ? Math.floor(1439 / step) * step : next);
|
|
458
|
+
__classPrivateFieldSet(this, _CmDatePicker_keepText, true, "f");
|
|
459
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setParts).call(this, __classPrivateFieldGet(this, _CmDatePicker_date, "f"), t);
|
|
460
|
+
__classPrivateFieldSet(this, _CmDatePicker_instances, __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_formatTime).call(this, t), "a", _CmDatePicker_timeText_set);
|
|
304
461
|
}, _CmDatePicker_pick = function _CmDatePicker_pick(d) {
|
|
305
462
|
const iso = toISO(d);
|
|
306
463
|
if (this.isUnavailable(iso))
|
|
307
464
|
return;
|
|
308
465
|
this.open = false;
|
|
309
|
-
__classPrivateFieldGet(this, _CmDatePicker_instances, "m",
|
|
466
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_setDate).call(this, iso);
|
|
310
467
|
this._text = __classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_format).call(this, iso);
|
|
311
|
-
__classPrivateFieldGet(this,
|
|
468
|
+
if (this.time && !__classPrivateFieldGet(this, _CmDatePicker_time, "f"))
|
|
469
|
+
this.updateComplete.then(() => this.renderRoot.querySelector('input.time-in')?.focus());
|
|
470
|
+
else
|
|
471
|
+
__classPrivateFieldGet(this, _CmDatePicker_instances, "m", _CmDatePicker_focusTrigger).call(this);
|
|
312
472
|
}, _CmDatePicker_focusTrigger = function _CmDatePicker_focusTrigger() { this.renderRoot.querySelector('.trigger')?.focus(); };
|
|
313
473
|
CmDatePicker.formAssociated = true;
|
|
314
474
|
CmDatePicker.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
@@ -329,6 +489,9 @@ CmDatePicker.properties = {
|
|
|
329
489
|
disabled: { type: Boolean, reflect: true },
|
|
330
490
|
open: { type: Boolean, reflect: true },
|
|
331
491
|
size: { reflect: true },
|
|
492
|
+
time: { type: Boolean, reflect: true },
|
|
493
|
+
step: { type: Number },
|
|
494
|
+
hourCycle: { attribute: 'hour-cycle' },
|
|
332
495
|
_text: { state: true },
|
|
333
496
|
_focus: { state: true },
|
|
334
497
|
};
|
|
@@ -4,10 +4,13 @@ import './icon.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Shown in place of a list or page when there is nothing to show yet, with the next step to take.
|
|
6
6
|
* A soft circle holds an illustration (an image, your own markup or one of the system icons).
|
|
7
|
+
* `size="inline"` is the compact form for an empty list inside a card or table: one or two left-aligned lines,
|
|
8
|
+
* an optional small icon and an optional text action, with no circle.
|
|
7
9
|
* @element cm-empty-state
|
|
8
|
-
* @slot - Optional supporting text under the heading.
|
|
9
|
-
* @slot image - Your own illustration, drawn inside the circle. Decorative: give it `alt=""`.
|
|
10
|
+
* @slot - Optional supporting text under the heading (inline: after it, on the same line).
|
|
11
|
+
* @slot image - Your own illustration, drawn inside the circle. Decorative: give it `alt=""`. Inline: 20px.
|
|
10
12
|
* @slot actions - The primary action (usually one primary `cm-button`), plus an optional link.
|
|
13
|
+
* @fires cm-action - The text action (`action`) was pressed. Not fired when it has `action-href` (it is then a link).
|
|
11
14
|
*/
|
|
12
15
|
export declare class CmEmptyState extends LitElement {
|
|
13
16
|
#private;
|
|
@@ -22,6 +25,10 @@ export declare class CmEmptyState extends LitElement {
|
|
|
22
25
|
size: {
|
|
23
26
|
reflect: boolean;
|
|
24
27
|
};
|
|
28
|
+
action: {};
|
|
29
|
+
actionHref: {
|
|
30
|
+
attribute: string;
|
|
31
|
+
};
|
|
25
32
|
};
|
|
26
33
|
/** What is missing, said plainly: "No products found". */
|
|
27
34
|
heading: string;
|
|
@@ -31,8 +38,16 @@ export declare class CmEmptyState extends LitElement {
|
|
|
31
38
|
icon: IconName | '';
|
|
32
39
|
/** Heading level, so the page outline stays correct. Default 2. */
|
|
33
40
|
headingLevel: 2 | 3 | 4 | 5 | 6;
|
|
34
|
-
/**
|
|
35
|
-
|
|
41
|
+
/**
|
|
42
|
+
* `large` (250px circle, page-level), `small` (200px circle, inside a card or on mobile) or `inline`
|
|
43
|
+
* (since 1.2: no circle, a 20px icon, heading and text on one or two left-aligned lines; for an empty list
|
|
44
|
+
* inside a card, panel or table). Inline shows the `icon` (default `box`); set `icon=""` for text only.
|
|
45
|
+
*/
|
|
46
|
+
size: 'large' | 'small' | 'inline';
|
|
47
|
+
/** Text of one action drawn as a text button ("Add task", "View all"), after the text. Meant for `size="inline"`; larger sizes put a `cm-button` in the `actions` slot. Fires `cm-action`. Since 1.2. */
|
|
48
|
+
action: string;
|
|
49
|
+
/** Makes the text action a link to this URL instead of a button. Since 1.2. */
|
|
50
|
+
actionHref: string;
|
|
36
51
|
static styles: import("lit").CSSResult[];
|
|
37
52
|
/** @internal */
|
|
38
53
|
hasText: boolean;
|