primevue 4.3.9 → 4.4.1

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.
Files changed (101) hide show
  1. package/autocomplete/AutoComplete.vue +19 -4
  2. package/autocomplete/BaseAutoComplete.vue +4 -0
  3. package/autocomplete/index.d.ts +20 -0
  4. package/autocomplete/index.mjs +35 -8
  5. package/autocomplete/index.mjs.map +1 -1
  6. package/autocomplete/style/index.d.ts +4 -0
  7. package/autocomplete/style/index.mjs +3 -1
  8. package/autocomplete/style/index.mjs.map +1 -1
  9. package/cascadeselect/CascadeSelect.vue +1 -1
  10. package/cascadeselect/index.mjs +1 -1
  11. package/cascadeselect/index.mjs.map +1 -1
  12. package/checkbox/Checkbox.vue +15 -2
  13. package/checkbox/index.mjs +14 -2
  14. package/checkbox/index.mjs.map +1 -1
  15. package/colorpicker/ColorPicker.vue +3 -4
  16. package/colorpicker/index.mjs +3 -3
  17. package/colorpicker/index.mjs.map +1 -1
  18. package/confirmdialog/ConfirmDialog.vue +1 -1
  19. package/confirmdialog/index.d.ts +5 -0
  20. package/confirmdialog/index.mjs +3 -2
  21. package/confirmdialog/index.mjs.map +1 -1
  22. package/datatable/ColumnFilter.vue +1 -1
  23. package/datatable/DataTable.vue +2 -2
  24. package/datatable/HeaderCheckbox.vue +3 -3
  25. package/datatable/index.mjs +13 -4
  26. package/datatable/index.mjs.map +1 -1
  27. package/datepicker/BaseDatePicker.vue +8 -0
  28. package/datepicker/DatePicker.vue +225 -105
  29. package/datepicker/index.d.ts +43 -2
  30. package/datepicker/index.mjs +303 -186
  31. package/datepicker/index.mjs.map +1 -1
  32. package/datepicker/style/index.d.ts +4 -0
  33. package/datepicker/style/index.mjs +5 -2
  34. package/datepicker/style/index.mjs.map +1 -1
  35. package/drawer/BaseDrawer.vue +4 -0
  36. package/drawer/Drawer.vue +5 -5
  37. package/drawer/index.d.ts +5 -0
  38. package/drawer/index.mjs +11 -7
  39. package/drawer/index.mjs.map +1 -1
  40. package/editor/Editor.vue +5 -1
  41. package/editor/index.mjs +5 -0
  42. package/editor/index.mjs.map +1 -1
  43. package/image/index.d.ts +5 -11
  44. package/inputmask/InputMask.vue +1 -2
  45. package/inputmask/index.mjs +1 -1
  46. package/inputmask/index.mjs.map +1 -1
  47. package/inputnumber/BaseInputNumber.vue +4 -0
  48. package/inputnumber/InputNumber.vue +30 -5
  49. package/inputnumber/index.d.ts +20 -0
  50. package/inputnumber/index.mjs +45 -7
  51. package/inputnumber/index.mjs.map +1 -1
  52. package/inputnumber/style/index.mjs +1 -0
  53. package/inputnumber/style/index.mjs.map +1 -1
  54. package/inputotp/InputOtp.vue +7 -3
  55. package/inputotp/index.mjs +6 -3
  56. package/inputotp/index.mjs.map +1 -1
  57. package/listbox/Listbox.vue +1 -1
  58. package/listbox/index.mjs +1 -1
  59. package/listbox/index.mjs.map +1 -1
  60. package/menu/Menu.vue +2 -2
  61. package/menu/index.mjs +1 -1
  62. package/menu/index.mjs.map +1 -1
  63. package/multiselect/MultiSelect.vue +10 -6
  64. package/multiselect/index.mjs +15 -11
  65. package/multiselect/index.mjs.map +1 -1
  66. package/package.json +5 -5
  67. package/panel/Panel.vue +1 -1
  68. package/panel/index.d.ts +4 -0
  69. package/panel/index.mjs +2 -1
  70. package/panel/index.mjs.map +1 -1
  71. package/password/BasePassword.vue +4 -0
  72. package/password/Password.vue +14 -2
  73. package/password/index.d.ts +20 -0
  74. package/password/index.mjs +26 -3
  75. package/password/index.mjs.map +1 -1
  76. package/password/style/index.d.ts +4 -0
  77. package/password/style/index.mjs +1 -0
  78. package/password/style/index.mjs.map +1 -1
  79. package/select/Select.vue +2 -1
  80. package/select/index.mjs +2 -1
  81. package/select/index.mjs.map +1 -1
  82. package/speeddial/SpeedDial.vue +1 -1
  83. package/speeddial/index.mjs +1 -1
  84. package/speeddial/index.mjs.map +1 -1
  85. package/splitbutton/SplitButton.vue +1 -1
  86. package/splitbutton/index.mjs +1 -1
  87. package/splitbutton/index.mjs.map +1 -1
  88. package/tree/BaseTree.vue +20 -0
  89. package/tree/Tree.vue +236 -4
  90. package/tree/TreeNode.vue +295 -3
  91. package/tree/index.d.ts +140 -0
  92. package/tree/index.mjs +637 -27
  93. package/tree/index.mjs.map +1 -1
  94. package/tree/style/index.mjs +9 -4
  95. package/tree/style/index.mjs.map +1 -1
  96. package/treenode/index.d.ts +12 -0
  97. package/treeselect/TreeSelect.vue +3 -2
  98. package/treeselect/index.mjs +6 -5
  99. package/treeselect/index.mjs.map +1 -1
  100. package/umd/primevue.min.js +1 -1
  101. 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'
@@ -20,7 +20,7 @@
20
20
  aria-autocomplete="none"
21
21
  aria-haspopup="dialog"
22
22
  :aria-expanded="overlayVisible"
23
- :aria-controls="panelId"
23
+ :aria-controls="overlayVisible ? panelId : undefined"
24
24
  :aria-labelledby="ariaLabelledby"
25
25
  :aria-label="ariaLabel"
26
26
  inputmode="none"
@@ -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')"
@@ -528,29 +531,31 @@
528
531
  </div>
529
532
  </div>
530
533
  <div v-if="showButtonBar" :class="cx('buttonbar')" v-bind="ptm('buttonbar')">
531
- <slot name="todaybutton" :actionCallback="(event) => onTodayButtonClick(event)" :keydownCallback="(event) => onContainerButtonKeydown(event)">
532
- <Button
533
- :label="todayLabel"
534
- @click="onTodayButtonClick($event)"
535
- :class="cx('pcTodayButton')"
536
- :unstyled="unstyled"
537
- @keydown="onContainerButtonKeydown"
538
- v-bind="todayButtonProps"
539
- :pt="ptm('pcTodayButton')"
540
- data-pc-group-section="button"
541
- />
542
- </slot>
543
- <slot name="clearbutton" :actionCallback="(event) => onClearButtonClick(event)" :keydownCallback="(event) => onContainerButtonKeydown(event)">
544
- <Button
545
- :label="clearLabel"
546
- @click="onClearButtonClick($event)"
547
- :class="cx('pcClearButton')"
548
- :unstyled="unstyled"
549
- @keydown="onContainerButtonKeydown"
550
- v-bind="clearButtonProps"
551
- :pt="ptm('pcClearButton')"
552
- data-pc-group-section="button"
553
- />
534
+ <slot name="buttonbar" :todayCallback="(event) => onTodayButtonClick(event)" :clearCallback="(event) => onClearButtonClick(event)">
535
+ <slot name="todaybutton" :actionCallback="(event) => onTodayButtonClick(event)" :keydownCallback="(event) => onContainerButtonKeydown(event)">
536
+ <Button
537
+ :label="todayLabel"
538
+ @click="onTodayButtonClick($event)"
539
+ :class="cx('pcTodayButton')"
540
+ :unstyled="unstyled"
541
+ @keydown="onContainerButtonKeydown"
542
+ v-bind="todayButtonProps"
543
+ :pt="ptm('pcTodayButton')"
544
+ data-pc-group-section="button"
545
+ />
546
+ </slot>
547
+ <slot name="clearbutton" :actionCallback="(event) => onClearButtonClick(event)" :keydownCallback="(event) => onContainerButtonKeydown(event)">
548
+ <Button
549
+ :label="clearLabel"
550
+ @click="onClearButtonClick($event)"
551
+ :class="cx('pcClearButton')"
552
+ :unstyled="unstyled"
553
+ @keydown="onContainerButtonKeydown"
554
+ v-bind="clearButtonProps"
555
+ :pt="ptm('pcClearButton')"
556
+ data-pc-group-section="button"
557
+ />
558
+ </slot>
554
559
  </slot>
555
560
  </div>
556
561
  <slot name="footer"></slot>
@@ -563,7 +568,7 @@
563
568
  <script>
564
569
  import { cn } from '@primeuix/utils';
565
570
  import { absolutePosition, addStyle, find, findSingle, getAttribute, getFocusableElements, getIndex, getOuterWidth, isTouchDevice, relativePosition, setAttribute } from '@primeuix/utils/dom';
566
- import { localeComparator } from '@primeuix/utils/object';
571
+ import { isDate, isEmpty, isNotEmpty, localeComparator } from '@primeuix/utils/object';
567
572
  import { ZIndex } from '@primeuix/utils/zindex';
568
573
  import { ConnectedOverlayScrollHandler } from '@primevue/core/utils';
569
574
  import CalendarIcon from '@primevue/icons/calendar';
@@ -571,6 +576,7 @@ import ChevronDownIcon from '@primevue/icons/chevrondown';
571
576
  import ChevronLeftIcon from '@primevue/icons/chevronleft';
572
577
  import ChevronRightIcon from '@primevue/icons/chevronright';
573
578
  import ChevronUpIcon from '@primevue/icons/chevronup';
579
+ import TimesIcon from '@primevue/icons/times';
574
580
  import Button from 'primevue/button';
575
581
  import InputText from 'primevue/inputtext';
576
582
  import OverlayEventBus from 'primevue/overlayeventbus';
@@ -614,18 +620,27 @@ export default {
614
620
  query: null,
615
621
  queryMatches: false,
616
622
  queryOrientation: null,
617
- focusedDateIndex: 0
623
+ focusedDateIndex: 0,
624
+ rawValue: null
618
625
  };
619
626
  },
620
627
  watch: {
621
- modelValue(newValue) {
622
- this.updateCurrentMetaData();
628
+ modelValue: {
629
+ immediate: true,
630
+ handler(newValue) {
631
+ this.updateCurrentMetaData();
632
+ this.rawValue = typeof newValue === 'string' ? this.parseValue(newValue) : newValue;
623
633
 
624
- if (!this.typeUpdate && !this.inline && this.input) {
625
- this.input.value = this.inputFieldValue;
626
- }
634
+ if (!this.typeUpdate && !this.inline && this.input) {
635
+ this.input.value = this.formatValue(this.rawValue);
636
+ }
627
637
 
628
- this.typeUpdate = false;
638
+ this.typeUpdate = false;
639
+
640
+ if (this.$refs.clearIcon?.$el?.style) {
641
+ this.$refs.clearIcon.$el.style.display = isEmpty(newValue) ? 'none' : 'block';
642
+ }
643
+ }
629
644
  },
630
645
  showTime() {
631
646
  this.updateCurrentMetaData();
@@ -677,6 +692,10 @@ export default {
677
692
  }
678
693
  } else {
679
694
  this.input.value = this.inputFieldValue;
695
+
696
+ if (this.$refs.clearIcon?.$el?.style) {
697
+ this.$refs.clearIcon.$el.style.display = !this.$filled ? 'none' : 'block';
698
+ }
680
699
  }
681
700
  },
682
701
  updated() {
@@ -716,22 +735,15 @@ export default {
716
735
  this.overlay = null;
717
736
  },
718
737
  methods: {
719
- isComparable() {
720
- return this.d_value != null && typeof this.d_value !== 'string';
721
- },
722
738
  isSelected(dateMeta) {
723
- if (!this.isComparable()) {
724
- return false;
725
- }
726
-
727
- if (this.d_value) {
739
+ if (this.rawValue) {
728
740
  if (this.isSingleSelection()) {
729
- return this.isDateEquals(this.d_value, dateMeta);
741
+ return this.isDateEquals(this.parseValueForComparison(this.rawValue), dateMeta);
730
742
  } else if (this.isMultipleSelection()) {
731
743
  let selected = false;
732
744
 
733
- for (let date of this.d_value) {
734
- selected = this.isDateEquals(date, dateMeta);
745
+ for (let date of this.rawValue) {
746
+ selected = this.isDateEquals(this.parseValueForComparison(date), dateMeta);
735
747
 
736
748
  if (selected) {
737
749
  break;
@@ -740,9 +752,14 @@ export default {
740
752
 
741
753
  return selected;
742
754
  } else if (this.isRangeSelection()) {
743
- if (this.d_value[1]) return this.isDateEquals(this.d_value[0], dateMeta) || this.isDateEquals(this.d_value[1], dateMeta) || this.isDateBetween(this.d_value[0], this.d_value[1], dateMeta);
744
- else {
745
- return this.isDateEquals(this.d_value[0], dateMeta);
755
+ const start = this.parseValueForComparison(this.rawValue[0]);
756
+
757
+ if (this.rawValue[1]) {
758
+ const end = this.parseValueForComparison(this.rawValue[1]);
759
+
760
+ return this.isDateEquals(start, dateMeta) || this.isDateEquals(end, dateMeta) || this.isDateBetween(start, end, dateMeta);
761
+ } else {
762
+ return this.isDateEquals(start, dateMeta);
746
763
  }
747
764
  }
748
765
  }
@@ -750,36 +767,45 @@ export default {
750
767
  return false;
751
768
  },
752
769
  isMonthSelected(month) {
753
- if (!this.isComparable()) return false;
754
-
755
770
  if (this.isMultipleSelection()) {
756
- return this.d_value.some((currentValue) => currentValue.getMonth() === month && currentValue.getFullYear() === this.currentYear);
771
+ return this.rawValue?.some((currentValue) => {
772
+ const parsedDate = this.parseValueForComparison(currentValue);
773
+
774
+ return parsedDate.getMonth() === month && parsedDate.getFullYear() === this.currentYear;
775
+ });
757
776
  } else if (this.isRangeSelection()) {
758
- if (!this.d_value[1]) {
759
- return this.d_value[0]?.getFullYear() === this.currentYear && this.d_value[0]?.getMonth() === month;
777
+ const parsedStart = this.rawValue?.[0] ? this.parseValueForComparison(this.rawValue[0]) : null;
778
+ const parsedEnd = this.rawValue?.[1] ? this.parseValueForComparison(this.rawValue[1]) : null;
779
+
780
+ if (!parsedEnd) {
781
+ return parsedStart?.getFullYear() === this.currentYear && parsedStart?.getMonth() === month;
760
782
  } else {
761
783
  const currentDate = new Date(this.currentYear, month, 1);
762
- const startDate = new Date(this.d_value[0].getFullYear(), this.d_value[0].getMonth(), 1);
763
- const endDate = new Date(this.d_value[1].getFullYear(), this.d_value[1].getMonth(), 1);
764
-
784
+ const startDate = new Date(parsedStart.getFullYear(), parsedStart.getMonth(), 1);
785
+ const endDate = new Date(parsedEnd.getFullYear(), parsedEnd.getMonth(), 1);
765
786
  return currentDate >= startDate && currentDate <= endDate;
766
787
  }
767
788
  } else {
768
- return this.d_value.getMonth() === month && this.d_value.getFullYear() === this.currentYear;
789
+ return this.rawValue?.getMonth() === month && this.rawValue?.getFullYear() === this.currentYear;
769
790
  }
770
791
  },
771
792
  isYearSelected(year) {
772
- if (!this.isComparable()) return false;
773
-
774
793
  if (this.isMultipleSelection()) {
775
- return this.d_value.some((currentValue) => currentValue.getFullYear() === year);
794
+ return this.rawValue?.some((currentValue) => {
795
+ const parsedDate = this.parseValueForComparison(currentValue);
796
+
797
+ return parsedDate.getFullYear() === year;
798
+ });
776
799
  } else if (this.isRangeSelection()) {
777
- const start = this.d_value[0] ? this.d_value[0].getFullYear() : null;
778
- const end = this.d_value[1] ? this.d_value[1].getFullYear() : null;
800
+ const parsedStart = this.rawValue?.[0] ? this.parseValueForComparison(this.rawValue[0]) : null;
801
+ const parsedEnd = this.rawValue?.[1] ? this.parseValueForComparison(this.rawValue[1]) : null;
802
+
803
+ const start = parsedStart ? parsedStart.getFullYear() : null;
804
+ const end = parsedEnd ? parsedEnd.getFullYear() : null;
779
805
 
780
806
  return start === year || end === year || (start < year && end > year);
781
807
  } else {
782
- return this.d_value.getFullYear() === year;
808
+ return this.rawValue?.getFullYear() === year;
783
809
  }
784
810
  },
785
811
  isDateEquals(value, dateMeta) {
@@ -788,11 +814,13 @@ export default {
788
814
  },
789
815
  isDateBetween(start, end, dateMeta) {
790
816
  let between = false;
817
+ let parsedStart = this.parseValueForComparison(start);
818
+ let parsedEnd = this.parseValueForComparison(end);
791
819
 
792
- if (start && end) {
820
+ if (parsedStart && parsedEnd) {
793
821
  let date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
794
822
 
795
- return start.getTime() <= date.getTime() && end.getTime() >= date.getTime();
823
+ return parsedStart.getTime() <= date.getTime() && parsedEnd.getTime() >= date.getTime();
796
824
  }
797
825
 
798
826
  return between;
@@ -1201,7 +1229,7 @@ export default {
1201
1229
  }
1202
1230
 
1203
1231
  if (this.isMultipleSelection() && this.isSelected(dateMeta)) {
1204
- let newValue = this.d_value.filter((date) => !this.isDateEquals(date, dateMeta));
1232
+ let newValue = this.rawValue.filter((date) => !this.isDateEquals(this.parseValueForComparison(date), dateMeta));
1205
1233
 
1206
1234
  this.updateModel(newValue);
1207
1235
  } else {
@@ -1255,12 +1283,11 @@ export default {
1255
1283
  if (this.isSingleSelection()) {
1256
1284
  modelVal = date;
1257
1285
  } else if (this.isMultipleSelection()) {
1258
- modelVal = this.d_value ? [...this.d_value, date] : [date];
1286
+ modelVal = this.rawValue ? [...this.rawValue, date] : [date];
1259
1287
  } else if (this.isRangeSelection()) {
1260
- if (this.d_value && this.d_value.length) {
1261
- let startDate = this.d_value[0];
1262
- let endDate = this.d_value[1];
1263
-
1288
+ if (this.rawValue && this.rawValue.length) {
1289
+ let startDate = this.parseValueForComparison(this.rawValue[0]);
1290
+ let endDate = this.rawValue[1];
1264
1291
  if (!endDate && date.getTime() >= startDate.getTime()) {
1265
1292
  endDate = date;
1266
1293
  this.focusedDateIndex = 1;
@@ -1269,7 +1296,6 @@ export default {
1269
1296
  endDate = null;
1270
1297
  this.focusedDateIndex = 0;
1271
1298
  }
1272
-
1273
1299
  modelVal = [startDate, endDate];
1274
1300
  } else {
1275
1301
  modelVal = [date, null];
@@ -1290,10 +1316,49 @@ export default {
1290
1316
  this.$emit('date-select', date);
1291
1317
  },
1292
1318
  updateModel(value) {
1293
- this.writeValue(value);
1319
+ this.rawValue = value;
1320
+
1321
+ if (this.updateModelType === 'date') {
1322
+ if (this.isSingleSelection()) {
1323
+ this.writeValue(value);
1324
+ } else {
1325
+ let stringArrValue = null;
1326
+
1327
+ if (Array.isArray(value)) {
1328
+ stringArrValue = value.map((date) => this.parseValueForComparison(date));
1329
+ }
1330
+
1331
+ this.writeValue(stringArrValue);
1332
+ }
1333
+ } else if (this.updateModelType == 'string') {
1334
+ if (this.isSingleSelection()) {
1335
+ this.writeValue(this.formatDateTime(value));
1336
+ } else if (this.isMultipleSelection()) {
1337
+ let stringArrValue = null;
1338
+
1339
+ if (Array.isArray(value)) {
1340
+ stringArrValue = value.map((date) => this.formatDateTime(date));
1341
+ }
1342
+
1343
+ this.writeValue(stringArrValue);
1344
+ } else if (this.isRangeSelection()) {
1345
+ let stringArrValue = null;
1346
+
1347
+ if (Array.isArray(value)) {
1348
+ stringArrValue = value.map((date) => {
1349
+ if (date === null || date === undefined) {
1350
+ return null;
1351
+ }
1352
+ return typeof date === 'string' ? date : this.formatDateTime(date);
1353
+ });
1354
+ }
1355
+
1356
+ this.writeValue(stringArrValue);
1357
+ }
1358
+ }
1294
1359
  },
1295
1360
  shouldSelectDate() {
1296
- if (this.isMultipleSelection()) return this.maxDateCount != null ? this.maxDateCount > (this.d_value ? this.d_value.length : 0) : true;
1361
+ if (this.isMultipleSelection()) return this.maxDateCount != null ? this.maxDateCount > (this.rawValue ? this.rawValue.length : 0) : true;
1297
1362
  else return true;
1298
1363
  },
1299
1364
  isSingleSelection() {
@@ -1318,7 +1383,7 @@ export default {
1318
1383
  formattedValue = this.formatDateTime(value);
1319
1384
  } else if (this.isMultipleSelection()) {
1320
1385
  for (let i = 0; i < value.length; i++) {
1321
- let dateAsString = this.formatDateTime(value[i]);
1386
+ let dateAsString = typeof value[i] === 'string' ? this.formatDateTime(this.parseValueForComparison(value[i])) : this.formatDateTime(value[i]);
1322
1387
 
1323
1388
  formattedValue += dateAsString;
1324
1389
 
@@ -1328,8 +1393,8 @@ export default {
1328
1393
  }
1329
1394
  } else if (this.isRangeSelection()) {
1330
1395
  if (value && value.length) {
1331
- let startDate = value[0];
1332
- let endDate = value[1];
1396
+ let startDate = this.parseValueForComparison(value[0]);
1397
+ let endDate = this.parseValueForComparison(value[1]);
1333
1398
 
1334
1399
  formattedValue = this.formatDateTime(startDate);
1335
1400
 
@@ -1348,7 +1413,7 @@ export default {
1348
1413
  formatDateTime(date) {
1349
1414
  let formattedValue = null;
1350
1415
 
1351
- if (date) {
1416
+ if (isDate(date) && isNotEmpty(date)) {
1352
1417
  if (this.timeOnly) {
1353
1418
  formattedValue = this.formatTime(date);
1354
1419
  } else {
@@ -1358,6 +1423,8 @@ export default {
1358
1423
  formattedValue += ' ' + this.formatTime(date);
1359
1424
  }
1360
1425
  }
1426
+ } else if (this.updateModelType === 'string') {
1427
+ formattedValue = date;
1361
1428
  }
1362
1429
 
1363
1430
  return formattedValue;
@@ -1497,7 +1564,7 @@ export default {
1497
1564
  event.preventDefault();
1498
1565
  },
1499
1566
  onClearButtonClick(event) {
1500
- this.updateModel(this.$formDefaultValue || null);
1567
+ this.updateModel(null);
1501
1568
  this.overlayVisible = false;
1502
1569
  this.$emit('clear-click', event);
1503
1570
  event.preventDefault();
@@ -1580,15 +1647,15 @@ export default {
1580
1647
  return hours;
1581
1648
  },
1582
1649
  validateTime(hour, minute, second, pm) {
1583
- let value = this.isComparable() ? this.d_value : this.viewDate;
1650
+ let value = this.viewDate;
1584
1651
  const convertedHour = this.convertTo24Hour(hour, pm);
1585
1652
 
1586
1653
  if (this.isRangeSelection()) {
1587
- value = this.d_value[1] || this.d_value[0];
1654
+ value = this.rawValue[1] || this.rawValue[0];
1588
1655
  }
1589
1656
 
1590
1657
  if (this.isMultipleSelection()) {
1591
- value = this.d_value[this.d_value.length - 1];
1658
+ value = this.rawValue[this.rawValue.length - 1];
1592
1659
  }
1593
1660
 
1594
1661
  const valueDateString = value ? value.toDateString() : null;
@@ -1716,14 +1783,14 @@ export default {
1716
1783
  },
1717
1784
  updateModelTime() {
1718
1785
  this.timePickerChange = true;
1719
- let value = this.isComparable() ? this.d_value : this.viewDate;
1786
+ let value = this.viewDate;
1720
1787
 
1721
1788
  if (this.isRangeSelection()) {
1722
- value = this.d_value[this.focusedDateIndex] || this.d_value[0];
1789
+ value = this.rawValue[this.focusedDateIndex] || this.rawValue[0];
1723
1790
  }
1724
1791
 
1725
1792
  if (this.isMultipleSelection()) {
1726
- value = this.d_value[this.d_value.length - 1];
1793
+ value = this.rawValue[this.rawValue.length - 1];
1727
1794
  }
1728
1795
 
1729
1796
  value = value ? new Date(value.getTime()) : new Date();
@@ -1739,17 +1806,17 @@ export default {
1739
1806
  value.setSeconds(this.currentSecond);
1740
1807
 
1741
1808
  if (this.isRangeSelection()) {
1742
- if (this.focusedDateIndex === 1 && this.d_value[1]) {
1743
- value = [this.d_value[0], value];
1809
+ if (this.focusedDateIndex === 1 && this.rawValue[1]) {
1810
+ value = [this.rawValue[0], value];
1744
1811
  } else if (this.focusedDateIndex === 0) {
1745
- value = [value, this.d_value[1]];
1812
+ value = [value, this.rawValue[1]];
1746
1813
  } else {
1747
1814
  value = [value, null];
1748
1815
  }
1749
1816
  }
1750
1817
 
1751
1818
  if (this.isMultipleSelection()) {
1752
- value = [...this.d_value.slice(0, -1), value];
1819
+ value = [...this.rawValue.slice(0, -1), value];
1753
1820
  }
1754
1821
 
1755
1822
  this.updateModel(value);
@@ -1801,8 +1868,8 @@ export default {
1801
1868
  if (this.showTime || this.timeOnly) {
1802
1869
  let timeDate = viewDate;
1803
1870
 
1804
- if (this.isRangeSelection() && this.d_value && this.d_value[this.focusedDateIndex]) {
1805
- timeDate = this.d_value[this.focusedDateIndex];
1871
+ if (this.isRangeSelection() && this.rawValue && this.rawValue[this.focusedDateIndex]) {
1872
+ timeDate = this.rawValue[this.focusedDateIndex];
1806
1873
  }
1807
1874
 
1808
1875
  this.updateCurrentTimeMeta(timeDate);
@@ -1856,19 +1923,28 @@ export default {
1856
1923
 
1857
1924
  return value;
1858
1925
  },
1926
+ parseValueForComparison(value) {
1927
+ if (typeof value === 'string') {
1928
+ const parsedValue = this.parseValue(value);
1929
+
1930
+ return this.isSingleSelection() ? parsedValue : parsedValue[0];
1931
+ }
1932
+
1933
+ return value;
1934
+ },
1859
1935
  parseDateTime(text) {
1860
1936
  let date;
1861
- let parts = text.split(' ');
1937
+ let parts = text.match(/(?:(.+?) )?(\d{2}:\d{2}(?::\d{2})?)(?: (am|pm))?/);
1862
1938
 
1863
1939
  if (this.timeOnly) {
1864
1940
  date = new Date();
1865
- this.populateTime(date, parts[0], parts[1]);
1941
+ this.populateTime(date, parts[2], parts[3]);
1866
1942
  } else {
1867
1943
  const dateFormat = this.datePattern;
1868
1944
 
1869
1945
  if (this.showTime) {
1870
- date = this.parseDate(parts[0], dateFormat);
1871
- this.populateTime(date, parts[1], parts[2]);
1946
+ date = this.parseDate(parts[1], dateFormat);
1947
+ this.populateTime(date, parts[2], parts[3]);
1872
1948
  } else {
1873
1949
  date = this.parseDate(text, dateFormat);
1874
1950
  }
@@ -2686,11 +2762,15 @@ export default {
2686
2762
  this.selectionStart = this.input.selectionStart;
2687
2763
  this.selectionEnd = this.input.selectionEnd;
2688
2764
 
2765
+ if (this.$refs.clearIcon?.$el?.style) {
2766
+ this.$refs.clearIcon.$el.style.display = isEmpty(event.target.value) ? 'none' : 'block';
2767
+ }
2768
+
2689
2769
  let value = this.parseValue(event.target.value);
2690
2770
 
2691
2771
  if (this.isValidSelection(value)) {
2692
2772
  this.typeUpdate = true;
2693
- this.updateModel(value);
2773
+ this.updateModel(this.updateModelType === 'string' ? this.formatValue(value) : value);
2694
2774
  this.updateCurrentMetaData();
2695
2775
  }
2696
2776
  } catch (err) {
@@ -2717,7 +2797,11 @@ export default {
2717
2797
  this.formField.onBlur?.();
2718
2798
 
2719
2799
  this.focused = false;
2720
- event.target.value = this.formatValue(this.d_value);
2800
+ event.target.value = this.formatValue(this.rawValue);
2801
+
2802
+ if (this.$refs.clearIcon?.$el?.style) {
2803
+ this.$refs.clearIcon.$el.style.display = isEmpty(event.target.value) ? 'none' : 'block';
2804
+ }
2721
2805
  },
2722
2806
  onKeyDown(event) {
2723
2807
  if (event.code === 'ArrowDown' && this.overlay) {
@@ -2772,6 +2856,10 @@ export default {
2772
2856
  getYear(month) {
2773
2857
  return this.currentView === 'month' ? this.currentYear : month.year;
2774
2858
  },
2859
+ onClearClick() {
2860
+ this.updateModel(null);
2861
+ this.overlayVisible = false;
2862
+ },
2775
2863
  onOverlayClick(event) {
2776
2864
  event.stopPropagation();
2777
2865
 
@@ -2859,18 +2947,24 @@ export default {
2859
2947
  },
2860
2948
  computed: {
2861
2949
  viewDate() {
2862
- let propValue = this.d_value;
2950
+ let propValue = this.rawValue;
2863
2951
 
2864
2952
  if (propValue && Array.isArray(propValue)) {
2865
2953
  if (this.isRangeSelection()) {
2866
- if (propValue.length === 1) {
2954
+ if (propValue.length === 0) {
2955
+ propValue = null;
2956
+ } else if (propValue.length === 1) {
2867
2957
  propValue = propValue[0];
2868
2958
  } else {
2869
- let lastVisibleMonth = new Date(propValue[0].getFullYear(), propValue[0].getMonth() + this.numberOfMonths, 1);
2959
+ const start = this.parseValueForComparison(propValue[0]);
2960
+ let lastVisibleMonth = new Date(start.getFullYear(), start.getMonth() + this.numberOfMonths, 1);
2961
+
2870
2962
  if (propValue[1] < lastVisibleMonth) {
2871
2963
  propValue = propValue[0];
2872
2964
  } else {
2873
- propValue = new Date(propValue[1].getFullYear(), propValue[1].getMonth() - this.numberOfMonths + 1, 1);
2965
+ const end = this.parseValueForComparison(propValue[1]);
2966
+
2967
+ propValue = new Date(end.getFullYear(), end.getMonth() - this.numberOfMonths + 1, 1);
2874
2968
  }
2875
2969
  }
2876
2970
  } else if (this.isMultipleSelection()) {
@@ -2895,7 +2989,7 @@ export default {
2895
2989
  }
2896
2990
  },
2897
2991
  inputFieldValue() {
2898
- return this.formatValue(this.d_value);
2992
+ return this.formatValue(this.rawValue);
2899
2993
  },
2900
2994
  months() {
2901
2995
  let months = [];
@@ -2925,13 +3019,26 @@ export default {
2925
3019
  for (let j = prevMonthDaysLength - firstDay + 1; j <= prevMonthDaysLength; j++) {
2926
3020
  let prev = this.getPreviousMonthAndYear(month, year);
2927
3021
 
2928
- week.push({ day: j, month: prev.month, year: prev.year, otherMonth: true, today: this.isToday(today, j, prev.month, prev.year), selectable: this.isSelectable(j, prev.month, prev.year, true) });
3022
+ week.push({
3023
+ day: j,
3024
+ month: prev.month,
3025
+ year: prev.year,
3026
+ otherMonth: true,
3027
+ today: this.isToday(today, j, prev.month, prev.year),
3028
+ selectable: this.isSelectable(j, prev.month, prev.year, true)
3029
+ });
2929
3030
  }
2930
3031
 
2931
3032
  let remainingDaysLength = 7 - week.length;
2932
3033
 
2933
3034
  for (let j = 0; j < remainingDaysLength; j++) {
2934
- week.push({ day: dayNo, month: month, year: year, today: this.isToday(today, dayNo, month, year), selectable: this.isSelectable(dayNo, month, year, false) });
3035
+ week.push({
3036
+ day: dayNo,
3037
+ month: month,
3038
+ year: year,
3039
+ today: this.isToday(today, dayNo, month, year),
3040
+ selectable: this.isSelectable(dayNo, month, year, false)
3041
+ });
2935
3042
  dayNo++;
2936
3043
  }
2937
3044
  } else {
@@ -2948,7 +3055,13 @@ export default {
2948
3055
  selectable: this.isSelectable(dayNo - daysLength, next.month, next.year, true)
2949
3056
  });
2950
3057
  } else {
2951
- week.push({ day: dayNo, month: month, year: year, today: this.isToday(today, dayNo, month, year), selectable: this.isSelectable(dayNo, month, year, false) });
3058
+ week.push({
3059
+ day: dayNo,
3060
+ month: month,
3061
+ year: year,
3062
+ today: this.isToday(today, dayNo, month, year),
3063
+ selectable: this.isSelectable(dayNo, month, year, false)
3064
+ });
2952
3065
  }
2953
3066
 
2954
3067
  dayNo++;
@@ -3018,7 +3131,10 @@ export default {
3018
3131
  };
3019
3132
 
3020
3133
  for (let i = 0; i <= 11; i++) {
3021
- monthPickerValues.push({ value: this.$primevue.config.locale.monthNamesShort[i], selectable: isSelectableMonth(i) });
3134
+ monthPickerValues.push({
3135
+ value: this.$primevue.config.locale.monthNamesShort[i],
3136
+ selectable: isSelectableMonth(i)
3137
+ });
3022
3138
  }
3023
3139
 
3024
3140
  return monthPickerValues;
@@ -3073,6 +3189,9 @@ export default {
3073
3189
  switchViewButtonDisabled() {
3074
3190
  return this.numberOfMonths > 1 || this.disabled;
3075
3191
  },
3192
+ isClearIconVisible() {
3193
+ return this.showClear && this.rawValue != null && !this.disabled;
3194
+ },
3076
3195
  panelId() {
3077
3196
  return this.$id + '_panel';
3078
3197
  },
@@ -3160,7 +3279,8 @@ export default {
3160
3279
  ChevronLeftIcon,
3161
3280
  ChevronRightIcon,
3162
3281
  ChevronUpIcon,
3163
- ChevronDownIcon
3282
+ ChevronDownIcon,
3283
+ TimesIcon
3164
3284
  },
3165
3285
  directives: {
3166
3286
  ripple: Ripple