@mantine-vue/dates 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.cjs +35 -6
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +35 -6
- package/esm/index.mjs.map +1 -1
- package/lib/types.d.ts +6 -4
- package/package.json +3 -3
package/esm/index.mjs
CHANGED
|
@@ -3288,7 +3288,14 @@ var DateInput_default = /* @__PURE__ */ defineComponent({
|
|
|
3288
3288
|
props: {
|
|
3289
3289
|
modelValue: {},
|
|
3290
3290
|
defaultValue: {},
|
|
3291
|
-
valueFormat: {
|
|
3291
|
+
valueFormat: {
|
|
3292
|
+
type: [String, Function],
|
|
3293
|
+
default: "MMMM D, YYYY"
|
|
3294
|
+
},
|
|
3295
|
+
withTime: {
|
|
3296
|
+
type: Boolean,
|
|
3297
|
+
default: false
|
|
3298
|
+
},
|
|
3292
3299
|
dateParser: {},
|
|
3293
3300
|
locale: {},
|
|
3294
3301
|
minDate: {},
|
|
@@ -3326,14 +3333,22 @@ var DateInput_default = /* @__PURE__ */ defineComponent({
|
|
|
3326
3333
|
emit("change", next);
|
|
3327
3334
|
}
|
|
3328
3335
|
});
|
|
3329
|
-
const format = (next) => next ? dayjs(next).locale(props.locale || "en").format(props.valueFormat) : "";
|
|
3336
|
+
const format = (next) => next ? typeof props.valueFormat === "function" ? props.valueFormat(toDateString(next)) : dayjs(next).locale(props.locale || "en").format(props.valueFormat) : "";
|
|
3330
3337
|
const inputValue = ref(format(value.value));
|
|
3331
3338
|
const opened = ref(false);
|
|
3332
3339
|
watch(value, (next) => {
|
|
3333
3340
|
if (!opened.value) inputValue.value = format(next);
|
|
3334
3341
|
});
|
|
3335
3342
|
function parse(raw) {
|
|
3336
|
-
|
|
3343
|
+
let parsed;
|
|
3344
|
+
if (props.dateParser) parsed = props.dateParser(raw);
|
|
3345
|
+
else if (typeof props.valueFormat === "function") {
|
|
3346
|
+
const value = dayjs(raw);
|
|
3347
|
+
parsed = value.isValid() ? value.format(props.withTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD") : null;
|
|
3348
|
+
} else {
|
|
3349
|
+
const value = dayjs(raw, props.valueFormat, props.locale || "en", true);
|
|
3350
|
+
parsed = value.isValid() ? value.format(props.withTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD") : dateStringParser(raw, props.valueFormat, props.locale);
|
|
3351
|
+
}
|
|
3337
3352
|
return parsed && isDateValid({
|
|
3338
3353
|
date: parsed,
|
|
3339
3354
|
minDate: props.minDate,
|
|
@@ -3606,15 +3621,23 @@ var SpinInput_default = /* @__PURE__ */ defineComponent({
|
|
|
3606
3621
|
const props = __props;
|
|
3607
3622
|
const emit = __emit;
|
|
3608
3623
|
const attrs = useAttrs();
|
|
3624
|
+
const inputRef = ref(null);
|
|
3625
|
+
let emittedValue;
|
|
3609
3626
|
const [value, setValue] = useUncontrolled({
|
|
3610
3627
|
value: computed(() => props.modelValue),
|
|
3611
3628
|
defaultValue: props.defaultValue,
|
|
3612
3629
|
finalValue: null,
|
|
3613
3630
|
onChange: (next) => {
|
|
3631
|
+
emittedValue = next;
|
|
3614
3632
|
emit("update:modelValue", next);
|
|
3615
3633
|
emit("change", next);
|
|
3616
3634
|
}
|
|
3617
3635
|
});
|
|
3636
|
+
watch(() => props.modelValue, (next) => {
|
|
3637
|
+
const externalChange = next !== emittedValue;
|
|
3638
|
+
emittedValue = void 0;
|
|
3639
|
+
if (externalChange && document.activeElement === inputRef.value) inputRef.value?.select();
|
|
3640
|
+
}, { flush: "post" });
|
|
3618
3641
|
const finiteMax = () => Number.isFinite(props.max);
|
|
3619
3642
|
const maxDigit = () => finiteMax() ? Number(props.max.toFixed(0)[0]) : Infinity;
|
|
3620
3643
|
const arrowsMax = () => props.max + 1 - props.step;
|
|
@@ -3683,7 +3706,10 @@ var SpinInput_default = /* @__PURE__ */ defineComponent({
|
|
|
3683
3706
|
event.target.select();
|
|
3684
3707
|
}
|
|
3685
3708
|
return (_ctx, _cache) => {
|
|
3686
|
-
return openBlock(), createElementBlock("input", mergeProps(
|
|
3709
|
+
return openBlock(), createElementBlock("input", mergeProps({
|
|
3710
|
+
ref_key: "inputRef",
|
|
3711
|
+
ref: inputRef
|
|
3712
|
+
}, unref(attrs), {
|
|
3687
3713
|
type: "text",
|
|
3688
3714
|
role: "spinbutton",
|
|
3689
3715
|
"aria-valuemin": props.min,
|
|
@@ -4441,7 +4467,10 @@ var MiniCalendar_default = /* @__PURE__ */ defineComponent({
|
|
|
4441
4467
|
maxDate: {},
|
|
4442
4468
|
minDate: {},
|
|
4443
4469
|
numberOfDays: { default: 7 },
|
|
4444
|
-
monthLabelFormat: {
|
|
4470
|
+
monthLabelFormat: {
|
|
4471
|
+
type: [String, Function],
|
|
4472
|
+
default: "MMM"
|
|
4473
|
+
},
|
|
4445
4474
|
getDayProps: {},
|
|
4446
4475
|
size: { default: "sm" },
|
|
4447
4476
|
previousControlProps: {},
|
|
@@ -4530,7 +4559,7 @@ var MiniCalendar_default = /* @__PURE__ */ defineComponent({
|
|
|
4530
4559
|
"data-selected": unref(value) && item.isSame(unref(value), "day") || void 0,
|
|
4531
4560
|
onClick: ($event) => select(item, $event)
|
|
4532
4561
|
}), {
|
|
4533
|
-
default: withCtx(() => [createElementVNode("span", { class: normalizeClass(unref(Dates_module_default).miniCalendarDayMonth) }, toDisplayString(item.locale(props.locale || unref(context).locale).format(props.monthLabelFormat)), 3), createElementVNode("span", { class: normalizeClass(unref(Dates_module_default).miniCalendarDayNumber) }, toDisplayString(item.date()), 3)]),
|
|
4562
|
+
default: withCtx(() => [createElementVNode("span", { class: normalizeClass(unref(Dates_module_default).miniCalendarDayMonth) }, toDisplayString(typeof props.monthLabelFormat === "function" ? props.monthLabelFormat(item.format("YYYY-MM-DD")) : item.locale(props.locale || unref(context).locale).format(props.monthLabelFormat)), 3), createElementVNode("span", { class: normalizeClass(unref(Dates_module_default).miniCalendarDayNumber) }, toDisplayString(item.date()), 3)]),
|
|
4534
4563
|
_: 2
|
|
4535
4564
|
}, 1040, [
|
|
4536
4565
|
"class",
|