@zircon-labs/carousel 0.0.0-stage → 0.1.0-beta.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/LICENSE +201 -0
- package/README.md +229 -2
- package/dist/document-BD0NGsow.js +557 -0
- package/dist/editor.css +125 -0
- package/dist/editor.js +562 -0
- package/dist/index.js +1 -0
- package/dist/styles.css +370 -0
- package/dist/types/Carousel.d.ts +9 -0
- package/dist/types/CarouselControls.d.ts +15 -0
- package/dist/types/CarouselImage.d.ts +8 -0
- package/dist/types/assets.d.ts +34 -0
- package/dist/types/document.d.ts +13 -0
- package/dist/types/editor/CarouselEditor.d.ts +19 -0
- package/dist/types/editor/draft.d.ts +31 -0
- package/dist/types/editor/index.d.ts +2 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/model.d.ts +80 -0
- package/dist/types/slideNavigation.d.ts +13 -0
- package/dist/types/urls.d.ts +2 -0
- package/package.json +42 -4
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import { Component as e, createRef as t, useState as n } from "react";
|
|
2
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
3
|
+
// src/CarouselImage.tsx
|
|
4
|
+
function a(e, t) {
|
|
5
|
+
return e.kind === "url" ? {
|
|
6
|
+
status: "ready",
|
|
7
|
+
image: e
|
|
8
|
+
} : t?.(e.id) ?? { status: "missing" };
|
|
9
|
+
}
|
|
10
|
+
function o({ image: e, alt: t, thumbnail: i }) {
|
|
11
|
+
let [a, o] = n(!1);
|
|
12
|
+
return a ? /* @__PURE__ */ r(s, {
|
|
13
|
+
alt: t,
|
|
14
|
+
message: "No se pudo cargar la imagen"
|
|
15
|
+
}) : /* @__PURE__ */ r("img", {
|
|
16
|
+
src: e.src,
|
|
17
|
+
srcSet: e.srcSet,
|
|
18
|
+
sizes: i ? "64px" : e.sizes,
|
|
19
|
+
alt: t,
|
|
20
|
+
onError: () => o(!0)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function s({ alt: e, message: t }) {
|
|
24
|
+
return /* @__PURE__ */ r("span", {
|
|
25
|
+
className: "zircon-carousel__placeholder",
|
|
26
|
+
role: e ? "img" : void 0,
|
|
27
|
+
"aria-label": e || void 0,
|
|
28
|
+
"aria-hidden": !e || void 0,
|
|
29
|
+
children: t
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function c({ state: e, alt: t, thumbnail: n = !1 }) {
|
|
33
|
+
if (e.status === "ready") {
|
|
34
|
+
let { src: i, srcSet: a, sizes: s } = e.image;
|
|
35
|
+
return /* @__PURE__ */ r(o, {
|
|
36
|
+
image: e.image,
|
|
37
|
+
alt: t,
|
|
38
|
+
thumbnail: n
|
|
39
|
+
}, JSON.stringify([
|
|
40
|
+
i,
|
|
41
|
+
a,
|
|
42
|
+
s
|
|
43
|
+
]));
|
|
44
|
+
}
|
|
45
|
+
let i = e.status === "loading" ? "Cargando imagen" : e.status === "missing" ? "Imagen no encontrada" : "No se pudo cargar la imagen";
|
|
46
|
+
return /* @__PURE__ */ r(s, {
|
|
47
|
+
alt: t,
|
|
48
|
+
message: i
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// src/CarouselControls.tsx
|
|
52
|
+
function l({ variant: e, slides: t, images: n, activeIndex: a, destinationIndex: o, indicatorLine: s, settledId: l, move: u, select: d }) {
|
|
53
|
+
let f = e === "advanced", p = `${a + 1} de ${t.length}`, m = e === "basic" ? null : /* @__PURE__ */ r("div", {
|
|
54
|
+
className: "zircon-carousel__indicators",
|
|
55
|
+
children: t.map(({ id: e, image: o }, u) => {
|
|
56
|
+
let p = u === a, m = s && p;
|
|
57
|
+
return /* @__PURE__ */ i("button", {
|
|
58
|
+
type: "button",
|
|
59
|
+
className: "zircon-carousel__indicator",
|
|
60
|
+
"data-indicator-id": e,
|
|
61
|
+
"aria-label": `Ir a diapositiva ${u + 1} de ${t.length}${f ? `: ${o.alt}` : ""}`,
|
|
62
|
+
"aria-current": p ? "true" : void 0,
|
|
63
|
+
onClick: () => d(e),
|
|
64
|
+
children: [f ? /* @__PURE__ */ r(c, {
|
|
65
|
+
state: n[u],
|
|
66
|
+
alt: "",
|
|
67
|
+
thumbnail: !0
|
|
68
|
+
}) : /* @__PURE__ */ r("span", {
|
|
69
|
+
className: "zircon-carousel__dot",
|
|
70
|
+
"aria-hidden": "true"
|
|
71
|
+
}), m && /* @__PURE__ */ r("span", {
|
|
72
|
+
className: "zircon-carousel__line",
|
|
73
|
+
"data-animate": l === e || void 0,
|
|
74
|
+
"aria-hidden": "true"
|
|
75
|
+
})]
|
|
76
|
+
}, e);
|
|
77
|
+
})
|
|
78
|
+
}, "indicators");
|
|
79
|
+
return /* @__PURE__ */ i("div", {
|
|
80
|
+
className: "zircon-carousel__controls",
|
|
81
|
+
"data-variant": e,
|
|
82
|
+
role: "group",
|
|
83
|
+
"aria-label": "Controles del carrusel",
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ r("button", {
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "zircon-carousel__arrow",
|
|
88
|
+
"aria-label": "Anterior",
|
|
89
|
+
"aria-disabled": o === 0,
|
|
90
|
+
onClick: () => u(-1),
|
|
91
|
+
children: /* @__PURE__ */ r("span", {
|
|
92
|
+
"aria-hidden": "true",
|
|
93
|
+
children: "←"
|
|
94
|
+
})
|
|
95
|
+
}, "previous"),
|
|
96
|
+
f ? /* @__PURE__ */ i("span", {
|
|
97
|
+
className: "zircon-carousel__counter",
|
|
98
|
+
children: [/* @__PURE__ */ i("span", {
|
|
99
|
+
className: "zircon-carousel__sr-only",
|
|
100
|
+
children: ["Diapositiva ", p]
|
|
101
|
+
}), /* @__PURE__ */ i("span", {
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
children: [
|
|
104
|
+
a + 1,
|
|
105
|
+
" / ",
|
|
106
|
+
t.length
|
|
107
|
+
]
|
|
108
|
+
})]
|
|
109
|
+
}, "counter") : m,
|
|
110
|
+
/* @__PURE__ */ r("button", {
|
|
111
|
+
type: "button",
|
|
112
|
+
className: "zircon-carousel__arrow",
|
|
113
|
+
"aria-label": "Siguiente",
|
|
114
|
+
"aria-disabled": o === t.length - 1,
|
|
115
|
+
onClick: () => u(1),
|
|
116
|
+
children: /* @__PURE__ */ r("span", {
|
|
117
|
+
"aria-hidden": "true",
|
|
118
|
+
children: "→"
|
|
119
|
+
})
|
|
120
|
+
}, "next"),
|
|
121
|
+
f ? m : null
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// src/model.ts
|
|
126
|
+
var u = {
|
|
127
|
+
variant: "basic",
|
|
128
|
+
transition: "slide",
|
|
129
|
+
effects: {
|
|
130
|
+
snakeBorder: !1,
|
|
131
|
+
sparkle: !1,
|
|
132
|
+
indicatorLine: !1
|
|
133
|
+
},
|
|
134
|
+
layout: {
|
|
135
|
+
aspectRatio: 16 / 9,
|
|
136
|
+
gapPx: 16,
|
|
137
|
+
imageFit: "cover"
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
function d(e = {}) {
|
|
141
|
+
let { aspectRatio: t, gapPx: n, imageFit: r } = e;
|
|
142
|
+
return {
|
|
143
|
+
aspectRatio: t !== void 0 && Number.isFinite(t) && t > 0 ? t : u.layout.aspectRatio,
|
|
144
|
+
gapPx: n !== void 0 && Number.isFinite(n) && n >= 0 ? n : u.layout.gapPx,
|
|
145
|
+
imageFit: r ?? u.layout.imageFit
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function f(e = {}) {
|
|
149
|
+
return {
|
|
150
|
+
snakeBorder: e.snakeBorder ?? u.effects.snakeBorder,
|
|
151
|
+
sparkle: e.sparkle ?? u.effects.sparkle,
|
|
152
|
+
indicatorLine: e.indicatorLine ?? u.effects.indicatorLine
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function p(e, t, n) {
|
|
156
|
+
if (n !== void 0 && t.includes(n)) return n;
|
|
157
|
+
let r = e.indexOf(n ?? "");
|
|
158
|
+
return t[Math.max(0, Math.min(r, t.length - 1))];
|
|
159
|
+
}
|
|
160
|
+
function m(e) {
|
|
161
|
+
return {
|
|
162
|
+
variant: e.variant ?? u.variant,
|
|
163
|
+
transition: e.transition ?? u.transition,
|
|
164
|
+
effects: f(e.effects),
|
|
165
|
+
layout: d(e.layout)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
// src/slideNavigation.ts
|
|
169
|
+
var h = 1, g = 200;
|
|
170
|
+
function _(e) {
|
|
171
|
+
let t = getComputedStyle(e).direction === "rtl", n = e.getBoundingClientRect().left + e.clientLeft + (t ? e.clientWidth : 0);
|
|
172
|
+
return Array.from(e.children, (e) => {
|
|
173
|
+
let r = e.getBoundingClientRect();
|
|
174
|
+
return (t ? r.right : r.left) - n;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function v(e, t) {
|
|
178
|
+
let n = Math.max(0, t);
|
|
179
|
+
return e.forEach((t, r) => {
|
|
180
|
+
Math.abs(t) < Math.abs(e[n]) && (n = r);
|
|
181
|
+
}), n;
|
|
182
|
+
}
|
|
183
|
+
function y(e, t, n) {
|
|
184
|
+
return e.clientWidth ? t[v(_(e), t.indexOf(n ?? ""))] : n;
|
|
185
|
+
}
|
|
186
|
+
function b(e, t, n) {
|
|
187
|
+
let r = _(e)[t];
|
|
188
|
+
e.clientWidth && r !== void 0 && e.scrollBy({
|
|
189
|
+
left: r,
|
|
190
|
+
behavior: n
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function x(e, t, n, r) {
|
|
194
|
+
let i = n, a = n, o, s = !1, c = 0, l = 0, u = e.clientWidth, d = window.matchMedia?.("(prefers-reduced-motion: reduce)");
|
|
195
|
+
function f() {
|
|
196
|
+
r({
|
|
197
|
+
activeId: i,
|
|
198
|
+
pendingId: o,
|
|
199
|
+
settledId: a,
|
|
200
|
+
moving: s
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function p() {
|
|
204
|
+
if (!e.clientWidth) return;
|
|
205
|
+
if (u !== e.clientWidth) {
|
|
206
|
+
T();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
let n = _(e);
|
|
210
|
+
i = t[v(n, t.indexOf(i ?? ""))], o && Math.abs(n[t.indexOf(o)]) <= h && (o = void 0), f();
|
|
211
|
+
}
|
|
212
|
+
function m() {
|
|
213
|
+
c ||= requestAnimationFrame(() => {
|
|
214
|
+
c = 0, p();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function x() {
|
|
218
|
+
window.clearTimeout(l), s = !0, l = window.setTimeout(() => {
|
|
219
|
+
if (u !== e.clientWidth) {
|
|
220
|
+
T();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
o = void 0;
|
|
224
|
+
let n = _(e), r = v(n, t.indexOf(i ?? ""));
|
|
225
|
+
i = t[r], Math.abs(n[r]) <= h && (a = i, s = !1), f();
|
|
226
|
+
}, g);
|
|
227
|
+
}
|
|
228
|
+
function S() {
|
|
229
|
+
x(), m();
|
|
230
|
+
}
|
|
231
|
+
function C(n) {
|
|
232
|
+
let r = t.indexOf(n);
|
|
233
|
+
r < 0 || !e.clientWidth || (o = n, x(), f(), b(e, r, d?.matches ? "instant" : "smooth"), m());
|
|
234
|
+
}
|
|
235
|
+
function w(e) {
|
|
236
|
+
let n = t[Math.max(0, t.indexOf(o ?? i ?? "")) + e];
|
|
237
|
+
n !== void 0 && C(n);
|
|
238
|
+
}
|
|
239
|
+
function T() {
|
|
240
|
+
u = e.clientWidth;
|
|
241
|
+
let n = o ?? i;
|
|
242
|
+
o = void 0, window.clearTimeout(l), b(e, t.indexOf(n ?? ""), "instant"), i = y(e, t, n), a = i, s = !1, f();
|
|
243
|
+
}
|
|
244
|
+
function E() {
|
|
245
|
+
o && (o = void 0, e.scrollTo({
|
|
246
|
+
left: e.scrollLeft,
|
|
247
|
+
behavior: "instant"
|
|
248
|
+
}), x(), p());
|
|
249
|
+
}
|
|
250
|
+
function D(e) {
|
|
251
|
+
(e.deltaX || e.shiftKey && e.deltaY) && E();
|
|
252
|
+
}
|
|
253
|
+
function O(e) {
|
|
254
|
+
[
|
|
255
|
+
"ArrowLeft",
|
|
256
|
+
"ArrowRight",
|
|
257
|
+
"Home",
|
|
258
|
+
"End"
|
|
259
|
+
].includes(e.key) && E();
|
|
260
|
+
}
|
|
261
|
+
function k(e) {
|
|
262
|
+
e.matches && o && T();
|
|
263
|
+
}
|
|
264
|
+
let A = typeof ResizeObserver == "function" ? new ResizeObserver(() => {
|
|
265
|
+
u !== e.clientWidth && T();
|
|
266
|
+
}) : void 0;
|
|
267
|
+
A?.observe(e), d?.addEventListener("change", k), e.addEventListener("scroll", S, { passive: !0 }), e.addEventListener("scrollend", m), e.addEventListener("pointerdown", E), e.addEventListener("wheel", D, { passive: !0 }), e.addEventListener("keydown", O), e.addEventListener("focusin", E);
|
|
268
|
+
function j() {
|
|
269
|
+
A?.disconnect(), d?.removeEventListener("change", k), cancelAnimationFrame(c), window.clearTimeout(l), e.removeEventListener("scroll", S), e.removeEventListener("scrollend", m), e.removeEventListener("pointerdown", E), e.removeEventListener("wheel", D), e.removeEventListener("keydown", O), e.removeEventListener("focusin", E);
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
move: w,
|
|
273
|
+
select: C,
|
|
274
|
+
dispose: j
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
// src/urls.ts
|
|
278
|
+
function S(e) {
|
|
279
|
+
let t = e?.trim();
|
|
280
|
+
if (!t) return;
|
|
281
|
+
let n = t.replace(/[\t\n\r]/g, "");
|
|
282
|
+
if (!/^[\\/]{2}/.test(n)) try {
|
|
283
|
+
let e = /^[a-z][a-z\d+.-]*:/i.test(n), r = new URL(n, e ? void 0 : "https://carousel.invalid/");
|
|
284
|
+
if (r.protocol === "http:" || r.protocol === "https:") return t;
|
|
285
|
+
} catch {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function C(e) {
|
|
290
|
+
let t = e.trim();
|
|
291
|
+
if (!(t.startsWith("#") || t.startsWith("?"))) return S(t);
|
|
292
|
+
}
|
|
293
|
+
// src/Carousel.tsx
|
|
294
|
+
function w(e) {
|
|
295
|
+
return e.slides.map(({ id: e }) => e);
|
|
296
|
+
}
|
|
297
|
+
function T(e) {
|
|
298
|
+
return e.variant ?? u.variant;
|
|
299
|
+
}
|
|
300
|
+
function E(e) {
|
|
301
|
+
return e.transition ?? u.transition;
|
|
302
|
+
}
|
|
303
|
+
function D(e) {
|
|
304
|
+
return e.effects?.indicatorLine === !0 && T(e) !== "basic" && e.slides.length > 1;
|
|
305
|
+
}
|
|
306
|
+
function O(e) {
|
|
307
|
+
let { snakeBorder: t, sparkle: n } = f(e.effects);
|
|
308
|
+
return E(e) === "slide" && e.slides.length > 1 && (T(e) !== "basic" || t || n);
|
|
309
|
+
}
|
|
310
|
+
function k(e) {
|
|
311
|
+
return /* @__PURE__ */ r(A, { ...e });
|
|
312
|
+
}
|
|
313
|
+
var A = class extends e {
|
|
314
|
+
region = t();
|
|
315
|
+
list = t();
|
|
316
|
+
tracker;
|
|
317
|
+
state = {
|
|
318
|
+
activeId: this.props.config.slides[0]?.id,
|
|
319
|
+
settledId: this.props.config.slides[0]?.id,
|
|
320
|
+
moving: !1,
|
|
321
|
+
linePulse: !D(this.props.config) && void 0
|
|
322
|
+
};
|
|
323
|
+
componentDidMount() {
|
|
324
|
+
this.startTracking(this.state.activeId);
|
|
325
|
+
}
|
|
326
|
+
componentWillUnmount() {
|
|
327
|
+
this.tracker?.dispose();
|
|
328
|
+
}
|
|
329
|
+
getSnapshotBeforeUpdate(e, t) {
|
|
330
|
+
let { config: n } = this.props, r = e.config, i = r !== n && (T(r) !== T(n) || E(r) !== E(n) || O(r) !== O(n) || d(r.layout).gapPx !== d(n.layout).gapPx || r.slides.length !== n.slides.length || r.slides.some(({ id: e }, t) => e !== n.slides[t]?.id));
|
|
331
|
+
if (r === n && (E(n) !== "fade" || t.activeId === this.state.activeId)) return null;
|
|
332
|
+
let a = document.activeElement;
|
|
333
|
+
return {
|
|
334
|
+
focused: a instanceof HTMLElement && this.region.current?.contains(a) ? a : void 0,
|
|
335
|
+
reposition: i,
|
|
336
|
+
visibleId: i && E(r) === "slide" && r.slides.length > 1 && this.list.current ? y(this.list.current, w(r), t.activeId) : t.activeId
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
componentDidUpdate(e, t, n) {
|
|
340
|
+
let { config: r } = this.props;
|
|
341
|
+
if (!D(r) && this.state.linePulse !== void 0 ? this.setState({ linePulse: void 0 }) : !e.config.effects?.indicatorLine && D(r) && this.setState({ linePulse: !1 }), !n) return;
|
|
342
|
+
if (!n.reposition) {
|
|
343
|
+
this.restoreFocus(n.focused);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
let i = w(r), a = p(w(e.config), i, n.visibleId);
|
|
347
|
+
this.tracker?.dispose(), this.tracker = void 0, this.list.current && E(r) === "slide" && i.length > 1 && b(this.list.current, i.indexOf(a ?? ""), "instant"), this.startTracking(a), this.updateSelection({
|
|
348
|
+
activeId: a,
|
|
349
|
+
settledId: a,
|
|
350
|
+
moving: !1
|
|
351
|
+
}), n.focused && this.setState({}, () => this.restoreFocus(n.focused));
|
|
352
|
+
}
|
|
353
|
+
startTracking(e) {
|
|
354
|
+
let { config: t } = this.props;
|
|
355
|
+
this.list.current && O(t) && (this.tracker = x(this.list.current, w(t), e, this.updateSelection));
|
|
356
|
+
}
|
|
357
|
+
updateSelection = (e) => {
|
|
358
|
+
this.setState((t, { config: n }) => t.activeId === e.activeId && t.pendingId === e.pendingId && t.settledId === e.settledId && t.moving === e.moving ? null : {
|
|
359
|
+
...e,
|
|
360
|
+
pendingId: e.pendingId,
|
|
361
|
+
linePulse: D(n) && t.settledId !== e.settledId ? !t.linePulse : t.linePulse
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
restoreFocus(e) {
|
|
365
|
+
let t = this.region.current;
|
|
366
|
+
if (!e || !t) return;
|
|
367
|
+
let n = document.activeElement;
|
|
368
|
+
if (n !== e && n !== document.body) return;
|
|
369
|
+
if (t.contains(e) && !e.closest("[inert]") && (e !== this.list.current || e.tabIndex >= 0)) {
|
|
370
|
+
n !== e && e.focus({ preventScroll: !0 });
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
let r = Array.from(t.querySelectorAll("[data-indicator-id]")), i = e.hasAttribute("data-indicator-id") ? r.find((e) => e.getAttribute("aria-current") === "true") : void 0, a = t.querySelector("[data-active-slide] a");
|
|
374
|
+
(i ?? a ?? t).focus({ preventScroll: !0 });
|
|
375
|
+
}
|
|
376
|
+
changeFade(e) {
|
|
377
|
+
this.setState((t, { config: n }) => {
|
|
378
|
+
let r = e(Math.max(0, n.slides.findIndex(({ id: e }) => e === t.activeId)), n.slides);
|
|
379
|
+
return r === void 0 || r === t.activeId ? null : {
|
|
380
|
+
activeId: r,
|
|
381
|
+
settledId: r,
|
|
382
|
+
moving: !1,
|
|
383
|
+
linePulse: D(n) ? !t.linePulse : void 0
|
|
384
|
+
};
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
move = (e) => {
|
|
388
|
+
E(this.props.config) === "fade" ? this.changeFade((t, n) => n[t + e]?.id) : this.tracker?.move(e);
|
|
389
|
+
};
|
|
390
|
+
select = (e) => {
|
|
391
|
+
E(this.props.config) === "fade" ? this.changeFade((t, n) => n.find((t) => t.id === e)?.id) : this.tracker?.select(e);
|
|
392
|
+
};
|
|
393
|
+
render() {
|
|
394
|
+
let { config: e, ariaLabel: t, className: n, getAssetState: o } = this.props, { slides: s } = e;
|
|
395
|
+
if (s.length === 0) return null;
|
|
396
|
+
let u = s.map(({ image: e }) => a(e.source, o)), p = E(e), m = T(e), h = s.length > 1, g = h && p === "fade", _ = h && p === "slide", v = h && (m !== "basic" || g), { aspectRatio: y, gapPx: b, imageFit: x } = d(e.layout), { snakeBorder: C, sparkle: w, indicatorLine: O } = f(e.effects), { activeId: k, settledId: A, pendingId: j, moving: M, linePulse: N } = this.state, P = Math.max(0, s.findIndex(({ id: e }) => e === k)), F = s.findIndex(({ id: e }) => e === j), I = A ?? s[P].id, L = {
|
|
397
|
+
"--zircon-carousel-ratio": y,
|
|
398
|
+
"--zircon-carousel-gap": `${b}px`,
|
|
399
|
+
"--zircon-carousel-fit": x
|
|
400
|
+
};
|
|
401
|
+
return /* @__PURE__ */ i("section", {
|
|
402
|
+
ref: this.region,
|
|
403
|
+
"aria-label": t,
|
|
404
|
+
tabIndex: -1,
|
|
405
|
+
className: n ? `zircon-carousel ${n}` : "zircon-carousel",
|
|
406
|
+
"data-line-pulse": N !== void 0 && D(e) ? String(N) : void 0,
|
|
407
|
+
style: L,
|
|
408
|
+
children: [/* @__PURE__ */ i("div", {
|
|
409
|
+
className: "zircon-carousel__viewport",
|
|
410
|
+
children: [/* @__PURE__ */ r("ul", {
|
|
411
|
+
ref: this.list,
|
|
412
|
+
className: [
|
|
413
|
+
"zircon-carousel__list",
|
|
414
|
+
_ && "zircon-carousel__list--scrollable",
|
|
415
|
+
g && "zircon-carousel__list--fade"
|
|
416
|
+
].filter(Boolean).join(" "),
|
|
417
|
+
role: "list",
|
|
418
|
+
tabIndex: _ ? 0 : void 0,
|
|
419
|
+
children: s.map(({ id: e, href: t, image: n }, i) => {
|
|
420
|
+
let a = S(t), o = /* @__PURE__ */ r(c, {
|
|
421
|
+
state: u[i],
|
|
422
|
+
alt: n.alt
|
|
423
|
+
}), s = i === P;
|
|
424
|
+
return /* @__PURE__ */ r("li", {
|
|
425
|
+
className: "zircon-carousel__slide",
|
|
426
|
+
"data-active-slide": s || void 0,
|
|
427
|
+
inert: g && !s,
|
|
428
|
+
children: a ? /* @__PURE__ */ r("a", {
|
|
429
|
+
className: "zircon-carousel__media",
|
|
430
|
+
href: a,
|
|
431
|
+
children: o
|
|
432
|
+
}) : /* @__PURE__ */ r("div", {
|
|
433
|
+
className: "zircon-carousel__media",
|
|
434
|
+
children: o
|
|
435
|
+
})
|
|
436
|
+
}, e);
|
|
437
|
+
})
|
|
438
|
+
}), (C || w) && /* @__PURE__ */ i("div", {
|
|
439
|
+
className: "zircon-carousel__effects",
|
|
440
|
+
"aria-hidden": "true",
|
|
441
|
+
"data-moving": M || void 0,
|
|
442
|
+
children: [C && /* @__PURE__ */ r("span", { className: "zircon-carousel__snake" }, `border:${I}`), w && /* @__PURE__ */ r("span", { className: "zircon-carousel__sparkle" }, `sparkle:${I}`)]
|
|
443
|
+
})]
|
|
444
|
+
}), v && /* @__PURE__ */ r(l, {
|
|
445
|
+
variant: m,
|
|
446
|
+
slides: s,
|
|
447
|
+
images: u,
|
|
448
|
+
activeIndex: P,
|
|
449
|
+
destinationIndex: F < 0 ? P : F,
|
|
450
|
+
indicatorLine: O,
|
|
451
|
+
settledId: A,
|
|
452
|
+
move: this.move,
|
|
453
|
+
select: this.select
|
|
454
|
+
})]
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
// src/document.ts
|
|
459
|
+
function j(e) {
|
|
460
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
461
|
+
}
|
|
462
|
+
function M(e) {
|
|
463
|
+
return typeof e == "string" && e.trim().length > 0;
|
|
464
|
+
}
|
|
465
|
+
function N(e, t) {
|
|
466
|
+
return e === void 0 || t.includes(e);
|
|
467
|
+
}
|
|
468
|
+
function P(e, t, n) {
|
|
469
|
+
return e === void 0 || typeof e == "number" && Number.isFinite(e) && (n ? e >= t : e > t);
|
|
470
|
+
}
|
|
471
|
+
function F(e) {
|
|
472
|
+
let t = !1, n = !1, r = !1;
|
|
473
|
+
for (let i of e.split(/[\t\n\f\r ]+/).filter(Boolean)) if (/^\d+w$/.test(i) && Number(i.slice(0, -1)) > 0 && !t) t = !0;
|
|
474
|
+
else if (/^\d+h$/.test(i) && Number(i.slice(0, -1)) > 0 && !n) n = !0;
|
|
475
|
+
else if (/^-?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?x$/i.test(i) && Number.isFinite(Number(i.slice(0, -1))) && Number(i.slice(0, -1)) >= 0 && !r) r = !0;
|
|
476
|
+
else return !1;
|
|
477
|
+
return (!n || t) && (!r || !t);
|
|
478
|
+
}
|
|
479
|
+
function I(e) {
|
|
480
|
+
let t = 0;
|
|
481
|
+
for (; t < e.length;) {
|
|
482
|
+
for (; t < e.length && /[,\t\n\f\r ]/.test(e[t]);) t += 1;
|
|
483
|
+
if (t === e.length) return !0;
|
|
484
|
+
let n = t;
|
|
485
|
+
for (; t < e.length && !/[\t\n\f\r ]/.test(e[t]);) t += 1;
|
|
486
|
+
let r = e.slice(n, t);
|
|
487
|
+
if (!C(r.replace(/,+$/, ""))) return !1;
|
|
488
|
+
if (r.endsWith(",")) continue;
|
|
489
|
+
let i = e.indexOf(",", t);
|
|
490
|
+
if (!F(e.slice(t, i < 0 ? e.length : i))) return !1;
|
|
491
|
+
t = i < 0 ? e.length : i + 1;
|
|
492
|
+
}
|
|
493
|
+
return !0;
|
|
494
|
+
}
|
|
495
|
+
function L(e) {
|
|
496
|
+
return j(e) ? e.kind === "asset" ? M(e.id) && e.id === e.id.trim() && !/^(?:blob|data):/i.test(e.id) : e.kind === "url" && typeof e.src == "string" && !!C(e.src) && (e.srcSet === void 0 || typeof e.srcSet == "string" && I(e.srcSet)) && (e.sizes === void 0 || typeof e.sizes == "string") : !1;
|
|
497
|
+
}
|
|
498
|
+
function R(e) {
|
|
499
|
+
if (!L(e)) throw TypeError("La fuente de imagen no es persistible.");
|
|
500
|
+
if (e.kind === "asset") return {
|
|
501
|
+
kind: "asset",
|
|
502
|
+
id: e.id
|
|
503
|
+
};
|
|
504
|
+
let { src: t, srcSet: n, sizes: r } = e;
|
|
505
|
+
return {
|
|
506
|
+
kind: "url",
|
|
507
|
+
src: t.trim(),
|
|
508
|
+
srcSet: n,
|
|
509
|
+
sizes: r
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
function z(e) {
|
|
513
|
+
return JSON.stringify({
|
|
514
|
+
schemaVersion: e.schemaVersion,
|
|
515
|
+
slides: e.slides.map(({ id: e, image: t, href: n }) => ({
|
|
516
|
+
id: e,
|
|
517
|
+
image: {
|
|
518
|
+
source: R(t.source),
|
|
519
|
+
alt: t.alt.trim()
|
|
520
|
+
},
|
|
521
|
+
href: S(n)
|
|
522
|
+
})),
|
|
523
|
+
...m(e)
|
|
524
|
+
}, null, 2);
|
|
525
|
+
}
|
|
526
|
+
function B(e) {
|
|
527
|
+
let t = (e) => ({
|
|
528
|
+
ok: !1,
|
|
529
|
+
issue: e
|
|
530
|
+
});
|
|
531
|
+
if (!j(e) || e.schemaVersion !== 1 && e.schemaVersion !== 2) return t("Versión de configuración no admitida.");
|
|
532
|
+
if (!Array.isArray(e.slides)) return t("La configuración debe incluir una lista de diapositivas.");
|
|
533
|
+
if (!N(e.variant, [
|
|
534
|
+
"basic",
|
|
535
|
+
"standard",
|
|
536
|
+
"advanced"
|
|
537
|
+
]) || !N(e.transition, ["slide", "fade"])) return t("Variante o transición no válida.");
|
|
538
|
+
if (e.effects !== void 0 && (!j(e.effects) || [
|
|
539
|
+
"snakeBorder",
|
|
540
|
+
"sparkle",
|
|
541
|
+
"indicatorLine"
|
|
542
|
+
].some((t) => !N(e.effects[t], [!0, !1])))) return t("Efectos no válidos.");
|
|
543
|
+
if (e.layout !== void 0 && (!j(e.layout) || !P(e.layout.aspectRatio, 0, !1) || !P(e.layout.gapPx, 0, !0) || !N(e.layout.imageFit, ["cover", "contain"]))) return t("Ajustes de presentación no válidos.");
|
|
544
|
+
let n = /* @__PURE__ */ new Set();
|
|
545
|
+
for (let [r, i] of e.slides.entries()) {
|
|
546
|
+
let a = `Diapositiva ${r + 1}`;
|
|
547
|
+
if (!j(i) || !M(i.id) || n.has(i.id)) return t(`${a}: el ID falta o está repetido.`);
|
|
548
|
+
if (n.add(i.id), !j(i.image) || !M(i.image.alt) || !L(i.image.source)) return t(`${a}: imagen o texto alternativo no válido.`);
|
|
549
|
+
if (e.schemaVersion === 1 && i.image.source.kind === "asset") return t(`${a}: una referencia administrada requiere la versión 2.`);
|
|
550
|
+
if (i.href !== void 0 && (typeof i.href != "string" || i.href.trim() && !S(i.href))) return t(`${a}: enlace no válido.`);
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
ok: !0,
|
|
554
|
+
value: JSON.parse(z(e))
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
export { C as a, p as c, k as i, m as l, z as n, S as o, L as r, u as s, B as t };
|
package/dist/editor.css
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
.zircon-editor {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: clamp(1rem, 3vw, 2rem);
|
|
4
|
+
align-items: start;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.zircon-editor__fields,
|
|
8
|
+
.zircon-editor__preview {
|
|
9
|
+
min-inline-size: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.zircon-editor__fields {
|
|
13
|
+
display: grid;
|
|
14
|
+
gap: 1rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.zircon-editor__preview {
|
|
18
|
+
padding: 1rem;
|
|
19
|
+
border: 1px solid #c7cbd1;
|
|
20
|
+
border-radius: 0.5rem;
|
|
21
|
+
background: #f8fafb;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.zircon-editor h2 {
|
|
25
|
+
margin-block: 0 0.75rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.zircon-editor p {
|
|
29
|
+
overflow-wrap: anywhere;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.zircon-editor__slides {
|
|
33
|
+
display: grid;
|
|
34
|
+
gap: 0.5rem;
|
|
35
|
+
padding-inline-start: 1.5rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.zircon-editor__slides button {
|
|
39
|
+
max-inline-size: 100%;
|
|
40
|
+
text-align: start;
|
|
41
|
+
white-space: normal;
|
|
42
|
+
overflow-wrap: anywhere;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.zircon-editor__slides button[aria-current='true'] {
|
|
46
|
+
border-color: currentColor;
|
|
47
|
+
font-weight: 600;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.zircon-editor__group,
|
|
51
|
+
.zircon-editor__effects {
|
|
52
|
+
display: grid;
|
|
53
|
+
gap: 0.75rem;
|
|
54
|
+
min-inline-size: 0;
|
|
55
|
+
margin: 0;
|
|
56
|
+
padding: 0.75rem;
|
|
57
|
+
border: 1px solid #c7cbd1;
|
|
58
|
+
border-radius: 0.5rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.zircon-editor__group {
|
|
62
|
+
margin-block-start: 0.75rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.zircon-editor__group legend {
|
|
66
|
+
padding-inline: 0.25rem;
|
|
67
|
+
font-weight: 600;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.zircon-editor__options {
|
|
71
|
+
display: grid;
|
|
72
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr));
|
|
73
|
+
gap: 0.75rem;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.zircon-editor__options label {
|
|
77
|
+
display: grid;
|
|
78
|
+
gap: 0.25rem;
|
|
79
|
+
min-inline-size: 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.zircon-editor__options select {
|
|
83
|
+
min-inline-size: 0;
|
|
84
|
+
max-inline-size: 100%;
|
|
85
|
+
min-block-size: 2.5rem;
|
|
86
|
+
padding: 0.25rem;
|
|
87
|
+
font: inherit;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.zircon-editor__actions {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
gap: 0.5rem;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.zircon-editor__actions button[aria-disabled='true'] {
|
|
97
|
+
color: GrayText;
|
|
98
|
+
cursor: default;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.zircon-editor__sr-only {
|
|
102
|
+
position: absolute;
|
|
103
|
+
inline-size: 1px;
|
|
104
|
+
block-size: 1px;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
clip-path: inset(50%);
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@media (min-width: 54rem) {
|
|
111
|
+
.zircon-editor {
|
|
112
|
+
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.zircon-editor__group > label:has(select) {
|
|
117
|
+
display: grid;
|
|
118
|
+
gap: 0.25rem;
|
|
119
|
+
min-inline-size: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.zircon-editor__group > label select {
|
|
123
|
+
max-inline-size: 100%;
|
|
124
|
+
font: inherit;
|
|
125
|
+
}
|