@mantine-vue/dates 2.3.1 → 2.4.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 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: "_calendar_5kwje_1",
33
- calendarLevel: "_calendarLevel_5kwje_15",
34
- calendarHeader: "_calendarHeader_5kwje_19",
35
- calendarHeaderLevel: "_calendarHeaderLevel_5kwje_32",
36
- calendarHeaderControl: "_calendarHeaderControl_5kwje_33",
37
- calendarHeaderControlIcon: "_calendarHeaderControlIcon_5kwje_74",
38
- month: "_month_5kwje_87",
39
- monthRow: "_monthRow_5kwje_97",
40
- monthCell: "_monthCell_5kwje_101",
41
- weekday: "_weekday_5kwje_110",
42
- weekNumber: "_weekNumber_5kwje_122",
43
- day: "_day_5kwje_128",
44
- pickerControl: "_pickerControl_5kwje_189",
45
- controlsGrid: "_controlsGrid_5kwje_195",
46
- timePicker: "_timePicker_5kwje_255",
47
- dateTimePicker: "_dateTimePicker_5kwje_256",
48
- datePickerRoot: "_datePickerRoot_5kwje_260",
49
- timeWrapper: "_timeWrapper_5kwje_270",
50
- timeInput: "_timeInput_5kwje_276",
51
- presetsList: "_presetsList_5kwje_281",
52
- presetButton: "_presetButton_5kwje_289",
53
- timePickerPresetsGroup: "_timePickerPresetsGroup_5kwje_300",
54
- dropdown: "_dropdown_5kwje_304",
55
- placeholder: "_placeholder_5kwje_308",
56
- timeGridControl: "_timeGridControl_5kwje_312",
57
- timePickerFieldsRoot: "_timePickerFieldsRoot_5kwje_343",
58
- timePickerFieldsGroup: "_timePickerFieldsGroup_5kwje_350",
59
- timePickerField: "_timePickerField_5kwje_343",
60
- timePickerDropdown: "_timePickerDropdown_5kwje_400",
61
- timePickerControlsListGroup: "_timePickerControlsListGroup_5kwje_404",
62
- timePickerControlsList: "_timePickerControlsList_5kwje_404",
63
- timePickerControl: "_timePickerControl_5kwje_404",
64
- miniCalendarRoot: "_miniCalendarRoot_5kwje_433",
65
- miniCalendarDays: "_miniCalendarDays_5kwje_440",
66
- miniCalendarDay: "_miniCalendarDay_5kwje_440",
67
- miniCalendarDayMonth: "_miniCalendarDayMonth_5kwje_475",
68
- miniCalendarDayNumber: "_miniCalendarDayNumber_5kwje_481",
69
- miniCalendarControl: "_miniCalendarControl_5kwje_486"
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 levelControl = (0, vue.h)(_mantine_vue_core.UnstyledButton, {
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,6 +1018,7 @@ 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,
@@ -976,9 +1043,11 @@ var DatePicker = (0, vue.defineComponent)({
976
1043
  type: Boolean,
977
1044
  default: true
978
1045
  },
979
- presets: Array
1046
+ presets: Array,
1047
+ withNativeLevelSelect: Boolean,
1048
+ yearsSelectRange: Array
980
1049
  },
981
- setup(props, { attrs }) {
1050
+ setup(props, { attrs, slots }) {
982
1051
  const finalValue = (0, vue.computed)(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
983
1052
  const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
984
1053
  value: (0, vue.computed)(() => props.value),
@@ -1009,7 +1078,12 @@ var DatePicker = (0, vue.defineComponent)({
1009
1078
  onDateChange: (date) => calendarDate.value = date,
1010
1079
  level: calendarLevel.value,
1011
1080
  onLevelChange: (level) => calendarLevel.value = level,
1081
+ withNativeLevelSelect: props.withNativeLevelSelect,
1082
+ yearsSelectRange: props.yearsSelectRange,
1012
1083
  onDayClick: selectDate
1084
+ }, {
1085
+ renderDay: slots.renderDay,
1086
+ day: slots.day
1013
1087
  });
1014
1088
  if (!props.presets?.length) return calendar;
1015
1089
  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, {
@@ -1048,7 +1122,9 @@ var YearPicker = (0, vue.defineComponent)({
1048
1122
  default: true
1049
1123
  },
1050
1124
  presets: Array,
1051
- onYearSelect: Function
1125
+ onYearSelect: Function,
1126
+ withNativeLevelSelect: Boolean,
1127
+ yearsSelectRange: Array
1052
1128
  },
1053
1129
  setup(props, { attrs }) {
1054
1130
  const finalValue = (0, vue.computed)(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
@@ -1092,6 +1168,8 @@ var YearPicker = (0, vue.defineComponent)({
1092
1168
  onDateChange: (date) => calendarDate.value = date,
1093
1169
  defaultLevel: "decade",
1094
1170
  minLevel: "decade",
1171
+ withNativeLevelSelect: props.withNativeLevelSelect,
1172
+ yearsSelectRange: props.yearsSelectRange,
1095
1173
  onYearSelect: selectYear,
1096
1174
  getYearControlProps: yearControlProps,
1097
1175
  onYearMouseEnter: (date) => {
@@ -1139,7 +1217,9 @@ var MonthPicker = (0, vue.defineComponent)({
1139
1217
  default: true
1140
1218
  },
1141
1219
  presets: Array,
1142
- onMonthSelect: Function
1220
+ onMonthSelect: Function,
1221
+ withNativeLevelSelect: Boolean,
1222
+ yearsSelectRange: Array
1143
1223
  },
1144
1224
  setup(props, { attrs }) {
1145
1225
  const finalValue = (0, vue.computed)(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
@@ -1183,6 +1263,8 @@ var MonthPicker = (0, vue.defineComponent)({
1183
1263
  onDateChange: (date) => calendarDate.value = date,
1184
1264
  defaultLevel: "year",
1185
1265
  minLevel: "year",
1266
+ withNativeLevelSelect: props.withNativeLevelSelect,
1267
+ yearsSelectRange: props.yearsSelectRange,
1186
1268
  onMonthSelect: selectMonth,
1187
1269
  getMonthControlProps: monthControlProps,
1188
1270
  onMonthMouseEnter: (date) => {
@@ -1336,7 +1418,9 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
1336
1418
  type: Boolean,
1337
1419
  default: true
1338
1420
  },
1339
- valueFormatter: Function
1421
+ valueFormatter: Function,
1422
+ withNativeLevelSelect: Boolean,
1423
+ yearsSelectRange: Array
1340
1424
  },
1341
1425
  setup(props, { attrs }) {
1342
1426
  const finalValue = (0, vue.computed)(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
@@ -1365,6 +1449,8 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
1365
1449
  sortDates: props.sortDates,
1366
1450
  defaultLevel,
1367
1451
  locale: props.locale,
1452
+ withNativeLevelSelect: props.withNativeLevelSelect,
1453
+ yearsSelectRange: props.yearsSelectRange,
1368
1454
  onChange: (value) => {
1369
1455
  setValue(value);
1370
1456
  if (props.closeOnChange && props.type === "default") close();
@@ -1705,7 +1791,8 @@ var SpinInput = (0, vue.defineComponent)({
1705
1791
  readOnly: Boolean
1706
1792
  },
1707
1793
  setup(props, { attrs }) {
1708
- const maxDigit = () => Number(props.max.toFixed(0)[0]);
1794
+ const finiteMax = () => Number.isFinite(props.max);
1795
+ const maxDigit = () => finiteMax() ? Number(props.max.toFixed(0)[0]) : Infinity;
1709
1796
  const arrowsMax = () => props.max + 1 - props.step;
1710
1797
  const handleChange = (raw) => {
1711
1798
  if (props.readOnly) return;
@@ -1715,9 +1802,9 @@ var SpinInput = (0, vue.defineComponent)({
1715
1802
  for (let i = 0; i < clearValue.length; i += 1) {
1716
1803
  const digit = clearValue.charCodeAt(i) - 48;
1717
1804
  const next = parsedValue * 10 + digit;
1718
- parsedValue = next > props.max ? digit : next;
1805
+ parsedValue = finiteMax() && next > props.max ? digit : next;
1719
1806
  }
1720
- const clampedValue = props.allowTemporaryZero && parsedValue === 0 && props.min > 0 ? 0 : Math.min(Math.max(parsedValue, props.min), props.max);
1807
+ 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);
1721
1808
  props.onChange?.(clampedValue);
1722
1809
  if (!props.disableAutoAdvance && (clampedValue > maxDigit() || raw.startsWith("00"))) props.onNextInput?.();
1723
1810
  };
@@ -1737,7 +1824,7 @@ var SpinInput = (0, vue.defineComponent)({
1737
1824
  }
1738
1825
  if (event.key === "End") {
1739
1826
  event.preventDefault();
1740
- props.onChange?.(props.max);
1827
+ if (finiteMax()) props.onChange?.(props.max);
1741
1828
  }
1742
1829
  if (event.key === "Backspace" || event.key === "Delete") {
1743
1830
  event.preventDefault();
@@ -1754,12 +1841,12 @@ var SpinInput = (0, vue.defineComponent)({
1754
1841
  }
1755
1842
  if (event.key === "ArrowUp") {
1756
1843
  event.preventDefault();
1757
- const newValue = props.value === null ? props.min : Math.min(Math.max(props.value + props.step, props.min), arrowsMax());
1844
+ const newValue = props.value === null ? props.min : finiteMax() ? Math.min(Math.max(props.value + props.step, props.min), arrowsMax()) : Math.max(props.value + props.step, props.min);
1758
1845
  props.onChange?.(newValue);
1759
1846
  }
1760
1847
  if (event.key === "ArrowDown") {
1761
1848
  event.preventDefault();
1762
- const newValue = props.value === null ? arrowsMax() : Math.min(Math.max(props.value - props.step, props.min), arrowsMax());
1849
+ const newValue = props.value === null ? finiteMax() ? arrowsMax() : props.min : Math.min(Math.max(props.value - props.step, props.min), arrowsMax());
1763
1850
  props.onChange?.(newValue);
1764
1851
  }
1765
1852
  };
@@ -1768,7 +1855,7 @@ var SpinInput = (0, vue.defineComponent)({
1768
1855
  type: "text",
1769
1856
  role: "spinbutton",
1770
1857
  "aria-valuemin": props.min,
1771
- "aria-valuemax": props.max,
1858
+ "aria-valuemax": finiteMax() ? props.max : void 0,
1772
1859
  "aria-valuenow": props.value === null ? 0 : props.value,
1773
1860
  "data-empty": props.value === null || void 0,
1774
1861
  inputmode: "numeric",
@@ -1850,6 +1937,10 @@ var TimePicker = (0, vue.defineComponent)({
1850
1937
  value: String,
1851
1938
  defaultValue: String,
1852
1939
  onChange: Function,
1940
+ type: {
1941
+ type: String,
1942
+ default: "time"
1943
+ },
1853
1944
  withSeconds: Boolean,
1854
1945
  min: String,
1855
1946
  max: String,
@@ -1886,6 +1977,7 @@ var TimePicker = (0, vue.defineComponent)({
1886
1977
  hoursRef: Object
1887
1978
  },
1888
1979
  setup(props, { attrs }) {
1980
+ const effectiveFormat = (0, vue.computed)(() => props.type === "duration" ? "24h" : props.format);
1889
1981
  const [_value, setValue] = (0, _mantine_vue_hooks.useUncontrolled)({
1890
1982
  value: (0, vue.computed)(() => props.value),
1891
1983
  defaultValue: props.defaultValue,
@@ -1894,7 +1986,7 @@ var TimePicker = (0, vue.defineComponent)({
1894
1986
  });
1895
1987
  const parsed = (0, vue.computed)(() => getParsedTime({
1896
1988
  time: _value.value,
1897
- format: props.format,
1989
+ format: effectiveFormat.value,
1898
1990
  amPmLabels: props.amPmLabels
1899
1991
  }));
1900
1992
  const hours = (0, vue.ref)(parsed.value.hours);
@@ -1904,7 +1996,7 @@ var TimePicker = (0, vue.defineComponent)({
1904
1996
  (0, vue.watch)(_value, (value) => {
1905
1997
  const next = getParsedTime({
1906
1998
  time: value,
1907
- format: props.format,
1999
+ format: effectiveFormat.value,
1908
2000
  amPmLabels: props.amPmLabels
1909
2001
  });
1910
2002
  hours.value = next.hours;
@@ -1930,7 +2022,7 @@ var TimePicker = (0, vue.defineComponent)({
1930
2022
  hours: hours.value,
1931
2023
  minutes: minutes.value,
1932
2024
  seconds: seconds.value,
1933
- format: props.format,
2025
+ format: effectiveFormat.value,
1934
2026
  withSeconds: props.withSeconds,
1935
2027
  amPm: amPm.value,
1936
2028
  amPmLabels: props.amPmLabels
@@ -1939,7 +2031,7 @@ var TimePicker = (0, vue.defineComponent)({
1939
2031
  };
1940
2032
  const setHours = (value) => {
1941
2033
  let adjusted = value;
1942
- if (props.format === "12h" && typeof value === "number" && value > 12) adjusted = (value - 1) % 12 + 1;
2034
+ if (effectiveFormat.value === "12h" && typeof value === "number" && value > 12) adjusted = (value - 1) % 12 + 1;
1943
2035
  hours.value = adjusted;
1944
2036
  commit();
1945
2037
  focus("hours");
@@ -1973,8 +2065,32 @@ var TimePicker = (0, vue.defineComponent)({
1973
2065
  setValue(timeString);
1974
2066
  if (props.closeDropdownOnPresetSelect) opened.value = false;
1975
2067
  };
2068
+ const handlePaste = (event) => {
2069
+ if (props.readOnly || props.disabled) return;
2070
+ const value = event.clipboardData?.getData("text").trim();
2071
+ if (!value || !/^\d+:\d{2}(?::\d{2})?(?:\s+[aApP][mM])?$/.test(value)) return;
2072
+ const next = getParsedTime({
2073
+ time: value,
2074
+ format: effectiveFormat.value,
2075
+ amPmLabels: props.amPmLabels
2076
+ });
2077
+ 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;
2078
+ event.preventDefault();
2079
+ hours.value = next.hours;
2080
+ minutes.value = next.minutes;
2081
+ seconds.value = props.withSeconds ? next.seconds : null;
2082
+ amPm.value = next.amPm;
2083
+ const result = getTimeString({
2084
+ ...next,
2085
+ seconds: props.withSeconds ? next.seconds : null,
2086
+ format: effectiveFormat.value,
2087
+ withSeconds: props.withSeconds,
2088
+ amPmLabels: props.amPmLabels
2089
+ });
2090
+ if (result.valid) setValue(clampTime(result.value, props.min, props.max));
2091
+ };
1976
2092
  return () => (0, vue.h)(_mantine_vue_core.Popover, {
1977
- opened: props.withDropdown && opened.value,
2093
+ opened: props.type !== "duration" && props.withDropdown && opened.value,
1978
2094
  position: "bottom-start",
1979
2095
  transitionProps: { duration: 0 }
1980
2096
  }, () => [(0, vue.h)(_mantine_vue_core.Popover.Target, null, () => (0, vue.h)(_mantine_vue_core.InputBase, {
@@ -1984,11 +2100,11 @@ var TimePicker = (0, vue.defineComponent)({
1984
2100
  disabled: props.disabled,
1985
2101
  onClick: () => {
1986
2102
  focus("hours");
1987
- if (props.withDropdown) opened.value = true;
2103
+ if (props.type !== "duration" && props.withDropdown) opened.value = true;
1988
2104
  },
1989
2105
  onMousedown: (event) => event.preventDefault(),
1990
2106
  onFocusin: () => {
1991
- if (props.withDropdown) opened.value = true;
2107
+ if (props.type !== "duration" && props.withDropdown) opened.value = true;
1992
2108
  },
1993
2109
  onFocusout: () => {
1994
2110
  if (props.withDropdown) opened.value = false;
@@ -2007,12 +2123,14 @@ var TimePicker = (0, vue.defineComponent)({
2007
2123
  ref: hoursRef,
2008
2124
  class: Dates_module_default.timePickerField,
2009
2125
  value: hours.value,
2010
- min: props.format === "12h" ? 1 : 0,
2011
- max: props.format === "12h" ? 12 : 23,
2126
+ min: effectiveFormat.value === "12h" ? 1 : 0,
2127
+ max: props.type === "duration" ? Infinity : effectiveFormat.value === "12h" ? 12 : 23,
2012
2128
  step: props.hoursStep,
2013
2129
  onChange: setHours,
2014
2130
  onNextInput: () => focus("minutes"),
2015
- allowTemporaryZero: props.format === "12h",
2131
+ allowTemporaryZero: effectiveFormat.value === "12h",
2132
+ disableAutoAdvance: props.type === "duration",
2133
+ onPaste: handlePaste,
2016
2134
  readOnly: props.readOnly,
2017
2135
  disabled: props.disabled,
2018
2136
  placeholder: "--"
@@ -2047,7 +2165,7 @@ var TimePicker = (0, vue.defineComponent)({
2047
2165
  disabled: props.disabled,
2048
2166
  placeholder: "--"
2049
2167
  }) : null,
2050
- props.format === "12h" ? (0, vue.h)(AmPmInput, {
2168
+ effectiveFormat.value === "12h" ? (0, vue.h)(AmPmInput, {
2051
2169
  ref: amPmRef,
2052
2170
  value: amPm.value,
2053
2171
  labels: props.amPmLabels,
@@ -2067,8 +2185,8 @@ var TimePicker = (0, vue.defineComponent)({
2067
2185
  onClick: () => handlePresetSelect(preset.value)
2068
2186
  }, () => preset.label))) : (0, vue.h)("div", { class: Dates_module_default.timePickerControlsListGroup }, [
2069
2187
  (0, vue.h)(TimeControlsList, {
2070
- min: props.format === "12h" ? 1 : 0,
2071
- max: props.format === "12h" ? 12 : 23,
2188
+ min: effectiveFormat.value === "12h" ? 1 : 0,
2189
+ max: effectiveFormat.value === "12h" ? 12 : 23,
2072
2190
  step: props.hoursStep,
2073
2191
  value: hours.value,
2074
2192
  onSelect: setHours