@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/esm/index.mjs CHANGED
@@ -4,44 +4,45 @@ import { computed, defineComponent, h, inject, provide, ref, watch } from "vue";
4
4
  import { useUncontrolled } from "@mantine-vue/hooks";
5
5
  import { AccordionChevron, ActionIcon, Box, Button, CheckIcon, CloseButton, Group, InputBase, Modal, Popover, ScrollArea, SimpleGrid, Text, UnstyledButton } from "@mantine-vue/core";
6
6
  var Dates_module_default = {
7
- calendar: "_calendar_5kwje_1",
8
- calendarLevel: "_calendarLevel_5kwje_15",
9
- calendarHeader: "_calendarHeader_5kwje_19",
10
- calendarHeaderLevel: "_calendarHeaderLevel_5kwje_32",
11
- calendarHeaderControl: "_calendarHeaderControl_5kwje_33",
12
- calendarHeaderControlIcon: "_calendarHeaderControlIcon_5kwje_74",
13
- month: "_month_5kwje_87",
14
- monthRow: "_monthRow_5kwje_97",
15
- monthCell: "_monthCell_5kwje_101",
16
- weekday: "_weekday_5kwje_110",
17
- weekNumber: "_weekNumber_5kwje_122",
18
- day: "_day_5kwje_128",
19
- pickerControl: "_pickerControl_5kwje_189",
20
- controlsGrid: "_controlsGrid_5kwje_195",
21
- timePicker: "_timePicker_5kwje_255",
22
- dateTimePicker: "_dateTimePicker_5kwje_256",
23
- datePickerRoot: "_datePickerRoot_5kwje_260",
24
- timeWrapper: "_timeWrapper_5kwje_270",
25
- timeInput: "_timeInput_5kwje_276",
26
- presetsList: "_presetsList_5kwje_281",
27
- presetButton: "_presetButton_5kwje_289",
28
- timePickerPresetsGroup: "_timePickerPresetsGroup_5kwje_300",
29
- dropdown: "_dropdown_5kwje_304",
30
- placeholder: "_placeholder_5kwje_308",
31
- timeGridControl: "_timeGridControl_5kwje_312",
32
- timePickerFieldsRoot: "_timePickerFieldsRoot_5kwje_343",
33
- timePickerFieldsGroup: "_timePickerFieldsGroup_5kwje_350",
34
- timePickerField: "_timePickerField_5kwje_343",
35
- timePickerDropdown: "_timePickerDropdown_5kwje_400",
36
- timePickerControlsListGroup: "_timePickerControlsListGroup_5kwje_404",
37
- timePickerControlsList: "_timePickerControlsList_5kwje_404",
38
- timePickerControl: "_timePickerControl_5kwje_404",
39
- miniCalendarRoot: "_miniCalendarRoot_5kwje_433",
40
- miniCalendarDays: "_miniCalendarDays_5kwje_440",
41
- miniCalendarDay: "_miniCalendarDay_5kwje_440",
42
- miniCalendarDayMonth: "_miniCalendarDayMonth_5kwje_475",
43
- miniCalendarDayNumber: "_miniCalendarDayNumber_5kwje_481",
44
- miniCalendarControl: "_miniCalendarControl_5kwje_486"
7
+ calendar: "_calendar_zystn_1",
8
+ calendarLevel: "_calendarLevel_zystn_15",
9
+ calendarHeader: "_calendarHeader_zystn_19",
10
+ calendarHeaderLevel: "_calendarHeaderLevel_zystn_32",
11
+ calendarHeaderControl: "_calendarHeaderControl_zystn_33",
12
+ calendarHeaderSelect: "_calendarHeaderSelect_zystn_79",
13
+ calendarHeaderControlIcon: "_calendarHeaderControlIcon_zystn_109",
14
+ month: "_month_zystn_122",
15
+ monthRow: "_monthRow_zystn_132",
16
+ monthCell: "_monthCell_zystn_136",
17
+ weekday: "_weekday_zystn_145",
18
+ weekNumber: "_weekNumber_zystn_157",
19
+ day: "_day_zystn_163",
20
+ pickerControl: "_pickerControl_zystn_224",
21
+ controlsGrid: "_controlsGrid_zystn_230",
22
+ timePicker: "_timePicker_zystn_290",
23
+ dateTimePicker: "_dateTimePicker_zystn_291",
24
+ datePickerRoot: "_datePickerRoot_zystn_295",
25
+ timeWrapper: "_timeWrapper_zystn_305",
26
+ timeInput: "_timeInput_zystn_311",
27
+ presetsList: "_presetsList_zystn_316",
28
+ presetButton: "_presetButton_zystn_324",
29
+ timePickerPresetsGroup: "_timePickerPresetsGroup_zystn_335",
30
+ dropdown: "_dropdown_zystn_339",
31
+ placeholder: "_placeholder_zystn_343",
32
+ timeGridControl: "_timeGridControl_zystn_347",
33
+ timePickerFieldsRoot: "_timePickerFieldsRoot_zystn_378",
34
+ timePickerFieldsGroup: "_timePickerFieldsGroup_zystn_385",
35
+ timePickerField: "_timePickerField_zystn_378",
36
+ timePickerDropdown: "_timePickerDropdown_zystn_435",
37
+ timePickerControlsListGroup: "_timePickerControlsListGroup_zystn_439",
38
+ timePickerControlsList: "_timePickerControlsList_zystn_439",
39
+ timePickerControl: "_timePickerControl_zystn_439",
40
+ miniCalendarRoot: "_miniCalendarRoot_zystn_468",
41
+ miniCalendarDays: "_miniCalendarDays_zystn_475",
42
+ miniCalendarDay: "_miniCalendarDay_zystn_475",
43
+ miniCalendarDayMonth: "_miniCalendarDayMonth_zystn_510",
44
+ miniCalendarDayNumber: "_miniCalendarDayNumber_zystn_516",
45
+ miniCalendarControl: "_miniCalendarControl_zystn_521"
45
46
  };
46
47
  //#endregion
47
48
  //#region src/index.ts
@@ -242,6 +243,7 @@ function getDecadeLabel(date) {
242
243
  var Day = defineComponent({
243
244
  name: "Day",
244
245
  inheritAttrs: false,
246
+ slots: Object,
245
247
  props: {
246
248
  date: {
247
249
  type: String,
@@ -276,7 +278,7 @@ var Day = defineComponent({
276
278
  },
277
279
  unstyled: Boolean
278
280
  },
279
- setup(props, { attrs }) {
281
+ setup(props, { attrs, slots }) {
280
282
  return () => h(UnstyledButton, {
281
283
  ...attrs,
282
284
  component: props.static ? "div" : "button",
@@ -295,7 +297,7 @@ var Day = defineComponent({
295
297
  "data-last-in-range": props.lastInRange && !props.disabled || void 0,
296
298
  "data-static": props.static || void 0,
297
299
  "data-full-width": props.fullWidth || void 0
298
- }, () => props.renderDay?.(props.date) || dayjs(props.date).date());
300
+ }, () => (props.renderDay ? props.renderDay(props.date) : (slots.renderDay ?? slots.day)?.({ date: props.date })) || dayjs(props.date).date());
299
301
  }
300
302
  });
301
303
  var PickerControl = defineComponent({
@@ -359,6 +361,15 @@ var CalendarHeader = defineComponent({
359
361
  },
360
362
  levelControlAriaLabel: String,
361
363
  fullWidth: Boolean,
364
+ withNativeLevelSelect: Boolean,
365
+ yearsSelectRange: Array,
366
+ calendarLevel: String,
367
+ date: [String, Date],
368
+ locale: String,
369
+ onDateChange: Function,
370
+ minDate: [String, Date],
371
+ maxDate: [String, Date],
372
+ disableNativeLevelSelect: Boolean,
362
373
  onNext: Function,
363
374
  onPrevious: Function,
364
375
  onLevelClick: Function
@@ -377,7 +388,40 @@ var CalendarHeader = defineComponent({
377
388
  "data-direction": "previous",
378
389
  size: "45%"
379
390
  })) : null;
380
- const levelControl = h(UnstyledButton, {
391
+ const displayed = props.date ? dayjs(props.date) : dayjs();
392
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
393
+ const rawMinYear = props.yearsSelectRange?.[0] ?? (props.minDate ? dayjs(props.minDate).year() : currentYear - 100);
394
+ const rawMaxYear = props.yearsSelectRange?.[1] ?? (props.maxDate ? dayjs(props.maxDate).year() : currentYear + 50);
395
+ const minYear = Math.min(rawMinYear, rawMaxYear, displayed.year());
396
+ const maxYear = Math.max(rawMinYear, rawMaxYear, displayed.year());
397
+ const updateNativeDate = (next) => {
398
+ let result = next;
399
+ if (props.minDate && result.isBefore(dayjs(props.minDate), "day")) result = dayjs(props.minDate);
400
+ if (props.maxDate && result.isAfter(dayjs(props.maxDate), "day")) result = dayjs(props.maxDate);
401
+ props.onDateChange?.(result.format("YYYY-MM-DD"));
402
+ };
403
+ const levelControl = (props.withNativeLevelSelect && props.date && props.onDateChange && props.calendarLevel !== "decade" ? h("div", {
404
+ class: Dates_module_default.calendarHeaderLevel,
405
+ "data-static": true,
406
+ "data-native-level-select": true
407
+ }, [props.calendarLevel === "month" ? h("select", {
408
+ class: Dates_module_default.calendarHeaderSelect,
409
+ "data-select": "month",
410
+ disabled: props.disableNativeLevelSelect,
411
+ value: displayed.month(),
412
+ "aria-label": props.levelControlAriaLabel,
413
+ onChange: (event) => updateNativeDate(displayed.month(Number(event.target.value)))
414
+ }, Array.from({ length: 12 }, (_, month) => h("option", { value: month }, dayjs().locale(props.locale || "en").month(month).format("MMMM")))) : null, h("select", {
415
+ class: Dates_module_default.calendarHeaderSelect,
416
+ "data-select": "year",
417
+ disabled: props.disableNativeLevelSelect,
418
+ value: displayed.year(),
419
+ "aria-label": props.levelControlAriaLabel,
420
+ onChange: (event) => updateNativeDate(displayed.year(Number(event.target.value)))
421
+ }, Array.from({ length: maxYear - minYear + 1 }, (_, index) => {
422
+ const year = minYear + index;
423
+ return h("option", { value: year }, year);
424
+ }))]) : null) ?? h(UnstyledButton, {
381
425
  component: props.hasNextLevel ? "button" : "div",
382
426
  class: Dates_module_default.calendarHeaderLevel,
383
427
  onClick: props.hasNextLevel ? props.onLevelClick : void 0,
@@ -434,6 +478,7 @@ var WeekdaysRow = defineComponent({
434
478
  });
435
479
  var Month = defineComponent({
436
480
  name: "Month",
481
+ slots: Object,
437
482
  props: {
438
483
  month: {
439
484
  type: String,
@@ -472,7 +517,7 @@ var Month = defineComponent({
472
517
  static: Boolean,
473
518
  fullWidth: Boolean
474
519
  },
475
- setup(props) {
520
+ setup(props, { slots }) {
476
521
  const ctx = useDatesContext();
477
522
  const hovered = ref(null);
478
523
  const dayRefs = [];
@@ -531,7 +576,7 @@ var Month = defineComponent({
531
576
  lastInRange: isSameDate(date, end),
532
577
  highlightToday: props.highlightToday,
533
578
  fullWidth: props.fullWidth,
534
- renderDay: props.renderDay,
579
+ renderDay: props.renderDay ?? (slots.renderDay ?? slots.day ? (date) => (slots.renderDay ?? slots.day)?.({ date }) : void 0),
535
580
  "aria-label": props.getDayAriaLabel?.(date),
536
581
  tabindex: props.static ? void 0 : date === dateInTabOrder ? 0 : -1,
537
582
  "data-autofocus": selected || void 0,
@@ -718,6 +763,7 @@ function clampLevel(level, minLevel, maxLevel) {
718
763
  }
719
764
  var Calendar = defineComponent({
720
765
  name: "Calendar",
766
+ slots: Object,
721
767
  props: {
722
768
  defaultLevel: String,
723
769
  level: String,
@@ -789,9 +835,11 @@ var Calendar = defineComponent({
789
835
  highlightToday: Boolean,
790
836
  withWeekNumbers: Boolean,
791
837
  static: Boolean,
792
- fullWidth: Boolean
838
+ fullWidth: Boolean,
839
+ withNativeLevelSelect: Boolean,
840
+ yearsSelectRange: Array
793
841
  },
794
- setup(props, { attrs }) {
842
+ setup(props, { attrs, slots }) {
795
843
  const [_level, setLevel] = useUncontrolled({
796
844
  value: computed(() => props.level === void 0 ? void 0 : clampLevel(props.level, props.minLevel, props.maxLevel)),
797
845
  defaultValue: props.defaultLevel === void 0 ? void 0 : clampLevel(props.defaultLevel, props.minLevel, props.maxLevel),
@@ -824,6 +872,15 @@ var Calendar = defineComponent({
824
872
  withPrevious: column === 0,
825
873
  withNext: column === (props.numberOfColumns || 1) - 1,
826
874
  fullWidth: props.fullWidth,
875
+ withNativeLevelSelect: props.withNativeLevelSelect,
876
+ yearsSelectRange: props.yearsSelectRange,
877
+ calendarLevel: "month",
878
+ date: currentDate,
879
+ locale: props.locale,
880
+ onDateChange: setDate,
881
+ minDate: props.minDate,
882
+ maxDate: props.maxDate,
883
+ disableNativeLevelSelect: props.date !== void 0 && !props.onDateChange,
827
884
  onPrevious: () => updateDate(-scroll, "month"),
828
885
  onNext: () => updateDate(scroll, "month"),
829
886
  onLevelClick: () => setLevel(getNextLevel(_level.value, "up"))
@@ -835,7 +892,7 @@ var Calendar = defineComponent({
835
892
  maxDate: props.maxDate,
836
893
  firstDayOfWeek: props.firstDayOfWeek,
837
894
  weekendDays: props.weekendDays,
838
- renderDay: props.renderDay,
895
+ renderDay: props.renderDay ?? (slots.renderDay ?? slots.day ? (date) => (slots.renderDay ?? slots.day)?.({ date }) : void 0),
839
896
  getDayProps: props.getDayProps,
840
897
  getDayAriaLabel: props.getDayAriaLabel,
841
898
  excludeDate: props.excludeDate,
@@ -854,6 +911,15 @@ var Calendar = defineComponent({
854
911
  withPrevious: column === 0,
855
912
  withNext: column === (props.numberOfColumns || 1) - 1,
856
913
  fullWidth: props.fullWidth,
914
+ withNativeLevelSelect: props.withNativeLevelSelect,
915
+ yearsSelectRange: props.yearsSelectRange,
916
+ calendarLevel: "year",
917
+ date: currentDate,
918
+ locale: props.locale,
919
+ onDateChange: setDate,
920
+ minDate: props.minDate,
921
+ maxDate: props.maxDate,
922
+ disableNativeLevelSelect: props.date !== void 0 && !props.onDateChange,
857
923
  onPrevious: () => updateDate(-scroll, "year"),
858
924
  onNext: () => updateDate(scroll, "year"),
859
925
  onLevelClick: () => setLevel(getNextLevel(_level.value, "up"))
@@ -927,11 +993,17 @@ function getNextPickerValue(value, date, type, sortDates = true) {
927
993
  }
928
994
  var DatePicker = defineComponent({
929
995
  name: "DatePicker",
996
+ slots: Object,
930
997
  props: {
931
998
  type: {
932
999
  type: String,
933
1000
  default: "default"
934
1001
  },
1002
+ modelValue: [
1003
+ String,
1004
+ Array,
1005
+ null
1006
+ ],
935
1007
  value: [
936
1008
  String,
937
1009
  Array,
@@ -951,15 +1023,21 @@ var DatePicker = defineComponent({
951
1023
  type: Boolean,
952
1024
  default: true
953
1025
  },
954
- presets: Array
1026
+ presets: Array,
1027
+ withNativeLevelSelect: Boolean,
1028
+ yearsSelectRange: Array
955
1029
  },
956
- setup(props, { attrs }) {
1030
+ emits: ["update:modelValue", "change"],
1031
+ setup(props, { attrs, slots, emit }) {
957
1032
  const finalValue = computed(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
958
1033
  const [_value, setValue] = useUncontrolled({
959
- value: computed(() => props.value),
1034
+ value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
960
1035
  defaultValue: props.defaultValue,
961
1036
  finalValue: finalValue.value,
962
- onChange: (value) => props.onChange?.(value)
1037
+ onChange: (value) => {
1038
+ emit("update:modelValue", value);
1039
+ emit("change", value);
1040
+ }
963
1041
  });
964
1042
  const selectDate = (date) => {
965
1043
  if (props.type === "default" && props.allowDeselect && isSameDate(_value.value, date)) setValue(null);
@@ -984,7 +1062,12 @@ var DatePicker = defineComponent({
984
1062
  onDateChange: (date) => calendarDate.value = date,
985
1063
  level: calendarLevel.value,
986
1064
  onLevelChange: (level) => calendarLevel.value = level,
1065
+ withNativeLevelSelect: props.withNativeLevelSelect,
1066
+ yearsSelectRange: props.yearsSelectRange,
987
1067
  onDayClick: selectDate
1068
+ }, {
1069
+ renderDay: slots.renderDay,
1070
+ day: slots.day
988
1071
  });
989
1072
  if (!props.presets?.length) return calendar;
990
1073
  return h("div", { class: Dates_module_default.datePickerRoot }, [h("div", { class: Dates_module_default.presetsList }, props.presets.map((preset, index) => h(UnstyledButton, {
@@ -1003,6 +1086,11 @@ var YearPicker = defineComponent({
1003
1086
  type: String,
1004
1087
  default: "default"
1005
1088
  },
1089
+ modelValue: [
1090
+ String,
1091
+ Array,
1092
+ null
1093
+ ],
1006
1094
  value: [
1007
1095
  String,
1008
1096
  Array,
@@ -1023,15 +1111,21 @@ var YearPicker = defineComponent({
1023
1111
  default: true
1024
1112
  },
1025
1113
  presets: Array,
1026
- onYearSelect: Function
1114
+ onYearSelect: Function,
1115
+ withNativeLevelSelect: Boolean,
1116
+ yearsSelectRange: Array
1027
1117
  },
1028
- setup(props, { attrs }) {
1118
+ emits: ["update:modelValue", "change"],
1119
+ setup(props, { attrs, emit }) {
1029
1120
  const finalValue = computed(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
1030
1121
  const [_value, setValue] = useUncontrolled({
1031
- value: computed(() => props.value),
1122
+ value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
1032
1123
  defaultValue: props.defaultValue,
1033
1124
  finalValue: finalValue.value,
1034
- onChange: (value) => props.onChange?.(value)
1125
+ onChange: (value) => {
1126
+ emit("update:modelValue", value);
1127
+ emit("change", value);
1128
+ }
1035
1129
  });
1036
1130
  const hoveredDate = ref(null);
1037
1131
  const selectYear = (date) => {
@@ -1067,6 +1161,8 @@ var YearPicker = defineComponent({
1067
1161
  onDateChange: (date) => calendarDate.value = date,
1068
1162
  defaultLevel: "decade",
1069
1163
  minLevel: "decade",
1164
+ withNativeLevelSelect: props.withNativeLevelSelect,
1165
+ yearsSelectRange: props.yearsSelectRange,
1070
1166
  onYearSelect: selectYear,
1071
1167
  getYearControlProps: yearControlProps,
1072
1168
  onYearMouseEnter: (date) => {
@@ -1094,6 +1190,11 @@ var MonthPicker = defineComponent({
1094
1190
  type: String,
1095
1191
  default: "default"
1096
1192
  },
1193
+ modelValue: [
1194
+ String,
1195
+ Array,
1196
+ null
1197
+ ],
1097
1198
  value: [
1098
1199
  String,
1099
1200
  Array,
@@ -1114,15 +1215,21 @@ var MonthPicker = defineComponent({
1114
1215
  default: true
1115
1216
  },
1116
1217
  presets: Array,
1117
- onMonthSelect: Function
1218
+ onMonthSelect: Function,
1219
+ withNativeLevelSelect: Boolean,
1220
+ yearsSelectRange: Array
1118
1221
  },
1119
- setup(props, { attrs }) {
1222
+ emits: ["update:modelValue", "change"],
1223
+ setup(props, { attrs, emit }) {
1120
1224
  const finalValue = computed(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
1121
1225
  const [_value, setValue] = useUncontrolled({
1122
- value: computed(() => props.value),
1226
+ value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
1123
1227
  defaultValue: props.defaultValue,
1124
1228
  finalValue: finalValue.value,
1125
- onChange: (value) => props.onChange?.(value)
1229
+ onChange: (value) => {
1230
+ emit("update:modelValue", value);
1231
+ emit("change", value);
1232
+ }
1126
1233
  });
1127
1234
  const hoveredDate = ref(null);
1128
1235
  const selectMonth = (date) => {
@@ -1158,6 +1265,8 @@ var MonthPicker = defineComponent({
1158
1265
  onDateChange: (date) => calendarDate.value = date,
1159
1266
  defaultLevel: "year",
1160
1267
  minLevel: "year",
1268
+ withNativeLevelSelect: props.withNativeLevelSelect,
1269
+ yearsSelectRange: props.yearsSelectRange,
1161
1270
  onMonthSelect: selectMonth,
1162
1271
  getMonthControlProps: monthControlProps,
1163
1272
  onMonthMouseEnter: (date) => {
@@ -1275,6 +1384,11 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
1275
1384
  type: String,
1276
1385
  default: "default"
1277
1386
  },
1387
+ modelValue: [
1388
+ String,
1389
+ Array,
1390
+ null
1391
+ ],
1278
1392
  value: [
1279
1393
  String,
1280
1394
  Array,
@@ -1311,15 +1425,21 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
1311
1425
  type: Boolean,
1312
1426
  default: true
1313
1427
  },
1314
- valueFormatter: Function
1428
+ valueFormatter: Function,
1429
+ withNativeLevelSelect: Boolean,
1430
+ yearsSelectRange: Array
1315
1431
  },
1316
- setup(props, { attrs }) {
1432
+ emits: ["update:modelValue", "change"],
1433
+ setup(props, { attrs, emit }) {
1317
1434
  const finalValue = computed(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
1318
1435
  const [_value, setValue] = useUncontrolled({
1319
- value: computed(() => props.value),
1436
+ value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
1320
1437
  defaultValue: props.defaultValue,
1321
1438
  finalValue: finalValue.value,
1322
- onChange: (value) => props.onChange?.(value)
1439
+ onChange: (value) => {
1440
+ emit("update:modelValue", value);
1441
+ emit("change", value);
1442
+ }
1323
1443
  });
1324
1444
  const opened = ref(false);
1325
1445
  const formattedValue = computed(() => formatValue(_value.value, props.type, props.valueFormat, props.locale, props.labelSeparator, props.valueFormatter));
@@ -1340,6 +1460,8 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
1340
1460
  sortDates: props.sortDates,
1341
1461
  defaultLevel,
1342
1462
  locale: props.locale,
1463
+ withNativeLevelSelect: props.withNativeLevelSelect,
1464
+ yearsSelectRange: props.yearsSelectRange,
1343
1465
  onChange: (value) => {
1344
1466
  setValue(value);
1345
1467
  if (props.closeOnChange && props.type === "default") close();
@@ -1383,6 +1505,11 @@ var DateInput = defineComponent({
1383
1505
  name: "DateInput",
1384
1506
  inheritAttrs: false,
1385
1507
  props: {
1508
+ modelValue: [
1509
+ String,
1510
+ Date,
1511
+ null
1512
+ ],
1386
1513
  value: [
1387
1514
  String,
1388
1515
  Date,
@@ -1405,12 +1532,19 @@ var DateInput = defineComponent({
1405
1532
  maxDate: [String, Date],
1406
1533
  presets: Array
1407
1534
  },
1408
- setup(props, { attrs }) {
1535
+ emits: ["update:modelValue", "change"],
1536
+ setup(props, { attrs, emit }) {
1409
1537
  const [_value, setValue] = useUncontrolled({
1410
- value: computed(() => props.value === void 0 ? void 0 : normalizeDate(props.value)),
1538
+ value: computed(() => {
1539
+ const controlledValue = props.modelValue !== void 0 ? props.modelValue : props.value;
1540
+ return controlledValue === void 0 ? void 0 : normalizeDate(controlledValue);
1541
+ }),
1411
1542
  defaultValue: normalizeDate(props.defaultValue),
1412
1543
  finalValue: null,
1413
- onChange: (value) => props.onChange?.(value)
1544
+ onChange: (value) => {
1545
+ emit("update:modelValue", value);
1546
+ emit("change", value);
1547
+ }
1414
1548
  });
1415
1549
  const formatValue = (value) => value ? dayjs(value).locale(props.locale || "en").format(props.valueFormat) : "";
1416
1550
  const inputValue = ref(formatValue(_value.value));
@@ -1582,18 +1716,22 @@ var TimeInput = defineComponent({
1582
1716
  name: "TimeInput",
1583
1717
  props: {
1584
1718
  withSeconds: Boolean,
1719
+ modelValue: String,
1585
1720
  value: String,
1586
1721
  defaultValue: String,
1587
1722
  onChange: Function
1588
1723
  },
1589
- setup(props, { attrs }) {
1724
+ emits: ["update:modelValue", "change"],
1725
+ setup(props, { attrs, emit }) {
1590
1726
  return () => h(InputBase, {
1591
1727
  ...attrs,
1592
1728
  type: "time",
1593
1729
  step: props.withSeconds ? 1 : 60,
1730
+ modelValue: props.modelValue,
1594
1731
  value: props.value,
1595
1732
  defaultValue: props.defaultValue,
1596
- onChange: props.onChange
1733
+ "onUpdate:modelValue": (value) => emit("update:modelValue", value),
1734
+ onChange: (value) => emit("change", value)
1597
1735
  });
1598
1736
  }
1599
1737
  });
@@ -1604,6 +1742,7 @@ var TimeGrid = defineComponent({
1604
1742
  type: Array,
1605
1743
  default: () => []
1606
1744
  },
1745
+ modelValue: String,
1607
1746
  value: String,
1608
1747
  defaultValue: String,
1609
1748
  minTime: String,
@@ -1613,12 +1752,16 @@ var TimeGrid = defineComponent({
1613
1752
  onChange: Function,
1614
1753
  getControlProps: Function
1615
1754
  },
1616
- setup(props, { attrs }) {
1755
+ emits: ["update:modelValue", "change"],
1756
+ setup(props, { attrs, emit }) {
1617
1757
  const [_value, setValue] = useUncontrolled({
1618
- value: computed(() => props.value),
1758
+ value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
1619
1759
  defaultValue: props.defaultValue,
1620
1760
  finalValue: null,
1621
- onChange: (value) => props.onChange?.(value)
1761
+ onChange: (value) => {
1762
+ emit("update:modelValue", value);
1763
+ emit("change", value);
1764
+ }
1622
1765
  });
1623
1766
  return () => h(Box, {
1624
1767
  ...attrs,
@@ -1651,9 +1794,17 @@ var SpinInput = defineComponent({
1651
1794
  name: "SpinInput",
1652
1795
  inheritAttrs: false,
1653
1796
  props: {
1797
+ modelValue: {
1798
+ type: Number,
1799
+ default: void 0
1800
+ },
1654
1801
  value: {
1655
1802
  type: Number,
1656
- default: null
1803
+ default: void 0
1804
+ },
1805
+ defaultValue: {
1806
+ type: Number,
1807
+ default: void 0
1657
1808
  },
1658
1809
  min: {
1659
1810
  type: Number,
@@ -1679,8 +1830,19 @@ var SpinInput = defineComponent({
1679
1830
  disabled: Boolean,
1680
1831
  readOnly: Boolean
1681
1832
  },
1682
- setup(props, { attrs }) {
1683
- const maxDigit = () => Number(props.max.toFixed(0)[0]);
1833
+ emits: ["update:modelValue", "change"],
1834
+ setup(props, { attrs, emit }) {
1835
+ const [value, setValue] = useUncontrolled({
1836
+ value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
1837
+ defaultValue: props.defaultValue,
1838
+ finalValue: null,
1839
+ onChange: (nextValue) => {
1840
+ emit("update:modelValue", nextValue);
1841
+ emit("change", nextValue);
1842
+ }
1843
+ });
1844
+ const finiteMax = () => Number.isFinite(props.max);
1845
+ const maxDigit = () => finiteMax() ? Number(props.max.toFixed(0)[0]) : Infinity;
1684
1846
  const arrowsMax = () => props.max + 1 - props.step;
1685
1847
  const handleChange = (raw) => {
1686
1848
  if (props.readOnly) return;
@@ -1690,10 +1852,10 @@ var SpinInput = defineComponent({
1690
1852
  for (let i = 0; i < clearValue.length; i += 1) {
1691
1853
  const digit = clearValue.charCodeAt(i) - 48;
1692
1854
  const next = parsedValue * 10 + digit;
1693
- parsedValue = next > props.max ? digit : next;
1855
+ parsedValue = finiteMax() && next > props.max ? digit : next;
1694
1856
  }
1695
- const clampedValue = props.allowTemporaryZero && parsedValue === 0 && props.min > 0 ? 0 : Math.min(Math.max(parsedValue, props.min), props.max);
1696
- props.onChange?.(clampedValue);
1857
+ 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);
1858
+ setValue(clampedValue);
1697
1859
  if (!props.disableAutoAdvance && (clampedValue > maxDigit() || raw.startsWith("00"))) props.onNextInput?.();
1698
1860
  };
1699
1861
  const handleKeydown = (event) => {
@@ -1701,22 +1863,22 @@ var SpinInput = defineComponent({
1701
1863
  if (event.key === "0" || event.key === "Num0") {
1702
1864
  const { selectionStart, selectionEnd, value: inputValue } = event.currentTarget;
1703
1865
  const isEntireValueSelected = inputValue.length > 0 && selectionStart === 0 && selectionEnd === inputValue.length;
1704
- if (props.value === 0 && !isEntireValueSelected) {
1866
+ if (value.value === 0 && !isEntireValueSelected) {
1705
1867
  event.preventDefault();
1706
1868
  props.onNextInput?.();
1707
1869
  }
1708
1870
  }
1709
1871
  if (event.key === "Home") {
1710
1872
  event.preventDefault();
1711
- props.onChange?.(props.min);
1873
+ setValue(props.min);
1712
1874
  }
1713
1875
  if (event.key === "End") {
1714
1876
  event.preventDefault();
1715
- props.onChange?.(props.max);
1877
+ if (finiteMax()) setValue(props.max);
1716
1878
  }
1717
1879
  if (event.key === "Backspace" || event.key === "Delete") {
1718
1880
  event.preventDefault();
1719
- if (props.value !== null) props.onChange?.(null);
1881
+ if (value.value !== null) setValue(null);
1720
1882
  else props.onPreviousInput?.();
1721
1883
  }
1722
1884
  if (event.key === "ArrowRight") {
@@ -1729,13 +1891,11 @@ var SpinInput = defineComponent({
1729
1891
  }
1730
1892
  if (event.key === "ArrowUp") {
1731
1893
  event.preventDefault();
1732
- const newValue = props.value === null ? props.min : Math.min(Math.max(props.value + props.step, props.min), arrowsMax());
1733
- props.onChange?.(newValue);
1894
+ 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));
1734
1895
  }
1735
1896
  if (event.key === "ArrowDown") {
1736
1897
  event.preventDefault();
1737
- const newValue = props.value === null ? arrowsMax() : Math.min(Math.max(props.value - props.step, props.min), arrowsMax());
1738
- props.onChange?.(newValue);
1898
+ setValue(value.value === null ? finiteMax() ? arrowsMax() : props.min : Math.min(Math.max(value.value - props.step, props.min), arrowsMax()));
1739
1899
  }
1740
1900
  };
1741
1901
  return () => h("input", {
@@ -1743,14 +1903,14 @@ var SpinInput = defineComponent({
1743
1903
  type: "text",
1744
1904
  role: "spinbutton",
1745
1905
  "aria-valuemin": props.min,
1746
- "aria-valuemax": props.max,
1747
- "aria-valuenow": props.value === null ? 0 : props.value,
1748
- "data-empty": props.value === null || void 0,
1906
+ "aria-valuemax": finiteMax() ? props.max : void 0,
1907
+ "aria-valuenow": value.value === null ? 0 : value.value,
1908
+ "data-empty": value.value === null || void 0,
1749
1909
  inputmode: "numeric",
1750
1910
  placeholder: props.placeholder,
1751
1911
  disabled: props.disabled,
1752
1912
  readonly: props.readOnly,
1753
- value: props.value === null ? "" : padTime(props.value),
1913
+ value: value.value === null ? "" : padTime(value.value),
1754
1914
  onInput: (event) => handleChange(event.target.value),
1755
1915
  onKeydown: handleKeydown,
1756
1916
  onFocus: (event) => event.target.select(),
@@ -1765,9 +1925,17 @@ var SpinInput = defineComponent({
1765
1925
  var AmPmInput = defineComponent({
1766
1926
  name: "AmPmInput",
1767
1927
  props: {
1928
+ modelValue: {
1929
+ type: String,
1930
+ default: void 0
1931
+ },
1768
1932
  value: {
1769
1933
  type: String,
1770
- default: null
1934
+ default: void 0
1935
+ },
1936
+ defaultValue: {
1937
+ type: String,
1938
+ default: void 0
1771
1939
  },
1772
1940
  labels: {
1773
1941
  type: Object,
@@ -1777,14 +1945,24 @@ var AmPmInput = defineComponent({
1777
1945
  disabled: Boolean,
1778
1946
  readOnly: Boolean
1779
1947
  },
1780
- setup(props, { attrs }) {
1948
+ emits: ["update:modelValue", "change"],
1949
+ setup(props, { attrs, emit }) {
1950
+ const [value, setValue] = useUncontrolled({
1951
+ value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
1952
+ defaultValue: props.defaultValue,
1953
+ finalValue: null,
1954
+ onChange: (nextValue) => {
1955
+ emit("update:modelValue", nextValue);
1956
+ emit("change", nextValue);
1957
+ }
1958
+ });
1781
1959
  return () => h("select", {
1782
1960
  ...attrs,
1783
1961
  class: Dates_module_default.timePickerField,
1784
1962
  "data-am-pm": true,
1785
1963
  disabled: props.disabled,
1786
- value: props.value ?? props.labels.am,
1787
- onChange: (event) => props.onChange?.(event.target.value)
1964
+ value: value.value ?? props.labels.am,
1965
+ onChange: (event) => setValue(event.target.value)
1788
1966
  }, [h("option", { value: props.labels.am }, props.labels.am), h("option", { value: props.labels.pm }, props.labels.pm)]);
1789
1967
  }
1790
1968
  });
@@ -1822,9 +2000,14 @@ var TimeControlsList = defineComponent({
1822
2000
  var TimePicker = defineComponent({
1823
2001
  name: "TimePicker",
1824
2002
  props: {
2003
+ modelValue: String,
1825
2004
  value: String,
1826
2005
  defaultValue: String,
1827
2006
  onChange: Function,
2007
+ type: {
2008
+ type: String,
2009
+ default: "time"
2010
+ },
1828
2011
  withSeconds: Boolean,
1829
2012
  min: String,
1830
2013
  max: String,
@@ -1860,16 +2043,21 @@ var TimePicker = defineComponent({
1860
2043
  closeDropdownOnPresetSelect: Boolean,
1861
2044
  hoursRef: Object
1862
2045
  },
1863
- setup(props, { attrs }) {
2046
+ emits: ["update:modelValue", "change"],
2047
+ setup(props, { attrs, emit }) {
2048
+ const effectiveFormat = computed(() => props.type === "duration" ? "24h" : props.format);
1864
2049
  const [_value, setValue] = useUncontrolled({
1865
- value: computed(() => props.value),
2050
+ value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
1866
2051
  defaultValue: props.defaultValue,
1867
2052
  finalValue: "",
1868
- onChange: (value) => props.onChange?.(value)
2053
+ onChange: (value) => {
2054
+ emit("update:modelValue", value);
2055
+ emit("change", value);
2056
+ }
1869
2057
  });
1870
2058
  const parsed = computed(() => getParsedTime({
1871
2059
  time: _value.value,
1872
- format: props.format,
2060
+ format: effectiveFormat.value,
1873
2061
  amPmLabels: props.amPmLabels
1874
2062
  }));
1875
2063
  const hours = ref(parsed.value.hours);
@@ -1879,7 +2067,7 @@ var TimePicker = defineComponent({
1879
2067
  watch(_value, (value) => {
1880
2068
  const next = getParsedTime({
1881
2069
  time: value,
1882
- format: props.format,
2070
+ format: effectiveFormat.value,
1883
2071
  amPmLabels: props.amPmLabels
1884
2072
  });
1885
2073
  hours.value = next.hours;
@@ -1905,7 +2093,7 @@ var TimePicker = defineComponent({
1905
2093
  hours: hours.value,
1906
2094
  minutes: minutes.value,
1907
2095
  seconds: seconds.value,
1908
- format: props.format,
2096
+ format: effectiveFormat.value,
1909
2097
  withSeconds: props.withSeconds,
1910
2098
  amPm: amPm.value,
1911
2099
  amPmLabels: props.amPmLabels
@@ -1914,7 +2102,7 @@ var TimePicker = defineComponent({
1914
2102
  };
1915
2103
  const setHours = (value) => {
1916
2104
  let adjusted = value;
1917
- if (props.format === "12h" && typeof value === "number" && value > 12) adjusted = (value - 1) % 12 + 1;
2105
+ if (effectiveFormat.value === "12h" && typeof value === "number" && value > 12) adjusted = (value - 1) % 12 + 1;
1918
2106
  hours.value = adjusted;
1919
2107
  commit();
1920
2108
  focus("hours");
@@ -1948,8 +2136,32 @@ var TimePicker = defineComponent({
1948
2136
  setValue(timeString);
1949
2137
  if (props.closeDropdownOnPresetSelect) opened.value = false;
1950
2138
  };
2139
+ const handlePaste = (event) => {
2140
+ if (props.readOnly || props.disabled) return;
2141
+ const value = event.clipboardData?.getData("text").trim();
2142
+ if (!value || !/^\d+:\d{2}(?::\d{2})?(?:\s+[aApP][mM])?$/.test(value)) return;
2143
+ const next = getParsedTime({
2144
+ time: value,
2145
+ format: effectiveFormat.value,
2146
+ amPmLabels: props.amPmLabels
2147
+ });
2148
+ 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;
2149
+ event.preventDefault();
2150
+ hours.value = next.hours;
2151
+ minutes.value = next.minutes;
2152
+ seconds.value = props.withSeconds ? next.seconds : null;
2153
+ amPm.value = next.amPm;
2154
+ const result = getTimeString({
2155
+ ...next,
2156
+ seconds: props.withSeconds ? next.seconds : null,
2157
+ format: effectiveFormat.value,
2158
+ withSeconds: props.withSeconds,
2159
+ amPmLabels: props.amPmLabels
2160
+ });
2161
+ if (result.valid) setValue(clampTime(result.value, props.min, props.max));
2162
+ };
1951
2163
  return () => h(Popover, {
1952
- opened: props.withDropdown && opened.value,
2164
+ opened: props.type !== "duration" && props.withDropdown && opened.value,
1953
2165
  position: "bottom-start",
1954
2166
  transitionProps: { duration: 0 }
1955
2167
  }, () => [h(Popover.Target, null, () => h(InputBase, {
@@ -1959,11 +2171,11 @@ var TimePicker = defineComponent({
1959
2171
  disabled: props.disabled,
1960
2172
  onClick: () => {
1961
2173
  focus("hours");
1962
- if (props.withDropdown) opened.value = true;
2174
+ if (props.type !== "duration" && props.withDropdown) opened.value = true;
1963
2175
  },
1964
2176
  onMousedown: (event) => event.preventDefault(),
1965
2177
  onFocusin: () => {
1966
- if (props.withDropdown) opened.value = true;
2178
+ if (props.type !== "duration" && props.withDropdown) opened.value = true;
1967
2179
  },
1968
2180
  onFocusout: () => {
1969
2181
  if (props.withDropdown) opened.value = false;
@@ -1982,12 +2194,14 @@ var TimePicker = defineComponent({
1982
2194
  ref: hoursRef,
1983
2195
  class: Dates_module_default.timePickerField,
1984
2196
  value: hours.value,
1985
- min: props.format === "12h" ? 1 : 0,
1986
- max: props.format === "12h" ? 12 : 23,
2197
+ min: effectiveFormat.value === "12h" ? 1 : 0,
2198
+ max: props.type === "duration" ? Infinity : effectiveFormat.value === "12h" ? 12 : 23,
1987
2199
  step: props.hoursStep,
1988
2200
  onChange: setHours,
1989
2201
  onNextInput: () => focus("minutes"),
1990
- allowTemporaryZero: props.format === "12h",
2202
+ allowTemporaryZero: effectiveFormat.value === "12h",
2203
+ disableAutoAdvance: props.type === "duration",
2204
+ onPaste: handlePaste,
1991
2205
  readOnly: props.readOnly,
1992
2206
  disabled: props.disabled,
1993
2207
  placeholder: "--"
@@ -2022,7 +2236,7 @@ var TimePicker = defineComponent({
2022
2236
  disabled: props.disabled,
2023
2237
  placeholder: "--"
2024
2238
  }) : null,
2025
- props.format === "12h" ? h(AmPmInput, {
2239
+ effectiveFormat.value === "12h" ? h(AmPmInput, {
2026
2240
  ref: amPmRef,
2027
2241
  value: amPm.value,
2028
2242
  labels: props.amPmLabels,
@@ -2042,8 +2256,8 @@ var TimePicker = defineComponent({
2042
2256
  onClick: () => handlePresetSelect(preset.value)
2043
2257
  }, () => preset.label))) : h("div", { class: Dates_module_default.timePickerControlsListGroup }, [
2044
2258
  h(TimeControlsList, {
2045
- min: props.format === "12h" ? 1 : 0,
2046
- max: props.format === "12h" ? 12 : 23,
2259
+ min: effectiveFormat.value === "12h" ? 1 : 0,
2260
+ max: effectiveFormat.value === "12h" ? 12 : 23,
2047
2261
  step: props.hoursStep,
2048
2262
  value: hours.value,
2049
2263
  onSelect: setHours
@@ -2085,6 +2299,11 @@ var TimeValue = defineComponent({
2085
2299
  var DateTimePicker = defineComponent({
2086
2300
  name: "DateTimePicker",
2087
2301
  props: {
2302
+ modelValue: [
2303
+ String,
2304
+ Date,
2305
+ null
2306
+ ],
2088
2307
  value: [
2089
2308
  String,
2090
2309
  Date,
@@ -2108,13 +2327,20 @@ var DateTimePicker = defineComponent({
2108
2327
  },
2109
2328
  submitButtonProps: Object
2110
2329
  },
2111
- setup(props, { attrs }) {
2330
+ emits: ["update:modelValue", "change"],
2331
+ setup(props, { attrs, emit }) {
2112
2332
  const hoursRef = ref();
2113
2333
  const [_value, setValue] = useUncontrolled({
2114
- value: computed(() => props.value === void 0 ? void 0 : props.value === null ? null : new Date(props.value)),
2334
+ value: computed(() => {
2335
+ const controlledValue = props.modelValue !== void 0 ? props.modelValue : props.value;
2336
+ return controlledValue === void 0 ? void 0 : controlledValue === null ? null : new Date(controlledValue);
2337
+ }),
2115
2338
  defaultValue: props.defaultValue ? new Date(props.defaultValue) : null,
2116
2339
  finalValue: null,
2117
- onChange: (value) => props.onChange?.(value)
2340
+ onChange: (value) => {
2341
+ emit("update:modelValue", value);
2342
+ emit("change", value);
2343
+ }
2118
2344
  });
2119
2345
  const date = computed(() => _value.value ? dayjs(_value.value).format("YYYY-MM-DD") : null);
2120
2346
  const time = computed(() => _value.value ? dayjs(_value.value).format(props.withSeconds ? "HH:mm:ss" : "HH:mm") : "");
@@ -2160,11 +2386,21 @@ var MiniCalendar = defineComponent({
2160
2386
  date: [String, Date],
2161
2387
  defaultDate: [String, Date],
2162
2388
  onDateChange: Function,
2389
+ modelValue: [
2390
+ String,
2391
+ Date,
2392
+ null
2393
+ ],
2163
2394
  value: [
2164
2395
  String,
2165
2396
  Date,
2166
2397
  null
2167
2398
  ],
2399
+ defaultValue: [
2400
+ String,
2401
+ Date,
2402
+ null
2403
+ ],
2168
2404
  onChange: Function,
2169
2405
  maxDate: [String, Date],
2170
2406
  minDate: [String, Date],
@@ -2187,12 +2423,25 @@ var MiniCalendar = defineComponent({
2187
2423
  nextControlProps: Object,
2188
2424
  locale: String
2189
2425
  },
2190
- setup(props, { attrs }) {
2426
+ emits: ["update:modelValue", "change"],
2427
+ setup(props, { attrs, emit }) {
2191
2428
  const ctx = useDatesContext();
2429
+ const [value, setValue] = useUncontrolled({
2430
+ value: computed(() => {
2431
+ const controlledValue = props.modelValue !== void 0 ? props.modelValue : props.value;
2432
+ return controlledValue === void 0 ? void 0 : toDateString(controlledValue);
2433
+ }),
2434
+ defaultValue: toDateString(props.defaultValue ?? null),
2435
+ finalValue: null,
2436
+ onChange: (nextValue) => {
2437
+ emit("update:modelValue", nextValue);
2438
+ emit("change", nextValue);
2439
+ }
2440
+ });
2192
2441
  const [_date, setDate] = useUncontrolled({
2193
2442
  value: computed(() => toDateString(props.date ?? null) ?? void 0),
2194
2443
  defaultValue: toDateString(props.defaultDate ?? null) ?? void 0,
2195
- finalValue: toDateString(props.value ?? null) || dayjs().format("YYYY-MM-DD"),
2444
+ finalValue: value.value || dayjs().format("YYYY-MM-DD"),
2196
2445
  onChange: (value) => props.onDateChange?.(value)
2197
2446
  });
2198
2447
  const handleNext = () => {
@@ -2214,12 +2463,12 @@ var MiniCalendar = defineComponent({
2214
2463
  disabled,
2215
2464
  "aria-label": date.format("YYYY-MM-DD"),
2216
2465
  "data-disabled": disabled || void 0,
2217
- "data-selected": props.value && dayjs(date).isSame(props.value, "day") || void 0,
2466
+ "data-selected": value.value && dayjs(date).isSame(value.value, "day") || void 0,
2218
2467
  ...dayProps,
2219
2468
  class: [Dates_module_default.miniCalendarDay, dayProps.class],
2220
2469
  onClick: (event) => {
2221
2470
  dayProps.onClick?.(event);
2222
- props.onChange?.(toDateString(date.format("YYYY-MM-DD")));
2471
+ setValue(toDateString(date.format("YYYY-MM-DD")));
2223
2472
  }
2224
2473
  }, () => [h("span", { class: Dates_module_default.miniCalendarDayMonth }, date.locale(props.locale || ctx.locale).format(props.monthLabelFormat)), h("span", { class: Dates_module_default.miniCalendarDayNumber }, String(date.date()))]);
2225
2474
  });