@adyen/bento-vue3 1.86.0 → 1.86.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1080 @@
1
+ import { reactive as be, defineComponent as aa, useSlots as Ta, ref as A, computed as p, onMounted as ta, openBlock as O, createElementBlock as ye, createElementVNode as P, normalizeClass as ge, unref as D, renderSlot as je, createCommentVNode as B, createBlock as W, createVNode as G, withCtx as Q, createTextVNode as X, toRaw as Fe, watch as Te, toRef as Se, withDirectives as ba, withKeys as Ye, toDisplayString as ha, createSlots as Ra } from "vue";
2
+ import { j as ka } from "./index.CbxHJr39.js";
3
+ import { B as Ia } from "./divider.BIY84UH7.js";
4
+ import { h as Ma, B as wa } from "./button-actions.BH-J7dux.js";
5
+ import { B as _e, d as Le } from "./typography.B3J6_tYk.js";
6
+ import { D as Sa } from "./dropdown-default-textbox.B-_dTUVX.js";
7
+ import { g as se } from "./generate-uid.NJ8tVoha.js";
8
+ import { u as Ae } from "./index.B875RXHM.js";
9
+ import { f as C, h as na, i as x, j as Oa, k as Qe, l as Ea, s as We, m as Fa, n as oe, o as Ge, b as L, u as _a, p as q, e as E, g as Aa } from "./calendar.DzeJoNc2.js";
10
+ import { t as K, c as Ba, n as Ca } from "./getTimezoneOffsetInMilliseconds.Tu2wlbTR.js";
11
+ import { u as qa } from "./use-form-layout-loading.CWbjZiwP.js";
12
+ import { f as Ke, v as Na, u as xa } from "./date-input.XSJuuCHe.js";
13
+ import { B as Ua } from "./directive.rXUeDb8p.js";
14
+ import { u as $a } from "./form-field.D_2g7vaP.js";
15
+ import { B as ve } from "./input-field.CNdqlGw6.js";
16
+ import { B as ja } from "./dropdown.CU6nfq3V.js";
17
+ import { B as Ya } from "./segmented-control.D9rHBysM.js";
18
+ import { d as pe } from "./debounce.DUTu11PS.js";
19
+ import { u as La } from "./use-has-slot.B7eQSabc.js";
20
+ import { e as $, a as He } from "./differenceInMonths.BR4Z2HIa.js";
21
+ import { s as Pe } from "./startOfWeek.D8Yh4c0G.js";
22
+ import { c as Qa } from "./constructNow.B8T1ljs6.js";
23
+ import { _ as ra } from "./_plugin-vue_export-helper.CHgC5LLL.js";
24
+ import { F as Wa, E as Ve } from "./error-message.BYA2_fPV.js";
25
+ import { B as Ga } from "./button-actions.types.BptAXjD8.js";
26
+ import "../assets/date-range-picker.css";
27
+ function le(t) {
28
+ if (t == null)
29
+ return C(/* @__PURE__ */ new Date());
30
+ const [o, u, r] = t.split("-").map((e) => parseInt(e, 10));
31
+ return new Date(o, u - 1, r);
32
+ }
33
+ function sa(t, o, u) {
34
+ return na(t, o * 3, u);
35
+ }
36
+ function Ka(t, o, u) {
37
+ return sa(t, -1, u);
38
+ }
39
+ const Ha = ({
40
+ firstDayOfWeek: t,
41
+ min: o,
42
+ max: u
43
+ }) => ({ getGranularCalendarLimits: (e) => {
44
+ if (!o && !u)
45
+ return { min: null, max: null };
46
+ let d = o ? C(o) : null, f = u ? $(u) : null;
47
+ if ((e == null ? void 0 : e.type) === "weekly") {
48
+ if (e.earliest)
49
+ d = C(e.earliest);
50
+ else if (d) {
51
+ const y = Pe(d, { weekStartsOn: t });
52
+ x(d, y) || (d = C(Oa(Qe(d, { weekStartsOn: t }), 1)));
53
+ }
54
+ if (e.latest)
55
+ f = $(e.latest);
56
+ else if (f) {
57
+ const y = Qe(f, { weekStartsOn: t });
58
+ x(f, y) || (f = $(Ea(Pe(f, { weekStartsOn: t }), 1)));
59
+ }
60
+ }
61
+ if ((e == null ? void 0 : e.type) === "monthly") {
62
+ if (e.earliest)
63
+ d = C(e.earliest);
64
+ else if (d) {
65
+ const y = We(d);
66
+ x(d, y) || (d = We(na(d, 1)));
67
+ }
68
+ if (e.latest)
69
+ f = $(e.latest);
70
+ else if (f) {
71
+ const y = He(f);
72
+ x(f, y) || (f = He(Fa(f, 1)));
73
+ }
74
+ }
75
+ if ((e == null ? void 0 : e.type) === "quarterly") {
76
+ if (e.earliest)
77
+ d = oe(e.earliest);
78
+ else if (d) {
79
+ const y = oe(d);
80
+ x(d, y) || (d = oe(sa(d, 1)));
81
+ }
82
+ if (e.latest)
83
+ f = $(e.latest);
84
+ else if (f) {
85
+ const y = Ge(f);
86
+ x(f, y) || (f = Ge(Ka(f)));
87
+ }
88
+ }
89
+ return { min: d, max: f };
90
+ } }), Pa = () => {
91
+ const t = be({
92
+ daily: null,
93
+ weekly: null,
94
+ monthly: null,
95
+ quarterly: null
96
+ });
97
+ return {
98
+ savedRanges: t,
99
+ saveRange: (r, e) => {
100
+ t[r] = e;
101
+ },
102
+ resetSavedRanges: () => {
103
+ t.daily = null, t.weekly = null, t.monthly = null, t.quarterly = null;
104
+ }
105
+ };
106
+ };
107
+ var v = /* @__PURE__ */ ((t) => (t.CUSTOM_RANGE = "custom-range", t.INPUT = "input", t.ERROR = "error", t.FORM_DATE = "form-date", t.START_DATE_SELECTED = "start-date-selected", t))(v || {});
108
+ function Va(t, o, u) {
109
+ const r = K(t, u == null ? void 0 : u.in);
110
+ return r.setHours(o), r;
111
+ }
112
+ function za(t, o, u) {
113
+ const r = K(t, u == null ? void 0 : u.in);
114
+ return r.setMinutes(o), r;
115
+ }
116
+ function Ja(t, o, u) {
117
+ const r = K(t, u == null ? void 0 : u.in);
118
+ return r.setSeconds(o), r;
119
+ }
120
+ function ze(t, o) {
121
+ const u = K(t, o == null ? void 0 : o.in);
122
+ return u.setMilliseconds(0), u;
123
+ }
124
+ function Oe(t, o) {
125
+ return +ze(t) == +ze(o);
126
+ }
127
+ function Ee(t, o) {
128
+ return +K(t) == +K(o);
129
+ }
130
+ function Xa(t, o) {
131
+ return x(
132
+ Ba(t, t),
133
+ Qa(t)
134
+ );
135
+ }
136
+ function Je(t, o, u) {
137
+ const r = K(t, u == null ? void 0 : u.in);
138
+ return r.setMilliseconds(o), r;
139
+ }
140
+ const Za = /[\d]/, et = /^\d{2}$/, at = /^\d{2}:\d{2}$/, tt = (t) => {
141
+ const { selectionStart: o } = t.target, u = ["Backspace", "Tab", "ArrowLeft", "ArrowRight"], r = Za.test(t.key) || u.includes(t.key), e = [1, 2, 4, 5].includes(o) && t.key === ":";
142
+ !r && !e && t.preventDefault();
143
+ }, Xe = (t) => {
144
+ if (!t)
145
+ return t;
146
+ let o = t;
147
+ if (o.length === 1 && parseInt(t, 10) > 2)
148
+ return `0${o}:`;
149
+ const [u, r] = o.slice(-2);
150
+ return [2, 5].includes(o.length) && r === ":" && (o = `${o.slice(0, o.length - 2)}0${u}`), (et.test(o) || at.test(o)) && (o += ":"), o;
151
+ }, la = {
152
+ "en-US": {
153
+ customRange: "Custom range",
154
+ daily: "Daily",
155
+ dateFrom: "Date from",
156
+ dateTo: "Date to",
157
+ lastMonth: "Last month",
158
+ lastSevenDays: "Last 7 days",
159
+ lastThreeMonths: "Last three months",
160
+ monthly: "Monthly",
161
+ quarterly: "Quarterly",
162
+ timeFrom: "Time from",
163
+ timeTo: "Time to",
164
+ weekly: "Weekly"
165
+ },
166
+ "ja-JP": {
167
+ customRange: "カスタム範囲",
168
+ daily: "毎日",
169
+ dateFrom: "開始日",
170
+ dateTo: "日付まで",
171
+ lastMonth: "先月",
172
+ lastSevenDays: "過去7日間",
173
+ lastThreeMonths: "過去3か月",
174
+ monthly: "毎月",
175
+ quarterly: "毎四半期",
176
+ timeFrom: "開始時刻",
177
+ timeTo: "終了時刻",
178
+ weekly: "毎週"
179
+ },
180
+ "pt-BR": {
181
+ customRange: "Intervalo personalizado",
182
+ daily: "Diária",
183
+ dateFrom: "Data a partir de",
184
+ dateTo: "Data até",
185
+ lastMonth: "Último mês",
186
+ lastSevenDays: "Últimos 7 dias",
187
+ lastThreeMonths: "Últimos 3 meses",
188
+ monthly: "Mensal",
189
+ quarterly: "Trimestral",
190
+ timeFrom: "Horário a partir de",
191
+ timeTo: "Hora de",
192
+ weekly: "Semanal"
193
+ }
194
+ }, nt = { class: "b-date-range-picker-calendar" }, rt = { class: "b-date-range-picker-calendar__form" }, st = { key: 0 }, lt = {
195
+ key: 0,
196
+ class: "b-date-range-picker-calendar__calendars-container",
197
+ "data-testid": "date-range-picker-calendar-calendar-container"
198
+ }, ot = {
199
+ name: "date-range-picker-calendar",
200
+ i18n: { messages: la }
201
+ }, it = /* @__PURE__ */ aa({
202
+ ...ot,
203
+ props: {
204
+ /**
205
+ * Allows user to enter time values in the form
206
+ */
207
+ allowTimeInput: { type: Boolean, default: !1 },
208
+ /**
209
+ * Ranges form persistance data
210
+ */
211
+ dateFormData: {
212
+ type: Object,
213
+ default: () => ({ startDate: void 0, endDate: void 0, startTime: void 0, endTime: void 0 })
214
+ },
215
+ /**
216
+ * Allows you to set the first day of the week. 0 is sunday, 1 is monday, 6 is saturday
217
+ */
218
+ firstDayOfWeek: L.props.firstDayOfWeek,
219
+ /**
220
+ * A list of available granularities.
221
+ * If present, the date picker will display a segmented control to change granularity.
222
+ */
223
+ granularities: {
224
+ type: Array,
225
+ default: null
226
+ },
227
+ /**
228
+ * Indicate if a date should be disabled or not
229
+ */
230
+ isDateDisabled: L.props.isDateDisabled,
231
+ /**
232
+ * Set a maximum number of dates to be selectable by the range.
233
+ */
234
+ maxRange: L.props.maxRange,
235
+ /**
236
+ * Sets a minimum limit for selectable dates - dates before `min` will not be selectable
237
+ */
238
+ min: L.props.min,
239
+ /**
240
+ * Sets a maximum limit for selectable dates - dates after `max` will not be selectable
241
+ */
242
+ max: L.props.max,
243
+ /**
244
+ * Number of months rendered on pane
245
+ */
246
+ numberOfMonths: {
247
+ type: L.props.numberOfMonths.type,
248
+ default: L.props.numberOfMonths.default,
249
+ validator: (t) => t >= 0
250
+ },
251
+ /**
252
+ * Displays the end date's month when the calendar is opened. Defaults to false i.e. the start date's month is displayed.
253
+ */
254
+ showEndDateOnOpen: { type: Boolean, default: !1 },
255
+ /**
256
+ * Enables the custom range selector.
257
+ * If provided, must be an array that sets the custom range dropdown items. Items are of the structure:
258
+ * `label` - label of custom range item.
259
+ * `value` - a unique key of the custom range item.
260
+ * `data` - an object `{ startDate: Date; endDate: Date }` to set the date picker range to upon selecting.
261
+ */
262
+ quickSelectRanges: {
263
+ type: Array,
264
+ default: void 0
265
+ },
266
+ /**
267
+ * Selected date
268
+ */
269
+ value: { type: Object, default: void 0 },
270
+ /**
271
+ * The type of calendar to display. Defaults to showing days.
272
+ */
273
+ variant: L.props.variant
274
+ },
275
+ emits: [
276
+ v.CUSTOM_RANGE,
277
+ v.INPUT,
278
+ v.ERROR,
279
+ v.FORM_DATE,
280
+ v.START_DATE_SELECTED
281
+ ],
282
+ setup(t, { emit: o }) {
283
+ var Ne, xe, Ue, $e;
284
+ const r = "customRange", e = t, d = o, f = Ta(), y = La(f), { t: M } = Ae({ messages: la }), h = A({}), ee = p(() => e.variant === "month" ? "monthly" : "daily"), ae = p(() => e.numberOfMonths === 0), n = be({
285
+ startDate: (Ne = e.value) == null ? void 0 : Ne.startDate,
286
+ endDate: (xe = e.value) == null ? void 0 : xe.endDate,
287
+ range: (Ue = e.value) == null ? void 0 : Ue.range,
288
+ ...e.granularities ? {
289
+ granularity: (($e = e.value) == null ? void 0 : $e.granularity) || ee.value
290
+ } : {}
291
+ }), F = p(() => {
292
+ var a, l;
293
+ return (
294
+ // eslint-disable-next-line consistent-return
295
+ ((l = (a = e == null ? void 0 : e.quickSelectRanges) == null ? void 0 : a.find(({ value: c, data: m }) => {
296
+ var R;
297
+ if (!m.endDate) {
298
+ if (m.isRelativeToNow) {
299
+ const S = (R = h.value) == null ? void 0 : R[c];
300
+ return S ? Ee(S.startDate, n.startDate) && Ee(S.endDate, n.endDate) : (
301
+ // If not stored calculated dates, fall back to comparing the quick select item's value
302
+ // with the internal range's stored range identifier.
303
+ c === n.range
304
+ );
305
+ }
306
+ return Ee(m.startDate, n.startDate) && Xa(n.endDate) && (!e.allowTimeInput || Oe(n.endDate, $(n.endDate))) && (e.granularities ? m.granularity === n.granularity : !0);
307
+ }
308
+ if (e.allowTimeInput)
309
+ return Oe(m.startDate, n.startDate) && Oe(m.endDate, n.endDate) && (e.granularities ? m.granularity === n.granularity : !0);
310
+ if (m.endDate)
311
+ return x(m.startDate, n.startDate) && x(m.endDate, n.endDate) && (e.granularities ? m.granularity === n.granularity : !0);
312
+ })) == null ? void 0 : l.value) ?? r
313
+ );
314
+ }), _ = p(() => ({
315
+ "b-date-range-picker-calendar__form-input-wrapper": e.allowTimeInput
316
+ })), g = p(() => [
317
+ { label: M("customRange"), value: r },
318
+ ...e.quickSelectRanges ? e.quickSelectRanges : []
319
+ ]), k = p(
320
+ () => {
321
+ var a;
322
+ return ((a = e.granularities) == null ? void 0 : a.find(({ type: l }) => l === n.granularity)) || null;
323
+ }
324
+ ), I = p(
325
+ () => {
326
+ var a;
327
+ return ((a = e.granularities) == null ? void 0 : a.map(({ type: l, disabled: c }) => ({
328
+ label: M(l),
329
+ value: l,
330
+ disabled: c
331
+ }))) ?? [];
332
+ }
333
+ ), { getGranularCalendarLimits: he } = Ha(e), T = p(
334
+ () => e.granularities ? he(k.value) : { min: e.min ? C(e.min) : null, max: e.max ? $(e.max) : null }
335
+ ), {
336
+ adjustDateForQuarterly: ie,
337
+ adjustDateForMonthly: te,
338
+ adjustDateForWeekly: Re,
339
+ adjustStartDateInputForWeekly: ke,
340
+ adjustEndDateInputForWeekly: ue,
341
+ adjustStartDateInputForMonthly: ne,
342
+ adjustEndDateInputForMonthly: b,
343
+ adjustStartDateInputForQuarterly: Ie,
344
+ adjustEndDateInputForQuarterly: V
345
+ } = _a(e.firstDayOfWeek), { savedRanges: H, saveRange: de, resetSavedRanges: re } = Pa(), w = (a) => a ? E(a) : "", U = A(!1), z = A(!1), j = A(!1), Y = A(!1), i = be({
346
+ startDate: e.dateFormData.startDate,
347
+ endDate: e.dateFormData.endDate,
348
+ startTime: e.dateFormData.startTime,
349
+ endTime: e.dateFormData.endTime
350
+ }), me = (a, l) => {
351
+ let c = new Date(a);
352
+ const [m, R, S] = l.split(":");
353
+ return c = Va(c, parseInt(m, 10)), c = za(c, parseInt(R, 10)), c = Ja(c, parseInt(S, 10)), c;
354
+ }, ce = (a) => /^(?:[01]\d|2[01234]):(?:[012345]\d):(?:[012345]\d)$/.test(a), Z = (a, l) => {
355
+ const c = () => {
356
+ if (l && s(l)) {
357
+ const m = me(new Date(l), a);
358
+ if (e.min && m < Je(e.min, 0) || e.max && m > Je(e.max, 0))
359
+ return !1;
360
+ }
361
+ return !0;
362
+ };
363
+ return ce(a) && c();
364
+ }, N = (a, l) => !l || !ce(l) || e.variant === "month" ? a : me(new Date(a), l), Me = (a) => {
365
+ i.startTime = q(
366
+ e.min && e.allowTimeInput && x(e.min, a.startDate) ? e.min : C(a.startDate)
367
+ ), i.endTime = q(
368
+ e.max && e.allowTimeInput && x(e.max, a.endDate) ? e.max : $(a.endDate)
369
+ ), n.startDate = N(a.startDate, i.startTime), n.endDate = N(a.endDate, i.endTime), n.range = null, e.granularities && re(), d(v.INPUT, {
370
+ ...n,
371
+ range: F.value
372
+ });
373
+ }, s = (a) => {
374
+ if (!a)
375
+ return !1;
376
+ const l = (m) => e.min && C(m) < C(e.min) || e.max && C(m) > C(e.max) ? !1 : e.isDateDisabled ? !e.isDateDisabled(C(m)) : !0;
377
+ return /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$/.test(a) && l(new Date(a));
378
+ };
379
+ ta(() => {
380
+ U.value = !!(e.dateFormData.startDate && !s(e.dateFormData.startDate)), e.allowTimeInput ? j.value = !!(e.dateFormData.startTime && !Z(e.dateFormData.startTime, e.dateFormData.startDate)) : j.value = !1, z.value = !!(e.dateFormData.endDate && !s(e.dateFormData.endDate)), e.allowTimeInput ? Y.value = !!(e.dateFormData.endTime && !Z(e.dateFormData.endTime, e.dateFormData.endDate)) : Y.value = !1;
381
+ });
382
+ const J = (a) => {
383
+ var l;
384
+ i.startDate = E(a), i.startTime ? j.value && (i.startTime = (l = e.dateFormData) == null ? void 0 : l.startTime) : i.startTime = q(a), U.value = !1, j.value = !1, d(v.START_DATE_SELECTED, a);
385
+ }, De = (a) => {
386
+ var l;
387
+ i.endDate = E(a), i.endTime ? Y.value && (i.endTime = (l = e.dateFormData) == null ? void 0 : l.endTime) : i.endTime = q($(a)), z.value = !1, Y.value = !1;
388
+ }, we = (a) => {
389
+ const l = e.value[a];
390
+ if (l)
391
+ return l;
392
+ if (e.dateFormData[a] && s(e.dateFormData[a]))
393
+ return new Date(e.dateFormData[a]);
394
+ }, oa = pe((a) => {
395
+ var l;
396
+ if (s(a)) {
397
+ let c = a;
398
+ switch (U.value = !1, (l = k.value) == null ? void 0 : l.type) {
399
+ case "weekly":
400
+ c = ke(
401
+ a,
402
+ w,
403
+ T.value.min,
404
+ T.value.max
405
+ ), i.startDate = c;
406
+ break;
407
+ case "monthly":
408
+ c = ne(
409
+ a,
410
+ w,
411
+ T.value.min,
412
+ T.value.max
413
+ ), i.startDate = c;
414
+ break;
415
+ case "quarterly":
416
+ c = Ie(
417
+ a,
418
+ w,
419
+ T.value.min,
420
+ T.value.max
421
+ ), i.startDate = c;
422
+ break;
423
+ }
424
+ const m = le(c);
425
+ n.startDate = N(m, i.startTime), n.endDate = N(
426
+ le(i.endDate),
427
+ i.endTime
428
+ ), s(i.endDate) && (n.endDate = N(
429
+ le(i.endDate),
430
+ i.endTime
431
+ ));
432
+ const R = we("endDate");
433
+ n.range = null, d(v.FORM_DATE, {
434
+ startDate: m,
435
+ endDate: R
436
+ }), d(v.INPUT, {
437
+ ...n,
438
+ range: F.value
439
+ });
440
+ } else
441
+ U.value = !0, d(v.ERROR, { ...i });
442
+ }, 300), ia = (a) => {
443
+ i.startDate = Ke(a), oa(i.startDate);
444
+ }, ua = pe((a) => {
445
+ var l;
446
+ if (s(a)) {
447
+ let c = a;
448
+ switch (z.value = !1, (l = k.value) == null ? void 0 : l.type) {
449
+ case "weekly":
450
+ c = ue(
451
+ a,
452
+ w,
453
+ T.value.min,
454
+ T.value.max
455
+ ), i.endDate = c;
456
+ break;
457
+ case "monthly":
458
+ c = b(
459
+ a,
460
+ w,
461
+ T.value.min,
462
+ T.value.max
463
+ ), i.endDate = c;
464
+ break;
465
+ case "quarterly":
466
+ c = V(
467
+ a,
468
+ w,
469
+ T.value.min,
470
+ T.value.max
471
+ ), i.endDate = c;
472
+ break;
473
+ }
474
+ const m = le(c);
475
+ n.endDate = N(m, i.endTime), s(i.startDate) && (n.startDate = N(
476
+ le(i.startDate),
477
+ i.startTime
478
+ ));
479
+ const R = we("startDate");
480
+ n.range = null, d(v.FORM_DATE, {
481
+ startDate: R,
482
+ endDate: m
483
+ }), d(v.INPUT, {
484
+ ...n,
485
+ range: F.value
486
+ });
487
+ } else
488
+ z.value = !0, d(v.ERROR, { ...i });
489
+ }, 300), da = (a) => {
490
+ i.endDate = Ke(a), ua(i.endDate);
491
+ }, Ce = (a) => {
492
+ Na(a);
493
+ }, ma = pe((a) => {
494
+ if (Z(a, e.dateFormData.startDate)) {
495
+ j.value = !1, n.startDate = N(n.startDate, a);
496
+ const l = we("endDate");
497
+ d(v.FORM_DATE, {
498
+ startDate: n.startDate,
499
+ endDate: l,
500
+ startTime: a,
501
+ endTime: i.endTime ?? e.dateFormData.endTime
502
+ }), d(v.INPUT, {
503
+ ...n,
504
+ range: F.value
505
+ });
506
+ } else
507
+ j.value = !0, d(v.ERROR, { ...i });
508
+ }), ca = pe((a) => {
509
+ Z(a, e.dateFormData.endDate) ? (Y.value = !1, n.endDate = N(n.endDate, a), d(v.FORM_DATE, {
510
+ startDate: n.startDate,
511
+ endDate: n.endDate,
512
+ startTime: i.startTime ?? e.dateFormData.startTime,
513
+ endTime: a
514
+ }), d(v.INPUT, {
515
+ ...n,
516
+ range: F.value
517
+ })) : (Y.value = !0, d(v.ERROR, { ...i }));
518
+ }), Da = (a) => {
519
+ i.startTime = Xe(a), ma(i.startTime);
520
+ }, fa = (a) => {
521
+ i.endTime = Xe(a), ca(i.endTime);
522
+ }, qe = (a) => {
523
+ tt(a);
524
+ }, fe = (a, l, c, m) => {
525
+ n.startDate = a, n.endDate = l, c && (n.granularity = c), m && (n.range = m);
526
+ }, va = (a) => {
527
+ var c;
528
+ const l = (c = e.quickSelectRanges) == null ? void 0 : c.find(({ value: m }) => m === a);
529
+ if (l) {
530
+ re();
531
+ const m = l.data, R = m.endDate || (m.isRelativeToNow ? new Date(Date.now()) : $(new Date(Date.now()))), S = m.isRelativeToNow && m.timeDifference ? new Date(R.getTime() - m.timeDifference) : m.startDate;
532
+ i.endDate = E(R), i.startDate = E(S), fe(S, R, null, a), e.granularities && (n.granularity = m.granularity || ee.value), i.startTime = q(S), i.endTime = q(R), n.startDate = S, n.endDate = R, m.isRelativeToNow && (h.value = {
533
+ ...h.value,
534
+ [a]: {
535
+ startDate: S,
536
+ endDate: R
537
+ }
538
+ }), d(v.CUSTOM_RANGE, {
539
+ ...l.data,
540
+ startDate: S,
541
+ endDate: R,
542
+ range: l.value
543
+ });
544
+ }
545
+ }, pa = {
546
+ weekly: Re,
547
+ monthly: te,
548
+ quarterly: ie
549
+ }, ya = (a) => {
550
+ const l = n.granularity;
551
+ if (n.granularity = a, l && de(l, structuredClone(Fe(n))), n.startDate && n.endDate) {
552
+ switch (a) {
553
+ case "quarterly":
554
+ case "monthly":
555
+ case "weekly": {
556
+ if (H[a]) {
557
+ fe(H[a].startDate, H[a].endDate, a);
558
+ break;
559
+ }
560
+ const { startDate: c, endDate: m } = pa[a](
561
+ n.startDate,
562
+ n.endDate,
563
+ T.value.min,
564
+ T.value.max
565
+ );
566
+ fe(c, m, a);
567
+ break;
568
+ }
569
+ case "daily":
570
+ H.daily && fe(H.daily.startDate, H.daily.endDate, a);
571
+ break;
572
+ }
573
+ i.startDate = E(n.startDate), i.endDate = E(n.endDate), d(v.INPUT, {
574
+ ...n,
575
+ range: F.value
576
+ });
577
+ }
578
+ }, ga = p(() => ({
579
+ "b-date-range-picker-calendar__form-container--no-calendars": ae.value
580
+ }));
581
+ return (a, l) => (O(), ye("div", nt, [
582
+ P("div", {
583
+ class: ge(["b-date-range-picker-calendar__form-container", ga.value]),
584
+ "data-testid": "date-range-picker-calendar-form-container"
585
+ }, [
586
+ P("div", rt, [
587
+ D(y)("title") ? je(a.$slots, "title", { key: 0 }, void 0, !0) : B("", !0),
588
+ t.quickSelectRanges ? (O(), W(ja, {
589
+ key: 1,
590
+ "aria-label": D(M)("customRange"),
591
+ items: g.value,
592
+ "model-value": F.value,
593
+ "onUpdate:modelValue": va
594
+ }, null, 8, ["aria-label", "items", "model-value"])) : B("", !0),
595
+ t.granularities ? (O(), W(D(Ya), {
596
+ key: 2,
597
+ items: I.value,
598
+ "model-value": n.granularity,
599
+ "full-width": "",
600
+ "onUpdate:modelValue": ya
601
+ }, null, 8, ["items", "model-value"])) : B("", !0),
602
+ P("div", null, [
603
+ G(D(_e), {
604
+ stronger: "",
605
+ el: "span",
606
+ class: "b-date-range-picker-calendar__label"
607
+ }, {
608
+ default: Q(() => l[0] || (l[0] = [
609
+ X(" From ")
610
+ ])),
611
+ _: 1
612
+ }),
613
+ P("div", {
614
+ class: ge(_.value)
615
+ }, [
616
+ G(D(ve), {
617
+ "aria-label": D(M)("dateFrom"),
618
+ "model-value": i.startDate,
619
+ error: U.value,
620
+ class: "b-date-range-picker-calendar__form-input",
621
+ "onUpdate:modelValue": ia,
622
+ onKeydown: Ce
623
+ }, {
624
+ description: Q(() => l[1] || (l[1] = [
625
+ X("YYYY-MM-DD")
626
+ ])),
627
+ _: 1
628
+ }, 8, ["aria-label", "model-value", "error"]),
629
+ t.allowTimeInput ? (O(), W(D(ve), {
630
+ key: 0,
631
+ "aria-label": D(M)("timeFrom"),
632
+ "model-value": i.startTime,
633
+ error: j.value,
634
+ class: "b-date-range-picker-calendar__form-input",
635
+ "onUpdate:modelValue": Da,
636
+ onKeydown: qe
637
+ }, {
638
+ description: Q(() => l[2] || (l[2] = [
639
+ X("HH:MM:SS")
640
+ ])),
641
+ _: 1
642
+ }, 8, ["aria-label", "model-value", "error"])) : B("", !0)
643
+ ], 2)
644
+ ]),
645
+ P("div", null, [
646
+ G(D(_e), {
647
+ stronger: "",
648
+ el: "span",
649
+ class: "b-date-range-picker-calendar__label"
650
+ }, {
651
+ default: Q(() => l[3] || (l[3] = [
652
+ X(" To ")
653
+ ])),
654
+ _: 1
655
+ }),
656
+ P("div", {
657
+ class: ge(_.value)
658
+ }, [
659
+ G(D(ve), {
660
+ class: "b-date-range-picker-calendar__form-input",
661
+ "aria-label": D(M)("dateTo"),
662
+ "model-value": i.endDate,
663
+ error: z.value,
664
+ "onUpdate:modelValue": da,
665
+ onKeydown: Ce
666
+ }, {
667
+ description: Q(() => l[4] || (l[4] = [
668
+ X("YYYY-MM-DD")
669
+ ])),
670
+ _: 1
671
+ }, 8, ["aria-label", "model-value", "error"]),
672
+ t.allowTimeInput ? (O(), W(D(ve), {
673
+ key: 0,
674
+ "aria-label": D(M)("timeTo"),
675
+ "model-value": i.endTime,
676
+ error: Y.value,
677
+ class: "b-date-range-picker-calendar__form-input",
678
+ "onUpdate:modelValue": fa,
679
+ onKeydown: qe
680
+ }, {
681
+ description: Q(() => l[5] || (l[5] = [
682
+ X("HH:MM:SS")
683
+ ])),
684
+ _: 1
685
+ }, 8, ["aria-label", "model-value", "error"])) : B("", !0)
686
+ ], 2)
687
+ ])
688
+ ]),
689
+ D(y)("actions") ? (O(), ye("div", st, [
690
+ je(a.$slots, "actions", {}, void 0, !0)
691
+ ])) : B("", !0)
692
+ ], 2),
693
+ ae.value ? B("", !0) : (O(), ye("div", lt, [
694
+ G(D(L), {
695
+ value: n,
696
+ "first-day-of-week": t.firstDayOfWeek,
697
+ "is-date-disabled": t.isDateDisabled,
698
+ "max-range": t.maxRange,
699
+ min: T.value.min,
700
+ max: T.value.max,
701
+ "number-of-months": t.numberOfMonths,
702
+ "show-end-date-on-open": t.showEndDateOnOpen,
703
+ granularity: k.value,
704
+ variant: t.variant,
705
+ "is-range": "",
706
+ onInput: Me,
707
+ onStartDateSelected: J,
708
+ onEndDateSelected: De
709
+ }, null, 8, ["value", "first-day-of-week", "is-date-disabled", "max-range", "min", "max", "number-of-months", "show-end-date-on-open", "granularity", "variant"])
710
+ ]))
711
+ ]));
712
+ }
713
+ }), ut = /* @__PURE__ */ ra(it, [["__scopeId", "data-v-13fe65b4"]]);
714
+ function Ze(t, o) {
715
+ const u = K(t, o == null ? void 0 : o.in);
716
+ return Math.trunc(u.getMonth() / 3) + 1;
717
+ }
718
+ function ea(t, o) {
719
+ return K(t, o == null ? void 0 : o.in).getFullYear();
720
+ }
721
+ function dt(t, o, u) {
722
+ const [r, e] = Ca(
723
+ u == null ? void 0 : u.in,
724
+ t,
725
+ o
726
+ );
727
+ return +oe(r) == +oe(e);
728
+ }
729
+ const Be = {
730
+ "en-US": {
731
+ apply: "Apply",
732
+ cancel: "Cancel",
733
+ dateRangePicker: "Date range picker {name}",
734
+ provideDateInAFormat: "Provide date in a YYYY-MM-DD format",
735
+ quarter: "Q{quarter} {year}",
736
+ selectDate: "Select a date",
737
+ selectDateRange: "Select a date range",
738
+ selectedDateIsNotAvailable: "Selected date is not available"
739
+ },
740
+ "ja-JP": {
741
+ apply: "適用",
742
+ cancel: "キャンセル",
743
+ dateRangePicker: "日付範囲ピッカー {name}",
744
+ provideDateInAFormat: "YYYY-MM-DD形式で日付を入力してください",
745
+ quarter: "{year}年第{quarter}四半期",
746
+ selectDate: "日付を選択",
747
+ selectDateRange: "日付範囲を選択",
748
+ selectedDateIsNotAvailable: "選択した日付は利用できません"
749
+ },
750
+ "pt-BR": {
751
+ apply: "Aplicar",
752
+ cancel: "Cancelar",
753
+ dateRangePicker: "Seletor de intervalo de datas {name}",
754
+ provideDateInAFormat: "Forneça a data no formato AAAA-MM-DD",
755
+ quarter: "{quarter}º trimestre de {year}",
756
+ selectDate: "Selecione uma data",
757
+ selectDateRange: "Selecione um intervalo de datas",
758
+ selectedDateIsNotAvailable: "A data selecionada não está disponível"
759
+ }
760
+ }, mt = ({
761
+ datePickerValue: t,
762
+ isDateIncorrect: o,
763
+ quickSelectRanges: u,
764
+ isMonthVariant: r,
765
+ withTimeInput: e,
766
+ placeholder: d
767
+ }) => {
768
+ const { locale: f, t: y } = Ae({ messages: Be }), M = (n) => !!n && !isNaN(n.getTime()), h = be({
769
+ startDate: null,
770
+ endDate: null,
771
+ startTime: null,
772
+ endTime: null
773
+ });
774
+ return Te(
775
+ t,
776
+ (n) => {
777
+ h.startDate = E(n == null ? void 0 : n.startDate), h.endDate = E(n == null ? void 0 : n.endDate), h.startTime = q(n == null ? void 0 : n.startDate), h.endTime = q(n == null ? void 0 : n.endDate);
778
+ },
779
+ { immediate: !0 }
780
+ ), {
781
+ // Values
782
+ dateDisplayValue: p(() => {
783
+ var F;
784
+ if (o.value)
785
+ return `${h.startDate || ""} - ${h.endDate || ""}`;
786
+ if (!t.value || !t.value.startDate && !t.value.endDate)
787
+ return (d == null ? void 0 : d.value) || y("selectDateRange");
788
+ if ((F = u.value) != null && F.length) {
789
+ const _ = u.value.find(({ value: g }) => {
790
+ var k;
791
+ return g === ((k = t.value) == null ? void 0 : k.range);
792
+ });
793
+ if (_)
794
+ return _.label;
795
+ }
796
+ if (t.value.granularity === "quarterly") {
797
+ const { startDate: _, endDate: g } = t.value, k = y("quarter", { quarter: Ze(_), year: ea(_) });
798
+ if (dt(_, g))
799
+ return k;
800
+ const I = y("quarter", { quarter: Ze(g), year: ea(g) });
801
+ return `${k} - ${I}`;
802
+ }
803
+ if (!M(t.value.startDate) || !M(t.value.endDate))
804
+ return `${h.startDate || ""} - ${h.endDate || ""}`;
805
+ let n = r != null && r.value ? { month: "long", year: "numeric" } : { month: "short", day: "2-digit", year: "numeric" };
806
+ return e.value && (n = {
807
+ ...n,
808
+ hour: "numeric",
809
+ minute: "numeric",
810
+ second: "numeric",
811
+ hour12: !1
812
+ }), Aa(f.value, n).formatRange(
813
+ t.value.startDate,
814
+ t.value.endDate
815
+ );
816
+ }),
817
+ textInputDisplayValue: h,
818
+ // Methods
819
+ formatTextInputDisplayValue: () => ""
820
+ };
821
+ }, ct = { class: "b-date-range-picker" }, Dt = { class: "b-date-range-picker__footer" }, ft = {
822
+ i18n: { messages: Be },
823
+ name: "bento-date-range-picker",
824
+ model: { prop: "modelValue" }
825
+ }, vt = /* @__PURE__ */ aa({
826
+ ...ft,
827
+ props: {
828
+ allowTimeInput: { type: Boolean },
829
+ firstDayOfWeek: { default: void 0 },
830
+ granularities: {},
831
+ isDateDisabled: { type: Function, default: void 0 },
832
+ showEndDateOnOpen: { type: Boolean, default: !1 },
833
+ quickSelectRanges: { default: void 0 },
834
+ maxRange: { default: null },
835
+ min: { default: null },
836
+ max: { default: null },
837
+ numberOfMonths: { default: void 0 },
838
+ modelValue: { default: null },
839
+ value: { default: null },
840
+ variant: { default: void 0 },
841
+ hasActions: { type: Boolean, default: !1 },
842
+ description: { default: void 0 },
843
+ disabled: { type: Boolean, default: !1 },
844
+ errorMessage: { default: null },
845
+ label: { default: void 0 },
846
+ optional: { type: Boolean, default: !1 },
847
+ placeholder: { default: null },
848
+ readonly: { type: Boolean, default: !1 },
849
+ required: { type: Boolean, default: !1 },
850
+ tooltipText: { default: null }
851
+ },
852
+ emits: ["update:model-value", "input"],
853
+ setup(t, { emit: o }) {
854
+ const u = o, r = t, { t: e } = Ae({ messages: Be }), d = se("bento-date-range-picker-container"), f = se("bento-date-range-picker-label"), y = se("bento-date-range-picker-description"), M = se("bento-date-range-picker-error"), h = se("bento-date-range-picker-date-error"), ee = p(() => r.label || e("dateRangePicker", { name: d })), { resolvedFirstDayOfWeek: ae } = xa(Se(r, "firstDayOfWeek")), n = ka({
855
+ none: 0,
856
+ one: 710,
857
+ // width of date range picker with one panes
858
+ two: 1030,
859
+ // width of date range picker with two panes
860
+ three: 1290
861
+ // width of date range picker with three panes
862
+ }), F = p(() => {
863
+ const s = n.active().value, J = {
864
+ none: 0,
865
+ one: 1,
866
+ two: 2
867
+ };
868
+ if (s in J) {
869
+ const De = J[s];
870
+ return r.numberOfMonths === void 0 ? De : Math.min(r.numberOfMonths, De);
871
+ }
872
+ return r.numberOfMonths;
873
+ }), _ = p(() => (r == null ? void 0 : r.quickSelectRanges) && r.quickSelectRanges.map((s) => {
874
+ const J = s.data.endDate ? void 0 : new Date(Date.now()).getTime() - s.data.startDate.getTime();
875
+ return {
876
+ ...s,
877
+ data: {
878
+ ...s.data,
879
+ // Adding timeDifference to calculate an up-to-date endDate on range selection
880
+ timeDifference: J
881
+ }
882
+ };
883
+ })), g = A(!1), k = A(null), I = A(!1), { isReadOnly: he } = qa(Se(r, "readonly")), { emitValue: T } = $a(u);
884
+ Te(
885
+ () => r.disabled,
886
+ () => {
887
+ r.disabled && I.value && (I.value = !1);
888
+ }
889
+ );
890
+ const ie = p(() => r.modelValue || r.value), te = p(() => r.hasActions ? !U.value && g.value : g.value), Re = p(() => ({
891
+ "b-date-range-picker__description--error": !!r.errorMessage || te.value
892
+ })), ke = p(() => r.variant === "month"), ue = p(() => r.allowTimeInput && r.variant !== "month"), { dateDisplayValue: ne, textInputDisplayValue: b } = mt({
893
+ datePickerValue: ie,
894
+ isDateIncorrect: g,
895
+ quickSelectRanges: _,
896
+ isMonthVariant: ke,
897
+ withTimeInput: ue,
898
+ placeholder: Se(r, "placeholder")
899
+ }), Ie = p(
900
+ () => `${r.description ? y : ""} ${r.errorMessage ? M : ""} ${g.value ? h : ""}`.trim() || null
901
+ ), V = () => {
902
+ I.value = !1;
903
+ }, H = () => {
904
+ I.value = !0;
905
+ }, de = A(ne.value), re = A(
906
+ // textInputDisplayValue is a reactive object
907
+ structuredClone(Fe(b))
908
+ ), w = A(r.modelValue ?? r.value), U = A(!0), z = p(
909
+ () => r.hasActions ? re.value : b
910
+ ), j = p(
911
+ () => r.hasActions ? de.value : ne.value
912
+ );
913
+ ta(() => {
914
+ if (r.hasActions || Le(
915
+ 'BentoDateRangePicker "hasActions" property',
916
+ `Set the BentoDateRangePicker "hasActions" property true which will display the "Apply" and "Cancel" buttons.
917
+ This will be the default behavior in the v2 and "hasActions" will be removed.`,
918
+ "2.0.0"
919
+ ), r.value && Le(
920
+ 'BentoDateRangePicker "value" property',
921
+ 'The use of "value" prop in "BentoDateRangePicker" is no longer supported. Use the "v-model" or "model-value" property instead.',
922
+ "2.0.0"
923
+ ), r.granularities && r.variant !== "month" && r.granularities.find(({ type: s }) => s === "quarterly"))
924
+ throw new Error('Quarterly granularity is only supported by BentoDateRangePicker with variant: "month"');
925
+ }), Te([() => r.value, () => r.modelValue], () => {
926
+ de.value = ne.value, re.value = structuredClone(Fe(b));
927
+ });
928
+ const Y = p(() => [
929
+ {
930
+ title: e("apply"),
931
+ event: () => {
932
+ T(w.value), V(), U.value = !0;
933
+ },
934
+ disabled: U.value
935
+ },
936
+ {
937
+ title: e("cancel"),
938
+ event: V
939
+ }
940
+ ]);
941
+ Te(w, (s) => {
942
+ if (r.hasActions) {
943
+ U.value = g.value;
944
+ return;
945
+ }
946
+ T(s);
947
+ });
948
+ const i = (s) => {
949
+ g.value = !1, b.startDate = E(s.startDate), b.endDate = E(s.endDate), b.startTime = q(s.startDate), b.endTime = q(s.endDate), w.value = s;
950
+ }, me = async () => {
951
+ g.value && (g.value = !1), w.value = null;
952
+ }, ce = () => {
953
+ if (!I.value) {
954
+ I.value = !0;
955
+ return;
956
+ }
957
+ g.value || (I.value = !1);
958
+ }, Z = (s) => {
959
+ g.value = !1, s.startTime && (b.startTime = s.startTime), s.endTime && (b.endTime = s.endTime);
960
+ }, N = (s) => {
961
+ g.value = !0, b.startDate = s.startDate, b.endDate = s.endDate, w.value = { startDate: null, endDate: null };
962
+ }, Me = (s) => {
963
+ s && (b.startDate = E(s.startDate), b.endDate = E(s.endDate), b.startTime = q(s.startDate), b.endTime = q(s.endDate), w.value = s);
964
+ };
965
+ return (s, J) => ba((O(), ye("div", ct, [
966
+ s.label ? (O(), W(D(Wa), {
967
+ key: 0,
968
+ id: D(f),
969
+ label: s.label,
970
+ "tooltip-text": s.tooltipText,
971
+ optional: s.optional,
972
+ required: s.required
973
+ }, null, 8, ["id", "label", "tooltip-text", "optional", "required"])) : B("", !0),
974
+ P("div", {
975
+ onKeydown: Ye(ce, ["enter"])
976
+ }, [
977
+ G(D(Sa), {
978
+ ref_key: "inputContainerRef",
979
+ ref: k,
980
+ "always-combobox-is-input": "",
981
+ ariaControls: D(d),
982
+ ariaExpanded: I.value,
983
+ "aria-labelledby": s.label ? D(f) : null,
984
+ "aria-describedby": Ie.value,
985
+ disabled: s.disabled,
986
+ "is-invalid": !!s.errorMessage || te.value,
987
+ open: I.value,
988
+ "display-value": j.value,
989
+ readonly: D(he),
990
+ onOpen: H,
991
+ onClear: me,
992
+ onClose: V
993
+ }, null, 8, ["ariaControls", "ariaExpanded", "aria-labelledby", "aria-describedby", "disabled", "is-invalid", "open", "display-value", "readonly"])
994
+ ], 32),
995
+ te.value ? (O(), W(D(Ve), {
996
+ key: 1,
997
+ id: D(h),
998
+ "error-message": D(e)("provideDateInAFormat"),
999
+ class: "b-date-range-picker__error-message"
1000
+ }, null, 8, ["id", "error-message"])) : B("", !0),
1001
+ s.errorMessage ? (O(), W(D(Ve), {
1002
+ key: 2,
1003
+ id: D(M),
1004
+ "error-message": s.errorMessage,
1005
+ class: "b-date-range-picker__error-message"
1006
+ }, null, 8, ["id", "error-message"])) : B("", !0),
1007
+ s.description ? (O(), W(D(_e), {
1008
+ key: 3,
1009
+ id: D(y),
1010
+ class: ge(["b-date-range-picker__description", Re.value]),
1011
+ el: "span"
1012
+ }, {
1013
+ default: Q(() => [
1014
+ X(ha(s.description), 1)
1015
+ ]),
1016
+ _: 1
1017
+ }, 8, ["id", "class"])) : B("", !0),
1018
+ k.value ? (O(), W(D(Ma), {
1019
+ key: 4,
1020
+ id: D(d),
1021
+ class: "b-date-range-picker__container",
1022
+ open: I.value,
1023
+ "target-element": k.value,
1024
+ "aria-label": ee.value,
1025
+ position: "bottom-start",
1026
+ "without-space": "",
1027
+ "fit-content": "",
1028
+ "trap-all": "",
1029
+ "overflow-visible": "",
1030
+ onKeydown: Ye(V, ["esc", "native"])
1031
+ }, {
1032
+ default: Q(() => [
1033
+ G(D(ut), {
1034
+ "allow-time-input": ue.value,
1035
+ "quick-select-ranges": _.value,
1036
+ value: ie.value,
1037
+ "first-day-of-week": D(ae),
1038
+ granularities: s.granularities,
1039
+ "is-date-disabled": s.isDateDisabled,
1040
+ "max-range": s.maxRange,
1041
+ min: s.min,
1042
+ max: s.max,
1043
+ "number-of-months": F.value,
1044
+ "show-end-date-on-open": s.showEndDateOnOpen,
1045
+ "date-form-data": z.value,
1046
+ variant: s.variant,
1047
+ onCustomRange: Me,
1048
+ onInput: i,
1049
+ onError: N,
1050
+ onFormDate: Z
1051
+ }, Ra({ _: 2 }, [
1052
+ s.hasActions ? {
1053
+ name: "actions",
1054
+ fn: Q(() => [
1055
+ G(D(Ia)),
1056
+ P("div", Dt, [
1057
+ G(D(wa), {
1058
+ actions: Y.value,
1059
+ layout: D(Ga).SPACE_BETWEEN
1060
+ }, null, 8, ["actions", "layout"])
1061
+ ])
1062
+ ]),
1063
+ key: "0"
1064
+ } : void 0
1065
+ ]), 1032, ["allow-time-input", "quick-select-ranges", "value", "first-day-of-week", "granularities", "is-date-disabled", "max-range", "min", "max", "number-of-months", "show-end-date-on-open", "date-form-data", "variant"])
1066
+ ]),
1067
+ _: 1
1068
+ }, 8, ["id", "open", "target-element", "aria-label"])) : B("", !0)
1069
+ ])), [
1070
+ [D(Ua), V]
1071
+ ]);
1072
+ }
1073
+ }), Yt = /* @__PURE__ */ ra(vt, [["__scopeId", "data-v-75f221c8"]]);
1074
+ export {
1075
+ Yt as B,
1076
+ ut as D,
1077
+ Xa as a,
1078
+ Ee as i
1079
+ };
1080
+ //# sourceMappingURL=date-range-picker.D0YqnZ86.js.map