hys-ui 0.7.0 → 0.8.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/HysDatePicker/HysDatePicker.vue.js +102 -48
  3. package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +2 -2
  4. package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +874 -532
  5. package/dist/components/HysDatePicker/HysDatePickerPanel.vue.js +2 -2
  6. package/dist/components/HysDatePicker/HysDatePickerPanel2.vue.js +209 -168
  7. package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +102 -48
  8. package/dist/composables/datePicker.js +153 -94
  9. package/dist/composables/datePickerModel.js +156 -0
  10. package/dist/composables/datePickerPanels.js +78 -0
  11. package/dist/composables/datePickerRules.js +166 -0
  12. package/dist/composables/floatingPosition.js +32 -13
  13. package/dist/composables/useDatePicker.js +274 -381
  14. package/dist/composables/useFloating.js +21 -20
  15. package/dist/style.css +1 -1
  16. package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +6 -9
  17. package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +12 -0
  18. package/dist/types/components/HysDatePicker/HysDatePickerPanel.vue.d.ts +6 -0
  19. package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +6 -9
  20. package/dist/types/components/HysIcon/HysIcon.vue.d.ts +1 -1
  21. package/dist/types/composables/datePicker.d.ts +14 -214
  22. package/dist/types/composables/datePickerModel.d.ts +63 -0
  23. package/dist/types/composables/datePickerPanels.d.ts +23 -0
  24. package/dist/types/composables/datePickerRules.d.ts +31 -0
  25. package/dist/types/composables/datePickerTypes.d.ts +277 -0
  26. package/dist/types/composables/floatingPosition.d.ts +1 -1
  27. package/dist/types/composables/useColorPicker.d.ts +1 -3
  28. package/dist/types/composables/useContextMenu.d.ts +1 -3
  29. package/dist/types/composables/useDatePicker.d.ts +20 -11
  30. package/dist/types/composables/useFloating.d.ts +2 -3
  31. package/dist/types/index.d.ts +1 -1
  32. package/package.json +1 -1
@@ -0,0 +1,166 @@
1
+ import { calendarISO as L } from "./calendar.js";
2
+ import { datePeriod as _, dateShift as P, dateWeek as B, dateNative as G, DATE_MIN as J, DATE_MAX as K } from "./datePicker.js";
3
+ function p({
4
+ props: l,
5
+ range: D,
6
+ multiple: Q,
7
+ time: U,
8
+ unit: i,
9
+ first: k,
10
+ weekContains: N,
11
+ selected: Y,
12
+ draft: c,
13
+ stage: Z,
14
+ minPoint: h,
15
+ maxPoint: x
16
+ }) {
17
+ function E(e, d, s = c.value[0]) {
18
+ return {
19
+ range: d ? "end" : "start",
20
+ from: D.value && s ? G(s) : null,
21
+ iso: L(e)
22
+ };
23
+ }
24
+ function V(e) {
25
+ return Array.isArray(l.disabled) && !!l.disabled[e];
26
+ }
27
+ function M(e, d = 0, s = !0, u = c.value[0]) {
28
+ var a;
29
+ if (!Number.isFinite(e) || e < J || e > K || h.value && e < h.value.day || x.value && e > x.value.day || (a = l.disabledDate) != null && a.call(
30
+ l,
31
+ new Date(e * 864e5),
32
+ E(e, d, u)
33
+ ))
34
+ return !1;
35
+ if (D.value && s && d === 1 && c.value[0]) {
36
+ const t = i.value === "week" ? Math.abs(
37
+ _(e, "week", k.value)[0] - _(c.value[0].day, "week", k.value)[0]
38
+ ) + 7 : Math.abs(e - c.value[0].day) + 1;
39
+ if (l.minRangeDays && t < l.minRangeDays || l.maxRangeDays && t > l.maxRangeDays)
40
+ return !1;
41
+ }
42
+ return !0;
43
+ }
44
+ function W(e, d, s = Z.value === "end" ? 1 : 0, u = !0, a = c.value[0]) {
45
+ var n, b, r;
46
+ if (i.value === "week" && d - e <= 6) {
47
+ if ((n = l.disabledWeek) != null && n.call(l, B(e, k.value, N.value)))
48
+ return !1;
49
+ if (l.weekValidation === "full") {
50
+ if (d - e !== 6) return !1;
51
+ for (let m = e; m <= d; m++)
52
+ if (!M(m, s, u, a)) return !1;
53
+ return !0;
54
+ }
55
+ }
56
+ const t = Math.max(e, ((b = h.value) == null ? void 0 : b.day) ?? J), y = Math.min(d, ((r = x.value) == null ? void 0 : r.day) ?? K);
57
+ for (let m = t; m <= y; m++)
58
+ if (M(m, s, u, a)) return !0;
59
+ return !1;
60
+ }
61
+ function I(e, d, s = c.value[0]) {
62
+ var R, A, j, q, z;
63
+ const u = E(e.day, d, s), a = (R = l.disabledTime) == null ? void 0 : R.call(l, G(e), u), t = (A = l.disabledHours) == null ? void 0 : A.call(l, u.range, u.from), y = (j = a == null ? void 0 : a.disabledHours) == null ? void 0 : j.call(a), n = ((q = h.value) == null ? void 0 : q.day) === e.day ? h.value.second : 0, b = ((z = x.value) == null ? void 0 : z.day) === e.day ? F() : 86399;
64
+ function r(v, f) {
65
+ return v + f - 1 < n || v > b;
66
+ }
67
+ const m = Array.from({ length: 24 }, (v, f) => f).filter(
68
+ (v) => r(v * 3600, 3600)
69
+ ), w = Array.from({ length: 60 }, (v, f) => f);
70
+ return {
71
+ hours: [
72
+ ...m,
73
+ ...(a == null ? void 0 : a.hours) ?? [],
74
+ ...y ?? [],
75
+ ...t ?? []
76
+ ],
77
+ minutes: (v) => {
78
+ var f, S, T;
79
+ return [
80
+ ...w.filter(
81
+ (H) => r(v * 3600 + H * 60, 60)
82
+ ),
83
+ ...((f = a == null ? void 0 : a.minutes) == null ? void 0 : f.call(a, v)) ?? [],
84
+ ...((S = a == null ? void 0 : a.disabledMinutes) == null ? void 0 : S.call(a, v)) ?? [],
85
+ ...((T = l.disabledMinutes) == null ? void 0 : T.call(l, v, u.range, u.from)) ?? []
86
+ ];
87
+ },
88
+ seconds: (v, f) => {
89
+ var S, T, H;
90
+ return [
91
+ ...w.filter(
92
+ (C) => r(v * 3600 + f * 60 + C, 1)
93
+ ),
94
+ ...((S = a == null ? void 0 : a.seconds) == null ? void 0 : S.call(a, v, f)) ?? [],
95
+ ...((T = a == null ? void 0 : a.disabledSeconds) == null ? void 0 : T.call(a, v, f)) ?? [],
96
+ ...((H = l.disabledSeconds) == null ? void 0 : H.call(l, v, f, u.range, u.from)) ?? []
97
+ ];
98
+ }
99
+ };
100
+ }
101
+ function F() {
102
+ var e;
103
+ return typeof l.max == "string" && !/[T :]/.test(l.max) ? 86399 : ((e = x.value) == null ? void 0 : e.second) ?? 0;
104
+ }
105
+ function O(e, d, s = c.value[0]) {
106
+ var w, R, A;
107
+ const u = I(e, d, s), a = Math.floor(e.second / 3600), t = Math.floor(e.second / 60) % 60, y = e.second % 60;
108
+ if ((w = u.hours) != null && w.includes(a) || (R = u.minutes) != null && R.call(u, a).includes(t) || (A = u.seconds) != null && A.call(u, a, t).includes(y))
109
+ return !1;
110
+ const n = e.day * 86400 + e.second, b = h.value, r = x.value, m = F();
111
+ return !(b && n < b.day * 86400 + b.second || r && n > r.day * 86400 + m);
112
+ }
113
+ function $(e, d = !0) {
114
+ var s;
115
+ if (D.value) {
116
+ if (e.length !== 2 || e.some((t, y) => {
117
+ var n;
118
+ return !t && !((n = l.allowEmpty) != null && n[y]);
119
+ })) return !1;
120
+ const [u, a] = e;
121
+ if (u && a && u.day * 86400 + u.second > a.day * 86400 + a.second)
122
+ return !1;
123
+ if (u && a) {
124
+ const t = i.value === "week" ? _(a.day, "week", k.value)[1] : a.day, y = t - u.day + 1;
125
+ if (l.minRangeDays && y < l.minRangeDays || l.maxRangeDays && y > l.maxRangeDays)
126
+ return !1;
127
+ if (l.rangeValidation === "continuous") {
128
+ if (a.day > P(u.day, 1200)) return !1;
129
+ for (let n = u.day; n <= t; n++)
130
+ if (!M(n, n === u.day ? 0 : 1, !1, u) || i.value === "week" && (n - u.day) % 7 === 0 && ((s = l.disabledWeek) != null && s.call(
131
+ l,
132
+ B(n, k.value, N.value)
133
+ )))
134
+ return !1;
135
+ }
136
+ }
137
+ if (d && e.some((t, y) => V(y) && !X(t, Y.value[y])))
138
+ return !1;
139
+ } else if (!e.length || !Q.value && e.length !== 1 || l.maxDates && e.length > l.maxDates)
140
+ return !1;
141
+ return e.every(
142
+ (u, a) => !u || (i.value === "date" ? M(u.day, D.value ? a : 0, !1, e[0] ?? null) : W(
143
+ ..._(u.day, i.value, k.value),
144
+ D.value ? a : 0,
145
+ !1,
146
+ e[0] ?? null
147
+ )) && (!U.value || O(u, D.value ? a : 0, e[0] ?? null))
148
+ );
149
+ }
150
+ function X(e, d) {
151
+ return !e && !d || !!e && !!d && e.day === d.day && e.second === d.second;
152
+ }
153
+ return {
154
+ context: E,
155
+ locked: V,
156
+ available: M,
157
+ periodAvailable: W,
158
+ timeDisabled: I,
159
+ validTime: O,
160
+ valid: $,
161
+ samePoint: X
162
+ };
163
+ }
164
+ export {
165
+ p as useDatePickerRules
166
+ };
@@ -1,18 +1,37 @@
1
- function B(t, x, u, y, o, e, F) {
2
- const { width: f, height: n } = u, m = Math.min(x.width, Math.max(0, f - 2 * e)), s = Math.min(x.height, Math.max(0, n - 2 * e)), [j, l] = y.split("-"), b = {
3
- top: t.top - o,
4
- bottom: n - t.bottom - o,
5
- left: t.left - o,
6
- right: f - t.right - o
7
- }, k = { top: "bottom", bottom: "top", left: "right", right: "left" }, i = j, M = i === "top" || i === "bottom", c = k[i], h = F && b[i] < (M ? s : m) && b[c] > b[i] ? c : i, v = (p, r, w) => l === "start" ? p : l === "end" ? r - w : (p + r - w) / 2, q = M ? v(t.left, t.right, m) : h === "left" ? t.left - m - o : t.right + o, A = M ? h === "top" ? t.top - s - o : t.bottom + o : v(t.top, t.bottom, s);
1
+ function N(t, w, G, u, e, o, c, x) {
2
+ const { width: f, height: h } = G, s = Math.min(w.width, Math.max(0, f - 2 * o)), m = Math.min(w.height, Math.max(0, h - 2 * o)), [H, y] = u.split("-"), v = {
3
+ top: t.top - e,
4
+ bottom: h - t.bottom - e,
5
+ left: t.left - e,
6
+ right: f - t.right - e
7
+ }, I = {
8
+ top: "bottom",
9
+ bottom: "top",
10
+ left: "right",
11
+ right: "left"
12
+ }, l = H, J = l === "top" || l === "bottom", F = I[l], j = c && v[l] < (J ? m : s) && v[F] > v[l] ? F : l;
13
+ function p(r) {
14
+ const [i, q] = r.split("-"), A = i === "top" || i === "bottom", B = (C, D, E) => q === "start" ? C : q === "end" ? D - E : (C + D - E) / 2, M = A ? B(t.left, t.right, s) : i === "left" ? t.left - s - e : t.right + e, b = A ? i === "top" ? t.top - m - e : t.bottom + e : B(t.top, t.bottom, m), L = Math.max(0, o - M, M + s + o - f) + Math.max(0, o - b, b + m + o - h);
15
+ return { x: M, y: b, overflow: L, placement: r };
16
+ }
17
+ const K = y ? j + "-" + y : j;
18
+ let n = p(
19
+ c && x ? u : K
20
+ );
21
+ if (c && x)
22
+ for (const r of x) {
23
+ if (!n.overflow) break;
24
+ const i = p(r);
25
+ i.overflow < n.overflow && (n = i);
26
+ }
8
27
  return {
9
- width: m,
10
- height: s,
11
- x: Math.max(e, Math.min(q, f - m - e)),
12
- y: Math.max(e, Math.min(A, n - s - e)),
13
- placement: l ? h + "-" + l : h
28
+ width: s,
29
+ height: m,
30
+ x: Math.max(o, Math.min(n.x, f - s - o)),
31
+ y: Math.max(o, Math.min(n.y, h - m - o)),
32
+ placement: n.placement
14
33
  };
15
34
  }
16
35
  export {
17
- B as positionFloating
36
+ N as positionFloating
18
37
  };