@archpublicwebsite/rangepicker 1.2.12 → 1.2.14
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 +76 -107
- package/dist/Rangepicker.vue.d.ts.map +1 -1
- package/dist/RangepickerConstraints.stories.d.ts +2 -2
- package/dist/RangepickerConstraints.stories.d.ts.map +1 -1
- package/dist/RangepickerConstraints.stories.js +25 -25
- package/dist/RangepickerFormatting.stories.d.ts +2 -2
- package/dist/RangepickerFormatting.stories.d.ts.map +1 -1
- package/dist/RangepickerFormatting.stories.js +36 -36
- package/dist/RangepickerInput.stories.d.ts +2 -2
- package/dist/RangepickerInput.stories.d.ts.map +1 -1
- package/dist/RangepickerInput.stories.js +48 -48
- package/dist/RangepickerInput.vue.d.ts +0 -1
- package/dist/RangepickerInput.vue.d.ts.map +1 -1
- package/dist/RangepickerModes.stories.d.ts +2 -2
- package/dist/RangepickerModes.stories.d.ts.map +1 -1
- package/dist/RangepickerModes.stories.js +50 -50
- package/dist/RangepickerSpecialDates.stories.d.ts +2 -2
- package/dist/RangepickerSpecialDates.stories.d.ts.map +1 -1
- package/dist/RangepickerSpecialDates.stories.js +29 -33
- package/dist/RangepickerTheming.stories.d.ts +2 -2
- package/dist/RangepickerTheming.stories.d.ts.map +1 -1
- package/dist/RangepickerTheming.stories.js +49 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/rangepicker.js +93 -116
- package/dist/rangepicker.js.map +1 -1
- package/dist/rangepicker.umd.cjs +1 -1
- package/dist/rangepicker.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +46 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/calendar.d.ts.map +1 -1
- package/dist/utils/calendar.js +5 -9
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/position.d.ts.map +1 -1
- package/package.json +6 -5
package/dist/rangepicker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, computed, ref, watch, onMounted, onUnmounted, createBlock, openBlock, Teleport, createVNode, Transition, withCtx, createElementBlock, createCommentVNode, createElementVNode, normalizeStyle, normalizeClass, toDisplayString, Fragment, renderList, nextTick, mergeProps, withModifiers } from "vue";
|
|
1
|
+
import { defineComponent, computed, ref, watch, onMounted, onUnmounted, createBlock, openBlock, Teleport, createVNode, Transition, withCtx, createElementBlock, createCommentVNode, createElementVNode, normalizeStyle, normalizeClass, unref, toDisplayString, Fragment, renderList, nextTick, mergeProps, withModifiers } from "vue";
|
|
2
2
|
import { useBreakpoints, breakpointsTailwind, useWindowSize, onClickOutside } from "@vueuse/core";
|
|
3
3
|
import dayjs from "dayjs";
|
|
4
4
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
@@ -246,13 +246,7 @@ function generateCalendarMonths(numberOfMonths, startOffset = 0, options = {}) {
|
|
|
246
246
|
for (let i = 0; i < numberOfMonths; i++) {
|
|
247
247
|
const { month, days } = getMonthDays(startOffset + i);
|
|
248
248
|
const calendarDays = days.map(
|
|
249
|
-
(day) => createCalendarDay(
|
|
250
|
-
day.date,
|
|
251
|
-
day.isPrevMonth,
|
|
252
|
-
day.isCurrentMonth,
|
|
253
|
-
day.isNextMonth,
|
|
254
|
-
options
|
|
255
|
-
)
|
|
249
|
+
(day) => createCalendarDay(day.date, day.isPrevMonth, day.isCurrentMonth, day.isNextMonth, options)
|
|
256
250
|
);
|
|
257
251
|
months.push({
|
|
258
252
|
month,
|
|
@@ -271,8 +265,7 @@ function getWeekDays(locale = "en", format = "short") {
|
|
|
271
265
|
return days;
|
|
272
266
|
}
|
|
273
267
|
function calculatePosition(triggerElement, calendarElement, preferredPosition = "auto") {
|
|
274
|
-
if (!triggerElement || !calendarElement)
|
|
275
|
-
return { left: 0 };
|
|
268
|
+
if (!triggerElement || !calendarElement) return { left: 0 };
|
|
276
269
|
const triggerRect = triggerElement.getBoundingClientRect();
|
|
277
270
|
const calendarRect = calendarElement.getBoundingClientRect();
|
|
278
271
|
const viewportHeight = window.innerHeight;
|
|
@@ -291,49 +284,48 @@ function calculatePosition(triggerElement, calendarElement, preferredPosition =
|
|
|
291
284
|
} else {
|
|
292
285
|
position.top = triggerRect.bottom + 8;
|
|
293
286
|
}
|
|
294
|
-
if (position.left + calendarRect.width > viewportWidth)
|
|
295
|
-
|
|
296
|
-
if (position.left < 16)
|
|
297
|
-
position.left = 16;
|
|
287
|
+
if (position.left + calendarRect.width > viewportWidth) position.left = viewportWidth - calendarRect.width - 16;
|
|
288
|
+
if (position.left < 16) position.left = 16;
|
|
298
289
|
return position;
|
|
299
290
|
}
|
|
300
291
|
const _hoisted_1$1 = {
|
|
301
292
|
key: 0,
|
|
302
293
|
class: "rangepicker-overlay"
|
|
303
294
|
};
|
|
304
|
-
const _hoisted_2$1 =
|
|
305
|
-
const _hoisted_3 = { class: "
|
|
306
|
-
const _hoisted_4 = {
|
|
295
|
+
const _hoisted_2$1 = ["data-version"];
|
|
296
|
+
const _hoisted_3 = { class: "rangepicker-header" };
|
|
297
|
+
const _hoisted_4 = { class: "arch-flex arch-items-center arch-justify-between" };
|
|
298
|
+
const _hoisted_5 = {
|
|
307
299
|
key: 0,
|
|
308
|
-
class: "arch-text-xs arch-font-medium arch-text-gray-500
|
|
300
|
+
class: "arch-mb-1 arch-text-xs arch-font-medium arch-text-gray-500"
|
|
309
301
|
};
|
|
310
|
-
const
|
|
311
|
-
const
|
|
302
|
+
const _hoisted_6 = { class: "arch-text-sm arch-font-semibold arch-text-gray-900" };
|
|
303
|
+
const _hoisted_7 = {
|
|
312
304
|
key: 0,
|
|
313
|
-
class: "arch-text-xs arch-text-gray-500
|
|
305
|
+
class: "arch-mt-1 arch-text-xs arch-text-gray-500"
|
|
314
306
|
};
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
const
|
|
318
|
-
const
|
|
319
|
-
const
|
|
307
|
+
const _hoisted_8 = { class: "rangepicker-body" };
|
|
308
|
+
const _hoisted_9 = { class: "rangepicker-month-grid" };
|
|
309
|
+
const _hoisted_10 = { class: "rangepicker-month-header" };
|
|
310
|
+
const _hoisted_11 = ["disabled"];
|
|
311
|
+
const _hoisted_12 = {
|
|
320
312
|
key: 1,
|
|
321
313
|
class: "arch-w-8"
|
|
322
314
|
};
|
|
323
|
-
const
|
|
324
|
-
const
|
|
325
|
-
const
|
|
315
|
+
const _hoisted_13 = { class: "rangepicker-month-title" };
|
|
316
|
+
const _hoisted_14 = ["disabled"];
|
|
317
|
+
const _hoisted_15 = {
|
|
326
318
|
key: 3,
|
|
327
319
|
class: "arch-w-8"
|
|
328
320
|
};
|
|
329
|
-
const
|
|
330
|
-
const
|
|
331
|
-
const
|
|
321
|
+
const _hoisted_16 = { class: "rangepicker-weekdays" };
|
|
322
|
+
const _hoisted_17 = ["disabled", "aria-label", "onClick", "onMouseenter"];
|
|
323
|
+
const _hoisted_18 = {
|
|
332
324
|
key: 0,
|
|
333
325
|
class: "arch-mt-4 arch-flex arch-items-center arch-justify-end arch-gap-2 arch-border-t arch-border-gray-200 arch-pt-4"
|
|
334
326
|
};
|
|
335
|
-
const
|
|
336
|
-
const
|
|
327
|
+
const _hoisted_19 = ["disabled"];
|
|
328
|
+
const _hoisted_20 = { class: "arch-flex arch-items-center arch-gap-1" };
|
|
337
329
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
338
330
|
__name: "Rangepicker",
|
|
339
331
|
props: {
|
|
@@ -366,12 +358,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
366
358
|
const emit = __emit;
|
|
367
359
|
const breakpoints = useBreakpoints(breakpointsTailwind);
|
|
368
360
|
const isMobile = breakpoints.smallerOrEqual("lg");
|
|
369
|
-
const numberOfMonths = computed(
|
|
370
|
-
|
|
371
|
-
);
|
|
372
|
-
computed(
|
|
373
|
-
() => isMobile.value ? 1 : props.valueOfColumns
|
|
374
|
-
);
|
|
361
|
+
const numberOfMonths = computed(() => isMobile.value ? 1 : props.valueOfMonths);
|
|
362
|
+
computed(() => isMobile.value ? 1 : props.valueOfColumns);
|
|
375
363
|
const calendarRef = ref(null);
|
|
376
364
|
const isFadingOut = ref(false);
|
|
377
365
|
const hoveredDay = ref(null);
|
|
@@ -379,28 +367,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
379
367
|
const localIsOpen = ref(props.isOpen);
|
|
380
368
|
const localStartDate = ref(null);
|
|
381
369
|
const localEndDate = ref(null);
|
|
382
|
-
const parsedMinDate = computed(
|
|
383
|
-
|
|
384
|
-
)
|
|
385
|
-
|
|
386
|
-
(
|
|
387
|
-
);
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
);
|
|
394
|
-
const parsedHolidays = computed(
|
|
395
|
-
() => {
|
|
396
|
-
var _a;
|
|
397
|
-
return ((_a = props.holidays) == null ? void 0 : _a.map((h) => dayjs(h))) || [];
|
|
398
|
-
}
|
|
399
|
-
);
|
|
370
|
+
const parsedMinDate = computed(() => props.minDate ? dayjs(props.minDate) : null);
|
|
371
|
+
const parsedMaxDate = computed(() => props.maxDate ? dayjs(props.maxDate) : null);
|
|
372
|
+
const parsedDisabledDates = computed(() => {
|
|
373
|
+
var _a;
|
|
374
|
+
return ((_a = props.disabledDates) == null ? void 0 : _a.map((d) => dayjs(d))) || [];
|
|
375
|
+
});
|
|
376
|
+
const parsedHolidays = computed(() => {
|
|
377
|
+
var _a;
|
|
378
|
+
return ((_a = props.holidays) == null ? void 0 : _a.map((h) => dayjs(h))) || [];
|
|
379
|
+
});
|
|
400
380
|
const weekdays = computed(() => getWeekDays("en", "narrow"));
|
|
401
|
-
const effectiveNumberOfMonths = computed(
|
|
402
|
-
() => props.variant === "mobile" ? 1 : numberOfMonths.value
|
|
403
|
-
);
|
|
381
|
+
const effectiveNumberOfMonths = computed(() => props.variant === "mobile" ? 1 : numberOfMonths.value);
|
|
404
382
|
const calendarMonths = computed(
|
|
405
383
|
() => generateCalendarMonths(effectiveNumberOfMonths.value, monthOffset.value, {
|
|
406
384
|
startDate: localStartDate.value,
|
|
@@ -417,8 +395,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
417
395
|
});
|
|
418
396
|
const formattedDateRange = computed(() => {
|
|
419
397
|
if (!localStartDate.value && !localEndDate.value) return "";
|
|
420
|
-
else if (localStartDate.value && !localEndDate.value)
|
|
421
|
-
return localStartDate.value.format(props.format);
|
|
398
|
+
else if (localStartDate.value && !localEndDate.value) return localStartDate.value.format(props.format);
|
|
422
399
|
else if (localStartDate.value && localEndDate.value)
|
|
423
400
|
return `${localStartDate.value.format(props.format)}${props.delimiter}${localEndDate.value.format(props.format)}`;
|
|
424
401
|
else return "";
|
|
@@ -443,13 +420,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
443
420
|
return;
|
|
444
421
|
}
|
|
445
422
|
nextTick(() => {
|
|
446
|
-
const position = calculatePosition(
|
|
447
|
-
props.triggerElement,
|
|
448
|
-
calendarRef.value,
|
|
449
|
-
props.position
|
|
450
|
-
);
|
|
423
|
+
const position = calculatePosition(props.triggerElement, calendarRef.value, props.position);
|
|
451
424
|
calendarStyle.value = {
|
|
452
|
-
left: `${position.left}px`,
|
|
425
|
+
"left": `${position.left}px`,
|
|
453
426
|
...position.top !== void 0 && { top: `${position.top}px` },
|
|
454
427
|
...position.bottom !== void 0 && { bottom: `${position.bottom}px` },
|
|
455
428
|
...position.transform && { transform: position.transform },
|
|
@@ -458,6 +431,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
458
431
|
});
|
|
459
432
|
}
|
|
460
433
|
const tooltipStyle = ref({});
|
|
434
|
+
const packageVersion = "1.2.14";
|
|
461
435
|
const tooltipText = computed(() => {
|
|
462
436
|
if (!hoveredDay.value || !localStartDate.value) return "";
|
|
463
437
|
const nights = hoveredDay.value.date.diff(localStartDate.value, "day");
|
|
@@ -475,13 +449,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
475
449
|
if (day.isWeekend && !day.isSelected) classes.push("rangepicker-day-weekend");
|
|
476
450
|
if (day.isHoliday) classes.push("rangepicker-day-holiday");
|
|
477
451
|
if (day.isSelected) {
|
|
478
|
-
if (localStartDate.value && localEndDate.value && day.date.isSame(localStartDate.value, "day") && day.date.isSame(localEndDate.value, "day"))
|
|
452
|
+
if (localStartDate.value && localEndDate.value && day.date.isSame(localStartDate.value, "day") && day.date.isSame(localEndDate.value, "day")) {
|
|
479
453
|
classes.push("rangepicker-day-selected-single");
|
|
480
|
-
else if (localStartDate.value && day.date.isSame(localStartDate.value, "day"))
|
|
454
|
+
} else if (localStartDate.value && day.date.isSame(localStartDate.value, "day")) {
|
|
481
455
|
classes.push("rangepicker-day-selected-start");
|
|
482
|
-
else if (localEndDate.value && day.date.isSame(localEndDate.value, "day"))
|
|
456
|
+
} else if (localEndDate.value && day.date.isSame(localEndDate.value, "day")) {
|
|
483
457
|
classes.push("rangepicker-day-selected-end");
|
|
484
|
-
else
|
|
458
|
+
} else {
|
|
459
|
+
classes.push("rangepicker-day-selected");
|
|
460
|
+
}
|
|
485
461
|
}
|
|
486
462
|
if (day.isInRange) classes.push("rangepicker-day-in-range");
|
|
487
463
|
if (localStartDate.value && !localEndDate.value && hoveredDay.value) {
|
|
@@ -543,8 +519,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
543
519
|
}
|
|
544
520
|
function handleDayHover(day, event) {
|
|
545
521
|
hoveredDay.value = day;
|
|
546
|
-
if (props.showTooltip && localStartDate.value && !localEndDate.value)
|
|
547
|
-
updateTooltipPosition(event);
|
|
522
|
+
if (props.showTooltip && localStartDate.value && !localEndDate.value) updateTooltipPosition(event);
|
|
548
523
|
}
|
|
549
524
|
function updateTooltipPosition(event) {
|
|
550
525
|
const rect = event.target.getBoundingClientRect();
|
|
@@ -583,11 +558,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
583
558
|
}
|
|
584
559
|
function cancel() {
|
|
585
560
|
var _a, _b;
|
|
586
|
-
if ((_a = props.modelValue) == null ? void 0 : _a.startDate)
|
|
587
|
-
localStartDate.value = dayjs(props.modelValue.startDate);
|
|
561
|
+
if ((_a = props.modelValue) == null ? void 0 : _a.startDate) localStartDate.value = dayjs(props.modelValue.startDate);
|
|
588
562
|
else localStartDate.value = null;
|
|
589
|
-
if ((_b = props.modelValue) == null ? void 0 : _b.endDate)
|
|
590
|
-
localEndDate.value = dayjs(props.modelValue.endDate);
|
|
563
|
+
if ((_b = props.modelValue) == null ? void 0 : _b.endDate) localEndDate.value = dayjs(props.modelValue.endDate);
|
|
591
564
|
else localEndDate.value = null;
|
|
592
565
|
close();
|
|
593
566
|
}
|
|
@@ -647,26 +620,27 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
647
620
|
createElementVNode("div", {
|
|
648
621
|
ref_key: "calendarRef",
|
|
649
622
|
ref: calendarRef,
|
|
623
|
+
"data-version": unref(packageVersion),
|
|
650
624
|
class: normalizeClass(["rangepicker-container", [__props.variant === "mobile" ? "rangepicker-mobile" : ""]]),
|
|
651
625
|
style: normalizeStyle({ ...calendarStyle.value, ...__props.colorStyles, borderRadius: props.borderRadius })
|
|
652
626
|
}, [
|
|
653
|
-
createElementVNode("div",
|
|
654
|
-
createElementVNode("div",
|
|
627
|
+
createElementVNode("div", _hoisted_3, [
|
|
628
|
+
createElementVNode("div", _hoisted_4, [
|
|
655
629
|
createElementVNode("div", null, [
|
|
656
|
-
__props.label ? (openBlock(), createElementBlock("p",
|
|
657
|
-
createElementVNode("p",
|
|
630
|
+
__props.label ? (openBlock(), createElementBlock("p", _hoisted_5, toDisplayString(__props.label), 1)) : createCommentVNode("", true),
|
|
631
|
+
createElementVNode("p", _hoisted_6, toDisplayString(formattedDateRange.value || __props.placeholder || "Select dates"), 1)
|
|
658
632
|
]),
|
|
659
|
-
nightCount.value > 0 ? (openBlock(), createElementBlock("p",
|
|
633
|
+
nightCount.value > 0 ? (openBlock(), createElementBlock("p", _hoisted_7, toDisplayString(nightCount.value) + " " + toDisplayString(nightCount.value === 1 ? "night" : "nights"), 1)) : createCommentVNode("", true)
|
|
660
634
|
])
|
|
661
635
|
]),
|
|
662
|
-
createElementVNode("div",
|
|
663
|
-
createElementVNode("div",
|
|
636
|
+
createElementVNode("div", _hoisted_8, [
|
|
637
|
+
createElementVNode("div", _hoisted_9, [
|
|
664
638
|
(openBlock(true), createElementBlock(Fragment, null, renderList(calendarMonths.value, (monthData, index) => {
|
|
665
639
|
return openBlock(), createElementBlock("div", {
|
|
666
640
|
key: monthData.month.format("YYYY-MM"),
|
|
667
641
|
class: "rangepicker-month"
|
|
668
642
|
}, [
|
|
669
|
-
createElementVNode("div",
|
|
643
|
+
createElementVNode("div", _hoisted_10, [
|
|
670
644
|
__props.variant === "mobile" || index === 0 ? (openBlock(), createElementBlock("button", {
|
|
671
645
|
key: 0,
|
|
672
646
|
class: "rangepicker-nav-button",
|
|
@@ -686,8 +660,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
686
660
|
"clip-rule": "evenodd"
|
|
687
661
|
})
|
|
688
662
|
], -1)
|
|
689
|
-
])], 8,
|
|
690
|
-
createElementVNode("span",
|
|
663
|
+
])], 8, _hoisted_11)) : (openBlock(), createElementBlock("div", _hoisted_12)),
|
|
664
|
+
createElementVNode("span", _hoisted_13, toDisplayString(monthData.month.format("MMMM YYYY")), 1),
|
|
691
665
|
__props.variant === "mobile" || index === calendarMonths.value.length - 1 ? (openBlock(), createElementBlock("button", {
|
|
692
666
|
key: 2,
|
|
693
667
|
class: "rangepicker-nav-button",
|
|
@@ -707,9 +681,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
707
681
|
"clip-rule": "evenodd"
|
|
708
682
|
})
|
|
709
683
|
], -1)
|
|
710
|
-
])], 8,
|
|
684
|
+
])], 8, _hoisted_14)) : (openBlock(), createElementBlock("div", _hoisted_15))
|
|
711
685
|
]),
|
|
712
|
-
createElementVNode("div",
|
|
686
|
+
createElementVNode("div", _hoisted_16, [
|
|
713
687
|
(openBlock(true), createElementBlock(Fragment, null, renderList(weekdays.value, (weekday) => {
|
|
714
688
|
return openBlock(), createElementBlock("div", {
|
|
715
689
|
key: weekday,
|
|
@@ -731,25 +705,25 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
731
705
|
onMouseenter: (e) => handleDayHover(day, e)
|
|
732
706
|
}, [
|
|
733
707
|
createElementVNode("span", null, toDisplayString(day.date.date()), 1)
|
|
734
|
-
], 42,
|
|
708
|
+
], 42, _hoisted_17);
|
|
735
709
|
}), 128))
|
|
736
710
|
], 32)
|
|
737
711
|
]);
|
|
738
712
|
}), 128))
|
|
739
713
|
]),
|
|
740
|
-
!__props.autoApply ? (openBlock(), createElementBlock("div",
|
|
714
|
+
!__props.autoApply ? (openBlock(), createElementBlock("div", _hoisted_18, [
|
|
741
715
|
createElementVNode("button", {
|
|
742
|
-
class: "arch-px-4 arch-py-2 arch-text-sm arch-font-medium arch-text-gray-700 hover:arch-bg-gray-100
|
|
716
|
+
class: "arch-rounded-lg arch-px-4 arch-py-2 arch-text-sm arch-font-medium arch-text-gray-700 arch-transition-colors hover:arch-bg-gray-100",
|
|
743
717
|
onClick: cancel
|
|
744
718
|
}, " Cancel "),
|
|
745
719
|
createElementVNode("button", {
|
|
746
|
-
class: "arch-px-4 arch-py-2 arch-text-sm arch-font-medium arch-text-white arch-
|
|
720
|
+
class: "arch-rounded-lg arch-px-4 arch-py-2 arch-text-sm arch-font-medium arch-text-white arch-transition-colors disabled:arch-cursor-not-allowed disabled:arch-opacity-50",
|
|
747
721
|
style: normalizeStyle({
|
|
748
722
|
backgroundColor: ((_a = __props.colorStyles) == null ? void 0 : _a["--color-primary"]) ? `rgb(${__props.colorStyles["--color-primary"]})` : "rgb(37 99 235)"
|
|
749
723
|
}),
|
|
750
724
|
disabled: !localStartDate.value || !localEndDate.value,
|
|
751
725
|
onClick: apply
|
|
752
|
-
}, " Apply ", 12,
|
|
726
|
+
}, " Apply ", 12, _hoisted_19)
|
|
753
727
|
])) : createCommentVNode("", true)
|
|
754
728
|
]),
|
|
755
729
|
showTooltipComputed.value ? (openBlock(), createElementBlock("div", {
|
|
@@ -757,9 +731,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
757
731
|
class: "rangepicker-tooltip",
|
|
758
732
|
style: normalizeStyle(tooltipStyle.value)
|
|
759
733
|
}, [
|
|
760
|
-
createElementVNode("div",
|
|
734
|
+
createElementVNode("div", _hoisted_20, toDisplayString(tooltipText.value), 1)
|
|
761
735
|
], 4)) : createCommentVNode("", true)
|
|
762
|
-
],
|
|
736
|
+
], 14, _hoisted_2$1)
|
|
763
737
|
])) : createCommentVNode("", true)
|
|
764
738
|
];
|
|
765
739
|
}),
|
|
@@ -776,7 +750,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
776
750
|
}
|
|
777
751
|
return target;
|
|
778
752
|
};
|
|
779
|
-
const Rangepicker = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
753
|
+
const Rangepicker = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-08df566e"]]);
|
|
780
754
|
const _hoisted_1 = { class: "rangepicker-input-container" };
|
|
781
755
|
const _hoisted_2 = ["id", "value", "placeholder", "readonly", "name"];
|
|
782
756
|
const inputClass = "rangepicker-input block w-full h-full bg-transparent border-0 shadow-none outline-none cursor-pointer font-inherit text-inherit p-0";
|
|
@@ -825,10 +799,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
825
799
|
console.warn(`[Rangepicker] Invalid hex color: ${hex}`);
|
|
826
800
|
return null;
|
|
827
801
|
}
|
|
828
|
-
const r = parseInt(hex.substring(0, 2), 16);
|
|
829
|
-
const g = parseInt(hex.substring(2, 4), 16);
|
|
830
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
|
831
|
-
if (isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
802
|
+
const r = Number.parseInt(hex.substring(0, 2), 16);
|
|
803
|
+
const g = Number.parseInt(hex.substring(2, 4), 16);
|
|
804
|
+
const b = Number.parseInt(hex.substring(4, 6), 16);
|
|
805
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
832
806
|
return null;
|
|
833
807
|
}
|
|
834
808
|
return `${r} ${g} ${b}`;
|
|
@@ -838,8 +812,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
838
812
|
const inputRef = ref(null);
|
|
839
813
|
const isOpen = ref(false);
|
|
840
814
|
function parseValue(value) {
|
|
841
|
-
if (!value)
|
|
842
|
-
return { startDate: "", endDate: "" };
|
|
815
|
+
if (!value) return { startDate: "", endDate: "" };
|
|
843
816
|
const parts = value.split(" - ");
|
|
844
817
|
if (parts.length === 2) {
|
|
845
818
|
return {
|
|
@@ -849,10 +822,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
849
822
|
}
|
|
850
823
|
return { startDate: "", endDate: "" };
|
|
851
824
|
}
|
|
852
|
-
watch(
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
825
|
+
watch(
|
|
826
|
+
() => props == null ? void 0 : props.close,
|
|
827
|
+
(cur) => {
|
|
828
|
+
if (cur) inputRef.value.blur();
|
|
829
|
+
}
|
|
830
|
+
);
|
|
856
831
|
const localValue = ref(parseValue(props.modelValue));
|
|
857
832
|
const displayValue = computed(() => {
|
|
858
833
|
return props.modelValue || "";
|
|
@@ -874,9 +849,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
874
849
|
emit("update:modelValue", "");
|
|
875
850
|
isOpen.value = false;
|
|
876
851
|
}
|
|
877
|
-
watch(
|
|
878
|
-
|
|
879
|
-
|
|
852
|
+
watch(
|
|
853
|
+
() => props.modelValue,
|
|
854
|
+
(newVal) => {
|
|
855
|
+
localValue.value = parseValue(newVal);
|
|
856
|
+
}
|
|
857
|
+
);
|
|
880
858
|
const colorStyles = computed(() => {
|
|
881
859
|
const styles = {};
|
|
882
860
|
if (props.primaryColor) {
|
|
@@ -898,7 +876,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
898
876
|
});
|
|
899
877
|
return (_ctx, _cache) => {
|
|
900
878
|
return openBlock(), createElementBlock("div", mergeProps(_ctx.$attrs, {
|
|
901
|
-
ref: "wrapperRef",
|
|
902
879
|
class: "rangepicker-input-wrapper",
|
|
903
880
|
style: colorStyles.value
|
|
904
881
|
}), [
|
|
@@ -912,10 +889,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
912
889
|
placeholder: __props.placeholder,
|
|
913
890
|
readonly: __props.readonly,
|
|
914
891
|
name: __props.name,
|
|
915
|
-
class: normalizeClass(inputClass),
|
|
892
|
+
class: normalizeClass((props == null ? void 0 : props.class) ? props.class : inputClass),
|
|
916
893
|
onClick: openPicker,
|
|
917
894
|
onFocus
|
|
918
|
-
}, null,
|
|
895
|
+
}, null, 42, _hoisted_2),
|
|
919
896
|
__props.showClearButton && displayValue.value ? (openBlock(), createElementBlock("button", {
|
|
920
897
|
key: 0,
|
|
921
898
|
type: "button",
|
|
@@ -964,7 +941,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
964
941
|
};
|
|
965
942
|
}
|
|
966
943
|
});
|
|
967
|
-
const RangepickerInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
944
|
+
const RangepickerInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1132af89"]]);
|
|
968
945
|
function useRangepicker(triggerRef, options = {}) {
|
|
969
946
|
const isOpen = ref(false);
|
|
970
947
|
const dateRange = ref({ startDate: "", endDate: "" });
|