@vialiq/web-components 0.20.0 → 0.22.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 +126 -0
- package/base/controllers/floating-controller.d.ts +2 -2
- package/base/controllers/floating-controller.d.ts.map +1 -1
- package/base/flatpickr-mixin.d.ts +38 -0
- package/base/flatpickr-mixin.d.ts.map +1 -0
- package/base/validity-mixin.d.ts +2 -0
- package/base/validity-mixin.d.ts.map +1 -1
- package/date-picker/i18n.d.ts +19 -0
- package/date-picker/i18n.d.ts.map +1 -0
- package/date-picker/index.d.ts +4 -0
- package/date-picker/index.d.ts.map +1 -0
- package/date-picker/index.js +2 -0
- package/date-picker/iso-week.d.ts +18 -0
- package/date-picker/iso-week.d.ts.map +1 -0
- package/date-picker/locale-registry.d.ts +8 -0
- package/date-picker/locale-registry.d.ts.map +1 -0
- package/date-picker/plugin-registry.d.ts +7 -0
- package/date-picker/plugin-registry.d.ts.map +1 -0
- package/date-picker/plugin-utils.d.ts +10 -0
- package/date-picker/plugin-utils.d.ts.map +1 -0
- package/date-picker/plugins/vi-month-year-plugin.d.ts +17 -0
- package/date-picker/plugins/vi-month-year-plugin.d.ts.map +1 -0
- package/date-picker/plugins/vi-range-plugin.d.ts +12 -0
- package/date-picker/plugins/vi-range-plugin.d.ts.map +1 -0
- package/date-picker/plugins/vi-shadow-dom-plugin.d.ts +18 -0
- package/date-picker/plugins/vi-shadow-dom-plugin.d.ts.map +1 -0
- package/date-picker/types.d.ts +34 -0
- package/date-picker/types.d.ts.map +1 -0
- package/date-picker/vi-date-picker-input.d.ts +34 -0
- package/date-picker/vi-date-picker-input.d.ts.map +1 -0
- package/date-picker/vi-date-picker-input.js +599 -0
- package/date-picker/vi-date-picker.d.ts +95 -0
- package/date-picker/vi-date-picker.d.ts.map +1 -0
- package/date-picker/vi-date-picker.js +2273 -0
- package/index.d.ts +7 -0
- package/index.js +5 -0
- package/input/vi-input.js +1 -1
- package/{keyboard-controller-DqpJtUuK.js → keyboard-controller-D3htDhGR.js} +25 -23
- package/label/index.d.ts +2 -0
- package/label/index.d.ts.map +1 -0
- package/label/index.js +1 -0
- package/label/vi-label.d.ts +53 -0
- package/label/vi-label.d.ts.map +1 -0
- package/label/vi-label.js +552 -0
- package/package.json +32 -4
|
@@ -0,0 +1,2273 @@
|
|
|
1
|
+
import { html, unsafeCSS, css } from 'lit';
|
|
2
|
+
import { property, customElement, state, query, queryAssignedElements } from 'lit/decorators.js';
|
|
3
|
+
import { V as ViElement } from '../vi-element-C6GfDPs3.js';
|
|
4
|
+
import { V as ValidityMixin } from '../validity-mixin-DO0ycRH2.js';
|
|
5
|
+
import { F as FloatingController } from '../keyboard-controller-D3htDhGR.js';
|
|
6
|
+
import '../select/vi-select.js';
|
|
7
|
+
import rangePlugin from 'flatpickr/dist/plugins/rangePlugin.js';
|
|
8
|
+
import './vi-date-picker-input.js';
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
async function loadL10n(importer) {
|
|
12
|
+
const mod = await importer();
|
|
13
|
+
const isLocale = (v)=>!!v && typeof v === 'object' && 'weekdays' in v && 'months' in v;
|
|
14
|
+
// 1. Check if the module exports a named locale directly (e.g. exports.French)
|
|
15
|
+
for (const key of Object.keys(mod)){
|
|
16
|
+
if (key !== 'default' && isLocale(mod[key])) {
|
|
17
|
+
return mod[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// 2. Check if mod.default is the locale directly
|
|
21
|
+
if (isLocale(mod.default)) {
|
|
22
|
+
return mod.default;
|
|
23
|
+
}
|
|
24
|
+
// 3. Check if mod.default is an l10ns map (e.g. { fr: CustomLocale })
|
|
25
|
+
if (mod.default && typeof mod.default === 'object') {
|
|
26
|
+
const l10ns = mod.default;
|
|
27
|
+
for (const key of Object.keys(l10ns)){
|
|
28
|
+
if (isLocale(l10ns[key])) {
|
|
29
|
+
return l10ns[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// 4. Check if mod itself is the l10ns map
|
|
34
|
+
for (const key of Object.keys(mod)){
|
|
35
|
+
if (isLocale(mod[key])) {
|
|
36
|
+
return mod[key];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
// Map of BCP 47 locale tags to flatpickr l10n imports.
|
|
42
|
+
const LOCALE_MAP = {
|
|
43
|
+
ar: ()=>loadL10n(()=>import('flatpickr/dist/l10n/ar.js')),
|
|
44
|
+
de: ()=>loadL10n(()=>import('flatpickr/dist/l10n/de.js')),
|
|
45
|
+
'de-DE': ()=>loadL10n(()=>import('flatpickr/dist/l10n/de.js')),
|
|
46
|
+
es: ()=>loadL10n(()=>import('flatpickr/dist/l10n/es.js')),
|
|
47
|
+
'es-ES': ()=>loadL10n(()=>import('flatpickr/dist/l10n/es.js')),
|
|
48
|
+
fr: ()=>loadL10n(()=>import('flatpickr/dist/l10n/fr.js')),
|
|
49
|
+
'fr-FR': ()=>loadL10n(()=>import('flatpickr/dist/l10n/fr.js')),
|
|
50
|
+
it: ()=>loadL10n(()=>import('flatpickr/dist/l10n/it.js')),
|
|
51
|
+
ja: ()=>loadL10n(()=>import('flatpickr/dist/l10n/ja.js')),
|
|
52
|
+
ko: ()=>loadL10n(()=>import('flatpickr/dist/l10n/ko.js')),
|
|
53
|
+
nl: ()=>loadL10n(()=>import('flatpickr/dist/l10n/nl.js')),
|
|
54
|
+
'pt-BR': ()=>loadL10n(()=>import('flatpickr/dist/l10n/pt.js')),
|
|
55
|
+
pt: ()=>loadL10n(()=>import('flatpickr/dist/l10n/pt.js')),
|
|
56
|
+
'zh-CN': ()=>loadL10n(()=>import('flatpickr/dist/l10n/zh.js')),
|
|
57
|
+
zh: ()=>loadL10n(()=>import('flatpickr/dist/l10n/zh.js'))
|
|
58
|
+
};
|
|
59
|
+
const localeCache = new Map();
|
|
60
|
+
/**
|
|
61
|
+
* Lazily loads a flatpickr locale definition for a given BCP 47 tag.
|
|
62
|
+
* Returns null for English (flatpickr's built-in default) or unsupported locales.
|
|
63
|
+
*/ async function loadLocale(bcp47) {
|
|
64
|
+
// English is built-in
|
|
65
|
+
if (bcp47.startsWith('en')) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
// Check cache
|
|
69
|
+
if (localeCache.has(bcp47)) {
|
|
70
|
+
return localeCache.get(bcp47) ?? null;
|
|
71
|
+
}
|
|
72
|
+
const loadFn = LOCALE_MAP[bcp47] ?? LOCALE_MAP[bcp47.split('-')[0]];
|
|
73
|
+
if (!loadFn) {
|
|
74
|
+
localeCache.set(bcp47, null);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const locale = await loadFn();
|
|
79
|
+
localeCache.set(bcp47, locale);
|
|
80
|
+
return locale;
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.warn(`[vi-date-picker] Failed to load locale: ${bcp47}`, e);
|
|
83
|
+
localeCache.set(bcp47, null);
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Loaders for built-in flatpickr plugins and our custom plugins.
|
|
89
|
+
const REGISTRY = {
|
|
90
|
+
month: async (options)=>{
|
|
91
|
+
const mod = await Promise.resolve().then(() => viMonthYearPlugin);
|
|
92
|
+
const factory = mod.ViMonthYearPlugin({
|
|
93
|
+
hideDays: true,
|
|
94
|
+
ariaLabels: options?.ariaLabels
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
id: 'vi-month-select',
|
|
98
|
+
label: 'Month Select',
|
|
99
|
+
factory
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
'month-year': async (options)=>{
|
|
103
|
+
const mod = await Promise.resolve().then(() => viMonthYearPlugin);
|
|
104
|
+
const factory = mod.ViMonthYearPlugin({
|
|
105
|
+
hideDays: true,
|
|
106
|
+
ariaLabels: options?.ariaLabels
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
id: 'vi-month-select',
|
|
110
|
+
label: 'Month Select',
|
|
111
|
+
factory
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
week: async ()=>{
|
|
115
|
+
// weekSelectPlugin is a plain factory function returning Plugin<PlusWeeks>.
|
|
116
|
+
// We widen to Plugin (= Plugin<{}>) here — the extra PlusWeeks fields on the
|
|
117
|
+
// instance are irrelevant to our wrapper; flatpickr accepts Plugin<{}> in its
|
|
118
|
+
// plugins array.
|
|
119
|
+
const mod = await import('flatpickr/dist/plugins/weekSelect/weekSelect.js');
|
|
120
|
+
const factory = mod.default();
|
|
121
|
+
return {
|
|
122
|
+
id: 'vi-week-select',
|
|
123
|
+
label: 'Week Select',
|
|
124
|
+
factory
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Lazily loads the required flatpickr plugin for a given picker mode.
|
|
130
|
+
* Returns null if the mode does not require a plugin (e.g. 'date', 'range').
|
|
131
|
+
*/ async function loadModePlugin(mode, options) {
|
|
132
|
+
const loader = REGISTRY[mode];
|
|
133
|
+
if (loader) {
|
|
134
|
+
return await loader(options);
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function isViPlugin(p) {
|
|
140
|
+
return typeof p === 'object' && p !== null && 'id' in p && 'factory' in p;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Merges the built-in mode plugin with any consumer-provided plugins.
|
|
144
|
+
* Ensures the mode plugin is always first, and deduplicates by ViDatePickerPlugin.id.
|
|
145
|
+
*/ function mergePlugins(modePlugin, consumerPlugins = []) {
|
|
146
|
+
const finalPlugins = [];
|
|
147
|
+
const seenIds = new Set();
|
|
148
|
+
// Helper to add a plugin if not duplicated by ID
|
|
149
|
+
const addPlugin = (pInput)=>{
|
|
150
|
+
if (isViPlugin(pInput)) {
|
|
151
|
+
if (!seenIds.has(pInput.id)) {
|
|
152
|
+
seenIds.add(pInput.id);
|
|
153
|
+
finalPlugins.push(pInput.factory);
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
// Raw flatpickr plugin — no ID, just push
|
|
157
|
+
finalPlugins.push(pInput);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
if (modePlugin) {
|
|
161
|
+
addPlugin(modePlugin);
|
|
162
|
+
}
|
|
163
|
+
consumerPlugins.forEach(addPlugin);
|
|
164
|
+
return finalPlugins;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Resolves the effective BCP 47 locale tag. */ function resolveLocale(localeAttr) {
|
|
168
|
+
if (localeAttr) return localeAttr;
|
|
169
|
+
if (typeof navigator !== 'undefined' && navigator.language) return navigator.language;
|
|
170
|
+
return 'en';
|
|
171
|
+
}
|
|
172
|
+
/** Reads the browser's IANA time zone from Intl. */ function resolveTimeZone() {
|
|
173
|
+
try {
|
|
174
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
175
|
+
} catch (_e) {
|
|
176
|
+
return 'UTC';
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Returns the localized word for "Today" (e.g. "today", "hoy", "aujourd'hui")
|
|
181
|
+
* capitalized properly using native Intl formatting.
|
|
182
|
+
*/ function getTodayLabel(locale) {
|
|
183
|
+
try {
|
|
184
|
+
const rtf = new Intl.RelativeTimeFormat(locale, {
|
|
185
|
+
numeric: 'auto'
|
|
186
|
+
});
|
|
187
|
+
const today = rtf.format(0, 'day');
|
|
188
|
+
return today.charAt(0).toUpperCase() + today.slice(1);
|
|
189
|
+
} catch (_e) {
|
|
190
|
+
return 'Today';
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const FMT_OPTIONS_BY_MODE = {
|
|
194
|
+
date: {
|
|
195
|
+
day: 'numeric',
|
|
196
|
+
month: 'long',
|
|
197
|
+
year: 'numeric'
|
|
198
|
+
},
|
|
199
|
+
month: {
|
|
200
|
+
month: 'long',
|
|
201
|
+
year: 'numeric'
|
|
202
|
+
},
|
|
203
|
+
'month-year': {
|
|
204
|
+
month: 'long',
|
|
205
|
+
year: 'numeric'
|
|
206
|
+
},
|
|
207
|
+
range: {
|
|
208
|
+
day: 'numeric',
|
|
209
|
+
month: 'short',
|
|
210
|
+
year: 'numeric'
|
|
211
|
+
},
|
|
212
|
+
week: {
|
|
213
|
+
year: 'numeric',
|
|
214
|
+
month: 'short',
|
|
215
|
+
day: 'numeric'
|
|
216
|
+
} // Fallback, usually overridden by custom week display
|
|
217
|
+
};
|
|
218
|
+
function formatDisplay(date, locale, mode, formatStr) {
|
|
219
|
+
if (formatStr && new RegExp('^([yYmMdD\\-/.\\s]+)$').test(formatStr)) {
|
|
220
|
+
const year = date.getFullYear();
|
|
221
|
+
const month = date.getMonth() + 1;
|
|
222
|
+
const day = date.getDate();
|
|
223
|
+
const res = formatStr.replace(/y{4}|Y{4}|y{2}|Y{2}|y|Y|m{4}|M{4}|m{3}|M{3}|m{2}|M{2}|m|M|d{2}|D{2}|d|D/g, (match)=>{
|
|
224
|
+
switch(match){
|
|
225
|
+
case 'yyyy':
|
|
226
|
+
case 'YYYY':
|
|
227
|
+
return year.toString();
|
|
228
|
+
case 'yy':
|
|
229
|
+
case 'YY':
|
|
230
|
+
return year.toString().slice(-2);
|
|
231
|
+
case 'y':
|
|
232
|
+
case 'Y':
|
|
233
|
+
return year.toString();
|
|
234
|
+
case 'mmmm':
|
|
235
|
+
case 'MMMM':
|
|
236
|
+
return new Intl.DateTimeFormat(locale, {
|
|
237
|
+
month: 'long'
|
|
238
|
+
}).format(date);
|
|
239
|
+
case 'mmm':
|
|
240
|
+
case 'MMM':
|
|
241
|
+
return new Intl.DateTimeFormat(locale, {
|
|
242
|
+
month: 'short'
|
|
243
|
+
}).format(date);
|
|
244
|
+
case 'mm':
|
|
245
|
+
case 'MM':
|
|
246
|
+
return month.toString().padStart(2, '0');
|
|
247
|
+
case 'm':
|
|
248
|
+
case 'M':
|
|
249
|
+
return month.toString();
|
|
250
|
+
case 'dd':
|
|
251
|
+
case 'DD':
|
|
252
|
+
return day.toString().padStart(2, '0');
|
|
253
|
+
case 'd':
|
|
254
|
+
case 'D':
|
|
255
|
+
return day.toString();
|
|
256
|
+
default:
|
|
257
|
+
return match;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
return res;
|
|
261
|
+
}
|
|
262
|
+
const opts = FMT_OPTIONS_BY_MODE[mode] || FMT_OPTIONS_BY_MODE.date;
|
|
263
|
+
return new Intl.DateTimeFormat(locale, opts).format(date);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function applyDecs2203RFactory$1() {
|
|
267
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
268
|
+
return function addInitializer(initializer) {
|
|
269
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
270
|
+
assertCallable(initializer, "An initializer");
|
|
271
|
+
initializers.push(initializer);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
275
|
+
var kindStr;
|
|
276
|
+
switch(kind){
|
|
277
|
+
case 1:
|
|
278
|
+
kindStr = "accessor";
|
|
279
|
+
break;
|
|
280
|
+
case 2:
|
|
281
|
+
kindStr = "method";
|
|
282
|
+
break;
|
|
283
|
+
case 3:
|
|
284
|
+
kindStr = "getter";
|
|
285
|
+
break;
|
|
286
|
+
case 4:
|
|
287
|
+
kindStr = "setter";
|
|
288
|
+
break;
|
|
289
|
+
default:
|
|
290
|
+
kindStr = "field";
|
|
291
|
+
}
|
|
292
|
+
var ctx = {
|
|
293
|
+
kind: kindStr,
|
|
294
|
+
name: isPrivate ? "#" + name : name,
|
|
295
|
+
static: isStatic,
|
|
296
|
+
private: isPrivate,
|
|
297
|
+
metadata: metadata
|
|
298
|
+
};
|
|
299
|
+
var decoratorFinishedRef = {
|
|
300
|
+
v: false
|
|
301
|
+
};
|
|
302
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
303
|
+
var get, set;
|
|
304
|
+
if (kind === 0) {
|
|
305
|
+
if (isPrivate) {
|
|
306
|
+
get = desc.get;
|
|
307
|
+
set = desc.set;
|
|
308
|
+
} else {
|
|
309
|
+
get = function() {
|
|
310
|
+
return this[name];
|
|
311
|
+
};
|
|
312
|
+
set = function(v) {
|
|
313
|
+
this[name] = v;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
} else if (kind === 2) {
|
|
317
|
+
get = function() {
|
|
318
|
+
return desc.value;
|
|
319
|
+
};
|
|
320
|
+
} else {
|
|
321
|
+
if (kind === 1 || kind === 3) {
|
|
322
|
+
get = function() {
|
|
323
|
+
return desc.get.call(this);
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
if (kind === 1 || kind === 4) {
|
|
327
|
+
set = function(v) {
|
|
328
|
+
desc.set.call(this, v);
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
ctx.access = get && set ? {
|
|
333
|
+
get: get,
|
|
334
|
+
set: set
|
|
335
|
+
} : get ? {
|
|
336
|
+
get: get
|
|
337
|
+
} : {
|
|
338
|
+
set: set
|
|
339
|
+
};
|
|
340
|
+
try {
|
|
341
|
+
return dec(value, ctx);
|
|
342
|
+
} finally{
|
|
343
|
+
decoratorFinishedRef.v = true;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
347
|
+
if (decoratorFinishedRef.v) {
|
|
348
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function assertCallable(fn, hint) {
|
|
352
|
+
if (typeof fn !== "function") {
|
|
353
|
+
throw new TypeError(hint + " must be a function");
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function assertValidReturnValue(kind, value) {
|
|
357
|
+
var type = typeof value;
|
|
358
|
+
if (kind === 1) {
|
|
359
|
+
if (type !== "object" || value === null) {
|
|
360
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
361
|
+
}
|
|
362
|
+
if (value.get !== undefined) {
|
|
363
|
+
assertCallable(value.get, "accessor.get");
|
|
364
|
+
}
|
|
365
|
+
if (value.set !== undefined) {
|
|
366
|
+
assertCallable(value.set, "accessor.set");
|
|
367
|
+
}
|
|
368
|
+
if (value.init !== undefined) {
|
|
369
|
+
assertCallable(value.init, "accessor.init");
|
|
370
|
+
}
|
|
371
|
+
} else if (type !== "function") {
|
|
372
|
+
var hint;
|
|
373
|
+
if (kind === 0) {
|
|
374
|
+
hint = "field";
|
|
375
|
+
} else if (kind === 10) {
|
|
376
|
+
hint = "class";
|
|
377
|
+
} else {
|
|
378
|
+
hint = "method";
|
|
379
|
+
}
|
|
380
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
384
|
+
var decs = decInfo[0];
|
|
385
|
+
var desc, init, value;
|
|
386
|
+
if (isPrivate) {
|
|
387
|
+
if (kind === 0 || kind === 1) {
|
|
388
|
+
desc = {
|
|
389
|
+
get: decInfo[3],
|
|
390
|
+
set: decInfo[4]
|
|
391
|
+
};
|
|
392
|
+
} else if (kind === 3) {
|
|
393
|
+
desc = {
|
|
394
|
+
get: decInfo[3]
|
|
395
|
+
};
|
|
396
|
+
} else if (kind === 4) {
|
|
397
|
+
desc = {
|
|
398
|
+
set: decInfo[3]
|
|
399
|
+
};
|
|
400
|
+
} else {
|
|
401
|
+
desc = {
|
|
402
|
+
value: decInfo[3]
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
} else if (kind !== 0) {
|
|
406
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
407
|
+
}
|
|
408
|
+
if (kind === 1) {
|
|
409
|
+
value = {
|
|
410
|
+
get: desc.get,
|
|
411
|
+
set: desc.set
|
|
412
|
+
};
|
|
413
|
+
} else if (kind === 2) {
|
|
414
|
+
value = desc.value;
|
|
415
|
+
} else if (kind === 3) {
|
|
416
|
+
value = desc.get;
|
|
417
|
+
} else if (kind === 4) {
|
|
418
|
+
value = desc.set;
|
|
419
|
+
}
|
|
420
|
+
var newValue, get, set;
|
|
421
|
+
if (typeof decs === "function") {
|
|
422
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
423
|
+
if (newValue !== void 0) {
|
|
424
|
+
assertValidReturnValue(kind, newValue);
|
|
425
|
+
if (kind === 0) {
|
|
426
|
+
init = newValue;
|
|
427
|
+
} else if (kind === 1) {
|
|
428
|
+
init = newValue.init;
|
|
429
|
+
get = newValue.get || value.get;
|
|
430
|
+
set = newValue.set || value.set;
|
|
431
|
+
value = {
|
|
432
|
+
get: get,
|
|
433
|
+
set: set
|
|
434
|
+
};
|
|
435
|
+
} else {
|
|
436
|
+
value = newValue;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
441
|
+
var dec = decs[i];
|
|
442
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
443
|
+
if (newValue !== void 0) {
|
|
444
|
+
assertValidReturnValue(kind, newValue);
|
|
445
|
+
var newInit;
|
|
446
|
+
if (kind === 0) {
|
|
447
|
+
newInit = newValue;
|
|
448
|
+
} else if (kind === 1) {
|
|
449
|
+
newInit = newValue.init;
|
|
450
|
+
get = newValue.get || value.get;
|
|
451
|
+
set = newValue.set || value.set;
|
|
452
|
+
value = {
|
|
453
|
+
get: get,
|
|
454
|
+
set: set
|
|
455
|
+
};
|
|
456
|
+
} else {
|
|
457
|
+
value = newValue;
|
|
458
|
+
}
|
|
459
|
+
if (newInit !== void 0) {
|
|
460
|
+
if (init === void 0) {
|
|
461
|
+
init = newInit;
|
|
462
|
+
} else if (typeof init === "function") {
|
|
463
|
+
init = [
|
|
464
|
+
init,
|
|
465
|
+
newInit
|
|
466
|
+
];
|
|
467
|
+
} else {
|
|
468
|
+
init.push(newInit);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (kind === 0 || kind === 1) {
|
|
475
|
+
if (init === void 0) {
|
|
476
|
+
init = function(instance, init) {
|
|
477
|
+
return init;
|
|
478
|
+
};
|
|
479
|
+
} else if (typeof init !== "function") {
|
|
480
|
+
var ownInitializers = init;
|
|
481
|
+
init = function(instance, init) {
|
|
482
|
+
var value = init;
|
|
483
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
484
|
+
value = ownInitializers[i].call(instance, value);
|
|
485
|
+
}
|
|
486
|
+
return value;
|
|
487
|
+
};
|
|
488
|
+
} else {
|
|
489
|
+
var originalInitializer = init;
|
|
490
|
+
init = function(instance, init) {
|
|
491
|
+
return originalInitializer.call(instance, init);
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
ret.push(init);
|
|
495
|
+
}
|
|
496
|
+
if (kind !== 0) {
|
|
497
|
+
if (kind === 1) {
|
|
498
|
+
desc.get = value.get;
|
|
499
|
+
desc.set = value.set;
|
|
500
|
+
} else if (kind === 2) {
|
|
501
|
+
desc.value = value;
|
|
502
|
+
} else if (kind === 3) {
|
|
503
|
+
desc.get = value;
|
|
504
|
+
} else if (kind === 4) {
|
|
505
|
+
desc.set = value;
|
|
506
|
+
}
|
|
507
|
+
if (isPrivate) {
|
|
508
|
+
if (kind === 1) {
|
|
509
|
+
ret.push(function(instance, args) {
|
|
510
|
+
return value.get.call(instance, args);
|
|
511
|
+
});
|
|
512
|
+
ret.push(function(instance, args) {
|
|
513
|
+
return value.set.call(instance, args);
|
|
514
|
+
});
|
|
515
|
+
} else if (kind === 2) {
|
|
516
|
+
ret.push(value);
|
|
517
|
+
} else {
|
|
518
|
+
ret.push(function(instance, args) {
|
|
519
|
+
return value.call(instance, args);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
Object.defineProperty(base, name, desc);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
528
|
+
var ret = [];
|
|
529
|
+
var protoInitializers;
|
|
530
|
+
var staticInitializers;
|
|
531
|
+
var existingProtoNonFields = new Map();
|
|
532
|
+
var existingStaticNonFields = new Map();
|
|
533
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
534
|
+
var decInfo = decInfos[i];
|
|
535
|
+
if (!Array.isArray(decInfo)) continue;
|
|
536
|
+
var kind = decInfo[1];
|
|
537
|
+
var name = decInfo[2];
|
|
538
|
+
var isPrivate = decInfo.length > 3;
|
|
539
|
+
var isStatic = kind >= 5;
|
|
540
|
+
var base;
|
|
541
|
+
var initializers;
|
|
542
|
+
if (isStatic) {
|
|
543
|
+
base = Class;
|
|
544
|
+
kind = kind - 5;
|
|
545
|
+
staticInitializers = staticInitializers || [];
|
|
546
|
+
initializers = staticInitializers;
|
|
547
|
+
} else {
|
|
548
|
+
base = Class.prototype;
|
|
549
|
+
protoInitializers = protoInitializers || [];
|
|
550
|
+
initializers = protoInitializers;
|
|
551
|
+
}
|
|
552
|
+
if (kind !== 0 && !isPrivate) {
|
|
553
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
554
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
555
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
556
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
557
|
+
} else if (!existingKind && kind > 2) {
|
|
558
|
+
existingNonFields.set(name, kind);
|
|
559
|
+
} else {
|
|
560
|
+
existingNonFields.set(name, true);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
564
|
+
}
|
|
565
|
+
pushInitializers(ret, protoInitializers);
|
|
566
|
+
pushInitializers(ret, staticInitializers);
|
|
567
|
+
return ret;
|
|
568
|
+
}
|
|
569
|
+
function pushInitializers(ret, initializers) {
|
|
570
|
+
if (initializers) {
|
|
571
|
+
ret.push(function(instance) {
|
|
572
|
+
for(var i = 0; i < initializers.length; i++){
|
|
573
|
+
initializers[i].call(instance);
|
|
574
|
+
}
|
|
575
|
+
return instance;
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
580
|
+
if (classDecs.length > 0) {
|
|
581
|
+
var initializers = [];
|
|
582
|
+
var newClass = targetClass;
|
|
583
|
+
var name = targetClass.name;
|
|
584
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
585
|
+
var decoratorFinishedRef = {
|
|
586
|
+
v: false
|
|
587
|
+
};
|
|
588
|
+
try {
|
|
589
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
590
|
+
kind: "class",
|
|
591
|
+
name: name,
|
|
592
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
593
|
+
metadata
|
|
594
|
+
});
|
|
595
|
+
} finally{
|
|
596
|
+
decoratorFinishedRef.v = true;
|
|
597
|
+
}
|
|
598
|
+
if (nextNewClass !== undefined) {
|
|
599
|
+
assertValidReturnValue(10, nextNewClass);
|
|
600
|
+
newClass = nextNewClass;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return [
|
|
604
|
+
defineMetadata(newClass, metadata),
|
|
605
|
+
function() {
|
|
606
|
+
for(var i = 0; i < initializers.length; i++){
|
|
607
|
+
initializers[i].call(newClass);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
];
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
function defineMetadata(Class, metadata) {
|
|
614
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
615
|
+
configurable: true,
|
|
616
|
+
enumerable: true,
|
|
617
|
+
value: metadata
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
621
|
+
if (parentClass !== void 0) {
|
|
622
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
623
|
+
}
|
|
624
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
625
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
626
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
627
|
+
return {
|
|
628
|
+
e: e,
|
|
629
|
+
get c () {
|
|
630
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
function _apply_decs_2203_r$1(targetClass, memberDecs, classDecs, parentClass) {
|
|
636
|
+
return (_apply_decs_2203_r$1 = applyDecs2203RFactory$1())(targetClass, memberDecs, classDecs, parentClass);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* FlatpickrMixin — abstract base mixin that manages a flatpickr lifecycle.
|
|
640
|
+
*
|
|
641
|
+
* Usage:
|
|
642
|
+
* class MyPicker extends FlatpickrMixin(ViElement) { ... }
|
|
643
|
+
*
|
|
644
|
+
* The subclass must:
|
|
645
|
+
* 1. Call `_initFlatpickr(config, mode, resolvedLocale)` in `firstUpdated()`.
|
|
646
|
+
* 2. Override `_getHiddenInput()` to return the `<input type="hidden">` element
|
|
647
|
+
* flatpickr should attach to.
|
|
648
|
+
*/ function FlatpickrMixin(Base) {
|
|
649
|
+
var _dec, /**
|
|
650
|
+
* Consumer-provided plugins (in addition to the mode plugin).
|
|
651
|
+
* Not reflected as an attribute — set via JS property only.
|
|
652
|
+
*/ _init_plugins, _initProto;
|
|
653
|
+
_dec = property({
|
|
654
|
+
attribute: false
|
|
655
|
+
});
|
|
656
|
+
class FlatpickrMixinClass extends Base {
|
|
657
|
+
static{
|
|
658
|
+
({ e: [_init_plugins, _initProto] } = _apply_decs_2203_r$1(this, [
|
|
659
|
+
[
|
|
660
|
+
_dec,
|
|
661
|
+
1,
|
|
662
|
+
"plugins"
|
|
663
|
+
]
|
|
664
|
+
], []));
|
|
665
|
+
}
|
|
666
|
+
/** Live flatpickr instance — null before init or after destroy. */ _fp = (_initProto(this), null);
|
|
667
|
+
#___private_plugins_1 = _init_plugins(this, []);
|
|
668
|
+
get plugins() {
|
|
669
|
+
return this.#___private_plugins_1;
|
|
670
|
+
}
|
|
671
|
+
set plugins(_v) {
|
|
672
|
+
this.#___private_plugins_1 = _v;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Returns the hidden input flatpickr should mount on.
|
|
676
|
+
* Subclasses override this with `@query('#fp-input')`.
|
|
677
|
+
*/ _getHiddenInput() {
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
/** Token to track and cancel overlapping initializations. */ _initGeneration = 0;
|
|
681
|
+
/**
|
|
682
|
+
* Optional config to pass to the mode plugin loader.
|
|
683
|
+
*/ _getModePluginConfig() {
|
|
684
|
+
return {};
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Initialises flatpickr with the given config and optional mode.
|
|
688
|
+
* Loads the flatpickr module, locale, and mode plugin in parallel.
|
|
689
|
+
*/ async _initFlatpickr(config, mode = 'date', resolvedLocale = resolveLocale(null)) {
|
|
690
|
+
const currentGen = ++this._initGeneration;
|
|
691
|
+
const input = this._getHiddenInput();
|
|
692
|
+
if (!input) return;
|
|
693
|
+
// Load flatpickr module, locale, and mode plugin in parallel
|
|
694
|
+
const [{ default: flatpickr }, locale, modePlugin] = await Promise.all([
|
|
695
|
+
import('flatpickr'),
|
|
696
|
+
loadLocale(resolvedLocale),
|
|
697
|
+
loadModePlugin(mode, this._getModePluginConfig())
|
|
698
|
+
]);
|
|
699
|
+
// Abort if another init was called, or if disconnected during loading
|
|
700
|
+
if (currentGen !== this._initGeneration || !this.isConnected) {
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
// Destroy any previous instance right before we mount the new one
|
|
704
|
+
this._destroyFlatpickr();
|
|
705
|
+
// Resolve raw Plugin[] from ViDatePickerPlugin wrappers + consumer plugins + internal config plugins
|
|
706
|
+
const mergedPlugins = mergePlugins(modePlugin, this.plugins);
|
|
707
|
+
const allPlugins = [
|
|
708
|
+
...config.plugins || [],
|
|
709
|
+
...mergedPlugins
|
|
710
|
+
];
|
|
711
|
+
const fpConfig = {
|
|
712
|
+
appendTo: document.body,
|
|
713
|
+
disableMobile: true,
|
|
714
|
+
static: false,
|
|
715
|
+
...config,
|
|
716
|
+
plugins: allPlugins,
|
|
717
|
+
...locale ? {
|
|
718
|
+
locale
|
|
719
|
+
} : {}
|
|
720
|
+
};
|
|
721
|
+
this._fp = flatpickr(input, fpConfig);
|
|
722
|
+
}
|
|
723
|
+
/** Destroys the current flatpickr instance and clears the reference. */ _destroyFlatpickr() {
|
|
724
|
+
if (this._fp) {
|
|
725
|
+
this._fp.destroy();
|
|
726
|
+
this._fp = null;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
disconnectedCallback() {
|
|
730
|
+
super.disconnectedCallback();
|
|
731
|
+
this._destroyFlatpickr();
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
return FlatpickrMixinClass;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
const datePickerStyles = "@charset \"UTF-8\";@layer reset,components,utilities;.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:var(--vi-color-background, #ffffff);-webkit-box-shadow:var(--vi-date-picker-calendar-shadow, var(--vi-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, .1)));box-shadow:var(--vi-date-picker-calendar-shadow, var(--vi-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, .1)))}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown .3s cubic-bezier(.23,1,.32,1);animation:fpFadeInDown .3s cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px)}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none!important;box-shadow:none!important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:none;box-shadow:none}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.hasTime .flatpickr-time{height:40px;border-top:1px solid var(--vi-color-border, #e5e7eb)}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:\"\";height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.arrowRight:before,.flatpickr-calendar.rightMost:after,.flatpickr-calendar.arrowRight:after{left:auto;right:22px}.flatpickr-calendar.arrowCenter:before,.flatpickr-calendar.arrowCenter:after{left:50%;right:50%}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:var(--vi-color-border, #e5e7eb)}.flatpickr-calendar.arrowTop:after{border-bottom-color:var(--vi-color-background, #ffffff)}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:var(--vi-color-border, #e5e7eb)}.flatpickr-calendar.arrowBottom:after{border-top-color:var(--vi-color-background, #ffffff)}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-months .flatpickr-month{background:transparent;color:var(--vi-text-primary, #111827);fill:var(--vi-text-primary, #111827);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:var(--vi-text-primary, #111827);fill:var(--vi-text-primary, #111827)}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{left:0}.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,.flatpickr-months .flatpickr-next-month.flatpickr-next-month{right:0}.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{color:var(--vi-text-secondary, #4b5563)}.flatpickr-months .flatpickr-prev-month:hover svg,.flatpickr-months .flatpickr-next-month:hover svg{fill:var(--vi-color-error, #ef4444)}.flatpickr-months .flatpickr-prev-month svg,.flatpickr-months .flatpickr-next-month svg{width:14px;height:14px}.flatpickr-months .flatpickr-prev-month svg path,.flatpickr-months .flatpickr-next-month svg path{-webkit-transition:fill .1s;transition:fill .1s;fill:inherit}.numInputWrapper{position:relative;height:auto}.numInputWrapper input,.numInputWrapper span{display:inline-block}.numInputWrapper input{width:100%}.numInputWrapper input::-ms-clear{display:none}.numInputWrapper input::-webkit-outer-spin-button,.numInputWrapper input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid var(--vi-border-02, #eeeeee);-webkit-box-sizing:border-box;box-sizing:border-box}.numInputWrapper span:hover{background:var(--vi-layer-hover-01, #f3f4f6)}.numInputWrapper span:active{background:var(--vi-layer-hover-02, #e5e7eb)}.numInputWrapper span:after{display:block;content:\"\";position:absolute}.numInputWrapper span.arrowUp{top:0;border-bottom:0}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid var(--vi-text-secondary, #4b5563);top:26%}.numInputWrapper span.arrowDown{top:50%}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid var(--vi-text-secondary, #4b5563);top:40%}.numInputWrapper span svg{width:inherit;height:auto}.numInputWrapper span svg path{fill:var(--vi-text-secondary, #4b5563)}.numInputWrapper:hover{background:var(--vi-layer-hover-01, #f3f4f6)}.numInputWrapper:hover span{opacity:1}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0px,0px,0px);transform:translateZ(0)}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:.5ch;padding:0}.flatpickr-current-month span.cur-month:hover{background:var(--vi-layer-hover-01, #f3f4f6)}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\\fffd;display:inline-block}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:var(--vi-text-primary, #111827)}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:var(--vi-text-primary, #111827)}.flatpickr-current-month input.cur-year{background:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 .5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-current-month input.cur-year:focus{outline:0}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:var(--vi-text-secondary, #4b5563);background:transparent;pointer-events:none}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:transparent;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0;outline:none;padding:0 0 0 .5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto}.flatpickr-current-month .flatpickr-monthDropdown-months:focus,.flatpickr-current-month .flatpickr-monthDropdown-months:active{outline:none}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:var(--vi-layer-hover-01, #f3f4f6)}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:transparent;outline:none;padding:0}.flatpickr-weekdays{background:transparent;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}span.flatpickr-weekday{cursor:default;font-size:90%;background:transparent;color:var(--vi-text-secondary, #4b5563);line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder}.dayContainer,.flatpickr-weeks{padding:1px 0 0}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875px}.flatpickr-days:focus{outline:0}.dayContainer{padding:0;outline:0;text-align:left;width:307.875px;min-width:307.875px;max-width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-wrap:wrap;-ms-flex-pack:justify;-webkit-justify-content:space-around;justify-content:space-around;-webkit-transform:translate3d(0px,0px,0px);transform:translateZ(0);opacity:1}.dayContainer+.dayContainer{-webkit-box-shadow:-1px 0 0 var(--vi-color-border, #e5e7eb);box-shadow:-1px 0 0 var(--vi-color-border, #e5e7eb)}.flatpickr-day{background:none;border:1px solid transparent;border-radius:150px;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--vi-text-primary, #111827);cursor:pointer;font-weight:400;width:14.2857143%;-webkit-flex-basis:14.2857143%;-ms-flex-preferred-size:14.2857143%;flex-basis:14.2857143%;max-width:39px;height:39px;line-height:39px;margin:0;display:inline-block;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center}.flatpickr-day.inRange,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.today.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day:hover,.flatpickr-day.prevMonthDay:hover,.flatpickr-day.nextMonthDay:hover,.flatpickr-day:focus,.flatpickr-day.prevMonthDay:focus,.flatpickr-day.nextMonthDay:focus{cursor:pointer;outline:0;background:var(--vi-color-border, #e5e7eb);border-color:var(--vi-color-border, #e5e7eb)}.flatpickr-day.today{border-color:var(--vi-text-secondary, #4b5563)}.flatpickr-day.today:hover,.flatpickr-day.today:focus{border-color:var(--vi-text-secondary, #4b5563);background:var(--vi-text-secondary, #4b5563);color:var(--vi-color-background, #ffffff)}.flatpickr-day.selected,.flatpickr-day.startRange,.flatpickr-day.endRange,.flatpickr-day.selected.inRange,.flatpickr-day.startRange.inRange,.flatpickr-day.endRange.inRange,.flatpickr-day.selected:focus,.flatpickr-day.startRange:focus,.flatpickr-day.endRange:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange:hover,.flatpickr-day.endRange:hover,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.endRange.nextMonthDay{background:var(--vi-color-primary, #3676d0);-webkit-box-shadow:none;box-shadow:none;color:var(--vi-color-background, #ffffff);border-color:var(--vi-color-primary, #3676d0)}.flatpickr-day.selected.startRange,.flatpickr-day.startRange.startRange,.flatpickr-day.endRange.startRange{border-radius:50px 0 0 50px}.flatpickr-day.selected.endRange,.flatpickr-day.startRange.endRange,.flatpickr-day.endRange.endRange{border-radius:0 50px 50px 0}.flatpickr-day.selected.startRange+.endRange:not(:nth-child(7n+1)),.flatpickr-day.startRange.startRange+.endRange:not(:nth-child(7n+1)),.flatpickr-day.endRange.startRange+.endRange:not(:nth-child(7n+1)){-webkit-box-shadow:-10px 0 0 var(--vi-color-primary, #3676d0);box-shadow:-10px 0 0 var(--vi-color-primary, #3676d0)}.flatpickr-day.selected.startRange.endRange,.flatpickr-day.startRange.startRange.endRange,.flatpickr-day.endRange.startRange.endRange{border-radius:50px}.flatpickr-day.inRange{border-radius:0;-webkit-box-shadow:-5px 0 0 var(--vi-layer-03, #e5e7eb),5px 0 0 var(--vi-layer-03, #e5e7eb);box-shadow:-5px 0 0 var(--vi-layer-03, #e5e7eb),5px 0 0 var(--vi-layer-03, #e5e7eb)}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover,.flatpickr-day.prevMonthDay,.flatpickr-day.nextMonthDay,.flatpickr-day.notAllowed,.flatpickr-day.notAllowed.prevMonthDay,.flatpickr-day.notAllowed.nextMonthDay{color:var(--vi-text-disabled, #9e9e9e);background:transparent;border-color:transparent;cursor:default}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover{cursor:not-allowed;color:var(--vi-layer-disabled, #f3f4f6)}.flatpickr-day.week.selected{border-radius:0;-webkit-box-shadow:-5px 0 0 var(--vi-color-primary, #3676d0),5px 0 0 var(--vi-color-primary, #3676d0);box-shadow:-5px 0 0 var(--vi-color-primary, #3676d0),5px 0 0 var(--vi-color-primary, #3676d0)}.flatpickr-day.hidden{visibility:hidden}.rangeMode .flatpickr-day{margin-top:1px}.flatpickr-weekwrapper{float:left}.flatpickr-weekwrapper .flatpickr-weeks{padding:0 12px;-webkit-box-shadow:1px 0 0 var(--vi-color-border, #e5e7eb);box-shadow:1px 0 0 var(--vi-color-border, #e5e7eb)}.flatpickr-weekwrapper .flatpickr-weekday{float:none;width:100%;line-height:28px}.flatpickr-weekwrapper span.flatpickr-day,.flatpickr-weekwrapper span.flatpickr-day:hover{display:block;width:100%;max-width:none;color:var(--vi-text-disabled, #9e9e9e);background:transparent;cursor:default;border:none}.flatpickr-innerContainer{display:block;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden}.flatpickr-rContainer{display:inline-block;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box}.flatpickr-time{text-align:center;outline:0;display:block;height:0;line-height:40px;max-height:40px;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.flatpickr-time:after{content:\"\";display:table;clear:both}.flatpickr-time .numInputWrapper{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;width:40%;height:40px;float:left}.flatpickr-time .numInputWrapper span.arrowUp:after{border-bottom-color:var(--vi-text-primary, #111827)}.flatpickr-time .numInputWrapper span.arrowDown:after{border-top-color:var(--vi-text-primary, #111827)}.flatpickr-time.hasSeconds .numInputWrapper{width:26%}.flatpickr-time.time24hr .numInputWrapper{width:49%}.flatpickr-time input{background:transparent;-webkit-box-shadow:none;box-shadow:none;border:0;border-radius:0;text-align:center;margin:0;padding:0;height:inherit;line-height:inherit;color:var(--vi-text-primary, #111827);font-size:14px;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}.flatpickr-time input.flatpickr-hour{font-weight:700}.flatpickr-time input.flatpickr-minute,.flatpickr-time input.flatpickr-second{font-weight:400}.flatpickr-time input:focus{outline:0;border:0}.flatpickr-time .flatpickr-time-separator,.flatpickr-time .flatpickr-am-pm{height:inherit;float:left;line-height:inherit;color:var(--vi-text-primary, #111827);font-weight:700;width:2%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center}.flatpickr-time .flatpickr-am-pm{outline:0;width:18%;cursor:pointer;text-align:center;font-weight:400}.flatpickr-time input:hover,.flatpickr-time .flatpickr-am-pm:hover,.flatpickr-time input:focus,.flatpickr-time .flatpickr-am-pm:focus{background:var(--vi-layer-hover-01, #f3f4f6)}.flatpickr-input[readonly]{cursor:pointer}@-webkit-keyframes fpFadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}@keyframes fpFadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}.flatpickr-calendar{background:var(--vi-date-picker-calendar-bg, var(--vi-layer-01, #ffffff));box-shadow:var(--vi-date-picker-calendar-shadow, var(--vi-shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, .1)));border-radius:var(--vi-border-radius-lg, var(--vi-border-radius-lg, 8px));border:1px solid var(--vi-border-03, var(--vi-border-03, #e0e0e0));font-family:var(--vi-font-family-base, var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif));color:var(--vi-text-primary, var(--vi-text-primary, #111827));padding:var(--vi-spacing-xs, var(--vi-spacing-xs, 8px)) 0;width:max-content}.flatpickr-calendar.arrowTop:before{border-bottom-color:var(--vi-border-03, var(--vi-border-03, #e0e0e0))}.flatpickr-calendar.arrowTop:after{border-bottom-color:var(--vi-date-picker-calendar-bg, var(--vi-layer-01, #ffffff))}.flatpickr-calendar.arrowBottom:before{border-top-color:var(--vi-border-03, var(--vi-border-03, #e0e0e0))}.flatpickr-calendar.arrowBottom:after{border-top-color:var(--vi-date-picker-calendar-bg, var(--vi-layer-01, #ffffff))}.flatpickr-calendar .flatpickr-innerContainer{justify-content:center}.flatpickr-months .flatpickr-month{color:var(--vi-text-primary, var(--vi-text-primary, #111827));fill:var(--vi-text-primary, var(--vi-text-primary, #111827))}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{color:var(--vi-text-secondary, var(--vi-text-secondary, #4b5563));fill:var(--vi-text-secondary, var(--vi-text-secondary, #4b5563));padding:var(--vi-spacing-xs, var(--vi-spacing-xs, 8px));border-radius:var(--vi-border-radius-md, var(--vi-border-radius-md, 4px));transition:background-color .2s ease}.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{background-color:var(--vi-layer-hover-02, var(--vi-layer-hover-02, #e5e7eb));color:var(--vi-text-primary, var(--vi-text-primary, #111827));fill:var(--vi-text-primary, var(--vi-text-primary, #111827))}.flatpickr-current-month{font-size:var(--vi-font-size-base, var(--vi-font-size-base, 16px));font-weight:var(--vi-font-weight-semibold, var(--vi-font-weight-semibold, 600));color:inherit}.flatpickr-current-month .flatpickr-monthDropdown-months{background:var(--vi-date-picker-calendar-bg, var(--vi-layer-01, #ffffff));border-radius:var(--vi-border-radius-md, var(--vi-border-radius-md, 4px));padding:4px}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background-color:var(--vi-layer-hover-02, var(--vi-layer-hover-02, #e5e7eb))}.flatpickr-current-month input.cur-year{font-weight:inherit;color:inherit}.flatpickr-current-month input.cur-year:hover{background-color:var(--vi-layer-hover-02, var(--vi-layer-hover-02, #e5e7eb))}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:grid;grid-template-columns:repeat(7,var(--vi-date-picker-day-size, 32px));justify-items:center;width:max-content}.flatpickr-weekdays .flatpickr-weekday{color:var(--vi-text-secondary, var(--vi-text-secondary, #4b5563));font-size:var(--vi-font-size-xs, var(--vi-font-size-xs, 12px));font-weight:var(--vi-font-weight-medium, var(--vi-font-weight-medium, 500))}.flatpickr-days{width:auto}.dayContainer{display:grid;grid-template-columns:repeat(7,var(--vi-date-picker-day-size, 32px));justify-items:center;width:max-content;min-width:auto;max-width:none}.flatpickr-day{color:var(--vi-text-primary, var(--vi-text-primary, #111827));border-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px));margin:0;width:var(--vi-date-picker-day-size, 32px);max-width:var(--vi-date-picker-day-size, 32px);height:var(--vi-date-picker-day-size, 32px);line-height:var(--vi-date-picker-day-size, 32px);display:flex;align-items:center;justify-content:center;transition:all .2s ease}.flatpickr-day:hover,.flatpickr-day:focus{background:var(--vi-date-picker-day-hover-bg, var(--vi-layer-hover-01, #f3f4f6));border-color:var(--vi-date-picker-day-hover-bg, var(--vi-layer-hover-01, #f3f4f6))}.flatpickr-day.today{border-color:var(--vi-date-picker-day-today-border, var(--vi-color-primary, #3676d0))}.flatpickr-day.today:hover,.flatpickr-day.today:focus{border-color:var(--vi-date-picker-day-today-border, var(--vi-color-primary, #3676d0));background:var(--vi-date-picker-day-hover-bg, var(--vi-layer-hover-01, #f3f4f6))}.flatpickr-day.selected,.flatpickr-day.startRange,.flatpickr-day.endRange,.flatpickr-day.selected.inRange,.flatpickr-day.startRange.inRange,.flatpickr-day.endRange.inRange,.flatpickr-day.selected:focus,.flatpickr-day.startRange:focus,.flatpickr-day.endRange:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange:hover,.flatpickr-day.endRange:hover,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.endRange.nextMonthDay{background:var(--vi-date-picker-day-selected-bg, var(--vi-color-primary, #3676d0));border-color:var(--vi-date-picker-day-selected-bg, var(--vi-color-primary, #3676d0));color:var(--vi-date-picker-day-selected-color, var(--vi-text-primary-inverse, #ffffff))}.flatpickr-day.inRange,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.today.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day:hover.inRange,.flatpickr-day.prevMonthDay:hover.inRange,.flatpickr-day.nextMonthDay:hover.inRange{background:var(--vi-color-blue-100, var(--vi-color-blue-100, #ebf5ff));border-color:var(--vi-color-blue-100, var(--vi-color-blue-100, #ebf5ff));border-radius:0;box-shadow:none;color:var(--vi-text-primary, var(--vi-text-primary, #111827))}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover,.flatpickr-day.prevMonthDay,.flatpickr-day.nextMonthDay,.flatpickr-day.notAllowed,.flatpickr-day.notAllowed.prevMonthDay,.flatpickr-day.notAllowed.nextMonthDay{color:var(--vi-text-disabled, var(--vi-text-disabled, #9e9e9e));background:transparent;border-color:transparent}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover{cursor:not-allowed}.vi-calendar-header{display:flex;justify-content:space-between;align-items:center;padding:4px var(--vi-spacing-xs, var(--vi-spacing-xs, 8px));border-bottom:1px solid var(--vi-border-02, var(--vi-border-02, #eeeeee));margin-bottom:var(--vi-spacing-xs, var(--vi-spacing-xs, 8px))}.vi-calendar-selectors{display:flex;gap:var(--vi-spacing-xs, var(--vi-spacing-xs, 8px));align-items:center}.vi-calendar-month-toggle{background:transparent;border:1px solid transparent;border-radius:var(--vi-border-radius-md, var(--vi-border-radius-md, 4px));padding:4px 8px;font-family:var(--vi-font-family-base, var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif));font-weight:var(--vi-font-weight-semibold, var(--vi-font-weight-semibold, 600));font-size:var(--vi-font-size-base, var(--vi-font-size-base, 16px));color:var(--vi-text-primary, var(--vi-text-primary, #111827));cursor:pointer;transition:all .2s ease}.vi-calendar-month-toggle:hover{background:var(--vi-layer-hover-02, var(--vi-layer-hover-02, #e5e7eb))}.vi-calendar-month-toggle:focus-visible{outline:none;background:var(--vi-layer-hover-02, var(--vi-layer-hover-02, #e5e7eb));box-shadow:0 0 0 2px var(--vi-focus, var(--vi-focus, #3676d0))}.vi-calendar-year-select{min-width:76px;--vi-select-spacing-padding-inline: 4px;--vi-select-option-padding-inline: 8px;--vi-select-sizing-min-height: 32px}.vi-calendar-nav{display:flex;gap:2px}.vi-calendar-nav-btn{background:transparent;border:none;border-radius:var(--vi-border-radius-md, var(--vi-border-radius-md, 4px));width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;color:var(--vi-text-secondary, var(--vi-text-secondary, #4b5563));cursor:pointer;transition:all .2s ease}.vi-calendar-nav-btn:hover{background:var(--vi-layer-hover-02, var(--vi-layer-hover-02, #e5e7eb));color:var(--vi-text-primary, var(--vi-text-primary, #111827))}.vi-calendar-month-grid{position:absolute;inset:50px 0 0;background:var(--vi-date-picker-calendar-bg, var(--vi-layer-01, #ffffff));z-index:10;display:grid;grid-template-columns:repeat(3,1fr);grid-auto-rows:min-content;gap:4px;padding:var(--vi-spacing-xs, var(--vi-spacing-xs, 8px));border-radius:0 0 var(--vi-border-radius-lg, var(--vi-border-radius-lg, 8px)) var(--vi-border-radius-lg, var(--vi-border-radius-lg, 8px))}.vi-month-mode .vi-calendar-month-grid{position:relative;top:0;margin-top:var(--vi-spacing-xs, var(--vi-spacing-xs, 8px))}.vi-calendar-month-btn{background:transparent;border:1px solid transparent;border-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px));padding:var(--vi-spacing-xs, var(--vi-spacing-xs, 8px)) 0;font-family:var(--vi-font-family-base, var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif));font-size:var(--vi-font-size-sm, var(--vi-font-size-sm, 14px));color:var(--vi-text-primary, var(--vi-text-primary, #111827));cursor:pointer;transition:all .2s ease}.vi-calendar-month-btn:hover{background:var(--vi-layer-hover-01, var(--vi-layer-hover-01, #f3f4f6))}.vi-calendar-month-btn.active{background:var(--vi-date-picker-day-selected-bg, var(--vi-color-primary, #3676d0));color:var(--vi-text-primary-inverse, var(--vi-text-primary-inverse, #ffffff))}.flatpickr-day.inRange:nth-child(7n+1),.flatpickr-day.inRange:hover:nth-child(7n+1){border-top-left-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px));border-bottom-left-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px))}.flatpickr-day.inRange:nth-child(7n),.flatpickr-day.inRange:hover:nth-child(7n){border-top-right-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px));border-bottom-right-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px))}.flatpickr-day.week.selected{background:var(--vi-color-blue-100, var(--vi-color-blue-100, #ebf5ff));border-color:var(--vi-color-blue-100, var(--vi-color-blue-100, #ebf5ff));color:var(--vi-text-primary, var(--vi-text-primary, #111827));border-radius:0;box-shadow:none}.flatpickr-day.week.selected:nth-child(7n+1){background:var(--vi-date-picker-day-selected-bg, var(--vi-color-primary, #3676d0));border-color:var(--vi-date-picker-day-selected-bg, var(--vi-color-primary, #3676d0));color:var(--vi-date-picker-day-selected-color, var(--vi-text-primary-inverse, #ffffff));border-top-left-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px));border-bottom-left-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px))}.flatpickr-day.week.selected:nth-child(7n){background:var(--vi-date-picker-day-selected-bg, var(--vi-color-primary, #3676d0));border-color:var(--vi-date-picker-day-selected-bg, var(--vi-color-primary, #3676d0));color:var(--vi-date-picker-day-selected-color, var(--vi-text-primary-inverse, #ffffff));border-top-right-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px));border-bottom-right-radius:var(--vi-border-radius-full, var(--vi-border-radius-full, 9999px))}.vi-calendar-footer{padding:4px var(--vi-spacing-xs, var(--vi-spacing-xs, 8px));border-top:1px solid var(--vi-border-02, var(--vi-border-02, #eeeeee));display:flex;justify-content:flex-end}.vi-calendar-today-btn{background:transparent;border:none;color:var(--vi-color-primary, var(--vi-color-primary, #3676d0));font-family:var(--vi-font-family-base, var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif));font-weight:var(--vi-font-weight-medium, var(--vi-font-weight-medium, 500));font-size:var(--vi-font-size-sm, var(--vi-font-size-sm, 14px));cursor:pointer;padding:var(--vi-spacing-xs, var(--vi-spacing-xs, 8px)) var(--vi-spacing-sm, var(--vi-spacing-sm, 16px));border-radius:var(--vi-border-radius-md, var(--vi-border-radius-md, 4px));transition:background-color .2s ease}.vi-calendar-today-btn:hover{background:var(--vi-layer-hover-01, var(--vi-layer-hover-01, #f3f4f6))}:host{display:inline-block;font-family:var(--vi-font-family, var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif));position:relative}#fp-input{position:absolute;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;margin:0;padding:0;border:0}.control{display:flex;flex-direction:column;gap:var(--vi-date-picker-spacing-field-gap, var(--vi-spacing-xs, 8px))}.inputs-container{display:flex;flex-direction:row;align-items:flex-start;gap:var(--vi-date-picker-spacing-inputs-gap, var(--vi-spacing-md, 24px));width:100%}:host([status=invalid]) .inputs-container ::slotted(vi-date-picker-input){--vi-input-border-color: var( --vi-date-picker-error-color, tokens.$color-error )}.validity-msg{font-size:var(--vi-date-picker-validity-font-size, var(--vi-font-size-xs, 12px));color:var(--vi-date-picker-error-color, var(--vi-color-error, #ef4444))}#floating-menu-container{position:absolute}";
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Calculates the ISO 8601 week number of a given date.
|
|
741
|
+
* ISO week starts on Monday, and the first week of the year is the one
|
|
742
|
+
* that contains the first Thursday of the year (or Jan 4).
|
|
743
|
+
*
|
|
744
|
+
* @param date The Date object to calculate the ISO week for.
|
|
745
|
+
* @returns The ISO 8601 week number (1-53).
|
|
746
|
+
*/ function getISOWeek(date) {
|
|
747
|
+
const dt = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
748
|
+
// Set to nearest Thursday: current date + 4 - current day number
|
|
749
|
+
// Make Sunday's day number 7
|
|
750
|
+
const dayn = (dt.getUTCDay() + 6) % 7;
|
|
751
|
+
dt.setUTCDate(dt.getUTCDate() - dayn + 3);
|
|
752
|
+
// Return the calculated week number
|
|
753
|
+
const firstThursday = dt.valueOf();
|
|
754
|
+
// Set to January 1 of the nearest Thursday's year
|
|
755
|
+
dt.setUTCMonth(0, 1);
|
|
756
|
+
if (dt.getUTCDay() !== 4) {
|
|
757
|
+
dt.setUTCMonth(0, 1 + (4 - dt.getUTCDay() + 7) % 7);
|
|
758
|
+
}
|
|
759
|
+
// Calculate week number
|
|
760
|
+
return 1 + Math.round((firstThursday - dt.valueOf()) / 604800000);
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Parses an ISO 8601 week string (YYYY-Www) into a Date object.
|
|
764
|
+
* Returns the Monday of that week.
|
|
765
|
+
*
|
|
766
|
+
* @param isoWeekString The string in format YYYY-Www
|
|
767
|
+
* @returns A Date object representing the Monday of the given week, or null if invalid.
|
|
768
|
+
*/ function parseISOWeek(isoWeekString) {
|
|
769
|
+
const match = /^(\d{4})-W(\d{2})$/.exec(isoWeekString);
|
|
770
|
+
if (!match) return null;
|
|
771
|
+
const year = parseInt(match[1], 10);
|
|
772
|
+
const week = parseInt(match[2], 10);
|
|
773
|
+
if (week < 1 || week > 53) return null;
|
|
774
|
+
// Jan 4 is always in ISO week 1.
|
|
775
|
+
const jan4 = new Date(Date.UTC(year, 0, 4));
|
|
776
|
+
// Find Monday of week 1
|
|
777
|
+
const dayn = (jan4.getUTCDay() + 6) % 7; // Monday = 0, Sunday = 6
|
|
778
|
+
const week1Monday = new Date(Date.UTC(year, 0, 4 - dayn));
|
|
779
|
+
// Add (week - 1) weeks
|
|
780
|
+
week1Monday.setUTCDate(week1Monday.getUTCDate() + (week - 1) * 7);
|
|
781
|
+
return new Date(week1Monday.getUTCFullYear(), week1Monday.getUTCMonth(), week1Monday.getUTCDate());
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function ViMonthYearPlugin(config = {}) {
|
|
785
|
+
return function(fp) {
|
|
786
|
+
let headerContainer;
|
|
787
|
+
let prevBtn;
|
|
788
|
+
let nextBtn;
|
|
789
|
+
let monthToggleBtn;
|
|
790
|
+
let yearSelect; // vi-select
|
|
791
|
+
let monthGridContainer;
|
|
792
|
+
function createHeader() {
|
|
793
|
+
headerContainer = document.createElement('div');
|
|
794
|
+
headerContainer.className = 'vi-calendar-header';
|
|
795
|
+
prevBtn = document.createElement('button');
|
|
796
|
+
prevBtn.type = 'button';
|
|
797
|
+
prevBtn.className = 'vi-calendar-nav-btn vi-calendar-prev';
|
|
798
|
+
if (config.ariaLabels?.prevMonth) {
|
|
799
|
+
prevBtn.setAttribute('aria-label', config.ariaLabels.prevMonth);
|
|
800
|
+
}
|
|
801
|
+
prevBtn.innerHTML = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>`;
|
|
802
|
+
prevBtn.addEventListener('click', (e)=>{
|
|
803
|
+
e.preventDefault();
|
|
804
|
+
fp.changeMonth(-1);
|
|
805
|
+
});
|
|
806
|
+
nextBtn = document.createElement('button');
|
|
807
|
+
nextBtn.type = 'button';
|
|
808
|
+
nextBtn.className = 'vi-calendar-nav-btn vi-calendar-next';
|
|
809
|
+
if (config.ariaLabels?.nextMonth) {
|
|
810
|
+
nextBtn.setAttribute('aria-label', config.ariaLabels.nextMonth);
|
|
811
|
+
}
|
|
812
|
+
nextBtn.innerHTML = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>`;
|
|
813
|
+
nextBtn.addEventListener('click', (e)=>{
|
|
814
|
+
e.preventDefault();
|
|
815
|
+
fp.changeMonth(1);
|
|
816
|
+
});
|
|
817
|
+
const selectorsContainer = document.createElement('div');
|
|
818
|
+
selectorsContainer.className = 'vi-calendar-selectors';
|
|
819
|
+
monthToggleBtn = document.createElement('button');
|
|
820
|
+
monthToggleBtn.type = 'button';
|
|
821
|
+
monthToggleBtn.className = 'vi-calendar-month-toggle';
|
|
822
|
+
monthToggleBtn.setAttribute('aria-label', config.ariaLabels?.selectMonth ?? fp.l10n.monthAriaLabel ?? 'Select month');
|
|
823
|
+
monthToggleBtn.addEventListener('click', (e)=>{
|
|
824
|
+
e.preventDefault();
|
|
825
|
+
toggleMonthGrid();
|
|
826
|
+
});
|
|
827
|
+
yearSelect = document.createElement('vi-select');
|
|
828
|
+
yearSelect.className = 'vi-calendar-year-select';
|
|
829
|
+
yearSelect.setAttribute('size', 'sm');
|
|
830
|
+
yearSelect.setAttribute('aria-label', config.ariaLabels?.selectYear ?? fp.l10n.yearAriaLabel ?? 'Select year');
|
|
831
|
+
// Use createElement and assign .value directly so vi-select can synchronously read the value
|
|
832
|
+
// even before Lit has fully upgraded the custom elements in the browser.
|
|
833
|
+
const currentYear = new Date().getFullYear();
|
|
834
|
+
for(let y = currentYear - 50; y <= currentYear + 50; y++){
|
|
835
|
+
const opt = document.createElement('vi-select-option');
|
|
836
|
+
opt.value = y.toString();
|
|
837
|
+
opt.textContent = y.toString();
|
|
838
|
+
yearSelect.appendChild(opt);
|
|
839
|
+
}
|
|
840
|
+
yearSelect.addEventListener('vialiq-change', (e)=>{
|
|
841
|
+
e.stopPropagation(); // prevent it from bubbling up to Storybook
|
|
842
|
+
const selectedYear = parseInt(e.detail.value, 10);
|
|
843
|
+
if (!isNaN(selectedYear)) {
|
|
844
|
+
fp.changeYear(selectedYear);
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
selectorsContainer.appendChild(monthToggleBtn);
|
|
848
|
+
selectorsContainer.appendChild(yearSelect);
|
|
849
|
+
headerContainer.appendChild(prevBtn);
|
|
850
|
+
headerContainer.appendChild(selectorsContainer);
|
|
851
|
+
headerContainer.appendChild(nextBtn);
|
|
852
|
+
// Stop ALL click/pointer events from bubbling out of the header!
|
|
853
|
+
// This is the CRITICAL fix that prevents Flatpickr from closing the calendar
|
|
854
|
+
// when you click the year select. Because vi-select uses Shadow DOM, Flatpickr
|
|
855
|
+
// gets confused and thinks you clicked outside the calendar.
|
|
856
|
+
const stopPropagation = (e)=>e.stopPropagation();
|
|
857
|
+
headerContainer.addEventListener('mousedown', stopPropagation);
|
|
858
|
+
headerContainer.addEventListener('click', stopPropagation);
|
|
859
|
+
headerContainer.addEventListener('touchstart', stopPropagation);
|
|
860
|
+
return headerContainer;
|
|
861
|
+
}
|
|
862
|
+
function createMonthGrid() {
|
|
863
|
+
monthGridContainer = document.createElement('div');
|
|
864
|
+
monthGridContainer.className = 'vi-calendar-month-grid';
|
|
865
|
+
monthGridContainer.style.display = 'none';
|
|
866
|
+
const months = fp.l10n.months.shorthand;
|
|
867
|
+
months.forEach((monthName, index)=>{
|
|
868
|
+
const btn = document.createElement('button');
|
|
869
|
+
btn.type = 'button';
|
|
870
|
+
btn.className = 'vi-calendar-month-btn';
|
|
871
|
+
btn.textContent = monthName;
|
|
872
|
+
btn.dataset.month = index.toString();
|
|
873
|
+
btn.addEventListener('click', (e)=>{
|
|
874
|
+
e.preventDefault();
|
|
875
|
+
if (config.hideDays) {
|
|
876
|
+
// In month-only mode, clicking a month selects it and closes the picker
|
|
877
|
+
const newDate = new Date(fp.currentYear, index, 1);
|
|
878
|
+
fp.setDate(newDate, true);
|
|
879
|
+
fp.close();
|
|
880
|
+
} else {
|
|
881
|
+
// Normal mode: just change the calendar view to that month
|
|
882
|
+
fp.changeMonth(index, false);
|
|
883
|
+
toggleMonthGrid(false);
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
monthGridContainer.appendChild(btn);
|
|
887
|
+
});
|
|
888
|
+
return monthGridContainer;
|
|
889
|
+
}
|
|
890
|
+
function toggleMonthGrid(force) {
|
|
891
|
+
const isCurrentlyVisible = monthGridContainer.style.display === 'grid';
|
|
892
|
+
const shouldShow = force !== undefined ? force : !isCurrentlyVisible;
|
|
893
|
+
monthGridContainer.style.display = shouldShow ? 'grid' : 'none';
|
|
894
|
+
if (shouldShow) {
|
|
895
|
+
const monthBtns = monthGridContainer.querySelectorAll('.vi-calendar-month-btn');
|
|
896
|
+
monthBtns.forEach((btn)=>{
|
|
897
|
+
if (parseInt(btn.dataset.month || '', 10) === fp.currentMonth) {
|
|
898
|
+
btn.classList.add('active');
|
|
899
|
+
} else {
|
|
900
|
+
btn.classList.remove('active');
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function updateHeaderValues() {
|
|
906
|
+
if (!monthToggleBtn || !yearSelect) return;
|
|
907
|
+
monthToggleBtn.textContent = fp.l10n.months.longhand[fp.currentMonth];
|
|
908
|
+
yearSelect.value = fp.currentYear.toString();
|
|
909
|
+
if (prevBtn && !config.ariaLabels?.prevMonth) {
|
|
910
|
+
const prevMonthIndex = fp.currentMonth === 0 ? 11 : fp.currentMonth - 1;
|
|
911
|
+
prevBtn.setAttribute('aria-label', fp.l10n.months.longhand[prevMonthIndex]);
|
|
912
|
+
}
|
|
913
|
+
if (nextBtn && !config.ariaLabels?.nextMonth) {
|
|
914
|
+
const nextMonthIndex = fp.currentMonth === 11 ? 0 : fp.currentMonth + 1;
|
|
915
|
+
nextBtn.setAttribute('aria-label', fp.l10n.months.longhand[nextMonthIndex]);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function applyHideDaysConfig() {
|
|
919
|
+
if (!config.hideDays) return;
|
|
920
|
+
fp.calendarContainer.classList.add('vi-month-mode');
|
|
921
|
+
const innerContainer = fp.calendarContainer.querySelector('.flatpickr-innerContainer');
|
|
922
|
+
if (innerContainer) innerContainer.style.display = 'none';
|
|
923
|
+
// Permanently show the month grid
|
|
924
|
+
toggleMonthGrid(true);
|
|
925
|
+
// Also hide the month toggle button since it's permanently showing the grid anyway
|
|
926
|
+
if (monthToggleBtn) {
|
|
927
|
+
monthToggleBtn.style.display = 'none';
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
return {
|
|
931
|
+
onReady: ()=>{
|
|
932
|
+
if (fp.monthNav) {
|
|
933
|
+
fp.monthNav.style.display = 'none';
|
|
934
|
+
}
|
|
935
|
+
const header = createHeader();
|
|
936
|
+
fp.calendarContainer.insertBefore(header, fp.calendarContainer.firstChild);
|
|
937
|
+
const grid = createMonthGrid();
|
|
938
|
+
fp.calendarContainer.appendChild(grid);
|
|
939
|
+
// Tell Flatpickr not to close when these custom elements are clicked
|
|
940
|
+
if (!fp.config.ignoredFocusElements) {
|
|
941
|
+
fp.config.ignoredFocusElements = [];
|
|
942
|
+
}
|
|
943
|
+
fp.config.ignoredFocusElements.push(header, grid);
|
|
944
|
+
updateHeaderValues();
|
|
945
|
+
applyHideDaysConfig();
|
|
946
|
+
},
|
|
947
|
+
onMonthChange: ()=>{
|
|
948
|
+
updateHeaderValues();
|
|
949
|
+
},
|
|
950
|
+
onYearChange: ()=>{
|
|
951
|
+
updateHeaderValues();
|
|
952
|
+
},
|
|
953
|
+
onDestroy: ()=>{
|
|
954
|
+
headerContainer?.remove();
|
|
955
|
+
monthGridContainer?.remove();
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
const viMonthYearPlugin = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
962
|
+
__proto__: null,
|
|
963
|
+
ViMonthYearPlugin
|
|
964
|
+
}, Symbol.toStringTag, { value: 'Module' }));
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* A Carbon Web Components inspired plugin that fixes Flatpickr's native
|
|
968
|
+
* event targeting issues when used within a Web Component (Shadow DOM).
|
|
969
|
+
*
|
|
970
|
+
* Flatpickr relies on native `Node.contains()` for its `documentClick` listener
|
|
971
|
+
* to determine if a click occurred outside the calendar. Because Shadow DOM
|
|
972
|
+
* boundaries are not pierced by `Node.contains()`, clicks on custom elements
|
|
973
|
+
* (like `<vi-select>`) inside the calendar are falsely identified as outside
|
|
974
|
+
* clicks, causing the calendar to close unexpectedly.
|
|
975
|
+
*
|
|
976
|
+
* This plugin overrides `fp.calendarContainer.contains` to properly traverse
|
|
977
|
+
* up through Shadow Roots.
|
|
978
|
+
*/ function ViShadowDomPlugin() {
|
|
979
|
+
return function(fp) {
|
|
980
|
+
return {
|
|
981
|
+
onReady: ()=>{
|
|
982
|
+
if (!fp.calendarContainer) return;
|
|
983
|
+
const originalContains = fp.calendarContainer.contains.bind(fp.calendarContainer);
|
|
984
|
+
fp.calendarContainer.contains = (node)=>{
|
|
985
|
+
if (!node) return false;
|
|
986
|
+
if (originalContains(node)) return true;
|
|
987
|
+
let curr = node;
|
|
988
|
+
while(curr){
|
|
989
|
+
if (curr === fp.calendarContainer) return true;
|
|
990
|
+
if (curr.getRootNode() instanceof ShadowRoot) {
|
|
991
|
+
curr = curr.getRootNode().host;
|
|
992
|
+
} else {
|
|
993
|
+
curr = curr.parentNode;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return false;
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* A wrapper around Flatpickr's rangePlugin that correctly formats dates back to the
|
|
1005
|
+
* Shadow DOM input elements and handles Shadow DOM focus events correctly.
|
|
1006
|
+
*/ function ViRangePlugin(config) {
|
|
1007
|
+
// We initialize the base rangePlugin
|
|
1008
|
+
// Carbon originally forced position: 'left' to always align to the start date.
|
|
1009
|
+
// We remove this constraint so it correctly aligns to the end date when clicked.
|
|
1010
|
+
const factory = rangePlugin({
|
|
1011
|
+
...config,
|
|
1012
|
+
position: config.position
|
|
1013
|
+
});
|
|
1014
|
+
return (fp)=>{
|
|
1015
|
+
const origRangePlugin = factory(fp);
|
|
1016
|
+
const origOnReady = origRangePlugin.onReady;
|
|
1017
|
+
return Object.assign(origRangePlugin, {
|
|
1018
|
+
onChange () {},
|
|
1019
|
+
onPreCalendarPosition () {},
|
|
1020
|
+
onValueUpdate (selectedDates) {
|
|
1021
|
+
// We sync the formatted dates back to the two inputs when the value updates
|
|
1022
|
+
const [startDate, endDate] = selectedDates;
|
|
1023
|
+
const startDateFormatted = startDate ? fp.formatDate(startDate, fp.config.dateFormat) : '';
|
|
1024
|
+
const endDateFormatted = endDate ? fp.formatDate(endDate, fp.config.dateFormat) : '';
|
|
1025
|
+
// Ensure start date updates the main input
|
|
1026
|
+
if (fp._input && 'value' in fp._input) {
|
|
1027
|
+
fp._input.value = startDateFormatted;
|
|
1028
|
+
// Dispatch input event so our Lit wrapper knows the value changed
|
|
1029
|
+
fp._input.dispatchEvent(new Event('input', {
|
|
1030
|
+
bubbles: true
|
|
1031
|
+
}));
|
|
1032
|
+
}
|
|
1033
|
+
// Ensure end date updates the secondary config input
|
|
1034
|
+
if (config.input && typeof config.input !== 'string' && 'value' in config.input) {
|
|
1035
|
+
config.input.value = endDateFormatted;
|
|
1036
|
+
config.input.dispatchEvent(new Event('input', {
|
|
1037
|
+
bubbles: true
|
|
1038
|
+
}));
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
onReady (dates, currentDateString, self, data) {
|
|
1042
|
+
if (typeof origOnReady === 'function') {
|
|
1043
|
+
origOnReady(dates, currentDateString, self, data);
|
|
1044
|
+
} else if (Array.isArray(origOnReady)) {
|
|
1045
|
+
origOnReady.forEach((fn)=>fn(dates, currentDateString, self, data));
|
|
1046
|
+
}
|
|
1047
|
+
// Make sure flatpickr ignores clicks inside the inputs when they are in shadow DOM
|
|
1048
|
+
const { ignoredFocusElements } = fp.config;
|
|
1049
|
+
// Add shadow roots of ignored elements so clicks inside shadow DOM are ignored
|
|
1050
|
+
const shadowRoots = ignoredFocusElements.map((elem)=>elem.shadowRoot).filter(Boolean);
|
|
1051
|
+
ignoredFocusElements.push(...shadowRoots || []);
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function applyDecs2203RFactory() {
|
|
1058
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
1059
|
+
return function addInitializer(initializer) {
|
|
1060
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
1061
|
+
assertCallable(initializer, "An initializer");
|
|
1062
|
+
initializers.push(initializer);
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
1066
|
+
var kindStr;
|
|
1067
|
+
switch(kind){
|
|
1068
|
+
case 1:
|
|
1069
|
+
kindStr = "accessor";
|
|
1070
|
+
break;
|
|
1071
|
+
case 2:
|
|
1072
|
+
kindStr = "method";
|
|
1073
|
+
break;
|
|
1074
|
+
case 3:
|
|
1075
|
+
kindStr = "getter";
|
|
1076
|
+
break;
|
|
1077
|
+
case 4:
|
|
1078
|
+
kindStr = "setter";
|
|
1079
|
+
break;
|
|
1080
|
+
default:
|
|
1081
|
+
kindStr = "field";
|
|
1082
|
+
}
|
|
1083
|
+
var ctx = {
|
|
1084
|
+
kind: kindStr,
|
|
1085
|
+
name: isPrivate ? "#" + name : name,
|
|
1086
|
+
static: isStatic,
|
|
1087
|
+
private: isPrivate,
|
|
1088
|
+
metadata: metadata
|
|
1089
|
+
};
|
|
1090
|
+
var decoratorFinishedRef = {
|
|
1091
|
+
v: false
|
|
1092
|
+
};
|
|
1093
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
1094
|
+
var get, set;
|
|
1095
|
+
if (kind === 0) {
|
|
1096
|
+
if (isPrivate) {
|
|
1097
|
+
get = desc.get;
|
|
1098
|
+
set = desc.set;
|
|
1099
|
+
} else {
|
|
1100
|
+
get = function() {
|
|
1101
|
+
return this[name];
|
|
1102
|
+
};
|
|
1103
|
+
set = function(v) {
|
|
1104
|
+
this[name] = v;
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
} else if (kind === 2) {
|
|
1108
|
+
get = function() {
|
|
1109
|
+
return desc.value;
|
|
1110
|
+
};
|
|
1111
|
+
} else {
|
|
1112
|
+
if (kind === 1 || kind === 3) {
|
|
1113
|
+
get = function() {
|
|
1114
|
+
return desc.get.call(this);
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
if (kind === 1 || kind === 4) {
|
|
1118
|
+
set = function(v) {
|
|
1119
|
+
desc.set.call(this, v);
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
ctx.access = get && set ? {
|
|
1124
|
+
get: get,
|
|
1125
|
+
set: set
|
|
1126
|
+
} : get ? {
|
|
1127
|
+
get: get
|
|
1128
|
+
} : {
|
|
1129
|
+
set: set
|
|
1130
|
+
};
|
|
1131
|
+
try {
|
|
1132
|
+
return dec(value, ctx);
|
|
1133
|
+
} finally{
|
|
1134
|
+
decoratorFinishedRef.v = true;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
1138
|
+
if (decoratorFinishedRef.v) {
|
|
1139
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
function assertCallable(fn, hint) {
|
|
1143
|
+
if (typeof fn !== "function") {
|
|
1144
|
+
throw new TypeError(hint + " must be a function");
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
function assertValidReturnValue(kind, value) {
|
|
1148
|
+
var type = typeof value;
|
|
1149
|
+
if (kind === 1) {
|
|
1150
|
+
if (type !== "object" || value === null) {
|
|
1151
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
1152
|
+
}
|
|
1153
|
+
if (value.get !== undefined) {
|
|
1154
|
+
assertCallable(value.get, "accessor.get");
|
|
1155
|
+
}
|
|
1156
|
+
if (value.set !== undefined) {
|
|
1157
|
+
assertCallable(value.set, "accessor.set");
|
|
1158
|
+
}
|
|
1159
|
+
if (value.init !== undefined) {
|
|
1160
|
+
assertCallable(value.init, "accessor.init");
|
|
1161
|
+
}
|
|
1162
|
+
} else if (type !== "function") {
|
|
1163
|
+
var hint;
|
|
1164
|
+
if (kind === 0) {
|
|
1165
|
+
hint = "field";
|
|
1166
|
+
} else if (kind === 10) {
|
|
1167
|
+
hint = "class";
|
|
1168
|
+
} else {
|
|
1169
|
+
hint = "method";
|
|
1170
|
+
}
|
|
1171
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
1175
|
+
var decs = decInfo[0];
|
|
1176
|
+
var desc, init, value;
|
|
1177
|
+
if (isPrivate) {
|
|
1178
|
+
if (kind === 0 || kind === 1) {
|
|
1179
|
+
desc = {
|
|
1180
|
+
get: decInfo[3],
|
|
1181
|
+
set: decInfo[4]
|
|
1182
|
+
};
|
|
1183
|
+
} else if (kind === 3) {
|
|
1184
|
+
desc = {
|
|
1185
|
+
get: decInfo[3]
|
|
1186
|
+
};
|
|
1187
|
+
} else if (kind === 4) {
|
|
1188
|
+
desc = {
|
|
1189
|
+
set: decInfo[3]
|
|
1190
|
+
};
|
|
1191
|
+
} else {
|
|
1192
|
+
desc = {
|
|
1193
|
+
value: decInfo[3]
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
} else if (kind !== 0) {
|
|
1197
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
1198
|
+
}
|
|
1199
|
+
if (kind === 1) {
|
|
1200
|
+
value = {
|
|
1201
|
+
get: desc.get,
|
|
1202
|
+
set: desc.set
|
|
1203
|
+
};
|
|
1204
|
+
} else if (kind === 2) {
|
|
1205
|
+
value = desc.value;
|
|
1206
|
+
} else if (kind === 3) {
|
|
1207
|
+
value = desc.get;
|
|
1208
|
+
} else if (kind === 4) {
|
|
1209
|
+
value = desc.set;
|
|
1210
|
+
}
|
|
1211
|
+
var newValue, get, set;
|
|
1212
|
+
if (typeof decs === "function") {
|
|
1213
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
1214
|
+
if (newValue !== void 0) {
|
|
1215
|
+
assertValidReturnValue(kind, newValue);
|
|
1216
|
+
if (kind === 0) {
|
|
1217
|
+
init = newValue;
|
|
1218
|
+
} else if (kind === 1) {
|
|
1219
|
+
init = newValue.init;
|
|
1220
|
+
get = newValue.get || value.get;
|
|
1221
|
+
set = newValue.set || value.set;
|
|
1222
|
+
value = {
|
|
1223
|
+
get: get,
|
|
1224
|
+
set: set
|
|
1225
|
+
};
|
|
1226
|
+
} else {
|
|
1227
|
+
value = newValue;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
} else {
|
|
1231
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
1232
|
+
var dec = decs[i];
|
|
1233
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
1234
|
+
if (newValue !== void 0) {
|
|
1235
|
+
assertValidReturnValue(kind, newValue);
|
|
1236
|
+
var newInit;
|
|
1237
|
+
if (kind === 0) {
|
|
1238
|
+
newInit = newValue;
|
|
1239
|
+
} else if (kind === 1) {
|
|
1240
|
+
newInit = newValue.init;
|
|
1241
|
+
get = newValue.get || value.get;
|
|
1242
|
+
set = newValue.set || value.set;
|
|
1243
|
+
value = {
|
|
1244
|
+
get: get,
|
|
1245
|
+
set: set
|
|
1246
|
+
};
|
|
1247
|
+
} else {
|
|
1248
|
+
value = newValue;
|
|
1249
|
+
}
|
|
1250
|
+
if (newInit !== void 0) {
|
|
1251
|
+
if (init === void 0) {
|
|
1252
|
+
init = newInit;
|
|
1253
|
+
} else if (typeof init === "function") {
|
|
1254
|
+
init = [
|
|
1255
|
+
init,
|
|
1256
|
+
newInit
|
|
1257
|
+
];
|
|
1258
|
+
} else {
|
|
1259
|
+
init.push(newInit);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
if (kind === 0 || kind === 1) {
|
|
1266
|
+
if (init === void 0) {
|
|
1267
|
+
init = function(instance, init) {
|
|
1268
|
+
return init;
|
|
1269
|
+
};
|
|
1270
|
+
} else if (typeof init !== "function") {
|
|
1271
|
+
var ownInitializers = init;
|
|
1272
|
+
init = function(instance, init) {
|
|
1273
|
+
var value = init;
|
|
1274
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
1275
|
+
value = ownInitializers[i].call(instance, value);
|
|
1276
|
+
}
|
|
1277
|
+
return value;
|
|
1278
|
+
};
|
|
1279
|
+
} else {
|
|
1280
|
+
var originalInitializer = init;
|
|
1281
|
+
init = function(instance, init) {
|
|
1282
|
+
return originalInitializer.call(instance, init);
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
ret.push(init);
|
|
1286
|
+
}
|
|
1287
|
+
if (kind !== 0) {
|
|
1288
|
+
if (kind === 1) {
|
|
1289
|
+
desc.get = value.get;
|
|
1290
|
+
desc.set = value.set;
|
|
1291
|
+
} else if (kind === 2) {
|
|
1292
|
+
desc.value = value;
|
|
1293
|
+
} else if (kind === 3) {
|
|
1294
|
+
desc.get = value;
|
|
1295
|
+
} else if (kind === 4) {
|
|
1296
|
+
desc.set = value;
|
|
1297
|
+
}
|
|
1298
|
+
if (isPrivate) {
|
|
1299
|
+
if (kind === 1) {
|
|
1300
|
+
ret.push(function(instance, args) {
|
|
1301
|
+
return value.get.call(instance, args);
|
|
1302
|
+
});
|
|
1303
|
+
ret.push(function(instance, args) {
|
|
1304
|
+
return value.set.call(instance, args);
|
|
1305
|
+
});
|
|
1306
|
+
} else if (kind === 2) {
|
|
1307
|
+
ret.push(value);
|
|
1308
|
+
} else {
|
|
1309
|
+
ret.push(function(instance, args) {
|
|
1310
|
+
return value.call(instance, args);
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
} else {
|
|
1314
|
+
Object.defineProperty(base, name, desc);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
1319
|
+
var ret = [];
|
|
1320
|
+
var protoInitializers;
|
|
1321
|
+
var staticInitializers;
|
|
1322
|
+
var existingProtoNonFields = new Map();
|
|
1323
|
+
var existingStaticNonFields = new Map();
|
|
1324
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
1325
|
+
var decInfo = decInfos[i];
|
|
1326
|
+
if (!Array.isArray(decInfo)) continue;
|
|
1327
|
+
var kind = decInfo[1];
|
|
1328
|
+
var name = decInfo[2];
|
|
1329
|
+
var isPrivate = decInfo.length > 3;
|
|
1330
|
+
var isStatic = kind >= 5;
|
|
1331
|
+
var base;
|
|
1332
|
+
var initializers;
|
|
1333
|
+
if (isStatic) {
|
|
1334
|
+
base = Class;
|
|
1335
|
+
kind = kind - 5;
|
|
1336
|
+
staticInitializers = staticInitializers || [];
|
|
1337
|
+
initializers = staticInitializers;
|
|
1338
|
+
} else {
|
|
1339
|
+
base = Class.prototype;
|
|
1340
|
+
protoInitializers = protoInitializers || [];
|
|
1341
|
+
initializers = protoInitializers;
|
|
1342
|
+
}
|
|
1343
|
+
if (kind !== 0 && !isPrivate) {
|
|
1344
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
1345
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
1346
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
1347
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
1348
|
+
} else if (!existingKind && kind > 2) {
|
|
1349
|
+
existingNonFields.set(name, kind);
|
|
1350
|
+
} else {
|
|
1351
|
+
existingNonFields.set(name, true);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
1355
|
+
}
|
|
1356
|
+
pushInitializers(ret, protoInitializers);
|
|
1357
|
+
pushInitializers(ret, staticInitializers);
|
|
1358
|
+
return ret;
|
|
1359
|
+
}
|
|
1360
|
+
function pushInitializers(ret, initializers) {
|
|
1361
|
+
if (initializers) {
|
|
1362
|
+
ret.push(function(instance) {
|
|
1363
|
+
for(var i = 0; i < initializers.length; i++){
|
|
1364
|
+
initializers[i].call(instance);
|
|
1365
|
+
}
|
|
1366
|
+
return instance;
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
1371
|
+
if (classDecs.length > 0) {
|
|
1372
|
+
var initializers = [];
|
|
1373
|
+
var newClass = targetClass;
|
|
1374
|
+
var name = targetClass.name;
|
|
1375
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
1376
|
+
var decoratorFinishedRef = {
|
|
1377
|
+
v: false
|
|
1378
|
+
};
|
|
1379
|
+
try {
|
|
1380
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
1381
|
+
kind: "class",
|
|
1382
|
+
name: name,
|
|
1383
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
1384
|
+
metadata
|
|
1385
|
+
});
|
|
1386
|
+
} finally{
|
|
1387
|
+
decoratorFinishedRef.v = true;
|
|
1388
|
+
}
|
|
1389
|
+
if (nextNewClass !== undefined) {
|
|
1390
|
+
assertValidReturnValue(10, nextNewClass);
|
|
1391
|
+
newClass = nextNewClass;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
return [
|
|
1395
|
+
defineMetadata(newClass, metadata),
|
|
1396
|
+
function() {
|
|
1397
|
+
for(var i = 0; i < initializers.length; i++){
|
|
1398
|
+
initializers[i].call(newClass);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
];
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
function defineMetadata(Class, metadata) {
|
|
1405
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
1406
|
+
configurable: true,
|
|
1407
|
+
enumerable: true,
|
|
1408
|
+
value: metadata
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
1412
|
+
if (parentClass !== void 0) {
|
|
1413
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
1414
|
+
}
|
|
1415
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
1416
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
1417
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
1418
|
+
return {
|
|
1419
|
+
e: e,
|
|
1420
|
+
get c () {
|
|
1421
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
1427
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
1428
|
+
}
|
|
1429
|
+
function _identity(x) {
|
|
1430
|
+
return x;
|
|
1431
|
+
}
|
|
1432
|
+
var _dec, _initClass, _ValidityMixin, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, // ── Lit TC39 stage-3 accessors ──────────────────────────────────────────
|
|
1433
|
+
_init_value, _init_name, _init_mode, _init_flat, _init_hoist, _init_min, _init_max, _init_locale, _init_disabled, _init_weekNumbers, _init_todayLabel, // ── Internal state ────────────────────────────────────────────────────────
|
|
1434
|
+
_init__resolvedLocale, _init__displayValue, _init__fpInput, _init__floatingMenuContainer, _init__inputs, _init_labelPrevMonth, _init_labelNextMonth, _init_labelSelectMonth, _init_labelSelectYear, _initProto;
|
|
1435
|
+
/** Emitted when the user selects a date. Detail: DatePickerChangeDetail. */ const VIALIQ_CHANGE = 'vialiq-change';
|
|
1436
|
+
let _ViDatePicker;
|
|
1437
|
+
_dec = customElement('vi-date-picker'), _dec1 = property({
|
|
1438
|
+
type: String,
|
|
1439
|
+
reflect: true
|
|
1440
|
+
}), _dec2 = property({
|
|
1441
|
+
type: String
|
|
1442
|
+
}), _dec3 = property({
|
|
1443
|
+
type: String,
|
|
1444
|
+
reflect: true
|
|
1445
|
+
}), _dec4 = property({
|
|
1446
|
+
type: Boolean,
|
|
1447
|
+
reflect: true
|
|
1448
|
+
}), _dec5 = property({
|
|
1449
|
+
type: Boolean
|
|
1450
|
+
}), _dec6 = property({
|
|
1451
|
+
type: String
|
|
1452
|
+
}), _dec7 = property({
|
|
1453
|
+
type: String
|
|
1454
|
+
}), _dec8 = property({
|
|
1455
|
+
type: String
|
|
1456
|
+
}), _dec9 = property({
|
|
1457
|
+
type: Boolean,
|
|
1458
|
+
reflect: true
|
|
1459
|
+
}), _dec10 = property({
|
|
1460
|
+
type: Boolean,
|
|
1461
|
+
attribute: 'week-numbers'
|
|
1462
|
+
}), _dec11 = property({
|
|
1463
|
+
type: String,
|
|
1464
|
+
attribute: 'today-label'
|
|
1465
|
+
}), _dec12 = state(), _dec13 = state(), _dec14 = query('#fp-input'), _dec15 = query('#floating-menu-container'), _dec16 = queryAssignedElements({
|
|
1466
|
+
selector: 'vi-date-picker-input'
|
|
1467
|
+
}), _dec17 = property({
|
|
1468
|
+
type: String,
|
|
1469
|
+
attribute: 'label-prev-month'
|
|
1470
|
+
}), _dec18 = property({
|
|
1471
|
+
type: String,
|
|
1472
|
+
attribute: 'label-next-month'
|
|
1473
|
+
}), _dec19 = property({
|
|
1474
|
+
type: String,
|
|
1475
|
+
attribute: 'label-select-month'
|
|
1476
|
+
}), _dec20 = property({
|
|
1477
|
+
type: String,
|
|
1478
|
+
attribute: 'label-select-year'
|
|
1479
|
+
});
|
|
1480
|
+
new class extends _identity {
|
|
1481
|
+
constructor(){
|
|
1482
|
+
super(_ViDatePicker), _initClass();
|
|
1483
|
+
}
|
|
1484
|
+
static{
|
|
1485
|
+
class ViDatePicker extends (_ValidityMixin = ValidityMixin(FlatpickrMixin(ViElement))) {
|
|
1486
|
+
static{
|
|
1487
|
+
({ e: [_init_value, _init_name, _init_mode, _init_flat, _init_hoist, _init_min, _init_max, _init_locale, _init_disabled, _init_weekNumbers, _init_todayLabel, _init__resolvedLocale, _init__displayValue, _init__fpInput, _init__floatingMenuContainer, _init__inputs, _init_labelPrevMonth, _init_labelNextMonth, _init_labelSelectMonth, _init_labelSelectYear, _initProto], c: [_ViDatePicker, _initClass] } = _apply_decs_2203_r(this, [
|
|
1488
|
+
[
|
|
1489
|
+
_dec1,
|
|
1490
|
+
1,
|
|
1491
|
+
"value"
|
|
1492
|
+
],
|
|
1493
|
+
[
|
|
1494
|
+
_dec2,
|
|
1495
|
+
1,
|
|
1496
|
+
"name"
|
|
1497
|
+
],
|
|
1498
|
+
[
|
|
1499
|
+
_dec3,
|
|
1500
|
+
1,
|
|
1501
|
+
"mode"
|
|
1502
|
+
],
|
|
1503
|
+
[
|
|
1504
|
+
_dec4,
|
|
1505
|
+
1,
|
|
1506
|
+
"flat"
|
|
1507
|
+
],
|
|
1508
|
+
[
|
|
1509
|
+
_dec5,
|
|
1510
|
+
1,
|
|
1511
|
+
"hoist"
|
|
1512
|
+
],
|
|
1513
|
+
[
|
|
1514
|
+
_dec6,
|
|
1515
|
+
1,
|
|
1516
|
+
"min"
|
|
1517
|
+
],
|
|
1518
|
+
[
|
|
1519
|
+
_dec7,
|
|
1520
|
+
1,
|
|
1521
|
+
"max"
|
|
1522
|
+
],
|
|
1523
|
+
[
|
|
1524
|
+
_dec8,
|
|
1525
|
+
1,
|
|
1526
|
+
"locale"
|
|
1527
|
+
],
|
|
1528
|
+
[
|
|
1529
|
+
_dec9,
|
|
1530
|
+
1,
|
|
1531
|
+
"disabled"
|
|
1532
|
+
],
|
|
1533
|
+
[
|
|
1534
|
+
_dec10,
|
|
1535
|
+
1,
|
|
1536
|
+
"weekNumbers"
|
|
1537
|
+
],
|
|
1538
|
+
[
|
|
1539
|
+
_dec11,
|
|
1540
|
+
1,
|
|
1541
|
+
"todayLabel"
|
|
1542
|
+
],
|
|
1543
|
+
[
|
|
1544
|
+
_dec12,
|
|
1545
|
+
1,
|
|
1546
|
+
"_resolvedLocale"
|
|
1547
|
+
],
|
|
1548
|
+
[
|
|
1549
|
+
_dec13,
|
|
1550
|
+
1,
|
|
1551
|
+
"_displayValue"
|
|
1552
|
+
],
|
|
1553
|
+
[
|
|
1554
|
+
_dec14,
|
|
1555
|
+
1,
|
|
1556
|
+
"_fpInput"
|
|
1557
|
+
],
|
|
1558
|
+
[
|
|
1559
|
+
_dec15,
|
|
1560
|
+
1,
|
|
1561
|
+
"_floatingMenuContainer"
|
|
1562
|
+
],
|
|
1563
|
+
[
|
|
1564
|
+
_dec16,
|
|
1565
|
+
1,
|
|
1566
|
+
"_inputs"
|
|
1567
|
+
],
|
|
1568
|
+
[
|
|
1569
|
+
_dec17,
|
|
1570
|
+
1,
|
|
1571
|
+
"labelPrevMonth"
|
|
1572
|
+
],
|
|
1573
|
+
[
|
|
1574
|
+
_dec18,
|
|
1575
|
+
1,
|
|
1576
|
+
"labelNextMonth"
|
|
1577
|
+
],
|
|
1578
|
+
[
|
|
1579
|
+
_dec19,
|
|
1580
|
+
1,
|
|
1581
|
+
"labelSelectMonth"
|
|
1582
|
+
],
|
|
1583
|
+
[
|
|
1584
|
+
_dec20,
|
|
1585
|
+
1,
|
|
1586
|
+
"labelSelectYear"
|
|
1587
|
+
]
|
|
1588
|
+
], [
|
|
1589
|
+
_dec
|
|
1590
|
+
], _ValidityMixin));
|
|
1591
|
+
}
|
|
1592
|
+
#___private_value_1 = (_initProto(this), _init_value(this, ''));
|
|
1593
|
+
get value() {
|
|
1594
|
+
return this.#___private_value_1;
|
|
1595
|
+
}
|
|
1596
|
+
set value(_v) {
|
|
1597
|
+
this.#___private_value_1 = _v;
|
|
1598
|
+
}
|
|
1599
|
+
#___private_name_2 = _init_name(this, '');
|
|
1600
|
+
get name() {
|
|
1601
|
+
return this.#___private_name_2;
|
|
1602
|
+
}
|
|
1603
|
+
set name(_v) {
|
|
1604
|
+
this.#___private_name_2 = _v;
|
|
1605
|
+
}
|
|
1606
|
+
#___private_mode_3 = _init_mode(this, 'date');
|
|
1607
|
+
get mode() {
|
|
1608
|
+
return this.#___private_mode_3;
|
|
1609
|
+
}
|
|
1610
|
+
set mode(_v) {
|
|
1611
|
+
this.#___private_mode_3 = _v;
|
|
1612
|
+
}
|
|
1613
|
+
#___private_flat_4 = _init_flat(this, false);
|
|
1614
|
+
get flat() {
|
|
1615
|
+
return this.#___private_flat_4;
|
|
1616
|
+
}
|
|
1617
|
+
set flat(_v) {
|
|
1618
|
+
this.#___private_flat_4 = _v;
|
|
1619
|
+
}
|
|
1620
|
+
#___private_hoist_5 = _init_hoist(this, false);
|
|
1621
|
+
get hoist() {
|
|
1622
|
+
return this.#___private_hoist_5;
|
|
1623
|
+
}
|
|
1624
|
+
set hoist(_v) {
|
|
1625
|
+
this.#___private_hoist_5 = _v;
|
|
1626
|
+
}
|
|
1627
|
+
#___private_min_6 = _init_min(this, '');
|
|
1628
|
+
get min() {
|
|
1629
|
+
return this.#___private_min_6;
|
|
1630
|
+
}
|
|
1631
|
+
set min(_v) {
|
|
1632
|
+
this.#___private_min_6 = _v;
|
|
1633
|
+
}
|
|
1634
|
+
#___private_max_7 = _init_max(this, '');
|
|
1635
|
+
get max() {
|
|
1636
|
+
return this.#___private_max_7;
|
|
1637
|
+
}
|
|
1638
|
+
set max(_v) {
|
|
1639
|
+
this.#___private_max_7 = _v;
|
|
1640
|
+
}
|
|
1641
|
+
#___private_locale_8 = _init_locale(this, null);
|
|
1642
|
+
get locale() {
|
|
1643
|
+
return this.#___private_locale_8;
|
|
1644
|
+
}
|
|
1645
|
+
set locale(_v) {
|
|
1646
|
+
this.#___private_locale_8 = _v;
|
|
1647
|
+
}
|
|
1648
|
+
#___private_disabled_9 = _init_disabled(this, false);
|
|
1649
|
+
get disabled() {
|
|
1650
|
+
return this.#___private_disabled_9;
|
|
1651
|
+
}
|
|
1652
|
+
set disabled(_v) {
|
|
1653
|
+
this.#___private_disabled_9 = _v;
|
|
1654
|
+
}
|
|
1655
|
+
#___private_weekNumbers_10 = _init_weekNumbers(this, false);
|
|
1656
|
+
get weekNumbers() {
|
|
1657
|
+
return this.#___private_weekNumbers_10;
|
|
1658
|
+
}
|
|
1659
|
+
set weekNumbers(_v) {
|
|
1660
|
+
this.#___private_weekNumbers_10 = _v;
|
|
1661
|
+
}
|
|
1662
|
+
#___private_todayLabel_11 = _init_todayLabel(this, undefined);
|
|
1663
|
+
get todayLabel() {
|
|
1664
|
+
return this.#___private_todayLabel_11;
|
|
1665
|
+
}
|
|
1666
|
+
set todayLabel(_v) {
|
|
1667
|
+
this.#___private_todayLabel_11 = _v;
|
|
1668
|
+
}
|
|
1669
|
+
#___private__resolvedLocale_12 = _init__resolvedLocale(this, 'en');
|
|
1670
|
+
get _resolvedLocale() {
|
|
1671
|
+
return this.#___private__resolvedLocale_12;
|
|
1672
|
+
}
|
|
1673
|
+
set _resolvedLocale(_v) {
|
|
1674
|
+
this.#___private__resolvedLocale_12 = _v;
|
|
1675
|
+
}
|
|
1676
|
+
#___private__displayValue_13 = _init__displayValue(this, '');
|
|
1677
|
+
get _displayValue() {
|
|
1678
|
+
return this.#___private__displayValue_13;
|
|
1679
|
+
}
|
|
1680
|
+
set _displayValue(_v) {
|
|
1681
|
+
this.#___private__displayValue_13 = _v;
|
|
1682
|
+
}
|
|
1683
|
+
#___private__fpInput_14 = _init__fpInput(this);
|
|
1684
|
+
get _fpInput() {
|
|
1685
|
+
return this.#___private__fpInput_14;
|
|
1686
|
+
}
|
|
1687
|
+
set _fpInput(_v) {
|
|
1688
|
+
this.#___private__fpInput_14 = _v;
|
|
1689
|
+
}
|
|
1690
|
+
#___private__floatingMenuContainer_15 = _init__floatingMenuContainer(this);
|
|
1691
|
+
get _floatingMenuContainer() {
|
|
1692
|
+
return this.#___private__floatingMenuContainer_15;
|
|
1693
|
+
}
|
|
1694
|
+
set _floatingMenuContainer(_v) {
|
|
1695
|
+
this.#___private__floatingMenuContainer_15 = _v;
|
|
1696
|
+
}
|
|
1697
|
+
#___private__inputs_16 = _init__inputs(this);
|
|
1698
|
+
get _inputs() {
|
|
1699
|
+
return this.#___private__inputs_16;
|
|
1700
|
+
}
|
|
1701
|
+
set _inputs(_v) {
|
|
1702
|
+
this.#___private__inputs_16 = _v;
|
|
1703
|
+
}
|
|
1704
|
+
/** Light DOM container for flatpickr inline mode to inherit global CSS */ _inlineContainer;
|
|
1705
|
+
_initialValue = '';
|
|
1706
|
+
#___private_labelPrevMonth_17 = _init_labelPrevMonth(this, undefined);
|
|
1707
|
+
get labelPrevMonth() {
|
|
1708
|
+
return this.#___private_labelPrevMonth_17;
|
|
1709
|
+
}
|
|
1710
|
+
set labelPrevMonth(_v) {
|
|
1711
|
+
this.#___private_labelPrevMonth_17 = _v;
|
|
1712
|
+
}
|
|
1713
|
+
#___private_labelNextMonth_18 = _init_labelNextMonth(this, undefined);
|
|
1714
|
+
get labelNextMonth() {
|
|
1715
|
+
return this.#___private_labelNextMonth_18;
|
|
1716
|
+
}
|
|
1717
|
+
set labelNextMonth(_v) {
|
|
1718
|
+
this.#___private_labelNextMonth_18 = _v;
|
|
1719
|
+
}
|
|
1720
|
+
#___private_labelSelectMonth_19 = _init_labelSelectMonth(this, undefined);
|
|
1721
|
+
get labelSelectMonth() {
|
|
1722
|
+
return this.#___private_labelSelectMonth_19;
|
|
1723
|
+
}
|
|
1724
|
+
set labelSelectMonth(_v) {
|
|
1725
|
+
this.#___private_labelSelectMonth_19 = _v;
|
|
1726
|
+
}
|
|
1727
|
+
#___private_labelSelectYear_20 = _init_labelSelectYear(this, undefined);
|
|
1728
|
+
get labelSelectYear() {
|
|
1729
|
+
return this.#___private_labelSelectYear_20;
|
|
1730
|
+
}
|
|
1731
|
+
set labelSelectYear(_v) {
|
|
1732
|
+
this.#___private_labelSelectYear_20 = _v;
|
|
1733
|
+
}
|
|
1734
|
+
_floatingController = new FloatingController(this, {
|
|
1735
|
+
reference: ()=>{
|
|
1736
|
+
const primaryInput = this._inputs.find((i)=>i.kind === 'from') || this._inputs[0];
|
|
1737
|
+
return primaryInput ? primaryInput.inputElement : this._fpInput;
|
|
1738
|
+
},
|
|
1739
|
+
floating: ()=>this._fp?.calendarContainer ?? null,
|
|
1740
|
+
hoist: ()=>this.hoist,
|
|
1741
|
+
placement: ()=>'bottom-start',
|
|
1742
|
+
offset: 4,
|
|
1743
|
+
matchWidth: 'none'
|
|
1744
|
+
});
|
|
1745
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
1746
|
+
_getModePluginConfig() {
|
|
1747
|
+
return {
|
|
1748
|
+
ariaLabels: {
|
|
1749
|
+
prevMonth: this.labelPrevMonth,
|
|
1750
|
+
nextMonth: this.labelNextMonth,
|
|
1751
|
+
selectMonth: this.labelSelectMonth,
|
|
1752
|
+
selectYear: this.labelSelectYear
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
// ── ValidityMixin hook ─────────────────────────────────────────────────────
|
|
1757
|
+
_testValidity() {
|
|
1758
|
+
if (this._internals.validity.customError) {
|
|
1759
|
+
return {
|
|
1760
|
+
customError: true
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
if (this.required && !this.value) {
|
|
1764
|
+
const temp = document.createElement('input');
|
|
1765
|
+
temp.required = true;
|
|
1766
|
+
this.validityMessage = temp.validationMessage;
|
|
1767
|
+
return {
|
|
1768
|
+
valueMissing: true
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
if (this.value && (this.min || this.max)) {
|
|
1772
|
+
const dates = [];
|
|
1773
|
+
// Parse this.value directly since flatpickr might silently drop out-of-bounds dates
|
|
1774
|
+
// from its selectedDates array, causing us to miss the validation error.
|
|
1775
|
+
if (this.mode === 'range') {
|
|
1776
|
+
const parts = this.value.split(' to ');
|
|
1777
|
+
if (parts[0]) {
|
|
1778
|
+
const d = new Date(parts[0]);
|
|
1779
|
+
if (!isNaN(d.getTime())) dates.push(d);
|
|
1780
|
+
}
|
|
1781
|
+
if (parts[1]) {
|
|
1782
|
+
const d = new Date(parts[1]);
|
|
1783
|
+
if (!isNaN(d.getTime())) dates.push(d);
|
|
1784
|
+
}
|
|
1785
|
+
} else {
|
|
1786
|
+
const d = new Date(this.value);
|
|
1787
|
+
if (!isNaN(d.getTime())) {
|
|
1788
|
+
dates.push(d);
|
|
1789
|
+
} else if (this._fp) {
|
|
1790
|
+
const parsed = this._fp.parseDate(this.value, this._fp.config.dateFormat);
|
|
1791
|
+
if (parsed) dates.push(parsed);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
if (dates.length === 0 && this.value) {
|
|
1795
|
+
this.validityMessage = 'Please enter a valid date.';
|
|
1796
|
+
return {
|
|
1797
|
+
badInput: true
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
if (dates.length > 0) {
|
|
1801
|
+
const first = dates[0];
|
|
1802
|
+
const last = dates[dates.length - 1];
|
|
1803
|
+
if (this.min) {
|
|
1804
|
+
const minDate = new Date(this.min);
|
|
1805
|
+
first.setHours(0, 0, 0, 0);
|
|
1806
|
+
minDate.setHours(0, 0, 0, 0);
|
|
1807
|
+
if (first < minDate) {
|
|
1808
|
+
const temp = document.createElement('input');
|
|
1809
|
+
temp.type = this.mode === 'month' || this.mode === 'month-year' ? 'month' : this.mode === 'week' ? 'week' : 'date';
|
|
1810
|
+
temp.min = this.min;
|
|
1811
|
+
temp.value = '1000-01-01'; // Force underflow to get localized message
|
|
1812
|
+
this.validityMessage = temp.validationMessage;
|
|
1813
|
+
return {
|
|
1814
|
+
rangeUnderflow: true
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (this.max) {
|
|
1819
|
+
const maxDate = new Date(this.max);
|
|
1820
|
+
last.setHours(0, 0, 0, 0);
|
|
1821
|
+
maxDate.setHours(0, 0, 0, 0);
|
|
1822
|
+
if (last > maxDate) {
|
|
1823
|
+
const temp = document.createElement('input');
|
|
1824
|
+
temp.type = this.mode === 'month' || this.mode === 'month-year' ? 'month' : this.mode === 'week' ? 'week' : 'date';
|
|
1825
|
+
temp.max = this.max;
|
|
1826
|
+
temp.value = '9999-12-31'; // Force overflow to get localized message
|
|
1827
|
+
this.validityMessage = temp.validationMessage;
|
|
1828
|
+
return {
|
|
1829
|
+
rangeOverflow: true
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
return {};
|
|
1836
|
+
}
|
|
1837
|
+
connectedCallback() {
|
|
1838
|
+
super.connectedCallback();
|
|
1839
|
+
this._resolvedLocale = resolveLocale(this.locale);
|
|
1840
|
+
if (!this.hasUpdated) {
|
|
1841
|
+
this._initialValue = this.value;
|
|
1842
|
+
}
|
|
1843
|
+
if (this.hasUpdated && !this._fp) {
|
|
1844
|
+
// Re-initialize if the component is detached and re-attached
|
|
1845
|
+
this._setupFlatpickr();
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
disconnectedCallback() {
|
|
1849
|
+
super.disconnectedCallback();
|
|
1850
|
+
if (this._inlineContainer) {
|
|
1851
|
+
this._inlineContainer.remove();
|
|
1852
|
+
this._inlineContainer = undefined;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
// ── Form lifecycle ────────────────────────────────────────────────────────
|
|
1856
|
+
formResetCallback() {
|
|
1857
|
+
super.formResetCallback();
|
|
1858
|
+
this.value = this._initialValue;
|
|
1859
|
+
this._internals.setFormValue(this.value);
|
|
1860
|
+
if (this._fp) {
|
|
1861
|
+
this._setFpValue(this.value);
|
|
1862
|
+
} else if (this._inputs) {
|
|
1863
|
+
this._inputs.forEach((input)=>{
|
|
1864
|
+
input.value = this.value;
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
async firstUpdated(_changedProperties) {
|
|
1869
|
+
super.firstUpdated(_changedProperties);
|
|
1870
|
+
// Wait for all projected inputs to finish rendering so their internal `inputElement` is available
|
|
1871
|
+
if (this._inputs && this._inputs.length > 0) {
|
|
1872
|
+
await Promise.all(this._inputs.map((input)=>input.updateComplete));
|
|
1873
|
+
}
|
|
1874
|
+
await this._setupFlatpickr();
|
|
1875
|
+
}
|
|
1876
|
+
async _setupFlatpickr() {
|
|
1877
|
+
if (this.flat && !this._inlineContainer) {
|
|
1878
|
+
this._inlineContainer = document.createElement('div');
|
|
1879
|
+
this._inlineContainer.slot = 'inline-container';
|
|
1880
|
+
// Fallback part for styling if needed, though light DOM CSS usually styles it directly
|
|
1881
|
+
this._inlineContainer.part.add('inline-calendar');
|
|
1882
|
+
this.appendChild(this._inlineContainer);
|
|
1883
|
+
}
|
|
1884
|
+
await this._initFlatpickr(this._buildFpConfig(), this.mode, this._resolvedLocale);
|
|
1885
|
+
// Restore value if re-attaching
|
|
1886
|
+
if (this.value && this._fp) {
|
|
1887
|
+
this._setFpValue(this.value);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
async updated(changed) {
|
|
1891
|
+
super.updated(changed);
|
|
1892
|
+
const localeChanged = changed.has('locale');
|
|
1893
|
+
const modeChanged = changed.has('mode');
|
|
1894
|
+
const minMaxChanged = changed.has('min') || changed.has('max');
|
|
1895
|
+
const flatChanged = changed.has('flat');
|
|
1896
|
+
const pluginsChanged = changed.has('plugins');
|
|
1897
|
+
if (localeChanged) {
|
|
1898
|
+
this._resolvedLocale = resolveLocale(this.locale);
|
|
1899
|
+
}
|
|
1900
|
+
if (flatChanged) {
|
|
1901
|
+
if (this.flat && !this._inlineContainer) {
|
|
1902
|
+
this._inlineContainer = document.createElement('div');
|
|
1903
|
+
this._inlineContainer.slot = 'inline-container';
|
|
1904
|
+
this._inlineContainer.part.add('inline-calendar');
|
|
1905
|
+
this.appendChild(this._inlineContainer);
|
|
1906
|
+
} else if (!this.flat && this._inlineContainer) {
|
|
1907
|
+
this._inlineContainer.remove();
|
|
1908
|
+
this._inlineContainer = undefined;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
// Re-init when mode, locale, flat, or plugins change (flatpickr config requires re-init for these)
|
|
1912
|
+
if ((localeChanged || modeChanged || flatChanged || pluginsChanged) && this._fp) {
|
|
1913
|
+
await this._initFlatpickr(this._buildFpConfig(), this.mode, this._resolvedLocale);
|
|
1914
|
+
// Restore value when re-initializing
|
|
1915
|
+
if (this.value) {
|
|
1916
|
+
this._setFpValue(this.value);
|
|
1917
|
+
}
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
if (minMaxChanged) {
|
|
1921
|
+
if (this._fp) {
|
|
1922
|
+
this._fp.set('minDate', this.min || undefined);
|
|
1923
|
+
this._fp.set('maxDate', this.max || undefined);
|
|
1924
|
+
}
|
|
1925
|
+
this._syncValidity();
|
|
1926
|
+
}
|
|
1927
|
+
if (changed.has('value') && this._fp) {
|
|
1928
|
+
const fpDates = this._fp.selectedDates;
|
|
1929
|
+
const start = fpDates[0] ?? null;
|
|
1930
|
+
const end = fpDates[1] ?? null;
|
|
1931
|
+
if (this.value !== this._buildIsoValue(start, end)) {
|
|
1932
|
+
this._setFpValue(this.value);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
if (changed.has('disabled') || changed.has('invalid') || changed.has('validityMessage') || changed.has('required')) {
|
|
1936
|
+
if (this._inputs) {
|
|
1937
|
+
this._inputs.forEach((input)=>{
|
|
1938
|
+
input.disabled = this.disabled;
|
|
1939
|
+
input.required = this.required;
|
|
1940
|
+
input.invalid = this.invalid;
|
|
1941
|
+
input.validityMessage = this.validityMessage;
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
if (changed.has('disabled') && this._fp) {
|
|
1945
|
+
this._fp.set('clickOpens', !this.disabled);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
// ── FlatpickrMixin contract ───────────────────────────────────────────────
|
|
1950
|
+
_getHiddenInput() {
|
|
1951
|
+
return this._fpInput ?? null;
|
|
1952
|
+
}
|
|
1953
|
+
// ── Public API ────────────────────────────────────────────────────────────
|
|
1954
|
+
focus(options) {
|
|
1955
|
+
if (this._inputs && this._inputs.length > 0) {
|
|
1956
|
+
this._inputs[0].focus(options);
|
|
1957
|
+
} else if (this._fpInput) {
|
|
1958
|
+
this._fpInput.focus(options);
|
|
1959
|
+
} else {
|
|
1960
|
+
super.focus(options);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
/** Opens the calendar popup. No-op when flat=true. */ openCalendar() {
|
|
1964
|
+
this._fp?.open();
|
|
1965
|
+
}
|
|
1966
|
+
/** Closes the calendar popup. No-op when flat=true. */ closeCalendar() {
|
|
1967
|
+
this._fp?.close();
|
|
1968
|
+
}
|
|
1969
|
+
/** Clears the selected date(s). */ clear() {
|
|
1970
|
+
this._fp?.clear(false);
|
|
1971
|
+
this.value = '';
|
|
1972
|
+
this._internals.setFormValue('');
|
|
1973
|
+
this._inputs.forEach((input)=>{
|
|
1974
|
+
input.value = '';
|
|
1975
|
+
});
|
|
1976
|
+
this._emitChange([], '');
|
|
1977
|
+
}
|
|
1978
|
+
// ── Config builder ────────────────────────────────────────────────────────
|
|
1979
|
+
_buildFpConfig() {
|
|
1980
|
+
// Check if consumers already provided these plugins
|
|
1981
|
+
const hasMonthYear = this.plugins.some((p)=>isViPlugin(p) && p.id === 'vi-month-select');
|
|
1982
|
+
const hasShadowDomFix = this.plugins.some((p)=>isViPlugin(p) && p.id === 'ViShadowDomPlugin');
|
|
1983
|
+
// Construct internal plugins
|
|
1984
|
+
const internalPlugins = [];
|
|
1985
|
+
if (!hasMonthYear && this.mode !== 'month' && this.mode !== 'month-year') {
|
|
1986
|
+
internalPlugins.push(ViMonthYearPlugin());
|
|
1987
|
+
}
|
|
1988
|
+
if (!hasShadowDomFix) {
|
|
1989
|
+
internalPlugins.push(ViShadowDomPlugin());
|
|
1990
|
+
}
|
|
1991
|
+
if (this.mode === 'range') {
|
|
1992
|
+
const toInput = this._inputs.find((i)=>i.kind === 'to');
|
|
1993
|
+
if (toInput) {
|
|
1994
|
+
internalPlugins.push(ViRangePlugin({
|
|
1995
|
+
input: toInput.inputElement
|
|
1996
|
+
}));
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
const primaryInput = this._inputs.find((i)=>i.kind === 'from') || this._inputs[0];
|
|
2000
|
+
return {
|
|
2001
|
+
inline: this.flat,
|
|
2002
|
+
mode: this.mode === 'range' ? 'range' : 'single',
|
|
2003
|
+
dateFormat: 'Y-m-d',
|
|
2004
|
+
disableMobile: true,
|
|
2005
|
+
ignoredFocusElements: [
|
|
2006
|
+
this,
|
|
2007
|
+
...this._inputs,
|
|
2008
|
+
...this._inputs.map((i)=>i.shadowRoot).filter(Boolean)
|
|
2009
|
+
],
|
|
2010
|
+
...this.flat && this._inlineContainer ? {
|
|
2011
|
+
appendTo: this._inlineContainer
|
|
2012
|
+
} : this._floatingMenuContainer ? {
|
|
2013
|
+
appendTo: this._floatingMenuContainer
|
|
2014
|
+
} : {},
|
|
2015
|
+
...primaryInput && !this.flat ? {
|
|
2016
|
+
positionElement: primaryInput.inputElement
|
|
2017
|
+
} : {},
|
|
2018
|
+
...!this.flat ? {
|
|
2019
|
+
position: (fp)=>{
|
|
2020
|
+
if (this._fp?.isOpen) {
|
|
2021
|
+
this._floatingController.updatePosition().then(()=>{
|
|
2022
|
+
if (fp.calendarContainer) {
|
|
2023
|
+
const placement = fp.calendarContainer.getAttribute('data-placement') || 'bottom';
|
|
2024
|
+
const isBottom = placement.startsWith('bottom');
|
|
2025
|
+
fp.calendarContainer.classList.toggle('arrowTop', isBottom);
|
|
2026
|
+
fp.calendarContainer.classList.toggle('arrowBottom', !isBottom);
|
|
2027
|
+
}
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
} : {},
|
|
2032
|
+
...this.min ? {
|
|
2033
|
+
minDate: this.min
|
|
2034
|
+
} : {},
|
|
2035
|
+
...this.max ? {
|
|
2036
|
+
maxDate: this.max
|
|
2037
|
+
} : {},
|
|
2038
|
+
weekNumbers: this.weekNumbers,
|
|
2039
|
+
plugins: internalPlugins,
|
|
2040
|
+
onReady: (selectedDates, dateStr, instance)=>{
|
|
2041
|
+
if (this.mode === 'date') {
|
|
2042
|
+
this._setupTodayButton(instance);
|
|
2043
|
+
}
|
|
2044
|
+
this._removeFpAria();
|
|
2045
|
+
},
|
|
2046
|
+
onOpen: (selectedDates, dateStr, instance)=>{
|
|
2047
|
+
if (this._inputs) this._inputs.forEach((i)=>i.expanded = true);
|
|
2048
|
+
this._removeFpAria();
|
|
2049
|
+
if (instance.calendarContainer) {
|
|
2050
|
+
instance.calendarContainer.focus();
|
|
2051
|
+
}
|
|
2052
|
+
if (!this.flat) {
|
|
2053
|
+
this._floatingController.start();
|
|
2054
|
+
}
|
|
2055
|
+
},
|
|
2056
|
+
onClose: (selectedDates, dateStr, instance)=>{
|
|
2057
|
+
if (this._inputs) this._inputs.forEach((i)=>i.expanded = false);
|
|
2058
|
+
this._removeFpAria();
|
|
2059
|
+
if (!this.flat) {
|
|
2060
|
+
this._floatingController.stop();
|
|
2061
|
+
}
|
|
2062
|
+
if (!this.flat && this._inputs && this._inputs.length > 0) {
|
|
2063
|
+
const active = document.activeElement;
|
|
2064
|
+
if (active === this || active === document.body || active && instance.calendarContainer?.contains(active)) {
|
|
2065
|
+
const primaryInput = this._inputs.find((i)=>i.kind === 'from') || this._inputs[0];
|
|
2066
|
+
if (primaryInput) {
|
|
2067
|
+
primaryInput.focus();
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
},
|
|
2072
|
+
onChange: (dates, dateStr, fp)=>{
|
|
2073
|
+
this._onFlatpickrChange(dates, dateStr, fp);
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
_removeFpAria() {
|
|
2078
|
+
// Flatpickr blindly attaches ARIA properties to the bound input.
|
|
2079
|
+
// Since our bound input is type="hidden", this causes a11y audit failures.
|
|
2080
|
+
if (this._fpInput) {
|
|
2081
|
+
this._fpInput.removeAttribute('aria-expanded');
|
|
2082
|
+
this._fpInput.removeAttribute('aria-haspopup');
|
|
2083
|
+
this._fpInput.removeAttribute('readonly');
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
// ── Change handler ────────────────────────────────────────────────────────
|
|
2087
|
+
_setFpValue(val) {
|
|
2088
|
+
if (!this._fp) return;
|
|
2089
|
+
let dateToSet = val;
|
|
2090
|
+
if (this.mode === 'week' && val) {
|
|
2091
|
+
const parsed = parseISOWeek(val);
|
|
2092
|
+
if (parsed) dateToSet = parsed;
|
|
2093
|
+
}
|
|
2094
|
+
this._fp.setDate(dateToSet, false);
|
|
2095
|
+
this._syncInputValues(this._fp.selectedDates);
|
|
2096
|
+
}
|
|
2097
|
+
_syncInputValues(dates) {
|
|
2098
|
+
const start = dates[0] ?? null;
|
|
2099
|
+
const end = dates[1] ?? null;
|
|
2100
|
+
if (this.mode !== 'range' || !this._inputs.find((i)=>i.kind === 'to')) {
|
|
2101
|
+
// If single mode, or range mode but no 'to' input provided, sync formatted string to the first input
|
|
2102
|
+
const primaryInput = this._inputs.find((i)=>i.kind === 'from') || this._inputs[0];
|
|
2103
|
+
if (primaryInput) {
|
|
2104
|
+
primaryInput.value = start ? formatDisplay(start, this._resolvedLocale, this.mode, primaryInput.placeholder) : '';
|
|
2105
|
+
}
|
|
2106
|
+
} else {
|
|
2107
|
+
// vi-range-plugin handles updating the 'to' input's value, but since we are using custom elements,
|
|
2108
|
+
// it's cleaner to sync them here as well based on lit properties, though vi-range-plugin triggers 'input' event.
|
|
2109
|
+
const fromInput = this._inputs.find((i)=>i.kind === 'from');
|
|
2110
|
+
const toInput = this._inputs.find((i)=>i.kind === 'to');
|
|
2111
|
+
if (fromInput) {
|
|
2112
|
+
fromInput.value = start ? formatDisplay(start, this._resolvedLocale, 'date', fromInput.placeholder) : '';
|
|
2113
|
+
}
|
|
2114
|
+
if (toInput) {
|
|
2115
|
+
toInput.value = end ? formatDisplay(end, this._resolvedLocale, 'date', toInput.placeholder) : '';
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
_onFlatpickrChange(dates, _dateStr, _fp) {
|
|
2120
|
+
const start = dates[0] ?? null;
|
|
2121
|
+
const end = dates[1] ?? null;
|
|
2122
|
+
const isoValue = this._buildIsoValue(start, end) ?? '';
|
|
2123
|
+
this.value = isoValue;
|
|
2124
|
+
this._syncInputValues(dates);
|
|
2125
|
+
let formattedValue = '';
|
|
2126
|
+
const fromInput = this._inputs.find((i)=>i.kind === 'from') || this._inputs[0];
|
|
2127
|
+
const toInput = this._inputs.find((i)=>i.kind === 'to');
|
|
2128
|
+
if (this.mode === 'range' && toInput) {
|
|
2129
|
+
if (fromInput && toInput && start && end) {
|
|
2130
|
+
formattedValue = `${fromInput.value} to ${toInput.value}`;
|
|
2131
|
+
} else if (fromInput && start) {
|
|
2132
|
+
formattedValue = fromInput.value;
|
|
2133
|
+
}
|
|
2134
|
+
} else if (fromInput) {
|
|
2135
|
+
formattedValue = fromInput.value;
|
|
2136
|
+
}
|
|
2137
|
+
this._internals.setFormValue(isoValue);
|
|
2138
|
+
this._emitChange(dates, formattedValue);
|
|
2139
|
+
}
|
|
2140
|
+
_emitChange(dates, formattedValue) {
|
|
2141
|
+
const start = dates[0] ?? null;
|
|
2142
|
+
const end = dates[1] ?? null;
|
|
2143
|
+
const toComponents = (d)=>d ? {
|
|
2144
|
+
day: d.getDate(),
|
|
2145
|
+
month: d.getMonth() + 1,
|
|
2146
|
+
year: d.getFullYear()
|
|
2147
|
+
} : null;
|
|
2148
|
+
const detail = {
|
|
2149
|
+
value: this._buildIsoValue(start, end),
|
|
2150
|
+
type: this.mode,
|
|
2151
|
+
isoValue: this._buildIsoValue(start, end),
|
|
2152
|
+
utcIso: start ? new Date(Date.UTC(start.getFullYear(), start.getMonth(), start.getDate())).toISOString() : null,
|
|
2153
|
+
formattedValue,
|
|
2154
|
+
rawValue: toComponents(start),
|
|
2155
|
+
rawEndValue: toComponents(end),
|
|
2156
|
+
weekNumber: this.mode === 'week' && start ? getISOWeek(start) : null,
|
|
2157
|
+
locale: this._resolvedLocale,
|
|
2158
|
+
timeZone: resolveTimeZone()
|
|
2159
|
+
};
|
|
2160
|
+
this.dispatchEvent(new CustomEvent(VIALIQ_CHANGE, {
|
|
2161
|
+
detail,
|
|
2162
|
+
bubbles: true,
|
|
2163
|
+
composed: true
|
|
2164
|
+
}));
|
|
2165
|
+
}
|
|
2166
|
+
_buildIsoValue(start, end) {
|
|
2167
|
+
if (!start) return null;
|
|
2168
|
+
const fmt = (d)=>`${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
2169
|
+
switch(this.mode){
|
|
2170
|
+
case 'range':
|
|
2171
|
+
return end ? `${fmt(start)} to ${fmt(end)}` : fmt(start);
|
|
2172
|
+
case 'month':
|
|
2173
|
+
case 'month-year':
|
|
2174
|
+
return `${start.getFullYear()}-${String(start.getMonth() + 1).padStart(2, '0')}`;
|
|
2175
|
+
case 'week':
|
|
2176
|
+
{
|
|
2177
|
+
const week = getISOWeek(start);
|
|
2178
|
+
const weekYearDate = new Date(start);
|
|
2179
|
+
const mondayBasedDay = (start.getDay() + 6) % 7;
|
|
2180
|
+
weekYearDate.setDate(start.getDate() - mondayBasedDay + 3);
|
|
2181
|
+
return `${weekYearDate.getFullYear()}-W${String(week).padStart(2, '0')}`;
|
|
2182
|
+
}
|
|
2183
|
+
default:
|
|
2184
|
+
return fmt(start);
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
_setupTodayButton(fp) {
|
|
2188
|
+
const todayBtn = document.createElement('button');
|
|
2189
|
+
todayBtn.type = 'button';
|
|
2190
|
+
todayBtn.className = 'vi-calendar-today-btn';
|
|
2191
|
+
todayBtn.textContent = this.todayLabel || getTodayLabel(this._resolvedLocale);
|
|
2192
|
+
const handleTodayAction = (e)=>{
|
|
2193
|
+
e.stopPropagation();
|
|
2194
|
+
fp.setDate(new Date(), true);
|
|
2195
|
+
fp.close();
|
|
2196
|
+
};
|
|
2197
|
+
todayBtn.addEventListener('click', handleTodayAction);
|
|
2198
|
+
todayBtn.addEventListener('keydown', (e)=>{
|
|
2199
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
2200
|
+
e.preventDefault();
|
|
2201
|
+
handleTodayAction(e);
|
|
2202
|
+
}
|
|
2203
|
+
});
|
|
2204
|
+
const footer = document.createElement('div');
|
|
2205
|
+
footer.className = 'vi-calendar-footer';
|
|
2206
|
+
footer.appendChild(todayBtn);
|
|
2207
|
+
fp.calendarContainer.appendChild(footer);
|
|
2208
|
+
}
|
|
2209
|
+
async _handleSlotChange() {
|
|
2210
|
+
if (this._inputs && this._inputs.length > 0) {
|
|
2211
|
+
await Promise.all(this._inputs.map((input)=>input.updateComplete));
|
|
2212
|
+
}
|
|
2213
|
+
this._inputs.forEach((input)=>{
|
|
2214
|
+
input.disabled = this.disabled;
|
|
2215
|
+
input.required = this.required;
|
|
2216
|
+
input.invalid = this.invalid;
|
|
2217
|
+
input.validityMessage = this.validityMessage;
|
|
2218
|
+
});
|
|
2219
|
+
// We should re-init flatpickr to register the range plugin if the 'to' input was just slotted
|
|
2220
|
+
if (this._fp) {
|
|
2221
|
+
this._initFlatpickr(this._buildFpConfig(), this.mode, this._resolvedLocale);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
_handleInputsClick(e) {
|
|
2225
|
+
if (this.disabled || this.flat || !this._fp) return;
|
|
2226
|
+
// Check if the click came from a trigger button inside an input
|
|
2227
|
+
const path = e.composedPath();
|
|
2228
|
+
const inputWrapper = path.find((node)=>node.tagName?.toLowerCase() === 'vi-date-picker-input');
|
|
2229
|
+
if (inputWrapper && inputWrapper.inputElement) {
|
|
2230
|
+
this._fp.config.positionElement = inputWrapper.inputElement;
|
|
2231
|
+
this._fp.open();
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
// ── Render ────────────────────────────────────────────────────────────────
|
|
2235
|
+
render() {
|
|
2236
|
+
return html`
|
|
2237
|
+
<!-- Hidden input flatpickr binds to -->
|
|
2238
|
+
<input
|
|
2239
|
+
type="hidden"
|
|
2240
|
+
id="fp-input"
|
|
2241
|
+
tabindex="-1"
|
|
2242
|
+
aria-hidden="true"
|
|
2243
|
+
name="${this.name}"
|
|
2244
|
+
.value="${this.value}"
|
|
2245
|
+
/>
|
|
2246
|
+
|
|
2247
|
+
${this.flat ? html`<slot name="inline-container"></slot>` : html`
|
|
2248
|
+
<div part="control" class="control">
|
|
2249
|
+
<div class="inputs-container" @click="${this._handleInputsClick}">
|
|
2250
|
+
<slot @slotchange="${this._handleSlotChange}"></slot>
|
|
2251
|
+
</div>
|
|
2252
|
+
${this.validityMessage ? html`<span
|
|
2253
|
+
part="validity-message"
|
|
2254
|
+
class="validity-msg"
|
|
2255
|
+
role="alert"
|
|
2256
|
+
>
|
|
2257
|
+
${this.validityMessage}
|
|
2258
|
+
</span>` : ''}
|
|
2259
|
+
</div>
|
|
2260
|
+
<div id="floating-menu-container"></div>
|
|
2261
|
+
`}
|
|
2262
|
+
|
|
2263
|
+
<slot name="helper"></slot>
|
|
2264
|
+
`;
|
|
2265
|
+
}
|
|
2266
|
+
static styles = css`
|
|
2267
|
+
${unsafeCSS(datePickerStyles)}
|
|
2268
|
+
`;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
}();
|
|
2272
|
+
|
|
2273
|
+
export { VIALIQ_CHANGE, _ViDatePicker as ViDatePicker };
|