@mantine-vue/dates 2.4.0 → 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 +179 -48
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +179 -48
- package/esm/index.mjs.map +1 -1
- package/lib/index.d.mts +151 -42
- package/lib/index.d.ts +151 -42
- package/package.json +3 -3
package/esm/index.mjs
CHANGED
|
@@ -999,6 +999,11 @@ var DatePicker = defineComponent({
|
|
|
999
999
|
type: String,
|
|
1000
1000
|
default: "default"
|
|
1001
1001
|
},
|
|
1002
|
+
modelValue: [
|
|
1003
|
+
String,
|
|
1004
|
+
Array,
|
|
1005
|
+
null
|
|
1006
|
+
],
|
|
1002
1007
|
value: [
|
|
1003
1008
|
String,
|
|
1004
1009
|
Array,
|
|
@@ -1022,13 +1027,17 @@ var DatePicker = defineComponent({
|
|
|
1022
1027
|
withNativeLevelSelect: Boolean,
|
|
1023
1028
|
yearsSelectRange: Array
|
|
1024
1029
|
},
|
|
1025
|
-
|
|
1030
|
+
emits: ["update:modelValue", "change"],
|
|
1031
|
+
setup(props, { attrs, slots, emit }) {
|
|
1026
1032
|
const finalValue = computed(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
|
|
1027
1033
|
const [_value, setValue] = useUncontrolled({
|
|
1028
|
-
value: computed(() => props.value),
|
|
1034
|
+
value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1029
1035
|
defaultValue: props.defaultValue,
|
|
1030
1036
|
finalValue: finalValue.value,
|
|
1031
|
-
onChange: (value) =>
|
|
1037
|
+
onChange: (value) => {
|
|
1038
|
+
emit("update:modelValue", value);
|
|
1039
|
+
emit("change", value);
|
|
1040
|
+
}
|
|
1032
1041
|
});
|
|
1033
1042
|
const selectDate = (date) => {
|
|
1034
1043
|
if (props.type === "default" && props.allowDeselect && isSameDate(_value.value, date)) setValue(null);
|
|
@@ -1077,6 +1086,11 @@ var YearPicker = defineComponent({
|
|
|
1077
1086
|
type: String,
|
|
1078
1087
|
default: "default"
|
|
1079
1088
|
},
|
|
1089
|
+
modelValue: [
|
|
1090
|
+
String,
|
|
1091
|
+
Array,
|
|
1092
|
+
null
|
|
1093
|
+
],
|
|
1080
1094
|
value: [
|
|
1081
1095
|
String,
|
|
1082
1096
|
Array,
|
|
@@ -1101,13 +1115,17 @@ var YearPicker = defineComponent({
|
|
|
1101
1115
|
withNativeLevelSelect: Boolean,
|
|
1102
1116
|
yearsSelectRange: Array
|
|
1103
1117
|
},
|
|
1104
|
-
|
|
1118
|
+
emits: ["update:modelValue", "change"],
|
|
1119
|
+
setup(props, { attrs, emit }) {
|
|
1105
1120
|
const finalValue = computed(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
|
|
1106
1121
|
const [_value, setValue] = useUncontrolled({
|
|
1107
|
-
value: computed(() => props.value),
|
|
1122
|
+
value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1108
1123
|
defaultValue: props.defaultValue,
|
|
1109
1124
|
finalValue: finalValue.value,
|
|
1110
|
-
onChange: (value) =>
|
|
1125
|
+
onChange: (value) => {
|
|
1126
|
+
emit("update:modelValue", value);
|
|
1127
|
+
emit("change", value);
|
|
1128
|
+
}
|
|
1111
1129
|
});
|
|
1112
1130
|
const hoveredDate = ref(null);
|
|
1113
1131
|
const selectYear = (date) => {
|
|
@@ -1172,6 +1190,11 @@ var MonthPicker = defineComponent({
|
|
|
1172
1190
|
type: String,
|
|
1173
1191
|
default: "default"
|
|
1174
1192
|
},
|
|
1193
|
+
modelValue: [
|
|
1194
|
+
String,
|
|
1195
|
+
Array,
|
|
1196
|
+
null
|
|
1197
|
+
],
|
|
1175
1198
|
value: [
|
|
1176
1199
|
String,
|
|
1177
1200
|
Array,
|
|
@@ -1196,13 +1219,17 @@ var MonthPicker = defineComponent({
|
|
|
1196
1219
|
withNativeLevelSelect: Boolean,
|
|
1197
1220
|
yearsSelectRange: Array
|
|
1198
1221
|
},
|
|
1199
|
-
|
|
1222
|
+
emits: ["update:modelValue", "change"],
|
|
1223
|
+
setup(props, { attrs, emit }) {
|
|
1200
1224
|
const finalValue = computed(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
|
|
1201
1225
|
const [_value, setValue] = useUncontrolled({
|
|
1202
|
-
value: computed(() => props.value),
|
|
1226
|
+
value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1203
1227
|
defaultValue: props.defaultValue,
|
|
1204
1228
|
finalValue: finalValue.value,
|
|
1205
|
-
onChange: (value) =>
|
|
1229
|
+
onChange: (value) => {
|
|
1230
|
+
emit("update:modelValue", value);
|
|
1231
|
+
emit("change", value);
|
|
1232
|
+
}
|
|
1206
1233
|
});
|
|
1207
1234
|
const hoveredDate = ref(null);
|
|
1208
1235
|
const selectMonth = (date) => {
|
|
@@ -1357,6 +1384,11 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
|
|
|
1357
1384
|
type: String,
|
|
1358
1385
|
default: "default"
|
|
1359
1386
|
},
|
|
1387
|
+
modelValue: [
|
|
1388
|
+
String,
|
|
1389
|
+
Array,
|
|
1390
|
+
null
|
|
1391
|
+
],
|
|
1360
1392
|
value: [
|
|
1361
1393
|
String,
|
|
1362
1394
|
Array,
|
|
@@ -1397,13 +1429,17 @@ function createPickerInput(name, Picker, defaultLevel, defaultValueFormat = "MMM
|
|
|
1397
1429
|
withNativeLevelSelect: Boolean,
|
|
1398
1430
|
yearsSelectRange: Array
|
|
1399
1431
|
},
|
|
1400
|
-
|
|
1432
|
+
emits: ["update:modelValue", "change"],
|
|
1433
|
+
setup(props, { attrs, emit }) {
|
|
1401
1434
|
const finalValue = computed(() => props.type === "multiple" ? [] : props.type === "range" ? [null, null] : null);
|
|
1402
1435
|
const [_value, setValue] = useUncontrolled({
|
|
1403
|
-
value: computed(() => props.value),
|
|
1436
|
+
value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1404
1437
|
defaultValue: props.defaultValue,
|
|
1405
1438
|
finalValue: finalValue.value,
|
|
1406
|
-
onChange: (value) =>
|
|
1439
|
+
onChange: (value) => {
|
|
1440
|
+
emit("update:modelValue", value);
|
|
1441
|
+
emit("change", value);
|
|
1442
|
+
}
|
|
1407
1443
|
});
|
|
1408
1444
|
const opened = ref(false);
|
|
1409
1445
|
const formattedValue = computed(() => formatValue(_value.value, props.type, props.valueFormat, props.locale, props.labelSeparator, props.valueFormatter));
|
|
@@ -1469,6 +1505,11 @@ var DateInput = defineComponent({
|
|
|
1469
1505
|
name: "DateInput",
|
|
1470
1506
|
inheritAttrs: false,
|
|
1471
1507
|
props: {
|
|
1508
|
+
modelValue: [
|
|
1509
|
+
String,
|
|
1510
|
+
Date,
|
|
1511
|
+
null
|
|
1512
|
+
],
|
|
1472
1513
|
value: [
|
|
1473
1514
|
String,
|
|
1474
1515
|
Date,
|
|
@@ -1491,12 +1532,19 @@ var DateInput = defineComponent({
|
|
|
1491
1532
|
maxDate: [String, Date],
|
|
1492
1533
|
presets: Array
|
|
1493
1534
|
},
|
|
1494
|
-
|
|
1535
|
+
emits: ["update:modelValue", "change"],
|
|
1536
|
+
setup(props, { attrs, emit }) {
|
|
1495
1537
|
const [_value, setValue] = useUncontrolled({
|
|
1496
|
-
value: computed(() =>
|
|
1538
|
+
value: computed(() => {
|
|
1539
|
+
const controlledValue = props.modelValue !== void 0 ? props.modelValue : props.value;
|
|
1540
|
+
return controlledValue === void 0 ? void 0 : normalizeDate(controlledValue);
|
|
1541
|
+
}),
|
|
1497
1542
|
defaultValue: normalizeDate(props.defaultValue),
|
|
1498
1543
|
finalValue: null,
|
|
1499
|
-
onChange: (value) =>
|
|
1544
|
+
onChange: (value) => {
|
|
1545
|
+
emit("update:modelValue", value);
|
|
1546
|
+
emit("change", value);
|
|
1547
|
+
}
|
|
1500
1548
|
});
|
|
1501
1549
|
const formatValue = (value) => value ? dayjs(value).locale(props.locale || "en").format(props.valueFormat) : "";
|
|
1502
1550
|
const inputValue = ref(formatValue(_value.value));
|
|
@@ -1668,18 +1716,22 @@ var TimeInput = defineComponent({
|
|
|
1668
1716
|
name: "TimeInput",
|
|
1669
1717
|
props: {
|
|
1670
1718
|
withSeconds: Boolean,
|
|
1719
|
+
modelValue: String,
|
|
1671
1720
|
value: String,
|
|
1672
1721
|
defaultValue: String,
|
|
1673
1722
|
onChange: Function
|
|
1674
1723
|
},
|
|
1675
|
-
|
|
1724
|
+
emits: ["update:modelValue", "change"],
|
|
1725
|
+
setup(props, { attrs, emit }) {
|
|
1676
1726
|
return () => h(InputBase, {
|
|
1677
1727
|
...attrs,
|
|
1678
1728
|
type: "time",
|
|
1679
1729
|
step: props.withSeconds ? 1 : 60,
|
|
1730
|
+
modelValue: props.modelValue,
|
|
1680
1731
|
value: props.value,
|
|
1681
1732
|
defaultValue: props.defaultValue,
|
|
1682
|
-
|
|
1733
|
+
"onUpdate:modelValue": (value) => emit("update:modelValue", value),
|
|
1734
|
+
onChange: (value) => emit("change", value)
|
|
1683
1735
|
});
|
|
1684
1736
|
}
|
|
1685
1737
|
});
|
|
@@ -1690,6 +1742,7 @@ var TimeGrid = defineComponent({
|
|
|
1690
1742
|
type: Array,
|
|
1691
1743
|
default: () => []
|
|
1692
1744
|
},
|
|
1745
|
+
modelValue: String,
|
|
1693
1746
|
value: String,
|
|
1694
1747
|
defaultValue: String,
|
|
1695
1748
|
minTime: String,
|
|
@@ -1699,12 +1752,16 @@ var TimeGrid = defineComponent({
|
|
|
1699
1752
|
onChange: Function,
|
|
1700
1753
|
getControlProps: Function
|
|
1701
1754
|
},
|
|
1702
|
-
|
|
1755
|
+
emits: ["update:modelValue", "change"],
|
|
1756
|
+
setup(props, { attrs, emit }) {
|
|
1703
1757
|
const [_value, setValue] = useUncontrolled({
|
|
1704
|
-
value: computed(() => props.value),
|
|
1758
|
+
value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1705
1759
|
defaultValue: props.defaultValue,
|
|
1706
1760
|
finalValue: null,
|
|
1707
|
-
onChange: (value) =>
|
|
1761
|
+
onChange: (value) => {
|
|
1762
|
+
emit("update:modelValue", value);
|
|
1763
|
+
emit("change", value);
|
|
1764
|
+
}
|
|
1708
1765
|
});
|
|
1709
1766
|
return () => h(Box, {
|
|
1710
1767
|
...attrs,
|
|
@@ -1737,9 +1794,17 @@ var SpinInput = defineComponent({
|
|
|
1737
1794
|
name: "SpinInput",
|
|
1738
1795
|
inheritAttrs: false,
|
|
1739
1796
|
props: {
|
|
1797
|
+
modelValue: {
|
|
1798
|
+
type: Number,
|
|
1799
|
+
default: void 0
|
|
1800
|
+
},
|
|
1740
1801
|
value: {
|
|
1741
1802
|
type: Number,
|
|
1742
|
-
default:
|
|
1803
|
+
default: void 0
|
|
1804
|
+
},
|
|
1805
|
+
defaultValue: {
|
|
1806
|
+
type: Number,
|
|
1807
|
+
default: void 0
|
|
1743
1808
|
},
|
|
1744
1809
|
min: {
|
|
1745
1810
|
type: Number,
|
|
@@ -1765,7 +1830,17 @@ var SpinInput = defineComponent({
|
|
|
1765
1830
|
disabled: Boolean,
|
|
1766
1831
|
readOnly: Boolean
|
|
1767
1832
|
},
|
|
1768
|
-
|
|
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
|
+
});
|
|
1769
1844
|
const finiteMax = () => Number.isFinite(props.max);
|
|
1770
1845
|
const maxDigit = () => finiteMax() ? Number(props.max.toFixed(0)[0]) : Infinity;
|
|
1771
1846
|
const arrowsMax = () => props.max + 1 - props.step;
|
|
@@ -1780,7 +1855,7 @@ var SpinInput = defineComponent({
|
|
|
1780
1855
|
parsedValue = finiteMax() && next > props.max ? digit : next;
|
|
1781
1856
|
}
|
|
1782
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);
|
|
1783
|
-
|
|
1858
|
+
setValue(clampedValue);
|
|
1784
1859
|
if (!props.disableAutoAdvance && (clampedValue > maxDigit() || raw.startsWith("00"))) props.onNextInput?.();
|
|
1785
1860
|
};
|
|
1786
1861
|
const handleKeydown = (event) => {
|
|
@@ -1788,22 +1863,22 @@ var SpinInput = defineComponent({
|
|
|
1788
1863
|
if (event.key === "0" || event.key === "Num0") {
|
|
1789
1864
|
const { selectionStart, selectionEnd, value: inputValue } = event.currentTarget;
|
|
1790
1865
|
const isEntireValueSelected = inputValue.length > 0 && selectionStart === 0 && selectionEnd === inputValue.length;
|
|
1791
|
-
if (
|
|
1866
|
+
if (value.value === 0 && !isEntireValueSelected) {
|
|
1792
1867
|
event.preventDefault();
|
|
1793
1868
|
props.onNextInput?.();
|
|
1794
1869
|
}
|
|
1795
1870
|
}
|
|
1796
1871
|
if (event.key === "Home") {
|
|
1797
1872
|
event.preventDefault();
|
|
1798
|
-
|
|
1873
|
+
setValue(props.min);
|
|
1799
1874
|
}
|
|
1800
1875
|
if (event.key === "End") {
|
|
1801
1876
|
event.preventDefault();
|
|
1802
|
-
if (finiteMax())
|
|
1877
|
+
if (finiteMax()) setValue(props.max);
|
|
1803
1878
|
}
|
|
1804
1879
|
if (event.key === "Backspace" || event.key === "Delete") {
|
|
1805
1880
|
event.preventDefault();
|
|
1806
|
-
if (
|
|
1881
|
+
if (value.value !== null) setValue(null);
|
|
1807
1882
|
else props.onPreviousInput?.();
|
|
1808
1883
|
}
|
|
1809
1884
|
if (event.key === "ArrowRight") {
|
|
@@ -1816,13 +1891,11 @@ var SpinInput = defineComponent({
|
|
|
1816
1891
|
}
|
|
1817
1892
|
if (event.key === "ArrowUp") {
|
|
1818
1893
|
event.preventDefault();
|
|
1819
|
-
|
|
1820
|
-
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));
|
|
1821
1895
|
}
|
|
1822
1896
|
if (event.key === "ArrowDown") {
|
|
1823
1897
|
event.preventDefault();
|
|
1824
|
-
|
|
1825
|
-
props.onChange?.(newValue);
|
|
1898
|
+
setValue(value.value === null ? finiteMax() ? arrowsMax() : props.min : Math.min(Math.max(value.value - props.step, props.min), arrowsMax()));
|
|
1826
1899
|
}
|
|
1827
1900
|
};
|
|
1828
1901
|
return () => h("input", {
|
|
@@ -1831,13 +1904,13 @@ var SpinInput = defineComponent({
|
|
|
1831
1904
|
role: "spinbutton",
|
|
1832
1905
|
"aria-valuemin": props.min,
|
|
1833
1906
|
"aria-valuemax": finiteMax() ? props.max : void 0,
|
|
1834
|
-
"aria-valuenow":
|
|
1835
|
-
"data-empty":
|
|
1907
|
+
"aria-valuenow": value.value === null ? 0 : value.value,
|
|
1908
|
+
"data-empty": value.value === null || void 0,
|
|
1836
1909
|
inputmode: "numeric",
|
|
1837
1910
|
placeholder: props.placeholder,
|
|
1838
1911
|
disabled: props.disabled,
|
|
1839
1912
|
readonly: props.readOnly,
|
|
1840
|
-
value:
|
|
1913
|
+
value: value.value === null ? "" : padTime(value.value),
|
|
1841
1914
|
onInput: (event) => handleChange(event.target.value),
|
|
1842
1915
|
onKeydown: handleKeydown,
|
|
1843
1916
|
onFocus: (event) => event.target.select(),
|
|
@@ -1852,9 +1925,17 @@ var SpinInput = defineComponent({
|
|
|
1852
1925
|
var AmPmInput = defineComponent({
|
|
1853
1926
|
name: "AmPmInput",
|
|
1854
1927
|
props: {
|
|
1928
|
+
modelValue: {
|
|
1929
|
+
type: String,
|
|
1930
|
+
default: void 0
|
|
1931
|
+
},
|
|
1855
1932
|
value: {
|
|
1856
1933
|
type: String,
|
|
1857
|
-
default:
|
|
1934
|
+
default: void 0
|
|
1935
|
+
},
|
|
1936
|
+
defaultValue: {
|
|
1937
|
+
type: String,
|
|
1938
|
+
default: void 0
|
|
1858
1939
|
},
|
|
1859
1940
|
labels: {
|
|
1860
1941
|
type: Object,
|
|
@@ -1864,14 +1945,24 @@ var AmPmInput = defineComponent({
|
|
|
1864
1945
|
disabled: Boolean,
|
|
1865
1946
|
readOnly: Boolean
|
|
1866
1947
|
},
|
|
1867
|
-
|
|
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
|
+
});
|
|
1868
1959
|
return () => h("select", {
|
|
1869
1960
|
...attrs,
|
|
1870
1961
|
class: Dates_module_default.timePickerField,
|
|
1871
1962
|
"data-am-pm": true,
|
|
1872
1963
|
disabled: props.disabled,
|
|
1873
|
-
value:
|
|
1874
|
-
onChange: (event) =>
|
|
1964
|
+
value: value.value ?? props.labels.am,
|
|
1965
|
+
onChange: (event) => setValue(event.target.value)
|
|
1875
1966
|
}, [h("option", { value: props.labels.am }, props.labels.am), h("option", { value: props.labels.pm }, props.labels.pm)]);
|
|
1876
1967
|
}
|
|
1877
1968
|
});
|
|
@@ -1909,6 +2000,7 @@ var TimeControlsList = defineComponent({
|
|
|
1909
2000
|
var TimePicker = defineComponent({
|
|
1910
2001
|
name: "TimePicker",
|
|
1911
2002
|
props: {
|
|
2003
|
+
modelValue: String,
|
|
1912
2004
|
value: String,
|
|
1913
2005
|
defaultValue: String,
|
|
1914
2006
|
onChange: Function,
|
|
@@ -1951,13 +2043,17 @@ var TimePicker = defineComponent({
|
|
|
1951
2043
|
closeDropdownOnPresetSelect: Boolean,
|
|
1952
2044
|
hoursRef: Object
|
|
1953
2045
|
},
|
|
1954
|
-
|
|
2046
|
+
emits: ["update:modelValue", "change"],
|
|
2047
|
+
setup(props, { attrs, emit }) {
|
|
1955
2048
|
const effectiveFormat = computed(() => props.type === "duration" ? "24h" : props.format);
|
|
1956
2049
|
const [_value, setValue] = useUncontrolled({
|
|
1957
|
-
value: computed(() => props.value),
|
|
2050
|
+
value: computed(() => props.modelValue !== void 0 ? props.modelValue : props.value),
|
|
1958
2051
|
defaultValue: props.defaultValue,
|
|
1959
2052
|
finalValue: "",
|
|
1960
|
-
onChange: (value) =>
|
|
2053
|
+
onChange: (value) => {
|
|
2054
|
+
emit("update:modelValue", value);
|
|
2055
|
+
emit("change", value);
|
|
2056
|
+
}
|
|
1961
2057
|
});
|
|
1962
2058
|
const parsed = computed(() => getParsedTime({
|
|
1963
2059
|
time: _value.value,
|
|
@@ -2203,6 +2299,11 @@ var TimeValue = defineComponent({
|
|
|
2203
2299
|
var DateTimePicker = defineComponent({
|
|
2204
2300
|
name: "DateTimePicker",
|
|
2205
2301
|
props: {
|
|
2302
|
+
modelValue: [
|
|
2303
|
+
String,
|
|
2304
|
+
Date,
|
|
2305
|
+
null
|
|
2306
|
+
],
|
|
2206
2307
|
value: [
|
|
2207
2308
|
String,
|
|
2208
2309
|
Date,
|
|
@@ -2226,13 +2327,20 @@ var DateTimePicker = defineComponent({
|
|
|
2226
2327
|
},
|
|
2227
2328
|
submitButtonProps: Object
|
|
2228
2329
|
},
|
|
2229
|
-
|
|
2330
|
+
emits: ["update:modelValue", "change"],
|
|
2331
|
+
setup(props, { attrs, emit }) {
|
|
2230
2332
|
const hoursRef = ref();
|
|
2231
2333
|
const [_value, setValue] = useUncontrolled({
|
|
2232
|
-
value: computed(() =>
|
|
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
|
+
}),
|
|
2233
2338
|
defaultValue: props.defaultValue ? new Date(props.defaultValue) : null,
|
|
2234
2339
|
finalValue: null,
|
|
2235
|
-
onChange: (value) =>
|
|
2340
|
+
onChange: (value) => {
|
|
2341
|
+
emit("update:modelValue", value);
|
|
2342
|
+
emit("change", value);
|
|
2343
|
+
}
|
|
2236
2344
|
});
|
|
2237
2345
|
const date = computed(() => _value.value ? dayjs(_value.value).format("YYYY-MM-DD") : null);
|
|
2238
2346
|
const time = computed(() => _value.value ? dayjs(_value.value).format(props.withSeconds ? "HH:mm:ss" : "HH:mm") : "");
|
|
@@ -2278,11 +2386,21 @@ var MiniCalendar = defineComponent({
|
|
|
2278
2386
|
date: [String, Date],
|
|
2279
2387
|
defaultDate: [String, Date],
|
|
2280
2388
|
onDateChange: Function,
|
|
2389
|
+
modelValue: [
|
|
2390
|
+
String,
|
|
2391
|
+
Date,
|
|
2392
|
+
null
|
|
2393
|
+
],
|
|
2281
2394
|
value: [
|
|
2282
2395
|
String,
|
|
2283
2396
|
Date,
|
|
2284
2397
|
null
|
|
2285
2398
|
],
|
|
2399
|
+
defaultValue: [
|
|
2400
|
+
String,
|
|
2401
|
+
Date,
|
|
2402
|
+
null
|
|
2403
|
+
],
|
|
2286
2404
|
onChange: Function,
|
|
2287
2405
|
maxDate: [String, Date],
|
|
2288
2406
|
minDate: [String, Date],
|
|
@@ -2305,12 +2423,25 @@ var MiniCalendar = defineComponent({
|
|
|
2305
2423
|
nextControlProps: Object,
|
|
2306
2424
|
locale: String
|
|
2307
2425
|
},
|
|
2308
|
-
|
|
2426
|
+
emits: ["update:modelValue", "change"],
|
|
2427
|
+
setup(props, { attrs, emit }) {
|
|
2309
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
|
+
});
|
|
2310
2441
|
const [_date, setDate] = useUncontrolled({
|
|
2311
2442
|
value: computed(() => toDateString(props.date ?? null) ?? void 0),
|
|
2312
2443
|
defaultValue: toDateString(props.defaultDate ?? null) ?? void 0,
|
|
2313
|
-
finalValue:
|
|
2444
|
+
finalValue: value.value || dayjs().format("YYYY-MM-DD"),
|
|
2314
2445
|
onChange: (value) => props.onDateChange?.(value)
|
|
2315
2446
|
});
|
|
2316
2447
|
const handleNext = () => {
|
|
@@ -2332,12 +2463,12 @@ var MiniCalendar = defineComponent({
|
|
|
2332
2463
|
disabled,
|
|
2333
2464
|
"aria-label": date.format("YYYY-MM-DD"),
|
|
2334
2465
|
"data-disabled": disabled || void 0,
|
|
2335
|
-
"data-selected":
|
|
2466
|
+
"data-selected": value.value && dayjs(date).isSame(value.value, "day") || void 0,
|
|
2336
2467
|
...dayProps,
|
|
2337
2468
|
class: [Dates_module_default.miniCalendarDay, dayProps.class],
|
|
2338
2469
|
onClick: (event) => {
|
|
2339
2470
|
dayProps.onClick?.(event);
|
|
2340
|
-
|
|
2471
|
+
setValue(toDateString(date.format("YYYY-MM-DD")));
|
|
2341
2472
|
}
|
|
2342
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()))]);
|
|
2343
2474
|
});
|