@voicenter-team/voicenter-ui-plus 4.0.0-beta.3 → 4.0.0-beta.4

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.
@@ -106,13 +106,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
106
106
  if (!date) {
107
107
  return false;
108
108
  }
109
- if (props.part === "FROM") {
110
- return !!(props.maxDate && isSameAfter(date, props.maxDate, unit));
111
- }
112
- if (props.part === "TO") {
113
- return !!(props.minDate && isSameBefore(date, props.minDate, unit));
114
- }
115
- return false;
109
+ const afterMax = !!(props.maxDate && isSameAfter(date, props.maxDate, unit));
110
+ const beforeMin = !!(props.minDate && isSameBefore(date, props.minDate, unit));
111
+ return afterMax || beforeMin;
116
112
  }
117
113
  function closeTooltip() {
118
114
  tooltipOpened.value = false;
@@ -40,14 +40,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
40
40
  return selectedRelative.value ? selectedRelative.value.key : void 0;
41
41
  });
42
42
  const isDateValid = computed(() => {
43
- if (props.maxDate === null && props.minDate === null) return true;
44
- if (props.maxDate !== null) {
45
- return new Date(props.maxDate).getTime() > new Date(calculatedDate.value).getTime();
46
- }
47
- if (props.minDate !== null) {
48
- return new Date(props.minDate).getTime() < new Date(calculatedDate.value).getTime();
49
- }
50
- return true;
43
+ const calculatedTime = new Date(calculatedDate.value).getTime();
44
+ const beforeMax = props.maxDate === null || new Date(props.maxDate).getTime() > calculatedTime;
45
+ const afterMin = props.minDate === null || new Date(props.minDate).getTime() < calculatedTime;
46
+ return beforeMax && afterMin;
51
47
  });
52
48
  const selectDateButtonDisabled = computed(() => {
53
49
  return !isDateValid.value;
@@ -50,6 +50,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
50
50
  disabled: { type: Boolean, default: false },
51
51
  presetValues: { default: void 0 },
52
52
  wrapperClass: { default: "" },
53
+ minDate: { default: void 0 },
54
+ maxDate: { default: void 0 },
53
55
  id: {},
54
56
  clearable: { type: Boolean, default: false },
55
57
  isError: { type: Boolean, default: false },
@@ -118,6 +120,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
118
120
  if (toDate.value === void 0) return void 0;
119
121
  return toTimeObject(toDate.value);
120
122
  });
123
+ const fromMaxDate = computed(() => earlierDate(toDate.value, props.maxDate));
124
+ const toMinDate = computed(() => laterDate(fromDate.value, props.minDate));
125
+ function earlierDate(first, second) {
126
+ if (!first || !second) return first ?? second;
127
+ return first.getTime() <= second.getTime() ? first : second;
128
+ }
129
+ function laterDate(first, second) {
130
+ if (!first || !second) return first ?? second;
131
+ return first.getTime() >= second.getTime() ? first : second;
132
+ }
121
133
  function toTimeObject(date) {
122
134
  return {
123
135
  hours: getHours(date),
@@ -283,7 +295,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
283
295
  ref: "extendedDatetimeRangePickerPartFromRef",
284
296
  modelValue: fromDate.value,
285
297
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => fromDate.value = $event),
286
- "max-date": toDate.value,
298
+ "min-date": __props.minDate,
299
+ "max-date": fromMaxDate.value,
287
300
  "max-time": toTime.value,
288
301
  color: __props.color,
289
302
  disabled: __props.disabled,
@@ -292,7 +305,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
292
305
  part: "FROM",
293
306
  onPresetValueChange: onPresetValueFromChange,
294
307
  onResetPreset: _cache[3] || (_cache[3] = ($event) => onPresetResetValue("from"))
295
- }), null, 16, ["modelValue", "max-date", "max-time", "color", "disabled", "preset-value"]),
308
+ }), null, 16, ["modelValue", "min-date", "max-date", "max-time", "color", "disabled", "preset-value"]),
296
309
  createVNode(_sfc_main$1, {
297
310
  icon: unref(ArrowRight),
298
311
  class: "text-action-primary self-center shrink-0 !hidden sm:!block rtl:rotate-180"
@@ -301,7 +314,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
301
314
  ref: "extendedDatetimeRangePickerPartToRef",
302
315
  modelValue: toDate.value,
303
316
  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => toDate.value = $event),
304
- "min-date": fromDate.value,
317
+ "min-date": toMinDate.value,
318
+ "max-date": __props.maxDate,
305
319
  "min-time": fromTime.value,
306
320
  color: __props.color,
307
321
  disabled: __props.disabled,
@@ -310,7 +324,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
310
324
  part: "TO",
311
325
  onPresetValueChange: onPresetValueToChange,
312
326
  onResetPreset: _cache[5] || (_cache[5] = ($event) => onPresetResetValue("to"))
313
- }), null, 16, ["modelValue", "min-date", "min-time", "color", "disabled", "preset-value"])
327
+ }), null, 16, ["modelValue", "min-date", "max-date", "min-time", "color", "disabled", "preset-value"])
314
328
  ]),
315
329
  !__props.dynamicErrorSpace || __props.dynamicErrorSpace && __props.error ? (openBlock(), createElementBlock("div", _hoisted_8, [
316
330
  createElementVNode("span", _hoisted_9, toDisplayString(__props.error), 1)
@@ -15,6 +15,10 @@ interface IEDRPProps extends IVcBaseInputProps, IUseInputErrorProps, IUseInputLa
15
15
  presetValues?: VcPresetValuesType;
16
16
  /** @description Custom CSS class for the wrapper element */
17
17
  wrapperClass?: string;
18
+ /** @description The earliest date either end of the range may take; earlier days cannot be picked */
19
+ minDate?: Date;
20
+ /** @description The latest date either end of the range may take; later days cannot be picked */
21
+ maxDate?: Date;
18
22
  }
19
23
  declare function refresh(): void;
20
24
  declare function getDateRange(): {
@@ -46,6 +50,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
46
50
  label: string;
47
51
  icon: string;
48
52
  presetValues: undefined;
53
+ minDate: undefined;
54
+ maxDate: undefined;
49
55
  }>>, {
50
56
  refresh: typeof refresh;
51
57
  getDateRange: typeof getDateRange;
@@ -77,6 +83,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
77
83
  label: string;
78
84
  icon: string;
79
85
  presetValues: undefined;
86
+ minDate: undefined;
87
+ maxDate: undefined;
80
88
  }>>> & Readonly<{
81
89
  "onUpdate:modelValue"?: ((pl: VcExtendedDatetimeRangePickerModelType) => any) | undefined;
82
90
  "onUpdate:presetValue"?: ((pl: VcPresetValuesType) => any) | undefined;
@@ -100,6 +108,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
100
108
  label: string;
101
109
  wrapperClass: string;
102
110
  inline: boolean;
111
+ minDate: Date;
112
+ maxDate: Date;
103
113
  presetRanges: VcExtendedDatetimePickerRangeType[];
104
114
  presetValues: VcPresetValuesType;
105
115
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicenter-team/voicenter-ui-plus",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.4",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "vite build",