@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.
@@ -0,0 +1,206 @@
1
+ import { defineComponent as p, useAttrs as v, computed as u, ref as C, onMounted as R, nextTick as z, watch as B, onBeforeUnmount as D, provide as I, openBlock as m, createElementBlock as h, mergeProps as _, unref as o, renderSlot as S, inject as g, createElementVNode as c } from "vue";
2
+ import K from "embla-carousel";
3
+ import { c as w } from "./utils-C9QoOYNG.js";
4
+ const b = /* @__PURE__ */ Symbol("carousel"), Y = /* @__PURE__ */ p({
5
+ name: "UiCarousel",
6
+ inheritAttrs: !1,
7
+ __name: "UiCarousel",
8
+ props: {
9
+ opts: { default: void 0 },
10
+ orientation: { default: "horizontal" },
11
+ plugins: { default: void 0 }
12
+ },
13
+ emits: ["set-api"],
14
+ setup(d, { emit: s }) {
15
+ const t = d, l = s, n = v(), e = u(() => {
16
+ const { class: r, ...x } = n;
17
+ return x;
18
+ }), a = C(), i = C(), U = C(!1), N = C(!1), E = u(() => t.orientation);
19
+ function y() {
20
+ i.value?.scrollPrev();
21
+ }
22
+ function k() {
23
+ i.value?.scrollNext();
24
+ }
25
+ function A(r) {
26
+ U.value = r.canScrollPrev(), N.value = r.canScrollNext();
27
+ }
28
+ function P() {
29
+ i.value && (i.value.destroy(), i.value = void 0);
30
+ }
31
+ function $() {
32
+ const r = a.value;
33
+ if (!r) return;
34
+ P();
35
+ const x = {
36
+ ...t.opts,
37
+ axis: t.orientation === "vertical" ? "y" : "x"
38
+ }, f = K(r, x, t.plugins ?? []);
39
+ i.value = f, l("set-api", f), A(f), f.on("select", A), f.on("reInit", A);
40
+ }
41
+ R(() => {
42
+ z(() => {
43
+ a.value && $();
44
+ });
45
+ }), B(
46
+ () => [t.opts, t.orientation],
47
+ () => {
48
+ z(() => $());
49
+ },
50
+ { deep: !0 }
51
+ ), D(() => {
52
+ P();
53
+ });
54
+ function j(r) {
55
+ r.key === "ArrowLeft" && t.orientation === "horizontal" ? (r.preventDefault(), y()) : r.key === "ArrowRight" && t.orientation === "horizontal" ? (r.preventDefault(), k()) : r.key === "ArrowUp" && t.orientation === "vertical" ? (r.preventDefault(), y()) : r.key === "ArrowDown" && t.orientation === "vertical" && (r.preventDefault(), k());
56
+ }
57
+ return I(b, {
58
+ orientation: E,
59
+ viewportRef: a,
60
+ api: i,
61
+ canScrollPrev: U,
62
+ canScrollNext: N,
63
+ scrollPrev: y,
64
+ scrollNext: k
65
+ }), (r, x) => (m(), h("div", _(e.value, {
66
+ role: "region",
67
+ "aria-roledescription": "carousel",
68
+ tabindex: "0",
69
+ class: o(w)("relative", o(n).class),
70
+ onKeydown: j
71
+ }), [
72
+ S(r.$slots, "default")
73
+ ], 16));
74
+ }
75
+ }), q = /* @__PURE__ */ p({
76
+ name: "UiCarouselContent",
77
+ inheritAttrs: !1,
78
+ __name: "UiCarouselContent",
79
+ setup(d) {
80
+ const s = g(b), t = v(), l = u(() => {
81
+ const { class: e, ...a } = t;
82
+ return a;
83
+ });
84
+ function n(e) {
85
+ s.viewportRef.value = e;
86
+ }
87
+ return R(() => {
88
+ s.viewportRef.value;
89
+ }), (e, a) => (m(), h("div", {
90
+ ref: n,
91
+ class: "overflow-hidden"
92
+ }, [
93
+ c("div", _(l.value, {
94
+ class: o(w)("flex", o(s).orientation.value === "horizontal" ? "-ml-4" : "-mt-4 flex-col", o(t).class)
95
+ }), [
96
+ S(e.$slots, "default")
97
+ ], 16)
98
+ ]));
99
+ }
100
+ }), F = /* @__PURE__ */ p({
101
+ name: "UiCarouselItem",
102
+ inheritAttrs: !1,
103
+ __name: "UiCarouselItem",
104
+ setup(d) {
105
+ const s = g(b), t = v(), l = u(() => {
106
+ const { class: n, ...e } = t;
107
+ return e;
108
+ });
109
+ return (n, e) => (m(), h("div", _(l.value, {
110
+ role: "group",
111
+ "aria-roledescription": "slide",
112
+ class: o(w)(
113
+ "min-w-0 shrink-0 grow-0 basis-full",
114
+ o(s).orientation.value === "horizontal" ? "pl-4" : "pt-4",
115
+ o(t).class
116
+ )
117
+ }), [
118
+ S(n.$slots, "default")
119
+ ], 16));
120
+ }
121
+ }), L = ["disabled"], G = /* @__PURE__ */ p({
122
+ name: "UiCarouselPrevious",
123
+ inheritAttrs: !1,
124
+ __name: "UiCarouselPrevious",
125
+ setup(d) {
126
+ const s = g(b), t = v(), l = u(() => {
127
+ const { class: n, ...e } = t;
128
+ return e;
129
+ });
130
+ return (n, e) => (m(), h("button", _(l.value, {
131
+ type: "button",
132
+ disabled: !o(s).canScrollPrev.value,
133
+ "aria-label": "Slide anterior",
134
+ class: o(w)(
135
+ "border-ui border-border bg-card absolute z-10 flex h-8 w-8 items-center justify-center rounded-full shadow-md transition-colors",
136
+ "hover:bg-accent hover:text-accent-foreground",
137
+ "disabled:pointer-events-none disabled:opacity-50",
138
+ o(s).orientation.value === "horizontal" ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
139
+ o(t).class
140
+ ),
141
+ onClick: e[0] || (e[0] = (a) => o(s).scrollPrev())
142
+ }), [...e[1] || (e[1] = [
143
+ c("svg", {
144
+ xmlns: "http://www.w3.org/2000/svg",
145
+ width: "16",
146
+ height: "16",
147
+ viewBox: "0 0 24 24",
148
+ fill: "none",
149
+ stroke: "currentColor",
150
+ "stroke-width": "2",
151
+ "stroke-linecap": "round",
152
+ "stroke-linejoin": "round",
153
+ class: "h-4 w-4"
154
+ }, [
155
+ c("path", { d: "m15 18-6-6 6-6" })
156
+ ], -1),
157
+ c("span", { class: "sr-only" }, "Slide anterior", -1)
158
+ ])], 16, L));
159
+ }
160
+ }), O = ["disabled"], H = /* @__PURE__ */ p({
161
+ name: "UiCarouselNext",
162
+ inheritAttrs: !1,
163
+ __name: "UiCarouselNext",
164
+ setup(d) {
165
+ const s = g(b), t = v(), l = u(() => {
166
+ const { class: n, ...e } = t;
167
+ return e;
168
+ });
169
+ return (n, e) => (m(), h("button", _(l.value, {
170
+ type: "button",
171
+ disabled: !o(s).canScrollNext.value,
172
+ "aria-label": "Siguiente slide",
173
+ class: o(w)(
174
+ "border-ui border-border bg-card absolute z-10 flex h-8 w-8 items-center justify-center rounded-full shadow-md transition-colors",
175
+ "hover:bg-accent hover:text-accent-foreground",
176
+ "disabled:pointer-events-none disabled:opacity-50",
177
+ o(s).orientation.value === "horizontal" ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
178
+ o(t).class
179
+ ),
180
+ onClick: e[0] || (e[0] = (a) => o(s).scrollNext())
181
+ }), [...e[1] || (e[1] = [
182
+ c("svg", {
183
+ xmlns: "http://www.w3.org/2000/svg",
184
+ width: "16",
185
+ height: "16",
186
+ viewBox: "0 0 24 24",
187
+ fill: "none",
188
+ stroke: "currentColor",
189
+ "stroke-width": "2",
190
+ "stroke-linecap": "round",
191
+ "stroke-linejoin": "round",
192
+ class: "h-4 w-4"
193
+ }, [
194
+ c("path", { d: "m9 18 6-6-6-6" })
195
+ ], -1),
196
+ c("span", { class: "sr-only" }, "Siguiente slide", -1)
197
+ ])], 16, O));
198
+ }
199
+ });
200
+ export {
201
+ Y as Carousel,
202
+ q as CarouselContent,
203
+ F as CarouselItem,
204
+ H as CarouselNext,
205
+ G as CarouselPrevious
206
+ };