@3df-spa/ui 1.0.7 → 1.1.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.
- package/dist/UiPopoverTrigger.vue_vue_type_script_setup_true_lang-DKJgwMAw.js +258 -0
- package/dist/calendar.d.ts +88 -0
- package/dist/calendar.js +416 -0
- package/dist/carousel.d.ts +103 -0
- package/dist/carousel.js +206 -0
- package/dist/index.d.ts +43 -223
- package/dist/index.js +3568 -4426
- package/dist/utils-C9QoOYNG.js +6 -0
- package/package.json +20 -2
- /package/dist/{index.css → ui.css} +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { defineComponent as y, ref as h, watch as b, onBeforeUnmount as _, provide as L, openBlock as P, createElementBlock as x, renderSlot as O, nextTick as g, inject as C, useAttrs as B, computed as T, createBlock as S, Teleport as A, mergeProps as F, unref as m, createCommentVNode as U, watchEffect as z, withKeys as $, withModifiers as k } from "vue";
|
|
2
|
+
import { c as H } from "./utils-C9QoOYNG.js";
|
|
3
|
+
const E = /* @__PURE__ */ Symbol("popover");
|
|
4
|
+
let I = 0;
|
|
5
|
+
const Z = /* @__PURE__ */ y({
|
|
6
|
+
name: "UiPopover",
|
|
7
|
+
__name: "UiPopover",
|
|
8
|
+
props: {
|
|
9
|
+
open: { type: Boolean, default: void 0 },
|
|
10
|
+
defaultOpen: { type: Boolean, default: !1 }
|
|
11
|
+
},
|
|
12
|
+
emits: ["update:open"],
|
|
13
|
+
setup(e, { emit: t }) {
|
|
14
|
+
const o = e, s = t, i = h(o.defaultOpen);
|
|
15
|
+
b(
|
|
16
|
+
() => o.open,
|
|
17
|
+
(u) => {
|
|
18
|
+
u !== void 0 && (i.value = u);
|
|
19
|
+
}
|
|
20
|
+
), b(i, (u) => {
|
|
21
|
+
s("update:open", u);
|
|
22
|
+
});
|
|
23
|
+
const n = h(), l = h(), r = `popover-trigger-${++I}`;
|
|
24
|
+
function c() {
|
|
25
|
+
i.value = !0;
|
|
26
|
+
}
|
|
27
|
+
function a() {
|
|
28
|
+
i.value = !1, (n.value?.querySelector(
|
|
29
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
30
|
+
) ?? n.value)?.focus();
|
|
31
|
+
}
|
|
32
|
+
function p() {
|
|
33
|
+
i.value ? a() : c();
|
|
34
|
+
}
|
|
35
|
+
function v(u) {
|
|
36
|
+
u.key === "Escape" && i.value && (u.preventDefault(), a());
|
|
37
|
+
}
|
|
38
|
+
function f(u) {
|
|
39
|
+
const d = u.target;
|
|
40
|
+
n.value && !n.value.contains(d) && l.value && !l.value.contains(d) && a();
|
|
41
|
+
}
|
|
42
|
+
return b(i, (u) => {
|
|
43
|
+
u ? document.addEventListener("click", f, !0) : document.removeEventListener("click", f, !0);
|
|
44
|
+
}), _(() => {
|
|
45
|
+
document.removeEventListener("click", f, !0);
|
|
46
|
+
}), L(E, {
|
|
47
|
+
isOpen: i,
|
|
48
|
+
triggerRef: n,
|
|
49
|
+
contentRef: l,
|
|
50
|
+
triggerId: r,
|
|
51
|
+
toggle: p,
|
|
52
|
+
open: c,
|
|
53
|
+
close: a
|
|
54
|
+
}), (u, d) => (P(), x("div", {
|
|
55
|
+
class: "inline-block",
|
|
56
|
+
onKeydown: v
|
|
57
|
+
}, [
|
|
58
|
+
O(u.$slots, "default")
|
|
59
|
+
], 32));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
function K(e) {
|
|
63
|
+
let t;
|
|
64
|
+
function o() {
|
|
65
|
+
t || (t = requestAnimationFrame(() => {
|
|
66
|
+
e.updatePosition(), t = void 0;
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
const s = e.onScrollClose ?? V(e);
|
|
70
|
+
b(
|
|
71
|
+
() => e.isOpen.value,
|
|
72
|
+
async (i) => {
|
|
73
|
+
i ? (await g(), e.updatePosition(), await g(), e.updatePosition(), s && window.addEventListener("scroll", s, !0), window.addEventListener("resize", o)) : (s && window.removeEventListener("scroll", s, !0), window.removeEventListener("resize", o));
|
|
74
|
+
}
|
|
75
|
+
), _(() => {
|
|
76
|
+
s && window.removeEventListener("scroll", s, !0), window.removeEventListener("resize", o), t && cancelAnimationFrame(t);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function V(e) {
|
|
80
|
+
if (!e.contentRef || !e.closeFn) return;
|
|
81
|
+
const t = e.contentRef, o = e.closeFn;
|
|
82
|
+
return (s) => {
|
|
83
|
+
const i = s.target;
|
|
84
|
+
t.value && i && t.value.contains(i) || o();
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function q(e, t, o) {
|
|
88
|
+
const s = h({});
|
|
89
|
+
function i() {
|
|
90
|
+
const n = e.value, l = t.value;
|
|
91
|
+
if (!n || !l) return;
|
|
92
|
+
const r = o(), c = n.getBoundingClientRect(), a = l.getBoundingClientRect(), p = window.innerWidth, v = window.innerHeight, f = r.viewportPadding, u = r.sideOffset, d = D(c, a, p, v, f, u, r);
|
|
93
|
+
s.value = {
|
|
94
|
+
position: "fixed",
|
|
95
|
+
top: `${d.top}px`,
|
|
96
|
+
left: `${d.left}px`
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return { positionStyle: s, updatePosition: i };
|
|
100
|
+
}
|
|
101
|
+
function D(e, t, o, s, i, n, l) {
|
|
102
|
+
const r = M(e, t, o, s, i, n, l.side), c = W(e, t, o, i, l.align);
|
|
103
|
+
let a, p;
|
|
104
|
+
return r === "top" || r === "bottom" ? (a = r === "top" ? e.top - t.height - n : e.bottom + n, p = j(e, t, c)) : (p = r === "left" ? e.left - t.width - n : e.right + n, a = N(e, t, l.align)), Y(a, p, t, o, s, i);
|
|
105
|
+
}
|
|
106
|
+
function M(e, t, o, s, i, n, l) {
|
|
107
|
+
if (l === "top") {
|
|
108
|
+
if (e.top - n < t.height + i && s - e.bottom - n > e.top - n)
|
|
109
|
+
return "bottom";
|
|
110
|
+
} else if (l === "bottom") {
|
|
111
|
+
const r = s - e.bottom - n;
|
|
112
|
+
if (r < t.height && e.top - n > r) return "top";
|
|
113
|
+
} else if (l === "left") {
|
|
114
|
+
if (e.left - n < t.width + i && o - e.right - n > e.left - n)
|
|
115
|
+
return "right";
|
|
116
|
+
} else if (l === "right" && o - e.right - n < t.width + i && e.left - n > o - e.right - n)
|
|
117
|
+
return "left";
|
|
118
|
+
return l;
|
|
119
|
+
}
|
|
120
|
+
function W(e, t, o, s, i) {
|
|
121
|
+
if (i === "start") {
|
|
122
|
+
if (e.left + t.width > o - s) return "end";
|
|
123
|
+
} else if (i === "end") {
|
|
124
|
+
if (e.right - t.width < s) return "start";
|
|
125
|
+
} else {
|
|
126
|
+
const n = e.left + e.width / 2, l = t.width / 2;
|
|
127
|
+
if (n - l < s) return "start";
|
|
128
|
+
if (n + l > o - s) return "end";
|
|
129
|
+
}
|
|
130
|
+
return i;
|
|
131
|
+
}
|
|
132
|
+
function j(e, t, o) {
|
|
133
|
+
return o === "start" ? e.left : o === "end" ? e.right - t.width : e.left + (e.width - t.width) / 2;
|
|
134
|
+
}
|
|
135
|
+
function N(e, t, o) {
|
|
136
|
+
return o === "start" ? e.top : o === "end" ? e.bottom - t.height : e.top + (e.height - t.height) / 2;
|
|
137
|
+
}
|
|
138
|
+
function Y(e, t, o, s, i, n) {
|
|
139
|
+
let l = t, r = e;
|
|
140
|
+
return l < n ? l = n : l + o.width > s - n && (l = s - n - o.width), r < n ? r = n : r + o.height > i - n && (r = i - n - o.height), { top: r, left: l };
|
|
141
|
+
}
|
|
142
|
+
function R(e, t, o) {
|
|
143
|
+
const s = h({});
|
|
144
|
+
function i() {
|
|
145
|
+
const n = e.value, l = t.value;
|
|
146
|
+
if (!n || !l) return;
|
|
147
|
+
const r = o(), c = n.getBoundingClientRect(), a = l.getBoundingClientRect(), p = window.innerWidth, v = window.innerHeight, f = r.viewportPadding, u = r.sideOffset;
|
|
148
|
+
let d = c.right + u;
|
|
149
|
+
d + a.width > p - f && (d = c.left - a.width - u), d < f && (d = f);
|
|
150
|
+
let w = c.top;
|
|
151
|
+
w + a.height > v - f && (w = v - f - a.height), w < f && (w = f), s.value = { position: "fixed", top: `${w}px`, left: `${d}px` };
|
|
152
|
+
}
|
|
153
|
+
return { positionStyle: s, updatePosition: i };
|
|
154
|
+
}
|
|
155
|
+
const G = ["aria-labelledby"], ee = /* @__PURE__ */ y({
|
|
156
|
+
name: "UiPopoverContent",
|
|
157
|
+
inheritAttrs: !1,
|
|
158
|
+
__name: "UiPopoverContent",
|
|
159
|
+
props: {
|
|
160
|
+
align: { default: "center" },
|
|
161
|
+
side: { default: "bottom" },
|
|
162
|
+
sideOffset: { default: 4 },
|
|
163
|
+
viewportPadding: { default: 8 }
|
|
164
|
+
},
|
|
165
|
+
setup(e) {
|
|
166
|
+
const t = e, o = C(E), s = B(), i = T(() => {
|
|
167
|
+
const { class: v, ...f } = s;
|
|
168
|
+
return f;
|
|
169
|
+
}), n = h(!1), l = h(!1);
|
|
170
|
+
let r;
|
|
171
|
+
b(
|
|
172
|
+
() => o.isOpen.value,
|
|
173
|
+
async (v) => {
|
|
174
|
+
clearTimeout(r), v ? (n.value = !0, await g(), l.value = !0) : (l.value = !1, r = setTimeout(() => {
|
|
175
|
+
n.value = !1;
|
|
176
|
+
}, 150));
|
|
177
|
+
},
|
|
178
|
+
{ immediate: !0 }
|
|
179
|
+
), _(() => {
|
|
180
|
+
clearTimeout(r);
|
|
181
|
+
});
|
|
182
|
+
const c = h(), { positionStyle: a, updatePosition: p } = q(
|
|
183
|
+
o.triggerRef,
|
|
184
|
+
c,
|
|
185
|
+
() => ({
|
|
186
|
+
side: t.side,
|
|
187
|
+
align: t.align,
|
|
188
|
+
sideOffset: t.sideOffset,
|
|
189
|
+
viewportPadding: t.viewportPadding
|
|
190
|
+
})
|
|
191
|
+
);
|
|
192
|
+
return K({
|
|
193
|
+
isOpen: n,
|
|
194
|
+
updatePosition: p,
|
|
195
|
+
contentRef: c,
|
|
196
|
+
closeFn: o.close
|
|
197
|
+
}), (v, f) => (P(), S(A, { to: "body" }, [
|
|
198
|
+
n.value ? (P(), x("div", F({
|
|
199
|
+
key: 0,
|
|
200
|
+
ref: (u) => {
|
|
201
|
+
const d = u;
|
|
202
|
+
m(o).contentRef.value = d, c.value = d;
|
|
203
|
+
}
|
|
204
|
+
}, i.value, {
|
|
205
|
+
role: "dialog",
|
|
206
|
+
"aria-labelledby": m(o).triggerId,
|
|
207
|
+
tabindex: "-1",
|
|
208
|
+
style: m(a),
|
|
209
|
+
class: m(H)(
|
|
210
|
+
"z-50 w-72 max-w-[calc(100vw-1rem)]",
|
|
211
|
+
"bg-popover text-popover-foreground",
|
|
212
|
+
"border-ui border-border rounded-md p-4 shadow-lg",
|
|
213
|
+
"transition-all duration-150",
|
|
214
|
+
l.value ? "opacity-100 scale-100 ease-out" : "opacity-0 scale-[0.97] ease-in",
|
|
215
|
+
m(s).class
|
|
216
|
+
)
|
|
217
|
+
}), [
|
|
218
|
+
O(v.$slots, "default")
|
|
219
|
+
], 16, G)) : U("", !0)
|
|
220
|
+
]));
|
|
221
|
+
}
|
|
222
|
+
}), J = ["id", "aria-expanded"], te = /* @__PURE__ */ y({
|
|
223
|
+
name: "UiPopoverTrigger",
|
|
224
|
+
__name: "UiPopoverTrigger",
|
|
225
|
+
setup(e) {
|
|
226
|
+
const t = C(E), o = h();
|
|
227
|
+
return z(() => {
|
|
228
|
+
o.value && (t.triggerRef.value = o.value);
|
|
229
|
+
}), (s, i) => (P(), x("div", {
|
|
230
|
+
ref_key: "el",
|
|
231
|
+
ref: o,
|
|
232
|
+
id: m(t).triggerId,
|
|
233
|
+
class: "inline-flex outline-none",
|
|
234
|
+
role: "button",
|
|
235
|
+
tabindex: "0",
|
|
236
|
+
"aria-expanded": m(t).isOpen.value,
|
|
237
|
+
"aria-haspopup": "dialog",
|
|
238
|
+
onClick: i[0] || (i[0] = (n) => m(t).toggle()),
|
|
239
|
+
onKeydown: [
|
|
240
|
+
i[1] || (i[1] = $(k((n) => m(t).toggle(), ["prevent"]), ["enter"])),
|
|
241
|
+
i[2] || (i[2] = $(k((n) => m(t).toggle(), ["prevent"]), ["space"]))
|
|
242
|
+
]
|
|
243
|
+
}, [
|
|
244
|
+
O(s.$slots, "default", {
|
|
245
|
+
open: m(t).isOpen.value
|
|
246
|
+
})
|
|
247
|
+
], 40, J));
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
export {
|
|
251
|
+
E as P,
|
|
252
|
+
Z as _,
|
|
253
|
+
te as a,
|
|
254
|
+
ee as b,
|
|
255
|
+
K as c,
|
|
256
|
+
R as d,
|
|
257
|
+
q as u
|
|
258
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
2
|
+
import { ComponentProvideOptions } from 'vue';
|
|
3
|
+
import { DefineComponent } from 'vue';
|
|
4
|
+
import { Locale } from 'date-fns/locale';
|
|
5
|
+
import { PublicProps } from 'vue';
|
|
6
|
+
|
|
7
|
+
export declare const Calendar: DefineComponent<UiCalendarProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
8
|
+
"update:modelValue": (value: Date | DateRange | undefined) => any;
|
|
9
|
+
}, string, PublicProps, Readonly<UiCalendarProps> & Readonly<{
|
|
10
|
+
"onUpdate:modelValue"?: ((value: Date | DateRange | undefined) => any) | undefined;
|
|
11
|
+
}>, {
|
|
12
|
+
disabled: (date: Date) => boolean;
|
|
13
|
+
modelValue: Date | DateRange;
|
|
14
|
+
mode: CalendarMode;
|
|
15
|
+
weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
16
|
+
locale: Locale;
|
|
17
|
+
defaultMonth: Date;
|
|
18
|
+
numberOfMonths: number;
|
|
19
|
+
showOutsideDays: boolean;
|
|
20
|
+
fixedWeeks: boolean;
|
|
21
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
|
|
23
|
+
export declare type CalendarMode = 'single' | 'range';
|
|
24
|
+
|
|
25
|
+
export declare const DatePicker: DefineComponent<UiDatePickerProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
26
|
+
"update:modelValue": (value: Date | undefined) => any;
|
|
27
|
+
}, string, PublicProps, Readonly<UiDatePickerProps> & Readonly<{
|
|
28
|
+
"onUpdate:modelValue"?: ((value: Date | undefined) => any) | undefined;
|
|
29
|
+
}>, {
|
|
30
|
+
disabled: (date: Date) => boolean;
|
|
31
|
+
modelValue: Date;
|
|
32
|
+
placeholder: string;
|
|
33
|
+
weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
34
|
+
locale: Locale;
|
|
35
|
+
formatStr: string;
|
|
36
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
37
|
+
|
|
38
|
+
export declare interface DateRange {
|
|
39
|
+
from: Date;
|
|
40
|
+
to?: Date;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export declare const DateRangePicker: DefineComponent<UiDateRangePickerProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
44
|
+
"update:modelValue": (value: DateRange | undefined) => any;
|
|
45
|
+
}, string, PublicProps, Readonly<UiDateRangePickerProps> & Readonly<{
|
|
46
|
+
"onUpdate:modelValue"?: ((value: DateRange | undefined) => any) | undefined;
|
|
47
|
+
}>, {
|
|
48
|
+
disabled: (date: Date) => boolean;
|
|
49
|
+
modelValue: DateRange;
|
|
50
|
+
placeholder: string;
|
|
51
|
+
weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
52
|
+
locale: Locale;
|
|
53
|
+
numberOfMonths: number;
|
|
54
|
+
formatStr: string;
|
|
55
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
56
|
+
|
|
57
|
+
declare interface UiCalendarProps {
|
|
58
|
+
mode?: CalendarMode;
|
|
59
|
+
modelValue?: Date | DateRange;
|
|
60
|
+
defaultMonth?: Date;
|
|
61
|
+
numberOfMonths?: number;
|
|
62
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
63
|
+
showOutsideDays?: boolean;
|
|
64
|
+
fixedWeeks?: boolean;
|
|
65
|
+
disabled?: (date: Date) => boolean;
|
|
66
|
+
locale?: Locale;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare interface UiDatePickerProps {
|
|
70
|
+
modelValue?: Date;
|
|
71
|
+
placeholder?: string;
|
|
72
|
+
formatStr?: string;
|
|
73
|
+
locale?: Locale;
|
|
74
|
+
disabled?: (date: Date) => boolean;
|
|
75
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare interface UiDateRangePickerProps {
|
|
79
|
+
modelValue?: DateRange;
|
|
80
|
+
placeholder?: string;
|
|
81
|
+
formatStr?: string;
|
|
82
|
+
locale?: Locale;
|
|
83
|
+
disabled?: (date: Date) => boolean;
|
|
84
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
85
|
+
numberOfMonths?: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { }
|