@mantine-vue/dates 2.3.1 → 3.0.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 +364 -115
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +364 -115
- package/esm/index.mjs.map +1 -1
- package/lib/index.d.mts +271 -54
- package/lib/index.d.ts +271 -54
- package/package.json +3 -3
- package/styles.css +137 -102
- package/styles.layer.css +137 -102
package/cjs/index.cjs
CHANGED
|
@@ -29,44 +29,45 @@ let vue = require("vue");
|
|
|
29
29
|
let _mantine_vue_hooks = require("@mantine-vue/hooks");
|
|
30
30
|
let _mantine_vue_core = require("@mantine-vue/core");
|
|
31
31
|
var Dates_module_default = {
|
|
32
|
-
calendar: "
|
|
33
|
-
calendarLevel: "
|
|
34
|
-
calendarHeader: "
|
|
35
|
-
calendarHeaderLevel: "
|
|
36
|
-
calendarHeaderControl: "
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
32
|
+
calendar: "_calendar_zystn_1",
|
|
33
|
+
calendarLevel: "_calendarLevel_zystn_15",
|
|
34
|
+
calendarHeader: "_calendarHeader_zystn_19",
|
|
35
|
+
calendarHeaderLevel: "_calendarHeaderLevel_zystn_32",
|
|
36
|
+
calendarHeaderControl: "_calendarHeaderControl_zystn_33",
|
|
37
|
+
calendarHeaderSelect: "_calendarHeaderSelect_zystn_79",
|
|
38
|
+
calendarHeaderControlIcon: "_calendarHeaderControlIcon_zystn_109",
|
|
39
|
+
month: "_month_zystn_122",
|
|
40
|
+
monthRow: "_monthRow_zystn_132",
|
|
41
|
+
monthCell: "_monthCell_zystn_136",
|
|
42
|
+
weekday: "_weekday_zystn_145",
|
|
43
|
+
weekNumber: "_weekNumber_zystn_157",
|
|
44
|
+
day: "_day_zystn_163",
|
|
45
|
+
pickerControl: "_pickerControl_zystn_224",
|
|
46
|
+
controlsGrid: "_controlsGrid_zystn_230",
|
|
47
|
+
timePicker: "_timePicker_zystn_290",
|
|
48
|
+
dateTimePicker: "_dateTimePicker_zystn_291",
|
|
49
|
+
datePickerRoot: "_datePickerRoot_zystn_295",
|
|
50
|
+
timeWrapper: "_timeWrapper_zystn_305",
|
|
51
|
+
timeInput: "_timeInput_zystn_311",
|
|
52
|
+
presetsList: "_presetsList_zystn_316",
|
|
53
|
+
presetButton: "_presetButton_zystn_324",
|
|
54
|
+
timePickerPresetsGroup: "_timePickerPresetsGroup_zystn_335",
|
|
55
|
+
dropdown: "_dropdown_zystn_339",
|
|
56
|
+
placeholder: "_placeholder_zystn_343",
|
|
57
|
+
timeGridControl: "_timeGridControl_zystn_347",
|
|
58
|
+
timePickerFieldsRoot: "_timePickerFieldsRoot_zystn_378",
|
|
59
|
+
timePickerFieldsGroup: "_timePickerFieldsGroup_zystn_385",
|
|
60
|
+
timePickerField: "_timePickerField_zystn_378",
|
|
61
|
+
timePickerDropdown: "_timePickerDropdown_zystn_435",
|
|
62
|
+
timePickerControlsListGroup: "_timePickerControlsListGroup_zystn_439",
|
|
63
|
+
timePickerControlsList: "_timePickerControlsList_zystn_439",
|
|
64
|
+
timePickerControl: "_timePickerControl_zystn_439",
|
|
65
|
+
miniCalendarRoot: "_miniCalendarRoot_zystn_468",
|
|
66
|
+
miniCalendarDays: "_miniCalendarDays_zystn_475",
|
|
67
|
+
miniCalendarDay: "_miniCalendarDay_zystn_475",
|
|
68
|
+
miniCalendarDayMonth: "_miniCalendarDayMonth_zystn_510",
|
|
69
|
+
miniCalendarDayNumber: "_miniCalendarDayNumber_zystn_516",
|
|
70
|
+
miniCalendarControl: "_miniCalendarControl_zystn_521"
|
|
70
71
|
};
|
|
71
72
|
//#endregion
|
|
72
73
|
//#region src/index.ts
|
|
@@ -267,6 +268,7 @@ function getDecadeLabel(date) {
|
|
|
267
268
|
var Day = (0, vue.defineComponent)({
|
|
268
269
|
name: "Day",
|
|
269
270
|
inheritAttrs: false,
|
|
271
|
+
slots: Object,
|
|
270
272
|
props: {
|
|
271
273
|
date: {
|
|
272
274
|
type: String,
|
|
@@ -301,7 +303,7 @@ var Day = (0, vue.defineComponent)({
|
|
|
301
303
|
},
|
|
302
304
|
unstyled: Boolean
|
|
303
305
|
},
|
|
304
|
-
setup(props, { attrs }) {
|
|
306
|
+
setup(props, { attrs, slots }) {
|
|
305
307
|
return () => (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
306
308
|
...attrs,
|
|
307
309
|
component: props.static ? "div" : "button",
|
|
@@ -320,7 +322,7 @@ var Day = (0, vue.defineComponent)({
|
|
|
320
322
|
"data-last-in-range": props.lastInRange && !props.disabled || void 0,
|
|
321
323
|
"data-static": props.static || void 0,
|
|
322
324
|
"data-full-width": props.fullWidth || void 0
|
|
323
|
-
}, () => props.renderDay?.(props.date) || (0, dayjs.default)(props.date).date());
|
|
325
|
+
}, () => (props.renderDay ? props.renderDay(props.date) : (slots.renderDay ?? slots.day)?.({ date: props.date })) || (0, dayjs.default)(props.date).date());
|
|
324
326
|
}
|
|
325
327
|
});
|
|
326
328
|
var PickerControl = (0, vue.defineComponent)({
|
|
@@ -384,6 +386,15 @@ var CalendarHeader = (0, vue.defineComponent)({
|
|
|
384
386
|
},
|
|
385
387
|
levelControlAriaLabel: String,
|
|
386
388
|
fullWidth: Boolean,
|
|
389
|
+
withNativeLevelSelect: Boolean,
|
|
390
|
+
yearsSelectRange: Array,
|
|
391
|
+
calendarLevel: String,
|
|
392
|
+
date: [String, Date],
|
|
393
|
+
locale: String,
|
|
394
|
+
onDateChange: Function,
|
|
395
|
+
minDate: [String, Date],
|
|
396
|
+
maxDate: [String, Date],
|
|
397
|
+
disableNativeLevelSelect: Boolean,
|
|
387
398
|
onNext: Function,
|
|
388
399
|
onPrevious: Function,
|
|
389
400
|
onLevelClick: Function
|
|
@@ -402,7 +413,40 @@ var CalendarHeader = (0, vue.defineComponent)({
|
|
|
402
413
|
"data-direction": "previous",
|
|
403
414
|
size: "45%"
|
|
404
415
|
})) : null;
|
|
405
|
-
const
|
|
416
|
+
const displayed = props.date ? (0, dayjs.default)(props.date) : (0, dayjs.default)();
|
|
417
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
418
|
+
const rawMinYear = props.yearsSelectRange?.[0] ?? (props.minDate ? (0, dayjs.default)(props.minDate).year() : currentYear - 100);
|
|
419
|
+
const rawMaxYear = props.yearsSelectRange?.[1] ?? (props.maxDate ? (0, dayjs.default)(props.maxDate).year() : currentYear + 50);
|
|
420
|
+
const minYear = Math.min(rawMinYear, rawMaxYear, displayed.year());
|
|
421
|
+
const maxYear = Math.max(rawMinYear, rawMaxYear, displayed.year());
|
|
422
|
+
const updateNativeDate = (next) => {
|
|
423
|
+
let result = next;
|
|
424
|
+
if (props.minDate && result.isBefore((0, dayjs.default)(props.minDate), "day")) result = (0, dayjs.default)(props.minDate);
|
|
425
|
+
if (props.maxDate && result.isAfter((0, dayjs.default)(props.maxDate), "day")) result = (0, dayjs.default)(props.maxDate);
|
|
426
|
+
props.onDateChange?.(result.format("YYYY-MM-DD"));
|
|
427
|
+
};
|
|
428
|
+
const levelControl = (props.withNativeLevelSelect && props.date && props.onDateChange && props.calendarLevel !== "decade" ? (0, vue.h)("div", {
|
|
429
|
+
class: Dates_module_default.calendarHeaderLevel,
|
|
430
|
+
"data-static": true,
|
|
431
|
+
"data-native-level-select": true
|
|
432
|
+
}, [props.calendarLevel === "month" ? (0, vue.h)("select", {
|
|
433
|
+
class: Dates_module_default.calendarHeaderSelect,
|
|
434
|
+
"data-select": "month",
|
|
435
|
+
disabled: props.disableNativeLevelSelect,
|
|
436
|
+
value: displayed.month(),
|
|
437
|
+
"aria-label": props.levelControlAriaLabel,
|
|
438
|
+
onChange: (event) => updateNativeDate(displayed.month(Number(event.target.value)))
|
|
439
|
+
}, Array.from({ length: 12 }, (_, month) => (0, vue.h)("option", { value: month }, (0, dayjs.default)().locale(props.locale || "en").month(month).format("MMMM")))) : null, (0, vue.h)("select", {
|
|
440
|
+
class: Dates_module_default.calendarHeaderSelect,
|
|
441
|
+
"data-select": "year",
|
|
442
|
+
disabled: props.disableNativeLevelSelect,
|
|
443
|
+
value: displayed.year(),
|
|
444
|
+
"aria-label": props.levelControlAriaLabel,
|
|
445
|
+
onChange: (event) => updateNativeDate(displayed.year(Number(event.target.value)))
|
|
446
|
+
}, Array.from({ length: maxYear - minYear + 1 }, (_, index) => {
|
|
447
|
+
const year = minYear + index;
|
|
448
|
+
return (0, vue.h)("option", { value: year }, year);
|
|
449
|
+
}))]) : null) ?? (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
406
450
|
component: props.hasNextLevel ? "button" : "div",
|
|
407
451
|
class: Dates_module_default.calendarHeaderLevel,
|
|
408
452
|
onClick: props.hasNextLevel ? props.onLevelClick : void 0,
|
|
@@ -459,6 +503,7 @@ var WeekdaysRow = (0, vue.defineComponent)({
|
|
|
459
503
|
});
|
|
460
504
|
var Month = (0, vue.defineComponent)({
|
|
461
505
|
name: "Month",
|
|
506
|
+
slots: Object,
|
|
462
507
|
props: {
|
|
463
508
|
month: {
|
|
464
509
|
type: String,
|
|
@@ -497,7 +542,7 @@ var Month = (0, vue.defineComponent)({
|
|
|
497
542
|
static: Boolean,
|
|
498
543
|
fullWidth: Boolean
|
|
499
544
|
},
|
|
500
|
-
setup(props) {
|
|
545
|
+
setup(props, { slots }) {
|
|
501
546
|
const ctx = useDatesContext();
|
|
502
547
|
const hovered = (0, vue.ref)(null);
|
|
503
548
|
const dayRefs = [];
|
|
@@ -556,7 +601,7 @@ var Month = (0, vue.defineComponent)({
|
|
|
556
601
|
lastInRange: isSameDate(date, end),
|
|
557
602
|
highlightToday: props.highlightToday,
|
|
558
603
|
fullWidth: props.fullWidth,
|
|
559
|
-
renderDay: props.renderDay,
|
|
604
|
+
renderDay: props.renderDay ?? (slots.renderDay ?? slots.day ? (date) => (slots.renderDay ?? slots.day)?.({ date }) : void 0),
|
|
560
605
|
"aria-label": props.getDayAriaLabel?.(date),
|
|
561
606
|
tabindex: props.static ? void 0 : date === dateInTabOrder ? 0 : -1,
|
|
562
607
|
"data-autofocus": selected || void 0,
|
|
@@ -743,6 +788,7 @@ function clampLevel(level, minLevel, maxLevel) {
|
|
|
743
788
|
}
|
|
744
789
|
var Calendar = (0, vue.defineComponent)({
|
|
745
790
|
name: "Calendar",
|
|
791
|
+
slots: Object,
|
|
746
792
|
props: {
|
|
747
793
|
defaultLevel: String,
|
|
748
794
|
level: String,
|
|
@@ -814,9 +860,11 @@ var Calendar = (0, vue.defineComponent)({
|
|
|
814
860
|
highlightToday: Boolean,
|
|
815
861
|
withWeekNumbers: Boolean,
|
|
816
862
|
static: Boolean,
|
|
817
|
-
fullWidth: Boolean
|
|
863
|
+
fullWidth: Boolean,
|
|
864
|
+
withNativeLevelSelect: Boolean,
|
|
865
|
+
yearsSelectRange: Array
|
|
818
866
|
},
|
|
819
|
-
setup(props, { attrs }) {
|
|
867
|
+
setup(props, { attrs, slots }) {
|
|
820
868
|
const [_level, setLevel] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
821
869
|
value: (0, vue.computed)(() => props.level === void 0 ? void 0 : clampLevel(props.level, props.minLevel, props.maxLevel)),
|
|
822
870
|
defaultValue: props.defaultLevel === void 0 ? void 0 : clampLevel(props.defaultLevel, props.minLevel, props.maxLevel),
|
|
@@ -849,6 +897,15 @@ var Calendar = (0, vue.defineComponent)({
|
|
|
849
897
|
withPrevious: column === 0,
|
|
850
898
|
withNext: column === (props.numberOfColumns || 1) - 1,
|
|
851
899
|
fullWidth: props.fullWidth,
|
|
900
|
+
withNativeLevelSelect: props.withNativeLevelSelect,
|
|
901
|
+
yearsSelectRange: props.yearsSelectRange,
|
|
902
|
+
calendarLevel: "month",
|
|
903
|
+
date: currentDate,
|
|
904
|
+
locale: props.locale,
|
|
905
|
+
onDateChange: setDate,
|
|
906
|
+
minDate: props.minDate,
|
|
907
|
+
maxDate: props.maxDate,
|
|
908
|
+
disableNativeLevelSelect: props.date !== void 0 && !props.onDateChange,
|
|
852
909
|
onPrevious: () => updateDate(-scroll, "month"),
|
|
853
910
|
onNext: () => updateDate(scroll, "month"),
|
|
854
911
|
onLevelClick: () => setLevel(getNextLevel(_level.value, "up"))
|
|
@@ -860,7 +917,7 @@ var Calendar = (0, vue.defineComponent)({
|
|
|
860
917
|
maxDate: props.maxDate,
|
|
861
918
|
firstDayOfWeek: props.firstDayOfWeek,
|
|
862
919
|
weekendDays: props.weekendDays,
|
|
863
|
-
renderDay: props.renderDay,
|
|
920
|
+
renderDay: props.renderDay ?? (slots.renderDay ?? slots.day ? (date) => (slots.renderDay ?? slots.day)?.({ date }) : void 0),
|
|
864
921
|
getDayProps: props.getDayProps,
|
|
865
922
|
getDayAriaLabel: props.getDayAriaLabel,
|
|
866
923
|
excludeDate: props.excludeDate,
|
|
@@ -879,6 +936,15 @@ var Calendar = (0, vue.defineComponent)({
|
|
|
879
936
|
withPrevious: column === 0,
|
|
880
937
|
withNext: column === (props.numberOfColumns || 1) - 1,
|
|
881
938
|
fullWidth: props.fullWidth,
|
|
939
|
+
withNativeLevelSelect: props.withNativeLevelSelect,
|
|
940
|
+
yearsSelectRange: props.yearsSelectRange,
|
|
941
|
+
calendarLevel: "year",
|
|
942
|
+
date: currentDate,
|
|
943
|
+
locale: props.locale,
|
|
944
|
+
onDateChange: setDate,
|
|
945
|
+
minDate: props.minDate,
|
|
946
|
+
maxDate: props.maxDate,
|
|
947
|
+
disableNativeLevelSelect: props.date !== void 0 && !props.onDateChange,
|
|
882
948
|
onPrevious: () => updateDate(-scroll, "year"),
|
|
883
949
|
onNext: () => updateDate(scroll, "year"),
|
|
884
950
|
onLevelClick: () => setLevel(getNextLevel(_level.value, "up"))
|
|
@@ -952,11 +1018,17 @@ function getNextPickerValue(value, date, type, sortDates = true) {
|
|
|
952
1018
|
}
|
|
953
1019
|
var DatePicker = (0, vue.defineComponent)({
|
|
954
1020
|
name: "DatePicker",
|
|
1021
|
+
slots: Object,
|
|
955
1022
|
props: {
|
|
956
1023
|
type: {
|
|
957
1024
|
type: String,
|
|
958
1025
|
default: "default"
|
|
959
1026
|
},
|
|
1027
|
+
modelValue: [
|
|
1028
|
+
String,
|
|
1029
|
+
Array,
|
|
1030
|
+
null
|
|
1031
|
+
],
|
|
960
1032
|
value: [
|
|
961
1033
|
String,
|
|
962
1034
|
Array,
|
|
@@ -976,15 +1048,21 @@ var DatePicker = (0, vue.defineComponent)({
|
|
|
976
1048
|
type: Boolean,
|
|
977
1049
|
default: true
|
|
978
1050
|
},
|
|
979
|
-
presets: Array
|
|
1051
|
+
presets: Array,
|
|
1052
|
+
withNativeLevelSelect: Boolean,
|
|
1053
|
+
yearsSelectRange: Array
|
|
980
1054
|
},
|
|
981
|
-
|
|
1055
|
+
emits: ["update:modelValue", "change"],
|
|
1056
|
+
setup(props, { attrs, slots, emit }) {
|
|
982
1057
|
const finalValue = (0, vue.computed)(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
|
|
983
1058
|
const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
984
|
-
value: (0, vue.computed)(() => props.value),
|
|
1059
|
+
value: (0, vue.computed)(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
985
1060
|
defaultValue: props.defaultValue,
|
|
986
1061
|
finalValue: finalValue.value,
|
|
987
|
-
onChange: (value) =>
|
|
1062
|
+
onChange: (value) => {
|
|
1063
|
+
emit("update:modelValue", value);
|
|
1064
|
+
emit("change", value);
|
|
1065
|
+
}
|
|
988
1066
|
});
|
|
989
1067
|
const selectDate = (date) => {
|
|
990
1068
|
if (props.type === "default" && props.allowDeselect && isSameDate(_value.value, date)) setValue(null);
|
|
@@ -1009,7 +1087,12 @@ var DatePicker = (0, vue.defineComponent)({
|
|
|
1009
1087
|
onDateChange: (date) => calendarDate.value = date,
|
|
1010
1088
|
level: calendarLevel.value,
|
|
1011
1089
|
onLevelChange: (level) => calendarLevel.value = level,
|
|
1090
|
+
withNativeLevelSelect: props.withNativeLevelSelect,
|
|
1091
|
+
yearsSelectRange: props.yearsSelectRange,
|
|
1012
1092
|
onDayClick: selectDate
|
|
1093
|
+
}, {
|
|
1094
|
+
renderDay: slots.renderDay,
|
|
1095
|
+
day: slots.day
|
|
1013
1096
|
});
|
|
1014
1097
|
if (!props.presets?.length) return calendar;
|
|
1015
1098
|
return (0, vue.h)("div", { class: Dates_module_default.datePickerRoot }, [(0, vue.h)("div", { class: Dates_module_default.presetsList }, props.presets.map((preset, index) => (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
@@ -1028,6 +1111,11 @@ var YearPicker = (0, vue.defineComponent)({
|
|
|
1028
1111
|
type: String,
|
|
1029
1112
|
default: "default"
|
|
1030
1113
|
},
|
|
1114
|
+
modelValue: [
|
|
1115
|
+
String,
|
|
1116
|
+
Array,
|
|
1117
|
+
null
|
|
1118
|
+
],
|
|
1031
1119
|
value: [
|
|
1032
1120
|
String,
|
|
1033
1121
|
Array,
|
|
@@ -1048,15 +1136,21 @@ var YearPicker = (0, vue.defineComponent)({
|
|
|
1048
1136
|
default: true
|
|
1049
1137
|
},
|
|
1050
1138
|
presets: Array,
|
|
1051
|
-
onYearSelect: Function
|
|
1139
|
+
onYearSelect: Function,
|
|
1140
|
+
withNativeLevelSelect: Boolean,
|
|
1141
|
+
yearsSelectRange: Array
|
|
1052
1142
|
},
|
|
1053
|
-
|
|
1143
|
+
emits: ["update:modelValue", "change"],
|
|
1144
|
+
setup(props, { attrs, emit }) {
|
|
1054
1145
|
const finalValue = (0, vue.computed)(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
|
|
1055
1146
|
const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
1056
|
-
value: (0, vue.computed)(() => props.value),
|
|
1147
|
+
value: (0, vue.computed)(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1057
1148
|
defaultValue: props.defaultValue,
|
|
1058
1149
|
finalValue: finalValue.value,
|
|
1059
|
-
onChange: (value) =>
|
|
1150
|
+
onChange: (value) => {
|
|
1151
|
+
emit("update:modelValue", value);
|
|
1152
|
+
emit("change", value);
|
|
1153
|
+
}
|
|
1060
1154
|
});
|
|
1061
1155
|
const hoveredDate = (0, vue.ref)(null);
|
|
1062
1156
|
const selectYear = (date) => {
|
|
@@ -1092,6 +1186,8 @@ var YearPicker = (0, vue.defineComponent)({
|
|
|
1092
1186
|
onDateChange: (date) => calendarDate.value = date,
|
|
1093
1187
|
defaultLevel: "decade",
|
|
1094
1188
|
minLevel: "decade",
|
|
1189
|
+
withNativeLevelSelect: props.withNativeLevelSelect,
|
|
1190
|
+
yearsSelectRange: props.yearsSelectRange,
|
|
1095
1191
|
onYearSelect: selectYear,
|
|
1096
1192
|
getYearControlProps: yearControlProps,
|
|
1097
1193
|
onYearMouseEnter: (date) => {
|
|
@@ -1119,6 +1215,11 @@ var MonthPicker = (0, vue.defineComponent)({
|
|
|
1119
1215
|
type: String,
|
|
1120
1216
|
default: "default"
|
|
1121
1217
|
},
|
|
1218
|
+
modelValue: [
|
|
1219
|
+
String,
|
|
1220
|
+
Array,
|
|
1221
|
+
null
|
|
1222
|
+
],
|
|
1122
1223
|
value: [
|
|
1123
1224
|
String,
|
|
1124
1225
|
Array,
|
|
@@ -1139,15 +1240,21 @@ var MonthPicker = (0, vue.defineComponent)({
|
|
|
1139
1240
|
default: true
|
|
1140
1241
|
},
|
|
1141
1242
|
presets: Array,
|
|
1142
|
-
onMonthSelect: Function
|
|
1243
|
+
onMonthSelect: Function,
|
|
1244
|
+
withNativeLevelSelect: Boolean,
|
|
1245
|
+
yearsSelectRange: Array
|
|
1143
1246
|
},
|
|
1144
|
-
|
|
1247
|
+
emits: ["update:modelValue", "change"],
|
|
1248
|
+
setup(props, { attrs, emit }) {
|
|
1145
1249
|
const finalValue = (0, vue.computed)(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
|
|
1146
1250
|
const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
1147
|
-
value: (0, vue.computed)(() => props.value),
|
|
1251
|
+
value: (0, vue.computed)(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1148
1252
|
defaultValue: props.defaultValue,
|
|
1149
1253
|
finalValue: finalValue.value,
|
|
1150
|
-
onChange: (value) =>
|
|
1254
|
+
onChange: (value) => {
|
|
1255
|
+
emit("update:modelValue", value);
|
|
1256
|
+
emit("change", value);
|
|
1257
|
+
}
|
|
1151
1258
|
});
|
|
1152
1259
|
const hoveredDate = (0, vue.ref)(null);
|
|
1153
1260
|
const selectMonth = (date) => {
|
|
@@ -1183,6 +1290,8 @@ var MonthPicker = (0, vue.defineComponent)({
|
|
|
1183
1290
|
onDateChange: (date) => calendarDate.value = date,
|
|
1184
1291
|
defaultLevel: "year",
|
|
1185
1292
|
minLevel: "year",
|
|
1293
|
+
withNativeLevelSelect: props.withNativeLevelSelect,
|
|
1294
|
+
yearsSelectRange: props.yearsSelectRange,
|
|
1186
1295
|
onMonthSelect: selectMonth,
|
|
1187
1296
|
getMonthControlProps: monthControlProps,
|
|
1188
1297
|
onMonthMouseEnter: (date) => {
|
|
@@ -1300,6 +1409,11 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
|
|
|
1300
1409
|
type: String,
|
|
1301
1410
|
default: "default"
|
|
1302
1411
|
},
|
|
1412
|
+
modelValue: [
|
|
1413
|
+
String,
|
|
1414
|
+
Array,
|
|
1415
|
+
null
|
|
1416
|
+
],
|
|
1303
1417
|
value: [
|
|
1304
1418
|
String,
|
|
1305
1419
|
Array,
|
|
@@ -1336,15 +1450,21 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
|
|
|
1336
1450
|
type: Boolean,
|
|
1337
1451
|
default: true
|
|
1338
1452
|
},
|
|
1339
|
-
valueFormatter: Function
|
|
1453
|
+
valueFormatter: Function,
|
|
1454
|
+
withNativeLevelSelect: Boolean,
|
|
1455
|
+
yearsSelectRange: Array
|
|
1340
1456
|
},
|
|
1341
|
-
|
|
1457
|
+
emits: ["update:modelValue", "change"],
|
|
1458
|
+
setup(props, { attrs, emit }) {
|
|
1342
1459
|
const finalValue = (0, vue.computed)(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
|
|
1343
1460
|
const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
1344
|
-
value: (0, vue.computed)(() => props.value),
|
|
1461
|
+
value: (0, vue.computed)(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1345
1462
|
defaultValue: props.defaultValue,
|
|
1346
1463
|
finalValue: finalValue.value,
|
|
1347
|
-
onChange: (value) =>
|
|
1464
|
+
onChange: (value) => {
|
|
1465
|
+
emit("update:modelValue", value);
|
|
1466
|
+
emit("change", value);
|
|
1467
|
+
}
|
|
1348
1468
|
});
|
|
1349
1469
|
const opened = (0, vue.ref)(false);
|
|
1350
1470
|
const formattedValue = (0, vue.computed)(() => formatValue(_value.value, props.type, props.valueFormat, props.locale, props.labelSeparator, props.valueFormatter));
|
|
@@ -1365,6 +1485,8 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
|
|
|
1365
1485
|
sortDates: props.sortDates,
|
|
1366
1486
|
defaultLevel,
|
|
1367
1487
|
locale: props.locale,
|
|
1488
|
+
withNativeLevelSelect: props.withNativeLevelSelect,
|
|
1489
|
+
yearsSelectRange: props.yearsSelectRange,
|
|
1368
1490
|
onChange: (value) => {
|
|
1369
1491
|
setValue(value);
|
|
1370
1492
|
if (props.closeOnChange && props.type === "default") close();
|
|
@@ -1408,6 +1530,11 @@ var DateInput = (0, vue.defineComponent)({
|
|
|
1408
1530
|
name: "DateInput",
|
|
1409
1531
|
inheritAttrs: false,
|
|
1410
1532
|
props: {
|
|
1533
|
+
modelValue: [
|
|
1534
|
+
String,
|
|
1535
|
+
Date,
|
|
1536
|
+
null
|
|
1537
|
+
],
|
|
1411
1538
|
value: [
|
|
1412
1539
|
String,
|
|
1413
1540
|
Date,
|
|
@@ -1430,12 +1557,19 @@ var DateInput = (0, vue.defineComponent)({
|
|
|
1430
1557
|
maxDate: [String, Date],
|
|
1431
1558
|
presets: Array
|
|
1432
1559
|
},
|
|
1433
|
-
|
|
1560
|
+
emits: ["update:modelValue", "change"],
|
|
1561
|
+
setup(props, { attrs, emit }) {
|
|
1434
1562
|
const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
1435
|
-
value: (0, vue.computed)(() =>
|
|
1563
|
+
value: (0, vue.computed)(() => {
|
|
1564
|
+
const controlledValue = props.modelValue !== void 0 ? props.modelValue : props.value;
|
|
1565
|
+
return controlledValue === void 0 ? void 0 : normalizeDate(controlledValue);
|
|
1566
|
+
}),
|
|
1436
1567
|
defaultValue: normalizeDate(props.defaultValue),
|
|
1437
1568
|
finalValue: null,
|
|
1438
|
-
onChange: (value) =>
|
|
1569
|
+
onChange: (value) => {
|
|
1570
|
+
emit("update:modelValue", value);
|
|
1571
|
+
emit("change", value);
|
|
1572
|
+
}
|
|
1439
1573
|
});
|
|
1440
1574
|
const formatValue = (value) => value ? (0, dayjs.default)(value).locale(props.locale || "en").format(props.valueFormat) : "";
|
|
1441
1575
|
const inputValue = (0, vue.ref)(formatValue(_value.value));
|
|
@@ -1607,18 +1741,22 @@ var TimeInput = (0, vue.defineComponent)({
|
|
|
1607
1741
|
name: "TimeInput",
|
|
1608
1742
|
props: {
|
|
1609
1743
|
withSeconds: Boolean,
|
|
1744
|
+
modelValue: String,
|
|
1610
1745
|
value: String,
|
|
1611
1746
|
defaultValue: String,
|
|
1612
1747
|
onChange: Function
|
|
1613
1748
|
},
|
|
1614
|
-
|
|
1749
|
+
emits: ["update:modelValue", "change"],
|
|
1750
|
+
setup(props, { attrs, emit }) {
|
|
1615
1751
|
return () => (0, vue.h)(_mantine_vue_core.InputBase, {
|
|
1616
1752
|
...attrs,
|
|
1617
1753
|
type: "time",
|
|
1618
1754
|
step: props.withSeconds ? 1 : 60,
|
|
1755
|
+
modelValue: props.modelValue,
|
|
1619
1756
|
value: props.value,
|
|
1620
1757
|
defaultValue: props.defaultValue,
|
|
1621
|
-
|
|
1758
|
+
"onUpdate:modelValue": (value) => emit("update:modelValue", value),
|
|
1759
|
+
onChange: (value) => emit("change", value)
|
|
1622
1760
|
});
|
|
1623
1761
|
}
|
|
1624
1762
|
});
|
|
@@ -1629,6 +1767,7 @@ var TimeGrid = (0, vue.defineComponent)({
|
|
|
1629
1767
|
type: Array,
|
|
1630
1768
|
default: () => []
|
|
1631
1769
|
},
|
|
1770
|
+
modelValue: String,
|
|
1632
1771
|
value: String,
|
|
1633
1772
|
defaultValue: String,
|
|
1634
1773
|
minTime: String,
|
|
@@ -1638,12 +1777,16 @@ var TimeGrid = (0, vue.defineComponent)({
|
|
|
1638
1777
|
onChange: Function,
|
|
1639
1778
|
getControlProps: Function
|
|
1640
1779
|
},
|
|
1641
|
-
|
|
1780
|
+
emits: ["update:modelValue", "change"],
|
|
1781
|
+
setup(props, { attrs, emit }) {
|
|
1642
1782
|
const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
1643
|
-
value: (0, vue.computed)(() => props.value),
|
|
1783
|
+
value: (0, vue.computed)(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1644
1784
|
defaultValue: props.defaultValue,
|
|
1645
1785
|
finalValue: null,
|
|
1646
|
-
onChange: (value) =>
|
|
1786
|
+
onChange: (value) => {
|
|
1787
|
+
emit("update:modelValue", value);
|
|
1788
|
+
emit("change", value);
|
|
1789
|
+
}
|
|
1647
1790
|
});
|
|
1648
1791
|
return () => (0, vue.h)(_mantine_vue_core.Box, {
|
|
1649
1792
|
...attrs,
|
|
@@ -1676,9 +1819,17 @@ var SpinInput = (0, vue.defineComponent)({
|
|
|
1676
1819
|
name: "SpinInput",
|
|
1677
1820
|
inheritAttrs: false,
|
|
1678
1821
|
props: {
|
|
1822
|
+
modelValue: {
|
|
1823
|
+
type: Number,
|
|
1824
|
+
default: void 0
|
|
1825
|
+
},
|
|
1679
1826
|
value: {
|
|
1680
1827
|
type: Number,
|
|
1681
|
-
default:
|
|
1828
|
+
default: void 0
|
|
1829
|
+
},
|
|
1830
|
+
defaultValue: {
|
|
1831
|
+
type: Number,
|
|
1832
|
+
default: void 0
|
|
1682
1833
|
},
|
|
1683
1834
|
min: {
|
|
1684
1835
|
type: Number,
|
|
@@ -1704,8 +1855,19 @@ var SpinInput = (0, vue.defineComponent)({
|
|
|
1704
1855
|
disabled: Boolean,
|
|
1705
1856
|
readOnly: Boolean
|
|
1706
1857
|
},
|
|
1707
|
-
|
|
1708
|
-
|
|
1858
|
+
emits: ["update:modelValue", "change"],
|
|
1859
|
+
setup(props, { attrs, emit }) {
|
|
1860
|
+
const [value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
1861
|
+
value: (0, vue.computed)(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1862
|
+
defaultValue: props.defaultValue,
|
|
1863
|
+
finalValue: null,
|
|
1864
|
+
onChange: (nextValue) => {
|
|
1865
|
+
emit("update:modelValue", nextValue);
|
|
1866
|
+
emit("change", nextValue);
|
|
1867
|
+
}
|
|
1868
|
+
});
|
|
1869
|
+
const finiteMax = () => Number.isFinite(props.max);
|
|
1870
|
+
const maxDigit = () => finiteMax() ? Number(props.max.toFixed(0)[0]) : Infinity;
|
|
1709
1871
|
const arrowsMax = () => props.max + 1 - props.step;
|
|
1710
1872
|
const handleChange = (raw) => {
|
|
1711
1873
|
if (props.readOnly) return;
|
|
@@ -1715,10 +1877,10 @@ var SpinInput = (0, vue.defineComponent)({
|
|
|
1715
1877
|
for (let i = 0; i < clearValue.length; i += 1) {
|
|
1716
1878
|
const digit = clearValue.charCodeAt(i) - 48;
|
|
1717
1879
|
const next = parsedValue * 10 + digit;
|
|
1718
|
-
parsedValue = next > props.max ? digit : next;
|
|
1880
|
+
parsedValue = finiteMax() && next > props.max ? digit : next;
|
|
1719
1881
|
}
|
|
1720
|
-
const clampedValue = props.allowTemporaryZero && parsedValue === 0 && props.min > 0 ? 0 : Math.min(Math.max(parsedValue, props.min), props.max);
|
|
1721
|
-
|
|
1882
|
+
const clampedValue = props.allowTemporaryZero && parsedValue === 0 && props.min > 0 ? 0 : finiteMax() ? Math.min(Math.max(parsedValue, props.min), props.max) : Math.max(parsedValue, props.min);
|
|
1883
|
+
setValue(clampedValue);
|
|
1722
1884
|
if (!props.disableAutoAdvance && (clampedValue > maxDigit() || raw.startsWith("00"))) props.onNextInput?.();
|
|
1723
1885
|
};
|
|
1724
1886
|
const handleKeydown = (event) => {
|
|
@@ -1726,22 +1888,22 @@ var SpinInput = (0, vue.defineComponent)({
|
|
|
1726
1888
|
if (event.key === "0" || event.key === "Num0") {
|
|
1727
1889
|
const { selectionStart, selectionEnd, value: inputValue } = event.currentTarget;
|
|
1728
1890
|
const isEntireValueSelected = inputValue.length > 0 && selectionStart === 0 && selectionEnd === inputValue.length;
|
|
1729
|
-
if (
|
|
1891
|
+
if (value.value === 0 && !isEntireValueSelected) {
|
|
1730
1892
|
event.preventDefault();
|
|
1731
1893
|
props.onNextInput?.();
|
|
1732
1894
|
}
|
|
1733
1895
|
}
|
|
1734
1896
|
if (event.key === "Home") {
|
|
1735
1897
|
event.preventDefault();
|
|
1736
|
-
|
|
1898
|
+
setValue(props.min);
|
|
1737
1899
|
}
|
|
1738
1900
|
if (event.key === "End") {
|
|
1739
1901
|
event.preventDefault();
|
|
1740
|
-
|
|
1902
|
+
if (finiteMax()) setValue(props.max);
|
|
1741
1903
|
}
|
|
1742
1904
|
if (event.key === "Backspace" || event.key === "Delete") {
|
|
1743
1905
|
event.preventDefault();
|
|
1744
|
-
if (
|
|
1906
|
+
if (value.value !== null) setValue(null);
|
|
1745
1907
|
else props.onPreviousInput?.();
|
|
1746
1908
|
}
|
|
1747
1909
|
if (event.key === "ArrowRight") {
|
|
@@ -1754,13 +1916,11 @@ var SpinInput = (0, vue.defineComponent)({
|
|
|
1754
1916
|
}
|
|
1755
1917
|
if (event.key === "ArrowUp") {
|
|
1756
1918
|
event.preventDefault();
|
|
1757
|
-
|
|
1758
|
-
props.onChange?.(newValue);
|
|
1919
|
+
setValue(value.value === null ? props.min : finiteMax() ? Math.min(Math.max(value.value + props.step, props.min), arrowsMax()) : Math.max(value.value + props.step, props.min));
|
|
1759
1920
|
}
|
|
1760
1921
|
if (event.key === "ArrowDown") {
|
|
1761
1922
|
event.preventDefault();
|
|
1762
|
-
|
|
1763
|
-
props.onChange?.(newValue);
|
|
1923
|
+
setValue(value.value === null ? finiteMax() ? arrowsMax() : props.min : Math.min(Math.max(value.value - props.step, props.min), arrowsMax()));
|
|
1764
1924
|
}
|
|
1765
1925
|
};
|
|
1766
1926
|
return () => (0, vue.h)("input", {
|
|
@@ -1768,14 +1928,14 @@ var SpinInput = (0, vue.defineComponent)({
|
|
|
1768
1928
|
type: "text",
|
|
1769
1929
|
role: "spinbutton",
|
|
1770
1930
|
"aria-valuemin": props.min,
|
|
1771
|
-
"aria-valuemax": props.max,
|
|
1772
|
-
"aria-valuenow":
|
|
1773
|
-
"data-empty":
|
|
1931
|
+
"aria-valuemax": finiteMax() ? props.max : void 0,
|
|
1932
|
+
"aria-valuenow": value.value === null ? 0 : value.value,
|
|
1933
|
+
"data-empty": value.value === null || void 0,
|
|
1774
1934
|
inputmode: "numeric",
|
|
1775
1935
|
placeholder: props.placeholder,
|
|
1776
1936
|
disabled: props.disabled,
|
|
1777
1937
|
readonly: props.readOnly,
|
|
1778
|
-
value:
|
|
1938
|
+
value: value.value === null ? "" : padTime(value.value),
|
|
1779
1939
|
onInput: (event) => handleChange(event.target.value),
|
|
1780
1940
|
onKeydown: handleKeydown,
|
|
1781
1941
|
onFocus: (event) => event.target.select(),
|
|
@@ -1790,9 +1950,17 @@ var SpinInput = (0, vue.defineComponent)({
|
|
|
1790
1950
|
var AmPmInput = (0, vue.defineComponent)({
|
|
1791
1951
|
name: "AmPmInput",
|
|
1792
1952
|
props: {
|
|
1953
|
+
modelValue: {
|
|
1954
|
+
type: String,
|
|
1955
|
+
default: void 0
|
|
1956
|
+
},
|
|
1793
1957
|
value: {
|
|
1794
1958
|
type: String,
|
|
1795
|
-
default:
|
|
1959
|
+
default: void 0
|
|
1960
|
+
},
|
|
1961
|
+
defaultValue: {
|
|
1962
|
+
type: String,
|
|
1963
|
+
default: void 0
|
|
1796
1964
|
},
|
|
1797
1965
|
labels: {
|
|
1798
1966
|
type: Object,
|
|
@@ -1802,14 +1970,24 @@ var AmPmInput = (0, vue.defineComponent)({
|
|
|
1802
1970
|
disabled: Boolean,
|
|
1803
1971
|
readOnly: Boolean
|
|
1804
1972
|
},
|
|
1805
|
-
|
|
1973
|
+
emits: ["update:modelValue", "change"],
|
|
1974
|
+
setup(props, { attrs, emit }) {
|
|
1975
|
+
const [value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
1976
|
+
value: (0, vue.computed)(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1977
|
+
defaultValue: props.defaultValue,
|
|
1978
|
+
finalValue: null,
|
|
1979
|
+
onChange: (nextValue) => {
|
|
1980
|
+
emit("update:modelValue", nextValue);
|
|
1981
|
+
emit("change", nextValue);
|
|
1982
|
+
}
|
|
1983
|
+
});
|
|
1806
1984
|
return () => (0, vue.h)("select", {
|
|
1807
1985
|
...attrs,
|
|
1808
1986
|
class: Dates_module_default.timePickerField,
|
|
1809
1987
|
"data-am-pm": true,
|
|
1810
1988
|
disabled: props.disabled,
|
|
1811
|
-
value:
|
|
1812
|
-
onChange: (event) =>
|
|
1989
|
+
value: value.value ?? props.labels.am,
|
|
1990
|
+
onChange: (event) => setValue(event.target.value)
|
|
1813
1991
|
}, [(0, vue.h)("option", { value: props.labels.am }, props.labels.am), (0, vue.h)("option", { value: props.labels.pm }, props.labels.pm)]);
|
|
1814
1992
|
}
|
|
1815
1993
|
});
|
|
@@ -1847,9 +2025,14 @@ var TimeControlsList = (0, vue.defineComponent)({
|
|
|
1847
2025
|
var TimePicker = (0, vue.defineComponent)({
|
|
1848
2026
|
name: "TimePicker",
|
|
1849
2027
|
props: {
|
|
2028
|
+
modelValue: String,
|
|
1850
2029
|
value: String,
|
|
1851
2030
|
defaultValue: String,
|
|
1852
2031
|
onChange: Function,
|
|
2032
|
+
type: {
|
|
2033
|
+
type: String,
|
|
2034
|
+
default: "time"
|
|
2035
|
+
},
|
|
1853
2036
|
withSeconds: Boolean,
|
|
1854
2037
|
min: String,
|
|
1855
2038
|
max: String,
|
|
@@ -1885,16 +2068,21 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
1885
2068
|
closeDropdownOnPresetSelect: Boolean,
|
|
1886
2069
|
hoursRef: Object
|
|
1887
2070
|
},
|
|
1888
|
-
|
|
2071
|
+
emits: ["update:modelValue", "change"],
|
|
2072
|
+
setup(props, { attrs, emit }) {
|
|
2073
|
+
const effectiveFormat = (0, vue.computed)(() => props.type === "duration" ? "24h" : props.format);
|
|
1889
2074
|
const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
1890
|
-
value: (0, vue.computed)(() => props.value),
|
|
2075
|
+
value: (0, vue.computed)(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1891
2076
|
defaultValue: props.defaultValue,
|
|
1892
2077
|
finalValue: "",
|
|
1893
|
-
onChange: (value) =>
|
|
2078
|
+
onChange: (value) => {
|
|
2079
|
+
emit("update:modelValue", value);
|
|
2080
|
+
emit("change", value);
|
|
2081
|
+
}
|
|
1894
2082
|
});
|
|
1895
2083
|
const parsed = (0, vue.computed)(() => getParsedTime({
|
|
1896
2084
|
time: _value.value,
|
|
1897
|
-
format:
|
|
2085
|
+
format: effectiveFormat.value,
|
|
1898
2086
|
amPmLabels: props.amPmLabels
|
|
1899
2087
|
}));
|
|
1900
2088
|
const hours = (0, vue.ref)(parsed.value.hours);
|
|
@@ -1904,7 +2092,7 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
1904
2092
|
(0, vue.watch)(_value, (value) => {
|
|
1905
2093
|
const next = getParsedTime({
|
|
1906
2094
|
time: value,
|
|
1907
|
-
format:
|
|
2095
|
+
format: effectiveFormat.value,
|
|
1908
2096
|
amPmLabels: props.amPmLabels
|
|
1909
2097
|
});
|
|
1910
2098
|
hours.value = next.hours;
|
|
@@ -1930,7 +2118,7 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
1930
2118
|
hours: hours.value,
|
|
1931
2119
|
minutes: minutes.value,
|
|
1932
2120
|
seconds: seconds.value,
|
|
1933
|
-
format:
|
|
2121
|
+
format: effectiveFormat.value,
|
|
1934
2122
|
withSeconds: props.withSeconds,
|
|
1935
2123
|
amPm: amPm.value,
|
|
1936
2124
|
amPmLabels: props.amPmLabels
|
|
@@ -1939,7 +2127,7 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
1939
2127
|
};
|
|
1940
2128
|
const setHours = (value) => {
|
|
1941
2129
|
let adjusted = value;
|
|
1942
|
-
if (
|
|
2130
|
+
if (effectiveFormat.value === "12h" && typeof value === "number" && value > 12) adjusted = (value - 1) % 12 + 1;
|
|
1943
2131
|
hours.value = adjusted;
|
|
1944
2132
|
commit();
|
|
1945
2133
|
focus("hours");
|
|
@@ -1973,8 +2161,32 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
1973
2161
|
setValue(timeString);
|
|
1974
2162
|
if (props.closeDropdownOnPresetSelect) opened.value = false;
|
|
1975
2163
|
};
|
|
2164
|
+
const handlePaste = (event) => {
|
|
2165
|
+
if (props.readOnly || props.disabled) return;
|
|
2166
|
+
const value = event.clipboardData?.getData("text").trim();
|
|
2167
|
+
if (!value || !/^\d+:\d{2}(?::\d{2})?(?:\s+[aApP][mM])?$/.test(value)) return;
|
|
2168
|
+
const next = getParsedTime({
|
|
2169
|
+
time: value,
|
|
2170
|
+
format: effectiveFormat.value,
|
|
2171
|
+
amPmLabels: props.amPmLabels
|
|
2172
|
+
});
|
|
2173
|
+
if (next.hours === null || next.minutes === null || next.minutes > 59 || props.withSeconds && (next.seconds === null || next.seconds > 59) || props.type === "time" && effectiveFormat.value === "24h" && next.hours > 23) return;
|
|
2174
|
+
event.preventDefault();
|
|
2175
|
+
hours.value = next.hours;
|
|
2176
|
+
minutes.value = next.minutes;
|
|
2177
|
+
seconds.value = props.withSeconds ? next.seconds : null;
|
|
2178
|
+
amPm.value = next.amPm;
|
|
2179
|
+
const result = getTimeString({
|
|
2180
|
+
...next,
|
|
2181
|
+
seconds: props.withSeconds ? next.seconds : null,
|
|
2182
|
+
format: effectiveFormat.value,
|
|
2183
|
+
withSeconds: props.withSeconds,
|
|
2184
|
+
amPmLabels: props.amPmLabels
|
|
2185
|
+
});
|
|
2186
|
+
if (result.valid) setValue(clampTime(result.value, props.min, props.max));
|
|
2187
|
+
};
|
|
1976
2188
|
return () => (0, vue.h)(_mantine_vue_core.Popover, {
|
|
1977
|
-
opened: props.withDropdown && opened.value,
|
|
2189
|
+
opened: props.type !== "duration" && props.withDropdown && opened.value,
|
|
1978
2190
|
position: "bottom-start",
|
|
1979
2191
|
transitionProps: { duration: 0 }
|
|
1980
2192
|
}, () => [(0, vue.h)(_mantine_vue_core.Popover.Target, null, () => (0, vue.h)(_mantine_vue_core.InputBase, {
|
|
@@ -1984,11 +2196,11 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
1984
2196
|
disabled: props.disabled,
|
|
1985
2197
|
onClick: () => {
|
|
1986
2198
|
focus("hours");
|
|
1987
|
-
if (props.withDropdown) opened.value = true;
|
|
2199
|
+
if (props.type !== "duration" && props.withDropdown) opened.value = true;
|
|
1988
2200
|
},
|
|
1989
2201
|
onMousedown: (event) => event.preventDefault(),
|
|
1990
2202
|
onFocusin: () => {
|
|
1991
|
-
if (props.withDropdown) opened.value = true;
|
|
2203
|
+
if (props.type !== "duration" && props.withDropdown) opened.value = true;
|
|
1992
2204
|
},
|
|
1993
2205
|
onFocusout: () => {
|
|
1994
2206
|
if (props.withDropdown) opened.value = false;
|
|
@@ -2007,12 +2219,14 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
2007
2219
|
ref: hoursRef,
|
|
2008
2220
|
class: Dates_module_default.timePickerField,
|
|
2009
2221
|
value: hours.value,
|
|
2010
|
-
min:
|
|
2011
|
-
max: props.
|
|
2222
|
+
min: effectiveFormat.value === "12h" ? 1 : 0,
|
|
2223
|
+
max: props.type === "duration" ? Infinity : effectiveFormat.value === "12h" ? 12 : 23,
|
|
2012
2224
|
step: props.hoursStep,
|
|
2013
2225
|
onChange: setHours,
|
|
2014
2226
|
onNextInput: () => focus("minutes"),
|
|
2015
|
-
allowTemporaryZero:
|
|
2227
|
+
allowTemporaryZero: effectiveFormat.value === "12h",
|
|
2228
|
+
disableAutoAdvance: props.type === "duration",
|
|
2229
|
+
onPaste: handlePaste,
|
|
2016
2230
|
readOnly: props.readOnly,
|
|
2017
2231
|
disabled: props.disabled,
|
|
2018
2232
|
placeholder: "--"
|
|
@@ -2047,7 +2261,7 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
2047
2261
|
disabled: props.disabled,
|
|
2048
2262
|
placeholder: "--"
|
|
2049
2263
|
}) : null,
|
|
2050
|
-
|
|
2264
|
+
effectiveFormat.value === "12h" ? (0, vue.h)(AmPmInput, {
|
|
2051
2265
|
ref: amPmRef,
|
|
2052
2266
|
value: amPm.value,
|
|
2053
2267
|
labels: props.amPmLabels,
|
|
@@ -2067,8 +2281,8 @@ var TimePicker = (0, vue.defineComponent)({
|
|
|
2067
2281
|
onClick: () => handlePresetSelect(preset.value)
|
|
2068
2282
|
}, () => preset.label))) : (0, vue.h)("div", { class: Dates_module_default.timePickerControlsListGroup }, [
|
|
2069
2283
|
(0, vue.h)(TimeControlsList, {
|
|
2070
|
-
min:
|
|
2071
|
-
max:
|
|
2284
|
+
min: effectiveFormat.value === "12h" ? 1 : 0,
|
|
2285
|
+
max: effectiveFormat.value === "12h" ? 12 : 23,
|
|
2072
2286
|
step: props.hoursStep,
|
|
2073
2287
|
value: hours.value,
|
|
2074
2288
|
onSelect: setHours
|
|
@@ -2110,6 +2324,11 @@ var TimeValue = (0, vue.defineComponent)({
|
|
|
2110
2324
|
var DateTimePicker = (0, vue.defineComponent)({
|
|
2111
2325
|
name: "DateTimePicker",
|
|
2112
2326
|
props: {
|
|
2327
|
+
modelValue: [
|
|
2328
|
+
String,
|
|
2329
|
+
Date,
|
|
2330
|
+
null
|
|
2331
|
+
],
|
|
2113
2332
|
value: [
|
|
2114
2333
|
String,
|
|
2115
2334
|
Date,
|
|
@@ -2133,13 +2352,20 @@ var DateTimePicker = (0, vue.defineComponent)({
|
|
|
2133
2352
|
},
|
|
2134
2353
|
submitButtonProps: Object
|
|
2135
2354
|
},
|
|
2136
|
-
|
|
2355
|
+
emits: ["update:modelValue", "change"],
|
|
2356
|
+
setup(props, { attrs, emit }) {
|
|
2137
2357
|
const hoursRef = (0, vue.ref)();
|
|
2138
2358
|
const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
2139
|
-
value: (0, vue.computed)(() =>
|
|
2359
|
+
value: (0, vue.computed)(() => {
|
|
2360
|
+
const controlledValue = props.modelValue !== void 0 ? props.modelValue : props.value;
|
|
2361
|
+
return controlledValue === void 0 ? void 0 : controlledValue === null ? null : new Date(controlledValue);
|
|
2362
|
+
}),
|
|
2140
2363
|
defaultValue: props.defaultValue ? new Date(props.defaultValue) : null,
|
|
2141
2364
|
finalValue: null,
|
|
2142
|
-
onChange: (value) =>
|
|
2365
|
+
onChange: (value) => {
|
|
2366
|
+
emit("update:modelValue", value);
|
|
2367
|
+
emit("change", value);
|
|
2368
|
+
}
|
|
2143
2369
|
});
|
|
2144
2370
|
const date = (0, vue.computed)(() => _value.value ? (0, dayjs.default)(_value.value).format("YYYY-MM-DD") : null);
|
|
2145
2371
|
const time = (0, vue.computed)(() => _value.value ? (0, dayjs.default)(_value.value).format(props.withSeconds ? "HH:mm:ss" : "HH:mm") : "");
|
|
@@ -2185,11 +2411,21 @@ var MiniCalendar = (0, vue.defineComponent)({
|
|
|
2185
2411
|
date: [String, Date],
|
|
2186
2412
|
defaultDate: [String, Date],
|
|
2187
2413
|
onDateChange: Function,
|
|
2414
|
+
modelValue: [
|
|
2415
|
+
String,
|
|
2416
|
+
Date,
|
|
2417
|
+
null
|
|
2418
|
+
],
|
|
2188
2419
|
value: [
|
|
2189
2420
|
String,
|
|
2190
2421
|
Date,
|
|
2191
2422
|
null
|
|
2192
2423
|
],
|
|
2424
|
+
defaultValue: [
|
|
2425
|
+
String,
|
|
2426
|
+
Date,
|
|
2427
|
+
null
|
|
2428
|
+
],
|
|
2193
2429
|
onChange: Function,
|
|
2194
2430
|
maxDate: [String, Date],
|
|
2195
2431
|
minDate: [String, Date],
|
|
@@ -2212,12 +2448,25 @@ var MiniCalendar = (0, vue.defineComponent)({
|
|
|
2212
2448
|
nextControlProps: Object,
|
|
2213
2449
|
locale: String
|
|
2214
2450
|
},
|
|
2215
|
-
|
|
2451
|
+
emits: ["update:modelValue", "change"],
|
|
2452
|
+
setup(props, { attrs, emit }) {
|
|
2216
2453
|
const ctx = useDatesContext();
|
|
2454
|
+
const [value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
2455
|
+
value: (0, vue.computed)(() => {
|
|
2456
|
+
const controlledValue = props.modelValue !== void 0 ? props.modelValue : props.value;
|
|
2457
|
+
return controlledValue === void 0 ? void 0 : toDateString(controlledValue);
|
|
2458
|
+
}),
|
|
2459
|
+
defaultValue: toDateString(props.defaultValue ?? null),
|
|
2460
|
+
finalValue: null,
|
|
2461
|
+
onChange: (nextValue) => {
|
|
2462
|
+
emit("update:modelValue", nextValue);
|
|
2463
|
+
emit("change", nextValue);
|
|
2464
|
+
}
|
|
2465
|
+
});
|
|
2217
2466
|
const [_date, setDate] = (0, _mantine_vue_hooks.useUncontrolled)({
|
|
2218
2467
|
value: (0, vue.computed)(() => toDateString(props.date ?? null) ?? void 0),
|
|
2219
2468
|
defaultValue: toDateString(props.defaultDate ?? null) ?? void 0,
|
|
2220
|
-
finalValue:
|
|
2469
|
+
finalValue: value.value || (0, dayjs.default)().format("YYYY-MM-DD"),
|
|
2221
2470
|
onChange: (value) => props.onDateChange?.(value)
|
|
2222
2471
|
});
|
|
2223
2472
|
const handleNext = () => {
|
|
@@ -2239,12 +2488,12 @@ var MiniCalendar = (0, vue.defineComponent)({
|
|
|
2239
2488
|
disabled,
|
|
2240
2489
|
"aria-label": date.format("YYYY-MM-DD"),
|
|
2241
2490
|
"data-disabled": disabled || void 0,
|
|
2242
|
-
"data-selected":
|
|
2491
|
+
"data-selected": value.value && (0, dayjs.default)(date).isSame(value.value, "day") || void 0,
|
|
2243
2492
|
...dayProps,
|
|
2244
2493
|
class: [Dates_module_default.miniCalendarDay, dayProps.class],
|
|
2245
2494
|
onClick: (event) => {
|
|
2246
2495
|
dayProps.onClick?.(event);
|
|
2247
|
-
|
|
2496
|
+
setValue(toDateString(date.format("YYYY-MM-DD")));
|
|
2248
2497
|
}
|
|
2249
2498
|
}, () => [(0, vue.h)("span", { class: Dates_module_default.miniCalendarDayMonth }, date.locale(props.locale || ctx.locale).format(props.monthLabelFormat)), (0, vue.h)("span", { class: Dates_module_default.miniCalendarDayNumber }, String(date.date()))]);
|
|
2250
2499
|
});
|