primevue 4.3.7 → 4.3.8

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.
@@ -167,6 +167,10 @@ export default {
167
167
  type: String,
168
168
  default: null
169
169
  },
170
+ required: {
171
+ type: Boolean,
172
+ default: null
173
+ },
170
174
  inputId: {
171
175
  type: String,
172
176
  default: null
@@ -14,6 +14,7 @@
14
14
  :invalid="invalid"
15
15
  :variant="variant"
16
16
  :fluid="fluid"
17
+ :required="required"
17
18
  :unstyled="unstyled"
18
19
  autocomplete="off"
19
20
  aria-autocomplete="none"
@@ -612,7 +613,8 @@ export default {
612
613
  currentView: this.view,
613
614
  query: null,
614
615
  queryMatches: false,
615
- queryOrientation: null
616
+ queryOrientation: null,
617
+ focusedDateIndex: 0
616
618
  };
617
619
  },
618
620
  watch: {
@@ -1261,14 +1263,17 @@ export default {
1261
1263
 
1262
1264
  if (!endDate && date.getTime() >= startDate.getTime()) {
1263
1265
  endDate = date;
1266
+ this.focusedDateIndex = 1;
1264
1267
  } else {
1265
1268
  startDate = date;
1266
1269
  endDate = null;
1270
+ this.focusedDateIndex = 0;
1267
1271
  }
1268
1272
 
1269
1273
  modelVal = [startDate, endDate];
1270
1274
  } else {
1271
1275
  modelVal = [date, null];
1276
+ this.focusedDateIndex = 0;
1272
1277
  }
1273
1278
  }
1274
1279
 
@@ -1714,7 +1719,7 @@ export default {
1714
1719
  let value = this.isComparable() ? this.d_value : this.viewDate;
1715
1720
 
1716
1721
  if (this.isRangeSelection()) {
1717
- value = this.d_value[1] || this.d_value[0];
1722
+ value = this.d_value[this.focusedDateIndex] || this.d_value[0];
1718
1723
  }
1719
1724
 
1720
1725
  if (this.isMultipleSelection()) {
@@ -1734,8 +1739,13 @@ export default {
1734
1739
  value.setSeconds(this.currentSecond);
1735
1740
 
1736
1741
  if (this.isRangeSelection()) {
1737
- if (this.d_value[1]) value = [this.d_value[0], value];
1738
- else value = [value, null];
1742
+ if (this.focusedDateIndex === 1 && this.d_value[1]) {
1743
+ value = [this.d_value[0], value];
1744
+ } else if (this.focusedDateIndex === 0) {
1745
+ value = [value, this.d_value[1]];
1746
+ } else {
1747
+ value = [value, null];
1748
+ }
1739
1749
  }
1740
1750
 
1741
1751
  if (this.isMultipleSelection()) {
@@ -1789,7 +1799,13 @@ export default {
1789
1799
  this.currentYear = viewDate.getFullYear();
1790
1800
 
1791
1801
  if (this.showTime || this.timeOnly) {
1792
- this.updateCurrentTimeMeta(viewDate);
1802
+ let timeDate = viewDate;
1803
+
1804
+ if (this.isRangeSelection() && this.d_value && this.d_value[this.focusedDateIndex]) {
1805
+ timeDate = this.d_value[this.focusedDateIndex];
1806
+ }
1807
+
1808
+ this.updateCurrentTimeMeta(timeDate);
1793
1809
  }
1794
1810
  },
1795
1811
  isValidSelection(value) {
@@ -731,6 +731,10 @@ export interface DatePickerProps {
731
731
  * Placeholder text for the input.
732
732
  */
733
733
  placeholder?: string | undefined;
734
+ /*
735
+ * When present, it specifies that the component is a required field.
736
+ */
737
+ required?: boolean | undefined;
734
738
  /**
735
739
  * A valid query selector or an HTMLElement to specify where the overlay gets attached.
736
740
  * @defaultValue body
@@ -182,6 +182,10 @@ var script$1 = {
182
182
  type: String,
183
183
  "default": null
184
184
  },
185
+ required: {
186
+ type: Boolean,
187
+ "default": null
188
+ },
185
189
  inputId: {
186
190
  type: String,
187
191
  "default": null
@@ -308,7 +312,8 @@ var script = {
308
312
  currentView: this.view,
309
313
  query: null,
310
314
  queryMatches: false,
311
- queryOrientation: null
315
+ queryOrientation: null,
316
+ focusedDateIndex: 0
312
317
  };
313
318
  },
314
319
  watch: {
@@ -949,13 +954,16 @@ var script = {
949
954
  var endDate = this.d_value[1];
950
955
  if (!endDate && date.getTime() >= startDate.getTime()) {
951
956
  endDate = date;
957
+ this.focusedDateIndex = 1;
952
958
  } else {
953
959
  startDate = date;
954
960
  endDate = null;
961
+ this.focusedDateIndex = 0;
955
962
  }
956
963
  modelVal = [startDate, endDate];
957
964
  } else {
958
965
  modelVal = [date, null];
966
+ this.focusedDateIndex = 0;
959
967
  }
960
968
  }
961
969
  if (modelVal !== null) {
@@ -1332,7 +1340,7 @@ var script = {
1332
1340
  this.timePickerChange = true;
1333
1341
  var value = this.isComparable() ? this.d_value : this.viewDate;
1334
1342
  if (this.isRangeSelection()) {
1335
- value = this.d_value[1] || this.d_value[0];
1343
+ value = this.d_value[this.focusedDateIndex] || this.d_value[0];
1336
1344
  }
1337
1345
  if (this.isMultipleSelection()) {
1338
1346
  value = this.d_value[this.d_value.length - 1];
@@ -1346,7 +1354,13 @@ var script = {
1346
1354
  value.setMinutes(this.currentMinute);
1347
1355
  value.setSeconds(this.currentSecond);
1348
1356
  if (this.isRangeSelection()) {
1349
- if (this.d_value[1]) value = [this.d_value[0], value];else value = [value, null];
1357
+ if (this.focusedDateIndex === 1 && this.d_value[1]) {
1358
+ value = [this.d_value[0], value];
1359
+ } else if (this.focusedDateIndex === 0) {
1360
+ value = [value, this.d_value[1]];
1361
+ } else {
1362
+ value = [value, null];
1363
+ }
1350
1364
  }
1351
1365
  if (this.isMultipleSelection()) {
1352
1366
  value = [].concat(_toConsumableArray(this.d_value.slice(0, -1)), [value]);
@@ -1412,7 +1426,11 @@ var script = {
1412
1426
  this.currentMonth = viewDate.getMonth();
1413
1427
  this.currentYear = viewDate.getFullYear();
1414
1428
  if (this.showTime || this.timeOnly) {
1415
- this.updateCurrentTimeMeta(viewDate);
1429
+ var timeDate = viewDate;
1430
+ if (this.isRangeSelection() && this.d_value && this.d_value[this.focusedDateIndex]) {
1431
+ timeDate = this.d_value[this.focusedDateIndex];
1432
+ }
1433
+ this.updateCurrentTimeMeta(timeDate);
1416
1434
  }
1417
1435
  },
1418
1436
  isValidSelection: function isValidSelection(value) {
@@ -2767,6 +2785,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2767
2785
  invalid: _ctx.invalid,
2768
2786
  variant: _ctx.variant,
2769
2787
  fluid: _ctx.fluid,
2788
+ required: _ctx.required,
2770
2789
  unstyled: _ctx.unstyled,
2771
2790
  autocomplete: "off",
2772
2791
  "aria-autocomplete": "none",
@@ -2787,7 +2806,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
2787
2806
  "data-p-has-dropdown": _ctx.showIcon && _ctx.iconDisplay === 'button' && !_ctx.inline,
2788
2807
  "data-p-has-e-icon": _ctx.showIcon && _ctx.iconDisplay === 'input' && !_ctx.inline,
2789
2808
  pt: _ctx.ptm('pcInputText')
2790
- }, null, 8, ["id", "class", "style", "defaultValue", "placeholder", "name", "size", "invalid", "variant", "fluid", "unstyled", "aria-expanded", "aria-controls", "aria-labelledby", "aria-label", "disabled", "readonly", "onInput", "onClick", "onFocus", "onBlur", "onKeydown", "data-p-has-dropdown", "data-p-has-e-icon", "pt"])) : createCommentVNode("", true), _ctx.showIcon && _ctx.iconDisplay === 'button' && !_ctx.inline ? renderSlot(_ctx.$slots, "dropdownbutton", {
2809
+ }, null, 8, ["id", "class", "style", "defaultValue", "placeholder", "name", "size", "invalid", "variant", "fluid", "required", "unstyled", "aria-expanded", "aria-controls", "aria-labelledby", "aria-label", "disabled", "readonly", "onInput", "onClick", "onFocus", "onBlur", "onKeydown", "data-p-has-dropdown", "data-p-has-e-icon", "pt"])) : createCommentVNode("", true), _ctx.showIcon && _ctx.iconDisplay === 'button' && !_ctx.inline ? renderSlot(_ctx.$slots, "dropdownbutton", {
2791
2810
  key: 1,
2792
2811
  toggleCallback: $options.onButtonClick
2793
2812
  }, function () {