@aminnausin/cedar-ui 0.0.3 → 0.0.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.
- package/dist/cedar-ui.mjs +205 -205
- package/dist/cedar-ui.umd.js +1 -1
- package/dist/index.d.ts +24 -20
- package/package.json +1 -1
package/dist/cedar-ui.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (i, e, t) =>
|
|
4
|
-
import { reactive as
|
|
5
|
-
function
|
|
6
|
-
const
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var ee = (i, e, t) => e in i ? Z(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var p = (i, e, t) => ee(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { reactive as P, watch as O, ref as u, computed as F, onMounted as te, nextTick as se, onBeforeUnmount as ne, shallowRef as ie } from "vue";
|
|
5
|
+
function ge({ options: i, defaultItems: e }, t) {
|
|
6
|
+
const o = P({
|
|
7
7
|
selectOpen: !1,
|
|
8
8
|
selectedItems: e,
|
|
9
9
|
selectableItems: i,
|
|
@@ -26,8 +26,8 @@ function ue({ options: i, defaultItems: e }, t) {
|
|
|
26
26
|
return !1;
|
|
27
27
|
},
|
|
28
28
|
async selectScrollToActiveItem(s, a = !0) {
|
|
29
|
-
let
|
|
30
|
-
|
|
29
|
+
let l = document.getElementById(s + "-" + this.selectId);
|
|
30
|
+
l && (l.scrollIntoView({ behavior: "smooth", block: "center" }), a && l.focus({ preventScroll: !1 }));
|
|
31
31
|
},
|
|
32
32
|
selectKeydown(s) {
|
|
33
33
|
if (s.keyCode < 65 || s.keyCode > 90) return;
|
|
@@ -38,10 +38,10 @@ function ue({ options: i, defaultItems: e }, t) {
|
|
|
38
38
|
}, this.selectKeydownTimeout));
|
|
39
39
|
},
|
|
40
40
|
selectItemsFindBestMatch() {
|
|
41
|
-
let s = this.selectKeydownValue.toLowerCase(), a = null,
|
|
41
|
+
let s = this.selectKeydownValue.toLowerCase(), a = null, l = -1;
|
|
42
42
|
for (const r of this.selectableItems) {
|
|
43
43
|
let h = r.name.toLowerCase().indexOf(s);
|
|
44
|
-
h > -1 && (
|
|
44
|
+
h > -1 && (l == -1 || h < l) && !r.disabled && (a = r, l = h);
|
|
45
45
|
}
|
|
46
46
|
return a;
|
|
47
47
|
},
|
|
@@ -55,158 +55,158 @@ function ue({ options: i, defaultItems: e }, t) {
|
|
|
55
55
|
Array.isArray(s) && (this.selectableItems = s);
|
|
56
56
|
}
|
|
57
57
|
}), n = () => {
|
|
58
|
-
|
|
58
|
+
o.selectOpen && o.selectPositionUpdate();
|
|
59
59
|
};
|
|
60
|
-
return
|
|
61
|
-
() =>
|
|
60
|
+
return O(
|
|
61
|
+
() => o.selectOpen,
|
|
62
62
|
function(s) {
|
|
63
|
-
if (
|
|
63
|
+
if (o.selectedItems ? o.selectableItemActive = o.selectedItem : o.selectableItemActive = o.selectableItems[0], !s) {
|
|
64
64
|
window.removeEventListener("resize", n);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
n(), window.addEventListener("resize", n);
|
|
68
68
|
},
|
|
69
69
|
{ immediate: !1 }
|
|
70
|
-
),
|
|
70
|
+
), o;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
var
|
|
74
|
-
const
|
|
72
|
+
function be(i, e, t) {
|
|
73
|
+
var _;
|
|
74
|
+
const o = u(!1), n = u(((_ = i.model) == null ? void 0 : _.value) ?? i.defaultDate ?? ""), s = u("F d, Y"), a = u(0), l = u(0), r = u(0), f = u([]), h = u([]), d = u("bottom"), m = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], g = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], v = u("D"), I = F(() => {
|
|
75
75
|
let c = Math.max(a.value, 0);
|
|
76
76
|
return c >= m.length && (c = 0), m[c];
|
|
77
|
-
}),
|
|
78
|
-
const c = Math.floor(
|
|
77
|
+
}), U = F(() => {
|
|
78
|
+
const c = Math.floor(l.value / 10) * 10;
|
|
79
79
|
return Array.from({ length: 10 }, (b, w) => c + w);
|
|
80
80
|
});
|
|
81
|
-
function
|
|
82
|
-
|
|
81
|
+
function q(c) {
|
|
82
|
+
o.value = c ?? !o.value, v.value = "D";
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function z(c = "D") {
|
|
85
85
|
v.value = c;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
const b = g[c.getDay()], w = ("0" + c.getDate()).slice(-2), T = m[c.getMonth()],
|
|
87
|
+
function M(c) {
|
|
88
|
+
const b = g[c.getDay()], w = ("0" + c.getDate()).slice(-2), T = m[c.getMonth()], x = T.substring(0, 3), C = ("0" + (c.getMonth() + 1)).slice(-2), y = c.getFullYear();
|
|
89
89
|
switch (s.value) {
|
|
90
90
|
case "F d, Y":
|
|
91
91
|
return `${T} ${w}, ${y}`;
|
|
92
92
|
case "d M, Y":
|
|
93
|
-
return `${w} ${
|
|
93
|
+
return `${w} ${x}, ${y}`;
|
|
94
94
|
case "Y M d":
|
|
95
|
-
return `${y} ${
|
|
95
|
+
return `${y} ${x} ${w}`;
|
|
96
96
|
case "MM-DD-YYYY":
|
|
97
|
-
return `${
|
|
97
|
+
return `${C}-${w}-${y}`;
|
|
98
98
|
case "DD-MM-YYYY":
|
|
99
|
-
return `${w}-${
|
|
99
|
+
return `${w}-${C}-${y}`;
|
|
100
100
|
case "YYYY-MM-DD":
|
|
101
|
-
return `${y}-${
|
|
101
|
+
return `${y}-${C}-${w}`;
|
|
102
102
|
case "D d M, Y":
|
|
103
|
-
return `${b} ${w} ${
|
|
103
|
+
return `${b} ${w} ${x} ${y}`;
|
|
104
104
|
default:
|
|
105
105
|
return `${T} ${w}, ${y}`;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function W(c) {
|
|
109
109
|
switch (v.value) {
|
|
110
110
|
case "Y":
|
|
111
|
-
|
|
111
|
+
l.value = c, v.value = "M";
|
|
112
112
|
break;
|
|
113
113
|
case "M":
|
|
114
|
-
a.value = c, v.value = "D",
|
|
114
|
+
a.value = c, v.value = "D", A();
|
|
115
115
|
break;
|
|
116
116
|
default:
|
|
117
|
-
r.value = c, n.value =
|
|
117
|
+
r.value = c, n.value = M(new Date(l.value, a.value, c)), o.value = !1, i.model && (i.model.value = n.value);
|
|
118
118
|
break;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function J() {
|
|
122
122
|
switch (v.value) {
|
|
123
123
|
case "Y":
|
|
124
|
-
|
|
124
|
+
l.value -= 10;
|
|
125
125
|
break;
|
|
126
126
|
case "M":
|
|
127
|
-
|
|
127
|
+
l.value -= 1;
|
|
128
128
|
break;
|
|
129
129
|
default:
|
|
130
|
-
a.value === 0 ? (
|
|
130
|
+
a.value === 0 ? (l.value--, a.value = 11) : a.value--, A();
|
|
131
131
|
break;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function X() {
|
|
135
135
|
switch (v.value) {
|
|
136
136
|
case "Y":
|
|
137
|
-
|
|
137
|
+
l.value += 10;
|
|
138
138
|
break;
|
|
139
139
|
case "M":
|
|
140
|
-
|
|
140
|
+
l.value += 1;
|
|
141
141
|
break;
|
|
142
142
|
default:
|
|
143
|
-
a.value === 11 ? (a.value = 0,
|
|
143
|
+
a.value === 11 ? (a.value = 0, l.value++) : a.value++, A();
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
const b = new Date(
|
|
149
|
-
return n.value ===
|
|
147
|
+
function Q(c) {
|
|
148
|
+
const b = new Date(l.value, a.value, c);
|
|
149
|
+
return n.value === M(b);
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const b = /* @__PURE__ */ new Date(), w = new Date(
|
|
151
|
+
function G(c) {
|
|
152
|
+
const b = /* @__PURE__ */ new Date(), w = new Date(l.value, a.value, c);
|
|
153
153
|
return b.toDateString() === w.toDateString();
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
const c = new Date(
|
|
155
|
+
function A() {
|
|
156
|
+
const c = new Date(l.value, a.value + 1, 0).getDate(), b = new Date(l.value, a.value).getDay();
|
|
157
157
|
h.value = Array.from({ length: b }, (w, T) => T + 1), f.value = Array.from({ length: c }, (w, T) => T + 1);
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
if (!e.value || !t.value || !
|
|
159
|
+
function B() {
|
|
160
|
+
if (!e.value || !t.value || !o.value) return;
|
|
161
161
|
const c = e.value.getBoundingClientRect(), b = t.value.offsetHeight, w = c.top + c.height + b;
|
|
162
162
|
d.value = w > window.innerHeight ? "top" : "bottom";
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
a.value = c.getMonth(),
|
|
164
|
+
function N(c, b = !0) {
|
|
165
|
+
a.value = c.getMonth(), l.value = c.getFullYear(), r.value = c.getDate(), b && (n.value = M(c)), A();
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function $() {
|
|
168
168
|
if (n.value)
|
|
169
|
-
return
|
|
170
|
-
|
|
169
|
+
return N(new Date(Date.parse(n.value)));
|
|
170
|
+
N(/* @__PURE__ */ new Date(), i.useDefaultDate);
|
|
171
171
|
}
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
}),
|
|
172
|
+
return te(() => {
|
|
173
|
+
$();
|
|
174
|
+
}), O(o, async (c) => {
|
|
175
175
|
if (!c) {
|
|
176
|
-
window.removeEventListener("resize",
|
|
176
|
+
window.removeEventListener("resize", B);
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
|
-
await
|
|
179
|
+
await se(), $(), B(), window.addEventListener("resize", B);
|
|
180
180
|
}), {
|
|
181
181
|
datePickerInput: e,
|
|
182
182
|
datePickerCalendar: t,
|
|
183
|
-
datePickerOpen:
|
|
183
|
+
datePickerOpen: o,
|
|
184
184
|
datePickerValue: n,
|
|
185
185
|
datePickerPanel: v,
|
|
186
186
|
datePickerFormat: s,
|
|
187
187
|
datePickerMonth: a,
|
|
188
188
|
datePickerMonthVerbose: I,
|
|
189
|
-
datePickerYear:
|
|
190
|
-
datePickerDecade:
|
|
189
|
+
datePickerYear: l,
|
|
190
|
+
datePickerDecade: U,
|
|
191
191
|
datePickerDay: r,
|
|
192
192
|
datePickerDaysInMonth: f,
|
|
193
193
|
datePickerBlankDaysInMonth: h,
|
|
194
194
|
datePickerMonthNames: m,
|
|
195
195
|
datePickerDays: g,
|
|
196
196
|
datePickerPosition: d,
|
|
197
|
-
toggleDatePicker:
|
|
198
|
-
datePickerValueClicked:
|
|
199
|
-
datePickerPrevious:
|
|
200
|
-
datePickerNext:
|
|
201
|
-
datePickerIsSelectedDate:
|
|
202
|
-
datePickerIsToday:
|
|
203
|
-
showDatePickerPanel:
|
|
197
|
+
toggleDatePicker: q,
|
|
198
|
+
datePickerValueClicked: W,
|
|
199
|
+
datePickerPrevious: J,
|
|
200
|
+
datePickerNext: X,
|
|
201
|
+
datePickerIsSelectedDate: Q,
|
|
202
|
+
datePickerIsToday: G,
|
|
203
|
+
showDatePickerPanel: z
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function j(i = "pv_id_") {
|
|
207
207
|
return i + Math.random().toString(16).slice(2);
|
|
208
208
|
}
|
|
209
|
-
class
|
|
209
|
+
class ae {
|
|
210
210
|
constructor() {
|
|
211
211
|
p(this, "subscribers");
|
|
212
212
|
p(this, "toasts");
|
|
@@ -222,20 +222,20 @@ class Z {
|
|
|
222
222
|
this.publish(e), this.toasts = [...this.toasts, e];
|
|
223
223
|
});
|
|
224
224
|
p(this, "create", (e, t) => {
|
|
225
|
-
const
|
|
226
|
-
return this.toasts.find((s) => s.id ===
|
|
225
|
+
const o = t.id ?? j("toast_");
|
|
226
|
+
return this.toasts.find((s) => s.id === o) ? this.toasts = this.toasts.map((s) => s.id === o ? (this.publish({ ...s, ...t, id: o, title: e }), {
|
|
227
227
|
...s,
|
|
228
228
|
...t,
|
|
229
|
-
id:
|
|
229
|
+
id: o,
|
|
230
230
|
title: e
|
|
231
231
|
}) : s) : this.addToast({
|
|
232
232
|
title: e,
|
|
233
|
-
id:
|
|
233
|
+
id: o,
|
|
234
234
|
scale: 1,
|
|
235
235
|
zIndex: 200,
|
|
236
236
|
offsetY: 0,
|
|
237
237
|
...t
|
|
238
|
-
}),
|
|
238
|
+
}), o;
|
|
239
239
|
});
|
|
240
240
|
p(this, "dismiss", (e) => {
|
|
241
241
|
e ? (this.publish({ id: e, dismiss: !0 }), this.toasts = this.toasts.filter((t) => t.id !== e)) : (this.toasts.forEach((t) => {
|
|
@@ -250,12 +250,12 @@ class Z {
|
|
|
250
250
|
this.subscribers = [], this.toasts = [];
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
const D = new
|
|
254
|
-
function
|
|
255
|
-
const t =
|
|
253
|
+
const D = new ae();
|
|
254
|
+
function le(i, e) {
|
|
255
|
+
const t = j("toast_");
|
|
256
256
|
return D.create(i, { ...e, id: t }), t;
|
|
257
257
|
}
|
|
258
|
-
const
|
|
258
|
+
const oe = Object.assign(le, {
|
|
259
259
|
add: D.add,
|
|
260
260
|
success: D.success,
|
|
261
261
|
error: D.error,
|
|
@@ -263,7 +263,7 @@ const te = Object.assign(ee, {
|
|
|
263
263
|
warning: D.warning,
|
|
264
264
|
dismiss: D.dismiss
|
|
265
265
|
});
|
|
266
|
-
function
|
|
266
|
+
function ye(i) {
|
|
267
267
|
const e = u(!1);
|
|
268
268
|
return {
|
|
269
269
|
copyNotification: e,
|
|
@@ -272,16 +272,16 @@ function de(i) {
|
|
|
272
272
|
await navigator.clipboard.writeText(i.value), e.value = !0, setTimeout(() => {
|
|
273
273
|
e.value = !1;
|
|
274
274
|
}, 3e3);
|
|
275
|
-
} catch (
|
|
276
|
-
console.error(
|
|
275
|
+
} catch (o) {
|
|
276
|
+
console.error(o), oe.error("Error", {
|
|
277
277
|
description: "Unable to copy. Network is not secure."
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
const t =
|
|
283
|
+
function Ie(i, e) {
|
|
284
|
+
const t = P({
|
|
285
285
|
selectOpen: !1,
|
|
286
286
|
selectedItem: "",
|
|
287
287
|
selectableItems: i,
|
|
@@ -326,9 +326,9 @@ function me(i, e) {
|
|
|
326
326
|
},
|
|
327
327
|
selectItemsFindBestMatch() {
|
|
328
328
|
let n = this.selectKeydownValue.toLowerCase(), s = null, a = -1;
|
|
329
|
-
for (const
|
|
330
|
-
let f =
|
|
331
|
-
f > -1 && (a == -1 || f < a) && !
|
|
329
|
+
for (const l of this.selectableItems) {
|
|
330
|
+
let f = l.title.toLowerCase().indexOf(n);
|
|
331
|
+
f > -1 && (a == -1 || f < a) && !l.disabled && (s = l, a = f);
|
|
332
332
|
}
|
|
333
333
|
return s;
|
|
334
334
|
},
|
|
@@ -338,26 +338,26 @@ function me(i, e) {
|
|
|
338
338
|
let n = ((s = this.selectButton) == null ? void 0 : s.getBoundingClientRect().top) + this.selectButton.offsetHeight + parseInt(window.getComputedStyle(this.selectableItemsList).maxHeight);
|
|
339
339
|
window.innerHeight < n ? this.selectDropdownPosition = "top" : this.selectDropdownPosition = "bottom";
|
|
340
340
|
}
|
|
341
|
-
}),
|
|
341
|
+
}), o = () => {
|
|
342
342
|
t.selectOpen && t.selectPositionUpdate();
|
|
343
343
|
};
|
|
344
|
-
return
|
|
344
|
+
return O(
|
|
345
345
|
() => t.selectOpen,
|
|
346
346
|
function(n) {
|
|
347
347
|
if (t.selectedItem ? t.selectableItemActive = t.selectedItem : t.selectableItemActive = t.selectableItems[0], !n) {
|
|
348
|
-
window.removeEventListener("resize",
|
|
348
|
+
window.removeEventListener("resize", o);
|
|
349
349
|
return;
|
|
350
350
|
}
|
|
351
351
|
window.setTimeout(function() {
|
|
352
352
|
t.selectScrollToActiveItem();
|
|
353
|
-
}, 10),
|
|
353
|
+
}, 10), o(), window.addEventListener("resize", o);
|
|
354
354
|
},
|
|
355
355
|
{ immediate: !1 }
|
|
356
356
|
), t;
|
|
357
357
|
}
|
|
358
|
-
function
|
|
358
|
+
function Te(i) {
|
|
359
359
|
const e = u(null);
|
|
360
|
-
return
|
|
360
|
+
return P({
|
|
361
361
|
title: "",
|
|
362
362
|
...i,
|
|
363
363
|
modalOpen: !1,
|
|
@@ -373,14 +373,14 @@ function he(i) {
|
|
|
373
373
|
}
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
|
-
function
|
|
377
|
-
const e = u(1), t = u(i.itemsPerPage ?? 10),
|
|
378
|
-
filteredPage:
|
|
376
|
+
function De(i) {
|
|
377
|
+
const e = u(1), t = u(i.itemsPerPage ?? 10), o = u(i.searchQuery ?? ""), n = P({
|
|
378
|
+
filteredPage: F(() => {
|
|
379
379
|
const s = t.value * (e.value - 1), a = Math.min(t.value * e.value, i.data.length);
|
|
380
380
|
return i.data.slice(s, a);
|
|
381
381
|
}),
|
|
382
382
|
props: i,
|
|
383
|
-
fields: { currentPage: e, itemsPerPage: t, searchQuery:
|
|
383
|
+
fields: { currentPage: e, itemsPerPage: t, searchQuery: o },
|
|
384
384
|
handlePageChange(s) {
|
|
385
385
|
e.value = s;
|
|
386
386
|
},
|
|
@@ -388,51 +388,51 @@ function ve(i) {
|
|
|
388
388
|
e.value = 1;
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
|
-
return
|
|
391
|
+
return O(
|
|
392
392
|
() => i.data,
|
|
393
393
|
(s, a) => {
|
|
394
|
-
var
|
|
395
|
-
((s == null ? void 0 : s.length) !== (a == null ? void 0 : a.length) || s[0] && a[0] && ((
|
|
394
|
+
var l, r;
|
|
395
|
+
((s == null ? void 0 : s.length) !== (a == null ? void 0 : a.length) || s[0] && a[0] && ((l = s[0]) == null ? void 0 : l.id) !== ((r = a[0]) == null ? void 0 : r.id)) && n.handlePageReset();
|
|
396
396
|
},
|
|
397
397
|
{ immediate: !0 }
|
|
398
398
|
), n;
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function ce(i) {
|
|
401
401
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
402
402
|
}
|
|
403
|
-
var
|
|
404
|
-
function
|
|
405
|
-
return
|
|
403
|
+
var k, K;
|
|
404
|
+
function re() {
|
|
405
|
+
return K || (K = 1, k = function i(e, t) {
|
|
406
406
|
if (e === t) return !0;
|
|
407
407
|
if (e && t && typeof e == "object" && typeof t == "object") {
|
|
408
408
|
if (e.constructor !== t.constructor) return !1;
|
|
409
|
-
var
|
|
409
|
+
var o, n, s;
|
|
410
410
|
if (Array.isArray(e)) {
|
|
411
|
-
if (
|
|
412
|
-
for (n =
|
|
411
|
+
if (o = e.length, o != t.length) return !1;
|
|
412
|
+
for (n = o; n-- !== 0; )
|
|
413
413
|
if (!i(e[n], t[n])) return !1;
|
|
414
414
|
return !0;
|
|
415
415
|
}
|
|
416
416
|
if (e.constructor === RegExp) return e.source === t.source && e.flags === t.flags;
|
|
417
417
|
if (e.valueOf !== Object.prototype.valueOf) return e.valueOf() === t.valueOf();
|
|
418
418
|
if (e.toString !== Object.prototype.toString) return e.toString() === t.toString();
|
|
419
|
-
if (s = Object.keys(e),
|
|
420
|
-
for (n =
|
|
419
|
+
if (s = Object.keys(e), o = s.length, o !== Object.keys(t).length) return !1;
|
|
420
|
+
for (n = o; n-- !== 0; )
|
|
421
421
|
if (!Object.prototype.hasOwnProperty.call(t, s[n])) return !1;
|
|
422
|
-
for (n =
|
|
422
|
+
for (n = o; n-- !== 0; ) {
|
|
423
423
|
var a = s[n];
|
|
424
424
|
if (!i(e[a], t[a])) return !1;
|
|
425
425
|
}
|
|
426
426
|
return !0;
|
|
427
427
|
}
|
|
428
428
|
return e !== e && t !== t;
|
|
429
|
-
}),
|
|
429
|
+
}), k;
|
|
430
430
|
}
|
|
431
|
-
var
|
|
432
|
-
const
|
|
433
|
-
function
|
|
431
|
+
var ue = re();
|
|
432
|
+
const fe = /* @__PURE__ */ ce(ue);
|
|
433
|
+
function Se(i) {
|
|
434
434
|
let e = i, t;
|
|
435
|
-
const
|
|
435
|
+
const o = P({
|
|
436
436
|
fields: structuredClone(i),
|
|
437
437
|
errors: {},
|
|
438
438
|
dirty: !1,
|
|
@@ -446,17 +446,17 @@ function we(i) {
|
|
|
446
446
|
onBefore: async () => {
|
|
447
447
|
this.processing = !0, this.wasSuccessful = !1, this.recentlySuccessful = !1, clearTimeout(t), s.onBefore && await s.onBefore();
|
|
448
448
|
},
|
|
449
|
-
onSuccess: async (
|
|
449
|
+
onSuccess: async (l) => {
|
|
450
450
|
this.clearErrors(), this.wasSuccessful = !0, this.recentlySuccessful = !0, t = window.setTimeout(() => {
|
|
451
451
|
this.recentlySuccessful = !1;
|
|
452
|
-
}, 2e3), s.onSuccess && await s.onSuccess(
|
|
452
|
+
}, 2e3), s.onSuccess && await s.onSuccess(l), e = structuredClone(this.fields);
|
|
453
453
|
},
|
|
454
|
-
onError: async (
|
|
454
|
+
onError: async (l) => {
|
|
455
455
|
var r, f, h, d, m;
|
|
456
|
-
this.hasErrors = !0, (((r =
|
|
457
|
-
message: (h =
|
|
458
|
-
...(m = (d =
|
|
459
|
-
})), s.onError && await s.onError(
|
|
456
|
+
this.hasErrors = !0, (((r = l == null ? void 0 : l.response) == null ? void 0 : r.status) === 422 || ((f = l == null ? void 0 : l.response) == null ? void 0 : f.status) === 401) && (this.clearErrors(), this.setErrors({
|
|
457
|
+
message: (h = l == null ? void 0 : l.response) == null ? void 0 : h.data.message,
|
|
458
|
+
...(m = (d = l == null ? void 0 : l.response) == null ? void 0 : d.data) == null ? void 0 : m.errors
|
|
459
|
+
})), s.onError && await s.onError(l);
|
|
460
460
|
},
|
|
461
461
|
onFinish: async () => {
|
|
462
462
|
this.processing = !1, s.onFinish && await s.onFinish();
|
|
@@ -464,10 +464,10 @@ function we(i) {
|
|
|
464
464
|
};
|
|
465
465
|
await a.onBefore();
|
|
466
466
|
try {
|
|
467
|
-
const
|
|
468
|
-
await a.onSuccess(
|
|
469
|
-
} catch (
|
|
470
|
-
await a.onError(
|
|
467
|
+
const l = await n(this.fields);
|
|
468
|
+
await a.onSuccess(l);
|
|
469
|
+
} catch (l) {
|
|
470
|
+
await a.onError(l);
|
|
471
471
|
} finally {
|
|
472
472
|
await a.onFinish();
|
|
473
473
|
}
|
|
@@ -485,56 +485,56 @@ function we(i) {
|
|
|
485
485
|
this.errors = { ...this.errors, ...n }, this.hasErrors = Object.keys(this.errors).length > 0;
|
|
486
486
|
}
|
|
487
487
|
});
|
|
488
|
-
return
|
|
489
|
-
() =>
|
|
488
|
+
return O(
|
|
489
|
+
() => o.fields,
|
|
490
490
|
() => {
|
|
491
|
-
|
|
491
|
+
o.dirty = !fe(o.fields, e);
|
|
492
492
|
},
|
|
493
493
|
{ immediate: !0, deep: !0 }
|
|
494
|
-
),
|
|
494
|
+
), o;
|
|
495
495
|
}
|
|
496
|
-
function
|
|
497
|
-
const
|
|
496
|
+
function Pe({ directions: i, threshold: e, onSwipeOut: t }) {
|
|
497
|
+
const o = u(!1), n = u({ x: 0, y: 0 }), s = u(), a = u({ x: 0, y: 0 }), l = (d) => 1 / (1.5 + Math.abs(d) / 20);
|
|
498
498
|
function r(d) {
|
|
499
|
-
s.value = Date.now(), d.target.setPointerCapture(d.pointerId), !d.target.closest("button, a, input, textarea, select") && (a.value = { x: d.clientX, y: d.clientY },
|
|
499
|
+
s.value = Date.now(), d.target.setPointerCapture(d.pointerId), !d.target.closest("button, a, input, textarea, select") && (a.value = { x: d.clientX, y: d.clientY }, o.value = !0);
|
|
500
500
|
}
|
|
501
501
|
function f(d) {
|
|
502
|
-
if (!
|
|
502
|
+
if (!o.value) return;
|
|
503
503
|
const m = { x: 0, y: 0 }, g = d.clientX - a.value.x, v = d.clientY - a.value.y;
|
|
504
504
|
if (i.value.includes("left") && g < 0 || i.value.includes("right") && g > 0)
|
|
505
505
|
m.x = g;
|
|
506
506
|
else {
|
|
507
|
-
const I = g *
|
|
507
|
+
const I = g * l(g);
|
|
508
508
|
m.x = Math.abs(I) < Math.abs(g) ? I : g;
|
|
509
509
|
}
|
|
510
510
|
if (i.value.includes("top") && v < 0 || i.value.includes("bottom") && v > 0)
|
|
511
511
|
m.y = v;
|
|
512
512
|
else {
|
|
513
|
-
const I = v *
|
|
513
|
+
const I = v * l(v);
|
|
514
514
|
m.y = Math.abs(I) < Math.abs(v) ? I : v;
|
|
515
515
|
}
|
|
516
516
|
n.value = m;
|
|
517
517
|
}
|
|
518
518
|
function h() {
|
|
519
|
-
if (!
|
|
519
|
+
if (!o.value) return;
|
|
520
520
|
const d = Date.now() - (s.value ?? 0), m = n.value.x, g = Math.abs(m) / d;
|
|
521
521
|
if (Math.abs(m) >= e || g > 0.11) {
|
|
522
522
|
t();
|
|
523
523
|
return;
|
|
524
524
|
}
|
|
525
|
-
|
|
525
|
+
o.value = !1, n.value = { x: 0, y: 0 };
|
|
526
526
|
}
|
|
527
527
|
return {
|
|
528
528
|
offset: n,
|
|
529
|
-
isSwiping:
|
|
529
|
+
isSwiping: o,
|
|
530
530
|
onPointerDown: r,
|
|
531
531
|
onPointerMove: f,
|
|
532
532
|
onPointerUp: h
|
|
533
533
|
};
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function Oe({ duration: i, isPaused: e, onTimeout: t, immediate: o = !0 }) {
|
|
536
536
|
const n = u(), s = u(0), a = u(i);
|
|
537
|
-
function
|
|
537
|
+
function l() {
|
|
538
538
|
a.value === 1 / 0 || e() || (s.value = Date.now(), n.value = window.setTimeout(() => {
|
|
539
539
|
t();
|
|
540
540
|
}, a.value));
|
|
@@ -547,100 +547,100 @@ function ge({ duration: i, isPaused: e, onTimeout: t, immediate: l = !0 }) {
|
|
|
547
547
|
function f() {
|
|
548
548
|
n.value && (clearTimeout(n.value), n.value = null);
|
|
549
549
|
}
|
|
550
|
-
return
|
|
550
|
+
return O(
|
|
551
551
|
e,
|
|
552
552
|
(h) => {
|
|
553
553
|
if (h) {
|
|
554
554
|
r();
|
|
555
555
|
return;
|
|
556
556
|
}
|
|
557
|
-
|
|
557
|
+
l();
|
|
558
558
|
},
|
|
559
|
-
{ immediate:
|
|
560
|
-
),
|
|
559
|
+
{ immediate: o }
|
|
560
|
+
), ne(() => {
|
|
561
561
|
f();
|
|
562
562
|
}), { cancel: f };
|
|
563
563
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
return { isOpen:
|
|
564
|
+
const E = u(!1), L = u(!1), Y = u(300), S = u(null), R = P({}), H = ie(null);
|
|
565
|
+
function de(i, e = {}) {
|
|
566
|
+
S.value && clearTimeout(S.value), H.value = i, Object.assign(R, e), L.value = !0, E.value = !0, S.value = window.setTimeout(() => {
|
|
567
|
+
E.value = !1;
|
|
568
|
+
}, Y.value);
|
|
569
|
+
}
|
|
570
|
+
function me() {
|
|
571
|
+
S.value && clearTimeout(S.value), L.value = !1, E.value = !0, S.value = window.setTimeout(() => {
|
|
572
|
+
E.value = !1;
|
|
573
|
+
}, Y.value);
|
|
574
|
+
}
|
|
575
|
+
function Ee() {
|
|
576
|
+
return { isOpen: L, isAnimating: E, animationTime: Y, props: R, component: H, open: de, close: me };
|
|
577
577
|
}
|
|
578
|
-
function
|
|
578
|
+
function Ae(i, e) {
|
|
579
579
|
if (!i) return !1;
|
|
580
580
|
let t = ["INPUT", "TEXTAREA", "SELECT"];
|
|
581
581
|
return (e === " " || e === "Enter") && (t = [...t, "BUTTON"]), t.includes(i.tagName);
|
|
582
582
|
}
|
|
583
|
-
const
|
|
584
|
-
stringInsensitive: (i, e) =>
|
|
583
|
+
const Me = 3, Be = "24px", xe = "16px", Ce = 0, ke = 3e3, Fe = 16, Le = 45, Ye = 10, Ne = 0.06, $e = 16, he = {
|
|
584
|
+
stringInsensitive: (i, e) => V(i).localeCompare(V(e)),
|
|
585
585
|
date: (i, e) => new Date(i).getTime() - new Date(e).getTime(),
|
|
586
586
|
number: (i, e) => parseFloat(i) - parseFloat(e)
|
|
587
587
|
};
|
|
588
|
-
function
|
|
588
|
+
function V(i) {
|
|
589
589
|
return String(i ?? "").toLowerCase().replace(/\s+/g, " ").trim();
|
|
590
590
|
}
|
|
591
|
-
function
|
|
592
|
-
return (
|
|
593
|
-
const s =
|
|
591
|
+
function _e(i, e = 1, t = ["date", "date_released"]) {
|
|
592
|
+
return (o, n) => {
|
|
593
|
+
const s = o[i], a = n[i];
|
|
594
594
|
if (s instanceof Date && a instanceof Date || t.includes(String(i))) {
|
|
595
595
|
const f = new Date(String(s));
|
|
596
596
|
return (new Date(String(a)).getTime() - f.getTime()) * e;
|
|
597
597
|
}
|
|
598
|
-
const
|
|
599
|
-
return !isNaN(
|
|
598
|
+
const l = parseFloat(s), r = parseFloat(a);
|
|
599
|
+
return !isNaN(l) && !isNaN(r) ? (l - r) * e : String(s).toLowerCase().replace(/\s+/g, " ").localeCompare(String(a).toLowerCase().replace(/\s+/g, " ")) * e;
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
|
-
function
|
|
603
|
-
return (t,
|
|
602
|
+
function Ke(i, e = 1) {
|
|
603
|
+
return (t, o) => {
|
|
604
604
|
for (const { key: n, compareFn: s } of i) {
|
|
605
|
-
const a = n ? t[n] ?? "" : void 0,
|
|
605
|
+
const a = n ? t[n] ?? "" : void 0, l = n ? o[n] ?? "" : void 0;
|
|
606
606
|
let r;
|
|
607
|
-
if (s ? r = n ? s(a,
|
|
607
|
+
if (s ? r = n ? s(a, l) : s(t, o) : r = ve(a, l), r !== 0) return r * e;
|
|
608
608
|
}
|
|
609
609
|
return 0;
|
|
610
610
|
};
|
|
611
611
|
}
|
|
612
|
-
function
|
|
613
|
-
const t = parseFloat(i),
|
|
614
|
-
if (!isNaN(t) && !isNaN(
|
|
615
|
-
return t -
|
|
612
|
+
function ve(i, e) {
|
|
613
|
+
const t = parseFloat(i), o = parseFloat(e);
|
|
614
|
+
if (!isNaN(t) && !isNaN(o))
|
|
615
|
+
return t - o;
|
|
616
616
|
const n = new Date(i), s = new Date(e);
|
|
617
|
-
return !isNaN(n.getTime()) && !isNaN(s.getTime()) ? n.getTime() - s.getTime() :
|
|
617
|
+
return !isNaN(n.getTime()) && !isNaN(s.getTime()) ? n.getTime() - s.getTime() : he.stringInsensitive(i, e);
|
|
618
618
|
}
|
|
619
619
|
export {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
620
|
+
he as CompareStrategies,
|
|
621
|
+
Fe as DEFAULT_GAP,
|
|
622
|
+
xe as MOBILE_VIEWPORT_OFFSET,
|
|
623
|
+
Ne as SCALE_STEP,
|
|
624
|
+
Le as SWIPE_THRESHOLD,
|
|
625
|
+
ke as TOAST_LIFE,
|
|
626
|
+
Ce as TOAST_WIDTH,
|
|
627
627
|
D as ToastState,
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
628
|
+
Be as VIEWPORT_OFFSET,
|
|
629
|
+
Me as VISIBLE_TOASTS_AMOUNT,
|
|
630
|
+
$e as Y_OFFSET_STEP,
|
|
631
|
+
Ye as Z_STEP,
|
|
632
|
+
Ae as isInputLikeElement,
|
|
633
|
+
_e as sortObject,
|
|
634
|
+
Ke as sortObjectNew,
|
|
635
|
+
oe as toast,
|
|
636
|
+
ye as useClipboard,
|
|
637
|
+
be as useDatePicker,
|
|
638
|
+
Se as useForm,
|
|
639
|
+
Te as useModal,
|
|
640
|
+
Ee as useModalCore,
|
|
641
|
+
ge as useMultiSelect,
|
|
642
|
+
Ie as useSelect,
|
|
643
|
+
Pe as useSwipeHandler,
|
|
644
|
+
De as useTable,
|
|
645
|
+
Oe as useToastTimer
|
|
646
646
|
};
|
package/dist/cedar-ui.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r.CedarUI={},r.Vue))})(this,function(r,o){"use strict";var Se=Object.defineProperty;var De=(r,o,E)=>o in r?Se(r,o,{enumerable:!0,configurable:!0,writable:!0,value:E}):r[o]=E;var b=(r,o,E)=>De(r,typeof o!="symbol"?o+"":o,E);function E({options:i,defaultItems:e},t){const l=o.reactive({selectOpen:!1,selectedItems:e,selectableItems:i,selectableItemActive:null,selectId:"select-12",selectKeydownValue:"",selectKeydownTimeout:1e3,selectKeydownClearTimeout:null,selectDropdownPosition:"bottom",selectableItemsList:t.selectableItemsList,selectButton:t.selectButton,toggleSelect(s){s!==void 0?this.selectOpen=s===!0:this.selectOpen=!this.selectOpen},updateRefs(s){this.selectButton=s.selectButton,this.selectableItemsList=s.selectableItemsList,this.selectPositionUpdate()},selectableItemIsActive(){return!1},async selectScrollToActiveItem(s,a=!0){let c=document.getElementById(s+"-"+this.selectId);c&&(c.scrollIntoView({behavior:"smooth",block:"center"}),a&&c.focus({preventScroll:!1}))},selectKeydown(s){if(s.keyCode<65||s.keyCode>90)return;this.selectKeydownValue+=s.key;let a=this.selectItemsFindBestMatch();a&&this.selectOpen&&(this.selectableItemActive=a),this.selectKeydownValue!==""&&(clearTimeout(this.selectKeydownClearTimeout),this.selectKeydownClearTimeout=window.setTimeout(()=>{this.selectKeydownValue=""},this.selectKeydownTimeout))},selectItemsFindBestMatch(){let s=this.selectKeydownValue.toLowerCase(),a=null,c=-1;for(const f of this.selectableItems){let v=f.name.toLowerCase().indexOf(s);v>-1&&(c==-1||v<c)&&!f.disabled&&(a=f,c=v)}return a},selectPositionUpdate(){var a;if(!this.selectButton||!this.selectableItemsList)return;let s=((a=this.selectButton)==null?void 0:a.getBoundingClientRect().top)+this.selectButton.offsetHeight+parseInt(window.getComputedStyle(this.selectableItemsList).maxHeight);this.selectDropdownPosition=window.innerHeight<s?"top":"bottom"},setOptions(s){Array.isArray(s)&&(this.selectableItems=s)}}),n=()=>{l.selectOpen&&l.selectPositionUpdate()};return o.watch(()=>l.selectOpen,function(s){if(l.selectedItems?l.selectableItemActive=l.selectedItem:l.selectableItemActive=l.selectableItems[0],!s){window.removeEventListener("resize",n);return}n(),window.addEventListener("resize",n)},{immediate:!1}),l}function K(i,e,t){var V;const l=o.ref(!1),n=o.ref(((V=i.model)==null?void 0:V.value)??i.defaultDate??""),s=o.ref("F d, Y"),a=o.ref(0),c=o.ref(0),f=o.ref(0),d=o.ref([]),v=o.ref([]),m=o.ref("bottom"),h=["January","February","March","April","May","June","July","August","September","October","November","December"],I=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],w=o.ref("D"),S=o.computed(()=>{let u=Math.max(a.value,0);return u>=h.length&&(u=0),h[u]}),ve=o.computed(()=>{const u=Math.floor(c.value/10)*10;return Array.from({length:10},(T,g)=>u+g)});function we(u){l.value=u??!l.value,w.value="D"}function ge(u="D"){w.value=u}function A(u){const T=I[u.getDay()],g=("0"+u.getDate()).slice(-2),D=h[u.getMonth()],B=D.substring(0,3),F=("0"+(u.getMonth()+1)).slice(-2),p=u.getFullYear();switch(s.value){case"F d, Y":return`${D} ${g}, ${p}`;case"d M, Y":return`${g} ${B}, ${p}`;case"Y M d":return`${p} ${B} ${g}`;case"MM-DD-YYYY":return`${F}-${g}-${p}`;case"DD-MM-YYYY":return`${g}-${F}-${p}`;case"YYYY-MM-DD":return`${p}-${F}-${g}`;case"D d M, Y":return`${T} ${g} ${B} ${p}`;default:return`${D} ${g}, ${p}`}}function be(u){switch(w.value){case"Y":c.value=u,w.value="M";break;case"M":a.value=u,w.value="D",O();break;default:f.value=u,n.value=A(new Date(c.value,a.value,u)),l.value=!1,i.model&&(i.model.value=n.value);break}}function Ie(){switch(w.value){case"Y":c.value-=10;break;case"M":c.value-=1;break;default:a.value===0?(c.value--,a.value=11):a.value--,O();break}}function Te(){switch(w.value){case"Y":c.value+=10;break;case"M":c.value+=1;break;default:a.value===11?(a.value=0,c.value++):a.value++,O();break}}function ye(u){const T=new Date(c.value,a.value,u);return n.value===A(T)}function pe(u){const T=new Date,g=new Date(c.value,a.value,u);return T.toDateString()===g.toDateString()}function O(){const u=new Date(c.value,a.value+1,0).getDate(),T=new Date(c.value,a.value).getDay();v.value=Array.from({length:T},(g,D)=>D+1),d.value=Array.from({length:u},(g,D)=>D+1)}function M(){if(!e.value||!t.value||!l.value)return;const u=e.value.getBoundingClientRect(),T=t.value.offsetHeight,g=u.top+u.height+T;m.value=g>window.innerHeight?"top":"bottom"}function N(u,T=!0){a.value=u.getMonth(),c.value=u.getFullYear(),f.value=u.getDate(),T&&(n.value=A(u)),O()}function $(){if(n.value)return N(new Date(Date.parse(n.value)));N(new Date,i.useDefaultDate)}return o.onMounted(()=>{$()}),o.watch(l,async u=>{if(!u){window.removeEventListener("resize",M);return}await o.nextTick(),$(),M(),window.addEventListener("resize",M)}),{datePickerInput:e,datePickerCalendar:t,datePickerOpen:l,datePickerValue:n,datePickerPanel:w,datePickerFormat:s,datePickerMonth:a,datePickerMonthVerbose:S,datePickerYear:c,datePickerDecade:ve,datePickerDay:f,datePickerDaysInMonth:d,datePickerBlankDaysInMonth:v,datePickerMonthNames:h,datePickerDays:I,datePickerPosition:m,toggleDatePicker:we,datePickerValueClicked:be,datePickerPrevious:Ie,datePickerNext:Te,datePickerIsSelectedDate:ye,datePickerIsToday:pe,showDatePickerPanel:ge}}function C(i="pv_id_"){return i+Math.random().toString(16).slice(2)}class j{constructor(){b(this,"subscribers");b(this,"toasts");b(this,"subscribe",e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}));b(this,"publish",e=>{this.subscribers.forEach(t=>t(e))});b(this,"addToast",e=>{this.publish(e),this.toasts=[...this.toasts,e]});b(this,"create",(e,t)=>{const l=t.id??C("toast_");return this.toasts.find(s=>s.id===l)?this.toasts=this.toasts.map(s=>s.id===l?(this.publish({...s,...t,id:l,title:e}),{...s,...t,id:l,title:e}):s):this.addToast({title:e,id:l,scale:1,zIndex:200,offsetY:0,...t}),l});b(this,"dismiss",e=>{e?(this.publish({id:e,dismiss:!0}),this.toasts=this.toasts.filter(t=>t.id!==e)):(this.toasts.forEach(t=>{this.publish({id:t.id,dismiss:!0})}),this.toasts=[])});b(this,"add",(e,t)=>this.create(e,{...t}));b(this,"success",(e,t)=>this.create(e,{type:"success",...t}));b(this,"error",(e,t)=>this.create(e,{type:"danger",...t}));b(this,"info",(e,t)=>this.create(e,{type:"info",...t}));b(this,"warning",(e,t)=>this.create(e,{type:"warning",...t}));this.subscribers=[],this.toasts=[]}}const y=new j;function R(i,e){const t=C("toast_");return y.create(i,{...e,id:t}),t}const L=Object.assign(R,{add:y.add,success:y.success,error:y.error,info:y.info,warning:y.warning,dismiss:y.dismiss});function H(i){const e=o.ref(!1);return{copyNotification:e,copyToClipboard:async()=>{try{await navigator.clipboard.writeText(i.value),e.value=!0,setTimeout(()=>{e.value=!1},3e3)}catch(l){console.error(l),L.error("Error",{description:"Unable to copy. Network is not secure."})}}}}function U(i,e){const t=o.reactive({selectOpen:!1,selectedItem:"",selectableItems:i,selectableItemActive:null,selectId:"select-12",selectKeydownValue:"",selectKeydownTimeout:1e3,selectKeydownClearTimeout:null,selectDropdownPosition:"bottom",selectableItemsList:e.selectableItemsList,selectButton:e.selectButton,toggleSelect(n){n!==void 0?this.selectOpen=n===!0:this.selectOpen=!this.selectOpen},updateRefs(n){this.selectButton=n.selectButton,this.selectableItemsList=n.selectableItemsList},selectableItemIsActive(n){return this.selectableItemActive&&this.selectableItemActive.value==n.value},selectableItemActiveNext(){let n=this.selectableItems.indexOf(this.selectableItemActive);n<this.selectableItems.length-1&&(this.selectableItemActive=this.selectableItems[n+1],this.selectScrollToActiveItem())},selectableItemActivePrevious(){let n=this.selectableItems.indexOf(this.selectableItemActive);n>0&&(this.selectableItemActive=this.selectableItems[n-1],this.selectScrollToActiveItem())},selectScrollToActiveItem(){if(!this.selectableItemActive)return;let n=document.getElementById(this.selectableItemActive.value+"-"+this.selectId);n&&n.focus()},selectKeydown(n){if(n.keyCode>=65&&n.keyCode<=90){this.selectKeydownValue+=n.key;let s=this.selectItemsFindBestMatch();s&&(this.selectOpen?(this.selectableItemActive=s,this.selectScrollToActiveItem()):this.selectedItem=this.selectableItemActive===s),this.selectKeydownValue!=""&&(clearTimeout(this.selectKeydownClearTimeout),this.selectKeydownClearTimeout=window.setTimeout(()=>{this.selectKeydownValue=""},this.selectKeydownTimeout))}},selectItemsFindBestMatch(){let n=this.selectKeydownValue.toLowerCase(),s=null,a=-1;for(const c of this.selectableItems){let d=c.title.toLowerCase().indexOf(n);d>-1&&(a==-1||d<a)&&!c.disabled&&(s=c,a=d)}return s},selectPositionUpdate(){var s;if(!this.selectableItemsList||!this.selectButton)return;let n=((s=this.selectButton)==null?void 0:s.getBoundingClientRect().top)+this.selectButton.offsetHeight+parseInt(window.getComputedStyle(this.selectableItemsList).maxHeight);window.innerHeight<n?this.selectDropdownPosition="top":this.selectDropdownPosition="bottom"}}),l=()=>{t.selectOpen&&t.selectPositionUpdate()};return o.watch(()=>t.selectOpen,function(n){if(t.selectedItem?t.selectableItemActive=t.selectedItem:t.selectableItemActive=t.selectableItems[0],!n){window.removeEventListener("resize",l);return}window.setTimeout(function(){t.selectScrollToActiveItem()},10),l(),window.addEventListener("resize",l)},{immediate:!1}),t}function x(i){const e=o.ref(null);return o.reactive({title:"",...i,modalOpen:!1,isAnimating:!1,animationTime:i.animationTime??300,toggleModal(t=null){this.isAnimating||(e.value&&clearTimeout(e.value),t!=null?this.modalOpen=t:this.modalOpen=!this.modalOpen,this.isAnimating=!0,e.value=window.setTimeout(()=>{this.isAnimating=!1},this.animationTime))},setTitle(t){this.title=t}})}function q(i){const e=o.ref(1),t=o.ref(i.itemsPerPage??10),l=o.ref(i.searchQuery??""),n=o.reactive({filteredPage:o.computed(()=>{const s=t.value*(e.value-1),a=Math.min(t.value*e.value,i.data.length);return i.data.slice(s,a)}),props:i,fields:{currentPage:e,itemsPerPage:t,searchQuery:l},handlePageChange(s){e.value=s},handlePageReset(){e.value=1}});return o.watch(()=>i.data,(s,a)=>{var c,f;((s==null?void 0:s.length)!==(a==null?void 0:a.length)||s[0]&&a[0]&&((c=s[0])==null?void 0:c.id)!==((f=a[0])==null?void 0:f.id))&&n.handlePageReset()},{immediate:!0}),n}function W(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var P,k;function z(){return k||(k=1,P=function i(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var l,n,s;if(Array.isArray(e)){if(l=e.length,l!=t.length)return!1;for(n=l;n--!==0;)if(!i(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(s=Object.keys(e),l=s.length,l!==Object.keys(t).length)return!1;for(n=l;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[n]))return!1;for(n=l;n--!==0;){var a=s[n];if(!i(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}),P}var J=z();const X=W(J);function G(i){let e=i,t;const l=o.reactive({fields:structuredClone(i),errors:{},dirty:!1,hasErrors:!1,processing:!1,wasSuccessful:!1,recentlySuccessful:!1,async submit(n,s={}){if(this.processing)return;const a={onBefore:async()=>{this.processing=!0,this.wasSuccessful=!1,this.recentlySuccessful=!1,clearTimeout(t),s.onBefore&&await s.onBefore()},onSuccess:async c=>{this.clearErrors(),this.wasSuccessful=!0,this.recentlySuccessful=!0,t=window.setTimeout(()=>{this.recentlySuccessful=!1},2e3),s.onSuccess&&await s.onSuccess(c),e=structuredClone(this.fields)},onError:async c=>{var f,d,v,m,h;this.hasErrors=!0,(((f=c==null?void 0:c.response)==null?void 0:f.status)===422||((d=c==null?void 0:c.response)==null?void 0:d.status)===401)&&(this.clearErrors(),this.setErrors({message:(v=c==null?void 0:c.response)==null?void 0:v.data.message,...(h=(m=c==null?void 0:c.response)==null?void 0:m.data)==null?void 0:h.errors})),s.onError&&await s.onError(c)},onFinish:async()=>{this.processing=!1,s.onFinish&&await s.onFinish()}};await a.onBefore();try{const c=await n(this.fields);await a.onSuccess(c)}catch(c){await a.onError(c)}finally{await a.onFinish()}},reset(...n){const s=structuredClone(e);n.length===0?this.fields=s:n.forEach(a=>{s[a]!==void 0&&(this.fields[a]=s[a])})},clearErrors(...n){n.length===0?this.errors={}:n.forEach(s=>delete this.errors[s]),this.hasErrors=Object.keys(this.errors).length>0},setErrors(n){this.errors={...this.errors,...n},this.hasErrors=Object.keys(this.errors).length>0}});return o.watch(()=>l.fields,()=>{l.dirty=!X(l.fields,e)},{immediate:!0,deep:!0}),l}function Q({directions:i,threshold:e,onSwipeOut:t}){const l=o.ref(!1),n=o.ref({x:0,y:0}),s=o.ref(),a=o.ref({x:0,y:0}),c=m=>1/(1.5+Math.abs(m)/20);function f(m){s.value=Date.now(),m.target.setPointerCapture(m.pointerId),!m.target.closest("button, a, input, textarea, select")&&(a.value={x:m.clientX,y:m.clientY},l.value=!0)}function d(m){if(!l.value)return;const h={x:0,y:0},I=m.clientX-a.value.x,w=m.clientY-a.value.y;if(i.value.includes("left")&&I<0||i.value.includes("right")&&I>0)h.x=I;else{const S=I*c(I);h.x=Math.abs(S)<Math.abs(I)?S:I}if(i.value.includes("top")&&w<0||i.value.includes("bottom")&&w>0)h.y=w;else{const S=w*c(w);h.y=Math.abs(S)<Math.abs(w)?S:w}n.value=h}function v(){if(!l.value)return;const m=Date.now()-(s.value??0),h=n.value.x,I=Math.abs(h)/m;if(Math.abs(h)>=e||I>.11){t();return}l.value=!1,n.value={x:0,y:0}}return{offset:n,isSwiping:l,onPointerDown:f,onPointerMove:d,onPointerUp:v}}function Z({duration:i,isPaused:e,onTimeout:t,immediate:l=!0}){const n=o.ref(),s=o.ref(0),a=o.ref(i);function c(){a.value===1/0||e()||(s.value=Date.now(),n.value=window.setTimeout(()=>{t()},a.value))}function f(){d();const v=Date.now()-s.value;a.value-=v}function d(){n.value&&(clearTimeout(n.value),n.value=null)}return o.watch(e,v=>{if(v){f();return}c()},{immediate:l}),o.onBeforeUnmount(()=>{d()}),{cancel:d}}function ee(){const i=o.ref(!1),e=o.ref(!1),t=o.ref(300),l=o.ref(null),n=o.reactive({}),s=o.shallowRef(null);function a(f,d={}){l.value&&clearTimeout(l.value),s.value=f,Object.assign(n,d),e.value=!0,i.value=!0,l.value=window.setTimeout(()=>{i.value=!1},t.value)}function c(){l.value&&clearTimeout(l.value),e.value=!1,i.value=!0,l.value=window.setTimeout(()=>{i.value=!1},t.value)}return{isOpen:e,isAnimating:i,animationTime:t,props:n,component:s,open:a,close:c}}function te(i,e){if(!i)return!1;let t=["INPUT","TEXTAREA","SELECT"];return(e===" "||e==="Enter")&&(t=[...t,"BUTTON"]),t.includes(i.tagName)}const se=3,ne="24px",ie="16px",ae=0,le=3e3,ce=16,oe=45,re=10,ue=.06,fe=16,_={stringInsensitive:(i,e)=>Y(i).localeCompare(Y(e)),date:(i,e)=>new Date(i).getTime()-new Date(e).getTime(),number:(i,e)=>parseFloat(i)-parseFloat(e)};function Y(i){return String(i??"").toLowerCase().replace(/\s+/g," ").trim()}function de(i,e=1,t=["date","date_released"]){return(l,n)=>{const s=l[i],a=n[i];if(s instanceof Date&&a instanceof Date||t.includes(String(i))){const d=new Date(String(s));return(new Date(String(a)).getTime()-d.getTime())*e}const c=parseFloat(s),f=parseFloat(a);return!isNaN(c)&&!isNaN(f)?(c-f)*e:String(s).toLowerCase().replace(/\s+/g," ").localeCompare(String(a).toLowerCase().replace(/\s+/g," "))*e}}function me(i,e=1){return(t,l)=>{for(const{key:n,compareFn:s}of i){const a=n?t[n]??"":void 0,c=n?l[n]??"":void 0;let f;if(s?f=n?s(a,c):s(t,l):f=he(a,c),f!==0)return f*e}return 0}}function he(i,e){const t=parseFloat(i),l=parseFloat(e);if(!isNaN(t)&&!isNaN(l))return t-l;const n=new Date(i),s=new Date(e);return!isNaN(n.getTime())&&!isNaN(s.getTime())?n.getTime()-s.getTime():_.stringInsensitive(i,e)}r.CompareStrategies=_,r.DEFAULT_GAP=ce,r.MOBILE_VIEWPORT_OFFSET=ie,r.SCALE_STEP=ue,r.SWIPE_THRESHOLD=oe,r.TOAST_LIFE=le,r.TOAST_WIDTH=ae,r.ToastState=y,r.VIEWPORT_OFFSET=ne,r.VISIBLE_TOASTS_AMOUNT=se,r.Y_OFFSET_STEP=fe,r.Z_STEP=re,r.createModalCore=ee,r.isInputLikeElement=te,r.sortObject=de,r.sortObjectNew=me,r.toast=L,r.useClipboard=H,r.useDatePicker=K,r.useForm=G,r.useModal=x,r.useMultiSelect=E,r.useSelect=U,r.useSwipeHandler=Q,r.useTable=q,r.useToastTimer=Z,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(r,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r.CedarUI={},r.Vue))})(this,function(r,o){"use strict";var Fe=Object.defineProperty;var Ce=(r,o,E)=>o in r?Fe(r,o,{enumerable:!0,configurable:!0,writable:!0,value:E}):r[o]=E;var b=(r,o,E)=>Ce(r,typeof o!="symbol"?o+"":o,E);function E({options:i,defaultItems:e},t){const c=o.reactive({selectOpen:!1,selectedItems:e,selectableItems:i,selectableItemActive:null,selectId:"select-12",selectKeydownValue:"",selectKeydownTimeout:1e3,selectKeydownClearTimeout:null,selectDropdownPosition:"bottom",selectableItemsList:t.selectableItemsList,selectButton:t.selectButton,toggleSelect(s){s!==void 0?this.selectOpen=s===!0:this.selectOpen=!this.selectOpen},updateRefs(s){this.selectButton=s.selectButton,this.selectableItemsList=s.selectableItemsList,this.selectPositionUpdate()},selectableItemIsActive(){return!1},async selectScrollToActiveItem(s,a=!0){let l=document.getElementById(s+"-"+this.selectId);l&&(l.scrollIntoView({behavior:"smooth",block:"center"}),a&&l.focus({preventScroll:!1}))},selectKeydown(s){if(s.keyCode<65||s.keyCode>90)return;this.selectKeydownValue+=s.key;let a=this.selectItemsFindBestMatch();a&&this.selectOpen&&(this.selectableItemActive=a),this.selectKeydownValue!==""&&(clearTimeout(this.selectKeydownClearTimeout),this.selectKeydownClearTimeout=window.setTimeout(()=>{this.selectKeydownValue=""},this.selectKeydownTimeout))},selectItemsFindBestMatch(){let s=this.selectKeydownValue.toLowerCase(),a=null,l=-1;for(const f of this.selectableItems){let v=f.name.toLowerCase().indexOf(s);v>-1&&(l==-1||v<l)&&!f.disabled&&(a=f,l=v)}return a},selectPositionUpdate(){var a;if(!this.selectButton||!this.selectableItemsList)return;let s=((a=this.selectButton)==null?void 0:a.getBoundingClientRect().top)+this.selectButton.offsetHeight+parseInt(window.getComputedStyle(this.selectableItemsList).maxHeight);this.selectDropdownPosition=window.innerHeight<s?"top":"bottom"},setOptions(s){Array.isArray(s)&&(this.selectableItems=s)}}),n=()=>{c.selectOpen&&c.selectPositionUpdate()};return o.watch(()=>c.selectOpen,function(s){if(c.selectedItems?c.selectableItemActive=c.selectedItem:c.selectableItemActive=c.selectableItems[0],!s){window.removeEventListener("resize",n);return}n(),window.addEventListener("resize",n)},{immediate:!1}),c}function q(i,e,t){var x;const c=o.ref(!1),n=o.ref(((x=i.model)==null?void 0:x.value)??i.defaultDate??""),s=o.ref("F d, Y"),a=o.ref(0),l=o.ref(0),f=o.ref(0),d=o.ref([]),v=o.ref([]),m=o.ref("bottom"),h=["January","February","March","April","May","June","July","August","September","October","November","December"],I=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],w=o.ref("D"),S=o.computed(()=>{let u=Math.max(a.value,0);return u>=h.length&&(u=0),h[u]}),Se=o.computed(()=>{const u=Math.floor(l.value/10)*10;return Array.from({length:10},(T,g)=>u+g)});function De(u){c.value=u??!c.value,w.value="D"}function Ee(u="D"){w.value=u}function C(u){const T=I[u.getDay()],g=("0"+u.getDate()).slice(-2),D=h[u.getMonth()],k=D.substring(0,3),_=("0"+(u.getMonth()+1)).slice(-2),p=u.getFullYear();switch(s.value){case"F d, Y":return`${D} ${g}, ${p}`;case"d M, Y":return`${g} ${k}, ${p}`;case"Y M d":return`${p} ${k} ${g}`;case"MM-DD-YYYY":return`${_}-${g}-${p}`;case"DD-MM-YYYY":return`${g}-${_}-${p}`;case"YYYY-MM-DD":return`${p}-${_}-${g}`;case"D d M, Y":return`${T} ${g} ${k} ${p}`;default:return`${D} ${g}, ${p}`}}function Oe(u){switch(w.value){case"Y":l.value=u,w.value="M";break;case"M":a.value=u,w.value="D",A();break;default:f.value=u,n.value=C(new Date(l.value,a.value,u)),c.value=!1,i.model&&(i.model.value=n.value);break}}function Pe(){switch(w.value){case"Y":l.value-=10;break;case"M":l.value-=1;break;default:a.value===0?(l.value--,a.value=11):a.value--,A();break}}function Ae(){switch(w.value){case"Y":l.value+=10;break;case"M":l.value+=1;break;default:a.value===11?(a.value=0,l.value++):a.value++,A();break}}function Me(u){const T=new Date(l.value,a.value,u);return n.value===C(T)}function Be(u){const T=new Date,g=new Date(l.value,a.value,u);return T.toDateString()===g.toDateString()}function A(){const u=new Date(l.value,a.value+1,0).getDate(),T=new Date(l.value,a.value).getDay();v.value=Array.from({length:T},(g,D)=>D+1),d.value=Array.from({length:u},(g,D)=>D+1)}function L(){if(!e.value||!t.value||!c.value)return;const u=e.value.getBoundingClientRect(),T=t.value.offsetHeight,g=u.top+u.height+T;m.value=g>window.innerHeight?"top":"bottom"}function H(u,T=!0){a.value=u.getMonth(),l.value=u.getFullYear(),f.value=u.getDate(),T&&(n.value=C(u)),A()}function U(){if(n.value)return H(new Date(Date.parse(n.value)));H(new Date,i.useDefaultDate)}return o.onMounted(()=>{U()}),o.watch(c,async u=>{if(!u){window.removeEventListener("resize",L);return}await o.nextTick(),U(),L(),window.addEventListener("resize",L)}),{datePickerInput:e,datePickerCalendar:t,datePickerOpen:c,datePickerValue:n,datePickerPanel:w,datePickerFormat:s,datePickerMonth:a,datePickerMonthVerbose:S,datePickerYear:l,datePickerDecade:Se,datePickerDay:f,datePickerDaysInMonth:d,datePickerBlankDaysInMonth:v,datePickerMonthNames:h,datePickerDays:I,datePickerPosition:m,toggleDatePicker:De,datePickerValueClicked:Oe,datePickerPrevious:Pe,datePickerNext:Ae,datePickerIsSelectedDate:Me,datePickerIsToday:Be,showDatePickerPanel:Ee}}function Y(i="pv_id_"){return i+Math.random().toString(16).slice(2)}class W{constructor(){b(this,"subscribers");b(this,"toasts");b(this,"subscribe",e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}));b(this,"publish",e=>{this.subscribers.forEach(t=>t(e))});b(this,"addToast",e=>{this.publish(e),this.toasts=[...this.toasts,e]});b(this,"create",(e,t)=>{const c=t.id??Y("toast_");return this.toasts.find(s=>s.id===c)?this.toasts=this.toasts.map(s=>s.id===c?(this.publish({...s,...t,id:c,title:e}),{...s,...t,id:c,title:e}):s):this.addToast({title:e,id:c,scale:1,zIndex:200,offsetY:0,...t}),c});b(this,"dismiss",e=>{e?(this.publish({id:e,dismiss:!0}),this.toasts=this.toasts.filter(t=>t.id!==e)):(this.toasts.forEach(t=>{this.publish({id:t.id,dismiss:!0})}),this.toasts=[])});b(this,"add",(e,t)=>this.create(e,{...t}));b(this,"success",(e,t)=>this.create(e,{type:"success",...t}));b(this,"error",(e,t)=>this.create(e,{type:"danger",...t}));b(this,"info",(e,t)=>this.create(e,{type:"info",...t}));b(this,"warning",(e,t)=>this.create(e,{type:"warning",...t}));this.subscribers=[],this.toasts=[]}}const y=new W;function z(i,e){const t=Y("toast_");return y.create(i,{...e,id:t}),t}const N=Object.assign(z,{add:y.add,success:y.success,error:y.error,info:y.info,warning:y.warning,dismiss:y.dismiss});function J(i){const e=o.ref(!1);return{copyNotification:e,copyToClipboard:async()=>{try{await navigator.clipboard.writeText(i.value),e.value=!0,setTimeout(()=>{e.value=!1},3e3)}catch(c){console.error(c),N.error("Error",{description:"Unable to copy. Network is not secure."})}}}}function X(i,e){const t=o.reactive({selectOpen:!1,selectedItem:"",selectableItems:i,selectableItemActive:null,selectId:"select-12",selectKeydownValue:"",selectKeydownTimeout:1e3,selectKeydownClearTimeout:null,selectDropdownPosition:"bottom",selectableItemsList:e.selectableItemsList,selectButton:e.selectButton,toggleSelect(n){n!==void 0?this.selectOpen=n===!0:this.selectOpen=!this.selectOpen},updateRefs(n){this.selectButton=n.selectButton,this.selectableItemsList=n.selectableItemsList},selectableItemIsActive(n){return this.selectableItemActive&&this.selectableItemActive.value==n.value},selectableItemActiveNext(){let n=this.selectableItems.indexOf(this.selectableItemActive);n<this.selectableItems.length-1&&(this.selectableItemActive=this.selectableItems[n+1],this.selectScrollToActiveItem())},selectableItemActivePrevious(){let n=this.selectableItems.indexOf(this.selectableItemActive);n>0&&(this.selectableItemActive=this.selectableItems[n-1],this.selectScrollToActiveItem())},selectScrollToActiveItem(){if(!this.selectableItemActive)return;let n=document.getElementById(this.selectableItemActive.value+"-"+this.selectId);n&&n.focus()},selectKeydown(n){if(n.keyCode>=65&&n.keyCode<=90){this.selectKeydownValue+=n.key;let s=this.selectItemsFindBestMatch();s&&(this.selectOpen?(this.selectableItemActive=s,this.selectScrollToActiveItem()):this.selectedItem=this.selectableItemActive===s),this.selectKeydownValue!=""&&(clearTimeout(this.selectKeydownClearTimeout),this.selectKeydownClearTimeout=window.setTimeout(()=>{this.selectKeydownValue=""},this.selectKeydownTimeout))}},selectItemsFindBestMatch(){let n=this.selectKeydownValue.toLowerCase(),s=null,a=-1;for(const l of this.selectableItems){let d=l.title.toLowerCase().indexOf(n);d>-1&&(a==-1||d<a)&&!l.disabled&&(s=l,a=d)}return s},selectPositionUpdate(){var s;if(!this.selectableItemsList||!this.selectButton)return;let n=((s=this.selectButton)==null?void 0:s.getBoundingClientRect().top)+this.selectButton.offsetHeight+parseInt(window.getComputedStyle(this.selectableItemsList).maxHeight);window.innerHeight<n?this.selectDropdownPosition="top":this.selectDropdownPosition="bottom"}}),c=()=>{t.selectOpen&&t.selectPositionUpdate()};return o.watch(()=>t.selectOpen,function(n){if(t.selectedItem?t.selectableItemActive=t.selectedItem:t.selectableItemActive=t.selectableItems[0],!n){window.removeEventListener("resize",c);return}window.setTimeout(function(){t.selectScrollToActiveItem()},10),c(),window.addEventListener("resize",c)},{immediate:!1}),t}function G(i){const e=o.ref(null);return o.reactive({title:"",...i,modalOpen:!1,isAnimating:!1,animationTime:i.animationTime??300,toggleModal(t=null){this.isAnimating||(e.value&&clearTimeout(e.value),t!=null?this.modalOpen=t:this.modalOpen=!this.modalOpen,this.isAnimating=!0,e.value=window.setTimeout(()=>{this.isAnimating=!1},this.animationTime))},setTitle(t){this.title=t}})}function Q(i){const e=o.ref(1),t=o.ref(i.itemsPerPage??10),c=o.ref(i.searchQuery??""),n=o.reactive({filteredPage:o.computed(()=>{const s=t.value*(e.value-1),a=Math.min(t.value*e.value,i.data.length);return i.data.slice(s,a)}),props:i,fields:{currentPage:e,itemsPerPage:t,searchQuery:c},handlePageChange(s){e.value=s},handlePageReset(){e.value=1}});return o.watch(()=>i.data,(s,a)=>{var l,f;((s==null?void 0:s.length)!==(a==null?void 0:a.length)||s[0]&&a[0]&&((l=s[0])==null?void 0:l.id)!==((f=a[0])==null?void 0:f.id))&&n.handlePageReset()},{immediate:!0}),n}function Z(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var M,$;function ee(){return $||($=1,M=function i(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var c,n,s;if(Array.isArray(e)){if(c=e.length,c!=t.length)return!1;for(n=c;n--!==0;)if(!i(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(s=Object.keys(e),c=s.length,c!==Object.keys(t).length)return!1;for(n=c;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[n]))return!1;for(n=c;n--!==0;){var a=s[n];if(!i(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}),M}var te=ee();const se=Z(te);function ne(i){let e=i,t;const c=o.reactive({fields:structuredClone(i),errors:{},dirty:!1,hasErrors:!1,processing:!1,wasSuccessful:!1,recentlySuccessful:!1,async submit(n,s={}){if(this.processing)return;const a={onBefore:async()=>{this.processing=!0,this.wasSuccessful=!1,this.recentlySuccessful=!1,clearTimeout(t),s.onBefore&&await s.onBefore()},onSuccess:async l=>{this.clearErrors(),this.wasSuccessful=!0,this.recentlySuccessful=!0,t=window.setTimeout(()=>{this.recentlySuccessful=!1},2e3),s.onSuccess&&await s.onSuccess(l),e=structuredClone(this.fields)},onError:async l=>{var f,d,v,m,h;this.hasErrors=!0,(((f=l==null?void 0:l.response)==null?void 0:f.status)===422||((d=l==null?void 0:l.response)==null?void 0:d.status)===401)&&(this.clearErrors(),this.setErrors({message:(v=l==null?void 0:l.response)==null?void 0:v.data.message,...(h=(m=l==null?void 0:l.response)==null?void 0:m.data)==null?void 0:h.errors})),s.onError&&await s.onError(l)},onFinish:async()=>{this.processing=!1,s.onFinish&&await s.onFinish()}};await a.onBefore();try{const l=await n(this.fields);await a.onSuccess(l)}catch(l){await a.onError(l)}finally{await a.onFinish()}},reset(...n){const s=structuredClone(e);n.length===0?this.fields=s:n.forEach(a=>{s[a]!==void 0&&(this.fields[a]=s[a])})},clearErrors(...n){n.length===0?this.errors={}:n.forEach(s=>delete this.errors[s]),this.hasErrors=Object.keys(this.errors).length>0},setErrors(n){this.errors={...this.errors,...n},this.hasErrors=Object.keys(this.errors).length>0}});return o.watch(()=>c.fields,()=>{c.dirty=!se(c.fields,e)},{immediate:!0,deep:!0}),c}function ie({directions:i,threshold:e,onSwipeOut:t}){const c=o.ref(!1),n=o.ref({x:0,y:0}),s=o.ref(),a=o.ref({x:0,y:0}),l=m=>1/(1.5+Math.abs(m)/20);function f(m){s.value=Date.now(),m.target.setPointerCapture(m.pointerId),!m.target.closest("button, a, input, textarea, select")&&(a.value={x:m.clientX,y:m.clientY},c.value=!0)}function d(m){if(!c.value)return;const h={x:0,y:0},I=m.clientX-a.value.x,w=m.clientY-a.value.y;if(i.value.includes("left")&&I<0||i.value.includes("right")&&I>0)h.x=I;else{const S=I*l(I);h.x=Math.abs(S)<Math.abs(I)?S:I}if(i.value.includes("top")&&w<0||i.value.includes("bottom")&&w>0)h.y=w;else{const S=w*l(w);h.y=Math.abs(S)<Math.abs(w)?S:w}n.value=h}function v(){if(!c.value)return;const m=Date.now()-(s.value??0),h=n.value.x,I=Math.abs(h)/m;if(Math.abs(h)>=e||I>.11){t();return}c.value=!1,n.value={x:0,y:0}}return{offset:n,isSwiping:c,onPointerDown:f,onPointerMove:d,onPointerUp:v}}function ae({duration:i,isPaused:e,onTimeout:t,immediate:c=!0}){const n=o.ref(),s=o.ref(0),a=o.ref(i);function l(){a.value===1/0||e()||(s.value=Date.now(),n.value=window.setTimeout(()=>{t()},a.value))}function f(){d();const v=Date.now()-s.value;a.value-=v}function d(){n.value&&(clearTimeout(n.value),n.value=null)}return o.watch(e,v=>{if(v){f();return}l()},{immediate:c}),o.onBeforeUnmount(()=>{d()}),{cancel:d}}const P=o.ref(!1),B=o.ref(!1),F=o.ref(300),O=o.ref(null),V=o.reactive({}),K=o.shallowRef(null);function le(i,e={}){O.value&&clearTimeout(O.value),K.value=i,Object.assign(V,e),B.value=!0,P.value=!0,O.value=window.setTimeout(()=>{P.value=!1},F.value)}function ce(){O.value&&clearTimeout(O.value),B.value=!1,P.value=!0,O.value=window.setTimeout(()=>{P.value=!1},F.value)}function oe(){return{isOpen:B,isAnimating:P,animationTime:F,props:V,component:K,open:le,close:ce}}function re(i,e){if(!i)return!1;let t=["INPUT","TEXTAREA","SELECT"];return(e===" "||e==="Enter")&&(t=[...t,"BUTTON"]),t.includes(i.tagName)}const ue=3,fe="24px",de="16px",me=0,he=3e3,ve=16,we=45,ge=10,be=.06,Ie=16,j={stringInsensitive:(i,e)=>R(i).localeCompare(R(e)),date:(i,e)=>new Date(i).getTime()-new Date(e).getTime(),number:(i,e)=>parseFloat(i)-parseFloat(e)};function R(i){return String(i??"").toLowerCase().replace(/\s+/g," ").trim()}function Te(i,e=1,t=["date","date_released"]){return(c,n)=>{const s=c[i],a=n[i];if(s instanceof Date&&a instanceof Date||t.includes(String(i))){const d=new Date(String(s));return(new Date(String(a)).getTime()-d.getTime())*e}const l=parseFloat(s),f=parseFloat(a);return!isNaN(l)&&!isNaN(f)?(l-f)*e:String(s).toLowerCase().replace(/\s+/g," ").localeCompare(String(a).toLowerCase().replace(/\s+/g," "))*e}}function ye(i,e=1){return(t,c)=>{for(const{key:n,compareFn:s}of i){const a=n?t[n]??"":void 0,l=n?c[n]??"":void 0;let f;if(s?f=n?s(a,l):s(t,c):f=pe(a,l),f!==0)return f*e}return 0}}function pe(i,e){const t=parseFloat(i),c=parseFloat(e);if(!isNaN(t)&&!isNaN(c))return t-c;const n=new Date(i),s=new Date(e);return!isNaN(n.getTime())&&!isNaN(s.getTime())?n.getTime()-s.getTime():j.stringInsensitive(i,e)}r.CompareStrategies=j,r.DEFAULT_GAP=ve,r.MOBILE_VIEWPORT_OFFSET=de,r.SCALE_STEP=be,r.SWIPE_THRESHOLD=we,r.TOAST_LIFE=he,r.TOAST_WIDTH=me,r.ToastState=y,r.VIEWPORT_OFFSET=fe,r.VISIBLE_TOASTS_AMOUNT=ue,r.Y_OFFSET_STEP=Ie,r.Z_STEP=ge,r.isInputLikeElement=re,r.sortObject=Te,r.sortObjectNew=ye,r.toast=N,r.useClipboard=J,r.useDatePicker=q,r.useForm=ne,r.useModal=G,r.useModalCore=oe,r.useMultiSelect=E,r.useSelect=X,r.useSwipeHandler=ie,r.useTable=Q,r.useToastTimer=ae,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare interface BreadCrumbItem {
|
|
|
23
23
|
icon?: Component;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
declare function close_2(): void;
|
|
27
|
+
|
|
26
28
|
export declare const CompareStrategies: {
|
|
27
29
|
stringInsensitive: (a: any, b: any) => number;
|
|
28
30
|
date: (a: any, b: any) => number;
|
|
@@ -51,26 +53,6 @@ export declare interface ContextMenuItem {
|
|
|
51
53
|
icon?: Component;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
export declare function createModalCore(): {
|
|
55
|
-
isOpen: Ref<boolean, boolean>;
|
|
56
|
-
isAnimating: Ref<boolean, boolean>;
|
|
57
|
-
animationTime: Ref<number, number>;
|
|
58
|
-
props: Record<string, any>;
|
|
59
|
-
component: ShallowRef<null, null> | ShallowRef<ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions>, ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions>> | ShallowRef<FunctionalComponent<any, {}, any, {}>, FunctionalComponent<any, {}, any, {}>> | ShallowRef<{
|
|
60
|
-
new (...args: any[]): any;
|
|
61
|
-
__isFragment?: never;
|
|
62
|
-
__isTeleport?: never;
|
|
63
|
-
__isSuspense?: never;
|
|
64
|
-
}, {
|
|
65
|
-
new (...args: any[]): any;
|
|
66
|
-
__isFragment?: never;
|
|
67
|
-
__isTeleport?: never;
|
|
68
|
-
__isSuspense?: never;
|
|
69
|
-
}>;
|
|
70
|
-
open: (comp: Component, newProps?: Record<string, any>) => void;
|
|
71
|
-
close: () => void;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
56
|
declare interface DatePickerProps {
|
|
75
57
|
model?: ModelRef<string | undefined>;
|
|
76
58
|
defaultDate?: string;
|
|
@@ -190,6 +172,8 @@ declare class Observer {
|
|
|
190
172
|
warning: (message: string, options?: ToastOptions) => string;
|
|
191
173
|
}
|
|
192
174
|
|
|
175
|
+
declare function open_2(comp: Component, newProps?: Record<string, any>): void;
|
|
176
|
+
|
|
193
177
|
export declare interface PopoverItem {
|
|
194
178
|
text?: string;
|
|
195
179
|
title?: string;
|
|
@@ -390,6 +374,26 @@ export declare function useModal(props: ModalProps): {
|
|
|
390
374
|
submitText?: string | undefined;
|
|
391
375
|
};
|
|
392
376
|
|
|
377
|
+
export declare function useModalCore(): {
|
|
378
|
+
isOpen: Ref<boolean, boolean>;
|
|
379
|
+
isAnimating: Ref<boolean, boolean>;
|
|
380
|
+
animationTime: Ref<number, number>;
|
|
381
|
+
props: Record<string, any>;
|
|
382
|
+
component: ShallowRef<null, null> | ShallowRef<ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions>, ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions>> | ShallowRef<FunctionalComponent<any, {}, any, {}>, FunctionalComponent<any, {}, any, {}>> | ShallowRef<{
|
|
383
|
+
new (...args: any[]): any;
|
|
384
|
+
__isFragment?: never;
|
|
385
|
+
__isTeleport?: never;
|
|
386
|
+
__isSuspense?: never;
|
|
387
|
+
}, {
|
|
388
|
+
new (...args: any[]): any;
|
|
389
|
+
__isFragment?: never;
|
|
390
|
+
__isTeleport?: never;
|
|
391
|
+
__isSuspense?: never;
|
|
392
|
+
}>;
|
|
393
|
+
open: typeof open_2;
|
|
394
|
+
close: typeof close_2;
|
|
395
|
+
};
|
|
396
|
+
|
|
393
397
|
export declare function useMultiSelect({ options, defaultItems }: {
|
|
394
398
|
options: any;
|
|
395
399
|
defaultItems: any;
|