eco-vue-js 0.16.1 → 0.16.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"WDatePicker.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/DatePicker/WDatePicker.vue"],"names":[],"mappings":"AA8DA;AA2KA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AAW7C,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,SAAS,GAAG,SAAS,CAAA;IACjC,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AA6UJ,QAAA,MAAM,YAAY;;;;;cA9UH,OAAO;cAFP,OAAO;cACP,OAAO;aAHR,IAAI;aACJ,IAAI;6EAqVhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"WDatePicker.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/DatePicker/WDatePicker.vue"],"names":[],"mappings":"AAkEA;AA8KA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AAY7C,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,SAAS,GAAG,SAAS,CAAA;IACjC,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AAuUJ,QAAA,MAAM,YAAY;;;;;cAxUH,OAAO;cAFP,OAAO;cACP,OAAO;aAHR,IAAI;aACJ,IAAI;6EA+UhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1,9 +1,10 @@
1
1
  import { useComponentStates } from "../../utils/useComponentStates.js";
2
- import { addDay, addMonth, addYear, getStartOfDay, getStartOfMonth, getStartOfWeek, isSameMonth, monthShortFormatter } from "../../utils/dateTime.js";
2
+ import { getStartOfDay, isSameMonth, monthShortFormatter } from "../../utils/dateTime.js";
3
3
  import CalendarMonth_default from "./components/CalendarMonth.vue.js";
4
4
  import CalendarToggle_default from "./components/CalendarToggle.vue.js";
5
5
  import CalendarValue_default from "./components/CalendarValue.vue.js";
6
- import { Transition, computed, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeStyle, openBlock, ref, toRef, unref, watch, withCtx } from "vue";
6
+ import { useCalendarNavigation } from "./use/useCalendarNavigation.js";
7
+ import { Transition, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeStyle, openBlock, ref, toRef, unref, watch, withCtx } from "vue";
7
8
  //#region src/components/DatePicker/WDatePicker.vue?vue&type=script&setup=true&lang.ts
8
9
  var _hoisted_1 = { class: "mb-4 grid grid-cols-2 gap-5" };
9
10
  var _hoisted_2 = { class: "grid grid-cols-2 gap-5 px-3 pb-4" };
@@ -32,16 +33,10 @@ var WDatePicker_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
32
33
  const props = __props;
33
34
  const { isReadonly, isDisabled, isSkeleton } = useComponentStates(props);
34
35
  const emit = __emit;
35
- const currentDate = ref(getStartOfMonth());
36
+ const { currentDate, isDirect, year, isPreviousDisabled, isNextDisabled, setCurrentDate, toPreviousMonth, toNextMonth, toPreviousYear, toNextYear, isSameCalendarPage } = useCalendarNavigation(props);
36
37
  const dateRange = ref(props.modelValue);
37
38
  const preselectedValue = ref(null);
38
- const isDirect = ref(false);
39
39
  const today = ref(getStartOfDay());
40
- const year = computed(() => currentDate.value.getFullYear());
41
- const setCurrentDate = (value) => {
42
- isDirect.value = value > currentDate.value;
43
- currentDate.value = value;
44
- };
45
40
  const onClickDay = (value) => {
46
41
  if (!preselectedValue.value) {
47
42
  preselectedValue.value = value;
@@ -70,53 +65,72 @@ var WDatePicker_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
70
65
  to: new Date(preselectedValue.value)
71
66
  };
72
67
  };
73
- const firstDay = computed(() => getStartOfWeek(currentDate.value));
74
- const lastDay = computed(() => addDay(firstDay.value, 41));
75
- const isSameCalendarPage = (value) => {
76
- return value >= firstDay.value && value <= lastDay.value;
77
- };
78
68
  watch(toRef(props, "modelValue"), (modelValue) => {
79
69
  dateRange.value = modelValue;
80
70
  if (!modelValue) return;
81
- if (!isSameCalendarPage(modelValue.from) && !isSameCalendarPage(modelValue.to)) setCurrentDate(getStartOfMonth(modelValue.from));
71
+ if (!isSameCalendarPage(modelValue.from) && !isSameCalendarPage(modelValue.to)) setCurrentDate(modelValue.from);
82
72
  });
83
73
  return (_ctx, _cache) => {
84
74
  return openBlock(), createElementBlock("div", null, [createElementVNode("div", _hoisted_1, [createVNode(CalendarValue_default, {
85
75
  title: "From:",
86
76
  value: dateRange.value?.from,
87
- "current-date": currentDate.value,
77
+ "current-date": unref(currentDate),
88
78
  "auto-focus": "",
89
- "onUpdate:currentDate": setCurrentDate
90
- }, null, 8, ["value", "current-date"]), createVNode(CalendarValue_default, {
79
+ "onUpdate:currentDate": unref(setCurrentDate)
80
+ }, null, 8, [
81
+ "value",
82
+ "current-date",
83
+ "onUpdate:currentDate"
84
+ ]), createVNode(CalendarValue_default, {
91
85
  title: "To:",
92
86
  value: dateRange.value?.to,
93
- "current-date": currentDate.value,
94
- "onUpdate:currentDate": setCurrentDate
95
- }, null, 8, ["value", "current-date"])]), createElementVNode("div", {
87
+ "current-date": unref(currentDate),
88
+ "onUpdate:currentDate": unref(setCurrentDate)
89
+ }, null, 8, [
90
+ "value",
91
+ "current-date",
92
+ "onUpdate:currentDate"
93
+ ])]), createElementVNode("div", {
96
94
  class: "bg-default dark:bg-default-dark overflow-hidden rounded-xl border border-solid border-gray-300 py-3 dark:border-gray-700",
97
- style: normalizeStyle({ "--direction-factor": isDirect.value ? "1" : "-1" })
95
+ style: normalizeStyle({ "--direction-factor": unref(isDirect) ? "1" : "-1" })
98
96
  }, [createElementVNode("div", _hoisted_2, [createVNode(CalendarToggle_default, {
99
- text: unref(monthShortFormatter).format(currentDate.value).toLocaleUpperCase(),
100
- "onClick:previous": _cache[0] || (_cache[0] = ($event) => setCurrentDate(unref(addMonth)(currentDate.value, -1))),
101
- "onClick:next": _cache[1] || (_cache[1] = ($event) => setCurrentDate(unref(addMonth)(currentDate.value, 1)))
102
- }, null, 8, ["text"]), createVNode(CalendarToggle_default, {
103
- text: year.value.toString(),
104
- "onClick:previous": _cache[2] || (_cache[2] = ($event) => setCurrentDate(unref(addYear)(currentDate.value, -1))),
105
- "onClick:next": _cache[3] || (_cache[3] = ($event) => setCurrentDate(unref(addYear)(currentDate.value, 1)))
106
- }, null, 8, ["text"])]), createElementVNode("div", _hoisted_3, [createVNode(Transition, {
97
+ text: unref(monthShortFormatter).format(unref(currentDate)).toLocaleUpperCase(),
98
+ "disabled-previous": unref(isPreviousDisabled),
99
+ "disabled-next": unref(isNextDisabled),
100
+ "onClick:previous": unref(toPreviousMonth),
101
+ "onClick:next": unref(toNextMonth)
102
+ }, null, 8, [
103
+ "text",
104
+ "disabled-previous",
105
+ "disabled-next",
106
+ "onClick:previous",
107
+ "onClick:next"
108
+ ]), createVNode(CalendarToggle_default, {
109
+ text: unref(year).toString(),
110
+ "disabled-previous": unref(isPreviousDisabled),
111
+ "disabled-next": unref(isNextDisabled),
112
+ "onClick:previous": unref(toPreviousYear),
113
+ "onClick:next": unref(toNextYear)
114
+ }, null, 8, [
115
+ "text",
116
+ "disabled-previous",
117
+ "disabled-next",
118
+ "onClick:previous",
119
+ "onClick:next"
120
+ ])]), createElementVNode("div", _hoisted_3, [createVNode(Transition, {
107
121
  "enter-active-class": "transition-transform duration-250 w-full",
108
122
  "leave-active-class": "transition-transform duration-250 w-full absolute top-0",
109
123
  "enter-from-class": "translate-x-[calc(100%*var(--direction-factor))]",
110
124
  "leave-to-class": "translate-x-[calc(100%*var(--direction-factor)*-1)]"
111
125
  }, {
112
126
  default: withCtx(() => [(openBlock(), createBlock(CalendarMonth_default, {
113
- key: currentDate.value.toISOString(),
114
- "start-of-month": currentDate.value,
127
+ key: unref(currentDate).toISOString(),
128
+ "start-of-month": unref(currentDate),
115
129
  "date-range": dateRange.value,
116
130
  "is-hover-enabled": preselectedValue.value !== null,
117
131
  "min-date": __props.minDate,
118
132
  "max-date": __props.maxDate,
119
- today: today.value && unref(isSameMonth)(today.value, currentDate.value) ? today.value : void 0,
133
+ today: today.value && unref(isSameMonth)(today.value, unref(currentDate)) ? today.value : void 0,
120
134
  readonly: unref(isReadonly) || unref(isDisabled) || unref(isSkeleton),
121
135
  class: "px-3",
122
136
  "onClick:day": onClickDay,
@@ -1 +1 @@
1
- {"version":3,"file":"WDatePickerSingle.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/DatePicker/WDatePickerSingle.vue"],"names":[],"mappings":"AA0CA;AA8HA,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,IAAI,GAAG,SAAS,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AA8OJ,QAAA,MAAM,YAAY;;;;;cA/OH,OAAO;cAFP,OAAO;WAHV,MAAM;cAIH,OAAO;aAHR,IAAI;aACJ,IAAI;6EAsPhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"WDatePickerSingle.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/DatePicker/WDatePickerSingle.vue"],"names":[],"mappings":"AA8CA;AAkIA,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,IAAI,GAAG,SAAS,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AAuOJ,QAAA,MAAM,YAAY;;;;;cAxOH,OAAO;cAFP,OAAO;WAHV,MAAM;cAIH,OAAO;aAHR,IAAI;aACJ,IAAI;6EA+OhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1,8 +1,9 @@
1
1
  import { useComponentStates } from "../../utils/useComponentStates.js";
2
- import { addDay, addMonth, addYear, getStartOfDay, getStartOfMonth, getStartOfWeek, monthShortFormatter } from "../../utils/dateTime.js";
2
+ import { getStartOfDay, monthShortFormatter } from "../../utils/dateTime.js";
3
3
  import CalendarMonth_default from "./components/CalendarMonth.vue.js";
4
4
  import CalendarToggle_default from "./components/CalendarToggle.vue.js";
5
- import { Transition, computed, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeStyle, openBlock, ref, toRef, unref, watch, withCtx } from "vue";
5
+ import { useCalendarNavigation } from "./use/useCalendarNavigation.js";
6
+ import { Transition, createBlock, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeStyle, openBlock, ref, toRef, unref, watch, withCtx } from "vue";
6
7
  //#region src/components/DatePicker/WDatePickerSingle.vue?vue&type=script&setup=true&lang.ts
7
8
  var _hoisted_1 = { class: "grid grid-cols-2 gap-8 px-3 pb-4" };
8
9
  var _hoisted_2 = { class: "relative" };
@@ -31,53 +32,58 @@ var WDatePickerSingle_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*
31
32
  const props = __props;
32
33
  const { isReadonly, isDisabled, isSkeleton } = useComponentStates(props);
33
34
  const emit = __emit;
34
- const currentDate = ref(getStartOfMonth());
35
+ const { currentDate, isDirect, year, isPreviousDisabled, isNextDisabled, setCurrentDate, toPreviousMonth, toNextMonth, toPreviousYear, toNextYear, isSameCalendarPage } = useCalendarNavigation(props);
35
36
  const dateRange = ref(void 0);
36
37
  const preselectedValue = ref(null);
37
- const isDirect = ref(false);
38
38
  const today = ref(getStartOfDay());
39
- const year = computed(() => currentDate.value.getFullYear());
40
- const setCurrentDate = (value) => {
41
- isDirect.value = value > currentDate.value;
42
- currentDate.value = value;
43
- };
44
39
  const onClickDay = (value) => {
45
40
  emit("update:model-value", value);
46
41
  };
47
- const firstDay = computed(() => getStartOfWeek(currentDate.value));
48
- const lastDay = computed(() => addDay(firstDay.value, 41));
49
- const isSameCalendarPage = (value) => {
50
- return value >= firstDay.value && value <= lastDay.value;
51
- };
52
42
  watch(toRef(props, "modelValue"), (modelValue) => {
53
43
  dateRange.value = modelValue ? {
54
44
  from: modelValue,
55
45
  to: modelValue
56
46
  } : void 0;
57
47
  if (!modelValue) return;
58
- if (!isSameCalendarPage(modelValue)) setCurrentDate(getStartOfMonth(modelValue));
48
+ if (!isSameCalendarPage(modelValue)) setCurrentDate(modelValue);
59
49
  }, { immediate: true });
60
50
  return (_ctx, _cache) => {
61
51
  return openBlock(), createElementBlock("div", {
62
52
  class: "bg-default dark:bg-default-dark overflow-hidden rounded-xl border border-solid border-gray-300 py-3 dark:border-gray-700",
63
- style: normalizeStyle({ "--direction-factor": isDirect.value ? "1" : "-1" })
53
+ style: normalizeStyle({ "--direction-factor": unref(isDirect) ? "1" : "-1" })
64
54
  }, [createElementVNode("div", _hoisted_1, [createVNode(CalendarToggle_default, {
65
- text: unref(monthShortFormatter).format(currentDate.value).toLocaleUpperCase(),
66
- "onClick:previous": _cache[0] || (_cache[0] = ($event) => setCurrentDate(unref(addMonth)(currentDate.value, -1))),
67
- "onClick:next": _cache[1] || (_cache[1] = ($event) => setCurrentDate(unref(addMonth)(currentDate.value, 1)))
68
- }, null, 8, ["text"]), createVNode(CalendarToggle_default, {
69
- text: year.value.toString(),
70
- "onClick:previous": _cache[2] || (_cache[2] = ($event) => setCurrentDate(unref(addYear)(currentDate.value, -1))),
71
- "onClick:next": _cache[3] || (_cache[3] = ($event) => setCurrentDate(unref(addYear)(currentDate.value, 1)))
72
- }, null, 8, ["text"])]), createElementVNode("div", _hoisted_2, [createVNode(Transition, {
55
+ text: unref(monthShortFormatter).format(unref(currentDate)).toLocaleUpperCase(),
56
+ "disabled-previous": unref(isPreviousDisabled),
57
+ "disabled-next": unref(isNextDisabled),
58
+ "onClick:previous": unref(toPreviousMonth),
59
+ "onClick:next": unref(toNextMonth)
60
+ }, null, 8, [
61
+ "text",
62
+ "disabled-previous",
63
+ "disabled-next",
64
+ "onClick:previous",
65
+ "onClick:next"
66
+ ]), createVNode(CalendarToggle_default, {
67
+ text: unref(year).toString(),
68
+ "disabled-previous": unref(isPreviousDisabled),
69
+ "disabled-next": unref(isNextDisabled),
70
+ "onClick:previous": unref(toPreviousYear),
71
+ "onClick:next": unref(toNextYear)
72
+ }, null, 8, [
73
+ "text",
74
+ "disabled-previous",
75
+ "disabled-next",
76
+ "onClick:previous",
77
+ "onClick:next"
78
+ ])]), createElementVNode("div", _hoisted_2, [createVNode(Transition, {
73
79
  "enter-active-class": "transition-transform duration-250 w-full",
74
80
  "leave-active-class": "transition-transform duration-250 w-full absolute top-0",
75
81
  "enter-from-class": "translate-x-[calc(100%*var(--direction-factor))]",
76
82
  "leave-to-class": "translate-x-[calc(100%*var(--direction-factor)*-1)]"
77
83
  }, {
78
84
  default: withCtx(() => [(openBlock(), createBlock(CalendarMonth_default, {
79
- key: currentDate.value.toISOString(),
80
- "start-of-month": currentDate.value,
85
+ key: unref(currentDate).toISOString(),
86
+ "start-of-month": unref(currentDate),
81
87
  "date-range": dateRange.value,
82
88
  "is-hover-enabled": preselectedValue.value !== null,
83
89
  "min-date": __props.minDate,
@@ -53,8 +53,8 @@ var CalendarDay_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
53
53
  });
54
54
  const isDisabled = computed(() => {
55
55
  if (props.disabled) return true;
56
- if (props.minDate) return props.minDate > props.startOfDay;
57
- if (props.maxDate) return props.maxDate < props.startOfDay;
56
+ if (props.minDate && props.minDate > props.startOfDay) return true;
57
+ if (props.maxDate && props.maxDate < props.startOfDay) return true;
58
58
  return false;
59
59
  });
60
60
  return (_ctx, _cache) => {
@@ -70,8 +70,8 @@ var CalendarMonth_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
70
70
  });
71
71
  const isDisabled = computed(() => {
72
72
  if (props.disabled) return true;
73
- if (props.minDate) return props.minDate > endOfLastWeek.value;
74
- if (props.maxDate) return props.maxDate < startOfFirstWeek.value;
73
+ if (props.minDate && props.minDate > endOfLastWeek.value) return true;
74
+ if (props.maxDate && props.maxDate < startOfFirstWeek.value) return true;
75
75
  return false;
76
76
  });
77
77
  return (_ctx, _cache) => {
@@ -1,5 +1,7 @@
1
1
  type __VLS_Props = {
2
2
  text: string;
3
+ disabledPrevious?: boolean;
4
+ disabledNext?: boolean;
3
5
  };
4
6
  declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
5
7
  "click:next": () => any;
@@ -1 +1 @@
1
- {"version":3,"file":"CalendarToggle.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/DatePicker/components/CalendarToggle.vue"],"names":[],"mappings":"AAyCA;AA0DA,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAA;CACb,CAAC;AAiNF,QAAA,MAAM,YAAY;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"CalendarToggle.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/DatePicker/components/CalendarToggle.vue"],"names":[],"mappings":"AAuCA;AA0DA,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAC;AA2IF,QAAA,MAAM,YAAY;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1,19 +1,23 @@
1
1
  import IconArrow_default from "../../../assets/icons/IconArrow.js";
2
- import { Transition, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
2
+ import { Transition, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, toDisplayString, unref, withCtx } from "vue";
3
3
  //#region src/components/DatePicker/components/CalendarToggle.vue?vue&type=script&setup=true&lang.ts
4
4
  var _hoisted_1 = { class: "my-2 flex h-8 w-full items-center" };
5
5
  var _hoisted_2 = { class: "relative overflow-hidden" };
6
6
  var CalendarToggle_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
7
7
  __name: "CalendarToggle",
8
- props: { text: {} },
8
+ props: {
9
+ text: {},
10
+ disabledPrevious: { type: Boolean },
11
+ disabledNext: { type: Boolean }
12
+ },
9
13
  emits: ["click:next", "click:previous"],
10
14
  setup(__props) {
11
15
  return (_ctx, _cache) => {
12
16
  return openBlock(), createElementBlock("div", _hoisted_1, [
13
17
  createElementVNode("div", {
14
- class: "square-8 w-ripple hover:bg-primary hover:dark:bg-primary-dark hover:text-default dark:hover:text-default text-description relative mr-auto flex cursor-pointer select-none items-center justify-center rounded-xl",
15
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click:previous"))
16
- }, [createVNode(unref(IconArrow_default), { class: "-ml-1 rotate-90" })]),
18
+ class: normalizeClass(["square-8 text-description relative mr-auto flex select-none items-center justify-center rounded-xl", __props.disabledPrevious ? "cursor-not-allowed opacity-50" : "w-ripple hover:bg-primary hover:dark:bg-primary-dark hover:text-default dark:hover:text-default cursor-pointer"]),
19
+ onClick: _cache[0] || (_cache[0] = ($event) => !__props.disabledPrevious && _ctx.$emit("click:previous"))
20
+ }, [createVNode(unref(IconArrow_default), { class: "-ml-1 rotate-90" })], 2),
17
21
  createElementVNode("div", _hoisted_2, [createVNode(Transition, {
18
22
  "enter-active-class": "transition-transform duration-250 w-full",
19
23
  "leave-active-class": "transition-transform duration-250 w-full absolute top-0",
@@ -27,9 +31,9 @@ var CalendarToggle_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
27
31
  _: 1
28
32
  })]),
29
33
  createElementVNode("div", {
30
- class: "square-8 w-ripple hover:bg-primary hover:dark:bg-primary-dark hover:text-default dark:hover:text-default text-description relative ml-auto flex cursor-pointer select-none items-center justify-center rounded-xl",
31
- onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("click:next"))
32
- }, [createVNode(unref(IconArrow_default), { class: "-mr-1 -rotate-90" })])
34
+ class: normalizeClass(["square-8 text-description relative ml-auto flex select-none items-center justify-center rounded-xl", __props.disabledNext ? "cursor-not-allowed opacity-50" : "w-ripple hover:bg-primary hover:dark:bg-primary-dark hover:text-default dark:hover:text-default cursor-pointer"]),
35
+ onClick: _cache[1] || (_cache[1] = ($event) => !__props.disabledNext && _ctx.$emit("click:next"))
36
+ }, [createVNode(unref(IconArrow_default), { class: "-mr-1 -rotate-90" })], 2)
33
37
  ]);
34
38
  };
35
39
  }
@@ -57,8 +57,8 @@ var CalendarWeek_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
57
57
  });
58
58
  const isDisabled = computed(() => {
59
59
  if (props.disabled) return true;
60
- if (props.minDate) return props.minDate > endOfWeek.value;
61
- if (props.maxDate) return props.maxDate < props.startOfWeek;
60
+ if (props.minDate && props.minDate > endOfWeek.value) return true;
61
+ if (props.maxDate && props.maxDate < props.startOfWeek) return true;
62
62
  return false;
63
63
  });
64
64
  return (_ctx, _cache) => {
@@ -0,0 +1,17 @@
1
+ export declare const useCalendarNavigation: (props: {
2
+ minDate?: Date;
3
+ maxDate?: Date;
4
+ }) => {
5
+ currentDate: import('vue').Ref<Date, Date>;
6
+ isDirect: import('vue').Ref<boolean, boolean>;
7
+ year: import('vue').ComputedRef<number>;
8
+ isPreviousDisabled: import('vue').ComputedRef<boolean>;
9
+ isNextDisabled: import('vue').ComputedRef<boolean>;
10
+ setCurrentDate: (value: Date) => void;
11
+ toPreviousMonth: () => void;
12
+ toNextMonth: () => void;
13
+ toPreviousYear: () => void;
14
+ toNextYear: () => void;
15
+ isSameCalendarPage: (value: Date) => boolean;
16
+ };
17
+ //# sourceMappingURL=useCalendarNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCalendarNavigation.d.ts","sourceRoot":"","sources":["../../../../../src/components/DatePicker/use/useCalendarNavigation.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,GAAI,OAAO;IAAC,OAAO,CAAC,EAAE,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,IAAI,CAAA;CAAC;;;;;;4BAgB5C,IAAI,KAAG,IAAI;2BAYd,IAAI;uBACR,IAAI;0BACD,IAAI;sBACR,IAAI;gCAKQ,IAAI,KAAG,OAAO;CAqBlD,CAAA"}
@@ -0,0 +1,50 @@
1
+ import { addDay, addMonth, addYear, getStartOfMonth, getStartOfWeek } from "../../../utils/dateTime.js";
2
+ import { computed, ref, watch } from "vue";
3
+ //#region src/components/DatePicker/use/useCalendarNavigation.ts
4
+ var useCalendarNavigation = (props) => {
5
+ const minMonth = computed(() => props.minDate ? getStartOfMonth(props.minDate) : void 0);
6
+ const maxMonth = computed(() => props.maxDate ? getStartOfMonth(props.maxDate) : void 0);
7
+ const clampMonth = (value) => {
8
+ if (minMonth.value && value < minMonth.value) return new Date(minMonth.value);
9
+ if (maxMonth.value && value > maxMonth.value) return new Date(maxMonth.value);
10
+ return value;
11
+ };
12
+ const currentDate = ref(clampMonth(getStartOfMonth()));
13
+ const isDirect = ref(false);
14
+ const year = computed(() => currentDate.value.getFullYear());
15
+ const setCurrentDate = (value) => {
16
+ const startOfMonth = clampMonth(getStartOfMonth(value));
17
+ if (startOfMonth.getTime() === currentDate.value.getTime()) return;
18
+ isDirect.value = startOfMonth > currentDate.value;
19
+ currentDate.value = startOfMonth;
20
+ };
21
+ const isPreviousDisabled = computed(() => !!minMonth.value && currentDate.value <= minMonth.value);
22
+ const isNextDisabled = computed(() => !!maxMonth.value && currentDate.value >= maxMonth.value);
23
+ const toPreviousMonth = () => setCurrentDate(addMonth(currentDate.value, -1));
24
+ const toNextMonth = () => setCurrentDate(addMonth(currentDate.value, 1));
25
+ const toPreviousYear = () => setCurrentDate(addYear(currentDate.value, -1));
26
+ const toNextYear = () => setCurrentDate(addYear(currentDate.value, 1));
27
+ const firstDay = computed(() => getStartOfWeek(currentDate.value));
28
+ const lastDay = computed(() => addDay(firstDay.value, 41));
29
+ const isSameCalendarPage = (value) => {
30
+ return value >= firstDay.value && value <= lastDay.value;
31
+ };
32
+ watch([minMonth, maxMonth], () => {
33
+ setCurrentDate(currentDate.value);
34
+ });
35
+ return {
36
+ currentDate,
37
+ isDirect,
38
+ year,
39
+ isPreviousDisabled,
40
+ isNextDisabled,
41
+ setCurrentDate,
42
+ toPreviousMonth,
43
+ toNextMonth,
44
+ toPreviousYear,
45
+ toNextYear,
46
+ isSameCalendarPage
47
+ };
48
+ };
49
+ //#endregion
50
+ export { useCalendarNavigation };
@@ -1 +1 @@
1
- {"version":3,"file":"WInputDate.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Input/WInputDate.vue"],"names":[],"mappings":"AAoDA;AAwHA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAO3C,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AAoNvD,QAAA,IAAwB,QAAQ,IAAW,EAAE,QAAQ,IAAW,EAAE,QAAQ;;CAAY,CAAE;AACxF,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,GAC3C;IAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,GAC9C;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO9C,QAAA,MAAM,UAAU;;;;;;;;;;;;6EAId,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"WInputDate.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/Input/WInputDate.vue"],"names":[],"mappings":"AAoDA;AA2HA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AAO3C,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AAuNvD,QAAA,IAAwB,QAAQ,IAAW,EAAE,QAAQ,IAAW,EAAE,QAAQ;;CAAY,CAAE;AACxF,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,GAC3C;IAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,GAC9C;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO9C,QAAA,MAAM,UAAU;;;;;;;;;;;;6EAId,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -95,8 +95,11 @@ var WInputDate_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
95
95
  const inputComponentRef = useTemplateRef("inputComponent");
96
96
  const inputValue = ref(props.modelValue ? dateFormat(props.modelValue) : "");
97
97
  const updateInputValue = (value) => {
98
- if (!value) return;
99
- inputValue.value = value;
98
+ inputValue.value = value ?? "";
99
+ if (!value) {
100
+ emit("update:model-value", void 0);
101
+ return;
102
+ }
100
103
  const date = parseDate(value);
101
104
  if (!date) return;
102
105
  if (props.minDate && props.minDate > date) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/rsmple/eco-vue-js.git"
6
6
  },
7
- "version": "0.16.1",
7
+ "version": "0.16.2",
8
8
  "dependencies": {
9
9
  "@stylistic/eslint-plugin": "5.10.0",
10
10
  "@tanstack/eslint-plugin-query": "5.102.8",