@commmerce/ui 1.17.1 → 1.18.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.md +2 -0
- package/dist/calendar.d.ts +5 -0
- package/dist/calendar.js +9 -4
- package/dist/cdn.js +694 -583
- package/dist/components/date-range-picker.d.ts +28 -1
- package/dist/components/date-range-picker.js +273 -14
- package/dist/custom-elements.json +186 -1
- package/package.json +79 -6
|
@@ -47,6 +47,13 @@ declare const strings: {
|
|
|
47
47
|
last12Months: string;
|
|
48
48
|
thisYear: string;
|
|
49
49
|
lastYear: string;
|
|
50
|
+
quarterToDate: string;
|
|
51
|
+
lastQuarter: string;
|
|
52
|
+
/** `variant="report"`: the length of the range in the footer. */
|
|
53
|
+
dayCount: {
|
|
54
|
+
one: string;
|
|
55
|
+
other: string;
|
|
56
|
+
};
|
|
50
57
|
/** The preset that lets people pick their own dates in the calendar. */
|
|
51
58
|
custom: string;
|
|
52
59
|
/** With `confirm`: the footer buttons, and the footer line while the range is not complete. */
|
|
@@ -64,7 +71,7 @@ declare module '../localize.js' {
|
|
|
64
71
|
* whole previous day, week, month or year. Weeks start on the picker's first day of the week. `custom` is not a range:
|
|
65
72
|
* it is the "Custom" button that leaves the dates to the calendar (since 1.16).
|
|
66
73
|
*/
|
|
67
|
-
export type DateRangePresetKey = 'today' | 'yesterday' | 'this-week' | 'last-week' | 'last-7-days' | 'last-28-days' | 'last-30-days' | 'last-90-days' | 'last-12-months' | 'this-month' | 'last-month' | 'this-year' | 'last-year' | 'custom';
|
|
74
|
+
export type DateRangePresetKey = 'today' | 'yesterday' | 'this-week' | 'last-week' | 'last-7-days' | 'last-28-days' | 'last-30-days' | 'last-90-days' | 'last-12-months' | 'this-month' | 'last-month' | 'quarter-to-date' | 'last-quarter' | 'this-year' | 'last-year' | 'custom';
|
|
68
75
|
/** A custom preset: a label and ISO start and end dates. */
|
|
69
76
|
export interface DateRangePreset {
|
|
70
77
|
label: string;
|
|
@@ -157,6 +164,15 @@ export declare class CmDateRangePicker extends CmLocalizedElement {
|
|
|
157
164
|
type: BooleanConstructor;
|
|
158
165
|
reflect: boolean;
|
|
159
166
|
};
|
|
167
|
+
variant: {
|
|
168
|
+
reflect: boolean;
|
|
169
|
+
};
|
|
170
|
+
_dStartText: {
|
|
171
|
+
state: boolean;
|
|
172
|
+
};
|
|
173
|
+
_dEndText: {
|
|
174
|
+
state: boolean;
|
|
175
|
+
};
|
|
160
176
|
startLabel: {
|
|
161
177
|
attribute: string;
|
|
162
178
|
string: string;
|
|
@@ -255,6 +271,14 @@ export declare class CmDateRangePicker extends CmLocalizedElement {
|
|
|
255
271
|
* Without it, choosing a preset or the end date changes the range at once.
|
|
256
272
|
*/
|
|
257
273
|
confirm: boolean;
|
|
274
|
+
/**
|
|
275
|
+
* `report` (since 1.18): the layout for report and dashboard pages. The field is one button that shows the preset
|
|
276
|
+
* and the range ("Last 28 days · 23 Oct – 19 Nov 2026"); the popup has the presets on the left ("Custom" first, each
|
|
277
|
+
* with its dates), start and end date boxes, months to scroll through, and Cancel and Apply. It always works as with
|
|
278
|
+
* `confirm`. Without `presets` it lists custom, today, yesterday, this week, last 7 days, last week, last 28 days,
|
|
279
|
+
* last 30 days, this month, last month, last 90 days, quarter to date and this year.
|
|
280
|
+
*/
|
|
281
|
+
variant: '' | 'report';
|
|
258
282
|
/** Accessible name of the start input. Default: the built-in string `start` ("Start date"). */
|
|
259
283
|
startLabel: string;
|
|
260
284
|
/** Accessible name of the end input. Default: the built-in string `end` ("End date"). */
|
|
@@ -277,6 +301,9 @@ export declare class CmDateRangePicker extends CmLocalizedElement {
|
|
|
277
301
|
_view: Date;
|
|
278
302
|
/** With `confirm`: the preset key of the draft range. */
|
|
279
303
|
_draftPreset: string;
|
|
304
|
+
/** `variant="report"`: the text in the popup's start and end boxes (the draft, or what is being typed). */
|
|
305
|
+
_dStartText: string;
|
|
306
|
+
_dEndText: string;
|
|
280
307
|
static styles: import("lit").CSSResult[];
|
|
281
308
|
connectedCallback(): void;
|
|
282
309
|
disconnectedCallback(): void;
|
|
@@ -9,7 +9,7 @@ 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 _CmDateRangePicker_instances, _CmDateRangePicker_localeProp, _CmDateRangePicker_internals, _CmDateRangePicker_v, _CmDateRangePicker_id, _CmDateRangePicker_default, _CmDateRangePicker_ownPreset, _CmDateRangePicker_custom, _CmDateRangePicker_keepText, _CmDateRangePicker_focusGrid, _CmDateRangePicker_locale_get, _CmDateRangePicker_fmt_get, _CmDateRangePicker_firstDay_get, _CmDateRangePicker_monthCount_get, _CmDateRangePicker_show, _CmDateRangePicker_listed_get, _CmDateRangePicker_hasCustom_get, _CmDateRangePicker_picking, _CmDateRangePicker_pattern_get, _CmDateRangePicker_format, _CmDateRangePicker_layer, _CmDateRangePicker_emit, _CmDateRangePicker_setRange, _CmDateRangePicker_commitText, _CmDateRangePicker_pick, _CmDateRangePicker_applyPreset, _CmDateRangePicker_pickCustom, _CmDateRangePicker_apply, _CmDateRangePicker_cancel, _CmDateRangePicker_focusTrigger, _CmDateRangePicker_toggle, _CmDateRangePicker_onInputKey, _CmDateRangePicker_onGridKey, _CmDateRangePicker_onPopKey, _CmDateRangePicker_onOutside, _CmDateRangePicker_mark;
|
|
12
|
+
var _CmDateRangePicker_instances, _CmDateRangePicker_localeProp, _CmDateRangePicker_internals, _CmDateRangePicker_v, _CmDateRangePicker_id, _CmDateRangePicker_default, _CmDateRangePicker_ownPreset, _CmDateRangePicker_custom, _CmDateRangePicker_keepText, _CmDateRangePicker_focusGrid, _CmDateRangePicker_scrollMonths, _CmDateRangePicker_report_get, _CmDateRangePicker_confirming_get, _CmDateRangePicker_locale_get, _CmDateRangePicker_fmt_get, _CmDateRangePicker_firstDay_get, _CmDateRangePicker_syncDraftText, _CmDateRangePicker_monthCount_get, _CmDateRangePicker_show, _CmDateRangePicker_presetList_get, _CmDateRangePicker_listed_get, _CmDateRangePicker_hasCustom_get, _CmDateRangePicker_picking, _CmDateRangePicker_pattern_get, _CmDateRangePicker_format, _CmDateRangePicker_layer, _CmDateRangePicker_emit, _CmDateRangePicker_setRange, _CmDateRangePicker_commitText, _CmDateRangePicker_pick, _CmDateRangePicker_applyPreset, _CmDateRangePicker_pickCustom, _CmDateRangePicker_apply, _CmDateRangePicker_commitDraftText, _CmDateRangePicker_draftBad, _CmDateRangePicker_cancel, _CmDateRangePicker_focusTrigger, _CmDateRangePicker_toggle, _CmDateRangePicker_onInputKey, _CmDateRangePicker_onGridKey, _CmDateRangePicker_onPopKey, _CmDateRangePicker_onOutside, _CmDateRangePicker_mark, _CmDateRangePicker_span, _CmDateRangePicker_reportMonths_get, _CmDateRangePicker_renderReport;
|
|
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';
|
|
@@ -64,6 +64,10 @@ const strings = defineStrings('dateRangePicker', {
|
|
|
64
64
|
last12Months: 'Last 12 months',
|
|
65
65
|
thisYear: 'This year',
|
|
66
66
|
lastYear: 'Last year',
|
|
67
|
+
quarterToDate: 'Quarter to date',
|
|
68
|
+
lastQuarter: 'Last quarter',
|
|
69
|
+
/** `variant="report"`: the length of the range in the footer. */
|
|
70
|
+
dayCount: { one: '{count} day', other: '{count} days' },
|
|
67
71
|
/** The preset that lets people pick their own dates in the calendar. */
|
|
68
72
|
custom: 'Custom',
|
|
69
73
|
/** With `confirm`: the footer buttons, and the footer line while the range is not complete. */
|
|
@@ -84,6 +88,8 @@ const PRESETS = {
|
|
|
84
88
|
'last-12-months': ['Last 12 months', (t) => [addDays(addMonths(t, -12), 1), t]],
|
|
85
89
|
'this-month': ['This month', (t) => [startOfMonth(t), t]],
|
|
86
90
|
'last-month': ['Last month', (t) => [startOfMonth(addMonths(t, -1)), endOfMonth(addMonths(t, -1))]],
|
|
91
|
+
'quarter-to-date': ['Quarter to date', (t) => [new Date(t.getFullYear(), t.getMonth() - (t.getMonth() % 3), 1), t]],
|
|
92
|
+
'last-quarter': ['Last quarter', (t) => { const q = new Date(t.getFullYear(), t.getMonth() - (t.getMonth() % 3) - 3, 1); return [q, endOfMonth(addMonths(q, 2))]; }],
|
|
87
93
|
'this-year': ['This year', (t) => [new Date(t.getFullYear(), 0, 1), t]],
|
|
88
94
|
'last-year': ['Last year', (t) => [new Date(t.getFullYear() - 1, 0, 1), new Date(t.getFullYear() - 1, 11, 31)]],
|
|
89
95
|
};
|
|
@@ -103,6 +109,9 @@ export function resolvePreset(p, today = new Date(), label, firstDayOfWeek = 0)
|
|
|
103
109
|
const [s, e] = def[1](t, firstDayOfWeek);
|
|
104
110
|
return { label: label?.(presetKey(p)) || def[0], start: toISO(s), end: toISO(e) };
|
|
105
111
|
}
|
|
112
|
+
/** Presets of `variant="report"` when `presets` is empty. */
|
|
113
|
+
const REPORT_PRESETS = ['custom', 'today', 'yesterday', 'this-week', 'last-7-days', 'last-week', 'last-28-days',
|
|
114
|
+
'last-30-days', 'this-month', 'last-month', 'last-90-days', 'quarter-to-date', 'this-year'];
|
|
106
115
|
/**
|
|
107
116
|
* Date range field for report and order filters: type a start and end date or pick them in a calendar, or choose
|
|
108
117
|
* a preset range such as "Last 7 days". The calendar is the same APG date picker grid as `cm-date-picker`: the first
|
|
@@ -164,6 +173,14 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
164
173
|
* Without it, choosing a preset or the end date changes the range at once.
|
|
165
174
|
*/
|
|
166
175
|
this.confirm = false;
|
|
176
|
+
/**
|
|
177
|
+
* `report` (since 1.18): the layout for report and dashboard pages. The field is one button that shows the preset
|
|
178
|
+
* and the range ("Last 28 days · 23 Oct – 19 Nov 2026"); the popup has the presets on the left ("Custom" first, each
|
|
179
|
+
* with its dates), start and end date boxes, months to scroll through, and Cancel and Apply. It always works as with
|
|
180
|
+
* `confirm`. Without `presets` it lists custom, today, yesterday, this week, last 7 days, last week, last 28 days,
|
|
181
|
+
* last 30 days, this month, last month, last 90 days, quarter to date and this year.
|
|
182
|
+
*/
|
|
183
|
+
this.variant = '';
|
|
167
184
|
/** The form will not submit until both dates are set. */
|
|
168
185
|
this.required = false;
|
|
169
186
|
/** Blocks interaction. Also set by a disabled `<fieldset>`. */
|
|
@@ -182,6 +199,9 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
182
199
|
this._view = startOfMonth(new Date());
|
|
183
200
|
/** With `confirm`: the preset key of the draft range. */
|
|
184
201
|
this._draftPreset = '';
|
|
202
|
+
/** `variant="report"`: the text in the popup's start and end boxes (the draft, or what is being typed). */
|
|
203
|
+
this._dStartText = '';
|
|
204
|
+
this._dEndText = '';
|
|
185
205
|
_CmDateRangePicker_internals.set(this, this.attachInternals());
|
|
186
206
|
_CmDateRangePicker_v.set(this, new FieldValidity(this, __classPrivateFieldGet(this, _CmDateRangePicker_internals, "f")));
|
|
187
207
|
_CmDateRangePicker_id.set(this, nextId('cm-drp'));
|
|
@@ -192,6 +212,8 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
192
212
|
_CmDateRangePicker_custom.set(this, false);
|
|
193
213
|
_CmDateRangePicker_keepText.set(this, false);
|
|
194
214
|
_CmDateRangePicker_focusGrid.set(this, false);
|
|
215
|
+
/** `variant="report"`: scroll the months so the draft's first month is at the top after the next render. */
|
|
216
|
+
_CmDateRangePicker_scrollMonths.set(this, false);
|
|
195
217
|
_CmDateRangePicker_picking.set(this, 'start');
|
|
196
218
|
_CmDateRangePicker_layer.set(this, new TopLayer());
|
|
197
219
|
_CmDateRangePicker_toggle.set(this, () => {
|
|
@@ -200,8 +222,10 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
200
222
|
if (this.open)
|
|
201
223
|
this.open = false;
|
|
202
224
|
else {
|
|
203
|
-
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "
|
|
204
|
-
|
|
225
|
+
if (!__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_report_get)) {
|
|
226
|
+
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_commitText).call(this, 'start');
|
|
227
|
+
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_commitText).call(this, 'end');
|
|
228
|
+
}
|
|
205
229
|
this.show();
|
|
206
230
|
}
|
|
207
231
|
});
|
|
@@ -296,6 +320,8 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
296
320
|
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_show).call(this, this._focus);
|
|
297
321
|
__classPrivateFieldSet(this, _CmDateRangePicker_picking, 'start', "f");
|
|
298
322
|
__classPrivateFieldSet(this, _CmDateRangePicker_focusGrid, true, "f");
|
|
323
|
+
__classPrivateFieldSet(this, _CmDateRangePicker_scrollMonths, true, "f");
|
|
324
|
+
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_syncDraftText).call(this);
|
|
299
325
|
this.open = true;
|
|
300
326
|
}
|
|
301
327
|
/** Closes the calendar without changing the range. */
|
|
@@ -353,8 +379,10 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
353
379
|
fd.append(this.endName || `${this.name}-end`, this.end);
|
|
354
380
|
}
|
|
355
381
|
__classPrivateFieldGet(this, _CmDateRangePicker_internals, "f").setFormValue(s || e ? fd : null, `${this.start}/${this.end}`);
|
|
356
|
-
|
|
357
|
-
const
|
|
382
|
+
// The report layout has no boxes in the field: its messages point at the field's button.
|
|
383
|
+
const inputs = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_report_get) ? [] : [...this.renderRoot.querySelectorAll('.box input')];
|
|
384
|
+
const anchor = this.renderRoot.querySelector('.trigger') ?? undefined;
|
|
385
|
+
const [inS, inE] = [inputs[0] ?? anchor, inputs[1] ?? anchor];
|
|
358
386
|
const fmt = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_fmt_get);
|
|
359
387
|
const min = fromISO(this.min), max = fromISO(this.max);
|
|
360
388
|
if (this.error)
|
|
@@ -380,6 +408,15 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
380
408
|
__classPrivateFieldSet(this, _CmDateRangePicker_focusGrid, false, "f");
|
|
381
409
|
this.renderRoot.querySelector('td[tabindex="0"]')?.focus();
|
|
382
410
|
}
|
|
411
|
+
if (this.open && __classPrivateFieldGet(this, _CmDateRangePicker_scrollMonths, "f")) {
|
|
412
|
+
__classPrivateFieldSet(this, _CmDateRangePicker_scrollMonths, false, "f");
|
|
413
|
+
const list = this.renderRoot.querySelector('.r-months');
|
|
414
|
+
const first = fromISO(this._draftStart) ?? this._focus;
|
|
415
|
+
const month = list?.querySelector(`[data-month="${toISO(startOfMonth(first)).slice(0, 7)}"]`);
|
|
416
|
+
const week = list?.querySelector('.r-week');
|
|
417
|
+
if (list && month)
|
|
418
|
+
list.scrollTop = month.offsetTop - (week?.offsetHeight ?? 0);
|
|
419
|
+
}
|
|
383
420
|
}
|
|
384
421
|
render() {
|
|
385
422
|
const fmt = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_fmt_get);
|
|
@@ -390,7 +427,7 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
390
427
|
const name = this.label || hostLabel || '';
|
|
391
428
|
const presets = this.open ? __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_listed_get) : [];
|
|
392
429
|
// The pressed preset: with `confirm` the draft's, else the range's. A key wins over matching dates.
|
|
393
|
-
const [rs, re, key] = this
|
|
430
|
+
const [rs, re, key] = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_confirming_get) ? [this._draftStart, this._draftEnd, this._draftPreset] : [this.start, this.end, this.preset];
|
|
394
431
|
const keyed = !__classPrivateFieldGet(this, _CmDateRangePicker_custom, "f") && !!key && presets.some((p) => p.key === key);
|
|
395
432
|
const pressed = (p) => !__classPrivateFieldGet(this, _CmDateRangePicker_custom, "f") && (keyed ? p.key === key : p.start === rs && p.end === re);
|
|
396
433
|
const customPressed = __classPrivateFieldGet(this, _CmDateRangePicker_custom, "f") || (!presets.some(pressed) && !!(rs || re));
|
|
@@ -433,7 +470,7 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
433
470
|
${this.label
|
|
434
471
|
? html `<span class="label" id="${__classPrivateFieldGet(this, _CmDateRangePicker_id, "f")}-l" part="label">${this.label}${this.required ? html `<span class="req" aria-hidden="true">*</span>` : nothing}</span>`
|
|
435
472
|
: nothing}
|
|
436
|
-
|
|
473
|
+
${__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_report_get) ? __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_renderReport).call(this, name, message, described) : html `<div class="wrap">
|
|
437
474
|
<div class="box" part="box">
|
|
438
475
|
${input('start')}<span class="sep" aria-hidden="true">–</span>${input('end')}
|
|
439
476
|
<button type="button" class="trigger" part="trigger" ?disabled=${this.disabled}
|
|
@@ -452,7 +489,7 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
452
489
|
<div>
|
|
453
490
|
<div class="cals">${Array.from({ length: months }, (_, i) => html `<div class="cal">${grid(i)}</div>`)}</div>
|
|
454
491
|
<p class="status" aria-live="polite">${status}</p>
|
|
455
|
-
${this
|
|
492
|
+
${__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_confirming_get) && !__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_report_get) ? html `<div class="foot" part="footer">
|
|
456
493
|
<span class="draft">${ds && de ? `${fmt.medium(ds)} – ${fmt.medium(de)}` : ds ? `${fmt.medium(ds)} –` : this.t('noRange')}</span>
|
|
457
494
|
<button type="button" class="act" @click=${() => __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_cancel).call(this)}>${this.t('cancel')}</button>
|
|
458
495
|
<button type="button" class="act primary" ?disabled=${!ds || !de} @click=${() => __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_apply).call(this)}>${this.t('apply')}</button>
|
|
@@ -460,15 +497,18 @@ export class CmDateRangePicker extends CmLocalizedElement {
|
|
|
460
497
|
</div>
|
|
461
498
|
</div>` : nothing}
|
|
462
499
|
</div>
|
|
463
|
-
</div
|
|
500
|
+
</div>`}
|
|
464
501
|
${message ? html `<p class="error" id="${__classPrivateFieldGet(this, _CmDateRangePicker_id, "f")}-err" role="alert">${message}</p>` : nothing}
|
|
465
502
|
${this.helpText ? html `<p class="help" id="${__classPrivateFieldGet(this, _CmDateRangePicker_id, "f")}-help">${this.helpText}</p>` : nothing}
|
|
466
503
|
</div>`;
|
|
467
504
|
}
|
|
468
505
|
}
|
|
469
|
-
_CmDateRangePicker_localeProp = new WeakMap(), _CmDateRangePicker_internals = new WeakMap(), _CmDateRangePicker_v = new WeakMap(), _CmDateRangePicker_id = new WeakMap(), _CmDateRangePicker_default = new WeakMap(), _CmDateRangePicker_ownPreset = new WeakMap(), _CmDateRangePicker_custom = new WeakMap(), _CmDateRangePicker_keepText = new WeakMap(), _CmDateRangePicker_focusGrid = new WeakMap(), _CmDateRangePicker_picking = new WeakMap(), _CmDateRangePicker_layer = new WeakMap(), _CmDateRangePicker_toggle = new WeakMap(), _CmDateRangePicker_onInputKey = new WeakMap(), _CmDateRangePicker_onGridKey = new WeakMap(), _CmDateRangePicker_onPopKey = new WeakMap(), _CmDateRangePicker_onOutside = new WeakMap(), _CmDateRangePicker_instances = new WeakSet(), _CmDateRangePicker_locale_get = function _CmDateRangePicker_locale_get() { return resolveLocale(this, this.locale); }, _CmDateRangePicker_fmt_get = function _CmDateRangePicker_fmt_get() { return dateFormat(__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_locale_get)); }, _CmDateRangePicker_firstDay_get = function _CmDateRangePicker_firstDay_get() {
|
|
506
|
+
_CmDateRangePicker_localeProp = new WeakMap(), _CmDateRangePicker_internals = new WeakMap(), _CmDateRangePicker_v = new WeakMap(), _CmDateRangePicker_id = new WeakMap(), _CmDateRangePicker_default = new WeakMap(), _CmDateRangePicker_ownPreset = new WeakMap(), _CmDateRangePicker_custom = new WeakMap(), _CmDateRangePicker_keepText = new WeakMap(), _CmDateRangePicker_focusGrid = new WeakMap(), _CmDateRangePicker_scrollMonths = new WeakMap(), _CmDateRangePicker_picking = new WeakMap(), _CmDateRangePicker_layer = new WeakMap(), _CmDateRangePicker_toggle = new WeakMap(), _CmDateRangePicker_onInputKey = new WeakMap(), _CmDateRangePicker_onGridKey = new WeakMap(), _CmDateRangePicker_onPopKey = new WeakMap(), _CmDateRangePicker_onOutside = new WeakMap(), _CmDateRangePicker_instances = new WeakSet(), _CmDateRangePicker_report_get = function _CmDateRangePicker_report_get() { return this.variant === 'report'; }, _CmDateRangePicker_confirming_get = function _CmDateRangePicker_confirming_get() { return this.confirm || __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_report_get); }, _CmDateRangePicker_locale_get = function _CmDateRangePicker_locale_get() { return resolveLocale(this, this.locale); }, _CmDateRangePicker_fmt_get = function _CmDateRangePicker_fmt_get() { return dateFormat(__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_locale_get)); }, _CmDateRangePicker_firstDay_get = function _CmDateRangePicker_firstDay_get() {
|
|
470
507
|
const n = Number(this.firstDayOfWeek);
|
|
471
508
|
return this.firstDayOfWeek == null || Number.isNaN(n) ? localeFirstDay(__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_locale_get)) : ((Math.trunc(n) % 7) + 7) % 7;
|
|
509
|
+
}, _CmDateRangePicker_syncDraftText = function _CmDateRangePicker_syncDraftText() {
|
|
510
|
+
this._dStartText = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_format).call(this, this._draftStart);
|
|
511
|
+
this._dEndText = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_format).call(this, this._draftEnd);
|
|
472
512
|
}, _CmDateRangePicker_monthCount_get = function _CmDateRangePicker_monthCount_get() {
|
|
473
513
|
if (Number(this.months) !== 2)
|
|
474
514
|
return 1;
|
|
@@ -480,12 +520,15 @@ _CmDateRangePicker_localeProp = new WeakMap(), _CmDateRangePicker_internals = ne
|
|
|
480
520
|
this._view = m;
|
|
481
521
|
else if (m >= addMonths(this._view, n))
|
|
482
522
|
this._view = addMonths(m, 1 - n);
|
|
523
|
+
}, _CmDateRangePicker_presetList_get = function _CmDateRangePicker_presetList_get() {
|
|
524
|
+
const list = asList(this.presets);
|
|
525
|
+
return list.length || !__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_report_get) ? list : REPORT_PRESETS;
|
|
483
526
|
}, _CmDateRangePicker_listed_get = function _CmDateRangePicker_listed_get() {
|
|
484
|
-
return
|
|
527
|
+
return __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_presetList_get).flatMap((p) => {
|
|
485
528
|
const r = resolvePreset(p, new Date(), (k) => this.t(k), __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_firstDay_get));
|
|
486
529
|
return r ? [{ ...r, key: typeof p === 'string' ? p : '' }] : [];
|
|
487
530
|
});
|
|
488
|
-
}, _CmDateRangePicker_hasCustom_get = function _CmDateRangePicker_hasCustom_get() { return
|
|
531
|
+
}, _CmDateRangePicker_hasCustom_get = function _CmDateRangePicker_hasCustom_get() { return __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_presetList_get).includes('custom'); }, _CmDateRangePicker_pattern_get = function _CmDateRangePicker_pattern_get() { return datePattern(__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_fmt_get), { d: this.t('patternDay'), m: this.t('patternMonth'), y: this.t('patternYear') }); }, _CmDateRangePicker_format = function _CmDateRangePicker_format(v) { const d = fromISO(v); return d ? __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_fmt_get).short(d) : v; }, _CmDateRangePicker_emit = function _CmDateRangePicker_emit() {
|
|
489
532
|
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
490
533
|
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
491
534
|
}, _CmDateRangePicker_setRange = function _CmDateRangePicker_setRange(start, end, key) {
|
|
@@ -524,11 +567,13 @@ _CmDateRangePicker_localeProp = new WeakMap(), _CmDateRangePicker_internals = ne
|
|
|
524
567
|
__classPrivateFieldSet(this, _CmDateRangePicker_picking, 'end', "f");
|
|
525
568
|
this._focus = d;
|
|
526
569
|
__classPrivateFieldSet(this, _CmDateRangePicker_focusGrid, true, "f");
|
|
570
|
+
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_syncDraftText).call(this);
|
|
527
571
|
return;
|
|
528
572
|
}
|
|
529
573
|
this._draftEnd = iso;
|
|
574
|
+
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_syncDraftText).call(this);
|
|
530
575
|
__classPrivateFieldSet(this, _CmDateRangePicker_picking, 'start', "f");
|
|
531
|
-
if (this
|
|
576
|
+
if (__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_confirming_get)) {
|
|
532
577
|
this._focus = d;
|
|
533
578
|
__classPrivateFieldSet(this, _CmDateRangePicker_focusGrid, true, "f");
|
|
534
579
|
return;
|
|
@@ -537,7 +582,7 @@ _CmDateRangePicker_localeProp = new WeakMap(), _CmDateRangePicker_internals = ne
|
|
|
537
582
|
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_setRange).call(this, this._draftStart, iso, '');
|
|
538
583
|
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_focusTrigger).call(this);
|
|
539
584
|
}, _CmDateRangePicker_applyPreset = function _CmDateRangePicker_applyPreset(p) {
|
|
540
|
-
if (this
|
|
585
|
+
if (__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_confirming_get)) {
|
|
541
586
|
// A draft: shown in the calendar and the footer until Apply.
|
|
542
587
|
this._draftStart = p.start;
|
|
543
588
|
this._draftEnd = p.end;
|
|
@@ -548,6 +593,8 @@ _CmDateRangePicker_localeProp = new WeakMap(), _CmDateRangePicker_internals = ne
|
|
|
548
593
|
this._focus = clamp(end, fromISO(this.min), fromISO(this.max));
|
|
549
594
|
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_show).call(this, fromISO(p.start));
|
|
550
595
|
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_show).call(this, end);
|
|
596
|
+
__classPrivateFieldSet(this, _CmDateRangePicker_scrollMonths, true, "f");
|
|
597
|
+
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_syncDraftText).call(this);
|
|
551
598
|
return;
|
|
552
599
|
}
|
|
553
600
|
this.open = false;
|
|
@@ -565,6 +612,39 @@ _CmDateRangePicker_localeProp = new WeakMap(), _CmDateRangePicker_internals = ne
|
|
|
565
612
|
this.open = false;
|
|
566
613
|
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_setRange).call(this, this._draftStart, this._draftEnd, __classPrivateFieldGet(this, _CmDateRangePicker_custom, "f") ? '' : this._draftPreset || undefined);
|
|
567
614
|
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_focusTrigger).call(this);
|
|
615
|
+
}, _CmDateRangePicker_commitDraftText = function _CmDateRangePicker_commitDraftText(which) {
|
|
616
|
+
const text = (which === 'start' ? this._dStartText : this._dEndText).trim();
|
|
617
|
+
const iso = text ? parseDate(text, __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_fmt_get)) : '';
|
|
618
|
+
if (iso === null || (iso && this.isUnavailable(iso))) {
|
|
619
|
+
this.requestUpdate();
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
__classPrivateFieldSet(this, _CmDateRangePicker_custom, true, "f");
|
|
623
|
+
this._draftPreset = '';
|
|
624
|
+
if (which === 'start') {
|
|
625
|
+
this._draftStart = iso;
|
|
626
|
+
if (iso && this._draftEnd && this._draftEnd < iso)
|
|
627
|
+
this._draftEnd = '';
|
|
628
|
+
}
|
|
629
|
+
else if (iso && this._draftStart && iso < this._draftStart) {
|
|
630
|
+
this._draftEnd = this._draftStart;
|
|
631
|
+
this._draftStart = iso;
|
|
632
|
+
}
|
|
633
|
+
else
|
|
634
|
+
this._draftEnd = iso;
|
|
635
|
+
__classPrivateFieldSet(this, _CmDateRangePicker_picking, this._draftStart && !this._draftEnd ? 'end' : 'start', "f");
|
|
636
|
+
const d = fromISO(iso);
|
|
637
|
+
if (d) {
|
|
638
|
+
this._focus = d;
|
|
639
|
+
__classPrivateFieldSet(this, _CmDateRangePicker_scrollMonths, which === 'start', "f");
|
|
640
|
+
}
|
|
641
|
+
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_syncDraftText).call(this);
|
|
642
|
+
}, _CmDateRangePicker_draftBad = function _CmDateRangePicker_draftBad(which) {
|
|
643
|
+
const text = (which === 'start' ? this._dStartText : this._dEndText).trim();
|
|
644
|
+
if (!text)
|
|
645
|
+
return false;
|
|
646
|
+
const iso = parseDate(text, __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_fmt_get));
|
|
647
|
+
return !iso || this.isUnavailable(iso);
|
|
568
648
|
}, _CmDateRangePicker_cancel = function _CmDateRangePicker_cancel() {
|
|
569
649
|
this.open = false;
|
|
570
650
|
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_focusTrigger).call(this);
|
|
@@ -579,6 +659,112 @@ _CmDateRangePicker_localeProp = new WeakMap(), _CmDateRangePicker_internals = ne
|
|
|
579
659
|
if (s && e && iso > s && iso < e)
|
|
580
660
|
return 'in-range';
|
|
581
661
|
return '';
|
|
662
|
+
}, _CmDateRangePicker_span = function _CmDateRangePicker_span(start, end, year) {
|
|
663
|
+
const a = fromISO(start), b = fromISO(end);
|
|
664
|
+
if (!a)
|
|
665
|
+
return '';
|
|
666
|
+
const f = new Intl.DateTimeFormat(__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_locale_get), { day: 'numeric', month: 'short', ...(year ? { year: 'numeric' } : {}) });
|
|
667
|
+
const range = f.formatRange;
|
|
668
|
+
const out = !b || +a === +b ? f.format(a) : range ? range.call(f, a, b) : `${f.format(a)} – ${f.format(b)}`;
|
|
669
|
+
return out.replace(/[\u202f\u2009\u00a0]/g, ' ');
|
|
670
|
+
}, _CmDateRangePicker_reportMonths_get = function _CmDateRangePicker_reportMonths_get() {
|
|
671
|
+
const points = [new Date(), fromISO(this._draftStart), fromISO(this._draftEnd), this._focus].filter((d) => !!d).map(Number);
|
|
672
|
+
let first = addMonths(startOfMonth(new Date(Math.min(...points))), -12);
|
|
673
|
+
let last = addMonths(startOfMonth(new Date(Math.max(...points))), 2);
|
|
674
|
+
const min = fromISO(this.min), max = fromISO(this.max);
|
|
675
|
+
if (min && startOfMonth(min) > first)
|
|
676
|
+
first = startOfMonth(min);
|
|
677
|
+
if (max && startOfMonth(max) < last)
|
|
678
|
+
last = startOfMonth(max);
|
|
679
|
+
if (first > last)
|
|
680
|
+
first = last;
|
|
681
|
+
const out = [];
|
|
682
|
+
for (let m = first; m <= last && out.length < 600; m = addMonths(m, 1))
|
|
683
|
+
out.push(m);
|
|
684
|
+
return out;
|
|
685
|
+
}, _CmDateRangePicker_renderReport = function _CmDateRangePicker_renderReport(name, message, described) {
|
|
686
|
+
const fmt = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_fmt_get);
|
|
687
|
+
const s = fromISO(this.start), e = fromISO(this.end);
|
|
688
|
+
const presets = this.open ? __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_listed_get) : [];
|
|
689
|
+
const [rs, re, key] = [this._draftStart, this._draftEnd, this._draftPreset];
|
|
690
|
+
const keyed = !__classPrivateFieldGet(this, _CmDateRangePicker_custom, "f") && !!key && presets.some((p) => p.key === key);
|
|
691
|
+
const pressed = (p) => !__classPrivateFieldGet(this, _CmDateRangePicker_custom, "f") && (keyed ? p.key === key : p.start === rs && p.end === re);
|
|
692
|
+
const customPressed = __classPrivateFieldGet(this, _CmDateRangePicker_custom, "f") || (!presets.some(pressed) && !!(rs || re));
|
|
693
|
+
const thisYear = new Date().getFullYear();
|
|
694
|
+
const presetLabel = this.preset && this.preset !== 'custom'
|
|
695
|
+
? resolvePreset(this.preset, new Date(), (k) => this.t(k), __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_firstDay_get))?.label ?? ''
|
|
696
|
+
: s && e && __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_hasCustom_get) ? this.t('custom') : '';
|
|
697
|
+
const range = s && e ? __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_span).call(this, this.start, this.end, true) : '';
|
|
698
|
+
const order = Array.from({ length: 7 }, (_, i) => (i + __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_firstDay_get)) % 7);
|
|
699
|
+
const ds = fromISO(rs), de = fromISO(re);
|
|
700
|
+
const days = ds && de ? Math.round((+de - +ds) / 86400000) + 1 : 0;
|
|
701
|
+
const status = __classPrivateFieldGet(this, _CmDateRangePicker_picking, "f") === 'end' && rs ? this.t('chooseEnd', { date: fmt.medium(ds) }) : this.t('chooseStart');
|
|
702
|
+
const triggerName = s && e ? this.t(name ? 'changeFor' : 'change', { label: name, start: fmt.long(s), end: fmt.long(e) }) : this.t(name ? 'chooseFor' : 'choose', { label: name });
|
|
703
|
+
const box = (which) => {
|
|
704
|
+
const bad = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_draftBad).call(this, which);
|
|
705
|
+
return html `<label class="r-in"><span>${which === 'start' ? this.startLabel || this.t('start') : this.endLabel || this.t('end')}</span>
|
|
706
|
+
<input id="${__classPrivateFieldGet(this, _CmDateRangePicker_id, "f")}-d${which}" type="text" autocomplete="off" spellcheck="false" placeholder=${__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_pattern_get)}
|
|
707
|
+
.value=${live(which === 'start' ? this._dStartText : this._dEndText)} aria-invalid=${bad ? 'true' : nothing}
|
|
708
|
+
@input=${(ev) => { ev.stopPropagation(); const v = ev.target.value; if (which === 'start')
|
|
709
|
+
this._dStartText = v;
|
|
710
|
+
else
|
|
711
|
+
this._dEndText = v; }}
|
|
712
|
+
@change=${(ev) => { ev.stopPropagation(); __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_commitDraftText).call(this, which); }}
|
|
713
|
+
@keydown=${(ev) => { if (ev.key === 'Enter') {
|
|
714
|
+
ev.preventDefault();
|
|
715
|
+
__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_commitDraftText).call(this, which);
|
|
716
|
+
} }} /></label>`;
|
|
717
|
+
};
|
|
718
|
+
const presetItem = (p) => html `<li>
|
|
719
|
+
<button type="button" class="preset" data-preset=${p.key || nothing} aria-pressed=${pressed(p) ? 'true' : 'false'} @click=${() => __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_applyPreset).call(this, p)}>
|
|
720
|
+
<span class="p-label">${p.label}</span><span class="p-span">${__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_span).call(this, p.start, p.end, fromISO(p.start).getFullYear() !== thisYear || fromISO(p.end).getFullYear() !== thisYear)}</span>
|
|
721
|
+
</button></li>`;
|
|
722
|
+
return html `<div class="wrap">
|
|
723
|
+
<button type="button" class="trigger summary" part="trigger" ?disabled=${this.disabled}
|
|
724
|
+
aria-label=${presetLabel ? `${presetLabel}, ${triggerName}` : triggerName} aria-describedby=${described || nothing}
|
|
725
|
+
aria-invalid=${message ? 'true' : nothing}
|
|
726
|
+
aria-haspopup="dialog" aria-expanded=${this.open ? 'true' : 'false'} aria-controls="${__classPrivateFieldGet(this, _CmDateRangePicker_id, "f")}-pop" @click=${__classPrivateFieldGet(this, _CmDateRangePicker_toggle, "f")}>
|
|
727
|
+
${presetLabel ? html `<span class="chip">${presetLabel}</span>` : nothing}
|
|
728
|
+
<span class="range ${range ? '' : 'empty'}">${range || this.t('choose')}</span>
|
|
729
|
+
<cm-icon name="chevron-down" size="16"></cm-icon>
|
|
730
|
+
</button>
|
|
731
|
+
<div class="pop r-pop" id="${__classPrivateFieldGet(this, _CmDateRangePicker_id, "f")}-pop" part="popover" role="dialog" aria-modal="true" aria-label=${this.t('dialog')}
|
|
732
|
+
?hidden=${!this.open} @keydown=${__classPrivateFieldGet(this, _CmDateRangePicker_onPopKey, "f")}>
|
|
733
|
+
${this.open ? html `<div class="r-body">
|
|
734
|
+
<ul class="presets r-presets" part="presets" aria-label=${this.t('presets')}>
|
|
735
|
+
${__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_hasCustom_get) ? html `<li class="custom"><button type="button" class="preset" data-preset="custom" aria-pressed=${customPressed ? 'true' : 'false'}
|
|
736
|
+
@click=${() => __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_pickCustom).call(this)}><span class="p-label">${this.t('custom')}</span></button></li>` : nothing}
|
|
737
|
+
${presets.map(presetItem)}
|
|
738
|
+
</ul>
|
|
739
|
+
<div class="r-main">
|
|
740
|
+
<div class="r-inputs">${box('start')}<span class="sep" aria-hidden="true">–</span>${box('end')}</div>
|
|
741
|
+
<div class="r-months" part="months">
|
|
742
|
+
<div class="r-week" aria-hidden="true">${order.map((d) => html `<span>${fmt.weekdaysShort[d]}</span>`)}</div>
|
|
743
|
+
${__classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_reportMonths_get).map((m) => {
|
|
744
|
+
const k = toISO(m).slice(0, 7);
|
|
745
|
+
return html `<div class="r-month" data-month=${k}>${renderGrid({
|
|
746
|
+
id: `${__classPrivateFieldGet(this, _CmDateRangePicker_id, "f")}-${k}`, fmt, firstDay: __classPrivateFieldGet(this, _CmDateRangePicker_instances, "a", _CmDateRangePicker_firstDay_get), month: m, focus: this._focus, head: 'title',
|
|
747
|
+
min: fromISO(this.min), max: fromISO(this.max),
|
|
748
|
+
isDisabled: (d) => this.isUnavailable(toISO(d)),
|
|
749
|
+
mark: (d) => __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_mark).call(this, d),
|
|
750
|
+
note: (d) => { const mk = __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_mark).call(this, d); return mk === 'start' ? this.t('startNote') : mk === 'end' ? this.t('endNote') : ''; },
|
|
751
|
+
onPick: (d) => __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_pick).call(this, d), onKey: __classPrivateFieldGet(this, _CmDateRangePicker_onGridKey, "f"), onMonth: () => { },
|
|
752
|
+
previousLabel: this.t('previousMonth'), nextLabel: this.t('nextMonth'),
|
|
753
|
+
onHover: (d) => { if (__classPrivateFieldGet(this, _CmDateRangePicker_picking, "f") === 'end')
|
|
754
|
+
this._hover = d; },
|
|
755
|
+
})}</div>`;
|
|
756
|
+
})}
|
|
757
|
+
</div>
|
|
758
|
+
<p class="status vh" aria-live="polite">${status}</p>
|
|
759
|
+
</div>
|
|
760
|
+
</div>
|
|
761
|
+
<div class="foot r-foot" part="footer">
|
|
762
|
+
<span class="draft">${ds && de ? html `${__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_span).call(this, rs, re, true)} <span class="count">· ${this.t('dayCount', { count: days })}</span>` : ds ? `${__classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_span).call(this, rs, '', true)} –` : this.t('noRange')}</span>
|
|
763
|
+
<button type="button" class="act" @click=${() => __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_cancel).call(this)}>${this.t('cancel')}</button>
|
|
764
|
+
<button type="button" class="act primary" ?disabled=${!ds || !de || __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_draftBad).call(this, 'start') || __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_draftBad).call(this, 'end')} @click=${() => __classPrivateFieldGet(this, _CmDateRangePicker_instances, "m", _CmDateRangePicker_apply).call(this)}>${this.t('apply')}</button>
|
|
765
|
+
</div>` : nothing}
|
|
766
|
+
</div>
|
|
767
|
+
</div>`;
|
|
582
768
|
};
|
|
583
769
|
CmDateRangePicker.formAssociated = true;
|
|
584
770
|
CmDateRangePicker.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
@@ -601,6 +787,9 @@ CmDateRangePicker.properties = {
|
|
|
601
787
|
preset: { reflect: true },
|
|
602
788
|
months: { type: Number, reflect: true },
|
|
603
789
|
confirm: { type: Boolean, reflect: true },
|
|
790
|
+
variant: { reflect: true },
|
|
791
|
+
_dStartText: { state: true },
|
|
792
|
+
_dEndText: { state: true },
|
|
604
793
|
startLabel: { attribute: 'start-label', string: 'start' },
|
|
605
794
|
endLabel: { attribute: 'end-label', string: 'end' },
|
|
606
795
|
required: { type: Boolean, reflect: true },
|
|
@@ -649,6 +838,66 @@ CmDateRangePicker.styles = [
|
|
|
649
838
|
.act:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
650
839
|
.act:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
651
840
|
@media (pointer: coarse) { .act { min-height: var(--cm-control-height-touch, 44px); } }
|
|
841
|
+
/* variant="report" (1.18) */
|
|
842
|
+
.summary {
|
|
843
|
+
display: flex; align-items: center; gap: var(--cm-space-8); width: 100%; height: var(--_cm-field-h); margin: 0;
|
|
844
|
+
padding-block: 0; padding-inline: var(--_cm-field-pad) var(--cm-space-8); border: var(--cm-border-1) solid var(--cm-border-input);
|
|
845
|
+
border-radius: var(--cm-radius-sm); background: var(--cm-bg-surface); color: var(--cm-text-default);
|
|
846
|
+
font: inherit; font-size: var(--_cm-field-font); text-align: start; cursor: pointer;
|
|
847
|
+
}
|
|
848
|
+
.summary:hover { border-color: var(--cm-border-strong); background: var(--cm-bg-surface); }
|
|
849
|
+
.summary:focus-visible { outline: 2px solid var(--cm-border-strong); outline-offset: 0; }
|
|
850
|
+
:host([data-cm-invalid]) .summary, :host([error]:not([error=''])) .summary { border-color: var(--cm-border-critical); }
|
|
851
|
+
:host([disabled]) .summary { background: var(--cm-bg-input-filled); border-color: var(--cm-border-subtle); color: var(--cm-text-secondary); cursor: not-allowed; }
|
|
852
|
+
.chip {
|
|
853
|
+
flex: none; padding: 2px var(--cm-space-8); border-radius: var(--cm-radius-xs); background: var(--cm-bg-tag);
|
|
854
|
+
font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12, 16px); font-weight: 500; white-space: nowrap;
|
|
855
|
+
}
|
|
856
|
+
.range { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
|
857
|
+
.range.empty { color: var(--cm-text-tertiary); }
|
|
858
|
+
.summary cm-icon { flex: none; color: var(--cm-icon-selected); }
|
|
859
|
+
.pop.r-pop { padding: 0; }
|
|
860
|
+
/* The popup may be given a max-height (little room above and below the field): the months list shrinks first and the footer stays inside. */
|
|
861
|
+
.pop.r-pop:not([hidden]) { display: flex; flex-direction: column; }
|
|
862
|
+
.r-body { display: flex; flex: 1 1 auto; min-height: 0; }
|
|
863
|
+
.r-foot { flex: none; }
|
|
864
|
+
.r-presets {
|
|
865
|
+
width: 208px; max-height: 456px; min-height: 0; overflow-y: auto; padding: var(--cm-space-8); gap: 0; flex: none;
|
|
866
|
+
border-inline-end: var(--cm-border-1) solid var(--cm-border-subtle);
|
|
867
|
+
}
|
|
868
|
+
.r-presets .preset { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: var(--cm-space-8) var(--cm-space-12); }
|
|
869
|
+
.r-presets li.custom { padding-block-end: var(--cm-space-8); margin-block-end: var(--cm-space-8); border-block-end: var(--cm-border-1) solid var(--cm-border-subtle); }
|
|
870
|
+
.p-span { font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12, 16px); color: var(--cm-text-tertiary); font-variant-numeric: tabular-nums; }
|
|
871
|
+
.r-presets .preset[aria-pressed='true'] { background: var(--cm-bg-selected); color: var(--cm-text-default); font-weight: 600; }
|
|
872
|
+
.r-presets .preset[aria-pressed='true']::before {
|
|
873
|
+
content: ''; position: absolute; inset-block: var(--cm-space-8); inset-inline-start: 0; width: 3px; border-radius: var(--cm-radius-full);
|
|
874
|
+
background: var(--cm-tab-indicator);
|
|
875
|
+
}
|
|
876
|
+
.r-presets .preset[aria-pressed='true'] .p-span { font-weight: 400; color: var(--cm-text-default); }
|
|
877
|
+
.r-main { display: flex; flex-direction: column; min-height: 0; width: 312px; padding: var(--cm-space-16) var(--cm-space-16) 0; }
|
|
878
|
+
.r-inputs { display: flex; align-items: flex-end; gap: var(--cm-space-8); }
|
|
879
|
+
.r-in { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--cm-space-4); font-size: var(--cm-font-size-12); line-height: var(--cm-line-height-12, 16px); color: var(--cm-text-secondary); }
|
|
880
|
+
.r-in input {
|
|
881
|
+
flex: none; width: 100%; height: var(--cm-control-height-md, 36px); padding: 0 var(--cm-space-8); border: var(--cm-border-1) solid var(--cm-border-input);
|
|
882
|
+
border-radius: var(--cm-radius-sm); background: var(--cm-bg-surface); font-size: var(--cm-font-size-14); font-variant-numeric: tabular-nums;
|
|
883
|
+
}
|
|
884
|
+
.r-in input:focus { border-color: var(--cm-border-strong); box-shadow: 0 0 0 1px var(--cm-border-strong); }
|
|
885
|
+
.r-in input[aria-invalid='true'] { border-color: var(--cm-border-critical); }
|
|
886
|
+
.r-inputs .sep { padding-block-end: var(--cm-space-8); }
|
|
887
|
+
.r-months { position: relative; flex: 1 1 312px; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; margin-block-start: var(--cm-space-12); }
|
|
888
|
+
.r-week {
|
|
889
|
+
position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(7, 1fr); height: 32px; align-items: center;
|
|
890
|
+
background: var(--cm-bg-surface); border-block-end: var(--cm-border-1) solid var(--cm-border-subtle);
|
|
891
|
+
font-size: var(--cm-font-size-12); color: var(--cm-text-tertiary); text-align: center;
|
|
892
|
+
}
|
|
893
|
+
.cal-month {
|
|
894
|
+
position: sticky; top: 32px; z-index: 1; margin: 0; padding: var(--cm-space-12) var(--cm-space-4) var(--cm-space-4);
|
|
895
|
+
background: var(--cm-bg-surface); font-size: var(--cm-font-size-13); line-height: var(--cm-line-height-13, 18px); font-weight: 600;
|
|
896
|
+
}
|
|
897
|
+
.r-months .day, .r-months .empty { height: 36px; }
|
|
898
|
+
.r-foot { margin: 0; padding: var(--cm-space-12) var(--cm-space-16); }
|
|
899
|
+
.count { color: var(--cm-text-tertiary); }
|
|
900
|
+
.status.vh { margin: 0; }
|
|
652
901
|
.status { margin: var(--cm-space-8) 0 0; font-size: var(--cm-type-body-xs-size); line-height: var(--cm-type-body-xs-line-height); color: var(--cm-text-tertiary); }
|
|
653
902
|
@media (max-width: 640px) {
|
|
654
903
|
.body { flex-direction: column; }
|
|
@@ -656,6 +905,16 @@ CmDateRangePicker.styles = [
|
|
|
656
905
|
.presets li { flex: 0 0 auto; }
|
|
657
906
|
.preset { width: auto; border: var(--cm-border-1) solid var(--cm-border-subtle); border-radius: var(--cm-radius-full); min-height: 32px; }
|
|
658
907
|
.draft { flex-basis: 100%; }
|
|
908
|
+
.r-body { flex-direction: column; }
|
|
909
|
+
.r-presets { width: auto; max-height: none; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: var(--cm-space-8) var(--cm-space-12); border-inline-end: 0; }
|
|
910
|
+
.r-presets li.custom { padding: 0; margin: 0; border: 0; }
|
|
911
|
+
.r-presets .preset { padding: var(--cm-space-4) var(--cm-space-12); white-space: nowrap; }
|
|
912
|
+
.r-presets .preset[aria-pressed='true'] { background: var(--cm-action-primary); color: var(--cm-action-primary-text); }
|
|
913
|
+
.r-presets .preset[aria-pressed='true']::before, .p-span { display: none; }
|
|
914
|
+
.r-main { width: auto; padding-block-start: var(--cm-space-4); }
|
|
915
|
+
.r-body { overflow-y: auto; }
|
|
916
|
+
.r-presets { flex: none; }
|
|
917
|
+
.r-months { flex-basis: min(312px, 40vh); }
|
|
659
918
|
}
|
|
660
919
|
`,
|
|
661
920
|
];
|