@mortenbrudvik/waveui 0.12.0 → 0.14.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.
Files changed (174) hide show
  1. package/README.md +362 -60
  2. package/dist/components/data-display/Avatar.cjs +1 -1
  3. package/dist/components/data-display/Avatar.cjs.map +1 -1
  4. package/dist/components/data-display/Avatar.colors.cjs +2 -0
  5. package/dist/components/data-display/Avatar.colors.cjs.map +1 -0
  6. package/dist/components/data-display/Avatar.colors.mjs +45 -0
  7. package/dist/components/data-display/Avatar.colors.mjs.map +1 -0
  8. package/dist/components/data-display/Avatar.context.cjs +1 -1
  9. package/dist/components/data-display/Avatar.context.cjs.map +1 -1
  10. package/dist/components/data-display/Avatar.context.mjs +4 -2
  11. package/dist/components/data-display/Avatar.context.mjs.map +1 -1
  12. package/dist/components/data-display/Avatar.mjs +103 -96
  13. package/dist/components/data-display/Avatar.mjs.map +1 -1
  14. package/dist/components/data-display/Avatar.sizes.cjs +2 -0
  15. package/dist/components/data-display/Avatar.sizes.cjs.map +1 -0
  16. package/dist/components/data-display/Avatar.sizes.mjs +41 -0
  17. package/dist/components/data-display/Avatar.sizes.mjs.map +1 -0
  18. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  19. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  20. package/dist/components/data-display/AvatarGroup.context.cjs +2 -0
  21. package/dist/components/data-display/AvatarGroup.context.cjs.map +1 -0
  22. package/dist/components/data-display/AvatarGroup.context.mjs +9 -0
  23. package/dist/components/data-display/AvatarGroup.context.mjs.map +1 -0
  24. package/dist/components/data-display/AvatarGroup.mjs +65 -122
  25. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  26. package/dist/components/data-display/AvatarGroup.partition.cjs +2 -0
  27. package/dist/components/data-display/AvatarGroup.partition.cjs.map +1 -0
  28. package/dist/components/data-display/AvatarGroup.partition.mjs +14 -0
  29. package/dist/components/data-display/AvatarGroup.partition.mjs.map +1 -0
  30. package/dist/components/data-display/AvatarGroup.parts.cjs +2 -0
  31. package/dist/components/data-display/AvatarGroup.parts.cjs.map +1 -0
  32. package/dist/components/data-display/AvatarGroup.parts.mjs +178 -0
  33. package/dist/components/data-display/AvatarGroup.parts.mjs.map +1 -0
  34. package/dist/components/data-display/InteractionTag.cjs +1 -1
  35. package/dist/components/data-display/InteractionTag.cjs.map +1 -1
  36. package/dist/components/data-display/InteractionTag.mjs +36 -33
  37. package/dist/components/data-display/InteractionTag.mjs.map +1 -1
  38. package/dist/components/data-display/List.cjs +1 -1
  39. package/dist/components/data-display/List.cjs.map +1 -1
  40. package/dist/components/data-display/List.mjs +245 -195
  41. package/dist/components/data-display/List.mjs.map +1 -1
  42. package/dist/components/data-display/List.registry.cjs.map +1 -1
  43. package/dist/components/data-display/List.registry.mjs.map +1 -1
  44. package/dist/components/data-display/Persona.cjs +1 -1
  45. package/dist/components/data-display/Persona.cjs.map +1 -1
  46. package/dist/components/data-display/Persona.mjs +96 -37
  47. package/dist/components/data-display/Persona.mjs.map +1 -1
  48. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  49. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  50. package/dist/components/data-display/PresenceBadge.mjs +42 -28
  51. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  52. package/dist/components/data-display/Tag.cjs +1 -1
  53. package/dist/components/data-display/Tag.cjs.map +1 -1
  54. package/dist/components/data-display/Tag.mjs +111 -108
  55. package/dist/components/data-display/Tag.mjs.map +1 -1
  56. package/dist/components/layout/Card.cjs +1 -1
  57. package/dist/components/layout/Card.cjs.map +1 -1
  58. package/dist/components/layout/Card.context.cjs +2 -0
  59. package/dist/components/layout/Card.context.cjs.map +1 -0
  60. package/dist/components/layout/Card.context.mjs +14 -0
  61. package/dist/components/layout/Card.context.mjs.map +1 -0
  62. package/dist/components/layout/Card.mjs +138 -92
  63. package/dist/components/layout/Card.mjs.map +1 -1
  64. package/dist/components/layout/Card.preview.cjs +2 -0
  65. package/dist/components/layout/Card.preview.cjs.map +1 -0
  66. package/dist/components/layout/Card.preview.mjs +22 -0
  67. package/dist/components/layout/Card.preview.mjs.map +1 -0
  68. package/dist/components/layout/Carousel.button.cjs +2 -0
  69. package/dist/components/layout/Carousel.button.cjs.map +1 -0
  70. package/dist/components/layout/Carousel.button.mjs +34 -0
  71. package/dist/components/layout/Carousel.button.mjs.map +1 -0
  72. package/dist/components/layout/Carousel.cjs +1 -1
  73. package/dist/components/layout/Carousel.cjs.map +1 -1
  74. package/dist/components/layout/Carousel.context.cjs +2 -0
  75. package/dist/components/layout/Carousel.context.cjs.map +1 -0
  76. package/dist/components/layout/Carousel.context.mjs +24 -0
  77. package/dist/components/layout/Carousel.context.mjs.map +1 -0
  78. package/dist/components/layout/Carousel.drag.cjs +2 -0
  79. package/dist/components/layout/Carousel.drag.cjs.map +1 -0
  80. package/dist/components/layout/Carousel.drag.mjs +79 -0
  81. package/dist/components/layout/Carousel.drag.mjs.map +1 -0
  82. package/dist/components/layout/Carousel.groups.cjs +2 -0
  83. package/dist/components/layout/Carousel.groups.cjs.map +1 -0
  84. package/dist/components/layout/Carousel.groups.mjs +23 -0
  85. package/dist/components/layout/Carousel.groups.mjs.map +1 -0
  86. package/dist/components/layout/Carousel.mjs +288 -150
  87. package/dist/components/layout/Carousel.mjs.map +1 -1
  88. package/dist/components/layout/Carousel.styles.cjs +2 -0
  89. package/dist/components/layout/Carousel.styles.cjs.map +1 -0
  90. package/dist/components/layout/Carousel.styles.mjs +30 -0
  91. package/dist/components/layout/Carousel.styles.mjs.map +1 -0
  92. package/dist/components/layout/Overflow.cjs +1 -1
  93. package/dist/components/layout/Overflow.cjs.map +1 -1
  94. package/dist/components/layout/Overflow.mjs +240 -192
  95. package/dist/components/layout/Overflow.mjs.map +1 -1
  96. package/dist/components/layout/Overflow.store.cjs +2 -0
  97. package/dist/components/layout/Overflow.store.cjs.map +1 -0
  98. package/dist/components/layout/Overflow.store.mjs +209 -0
  99. package/dist/components/layout/Overflow.store.mjs.map +1 -0
  100. package/dist/components/layout/TabList.cjs +1 -1
  101. package/dist/components/layout/TabList.cjs.map +1 -1
  102. package/dist/components/layout/TabList.mjs +163 -124
  103. package/dist/components/layout/TabList.mjs.map +1 -1
  104. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  105. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  106. package/dist/components/navigation/Breadcrumb.mjs +239 -84
  107. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  108. package/dist/components/overlays/Dialog.slots.cjs +1 -1
  109. package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
  110. package/dist/components/overlays/Dialog.slots.mjs +19 -15
  111. package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
  112. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  113. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  114. package/dist/components/overlays/TeachingPopover.context.cjs +2 -0
  115. package/dist/components/overlays/TeachingPopover.context.cjs.map +1 -0
  116. package/dist/components/overlays/TeachingPopover.context.mjs +51 -0
  117. package/dist/components/overlays/TeachingPopover.context.mjs.map +1 -0
  118. package/dist/components/overlays/TeachingPopover.mjs +15 -185
  119. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  120. package/dist/components/overlays/TeachingPopover.parts.cjs +2 -0
  121. package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -0
  122. package/dist/components/overlays/TeachingPopover.parts.mjs +398 -0
  123. package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -0
  124. package/dist/components/overlays/TeachingPopover.root.cjs +2 -0
  125. package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -0
  126. package/dist/components/overlays/TeachingPopover.root.mjs +150 -0
  127. package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -0
  128. package/dist/components/overlays/TeachingPopover.stack.cjs +2 -0
  129. package/dist/components/overlays/TeachingPopover.stack.cjs.map +1 -0
  130. package/dist/components/overlays/TeachingPopover.stack.mjs +86 -0
  131. package/dist/components/overlays/TeachingPopover.stack.mjs.map +1 -0
  132. package/dist/components/table/DataGrid.cjs +1 -1
  133. package/dist/components/table/DataGrid.cjs.map +1 -1
  134. package/dist/components/table/DataGrid.mjs +540 -311
  135. package/dist/components/table/DataGrid.mjs.map +1 -1
  136. package/dist/components/table/Table.cjs +1 -1
  137. package/dist/components/table/Table.cjs.map +1 -1
  138. package/dist/components/table/Table.mjs +183 -60
  139. package/dist/components/table/Table.mjs.map +1 -1
  140. package/dist/components/table/Table.shared.cjs +2 -0
  141. package/dist/components/table/Table.shared.cjs.map +1 -0
  142. package/dist/components/table/Table.shared.mjs +65 -0
  143. package/dist/components/table/Table.shared.mjs.map +1 -0
  144. package/dist/index.cjs +1 -1
  145. package/dist/index.d.cts +2299 -213
  146. package/dist/index.d.ts +2299 -213
  147. package/dist/index.mjs +135 -127
  148. package/dist/lib/breadcrumb.cjs +2 -0
  149. package/dist/lib/breadcrumb.cjs.map +1 -0
  150. package/dist/lib/breadcrumb.mjs +26 -0
  151. package/dist/lib/breadcrumb.mjs.map +1 -0
  152. package/dist/lib/classNames.cjs +1 -1
  153. package/dist/lib/classNames.cjs.map +1 -1
  154. package/dist/lib/classNames.mjs +143 -95
  155. package/dist/lib/classNames.mjs.map +1 -1
  156. package/dist/lib/events.cjs +1 -1
  157. package/dist/lib/events.cjs.map +1 -1
  158. package/dist/lib/events.mjs +35 -8
  159. package/dist/lib/events.mjs.map +1 -1
  160. package/dist/lib/icons.cjs +1 -1
  161. package/dist/lib/icons.cjs.map +1 -1
  162. package/dist/lib/icons.mjs +34 -20
  163. package/dist/lib/icons.mjs.map +1 -1
  164. package/dist/lib/initials.cjs +2 -0
  165. package/dist/lib/initials.cjs.map +1 -0
  166. package/dist/lib/initials.mjs +21 -0
  167. package/dist/lib/initials.mjs.map +1 -0
  168. package/dist/lib/table.cjs +2 -0
  169. package/dist/lib/table.cjs.map +1 -0
  170. package/dist/lib/table.mjs +16 -0
  171. package/dist/lib/table.mjs.map +1 -0
  172. package/dist/styles.css +1 -1
  173. package/package.json +1 -1
  174. package/src/styles/tokens.css +102 -0
@@ -2,205 +2,343 @@
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
3
  import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
4
4
  import { warnOnce as r } from "../../lib/dev.mjs";
5
- import { slotRendersContent as i } from "../../lib/slot.mjs";
6
- import { composeEventHandlers as a } from "../../lib/composeEventHandlers.mjs";
7
- import { carouselClassNames as o, carouselItemClassNames as s } from "../../lib/classNames.mjs";
8
- import { useEventCallback as ee } from "../../hooks/useEventCallback.mjs";
5
+ import { renderSlot as i, slotRendersContent as a } from "../../lib/slot.mjs";
6
+ import { composeEventHandlers as o } from "../../lib/composeEventHandlers.mjs";
7
+ import { carouselClassNames as s, carouselItemClassNames as ee } from "../../lib/classNames.mjs";
8
+ import { useEventCallback as c } from "../../hooks/useEventCallback.mjs";
9
9
  import { useControllable as te } from "../../hooks/useControllable.mjs";
10
10
  import { useId as ne } from "../../hooks/useId.mjs";
11
- import { useMergedRefs as re } from "../../hooks/useMergedRefs.mjs";
12
- import { focusableDisabledProps as c, preventIfDisabled as l } from "../../lib/aria.mjs";
13
- import { usePrefersReducedMotion as ie } from "../../hooks/usePrefersReducedMotion.mjs";
14
- import { useDirection as ae } from "../../hooks/useDirection.mjs";
15
- import { disabledStyles as u, focusRing as d, forcedColors as oe } from "../../lib/styles.mjs";
16
- import { ChevronLeftIcon as se, ChevronRightIcon as ce } from "../../lib/icons.mjs";
17
- import * as f from "react";
18
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
11
+ import { getArrowIntent as re } from "../../lib/direction.mjs";
12
+ import { useRovingTabIndex as ie } from "../../hooks/useRovingTabIndex.mjs";
13
+ import { useMergedRefs as ae } from "../../hooks/useMergedRefs.mjs";
14
+ import { focusableDisabledProps as oe, preventIfDisabled as se } from "../../lib/aria.mjs";
15
+ import { usePrefersReducedMotion as ce } from "../../hooks/usePrefersReducedMotion.mjs";
16
+ import { useDirection as le } from "../../hooks/useDirection.mjs";
17
+ import { focusRing as ue, forcedColors as de } from "../../lib/styles.mjs";
18
+ import { ChevronLeftIcon as fe, ChevronRightIcon as pe } from "../../lib/icons.mjs";
19
+ import { CarouselContext as me } from "./Carousel.context.mjs";
20
+ import { CAROUSEL_CONTROL_BASE as l, CAROUSEL_CONTROL_LAYOUT as he } from "./Carousel.styles.mjs";
21
+ import { CarouselButton as ge } from "./Carousel.button.mjs";
22
+ import { useCarouselDrag as _e } from "./Carousel.drag.mjs";
23
+ import { clampToPage as ve, lastPageStart as ye, pageCount as be } from "./Carousel.groups.mjs";
24
+ import * as u from "react";
25
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
19
26
  //#region src/components/layout/Carousel.tsx
20
- var le = "Pause slide rotation", ue = "Start slide rotation", de = "Previous slide", fe = "Next slide", pe = "Choose slide", me = (e, t) => `Slide ${e + 1} of ${t}`, he = "carousel", ge = "slide";
21
- function h(e, t) {
22
- return t <= 0 || !Number.isFinite(e) ? 0 : Math.min(Math.max(Math.trunc(e), 0), t - 1);
27
+ var xe = "Pause slide rotation", Se = "Start slide rotation", Ce = "Previous slide", we = "Next slide", Te = "Choose slide", Ee = (e, t) => `Slide ${e + 1} of ${t}`, De = "carousel", Oe = "slide", ke = (e, t, n) => `Slides ${e} to ${t} of ${n}`;
28
+ function Ae(e, t, n) {
29
+ let r = u.useCallback((r) => {
30
+ if (!e || !t || typeof ResizeObserver > "u") return () => {};
31
+ let i = new ResizeObserver(r);
32
+ return i.observe(t), n && i.observe(n), () => i.disconnect();
33
+ }, [
34
+ e,
35
+ t,
36
+ n
37
+ ]), [i, a, o] = u.useSyncExternalStore(r, () => {
38
+ if (!e || !t || !n) return "1:0:0";
39
+ let r = n.offsetWidth, i = t.clientWidth;
40
+ return `${r > 0 ? Math.max(1, Math.floor(i / r)) : 1}:${r}:${i}`;
41
+ }, () => "1:0:0").split(":").map(Number);
42
+ return {
43
+ perPage: i,
44
+ slideWidth: a,
45
+ rootWidth: o
46
+ };
23
47
  }
24
- function _e(e) {
48
+ function je(e) {
25
49
  return e instanceof Element && e.closest("[data-carousel-rotation]") !== null;
26
50
  }
27
- var g = [
28
- "absolute z-10 inline-flex h-8 w-8 items-center justify-center rounded-full border border-border bg-background text-foreground shadow-2",
29
- "not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed",
30
- d,
31
- u
32
- ].join(" "), ve = () => /* @__PURE__ */ m("svg", {
51
+ function Me(e) {
52
+ return typeof e == "string" ? { src: e } : e;
53
+ }
54
+ var Ne = () => /* @__PURE__ */ f("svg", {
33
55
  width: "16",
34
56
  height: "16",
35
57
  viewBox: "0 0 16 16",
36
58
  fill: "currentColor",
37
59
  "aria-hidden": "true",
38
- children: [/* @__PURE__ */ p("rect", {
60
+ children: [/* @__PURE__ */ d("rect", {
39
61
  x: "4",
40
62
  y: "3",
41
63
  width: "3",
42
64
  height: "10",
43
65
  rx: "1"
44
- }), /* @__PURE__ */ p("rect", {
66
+ }), /* @__PURE__ */ d("rect", {
45
67
  x: "9",
46
68
  y: "3",
47
69
  width: "3",
48
70
  height: "10",
49
71
  rx: "1"
50
72
  })]
51
- }), ye = () => /* @__PURE__ */ p("svg", {
73
+ }), Pe = () => /* @__PURE__ */ d("svg", {
52
74
  width: "16",
53
75
  height: "16",
54
76
  viewBox: "0 0 16 16",
55
77
  fill: "currentColor",
56
78
  "aria-hidden": "true",
57
- children: /* @__PURE__ */ p("path", { d: "M5 3.5v9a.5.5 0 0 0 .77.42l7-4.5a.5.5 0 0 0 0-.84l-7-4.5A.5.5 0 0 0 5 3.5Z" })
58
- }), _ = ({ value: s, defaultValue: u = 0, onValueChange: _, autoPlay: y = !1, autoPlayInterval: b = 5e3, autoPlayLabels: x, labels: S, loop: C = !1, className: w, children: be, onMouseEnter: xe, onMouseLeave: Se, onFocus: Ce, onBlur: we, ref: Te, ...T }) => {
59
- let [Ee, E] = te(s, u, _), D = ne("carousel-slides"), [De, Oe] = f.useState(null), O = re(Te, Oe), ke = ae(De), k = T.dir === "rtl" || T.dir === "ltr" ? T.dir : ke, Ae = ie(), [je, A] = f.useState(null), [j, M] = f.useState(null), [Me, N] = f.useState(!1), [Ne, P] = f.useState(!1), [Pe, F] = f.useState(!1), [Fe, I] = f.useState(!1), L = [], R = !1;
60
- for (let e of t(be)) n(e.node, v) ? L.push(e) : i(e.node) && (R = !0);
61
- let z = L.length;
62
- f.useEffect(() => {
63
- R && r("Carousel:non-item-children", "Carousel: only `Carousel.Item` (`CarouselItem`) children are slides, directly or in Fragments; other children are not rendered. A component that renders `Carousel.Item` itself is not recognised: render the `Carousel.Item` in the Carousel and put the component inside it.");
64
- }, [R]);
65
- let B = h(Ee, z), V = B <= 0, H = B >= z - 1, U = z <= 1 || !C && V, W = z <= 1 || !C && H, G = j === z && !C, K = (je ?? Ae) || G, q = y && z > 1;
66
- q && !C && H && !K ? M(z) : j !== null && !G && M(null);
67
- let J = q && !K && !(Me && !Ne) && !(Pe && !Fe), Y = (e) => {
68
- e >= 0 && e < z && e !== B && E(e);
69
- }, Ie = () => Y(V ? z - 1 : B - 1), Le = () => Y(H ? 0 : B + 1), X = ee(() => {
70
- E((e) => {
71
- let t = h(e, z);
72
- return t < z - 1 ? t + 1 : C ? 0 : e;
79
+ children: /* @__PURE__ */ d("path", { d: "M5 3.5v9a.5.5 0 0 0 .77.42l7-4.5a.5.5 0 0 0 0-.84l-7-4.5A.5.5 0 0 0 5 3.5Z" })
80
+ }), p = ({ value: p, defaultValue: Fe = 0, onValueChange: Ie, autoPlay: Le = !1, autoPlayInterval: Re = 5e3, autoPlayLabels: ze, labels: h, loop: g = !1, groupSize: Be = 1, align: Ve = "start", draggable: He = !1, controlsLayout: _ = "overlay", appearance: v = "flat", className: Ue, children: We, onMouseEnter: Ge, onMouseLeave: Ke, onFocus: qe, onBlur: Je, ref: Ye, ...y }) => {
81
+ let [Xe, Ze] = te(p, Fe, Ie), b = ne("carousel-slides"), [Qe, $e] = u.useState(null), et = ae(Ye, $e), tt = le(Qe), x = y.dir === "rtl" || y.dir === "ltr" ? y.dir : tt, nt = ce(), [rt, it] = u.useState(null), [S, at] = u.useState(null), [ot, st] = u.useState(null), C = Be === "auto", w = Ae(C, ot, rt), T = C ? w.perPage : Math.max(1, Math.floor(Be) || 1), [ct, lt] = u.useState(null), [ut, E] = u.useState(null), [dt, ft] = u.useState(!1), [pt, mt] = u.useState(!1), [ht, gt] = u.useState(!1), [_t, D] = u.useState(!1), O = [], k = {}, A = !1;
82
+ for (let e of t(We)) if (n(e.node, m)) O.push({
83
+ ...e,
84
+ thumbnail: e.node.props.thumbnail
85
+ });
86
+ else if (n(e.node, ge)) {
87
+ let t = e.node.props.direction === "next" ? "next" : "previous";
88
+ k[t] ? A = !0 : k[t] = u.cloneElement(e.node, { key: e.key });
89
+ } else a(e.node) && (A = !0);
90
+ let vt = O.some((e) => e.thumbnail !== void 0), j = O.length;
91
+ u.useEffect(() => {
92
+ A && r("Carousel:non-item-children", "Carousel: only `Carousel.Item` (`CarouselItem`) children are slides, directly or in Fragments; other children are not rendered. A component that renders `Carousel.Item` itself is not recognised: render the `Carousel.Item` in the Carousel and put the component inside it.");
93
+ }, [A]);
94
+ let M = ve(Xe, T, j), N = be(j, T), P = ye(j, T), F = M <= 0, I = M >= P, L = N <= 1 || !g && F, R = N <= 1 || !g && I, yt = ut === j && !g, z = (ct ?? nt) || yt, B = Le && N > 1;
95
+ B && !g && I && !z ? E(j) : ut !== null && !yt && E(null);
96
+ let V = _e({
97
+ enabled: He && N > 1,
98
+ dir: x,
99
+ onCommit: (e) => {
100
+ e === 1 ? I ? g && U(0) : U(M + T) : e === -1 && (F ? g && U(P) : U(M - T));
101
+ }
102
+ }), bt = dt && !pt || V.dragging, H = B && !z && !bt && !(ht && !_t), U = (e) => {
103
+ e >= 0 && e < j && e !== M && Ze(e);
104
+ }, W = () => U(F ? P : M - T), G = () => U(I ? 0 : M + T), xt = c(() => {
105
+ Ze((e) => {
106
+ let t = ve(e, T, j);
107
+ return t < P ? t + T : g ? 0 : e;
73
108
  });
74
109
  });
75
- f.useEffect(() => {
76
- if (!J) return;
77
- let e = setInterval(X, b);
110
+ u.useEffect(() => {
111
+ if (!H) return;
112
+ let e = setInterval(xt, Re);
78
113
  return () => clearInterval(e);
79
114
  }, [
80
- J,
81
- b,
82
- X
115
+ H,
116
+ Re,
117
+ xt
83
118
  ]);
84
- let Re = () => {
85
- K ? (!C && H && Y(0), M(null), A(!1), I(!0)) : (A(!0), I(!1));
86
- }, Z = {
87
- onMouseEnter: a(xe, () => N(!0)),
88
- onMouseLeave: a(Se, () => N(!1)),
89
- onFocus: a(Ce, (e) => {
119
+ let St = () => {
120
+ z ? (!g && I && U(0), E(null), lt(!1), D(!0)) : (lt(!0), D(!1));
121
+ }, Ct = {
122
+ onMouseEnter: o(Ge, () => ft(!0)),
123
+ onMouseLeave: o(Ke, () => ft(!1)),
124
+ onFocus: o(qe, (e) => {
90
125
  let t = e.relatedTarget, n = !(t instanceof Node && e.currentTarget.contains(t));
91
- F(!0), (n || !_e(e.target)) && I(!1);
126
+ gt(!0), (n || !je(e.target)) && D(!1);
92
127
  }),
93
- onBlur: a(we, (e) => {
128
+ onBlur: o(Je, (e) => {
94
129
  let t = e.relatedTarget;
95
- t instanceof Node && e.currentTarget.contains(t) || (F(!1), I(!1));
130
+ t instanceof Node && e.currentTarget.contains(t) || (gt(!1), D(!1));
96
131
  })
97
- };
98
- if (z === 0) return /* @__PURE__ */ p("div", {
99
- ref: O,
100
- className: e(o.root, "relative", w),
101
- ...Z,
102
- ...T
132
+ }, K = T > 1, q = Math.min(M + T, j), wt = u.useMemo(() => K ? Array.from({ length: q - M }, (e, t) => String(M + t)) : [], [
133
+ K,
134
+ M,
135
+ q
136
+ ]), J = ie({
137
+ items: wt,
138
+ activeValue: String(M),
139
+ orientation: "horizontal",
140
+ loop: !1,
141
+ dir: x,
142
+ tabStop: "last-focused"
143
+ }), Tt = ae(J.containerProps.ref, at), Y = u.useRef(null);
144
+ u.useLayoutEffect(() => {
145
+ let e = Y.current;
146
+ if (!e || !S) return;
147
+ Y.current = null;
148
+ let t = e === "first" ? M : q - 1;
149
+ S.querySelector(`[data-roving-value="${t}"]`)?.focus();
150
+ }, [
151
+ M,
152
+ q,
153
+ S
154
+ ]);
155
+ let Et = (e) => {
156
+ let t = e.target.getAttribute("data-roving-value"), n = re(e.key, {
157
+ orientation: "horizontal",
158
+ dir: x
159
+ });
160
+ if (t !== null && n && !e.defaultPrevented && !e.altKey && !e.ctrlKey && !e.metaKey) {
161
+ let r = Number(t);
162
+ if (n === "next" && r === q - 1) {
163
+ e.preventDefault(), R || (Y.current = "first", G());
164
+ return;
165
+ }
166
+ if (n === "prev" && r === M) {
167
+ e.preventDefault(), L || (Y.current = "last", W());
168
+ return;
169
+ }
170
+ }
171
+ J.containerProps.onKeyDown(e);
172
+ }, X = h?.previous ?? Ce, Z = h?.next ?? we, Dt = c(() => W()), Ot = c(() => G()), kt = u.useMemo(() => ({
173
+ trackId: b,
174
+ previousLabel: X,
175
+ nextLabel: Z,
176
+ previousDisabled: L,
177
+ nextDisabled: R,
178
+ goPrevious: Dt,
179
+ goNext: Ot,
180
+ controlsLayout: _,
181
+ dir: x
182
+ }), [
183
+ b,
184
+ X,
185
+ Z,
186
+ L,
187
+ R,
188
+ Dt,
189
+ Ot,
190
+ _,
191
+ x
192
+ ]);
193
+ if (j === 0) return /* @__PURE__ */ d("div", {
194
+ ref: et,
195
+ "data-controls-layout": _,
196
+ "data-appearance": v,
197
+ className: e(s.root, "relative", Ue),
198
+ ...Ct,
199
+ ...y
103
200
  });
104
- let ze = (k === "rtl" ? 1 : -1) * B * 100, Q = k === "rtl" ? "-scale-x-100" : void 0, Be = x?.pause ?? le, Ve = x?.play ?? ue, He = S?.previous ?? de, Ue = S?.next ?? fe, We = S?.picker ?? pe, $ = S?.slide ?? me, Ge = S?.carouselRoleDescription ?? he, Ke = S?.slideRoleDescription ?? ge;
105
- return /* @__PURE__ */ m("div", {
106
- ref: O,
107
- role: "region",
108
- "aria-roledescription": Ge,
109
- "aria-label": "Carousel",
110
- className: e(o.root, "relative isolate overflow-hidden", w),
111
- ...Z,
112
- ...T,
201
+ let Q = x === "rtl" ? 1 : -1, At = `translateX(${M / T * Q * 100}%)`;
202
+ if (V.offsetPx !== 0 && (At = `translateX(calc(${M / T * Q * 100}% + ${V.offsetPx}px))`), C) {
203
+ let e = Math.max(0, w.rootWidth - T * w.slideWidth), t = Ve === "center" ? e / 2 : Ve === "end" ? e : 0;
204
+ At = `translateX(${Q * M * w.slideWidth + (x === "rtl" ? -t : t) + V.offsetPx + 0}px)`;
205
+ }
206
+ let jt = h?.slides ?? ke, Mt = (e) => {
207
+ let t = Math.min(e + T, j);
208
+ return t - e === 1 ? Lt(e, j) : jt(e + 1, t, j);
209
+ }, Nt = x === "rtl" ? "-scale-x-100" : void 0, Pt = ze?.pause ?? xe, Ft = ze?.play ?? Se, It = h?.picker ?? Te, Lt = h?.slide ?? Ee, Rt = h?.carouselRoleDescription ?? De, zt = h?.slideRoleDescription ?? Oe, $ = _ === "inline" || _ === "inline-wide", Bt = he[_], Vt = k.previous ?? /* @__PURE__ */ d("button", {
210
+ type: "button",
211
+ "aria-label": X,
212
+ "aria-controls": b,
213
+ ...oe(L),
214
+ onClick: se(L, W),
215
+ className: e(s.previousButton, l, Bt.previous),
216
+ children: /* @__PURE__ */ d(fe, {
217
+ size: 16,
218
+ className: Nt
219
+ })
220
+ }, "previous"), Ht = k.next ?? /* @__PURE__ */ d("button", {
221
+ type: "button",
222
+ "aria-label": Z,
223
+ "aria-controls": b,
224
+ ...oe(R),
225
+ onClick: se(R, G),
226
+ className: e(s.nextButton, l, Bt.next),
227
+ children: /* @__PURE__ */ d(pe, {
228
+ size: 16,
229
+ className: Nt
230
+ })
231
+ }, "next"), Ut = /* @__PURE__ */ f("div", {
232
+ ref: st,
233
+ className: e(s.viewport, "relative min-w-0 flex-1 overflow-hidden"),
113
234
  children: [
114
- q && /* @__PURE__ */ p("button", {
115
- type: "button",
116
- "data-carousel-rotation": "",
117
- "aria-label": K ? Ve : Be,
118
- "aria-controls": D,
119
- onClick: Re,
120
- onMouseEnter: () => P(!0),
121
- onMouseLeave: () => P(!1),
122
- className: e(o.autoPlayButton, g, "top-2 start-2"),
123
- children: p(K ? ye : ve, {})
124
- }),
125
- /* @__PURE__ */ p("div", {
126
- id: D,
127
- className: e(o.track, "flex transition-transform duration-300 ease-in-out motion-reduce:transition-none"),
128
- style: { transform: `translateX(${ze}%)` },
129
- children: L.map(({ key: t, node: n }, r) => {
130
- let i = r === B;
131
- return /* @__PURE__ */ p("div", {
235
+ /* @__PURE__ */ d("div", {
236
+ id: b,
237
+ className: e(s.track, V.dragging ? "flex" : "flex transition-transform duration-300 ease-in-out motion-reduce:transition-none", He && "touch-pan-y"),
238
+ style: { transform: At },
239
+ "data-dragging": V.dragging ? "" : void 0,
240
+ ...V.handlers,
241
+ ...K ? J.containerProps : null,
242
+ ref: K ? Tt : at,
243
+ onKeyDown: K ? Et : void 0,
244
+ children: O.map(({ key: t, node: n }, r) => {
245
+ let i = r >= M && r < M + T;
246
+ return /* @__PURE__ */ d("div", {
247
+ ref: r === 0 ? it : void 0,
132
248
  role: "group",
133
- "aria-roledescription": Ke,
134
- "aria-label": $(r, z),
249
+ "aria-roledescription": zt,
250
+ "aria-label": Lt(r, j),
135
251
  "aria-hidden": !i || void 0,
136
252
  inert: !i,
137
- className: e(o.slide, "w-full shrink-0"),
253
+ "data-roving-value": K && i ? String(r) : void 0,
254
+ tabIndex: K && i ? J.getTabIndex(String(r)) : void 0,
255
+ className: e(s.slide, C ? "w-auto shrink-0" : T === 1 ? "w-full shrink-0" : "shrink-0", K && "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"),
256
+ style: !C && T > 1 ? { width: `calc(100% / ${T})` } : void 0,
138
257
  children: n
139
258
  }, t);
140
259
  })
141
260
  }),
142
- /* @__PURE__ */ p("div", {
143
- "aria-live": J ? "off" : "polite",
144
- "aria-atomic": "true",
145
- className: "sr-only",
146
- children: $(B, z)
147
- }),
148
- /* @__PURE__ */ p("button", {
149
- type: "button",
150
- "aria-label": He,
151
- "aria-controls": D,
152
- ...c(U),
153
- onClick: l(U, Ie),
154
- className: e(o.previousButton, g, "top-1/2 start-2 -translate-y-1/2"),
155
- children: /* @__PURE__ */ p(se, {
156
- size: 16,
157
- className: Q
158
- })
159
- }),
160
- /* @__PURE__ */ p("button", {
161
- type: "button",
162
- "aria-label": Ue,
163
- "aria-controls": D,
164
- ...c(W),
165
- onClick: l(W, Le),
166
- className: e(o.nextButton, g, "top-1/2 end-2 -translate-y-1/2"),
167
- children: /* @__PURE__ */ p(ce, {
168
- size: 16,
169
- className: Q
170
- })
171
- }),
172
- /* @__PURE__ */ p("div", {
173
- role: "group",
174
- "aria-label": We,
175
- className: e(o.picker, "absolute inset-x-0 bottom-1 z-10 mx-auto flex w-fit"),
176
- children: L.map(({ key: t }, n) => {
177
- let r = n === B;
178
- return /* @__PURE__ */ p("button", {
179
- type: "button",
180
- "aria-label": $(n, z),
181
- "aria-current": r ? "true" : void 0,
182
- onClick: () => Y(n),
183
- className: e(o.pickerButton, "group inline-flex h-6 min-w-6 items-center justify-center", d),
184
- children: /* @__PURE__ */ p("span", {
185
- "aria-hidden": "true",
186
- className: e(o.pickerIndicator, "block h-2 rounded-full transition-[width,background-color] duration-200 motion-reduce:transition-none", r ? e("w-5 bg-primary", oe.selectedLeaf) : "w-2 bg-stroke-accessible group-hover:bg-foreground forced-colors:bg-[ButtonText] forced-colors:forced-color-adjust-none")
187
- })
188
- }, t);
189
- })
190
- })
261
+ !$ && Vt,
262
+ !$ && Ht
191
263
  ]
192
264
  });
265
+ return /* @__PURE__ */ d(me.Provider, {
266
+ value: kt,
267
+ children: /* @__PURE__ */ f("div", {
268
+ ref: et,
269
+ role: "region",
270
+ "aria-roledescription": Rt,
271
+ "aria-label": "Carousel",
272
+ "data-controls-layout": _,
273
+ "data-appearance": v,
274
+ className: e(s.root, "relative isolate overflow-hidden", v === "elevated" && "rounded-md shadow-4", Ue),
275
+ ...Ct,
276
+ ...y,
277
+ children: [
278
+ B && /* @__PURE__ */ d("button", {
279
+ type: "button",
280
+ "data-carousel-rotation": "",
281
+ "aria-label": z ? Ft : Pt,
282
+ "aria-controls": b,
283
+ onClick: St,
284
+ onMouseEnter: () => mt(!0),
285
+ onMouseLeave: () => mt(!1),
286
+ className: e(s.autoPlayButton, l, "absolute z-20 h-8 w-8 rounded-full border border-border bg-background shadow-2 top-2", $ ? "start-12" : "start-2"),
287
+ children: d(z ? Pe : Ne, {})
288
+ }),
289
+ $ ? /* @__PURE__ */ f("div", {
290
+ className: "flex items-stretch",
291
+ children: [
292
+ Vt,
293
+ Ut,
294
+ Ht
295
+ ]
296
+ }) : Ut,
297
+ /* @__PURE__ */ d("div", {
298
+ "aria-live": H ? "off" : "polite",
299
+ "aria-atomic": "true",
300
+ className: "sr-only",
301
+ children: Mt(M)
302
+ }),
303
+ /* @__PURE__ */ d("div", {
304
+ role: "group",
305
+ "aria-label": It,
306
+ className: e(s.picker, vt ? "relative mx-auto flex w-fit flex-wrap justify-center gap-2 p-2" : "absolute inset-x-0 bottom-1 z-10 mx-auto flex w-fit"),
307
+ children: O.filter((e, t) => t % T === 0).map(({ key: t, thumbnail: n }, r) => {
308
+ let a = r * T, o = a === M;
309
+ return /* @__PURE__ */ d("button", {
310
+ type: "button",
311
+ "aria-label": Mt(a),
312
+ "aria-current": o ? "true" : void 0,
313
+ onClick: () => U(a),
314
+ className: e(s.pickerButton, "group inline-flex items-center justify-center", n === void 0 ? "h-6 min-w-6" : "rounded-md p-0.5", ue),
315
+ children: n === void 0 ? /* @__PURE__ */ d("span", {
316
+ "aria-hidden": "true",
317
+ className: e(s.pickerIndicator, "block h-2 rounded-full transition-[width,background-color] duration-200 motion-reduce:transition-none", o ? e("w-5 bg-primary", de.selectedLeaf) : "w-2 bg-stroke-accessible group-hover:bg-foreground forced-colors:bg-[ButtonText] forced-colors:forced-color-adjust-none")
318
+ }) : i(Me(n), "img", e(ee.thumbnail, "block h-12 w-16 rounded object-cover", o ? e("outline-2 outline-primary", de.selectedContainer) : "opacity-70 group-hover:opacity-100"), {
319
+ alt: "",
320
+ draggable: !1
321
+ })
322
+ }, t);
323
+ })
324
+ })
325
+ ]
326
+ })
327
+ });
193
328
  };
194
- _.displayName = "Carousel";
195
- var v = ({ className: t, children: n, ref: r, ...i }) => /* @__PURE__ */ p("div", {
196
- ref: r,
197
- className: e(s.root, "p-4", t),
198
- ...i,
199
- children: n
329
+ p.displayName = "Carousel";
330
+ var m = ({ thumbnail: t, className: n, children: r, ref: i, ...a }) => /* @__PURE__ */ d("div", {
331
+ ref: i,
332
+ className: e(ee.root, "p-4", n),
333
+ ...a,
334
+ children: r
335
+ });
336
+ m.displayName = "CarouselItem";
337
+ var Fe = /* @__PURE__ */ Object.assign(p, {
338
+ Item: m,
339
+ Button: ge
200
340
  });
201
- v.displayName = "CarouselItem";
202
- var y = /* @__PURE__ */ Object.assign(_, { Item: v });
203
341
  //#endregion
204
- export { y as Carousel, v as CarouselItem };
342
+ export { Fe as Carousel, m as CarouselItem };
205
343
 
206
344
  //# sourceMappingURL=Carousel.mjs.map