primevue 4.3.9 → 4.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/autocomplete/AutoComplete.vue +18 -3
- package/autocomplete/BaseAutoComplete.vue +4 -0
- package/autocomplete/index.d.ts +20 -0
- package/autocomplete/index.mjs +34 -7
- package/autocomplete/index.mjs.map +1 -1
- package/autocomplete/style/index.d.ts +4 -0
- package/autocomplete/style/index.mjs +3 -1
- package/autocomplete/style/index.mjs.map +1 -1
- package/checkbox/Checkbox.vue +15 -2
- package/checkbox/index.mjs +14 -2
- package/checkbox/index.mjs.map +1 -1
- package/colorpicker/ColorPicker.vue +3 -4
- package/colorpicker/index.mjs +3 -3
- package/colorpicker/index.mjs.map +1 -1
- package/confirmdialog/ConfirmDialog.vue +1 -1
- package/confirmdialog/index.d.ts +5 -0
- package/confirmdialog/index.mjs +3 -2
- package/confirmdialog/index.mjs.map +1 -1
- package/datatable/DataTable.vue +2 -2
- package/datatable/HeaderCheckbox.vue +3 -3
- package/datatable/index.mjs +12 -3
- package/datatable/index.mjs.map +1 -1
- package/datepicker/BaseDatePicker.vue +8 -0
- package/datepicker/DatePicker.vue +199 -81
- package/datepicker/index.d.ts +25 -0
- package/datepicker/index.mjs +258 -150
- package/datepicker/index.mjs.map +1 -1
- package/datepicker/style/index.d.ts +4 -0
- package/datepicker/style/index.mjs +5 -2
- package/datepicker/style/index.mjs.map +1 -1
- package/drawer/BaseDrawer.vue +4 -0
- package/drawer/Drawer.vue +4 -4
- package/drawer/index.d.ts +5 -0
- package/drawer/index.mjs +8 -4
- package/drawer/index.mjs.map +1 -1
- package/editor/Editor.vue +5 -1
- package/editor/index.mjs +5 -0
- package/editor/index.mjs.map +1 -1
- package/image/index.d.ts +5 -11
- package/inputmask/InputMask.vue +1 -2
- package/inputmask/index.mjs +1 -1
- package/inputmask/index.mjs.map +1 -1
- package/inputnumber/BaseInputNumber.vue +4 -0
- package/inputnumber/InputNumber.vue +30 -5
- package/inputnumber/index.d.ts +20 -0
- package/inputnumber/index.mjs +45 -7
- package/inputnumber/index.mjs.map +1 -1
- package/inputnumber/style/index.mjs +1 -0
- package/inputnumber/style/index.mjs.map +1 -1
- package/inputotp/InputOtp.vue +7 -3
- package/inputotp/index.mjs +6 -3
- package/inputotp/index.mjs.map +1 -1
- package/listbox/Listbox.vue +1 -1
- package/listbox/index.mjs +1 -1
- package/listbox/index.mjs.map +1 -1
- package/multiselect/MultiSelect.vue +9 -5
- package/multiselect/index.mjs +14 -10
- package/multiselect/index.mjs.map +1 -1
- package/package.json +5 -5
- package/panel/Panel.vue +1 -1
- package/panel/index.d.ts +4 -0
- package/panel/index.mjs +2 -1
- package/panel/index.mjs.map +1 -1
- package/password/BasePassword.vue +4 -0
- package/password/Password.vue +12 -1
- package/password/index.d.ts +20 -0
- package/password/index.mjs +23 -1
- package/password/index.mjs.map +1 -1
- package/password/style/index.d.ts +4 -0
- package/password/style/index.mjs +1 -0
- package/password/style/index.mjs.map +1 -1
- package/select/Select.vue +1 -0
- package/select/index.mjs +1 -0
- package/select/index.mjs.map +1 -1
- package/tree/BaseTree.vue +16 -0
- package/tree/Tree.vue +179 -4
- package/tree/TreeNode.vue +225 -3
- package/tree/index.d.ts +65 -0
- package/tree/index.mjs +499 -22
- package/tree/index.mjs.map +1 -1
- package/tree/style/index.mjs +9 -4
- package/tree/style/index.mjs.map +1 -1
- package/treenode/index.d.ts +12 -0
- package/treeselect/TreeSelect.vue +1 -1
- package/treeselect/index.mjs +1 -1
- package/treeselect/index.mjs.map +1 -1
- package/umd/primevue.min.js +1 -1
- package/web-types.json +1 -1
|
@@ -14,6 +14,10 @@ export default {
|
|
|
14
14
|
type: String,
|
|
15
15
|
default: null
|
|
16
16
|
},
|
|
17
|
+
updateModelType: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: 'date'
|
|
20
|
+
},
|
|
17
21
|
inline: {
|
|
18
22
|
type: Boolean,
|
|
19
23
|
default: false
|
|
@@ -155,6 +159,10 @@ export default {
|
|
|
155
159
|
type: Boolean,
|
|
156
160
|
default: true
|
|
157
161
|
},
|
|
162
|
+
showClear: {
|
|
163
|
+
type: Boolean,
|
|
164
|
+
default: false
|
|
165
|
+
},
|
|
158
166
|
appendTo: {
|
|
159
167
|
type: [String, Object],
|
|
160
168
|
default: 'body'
|
|
@@ -36,6 +36,9 @@
|
|
|
36
36
|
:data-p-has-e-icon="showIcon && iconDisplay === 'input' && !inline"
|
|
37
37
|
:pt="ptm('pcInputText')"
|
|
38
38
|
/>
|
|
39
|
+
<slot v-if="showClear && !inline" name="clearicon" :class="cx('clearIcon')" :clearCallback="onClearClick">
|
|
40
|
+
<TimesIcon ref="clearIcon" :class="[cx('clearIcon')]" @click="onClearClick" v-bind="ptm('clearIcon')" />
|
|
41
|
+
</slot>
|
|
39
42
|
<slot v-if="showIcon && iconDisplay === 'button' && !inline" name="dropdownbutton" :toggleCallback="onButtonClick">
|
|
40
43
|
<button
|
|
41
44
|
:class="cx('dropdown')"
|
|
@@ -563,7 +566,7 @@
|
|
|
563
566
|
<script>
|
|
564
567
|
import { cn } from '@primeuix/utils';
|
|
565
568
|
import { absolutePosition, addStyle, find, findSingle, getAttribute, getFocusableElements, getIndex, getOuterWidth, isTouchDevice, relativePosition, setAttribute } from '@primeuix/utils/dom';
|
|
566
|
-
import { localeComparator } from '@primeuix/utils/object';
|
|
569
|
+
import { isDate, isEmpty, isNotEmpty, localeComparator } from '@primeuix/utils/object';
|
|
567
570
|
import { ZIndex } from '@primeuix/utils/zindex';
|
|
568
571
|
import { ConnectedOverlayScrollHandler } from '@primevue/core/utils';
|
|
569
572
|
import CalendarIcon from '@primevue/icons/calendar';
|
|
@@ -571,6 +574,7 @@ import ChevronDownIcon from '@primevue/icons/chevrondown';
|
|
|
571
574
|
import ChevronLeftIcon from '@primevue/icons/chevronleft';
|
|
572
575
|
import ChevronRightIcon from '@primevue/icons/chevronright';
|
|
573
576
|
import ChevronUpIcon from '@primevue/icons/chevronup';
|
|
577
|
+
import TimesIcon from '@primevue/icons/times';
|
|
574
578
|
import Button from 'primevue/button';
|
|
575
579
|
import InputText from 'primevue/inputtext';
|
|
576
580
|
import OverlayEventBus from 'primevue/overlayeventbus';
|
|
@@ -614,18 +618,27 @@ export default {
|
|
|
614
618
|
query: null,
|
|
615
619
|
queryMatches: false,
|
|
616
620
|
queryOrientation: null,
|
|
617
|
-
focusedDateIndex: 0
|
|
621
|
+
focusedDateIndex: 0,
|
|
622
|
+
rawValue: null
|
|
618
623
|
};
|
|
619
624
|
},
|
|
620
625
|
watch: {
|
|
621
|
-
modelValue
|
|
622
|
-
|
|
626
|
+
modelValue: {
|
|
627
|
+
immediate: true,
|
|
628
|
+
handler(newValue) {
|
|
629
|
+
this.updateCurrentMetaData();
|
|
630
|
+
this.rawValue = typeof newValue === 'string' ? this.parseValue(newValue) : newValue;
|
|
623
631
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
632
|
+
if (!this.typeUpdate && !this.inline && this.input) {
|
|
633
|
+
this.input.value = this.formatValue(this.rawValue);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
this.typeUpdate = false;
|
|
627
637
|
|
|
628
|
-
|
|
638
|
+
if (this.$refs.clearIcon?.$el?.style) {
|
|
639
|
+
this.$refs.clearIcon.$el.style.display = isEmpty(newValue) ? 'none' : 'block';
|
|
640
|
+
}
|
|
641
|
+
}
|
|
629
642
|
},
|
|
630
643
|
showTime() {
|
|
631
644
|
this.updateCurrentMetaData();
|
|
@@ -677,6 +690,10 @@ export default {
|
|
|
677
690
|
}
|
|
678
691
|
} else {
|
|
679
692
|
this.input.value = this.inputFieldValue;
|
|
693
|
+
|
|
694
|
+
if (this.$refs.clearIcon?.$el?.style) {
|
|
695
|
+
this.$refs.clearIcon.$el.style.display = !this.$filled ? 'none' : 'block';
|
|
696
|
+
}
|
|
680
697
|
}
|
|
681
698
|
},
|
|
682
699
|
updated() {
|
|
@@ -716,22 +733,15 @@ export default {
|
|
|
716
733
|
this.overlay = null;
|
|
717
734
|
},
|
|
718
735
|
methods: {
|
|
719
|
-
isComparable() {
|
|
720
|
-
return this.d_value != null && typeof this.d_value !== 'string';
|
|
721
|
-
},
|
|
722
736
|
isSelected(dateMeta) {
|
|
723
|
-
if (
|
|
724
|
-
return false;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
if (this.d_value) {
|
|
737
|
+
if (this.rawValue) {
|
|
728
738
|
if (this.isSingleSelection()) {
|
|
729
|
-
return this.isDateEquals(this.
|
|
739
|
+
return this.isDateEquals(this.parseValueForComparison(this.rawValue), dateMeta);
|
|
730
740
|
} else if (this.isMultipleSelection()) {
|
|
731
741
|
let selected = false;
|
|
732
742
|
|
|
733
|
-
for (let date of this.
|
|
734
|
-
selected = this.isDateEquals(date, dateMeta);
|
|
743
|
+
for (let date of this.rawValue) {
|
|
744
|
+
selected = this.isDateEquals(this.parseValueForComparison(date), dateMeta);
|
|
735
745
|
|
|
736
746
|
if (selected) {
|
|
737
747
|
break;
|
|
@@ -740,9 +750,14 @@ export default {
|
|
|
740
750
|
|
|
741
751
|
return selected;
|
|
742
752
|
} else if (this.isRangeSelection()) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
753
|
+
const start = this.parseValueForComparison(this.rawValue[0]);
|
|
754
|
+
|
|
755
|
+
if (this.rawValue[1]) {
|
|
756
|
+
const end = this.parseValueForComparison(this.rawValue[1]);
|
|
757
|
+
|
|
758
|
+
return this.isDateEquals(start, dateMeta) || this.isDateEquals(end, dateMeta) || this.isDateBetween(start, end, dateMeta);
|
|
759
|
+
} else {
|
|
760
|
+
return this.isDateEquals(start, dateMeta);
|
|
746
761
|
}
|
|
747
762
|
}
|
|
748
763
|
}
|
|
@@ -750,36 +765,45 @@ export default {
|
|
|
750
765
|
return false;
|
|
751
766
|
},
|
|
752
767
|
isMonthSelected(month) {
|
|
753
|
-
if (!this.isComparable()) return false;
|
|
754
|
-
|
|
755
768
|
if (this.isMultipleSelection()) {
|
|
756
|
-
return this.
|
|
769
|
+
return this.rawValue?.some((currentValue) => {
|
|
770
|
+
const parsedDate = this.parseValueForComparison(currentValue);
|
|
771
|
+
|
|
772
|
+
return parsedDate.getMonth() === month && parsedDate.getFullYear() === this.currentYear;
|
|
773
|
+
});
|
|
757
774
|
} else if (this.isRangeSelection()) {
|
|
758
|
-
|
|
759
|
-
|
|
775
|
+
const parsedStart = this.rawValue?.[0] ? this.parseValueForComparison(this.rawValue[0]) : null;
|
|
776
|
+
const parsedEnd = this.rawValue?.[1] ? this.parseValueForComparison(this.rawValue[1]) : null;
|
|
777
|
+
|
|
778
|
+
if (!parsedEnd) {
|
|
779
|
+
return parsedStart?.getFullYear() === this.currentYear && parsedStart?.getMonth() === month;
|
|
760
780
|
} else {
|
|
761
781
|
const currentDate = new Date(this.currentYear, month, 1);
|
|
762
|
-
const startDate = new Date(
|
|
763
|
-
const endDate = new Date(
|
|
764
|
-
|
|
782
|
+
const startDate = new Date(parsedStart.getFullYear(), parsedStart.getMonth(), 1);
|
|
783
|
+
const endDate = new Date(parsedEnd.getFullYear(), parsedEnd.getMonth(), 1);
|
|
765
784
|
return currentDate >= startDate && currentDate <= endDate;
|
|
766
785
|
}
|
|
767
786
|
} else {
|
|
768
|
-
return this.
|
|
787
|
+
return this.rawValue?.getMonth() === month && this.rawValue?.getFullYear() === this.currentYear;
|
|
769
788
|
}
|
|
770
789
|
},
|
|
771
790
|
isYearSelected(year) {
|
|
772
|
-
if (!this.isComparable()) return false;
|
|
773
|
-
|
|
774
791
|
if (this.isMultipleSelection()) {
|
|
775
|
-
return this.
|
|
792
|
+
return this.rawValue?.some((currentValue) => {
|
|
793
|
+
const parsedDate = this.parseValueForComparison(currentValue);
|
|
794
|
+
|
|
795
|
+
return parsedDate.getFullYear() === year;
|
|
796
|
+
});
|
|
776
797
|
} else if (this.isRangeSelection()) {
|
|
777
|
-
const
|
|
778
|
-
const
|
|
798
|
+
const parsedStart = this.rawValue?.[0] ? this.parseValueForComparison(this.rawValue[0]) : null;
|
|
799
|
+
const parsedEnd = this.rawValue?.[1] ? this.parseValueForComparison(this.rawValue[1]) : null;
|
|
800
|
+
|
|
801
|
+
const start = parsedStart ? parsedStart.getFullYear() : null;
|
|
802
|
+
const end = parsedEnd ? parsedEnd.getFullYear() : null;
|
|
779
803
|
|
|
780
804
|
return start === year || end === year || (start < year && end > year);
|
|
781
805
|
} else {
|
|
782
|
-
return this.
|
|
806
|
+
return this.rawValue?.getFullYear() === year;
|
|
783
807
|
}
|
|
784
808
|
},
|
|
785
809
|
isDateEquals(value, dateMeta) {
|
|
@@ -788,11 +812,13 @@ export default {
|
|
|
788
812
|
},
|
|
789
813
|
isDateBetween(start, end, dateMeta) {
|
|
790
814
|
let between = false;
|
|
815
|
+
let parsedStart = this.parseValueForComparison(start);
|
|
816
|
+
let parsedEnd = this.parseValueForComparison(end);
|
|
791
817
|
|
|
792
|
-
if (
|
|
818
|
+
if (parsedStart && parsedEnd) {
|
|
793
819
|
let date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
|
|
794
820
|
|
|
795
|
-
return
|
|
821
|
+
return parsedStart.getTime() <= date.getTime() && parsedEnd.getTime() >= date.getTime();
|
|
796
822
|
}
|
|
797
823
|
|
|
798
824
|
return between;
|
|
@@ -1201,7 +1227,7 @@ export default {
|
|
|
1201
1227
|
}
|
|
1202
1228
|
|
|
1203
1229
|
if (this.isMultipleSelection() && this.isSelected(dateMeta)) {
|
|
1204
|
-
let newValue = this.
|
|
1230
|
+
let newValue = this.rawValue.filter((date) => !this.isDateEquals(this.parseValueForComparison(date), dateMeta));
|
|
1205
1231
|
|
|
1206
1232
|
this.updateModel(newValue);
|
|
1207
1233
|
} else {
|
|
@@ -1255,12 +1281,11 @@ export default {
|
|
|
1255
1281
|
if (this.isSingleSelection()) {
|
|
1256
1282
|
modelVal = date;
|
|
1257
1283
|
} else if (this.isMultipleSelection()) {
|
|
1258
|
-
modelVal = this.
|
|
1284
|
+
modelVal = this.rawValue ? [...this.rawValue, date] : [date];
|
|
1259
1285
|
} else if (this.isRangeSelection()) {
|
|
1260
|
-
if (this.
|
|
1261
|
-
let startDate = this.
|
|
1262
|
-
let endDate = this.
|
|
1263
|
-
|
|
1286
|
+
if (this.rawValue && this.rawValue.length) {
|
|
1287
|
+
let startDate = this.parseValueForComparison(this.rawValue[0]);
|
|
1288
|
+
let endDate = this.rawValue[1];
|
|
1264
1289
|
if (!endDate && date.getTime() >= startDate.getTime()) {
|
|
1265
1290
|
endDate = date;
|
|
1266
1291
|
this.focusedDateIndex = 1;
|
|
@@ -1269,7 +1294,6 @@ export default {
|
|
|
1269
1294
|
endDate = null;
|
|
1270
1295
|
this.focusedDateIndex = 0;
|
|
1271
1296
|
}
|
|
1272
|
-
|
|
1273
1297
|
modelVal = [startDate, endDate];
|
|
1274
1298
|
} else {
|
|
1275
1299
|
modelVal = [date, null];
|
|
@@ -1290,10 +1314,49 @@ export default {
|
|
|
1290
1314
|
this.$emit('date-select', date);
|
|
1291
1315
|
},
|
|
1292
1316
|
updateModel(value) {
|
|
1293
|
-
this.
|
|
1317
|
+
this.rawValue = value;
|
|
1318
|
+
|
|
1319
|
+
if (this.updateModelType === 'date') {
|
|
1320
|
+
if (this.isSingleSelection()) {
|
|
1321
|
+
this.writeValue(value);
|
|
1322
|
+
} else {
|
|
1323
|
+
let stringArrValue = null;
|
|
1324
|
+
|
|
1325
|
+
if (Array.isArray(value)) {
|
|
1326
|
+
stringArrValue = value.map((date) => this.parseValueForComparison(date));
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
this.writeValue(stringArrValue);
|
|
1330
|
+
}
|
|
1331
|
+
} else if (this.updateModelType == 'string') {
|
|
1332
|
+
if (this.isSingleSelection()) {
|
|
1333
|
+
this.writeValue(this.formatDateTime(value));
|
|
1334
|
+
} else if (this.isMultipleSelection()) {
|
|
1335
|
+
let stringArrValue = null;
|
|
1336
|
+
|
|
1337
|
+
if (Array.isArray(value)) {
|
|
1338
|
+
stringArrValue = value.map((date) => this.formatDateTime(date));
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
this.writeValue(stringArrValue);
|
|
1342
|
+
} else if (this.isRangeSelection()) {
|
|
1343
|
+
let stringArrValue = null;
|
|
1344
|
+
|
|
1345
|
+
if (Array.isArray(value)) {
|
|
1346
|
+
stringArrValue = value.map((date) => {
|
|
1347
|
+
if (date === null || date === undefined) {
|
|
1348
|
+
return null;
|
|
1349
|
+
}
|
|
1350
|
+
return typeof date === 'string' ? date : this.formatDateTime(date);
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
this.writeValue(stringArrValue);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1294
1357
|
},
|
|
1295
1358
|
shouldSelectDate() {
|
|
1296
|
-
if (this.isMultipleSelection()) return this.maxDateCount != null ? this.maxDateCount > (this.
|
|
1359
|
+
if (this.isMultipleSelection()) return this.maxDateCount != null ? this.maxDateCount > (this.rawValue ? this.rawValue.length : 0) : true;
|
|
1297
1360
|
else return true;
|
|
1298
1361
|
},
|
|
1299
1362
|
isSingleSelection() {
|
|
@@ -1318,7 +1381,7 @@ export default {
|
|
|
1318
1381
|
formattedValue = this.formatDateTime(value);
|
|
1319
1382
|
} else if (this.isMultipleSelection()) {
|
|
1320
1383
|
for (let i = 0; i < value.length; i++) {
|
|
1321
|
-
let dateAsString = this.formatDateTime(value[i]);
|
|
1384
|
+
let dateAsString = typeof value[i] === 'string' ? this.formatDateTime(this.parseValueForComparison(value[i])) : this.formatDateTime(value[i]);
|
|
1322
1385
|
|
|
1323
1386
|
formattedValue += dateAsString;
|
|
1324
1387
|
|
|
@@ -1328,8 +1391,8 @@ export default {
|
|
|
1328
1391
|
}
|
|
1329
1392
|
} else if (this.isRangeSelection()) {
|
|
1330
1393
|
if (value && value.length) {
|
|
1331
|
-
let startDate = value[0];
|
|
1332
|
-
let endDate = value[1];
|
|
1394
|
+
let startDate = this.parseValueForComparison(value[0]);
|
|
1395
|
+
let endDate = this.parseValueForComparison(value[1]);
|
|
1333
1396
|
|
|
1334
1397
|
formattedValue = this.formatDateTime(startDate);
|
|
1335
1398
|
|
|
@@ -1348,7 +1411,7 @@ export default {
|
|
|
1348
1411
|
formatDateTime(date) {
|
|
1349
1412
|
let formattedValue = null;
|
|
1350
1413
|
|
|
1351
|
-
if (date) {
|
|
1414
|
+
if (isDate(date) && isNotEmpty(date)) {
|
|
1352
1415
|
if (this.timeOnly) {
|
|
1353
1416
|
formattedValue = this.formatTime(date);
|
|
1354
1417
|
} else {
|
|
@@ -1358,6 +1421,8 @@ export default {
|
|
|
1358
1421
|
formattedValue += ' ' + this.formatTime(date);
|
|
1359
1422
|
}
|
|
1360
1423
|
}
|
|
1424
|
+
} else if (this.updateModelType === 'string') {
|
|
1425
|
+
formattedValue = date;
|
|
1361
1426
|
}
|
|
1362
1427
|
|
|
1363
1428
|
return formattedValue;
|
|
@@ -1497,7 +1562,7 @@ export default {
|
|
|
1497
1562
|
event.preventDefault();
|
|
1498
1563
|
},
|
|
1499
1564
|
onClearButtonClick(event) {
|
|
1500
|
-
this.updateModel(
|
|
1565
|
+
this.updateModel(null);
|
|
1501
1566
|
this.overlayVisible = false;
|
|
1502
1567
|
this.$emit('clear-click', event);
|
|
1503
1568
|
event.preventDefault();
|
|
@@ -1580,15 +1645,15 @@ export default {
|
|
|
1580
1645
|
return hours;
|
|
1581
1646
|
},
|
|
1582
1647
|
validateTime(hour, minute, second, pm) {
|
|
1583
|
-
let value = this.
|
|
1648
|
+
let value = this.viewDate;
|
|
1584
1649
|
const convertedHour = this.convertTo24Hour(hour, pm);
|
|
1585
1650
|
|
|
1586
1651
|
if (this.isRangeSelection()) {
|
|
1587
|
-
value = this.
|
|
1652
|
+
value = this.rawValue[1] || this.rawValue[0];
|
|
1588
1653
|
}
|
|
1589
1654
|
|
|
1590
1655
|
if (this.isMultipleSelection()) {
|
|
1591
|
-
value = this.
|
|
1656
|
+
value = this.rawValue[this.rawValue.length - 1];
|
|
1592
1657
|
}
|
|
1593
1658
|
|
|
1594
1659
|
const valueDateString = value ? value.toDateString() : null;
|
|
@@ -1716,14 +1781,14 @@ export default {
|
|
|
1716
1781
|
},
|
|
1717
1782
|
updateModelTime() {
|
|
1718
1783
|
this.timePickerChange = true;
|
|
1719
|
-
let value = this.
|
|
1784
|
+
let value = this.viewDate;
|
|
1720
1785
|
|
|
1721
1786
|
if (this.isRangeSelection()) {
|
|
1722
|
-
value = this.
|
|
1787
|
+
value = this.rawValue[this.focusedDateIndex] || this.rawValue[0];
|
|
1723
1788
|
}
|
|
1724
1789
|
|
|
1725
1790
|
if (this.isMultipleSelection()) {
|
|
1726
|
-
value = this.
|
|
1791
|
+
value = this.rawValue[this.rawValue.length - 1];
|
|
1727
1792
|
}
|
|
1728
1793
|
|
|
1729
1794
|
value = value ? new Date(value.getTime()) : new Date();
|
|
@@ -1739,17 +1804,17 @@ export default {
|
|
|
1739
1804
|
value.setSeconds(this.currentSecond);
|
|
1740
1805
|
|
|
1741
1806
|
if (this.isRangeSelection()) {
|
|
1742
|
-
if (this.focusedDateIndex === 1 && this.
|
|
1743
|
-
value = [this.
|
|
1807
|
+
if (this.focusedDateIndex === 1 && this.rawValue[1]) {
|
|
1808
|
+
value = [this.rawValue[0], value];
|
|
1744
1809
|
} else if (this.focusedDateIndex === 0) {
|
|
1745
|
-
value = [value, this.
|
|
1810
|
+
value = [value, this.rawValue[1]];
|
|
1746
1811
|
} else {
|
|
1747
1812
|
value = [value, null];
|
|
1748
1813
|
}
|
|
1749
1814
|
}
|
|
1750
1815
|
|
|
1751
1816
|
if (this.isMultipleSelection()) {
|
|
1752
|
-
value = [...this.
|
|
1817
|
+
value = [...this.rawValue.slice(0, -1), value];
|
|
1753
1818
|
}
|
|
1754
1819
|
|
|
1755
1820
|
this.updateModel(value);
|
|
@@ -1801,8 +1866,8 @@ export default {
|
|
|
1801
1866
|
if (this.showTime || this.timeOnly) {
|
|
1802
1867
|
let timeDate = viewDate;
|
|
1803
1868
|
|
|
1804
|
-
if (this.isRangeSelection() && this.
|
|
1805
|
-
timeDate = this.
|
|
1869
|
+
if (this.isRangeSelection() && this.rawValue && this.rawValue[this.focusedDateIndex]) {
|
|
1870
|
+
timeDate = this.rawValue[this.focusedDateIndex];
|
|
1806
1871
|
}
|
|
1807
1872
|
|
|
1808
1873
|
this.updateCurrentTimeMeta(timeDate);
|
|
@@ -1856,19 +1921,28 @@ export default {
|
|
|
1856
1921
|
|
|
1857
1922
|
return value;
|
|
1858
1923
|
},
|
|
1924
|
+
parseValueForComparison(value) {
|
|
1925
|
+
if (typeof value === 'string') {
|
|
1926
|
+
const parsedValue = this.parseValue(value);
|
|
1927
|
+
|
|
1928
|
+
return this.isSingleSelection() ? parsedValue : parsedValue[0];
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
return value;
|
|
1932
|
+
},
|
|
1859
1933
|
parseDateTime(text) {
|
|
1860
1934
|
let date;
|
|
1861
|
-
let parts = text.
|
|
1935
|
+
let parts = text.match(/(?:(.+?) )?(\d{2}:\d{2})(?: (am|pm))?/);
|
|
1862
1936
|
|
|
1863
1937
|
if (this.timeOnly) {
|
|
1864
1938
|
date = new Date();
|
|
1865
|
-
this.populateTime(date, parts[
|
|
1939
|
+
this.populateTime(date, parts[2], parts[3]);
|
|
1866
1940
|
} else {
|
|
1867
1941
|
const dateFormat = this.datePattern;
|
|
1868
1942
|
|
|
1869
1943
|
if (this.showTime) {
|
|
1870
|
-
date = this.parseDate(parts[
|
|
1871
|
-
this.populateTime(date, parts[
|
|
1944
|
+
date = this.parseDate(parts[1], dateFormat);
|
|
1945
|
+
this.populateTime(date, parts[2], parts[3]);
|
|
1872
1946
|
} else {
|
|
1873
1947
|
date = this.parseDate(text, dateFormat);
|
|
1874
1948
|
}
|
|
@@ -2686,11 +2760,15 @@ export default {
|
|
|
2686
2760
|
this.selectionStart = this.input.selectionStart;
|
|
2687
2761
|
this.selectionEnd = this.input.selectionEnd;
|
|
2688
2762
|
|
|
2763
|
+
if (this.$refs.clearIcon?.$el?.style) {
|
|
2764
|
+
this.$refs.clearIcon.$el.style.display = isEmpty(event.target.value) ? 'none' : 'block';
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2689
2767
|
let value = this.parseValue(event.target.value);
|
|
2690
2768
|
|
|
2691
2769
|
if (this.isValidSelection(value)) {
|
|
2692
2770
|
this.typeUpdate = true;
|
|
2693
|
-
this.updateModel(value);
|
|
2771
|
+
this.updateModel(this.updateModelType === 'string' ? this.formatValue(value) : value);
|
|
2694
2772
|
this.updateCurrentMetaData();
|
|
2695
2773
|
}
|
|
2696
2774
|
} catch (err) {
|
|
@@ -2717,7 +2795,11 @@ export default {
|
|
|
2717
2795
|
this.formField.onBlur?.();
|
|
2718
2796
|
|
|
2719
2797
|
this.focused = false;
|
|
2720
|
-
event.target.value = this.formatValue(this.
|
|
2798
|
+
event.target.value = this.formatValue(this.rawValue);
|
|
2799
|
+
|
|
2800
|
+
if (this.$refs.clearIcon?.$el?.style) {
|
|
2801
|
+
this.$refs.clearIcon.$el.style.display = isEmpty(event.target.value) ? 'none' : 'block';
|
|
2802
|
+
}
|
|
2721
2803
|
},
|
|
2722
2804
|
onKeyDown(event) {
|
|
2723
2805
|
if (event.code === 'ArrowDown' && this.overlay) {
|
|
@@ -2772,6 +2854,10 @@ export default {
|
|
|
2772
2854
|
getYear(month) {
|
|
2773
2855
|
return this.currentView === 'month' ? this.currentYear : month.year;
|
|
2774
2856
|
},
|
|
2857
|
+
onClearClick() {
|
|
2858
|
+
this.updateModel(null);
|
|
2859
|
+
this.overlayVisible = false;
|
|
2860
|
+
},
|
|
2775
2861
|
onOverlayClick(event) {
|
|
2776
2862
|
event.stopPropagation();
|
|
2777
2863
|
|
|
@@ -2859,18 +2945,24 @@ export default {
|
|
|
2859
2945
|
},
|
|
2860
2946
|
computed: {
|
|
2861
2947
|
viewDate() {
|
|
2862
|
-
let propValue = this.
|
|
2948
|
+
let propValue = this.rawValue;
|
|
2863
2949
|
|
|
2864
2950
|
if (propValue && Array.isArray(propValue)) {
|
|
2865
2951
|
if (this.isRangeSelection()) {
|
|
2866
|
-
if (propValue.length ===
|
|
2952
|
+
if (propValue.length === 0) {
|
|
2953
|
+
propValue = null;
|
|
2954
|
+
} else if (propValue.length === 1) {
|
|
2867
2955
|
propValue = propValue[0];
|
|
2868
2956
|
} else {
|
|
2869
|
-
|
|
2957
|
+
const start = this.parseValueForComparison(propValue[0]);
|
|
2958
|
+
let lastVisibleMonth = new Date(start.getFullYear(), start.getMonth() + this.numberOfMonths, 1);
|
|
2959
|
+
|
|
2870
2960
|
if (propValue[1] < lastVisibleMonth) {
|
|
2871
2961
|
propValue = propValue[0];
|
|
2872
2962
|
} else {
|
|
2873
|
-
|
|
2963
|
+
const end = this.parseValueForComparison(propValue[1]);
|
|
2964
|
+
|
|
2965
|
+
propValue = new Date(end.getFullYear(), end.getMonth() - this.numberOfMonths + 1, 1);
|
|
2874
2966
|
}
|
|
2875
2967
|
}
|
|
2876
2968
|
} else if (this.isMultipleSelection()) {
|
|
@@ -2895,7 +2987,7 @@ export default {
|
|
|
2895
2987
|
}
|
|
2896
2988
|
},
|
|
2897
2989
|
inputFieldValue() {
|
|
2898
|
-
return this.formatValue(this.
|
|
2990
|
+
return this.formatValue(this.rawValue);
|
|
2899
2991
|
},
|
|
2900
2992
|
months() {
|
|
2901
2993
|
let months = [];
|
|
@@ -2925,13 +3017,26 @@ export default {
|
|
|
2925
3017
|
for (let j = prevMonthDaysLength - firstDay + 1; j <= prevMonthDaysLength; j++) {
|
|
2926
3018
|
let prev = this.getPreviousMonthAndYear(month, year);
|
|
2927
3019
|
|
|
2928
|
-
week.push({
|
|
3020
|
+
week.push({
|
|
3021
|
+
day: j,
|
|
3022
|
+
month: prev.month,
|
|
3023
|
+
year: prev.year,
|
|
3024
|
+
otherMonth: true,
|
|
3025
|
+
today: this.isToday(today, j, prev.month, prev.year),
|
|
3026
|
+
selectable: this.isSelectable(j, prev.month, prev.year, true)
|
|
3027
|
+
});
|
|
2929
3028
|
}
|
|
2930
3029
|
|
|
2931
3030
|
let remainingDaysLength = 7 - week.length;
|
|
2932
3031
|
|
|
2933
3032
|
for (let j = 0; j < remainingDaysLength; j++) {
|
|
2934
|
-
week.push({
|
|
3033
|
+
week.push({
|
|
3034
|
+
day: dayNo,
|
|
3035
|
+
month: month,
|
|
3036
|
+
year: year,
|
|
3037
|
+
today: this.isToday(today, dayNo, month, year),
|
|
3038
|
+
selectable: this.isSelectable(dayNo, month, year, false)
|
|
3039
|
+
});
|
|
2935
3040
|
dayNo++;
|
|
2936
3041
|
}
|
|
2937
3042
|
} else {
|
|
@@ -2948,7 +3053,13 @@ export default {
|
|
|
2948
3053
|
selectable: this.isSelectable(dayNo - daysLength, next.month, next.year, true)
|
|
2949
3054
|
});
|
|
2950
3055
|
} else {
|
|
2951
|
-
week.push({
|
|
3056
|
+
week.push({
|
|
3057
|
+
day: dayNo,
|
|
3058
|
+
month: month,
|
|
3059
|
+
year: year,
|
|
3060
|
+
today: this.isToday(today, dayNo, month, year),
|
|
3061
|
+
selectable: this.isSelectable(dayNo, month, year, false)
|
|
3062
|
+
});
|
|
2952
3063
|
}
|
|
2953
3064
|
|
|
2954
3065
|
dayNo++;
|
|
@@ -3018,7 +3129,10 @@ export default {
|
|
|
3018
3129
|
};
|
|
3019
3130
|
|
|
3020
3131
|
for (let i = 0; i <= 11; i++) {
|
|
3021
|
-
monthPickerValues.push({
|
|
3132
|
+
monthPickerValues.push({
|
|
3133
|
+
value: this.$primevue.config.locale.monthNamesShort[i],
|
|
3134
|
+
selectable: isSelectableMonth(i)
|
|
3135
|
+
});
|
|
3022
3136
|
}
|
|
3023
3137
|
|
|
3024
3138
|
return monthPickerValues;
|
|
@@ -3073,6 +3187,9 @@ export default {
|
|
|
3073
3187
|
switchViewButtonDisabled() {
|
|
3074
3188
|
return this.numberOfMonths > 1 || this.disabled;
|
|
3075
3189
|
},
|
|
3190
|
+
isClearIconVisible() {
|
|
3191
|
+
return this.showClear && this.rawValue != null && !this.disabled;
|
|
3192
|
+
},
|
|
3076
3193
|
panelId() {
|
|
3077
3194
|
return this.$id + '_panel';
|
|
3078
3195
|
},
|
|
@@ -3160,7 +3277,8 @@ export default {
|
|
|
3160
3277
|
ChevronLeftIcon,
|
|
3161
3278
|
ChevronRightIcon,
|
|
3162
3279
|
ChevronUpIcon,
|
|
3163
|
-
ChevronDownIcon
|
|
3280
|
+
ChevronDownIcon,
|
|
3281
|
+
TimesIcon
|
|
3164
3282
|
},
|
|
3165
3283
|
directives: {
|
|
3166
3284
|
ripple: Ripple
|
package/datepicker/index.d.ts
CHANGED
|
@@ -155,6 +155,10 @@ export interface DatePickerPassThroughOptions {
|
|
|
155
155
|
* Used to pass attributes to the input icon's DOM element.
|
|
156
156
|
*/
|
|
157
157
|
inputIcon?: DatePickerPassThroughOptionType;
|
|
158
|
+
/**
|
|
159
|
+
* Used to pass attributes to the label's DOM element.
|
|
160
|
+
*/
|
|
161
|
+
clearIcon?: DatePickerPassThroughOptionType;
|
|
158
162
|
/**
|
|
159
163
|
* Used to pass attributes to the panel's DOM element.
|
|
160
164
|
*/
|
|
@@ -534,6 +538,11 @@ export interface DatePickerProps {
|
|
|
534
538
|
* Format of the date. Defaults to PrimeVue Locale configuration.
|
|
535
539
|
*/
|
|
536
540
|
dateFormat?: string | undefined;
|
|
541
|
+
/**
|
|
542
|
+
* Type of the value to write back to modelValue.
|
|
543
|
+
* @defaultValue date
|
|
544
|
+
*/
|
|
545
|
+
updateModelType: HintedString<'date' | 'string'> | undefined;
|
|
537
546
|
/**
|
|
538
547
|
* When enabled, displays the datepicker as inline instead of an overlay.
|
|
539
548
|
* @defaultValue false
|
|
@@ -703,6 +712,11 @@ export interface DatePickerProps {
|
|
|
703
712
|
* @defaultValue true
|
|
704
713
|
*/
|
|
705
714
|
manualInput?: boolean | undefined;
|
|
715
|
+
/**
|
|
716
|
+
* When enabled, a clear icon is displayed to clear the value.
|
|
717
|
+
* @defaultValue false
|
|
718
|
+
*/
|
|
719
|
+
showClear?: boolean | undefined;
|
|
706
720
|
/**
|
|
707
721
|
* Defines the size of the component.
|
|
708
722
|
*/
|
|
@@ -1122,6 +1136,17 @@ export interface DatePickerSlots {
|
|
|
1122
1136
|
*/
|
|
1123
1137
|
toggleCallback: (event: Event) => void;
|
|
1124
1138
|
}): VNode[];
|
|
1139
|
+
/**
|
|
1140
|
+
* Custom clear icon template.
|
|
1141
|
+
* @param {Object} scope - clear icon slot's params.
|
|
1142
|
+
*/
|
|
1143
|
+
clearicon(scope: {
|
|
1144
|
+
/**
|
|
1145
|
+
* Clear icon click function.
|
|
1146
|
+
* @param {Event} event - Browser event
|
|
1147
|
+
*/
|
|
1148
|
+
clearCallback: (event: Event) => void;
|
|
1149
|
+
}): VNode[];
|
|
1125
1150
|
}
|
|
1126
1151
|
|
|
1127
1152
|
/**
|