@citrusworx/juiceui 0.3.0 → 0.4.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/README.md +263 -233
- package/dist/index.css +807 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +418 -45
- package/dist/js/juice.d.ts +6 -0
- package/dist/js/src/accordion/accordion-runtime.d.ts +16 -0
- package/dist/js/src/tabs/tabs-runtime.d.ts +16 -0
- package/dist/themes/aquaflux.css +152 -0
- package/dist/themes/citrusmint.css +124 -0
- package/dist/themes/index.d.ts +2 -0
- package/dist/themes/kiwipress.css +123 -10
- package/dist/tokens/index.d.ts +15 -0
- package/package.json +117 -109
- package/dist/components/accordion/accordion.test.d.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { Accordion } from "./components/accordion/accordion.js";
|
|
2
2
|
export { createNavigation, initNavigation, startNavigationRuntime, stopNavigationRuntime } from "./js/src/nav/navigation.js";
|
|
3
3
|
export type { NavigationController, NavigationOptions } from "./js/src/nav/navigation.js";
|
|
4
|
+
export { createAccordion, initAccordion, startAccordionRuntime, stopAccordionRuntime } from "./js/src/accordion/accordion-runtime.js";
|
|
5
|
+
export type { AccordionController, AccordionOptions } from "./js/src/accordion/accordion-runtime.js";
|
|
6
|
+
export { createTabs, initTabs, startTabsRuntime, stopTabsRuntime } from "./js/src/tabs/tabs-runtime.js";
|
|
7
|
+
export type { TabsController, TabsOptions } from "./js/src/tabs/tabs-runtime.js";
|
|
4
8
|
export { tokens } from "./tokens/index.js";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//#region ../sig/dist/signal.js
|
|
2
|
-
var e =
|
|
2
|
+
var e = 0, t = /* @__PURE__ */ new Set(), n = null, r = null;
|
|
3
3
|
function i(e) {
|
|
4
4
|
e?.();
|
|
5
5
|
}
|
|
6
6
|
function a(n) {
|
|
7
|
-
if (e) {
|
|
7
|
+
if (e > 0) {
|
|
8
8
|
t.add(n);
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
@@ -97,9 +97,9 @@ function f(e, t) {
|
|
|
97
97
|
}
|
|
98
98
|
if (typeof t == "function") {
|
|
99
99
|
let n = document.createTextNode("");
|
|
100
|
-
e.appendChild(n), l(() => {
|
|
100
|
+
e.appendChild(n), d(n, l(() => {
|
|
101
101
|
n.textContent = String(t());
|
|
102
|
-
});
|
|
102
|
+
}));
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
if (typeof t == "string" || typeof t == "number") {
|
|
@@ -109,7 +109,25 @@ function f(e, t) {
|
|
|
109
109
|
e.appendChild(t);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
function p(e, t
|
|
112
|
+
function p(e, t) {
|
|
113
|
+
return t in e && t !== "animate" && t !== "animation" && t !== "motion" && !t.startsWith("data-") && !t.startsWith("aria-");
|
|
114
|
+
}
|
|
115
|
+
function m(e, t, n) {
|
|
116
|
+
if (t === "class") {
|
|
117
|
+
if (n === !1 || n == null) {
|
|
118
|
+
e.removeAttribute("class"), e.className = "";
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
e.className = String(n === !0 ? "" : n);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (p(e, t)) {
|
|
125
|
+
e[t] = n;
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
n === !0 ? e.setAttribute(t, "") : n === !1 || n == null ? e.removeAttribute(t) : e.setAttribute(t, String(n));
|
|
129
|
+
}
|
|
130
|
+
function h(e, t, n) {
|
|
113
131
|
if (t !== "children") {
|
|
114
132
|
if (t === "ref" && typeof n == "function") {
|
|
115
133
|
n(e);
|
|
@@ -120,38 +138,40 @@ function p(e, t, n) {
|
|
|
120
138
|
e.addEventListener(r, n);
|
|
121
139
|
return;
|
|
122
140
|
}
|
|
123
|
-
if (
|
|
124
|
-
e
|
|
141
|
+
if (typeof n == "function") {
|
|
142
|
+
d(e, l(() => {
|
|
143
|
+
m(e, t, n());
|
|
144
|
+
}));
|
|
125
145
|
return;
|
|
126
146
|
}
|
|
127
|
-
|
|
147
|
+
m(e, t, n);
|
|
128
148
|
}
|
|
129
149
|
}
|
|
130
|
-
function
|
|
150
|
+
function g(e, t) {
|
|
131
151
|
if (typeof e == "function") {
|
|
132
152
|
let { value: n, dispose: r } = s(() => e(t));
|
|
133
153
|
return n instanceof Node && d(n, r), n;
|
|
134
154
|
}
|
|
135
155
|
let n = document.createElement(e);
|
|
136
156
|
if (t) {
|
|
137
|
-
for (let e in t)
|
|
157
|
+
for (let e in t) h(n, e, t[e]);
|
|
138
158
|
f(n, t.children);
|
|
139
159
|
}
|
|
140
160
|
return n;
|
|
141
161
|
}
|
|
142
|
-
var
|
|
162
|
+
var _ = g;
|
|
143
163
|
//#endregion
|
|
144
164
|
//#region src/components/accordion/accordion.tsx
|
|
145
|
-
function
|
|
165
|
+
function v(e) {
|
|
146
166
|
let t = c(e.defaultExpanded ?? !1), n = e.name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "accordion", r = `${n}-trigger`, i = `${n}-panel`, a = null, o = null, s = (e) => {
|
|
147
|
-
a?.setAttribute("aria-expanded", String(e)), o && (o.hidden = !e, o.setAttribute("aria-hidden", String(!e))
|
|
167
|
+
a?.setAttribute("aria-expanded", String(e)), o && (o.hidden = !e, o.setAttribute("aria-hidden", String(!e)));
|
|
148
168
|
};
|
|
149
169
|
return l(() => {
|
|
150
170
|
s(t.get());
|
|
151
|
-
}), /* @__PURE__ */
|
|
171
|
+
}), /* @__PURE__ */ _("section", {
|
|
152
172
|
accordion: !0,
|
|
153
173
|
name: e.name,
|
|
154
|
-
children: [/* @__PURE__ */
|
|
174
|
+
children: [/* @__PURE__ */ g("button", {
|
|
155
175
|
...e.attributes ?? {},
|
|
156
176
|
ref: (e) => {
|
|
157
177
|
a = e, s(t.get());
|
|
@@ -161,16 +181,14 @@ function g(e) {
|
|
|
161
181
|
"accordion-item": !0,
|
|
162
182
|
"aria-expanded": String(t.get()),
|
|
163
183
|
"aria-controls": i,
|
|
164
|
-
onclick: () => t.set(!t.get()),
|
|
165
184
|
children: e.title ?? e.name
|
|
166
|
-
}), /* @__PURE__ */
|
|
185
|
+
}), /* @__PURE__ */ g("div", {
|
|
167
186
|
ref: (e) => {
|
|
168
187
|
o = e, s(t.get());
|
|
169
188
|
},
|
|
170
189
|
id: i,
|
|
171
190
|
role: "region",
|
|
172
191
|
"aria-labelledby": r,
|
|
173
|
-
content: t.get() ? "active" : "hidden",
|
|
174
192
|
hidden: !t.get(),
|
|
175
193
|
"aria-hidden": String(!t.get()),
|
|
176
194
|
children: e.children
|
|
@@ -179,19 +197,19 @@ function g(e) {
|
|
|
179
197
|
}
|
|
180
198
|
//#endregion
|
|
181
199
|
//#region src/js/src/nav/navigation.ts
|
|
182
|
-
var
|
|
200
|
+
var y = {
|
|
183
201
|
root: typeof document < "u" ? document : {},
|
|
184
202
|
navSelector: "nav[type=\"bar\"], nav[type=\"links\"]",
|
|
185
203
|
sidebarSelector: "nav[type=\"sidebar\"]",
|
|
186
204
|
toggleSelector: "nav[type=\"mobile\"]",
|
|
187
205
|
mobileBreakpoint: 960
|
|
188
|
-
},
|
|
206
|
+
}, b = (e) => Array.from(e), x = "juice-sidebar", S = "Toggle navigation menu", C = (e, t) => {
|
|
189
207
|
if (t) {
|
|
190
208
|
e.removeAttribute("hidden");
|
|
191
209
|
return;
|
|
192
210
|
}
|
|
193
211
|
e.setAttribute("hidden", "true");
|
|
194
|
-
},
|
|
212
|
+
}, w = (e) => e instanceof HTMLButtonElement || e instanceof HTMLAnchorElement, T = (e = {}) => {
|
|
195
213
|
if (typeof window > "u" || typeof document > "u") return {
|
|
196
214
|
destroy: () => {},
|
|
197
215
|
openSidebar: () => {},
|
|
@@ -201,29 +219,29 @@ var _ = {
|
|
|
201
219
|
isMobile: () => !1
|
|
202
220
|
};
|
|
203
221
|
let t = {
|
|
204
|
-
...
|
|
222
|
+
...y,
|
|
205
223
|
...e
|
|
206
|
-
}, n = t.root ?? document, r = n, i = () =>
|
|
224
|
+
}, n = t.root ?? document, r = n, i = () => b(n.querySelectorAll(t.navSelector)), a = () => b(n.querySelectorAll(t.sidebarSelector)), o = () => b(n.querySelectorAll(t.toggleSelector)), s = () => window.innerWidth <= t.mobileBreakpoint, c = 0, l = null, u = (e) => {
|
|
207
225
|
if (e.id) return e.id;
|
|
208
226
|
c += 1;
|
|
209
|
-
let t = `${
|
|
227
|
+
let t = `${x}-${c}`;
|
|
210
228
|
return e.id = t, t;
|
|
211
229
|
}, d = (e, t) => {
|
|
212
230
|
if (!e) return;
|
|
213
231
|
let n = e.children.length > 0 || (e.textContent?.trim().length ?? 0) > 0;
|
|
214
|
-
t && e.setAttribute("aria-controls", u(t)), n ? e.removeAttribute("data-nav-toggle-icon") : e.setAttribute("data-nav-toggle-icon", "default"), !e.hasAttribute("aria-label") && !e.hasAttribute("aria-labelledby") && (e.textContent?.trim() ?? "").length === 0 && e.setAttribute("aria-label",
|
|
232
|
+
t && e.setAttribute("aria-controls", u(t)), n ? e.removeAttribute("data-nav-toggle-icon") : e.setAttribute("data-nav-toggle-icon", "default"), !e.hasAttribute("aria-label") && !e.hasAttribute("aria-labelledby") && (e.textContent?.trim() ?? "").length === 0 && e.setAttribute("aria-label", S), w(e) || (e.setAttribute("role", "button"), e.hasAttribute("tabindex") || e.setAttribute("tabindex", "0"));
|
|
215
233
|
}, f = (e) => {
|
|
216
234
|
let n = a();
|
|
217
235
|
if (n.length === 0) return null;
|
|
218
236
|
if (!e) return n[0] ?? null;
|
|
219
237
|
let r = e.parentElement;
|
|
220
238
|
if (r) {
|
|
221
|
-
let e =
|
|
239
|
+
let e = b(r.querySelectorAll(t.sidebarSelector))[0];
|
|
222
240
|
if (e) return e;
|
|
223
241
|
}
|
|
224
242
|
let i = e;
|
|
225
243
|
for (; i;) {
|
|
226
|
-
let e =
|
|
244
|
+
let e = b(i.querySelectorAll(t.sidebarSelector))[0];
|
|
227
245
|
if (e) return e;
|
|
228
246
|
i = i.parentElement;
|
|
229
247
|
}
|
|
@@ -234,12 +252,12 @@ var _ = {
|
|
|
234
252
|
if (!e) return n[0] ?? null;
|
|
235
253
|
let r = e.parentElement;
|
|
236
254
|
if (r) {
|
|
237
|
-
let e =
|
|
255
|
+
let e = b(r.querySelectorAll(t.toggleSelector))[0];
|
|
238
256
|
if (e) return e;
|
|
239
257
|
}
|
|
240
258
|
let i = e;
|
|
241
259
|
for (; i;) {
|
|
242
|
-
let e =
|
|
260
|
+
let e = b(i.querySelectorAll(t.toggleSelector))[0];
|
|
243
261
|
if (e) return e;
|
|
244
262
|
i = i.parentElement;
|
|
245
263
|
}
|
|
@@ -259,10 +277,10 @@ var _ = {
|
|
|
259
277
|
}
|
|
260
278
|
m(e);
|
|
261
279
|
}
|
|
262
|
-
},
|
|
280
|
+
}, _ = () => {
|
|
263
281
|
let e = s(), t = i(), n = o(), r = a();
|
|
264
|
-
t.forEach((t) =>
|
|
265
|
-
d(t, f(t)),
|
|
282
|
+
t.forEach((t) => C(t, !e)), n.forEach((t) => {
|
|
283
|
+
d(t, f(t)), C(t, e), e || t.setAttribute("aria-expanded", "false");
|
|
266
284
|
}), r.forEach((t) => {
|
|
267
285
|
u(t);
|
|
268
286
|
let n = p(t);
|
|
@@ -276,7 +294,7 @@ var _ = {
|
|
|
276
294
|
}
|
|
277
295
|
t.setAttribute("hidden", "true"), t.setAttribute("aria-hidden", "true"), n?.setAttribute("aria-expanded", "false");
|
|
278
296
|
});
|
|
279
|
-
},
|
|
297
|
+
}, v = () => _(), T = (e) => {
|
|
280
298
|
let n = e.target;
|
|
281
299
|
if (!(n instanceof Element)) return;
|
|
282
300
|
let r = n.closest(t.toggleSelector);
|
|
@@ -295,36 +313,375 @@ var _ = {
|
|
|
295
313
|
}
|
|
296
314
|
if (e.key !== "Enter" && e.key !== " ") return;
|
|
297
315
|
let r = n.closest(t.toggleSelector);
|
|
298
|
-
!(r instanceof HTMLElement) ||
|
|
316
|
+
!(r instanceof HTMLElement) || w(r) || (e.preventDefault(), g(r));
|
|
299
317
|
}, D = !1, O = () => {
|
|
300
318
|
D || (D = !0, requestAnimationFrame(() => {
|
|
301
|
-
D = !1,
|
|
319
|
+
D = !1, _();
|
|
302
320
|
}));
|
|
303
321
|
}, k = typeof MutationObserver < "u" ? new MutationObserver(() => O()) : null;
|
|
304
|
-
return window.addEventListener("resize",
|
|
322
|
+
return window.addEventListener("resize", v), r.addEventListener("click", T), r.addEventListener("keydown", E), k && n instanceof Node && k.observe(n, {
|
|
305
323
|
childList: !0,
|
|
306
324
|
subtree: !0,
|
|
307
325
|
attributes: !0,
|
|
308
326
|
attributeFilter: ["hidden", "type"]
|
|
309
|
-
}),
|
|
327
|
+
}), _(), {
|
|
310
328
|
destroy: () => {
|
|
311
|
-
window.removeEventListener("resize",
|
|
329
|
+
window.removeEventListener("resize", v), r.removeEventListener("click", T), r.removeEventListener("keydown", E), k?.disconnect();
|
|
312
330
|
},
|
|
313
331
|
openSidebar: m,
|
|
314
332
|
closeSidebar: h,
|
|
315
333
|
toggleSidebar: g,
|
|
316
|
-
sync:
|
|
334
|
+
sync: _,
|
|
317
335
|
isMobile: s
|
|
318
336
|
};
|
|
319
|
-
},
|
|
320
|
-
|
|
337
|
+
}, E = (e = {}) => T(e), D = null, O = () => typeof window > "u" || typeof document > "u" ? null : D ? (D.sync(), D) : (D = T(), D), k = () => {
|
|
338
|
+
D?.destroy(), D = null;
|
|
321
339
|
};
|
|
322
340
|
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => {
|
|
323
|
-
|
|
324
|
-
}) :
|
|
341
|
+
O();
|
|
342
|
+
}) : O());
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/js/src/accordion/accordion-runtime.ts
|
|
345
|
+
var A = {
|
|
346
|
+
root: typeof document < "u" ? document : {},
|
|
347
|
+
accordionSelector: "[accordion]",
|
|
348
|
+
triggerSelector: "[accordion-item]"
|
|
349
|
+
}, j = (e) => Array.from(e), M = "juice-accordion-trigger", ee = "juice-accordion-panel", N = (e) => e instanceof HTMLButtonElement ? !0 : e instanceof HTMLAnchorElement ? e.hasAttribute("href") : !1, P = /* @__PURE__ */ new WeakSet(), F = (e) => P.has(e) ? !1 : (P.add(e), !0), te = (e) => e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "accordion", I = (e, t, n) => {
|
|
350
|
+
let r = String(n);
|
|
351
|
+
if (e.getAttribute("aria-expanded") !== r && e.setAttribute("aria-expanded", r), !t) return;
|
|
352
|
+
t.hidden !== !n && (t.hidden = !n);
|
|
353
|
+
let i = String(!n);
|
|
354
|
+
t.getAttribute("aria-hidden") !== i && t.setAttribute("aria-hidden", i);
|
|
355
|
+
}, L = (e, t) => t ? !t.hasAttribute("hidden") : e.getAttribute("aria-expanded") === "true", R = (e = {}) => {
|
|
356
|
+
if (typeof window > "u" || typeof document > "u") return {
|
|
357
|
+
destroy: () => {},
|
|
358
|
+
sync: () => {},
|
|
359
|
+
expand: () => {},
|
|
360
|
+
collapse: () => {},
|
|
361
|
+
toggle: () => {}
|
|
362
|
+
};
|
|
363
|
+
let t = {
|
|
364
|
+
...A,
|
|
365
|
+
...e
|
|
366
|
+
}, n = t.root ?? document, r = n, i = () => j(n.querySelectorAll(t.accordionSelector)), a = (e) => j(e.querySelectorAll(t.triggerSelector)).filter((n) => n.closest(t.accordionSelector) === e), o = () => i().flatMap((e) => a(e)), s = 0, c = null, l = (e) => (s += 1, `${e}-${s}`), u = (e) => {
|
|
367
|
+
if (!e) return null;
|
|
368
|
+
let n = e.closest(t.accordionSelector);
|
|
369
|
+
return n instanceof HTMLElement ? n : null;
|
|
370
|
+
}, d = (e) => {
|
|
371
|
+
let n = u(e);
|
|
372
|
+
if (!n) return null;
|
|
373
|
+
let r = e.getAttribute("aria-controls");
|
|
374
|
+
if (r) {
|
|
375
|
+
let e = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(r) : r, t = n.querySelector(`#${e}`);
|
|
376
|
+
if (t) return t;
|
|
377
|
+
}
|
|
378
|
+
let i = e.nextElementSibling;
|
|
379
|
+
for (; i;) {
|
|
380
|
+
if (i instanceof HTMLElement && !i.matches(t.triggerSelector) && !i.matches(t.accordionSelector)) return i;
|
|
381
|
+
i = i.nextElementSibling;
|
|
382
|
+
}
|
|
383
|
+
return null;
|
|
384
|
+
}, f = (e) => {
|
|
385
|
+
if (e) {
|
|
386
|
+
if (e.matches(t.triggerSelector) && u(e)) return e;
|
|
387
|
+
let n = e.closest(t.triggerSelector);
|
|
388
|
+
if (n instanceof HTMLElement && u(n)) return n;
|
|
389
|
+
}
|
|
390
|
+
return o()[0] ?? null;
|
|
391
|
+
}, p = (e) => {
|
|
392
|
+
let t = e.getAttribute("name");
|
|
393
|
+
return t ? te(t) : null;
|
|
394
|
+
}, m = (e, t) => {
|
|
395
|
+
let n = u(e);
|
|
396
|
+
if (!n) return;
|
|
397
|
+
let r = a(n), i = Math.max(0, r.indexOf(e)), o = p(n), s = r.length > 1 ? `-${i + 1}` : "";
|
|
398
|
+
e.id ||= o ? `${o}-trigger${s}` : l(M), N(e) || (e.setAttribute("role", "button"), e.hasAttribute("tabindex") || e.setAttribute("tabindex", "0")), t && (t.id ||= o ? `${o}-panel${s}` : l(ee), e.getAttribute("aria-controls") !== t.id && e.setAttribute("aria-controls", t.id), t.getAttribute("role") !== "region" && t.setAttribute("role", "region"), t.getAttribute("aria-labelledby") !== e.id && t.setAttribute("aria-labelledby", e.id));
|
|
399
|
+
}, h = (e) => {
|
|
400
|
+
let t = f(e);
|
|
401
|
+
if (!t) return;
|
|
402
|
+
let n = d(t);
|
|
403
|
+
m(t, n), I(t, n, !0), c = t;
|
|
404
|
+
}, g = (e) => {
|
|
405
|
+
let t = f(e);
|
|
406
|
+
if (!t) return;
|
|
407
|
+
let n = d(t);
|
|
408
|
+
m(t, n), I(t, n, !1), t === c && (c = o().find((e) => e !== t && L(e, d(e))) ?? null);
|
|
409
|
+
}, _ = (e) => {
|
|
410
|
+
let t = f(e);
|
|
411
|
+
if (t) {
|
|
412
|
+
if (L(t, d(t))) {
|
|
413
|
+
g(t);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
h(t);
|
|
417
|
+
}
|
|
418
|
+
}, v = () => {
|
|
419
|
+
i().forEach((e) => {
|
|
420
|
+
a(e).forEach((e) => {
|
|
421
|
+
let t = d(e);
|
|
422
|
+
if (m(e, t), t) {
|
|
423
|
+
I(e, t, L(e, t));
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
e.hasAttribute("aria-expanded") || e.setAttribute("aria-expanded", "false");
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
}, y = (e) => {
|
|
430
|
+
let n = e.target;
|
|
431
|
+
if (!(n instanceof Element)) return;
|
|
432
|
+
let r = n.closest(t.triggerSelector);
|
|
433
|
+
!(r instanceof HTMLElement) || !u(r) || F(e) && _(r);
|
|
434
|
+
}, b = (e) => {
|
|
435
|
+
let n = e.closest(t.triggerSelector);
|
|
436
|
+
return n instanceof HTMLElement && u(n) && L(n, d(n)) ? n : o().filter((e) => L(e, d(e))).find((t) => d(t)?.contains(e)) || (c && u(c) && L(c, d(c)) ? c : null);
|
|
437
|
+
}, x = (e) => {
|
|
438
|
+
if (!(e instanceof KeyboardEvent)) return;
|
|
439
|
+
let n = e.target;
|
|
440
|
+
if (!(n instanceof Element)) return;
|
|
441
|
+
if (e.key === "Escape") {
|
|
442
|
+
let t = b(n);
|
|
443
|
+
if (!t || !F(e)) return;
|
|
444
|
+
e.preventDefault(), g(t), t.focus();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
448
|
+
let r = n.closest(t.triggerSelector);
|
|
449
|
+
!(r instanceof HTMLElement) || !u(r) || N(r) || F(e) && (e.preventDefault(), _(r));
|
|
450
|
+
}, S = !1, C = () => {
|
|
451
|
+
S || (S = !0, requestAnimationFrame(() => {
|
|
452
|
+
S = !1, v();
|
|
453
|
+
}));
|
|
454
|
+
}, w = typeof MutationObserver < "u" ? new MutationObserver(() => C()) : null;
|
|
455
|
+
return r.addEventListener("click", y), r.addEventListener("keydown", x), w && n instanceof Node && w.observe(n, {
|
|
456
|
+
childList: !0,
|
|
457
|
+
subtree: !0,
|
|
458
|
+
attributes: !0,
|
|
459
|
+
attributeFilter: [
|
|
460
|
+
"hidden",
|
|
461
|
+
"aria-expanded",
|
|
462
|
+
"aria-controls",
|
|
463
|
+
"accordion",
|
|
464
|
+
"accordion-item"
|
|
465
|
+
]
|
|
466
|
+
}), v(), {
|
|
467
|
+
destroy: () => {
|
|
468
|
+
r.removeEventListener("click", y), r.removeEventListener("keydown", x), w?.disconnect();
|
|
469
|
+
},
|
|
470
|
+
sync: v,
|
|
471
|
+
expand: h,
|
|
472
|
+
collapse: g,
|
|
473
|
+
toggle: _
|
|
474
|
+
};
|
|
475
|
+
}, ne = (e = {}) => R(e), z = null, B = !1, V = null, H = () => {
|
|
476
|
+
V &&= (document.removeEventListener("DOMContentLoaded", V), null);
|
|
477
|
+
}, U = () => typeof window > "u" || typeof document > "u" ? null : (B = !1, H(), z ? (z.sync(), z) : (z = R(), z)), re = () => {
|
|
478
|
+
B = !0, H(), z?.destroy(), z = null;
|
|
479
|
+
};
|
|
480
|
+
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (V = () => {
|
|
481
|
+
V = null, B || U();
|
|
482
|
+
}, document.addEventListener("DOMContentLoaded", V)) : U());
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/js/src/tabs/tabs-runtime.ts
|
|
485
|
+
var ie = {
|
|
486
|
+
root: typeof document < "u" ? document : {},
|
|
487
|
+
tabsSelector: "[tabs]",
|
|
488
|
+
listSelector: "[tabs-list]",
|
|
489
|
+
triggerSelector: "[tab]",
|
|
490
|
+
panelSelector: "[tab-panel]"
|
|
491
|
+
}, W = (e) => Array.from(e), ae = "juice-tabs-trigger", oe = "juice-tabs-panel", G = /* @__PURE__ */ new WeakSet(), K = (e) => G.has(e) ? !1 : (G.add(e), !0), q = (e) => e instanceof HTMLButtonElement ? !0 : e instanceof HTMLAnchorElement ? e.hasAttribute("href") : !1, se = (e) => e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "tabs", ce = (e) => e instanceof HTMLElement ? e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? !0 : e.isContentEditable : !1, le = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e, J = (e = {}) => {
|
|
492
|
+
if (typeof window > "u" || typeof document > "u") return {
|
|
493
|
+
destroy: () => {},
|
|
494
|
+
sync: () => {},
|
|
495
|
+
select: () => {}
|
|
496
|
+
};
|
|
497
|
+
let t = {
|
|
498
|
+
...ie,
|
|
499
|
+
...e
|
|
500
|
+
}, n = t.root ?? document, r = n, i = () => W(n.querySelectorAll(t.tabsSelector)), a = (e) => {
|
|
501
|
+
let n = e.querySelector(`:scope > ${t.listSelector}`);
|
|
502
|
+
return n instanceof HTMLElement ? n : null;
|
|
503
|
+
}, o = (e) => {
|
|
504
|
+
if (!e) return null;
|
|
505
|
+
let n = e.closest(t.tabsSelector);
|
|
506
|
+
return n instanceof HTMLElement ? n : null;
|
|
507
|
+
}, s = (e) => {
|
|
508
|
+
let n = e.closest(t.panelSelector);
|
|
509
|
+
if (!(n instanceof HTMLElement)) return !1;
|
|
510
|
+
let r = o(e);
|
|
511
|
+
return !!(r && r.contains(n));
|
|
512
|
+
}, c = (e, n) => {
|
|
513
|
+
if (o(e) !== n || s(e)) return !1;
|
|
514
|
+
let r = a(n) ?? n;
|
|
515
|
+
return e.matches(t.triggerSelector) || e.getAttribute("role") === "tab" ? r.contains(e) : e.tagName === "BUTTON" && e.parentElement === r;
|
|
516
|
+
}, l = (e) => {
|
|
517
|
+
let n = a(e) ?? e, r = /* @__PURE__ */ new Set(), i = [], o = (t) => {
|
|
518
|
+
t instanceof HTMLElement && (!c(t, e) || r.has(t) || (r.add(t), i.push(t)));
|
|
519
|
+
};
|
|
520
|
+
return W(n.children).forEach(o), W(n.querySelectorAll(t.triggerSelector)).forEach(o), W(n.querySelectorAll("[role=\"tab\"]")).forEach(o), i.sort((e, t) => {
|
|
521
|
+
let n = e.compareDocumentPosition(t);
|
|
522
|
+
return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
|
|
523
|
+
});
|
|
524
|
+
}, u = (e) => W(e.querySelectorAll(t.panelSelector)).filter((t) => o(t) === e), d = () => i().flatMap((e) => l(e)), f = 0, p = (e) => (f += 1, `${e}-${f}`), m = (e) => {
|
|
525
|
+
let n = o(e);
|
|
526
|
+
if (!n) return null;
|
|
527
|
+
let r = e.getAttribute("aria-controls");
|
|
528
|
+
if (r) {
|
|
529
|
+
let e = n.querySelector(`#${le(r)}`);
|
|
530
|
+
if (e && e.matches(t.panelSelector) && o(e) === n) return e;
|
|
531
|
+
}
|
|
532
|
+
let i = l(n), a = u(n), s = i.indexOf(e);
|
|
533
|
+
if (s >= 0 && a[s]) return a[s];
|
|
534
|
+
let d = e.nextElementSibling;
|
|
535
|
+
for (; d;) {
|
|
536
|
+
if (d instanceof HTMLElement && d.matches(t.panelSelector) && o(d) === n) return d;
|
|
537
|
+
if (d instanceof HTMLElement && c(d, n)) break;
|
|
538
|
+
d = d.nextElementSibling;
|
|
539
|
+
}
|
|
540
|
+
return null;
|
|
541
|
+
}, h = (e) => {
|
|
542
|
+
if (e) {
|
|
543
|
+
let n = o(e);
|
|
544
|
+
if (n && c(e, n)) return e;
|
|
545
|
+
let r = e.closest(t.triggerSelector);
|
|
546
|
+
if (r instanceof HTMLElement) {
|
|
547
|
+
let e = o(r);
|
|
548
|
+
if (e && c(r, e)) return r;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return d()[0] ?? null;
|
|
552
|
+
}, g = (e) => {
|
|
553
|
+
let t = e.getAttribute("name");
|
|
554
|
+
return t ? se(t) : null;
|
|
555
|
+
}, _ = (e) => {
|
|
556
|
+
let t = a(e), n = u(e), r = t ?? (n.length === 0 ? e : null);
|
|
557
|
+
if (!r) return;
|
|
558
|
+
r.getAttribute("role") !== "tablist" && r.setAttribute("role", "tablist");
|
|
559
|
+
let i = e.getAttribute("name");
|
|
560
|
+
i && !r.hasAttribute("aria-label") && !r.hasAttribute("aria-labelledby") && r.setAttribute("aria-label", i);
|
|
561
|
+
}, v = (e, t) => {
|
|
562
|
+
let n = o(e);
|
|
563
|
+
if (!n) return;
|
|
564
|
+
_(n);
|
|
565
|
+
let r = l(n), i = Math.max(0, r.indexOf(e)), a = g(n), s = r.length > 1 ? `-${i + 1}` : "";
|
|
566
|
+
e.id ||= a ? `${a}-tab${s}` : p(ae), e.getAttribute("role") !== "tab" && e.setAttribute("role", "tab"), !q(e) && !e.hasAttribute("tabindex") && e.setAttribute("tabindex", "-1"), t && (t.id ||= a ? `${a}-panel${s}` : p(oe), e.getAttribute("aria-controls") !== t.id && e.setAttribute("aria-controls", t.id), t.getAttribute("role") !== "tabpanel" && t.setAttribute("role", "tabpanel"), t.getAttribute("aria-labelledby") !== e.id && t.setAttribute("aria-labelledby", e.id));
|
|
567
|
+
}, y = (e) => e.hasAttribute("active") || e.getAttribute("aria-selected") === "true", b = (e, t, n) => {
|
|
568
|
+
n ? e.hasAttribute("active") || e.setAttribute("active", "") : e.hasAttribute("active") && e.removeAttribute("active");
|
|
569
|
+
let r = String(n);
|
|
570
|
+
e.getAttribute("aria-selected") !== r && e.setAttribute("aria-selected", r);
|
|
571
|
+
let i = n ? "0" : "-1";
|
|
572
|
+
if (e.getAttribute("tabindex") !== i && e.setAttribute("tabindex", i), !t) return;
|
|
573
|
+
t.hidden !== !n && (t.hidden = !n);
|
|
574
|
+
let a = String(!n);
|
|
575
|
+
t.getAttribute("aria-hidden") !== a && t.setAttribute("aria-hidden", a), n ? t.getAttribute("tabindex") !== "0" && t.setAttribute("tabindex", "0") : t.hasAttribute("tabindex") && t.removeAttribute("tabindex");
|
|
576
|
+
}, x = (e, t) => {
|
|
577
|
+
let n = l(e), r = u(e), i = m(t);
|
|
578
|
+
n.forEach((e) => {
|
|
579
|
+
let n = m(e);
|
|
580
|
+
v(e, n), b(e, n, e === t);
|
|
581
|
+
}), r.forEach((e) => {
|
|
582
|
+
e !== i && (e.hidden ||= !0, e.getAttribute("aria-hidden") !== "true" && e.setAttribute("aria-hidden", "true"), e.hasAttribute("tabindex") && e.removeAttribute("tabindex"));
|
|
583
|
+
});
|
|
584
|
+
}, S = (e) => {
|
|
585
|
+
let t = h(e);
|
|
586
|
+
if (!t) return;
|
|
587
|
+
let n = o(t);
|
|
588
|
+
n && x(n, t);
|
|
589
|
+
}, C = (e) => {
|
|
590
|
+
let t = l(e);
|
|
591
|
+
return t.length === 0 ? null : t.find((e) => y(e)) ?? t[0];
|
|
592
|
+
}, w = () => {
|
|
593
|
+
i().forEach((e) => {
|
|
594
|
+
if (l(e).length === 0) {
|
|
595
|
+
_(e);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
let t = C(e);
|
|
599
|
+
t && x(e, t);
|
|
600
|
+
});
|
|
601
|
+
}, T = (e) => {
|
|
602
|
+
if (!(e instanceof HTMLElement)) return null;
|
|
603
|
+
let n = o(e);
|
|
604
|
+
if (!n) return null;
|
|
605
|
+
if (c(e, n)) return e;
|
|
606
|
+
let r = e.closest(`${t.triggerSelector}, [role="tab"], ${t.tabsSelector} > button, ${t.listSelector} > button`);
|
|
607
|
+
return r instanceof HTMLElement && c(r, n) ? r : null;
|
|
608
|
+
}, E = (e) => {
|
|
609
|
+
let t = e.target;
|
|
610
|
+
if (!(t instanceof Element)) return;
|
|
611
|
+
let n = T(t);
|
|
612
|
+
n && K(e) && S(n);
|
|
613
|
+
}, D = (e, t) => {
|
|
614
|
+
let n = o(e);
|
|
615
|
+
if (!n) return;
|
|
616
|
+
let r = l(n);
|
|
617
|
+
if (r.length === 0) return;
|
|
618
|
+
let i = r[t(Math.max(0, r.indexOf(e)), r.length)];
|
|
619
|
+
i && (S(i), i.focus());
|
|
620
|
+
}, O = (e) => {
|
|
621
|
+
if (!(e instanceof KeyboardEvent)) return;
|
|
622
|
+
let t = e.target;
|
|
623
|
+
if (!(t instanceof Element) || ce(t)) return;
|
|
624
|
+
let n = T(t);
|
|
625
|
+
if (n && !(e.key === "Escape" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
626
|
+
if (e.key === "ArrowRight") {
|
|
627
|
+
if (!K(e)) return;
|
|
628
|
+
e.preventDefault(), D(n, (e, t) => (e + 1) % t);
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (e.key === "ArrowLeft") {
|
|
632
|
+
if (!K(e)) return;
|
|
633
|
+
e.preventDefault(), D(n, (e, t) => (e - 1 + t) % t);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (e.key === "Home") {
|
|
637
|
+
if (!K(e)) return;
|
|
638
|
+
e.preventDefault(), D(n, () => 0);
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
if (e.key === "End") {
|
|
642
|
+
if (!K(e)) return;
|
|
643
|
+
e.preventDefault(), D(n, (e, t) => t - 1);
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
e.key !== "Enter" && e.key !== " " || q(n) || K(e) && (e.preventDefault(), S(n));
|
|
647
|
+
}
|
|
648
|
+
}, k = !1, A = () => {
|
|
649
|
+
k || (k = !0, requestAnimationFrame(() => {
|
|
650
|
+
k = !1, w();
|
|
651
|
+
}));
|
|
652
|
+
}, j = typeof MutationObserver < "u" ? new MutationObserver(() => A()) : null;
|
|
653
|
+
return r.addEventListener("click", E), r.addEventListener("keydown", O), j && n instanceof Node && j.observe(n, {
|
|
654
|
+
childList: !0,
|
|
655
|
+
subtree: !0,
|
|
656
|
+
attributes: !0,
|
|
657
|
+
attributeFilter: [
|
|
658
|
+
"hidden",
|
|
659
|
+
"active",
|
|
660
|
+
"aria-selected",
|
|
661
|
+
"aria-controls",
|
|
662
|
+
"tabs",
|
|
663
|
+
"tabs-list",
|
|
664
|
+
"tab",
|
|
665
|
+
"tab-panel"
|
|
666
|
+
]
|
|
667
|
+
}), w(), {
|
|
668
|
+
destroy: () => {
|
|
669
|
+
r.removeEventListener("click", E), r.removeEventListener("keydown", O), j?.disconnect();
|
|
670
|
+
},
|
|
671
|
+
sync: w,
|
|
672
|
+
select: S
|
|
673
|
+
};
|
|
674
|
+
}, ue = (e = {}) => J(e), Y = null, X = !1, Z = null, Q = () => {
|
|
675
|
+
Z &&= (document.removeEventListener("DOMContentLoaded", Z), null);
|
|
676
|
+
}, $ = () => typeof window > "u" || typeof document > "u" ? null : (X = !1, Q(), Y ? (Y.sync(), Y) : (Y = J(), Y)), de = () => {
|
|
677
|
+
X = !0, Q(), Y?.destroy(), Y = null;
|
|
678
|
+
};
|
|
679
|
+
typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? (Z = () => {
|
|
680
|
+
Z = null, X || $();
|
|
681
|
+
}, document.addEventListener("DOMContentLoaded", Z)) : $());
|
|
325
682
|
//#endregion
|
|
326
683
|
//#region src/tokens/index.ts
|
|
327
|
-
var
|
|
684
|
+
var fe = {
|
|
328
685
|
colors: {
|
|
329
686
|
families: [
|
|
330
687
|
"black",
|
|
@@ -336,6 +693,7 @@ var O = {
|
|
|
336
693
|
"pink",
|
|
337
694
|
"purple",
|
|
338
695
|
"red",
|
|
696
|
+
"teal",
|
|
339
697
|
"white",
|
|
340
698
|
"yellow"
|
|
341
699
|
],
|
|
@@ -447,6 +805,21 @@ var O = {
|
|
|
447
805
|
800: "hsl(0, 100%, 60%);",
|
|
448
806
|
900: "hsl(0, 100%, 55%);"
|
|
449
807
|
} }.red,
|
|
808
|
+
teal: { teal: {
|
|
809
|
+
100: "hsl(174, 55%, 94%)",
|
|
810
|
+
200: "hsl(174, 58%, 84%)",
|
|
811
|
+
300: "hsl(174, 62%, 72%)",
|
|
812
|
+
400: "hsl(174, 64%, 62%)",
|
|
813
|
+
500: "hsl(174, 65%, 54%)",
|
|
814
|
+
600: "hsl(174, 62%, 42%)",
|
|
815
|
+
700: "hsl(174, 58%, 32%)",
|
|
816
|
+
800: "hsl(174, 52%, 22%)",
|
|
817
|
+
900: "hsl(174, 48%, 14%)",
|
|
818
|
+
swatches: {
|
|
819
|
+
source: "/swatch",
|
|
820
|
+
colors: ["Lagoon"]
|
|
821
|
+
}
|
|
822
|
+
} }.teal,
|
|
450
823
|
white: { white: {
|
|
451
824
|
100: "hsl(0deg, 0%, 100%);",
|
|
452
825
|
200: "hsl(0deg, 0%, 95%);",
|
|
@@ -476,4 +849,4 @@ var O = {
|
|
|
476
849
|
themes: {}
|
|
477
850
|
};
|
|
478
851
|
//#endregion
|
|
479
|
-
export {
|
|
852
|
+
export { v as Accordion, R as createAccordion, T as createNavigation, J as createTabs, ne as initAccordion, E as initNavigation, ue as initTabs, U as startAccordionRuntime, O as startNavigationRuntime, $ as startTabsRuntime, re as stopAccordionRuntime, k as stopNavigationRuntime, de as stopTabsRuntime, fe as tokens };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createNavigation, initNavigation, startNavigationRuntime, stopNavigationRuntime } from "./src/nav/navigation.js";
|
|
2
|
+
export type { NavigationController, NavigationOptions } from "./src/nav/navigation.js";
|
|
3
|
+
export { createAccordion, initAccordion, startAccordionRuntime, stopAccordionRuntime } from "./src/accordion/accordion-runtime.js";
|
|
4
|
+
export type { AccordionController, AccordionOptions } from "./src/accordion/accordion-runtime.js";
|
|
5
|
+
export { createTabs, initTabs, startTabsRuntime, stopTabsRuntime } from "./src/tabs/tabs-runtime.js";
|
|
6
|
+
export type { TabsController, TabsOptions } from "./src/tabs/tabs-runtime.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type AccordionOptions = {
|
|
2
|
+
root?: ParentNode;
|
|
3
|
+
accordionSelector?: string;
|
|
4
|
+
triggerSelector?: string;
|
|
5
|
+
};
|
|
6
|
+
export type AccordionController = {
|
|
7
|
+
destroy: () => void;
|
|
8
|
+
sync: () => void;
|
|
9
|
+
expand: (trigger?: HTMLElement | null) => void;
|
|
10
|
+
collapse: (trigger?: HTMLElement | null) => void;
|
|
11
|
+
toggle: (trigger?: HTMLElement | null) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const createAccordion: (options?: AccordionOptions) => AccordionController;
|
|
14
|
+
export declare const initAccordion: (options?: AccordionOptions) => AccordionController;
|
|
15
|
+
export declare const startAccordionRuntime: () => AccordionController | null;
|
|
16
|
+
export declare const stopAccordionRuntime: () => void;
|