@waveso/ui 0.0.10 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/dist/accordion.d.ts +24 -8
  2. package/dist/accordion.d.ts.map +1 -0
  3. package/dist/accordion.js +50 -73
  4. package/dist/accordion.js.map +1 -1
  5. package/dist/action-bar.d.ts +83 -0
  6. package/dist/action-bar.d.ts.map +1 -0
  7. package/dist/action-bar.js +264 -0
  8. package/dist/action-bar.js.map +1 -0
  9. package/dist/alert-dialog.d.ts +56 -21
  10. package/dist/alert-dialog.d.ts.map +1 -0
  11. package/dist/alert-dialog.js +75 -127
  12. package/dist/alert-dialog.js.map +1 -1
  13. package/dist/alert.d.ts +26 -11
  14. package/dist/alert.d.ts.map +1 -0
  15. package/dist/alert.js +37 -68
  16. package/dist/alert.js.map +1 -1
  17. package/dist/animate.d.ts +117 -75
  18. package/dist/animate.d.ts.map +1 -0
  19. package/dist/animate.js +259 -223
  20. package/dist/animate.js.map +1 -1
  21. package/dist/aspect-ratio.d.ts +11 -6
  22. package/dist/aspect-ratio.d.ts.map +1 -0
  23. package/dist/aspect-ratio.js +12 -14
  24. package/dist/aspect-ratio.js.map +1 -1
  25. package/dist/autocomplete.d.ts +91 -25
  26. package/dist/autocomplete.d.ts.map +1 -0
  27. package/dist/autocomplete.js +119 -181
  28. package/dist/autocomplete.js.map +1 -1
  29. package/dist/avatar.d.ts +32 -11
  30. package/dist/avatar.d.ts.map +1 -0
  31. package/dist/avatar.js +42 -89
  32. package/dist/avatar.js.map +1 -1
  33. package/dist/badge.d.ts +15 -8
  34. package/dist/badge.d.ts.map +1 -0
  35. package/dist/badge.js +34 -48
  36. package/dist/badge.js.map +1 -1
  37. package/dist/breadcrumb.d.ts +35 -11
  38. package/dist/breadcrumb.d.ts.map +1 -0
  39. package/dist/breadcrumb.js +60 -110
  40. package/dist/breadcrumb.js.map +1 -1
  41. package/dist/button-group.d.ts +26 -13
  42. package/dist/button-group.d.ts.map +1 -0
  43. package/dist/button-group.js +38 -76
  44. package/dist/button-group.js.map +1 -1
  45. package/dist/button.d.ts +17 -10
  46. package/dist/button.d.ts.map +1 -0
  47. package/dist/button.js +50 -3
  48. package/dist/button.js.map +1 -1
  49. package/dist/card.d.ts +35 -11
  50. package/dist/card.d.ts.map +1 -0
  51. package/dist/card.js +43 -82
  52. package/dist/card.js.map +1 -1
  53. package/dist/checkbox.d.ts +6 -4
  54. package/dist/checkbox.d.ts.map +1 -0
  55. package/dist/checkbox.js +21 -29
  56. package/dist/checkbox.js.map +1 -1
  57. package/dist/collapsible.d.ts +15 -7
  58. package/dist/collapsible.d.ts.map +1 -0
  59. package/dist/collapsible.js +19 -8
  60. package/dist/collapsible.js.map +1 -1
  61. package/dist/combobox.d.ts +83 -23
  62. package/dist/combobox.d.ts.map +1 -0
  63. package/dist/combobox.js +149 -247
  64. package/dist/combobox.js.map +1 -1
  65. package/dist/context-menu.d.ts +80 -26
  66. package/dist/context-menu.d.ts.map +1 -0
  67. package/dist/context-menu.js +108 -164
  68. package/dist/context-menu.js.map +1 -1
  69. package/dist/count.d.ts +45 -31
  70. package/dist/count.d.ts.map +1 -0
  71. package/dist/count.js +170 -165
  72. package/dist/count.js.map +1 -1
  73. package/dist/dialog.d.ts +61 -28
  74. package/dist/dialog.d.ts.map +1 -0
  75. package/dist/dialog.js +77 -120
  76. package/dist/dialog.js.map +1 -1
  77. package/dist/direction.d.ts +2 -1
  78. package/dist/direction.js +3 -3
  79. package/dist/drawer.d.ts +45 -15
  80. package/dist/drawer.d.ts.map +1 -0
  81. package/dist/drawer.js +93 -5
  82. package/dist/drawer.js.map +1 -1
  83. package/dist/encrypted-text.d.ts +25 -12
  84. package/dist/encrypted-text.d.ts.map +1 -0
  85. package/dist/encrypted-text.js +102 -134
  86. package/dist/encrypted-text.js.map +1 -1
  87. package/dist/field.d.ts +37 -21
  88. package/dist/field.d.ts.map +1 -0
  89. package/dist/field.js +52 -3
  90. package/dist/field.js.map +1 -1
  91. package/dist/film-grain-shader.d.ts +6 -0
  92. package/dist/film-grain-shader.d.ts.map +1 -0
  93. package/dist/film-grain-shader.js +88 -0
  94. package/dist/film-grain-shader.js.map +1 -0
  95. package/dist/film-grain-webgl.d.ts +20 -0
  96. package/dist/film-grain-webgl.d.ts.map +1 -0
  97. package/dist/film-grain-webgl.js +306 -0
  98. package/dist/film-grain-webgl.js.map +1 -0
  99. package/dist/film-grain.d.ts +21 -11
  100. package/dist/film-grain.d.ts.map +1 -0
  101. package/dist/film-grain.js +28 -420
  102. package/dist/film-grain.js.map +1 -1
  103. package/dist/form.d.ts +64 -49
  104. package/dist/form.d.ts.map +1 -0
  105. package/dist/form.js +112 -91
  106. package/dist/form.js.map +1 -1
  107. package/dist/gradient-reveal-text.d.ts +35 -22
  108. package/dist/gradient-reveal-text.d.ts.map +1 -0
  109. package/dist/gradient-reveal-text.js +238 -205
  110. package/dist/gradient-reveal-text.js.map +1 -1
  111. package/dist/hooks/use-mobile.d.ts +3 -1
  112. package/dist/hooks/use-mobile.d.ts.map +1 -0
  113. package/dist/hooks/use-mobile.js +28 -2
  114. package/dist/hooks/use-mobile.js.map +1 -1
  115. package/dist/infinite-scroll.d.ts +29 -15
  116. package/dist/infinite-scroll.d.ts.map +1 -0
  117. package/dist/infinite-scroll.js +69 -99
  118. package/dist/infinite-scroll.js.map +1 -1
  119. package/dist/input-group.d.ts +41 -18
  120. package/dist/input-group.d.ts.map +1 -0
  121. package/dist/input-group.js +80 -6
  122. package/dist/input-group.js.map +1 -1
  123. package/dist/input-otp.d.ts +26 -10
  124. package/dist/input-otp.d.ts.map +1 -0
  125. package/dist/input-otp.js +40 -70
  126. package/dist/input-otp.js.map +1 -1
  127. package/dist/input.d.ts +10 -4
  128. package/dist/input.d.ts.map +1 -0
  129. package/dist/input.js +16 -3
  130. package/dist/input.js.map +1 -1
  131. package/dist/item.d.ts +58 -23
  132. package/dist/item.d.ts.map +1 -0
  133. package/dist/item.js +102 -160
  134. package/dist/item.js.map +1 -1
  135. package/dist/kbd.d.ts +12 -4
  136. package/dist/kbd.d.ts.map +1 -0
  137. package/dist/kbd.js +15 -24
  138. package/dist/kbd.js.map +1 -1
  139. package/dist/label.d.ts +9 -4
  140. package/dist/label.d.ts.map +1 -0
  141. package/dist/label.js +12 -16
  142. package/dist/label.js.map +1 -1
  143. package/dist/lib/focus.d.ts +42 -0
  144. package/dist/lib/focus.d.ts.map +1 -0
  145. package/dist/lib/focus.js +21 -0
  146. package/dist/lib/focus.js.map +1 -0
  147. package/dist/lib/internal-icons.d.ts +32 -0
  148. package/dist/lib/internal-icons.d.ts.map +1 -0
  149. package/dist/lib/internal-icons.js +222 -0
  150. package/dist/lib/internal-icons.js.map +1 -0
  151. package/dist/lib/utils.d.ts +4 -2
  152. package/dist/lib/utils.d.ts.map +1 -0
  153. package/dist/lib/utils.js +12 -2
  154. package/dist/lib/utils.js.map +1 -1
  155. package/dist/masonry.d.ts +25 -11
  156. package/dist/masonry.d.ts.map +1 -0
  157. package/dist/masonry.js +188 -229
  158. package/dist/masonry.js.map +1 -1
  159. package/dist/menu.d.ts +84 -26
  160. package/dist/menu.d.ts.map +1 -0
  161. package/dist/menu.js +141 -4
  162. package/dist/menu.js.map +1 -1
  163. package/dist/menubar.d.ts +60 -22
  164. package/dist/menubar.d.ts.map +1 -0
  165. package/dist/menubar.js +80 -52
  166. package/dist/menubar.js.map +1 -1
  167. package/dist/pagination.d.ts +38 -17
  168. package/dist/pagination.d.ts.map +1 -0
  169. package/dist/pagination.js +68 -107
  170. package/dist/pagination.js.map +1 -1
  171. package/dist/popover.d.ts +56 -14
  172. package/dist/popover.d.ts.map +1 -0
  173. package/dist/popover.js +62 -87
  174. package/dist/popover.js.map +1 -1
  175. package/dist/preview-card.d.ts +28 -9
  176. package/dist/preview-card.d.ts.map +1 -0
  177. package/dist/preview-card.js +40 -60
  178. package/dist/preview-card.js.map +1 -1
  179. package/dist/progress.d.ts +28 -9
  180. package/dist/progress.d.ts.map +1 -0
  181. package/dist/progress.js +35 -60
  182. package/dist/progress.js.map +1 -1
  183. package/dist/radio-group.d.ts +14 -8
  184. package/dist/radio-group.d.ts.map +1 -0
  185. package/dist/radio-group.js +18 -22
  186. package/dist/radio-group.js.map +1 -1
  187. package/dist/radio.d.ts +14 -6
  188. package/dist/radio.d.ts.map +1 -0
  189. package/dist/radio.js +24 -3
  190. package/dist/radio.js.map +1 -1
  191. package/dist/scroll-area.d.ts +16 -6
  192. package/dist/scroll-area.d.ts.map +1 -0
  193. package/dist/scroll-area.js +34 -55
  194. package/dist/scroll-area.js.map +1 -1
  195. package/dist/select.d.ts +66 -18
  196. package/dist/select.d.ts.map +1 -0
  197. package/dist/select.js +105 -185
  198. package/dist/select.js.map +1 -1
  199. package/dist/separator.d.ts +11 -5
  200. package/dist/separator.d.ts.map +1 -0
  201. package/dist/separator.js +17 -3
  202. package/dist/separator.js.map +1 -1
  203. package/dist/sidebar.d.ts +172 -79
  204. package/dist/sidebar.d.ts.map +1 -0
  205. package/dist/sidebar.js +363 -585
  206. package/dist/sidebar.js.map +1 -1
  207. package/dist/skeleton.d.ts +8 -3
  208. package/dist/skeleton.d.ts.map +1 -0
  209. package/dist/skeleton.js +13 -3
  210. package/dist/skeleton.js.map +1 -1
  211. package/dist/slider.d.ts +16 -6
  212. package/dist/slider.d.ts.map +1 -0
  213. package/dist/slider.js +40 -67
  214. package/dist/slider.js.map +1 -1
  215. package/dist/spinner.d.ts +8 -3
  216. package/dist/spinner.d.ts.map +1 -0
  217. package/dist/spinner.js +15 -4
  218. package/dist/spinner.js.map +1 -1
  219. package/dist/switch.d.ts +12 -6
  220. package/dist/switch.d.ts.map +1 -0
  221. package/dist/switch.js +18 -25
  222. package/dist/switch.js.map +1 -1
  223. package/dist/table.d.ts +37 -11
  224. package/dist/table.d.ts.map +1 -0
  225. package/dist/table.js +51 -88
  226. package/dist/table.js.map +1 -1
  227. package/dist/tabs.d.ts +28 -12
  228. package/dist/tabs.d.ts.map +1 -0
  229. package/dist/tabs.js +40 -74
  230. package/dist/tabs.js.map +1 -1
  231. package/dist/textarea.d.ts +13 -6
  232. package/dist/textarea.d.ts.map +1 -0
  233. package/dist/textarea.js +19 -3
  234. package/dist/textarea.js.map +1 -1
  235. package/dist/toast.d.ts +63 -39
  236. package/dist/toast.d.ts.map +1 -0
  237. package/dist/toast.js +177 -215
  238. package/dist/toast.js.map +1 -1
  239. package/dist/toggle-group.d.ts +26 -12
  240. package/dist/toggle-group.d.ts.map +1 -0
  241. package/dist/toggle-group.js +49 -73
  242. package/dist/toggle-group.js.map +1 -1
  243. package/dist/toggle.d.ts +17 -10
  244. package/dist/toggle.d.ts.map +1 -0
  245. package/dist/toggle.js +38 -3
  246. package/dist/toggle.js.map +1 -1
  247. package/dist/tooltip.d.ts +35 -14
  248. package/dist/tooltip.d.ts.map +1 -0
  249. package/dist/tooltip.js +52 -3
  250. package/dist/tooltip.js.map +1 -1
  251. package/dist/typewriter.d.ts +44 -31
  252. package/dist/typewriter.d.ts.map +1 -0
  253. package/dist/typewriter.js +185 -185
  254. package/dist/typewriter.js.map +1 -1
  255. package/package.json +6 -6
  256. package/dist/chunk-45VQAWIM.js +0 -228
  257. package/dist/chunk-45VQAWIM.js.map +0 -1
  258. package/dist/chunk-6Y7LPQMO.js +0 -11
  259. package/dist/chunk-6Y7LPQMO.js.map +0 -1
  260. package/dist/chunk-76UQO56T.js +0 -19
  261. package/dist/chunk-76UQO56T.js.map +0 -1
  262. package/dist/chunk-7F4MPMLJ.js +0 -17
  263. package/dist/chunk-7F4MPMLJ.js.map +0 -1
  264. package/dist/chunk-BKTJYX4M.js +0 -143
  265. package/dist/chunk-BKTJYX4M.js.map +0 -1
  266. package/dist/chunk-D5XPEJ6T.js +0 -36
  267. package/dist/chunk-D5XPEJ6T.js.map +0 -1
  268. package/dist/chunk-DIGOLJIR.js +0 -105
  269. package/dist/chunk-DIGOLJIR.js.map +0 -1
  270. package/dist/chunk-IQ7YQ5XA.js +0 -141
  271. package/dist/chunk-IQ7YQ5XA.js.map +0 -1
  272. package/dist/chunk-NCHHHWTB.js +0 -85
  273. package/dist/chunk-NCHHHWTB.js.map +0 -1
  274. package/dist/chunk-OUFYQLVN.js +0 -56
  275. package/dist/chunk-OUFYQLVN.js.map +0 -1
  276. package/dist/chunk-QFSEK4M6.js +0 -22
  277. package/dist/chunk-QFSEK4M6.js.map +0 -1
  278. package/dist/chunk-QRW37LRP.js +0 -25
  279. package/dist/chunk-QRW37LRP.js.map +0 -1
  280. package/dist/chunk-RPQHL6C5.js +0 -26
  281. package/dist/chunk-RPQHL6C5.js.map +0 -1
  282. package/dist/chunk-V4ZX4YCP.js +0 -66
  283. package/dist/chunk-V4ZX4YCP.js.map +0 -1
  284. package/dist/chunk-YTSQQTSF.js +0 -44
  285. package/dist/chunk-YTSQQTSF.js.map +0 -1
  286. package/dist/chunk-ZZZH3JGW.js +0 -23
  287. package/dist/chunk-ZZZH3JGW.js.map +0 -1
  288. package/dist/direction.js.map +0 -1
package/dist/masonry.js CHANGED
@@ -1,235 +1,194 @@
1
- import { StarIcon } from './chunk-DIGOLJIR.js';
2
- import { cn } from './chunk-76UQO56T.js';
3
- import * as React from 'react';
4
- import { AnimatePresence, motion } from 'motion/react';
5
- import { jsx, jsxs } from 'react/jsx-runtime';
6
-
7
- var STAGGER_STEP = 0.05;
8
- var MasonryStaggerContext = React.createContext(null);
9
- function Masonry({
10
- columns,
11
- columnWidth,
12
- gap = 4,
13
- className,
14
- children,
15
- ...props
16
- }) {
17
- const containerRef = React.useRef(null);
18
- const rafRef = React.useRef(0);
19
- const staggerCounterRef = React.useRef(0);
20
- staggerCounterRef.current = 0;
21
- const getStaggerIndex = React.useCallback(
22
- () => staggerCounterRef.current++,
23
- []
24
- );
25
- React.useLayoutEffect(() => {
26
- const container = containerRef.current;
27
- if (!container) return;
28
- const remPx = parseFloat(
29
- getComputedStyle(document.documentElement).fontSize
30
- );
31
- const gapPx = gap * 0.25 * remPx;
32
- function reflow() {
33
- const allChildren = Array.from(container.children);
34
- const items = allChildren.filter((el) => el.dataset.exiting == null);
35
- if (items.length === 0) {
36
- container.style.removeProperty("height");
37
- return;
38
- }
39
- const containerWidth = container.clientWidth;
40
- if (containerWidth === 0) return;
41
- let colCount;
42
- if (columns != null) {
43
- colCount = Math.max(1, columns);
44
- } else if (columnWidth != null) {
45
- colCount = Math.max(
46
- 1,
47
- Math.floor((containerWidth + gapPx) / (columnWidth + gapPx))
48
- );
49
- } else {
50
- colCount = Math.max(
51
- 1,
52
- Math.floor((containerWidth + gapPx) / (240 + gapPx))
53
- );
54
- }
55
- if (colCount <= 1) {
56
- container.style.removeProperty("height");
57
- container.style.display = "flex";
58
- container.style.flexDirection = "column";
59
- container.style.gap = `${gapPx}px`;
60
- for (const item of items) {
61
- item.style.removeProperty("position");
62
- item.style.removeProperty("top");
63
- item.style.removeProperty("left");
64
- item.style.removeProperty("width");
65
- }
66
- return;
67
- }
68
- container.style.removeProperty("display");
69
- container.style.removeProperty("flex-direction");
70
- container.style.removeProperty("gap");
71
- const colWidth = (containerWidth - (colCount - 1) * gapPx) / colCount;
72
- const columnBottoms = new Array(colCount).fill(0);
73
- const topItems = [];
74
- const regularItems = [];
75
- for (const item of items) {
76
- const raw = parseInt(item.dataset.span || "1", 10);
77
- if (raw > 1) {
78
- topItems.push({ el: item, span: Math.min(raw, colCount) });
79
- } else {
80
- regularItems.push(item);
81
- }
82
- }
83
- for (const { el, span } of topItems) {
84
- el.style.position = "absolute";
85
- el.style.width = `${span * colWidth + (span - 1) * gapPx}px`;
86
- }
87
- for (const item of regularItems) {
88
- item.style.position = "absolute";
89
- item.style.width = `${colWidth}px`;
90
- }
91
- const topHeights = [];
92
- for (const { el } of topItems) {
93
- topHeights.push(el.offsetHeight);
94
- }
95
- const regularHeights = [];
96
- for (const item of regularItems) {
97
- regularHeights.push(item.offsetHeight);
98
- }
99
- let nextCol = 0;
100
- for (let i = 0; i < topItems.length; i++) {
101
- const { el, span } = topItems[i];
102
- const s = Math.min(span, colCount - nextCol);
103
- const x = nextCol * (colWidth + gapPx);
104
- el.style.top = "0px";
105
- el.style.left = `${x}px`;
106
- if (s !== span) {
107
- el.style.width = `${s * colWidth + (s - 1) * gapPx}px`;
108
- }
109
- const bottom = topHeights[i] + gapPx;
110
- for (let c = nextCol; c < nextCol + s; c++) {
111
- columnBottoms[c] = bottom;
112
- }
113
- nextCol += s;
114
- }
115
- for (let i = 0; i < regularItems.length; i++) {
116
- let shortestCol = 0;
117
- for (let c = 1; c < colCount; c++) {
118
- if (columnBottoms[c] < columnBottoms[shortestCol]) {
119
- shortestCol = c;
120
- }
121
- }
122
- const x = shortestCol * (colWidth + gapPx);
123
- const y = columnBottoms[shortestCol];
124
- regularItems[i].style.top = `${y}px`;
125
- regularItems[i].style.left = `${x}px`;
126
- columnBottoms[shortestCol] = y + regularHeights[i] + gapPx;
127
- }
128
- const maxBottom = Math.max(...columnBottoms) - gapPx;
129
- container.style.height = `${Math.max(0, maxBottom)}px`;
130
- }
131
- function scheduleReflow() {
132
- cancelAnimationFrame(rafRef.current);
133
- rafRef.current = requestAnimationFrame(reflow);
134
- }
135
- reflow();
136
- const ro = new ResizeObserver(scheduleReflow);
137
- ro.observe(container);
138
- const mo = new MutationObserver(scheduleReflow);
139
- mo.observe(container, {
140
- childList: true,
141
- subtree: true,
142
- attributes: true,
143
- attributeFilter: ["data-exiting", "data-span"]
144
- });
145
- container.addEventListener("load", scheduleReflow, true);
146
- return () => {
147
- cancelAnimationFrame(rafRef.current);
148
- ro.disconnect();
149
- mo.disconnect();
150
- container.removeEventListener("load", scheduleReflow, true);
151
- container.style.removeProperty("height");
152
- container.style.removeProperty("display");
153
- container.style.removeProperty("flex-direction");
154
- container.style.removeProperty("gap");
155
- const items = Array.from(container.children);
156
- for (const item of items) {
157
- item.style.removeProperty("position");
158
- item.style.removeProperty("top");
159
- item.style.removeProperty("left");
160
- item.style.removeProperty("width");
161
- }
162
- };
163
- }, [columns, columnWidth, gap]);
164
- return /* @__PURE__ */ jsx(MasonryStaggerContext.Provider, { value: getStaggerIndex, children: /* @__PURE__ */ jsx(
165
- "div",
166
- {
167
- ref: containerRef,
168
- "data-slot": "masonry",
169
- className: cn("relative", className),
170
- ...props,
171
- children: /* @__PURE__ */ jsx(AnimatePresence, { children })
172
- }
173
- ) });
1
+ "use client";
2
+ import { cn } from "./lib/utils.js";
3
+ import { StarIcon } from "./lib/internal-icons.js";
4
+ import * as React from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { AnimatePresence, motion } from "motion/react";
7
+ //#region src/masonry.tsx
8
+ const STAGGER_STEP = .05;
9
+ const MasonryStaggerContext = React.createContext(null);
10
+ function Masonry({ columns, columnWidth, gap = 4, className, children, ...props }) {
11
+ const containerRef = React.useRef(null);
12
+ const rafRef = React.useRef(0);
13
+ const staggerCounterRef = React.useRef(0);
14
+ staggerCounterRef.current = 0;
15
+ const getStaggerIndex = React.useCallback(() => staggerCounterRef.current++, []);
16
+ React.useLayoutEffect(() => {
17
+ const container = containerRef.current;
18
+ if (!container) return;
19
+ const remPx = parseFloat(getComputedStyle(document.documentElement).fontSize);
20
+ const gapPx = gap * .25 * remPx;
21
+ function reflow() {
22
+ const items = Array.from(container.children).filter((el) => el.dataset.exiting == null);
23
+ if (items.length === 0) {
24
+ container.style.removeProperty("height");
25
+ return;
26
+ }
27
+ const containerWidth = container.clientWidth;
28
+ if (containerWidth === 0) return;
29
+ let colCount;
30
+ if (columns != null) colCount = Math.max(1, columns);
31
+ else if (columnWidth != null) colCount = Math.max(1, Math.floor((containerWidth + gapPx) / (columnWidth + gapPx)));
32
+ else colCount = Math.max(1, Math.floor((containerWidth + gapPx) / (240 + gapPx)));
33
+ if (colCount <= 1) {
34
+ container.style.removeProperty("height");
35
+ container.style.display = "flex";
36
+ container.style.flexDirection = "column";
37
+ container.style.gap = `${gapPx}px`;
38
+ for (const item of items) {
39
+ item.style.removeProperty("position");
40
+ item.style.removeProperty("top");
41
+ item.style.removeProperty("left");
42
+ item.style.removeProperty("width");
43
+ }
44
+ return;
45
+ }
46
+ container.style.removeProperty("display");
47
+ container.style.removeProperty("flex-direction");
48
+ container.style.removeProperty("gap");
49
+ const colWidth = (containerWidth - (colCount - 1) * gapPx) / colCount;
50
+ const columnBottoms = new Array(colCount).fill(0);
51
+ const topItems = [];
52
+ const regularItems = [];
53
+ for (const item of items) {
54
+ const raw = parseInt(item.dataset.span || "1", 10);
55
+ if (raw > 1) topItems.push({
56
+ el: item,
57
+ span: Math.min(raw, colCount)
58
+ });
59
+ else regularItems.push(item);
60
+ }
61
+ for (const { el, span } of topItems) {
62
+ el.style.position = "absolute";
63
+ el.style.width = `${span * colWidth + (span - 1) * gapPx}px`;
64
+ }
65
+ for (const item of regularItems) {
66
+ item.style.position = "absolute";
67
+ item.style.width = `${colWidth}px`;
68
+ }
69
+ const topHeights = [];
70
+ for (const { el } of topItems) topHeights.push(el.offsetHeight);
71
+ const regularHeights = [];
72
+ for (const item of regularItems) regularHeights.push(item.offsetHeight);
73
+ let nextCol = 0;
74
+ for (let i = 0; i < topItems.length; i++) {
75
+ const { el, span } = topItems[i];
76
+ const s = Math.min(span, colCount - nextCol);
77
+ const x = nextCol * (colWidth + gapPx);
78
+ el.style.top = "0px";
79
+ el.style.left = `${x}px`;
80
+ if (s !== span) el.style.width = `${s * colWidth + (s - 1) * gapPx}px`;
81
+ const bottom = topHeights[i] + gapPx;
82
+ for (let c = nextCol; c < nextCol + s; c++) columnBottoms[c] = bottom;
83
+ nextCol += s;
84
+ }
85
+ for (let i = 0; i < regularItems.length; i++) {
86
+ let shortestCol = 0;
87
+ for (let c = 1; c < colCount; c++) if (columnBottoms[c] < columnBottoms[shortestCol]) shortestCol = c;
88
+ const x = shortestCol * (colWidth + gapPx);
89
+ const y = columnBottoms[shortestCol];
90
+ regularItems[i].style.top = `${y}px`;
91
+ regularItems[i].style.left = `${x}px`;
92
+ columnBottoms[shortestCol] = y + regularHeights[i] + gapPx;
93
+ }
94
+ const maxBottom = Math.max(...columnBottoms) - gapPx;
95
+ container.style.height = `${Math.max(0, maxBottom)}px`;
96
+ }
97
+ function scheduleReflow() {
98
+ cancelAnimationFrame(rafRef.current);
99
+ rafRef.current = requestAnimationFrame(reflow);
100
+ }
101
+ reflow();
102
+ const ro = new ResizeObserver(scheduleReflow);
103
+ ro.observe(container);
104
+ const mo = new MutationObserver(scheduleReflow);
105
+ mo.observe(container, {
106
+ childList: true,
107
+ subtree: true,
108
+ attributes: true,
109
+ attributeFilter: ["data-exiting", "data-span"]
110
+ });
111
+ container.addEventListener("load", scheduleReflow, true);
112
+ return () => {
113
+ cancelAnimationFrame(rafRef.current);
114
+ ro.disconnect();
115
+ mo.disconnect();
116
+ container.removeEventListener("load", scheduleReflow, true);
117
+ container.style.removeProperty("height");
118
+ container.style.removeProperty("display");
119
+ container.style.removeProperty("flex-direction");
120
+ container.style.removeProperty("gap");
121
+ const items = Array.from(container.children);
122
+ for (const item of items) {
123
+ item.style.removeProperty("position");
124
+ item.style.removeProperty("top");
125
+ item.style.removeProperty("left");
126
+ item.style.removeProperty("width");
127
+ }
128
+ };
129
+ }, [
130
+ columns,
131
+ columnWidth,
132
+ gap
133
+ ]);
134
+ return /* @__PURE__ */ jsx(MasonryStaggerContext.Provider, {
135
+ value: getStaggerIndex,
136
+ children: /* @__PURE__ */ jsx("div", {
137
+ ref: containerRef,
138
+ "data-slot": "masonry",
139
+ className: cn("relative", className),
140
+ ...props,
141
+ children: /* @__PURE__ */ jsx(AnimatePresence, { children })
142
+ })
143
+ });
174
144
  }
175
145
  function FeaturedBadge() {
176
- return /* @__PURE__ */ jsx(
177
- "span",
178
- {
179
- "data-slot": "masonry-badge",
180
- className: "absolute top-2 right-2 z-10 flex size-5 items-center justify-center pointer-events-none",
181
- "aria-label": "Featured",
182
- children: /* @__PURE__ */ jsx(StarIcon, { width: 10, height: 10, fill: "currentColor", "aria-hidden": true })
183
- }
184
- );
146
+ return /* @__PURE__ */ jsx("span", {
147
+ "data-slot": "masonry-badge",
148
+ className: "absolute top-2 right-2 z-10 flex size-5 items-center justify-center pointer-events-none",
149
+ "aria-label": "Featured",
150
+ children: /* @__PURE__ */ jsx(StarIcon, {
151
+ width: 10,
152
+ height: 10,
153
+ fill: "currentColor",
154
+ "aria-hidden": true
155
+ })
156
+ });
185
157
  }
186
- function MasonryItem({
187
- className,
188
- span,
189
- children,
190
- ...props
191
- }) {
192
- const isSpanned = span != null && span > 1;
193
- const getStaggerIndex = React.useContext(MasonryStaggerContext);
194
- const [staggerDelay] = React.useState(
195
- () => getStaggerIndex ? getStaggerIndex() * STAGGER_STEP : 0
196
- );
197
- return /* @__PURE__ */ jsxs(
198
- motion.div,
199
- {
200
- "data-slot": "masonry-item",
201
- "data-span": isSpanned ? span : void 0,
202
- className: cn("relative", className),
203
- initial: {
204
- opacity: 0,
205
- y: 10,
206
- filter: "blur(8px)"
207
- },
208
- animate: {
209
- opacity: 1,
210
- y: 0,
211
- filter: "blur(0px)"
212
- },
213
- transition: {
214
- type: "spring",
215
- stiffness: 100,
216
- damping: 10,
217
- delay: staggerDelay
218
- },
219
- exit: {
220
- opacity: 0,
221
- scale: 1.2,
222
- filter: "blur(8px)"
223
- },
224
- ...props,
225
- children: [
226
- children,
227
- isSpanned && /* @__PURE__ */ jsx(FeaturedBadge, {})
228
- ]
229
- }
230
- );
158
+ function MasonryItem({ className, span, children, ...props }) {
159
+ const isSpanned = span != null && span > 1;
160
+ const getStaggerIndex = React.useContext(MasonryStaggerContext);
161
+ const [staggerDelay] = React.useState(() => getStaggerIndex ? getStaggerIndex() * STAGGER_STEP : 0);
162
+ return /* @__PURE__ */ jsxs(motion.div, {
163
+ "data-slot": "masonry-item",
164
+ "data-span": isSpanned ? span : void 0,
165
+ className: cn("relative", className),
166
+ initial: {
167
+ opacity: 0,
168
+ y: 10,
169
+ filter: "blur(8px)"
170
+ },
171
+ animate: {
172
+ opacity: 1,
173
+ y: 0,
174
+ filter: "blur(0px)"
175
+ },
176
+ transition: {
177
+ type: "spring",
178
+ stiffness: 100,
179
+ damping: 10,
180
+ delay: staggerDelay
181
+ },
182
+ exit: {
183
+ opacity: 0,
184
+ scale: 1.2,
185
+ filter: "blur(8px)"
186
+ },
187
+ ...props,
188
+ children: [children, isSpanned && /* @__PURE__ */ jsx(FeaturedBadge, {})]
189
+ });
231
190
  }
232
-
191
+ //#endregion
233
192
  export { Masonry, MasonryItem };
234
- //# sourceMappingURL=masonry.js.map
193
+
235
194
  //# sourceMappingURL=masonry.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/masonry.tsx"],"names":[],"mappings":";;;;;;AASA,IAAM,YAAA,GAAe,IAAA;AAErB,IAAM,qBAAA,GAA8B,oBAAqC,IAAI,CAAA;AAa7E,SAAS,OAAA,CAAQ;AAAA,EACf,OAAA;AAAA,EACA,WAAA;AAAA,EACA,GAAA,GAAM,CAAA;AAAA,EACN,SAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAiB;AACf,EAAA,MAAM,YAAA,GAAqB,aAAuB,IAAI,CAAA;AACtD,EAAA,MAAM,MAAA,GAAe,aAAe,CAAC,CAAA;AACrC,EAAA,MAAM,iBAAA,GAA0B,aAAO,CAAC,CAAA;AAGxC,EAAA,iBAAA,CAAkB,OAAA,GAAU,CAAA;AAE5B,EAAA,MAAM,eAAA,GAAwB,KAAA,CAAA,WAAA;AAAA,IAC5B,MAAM,iBAAA,CAAkB,OAAA,EAAA;AAAA,IACxB;AAAC,GACH;AAEA,EAAM,sBAAgB,MAAM;AAC1B,IAAA,MAAM,YAAY,YAAA,CAAa,OAAA;AAC/B,IAAA,IAAI,CAAC,SAAA,EAAW;AAEhB,IAAA,MAAM,KAAA,GAAQ,UAAA;AAAA,MACZ,gBAAA,CAAiB,QAAA,CAAS,eAAe,CAAA,CAAE;AAAA,KAC7C;AACA,IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,GAAO,KAAA;AAE3B,IAAA,SAAS,MAAA,GAAS;AAChB,MAAA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AAA,CAAA,QAAA;AAAA,IAAS,MACpC,eAAA,GAAkB,eAAA,EAAgB,GAAI,YAAA,GAAe;AAAA,GACvD;AAEA,EAAA,uBACE,IAAA;AAAA,IAAC,MAAA,CAAO,GAAA;AAAA,IAAP;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,WAAA,EAAW,YAAY,IAAA,GAAO,MAAA;AAAA,MAC9B,SAAA,EAAW,EAAA,CAAG,UAAA,EAAY,SAAS,CAAA;AAAA,MACnC,OAAA,EAAS;AAAA,QACP,OAAA,EAAS,CAAA;AAAA,QACT,CAAA,EAAG,EAAA;AAAA,QACH,MAAA,EAAQ;AAAA,OACV;AAAA,MACA,OAAA,EAAS;AAAA,QACP,OAAA,EAAS,CAAA;AAAA,QACT,CAAA,EAAG,CAAA;AAAA,QACH,MAAA,EAAQ;AAAA,OACV;AAAA,MACA,UAAA,EAAY;AAAA,QACV,IAAA,EAAM,QAAA;AAAA,QACN,SAAA,EAAW,GAAA;AAAA,QACX,OAAA,EAAS,EAAA;AAAA,QACT,KAAA,EAAO;AAAA,OACT;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,OAAA,EAAS,CAAA;AAAA,QACT,KAAA,EAAO,GAAA;AAAA,QACP,MAAA,EAAQ;AAAA,OACV;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,QACA,SAAA,wBAAc,aAAA,EAAA,EAAc;AAAA;AAAA;AAAA,GAC/B;AAEJ","file":"masonry.js","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\n\nimport { AnimatePresence, type HTMLMotionProps, motion } from \"motion/react\"\n\nimport { StarIcon } from \"./lib/internal-icons\"\nimport { cn } from \"./lib/utils\"\n\nconst STAGGER_STEP = 0.05 // 50ms between each item's enter animation\n\nconst MasonryStaggerContext = React.createContext<(() => number) | null>(null)\n\ntype MasonryProps = React.ComponentProps<\"div\"> & {\n columns?: number\n columnWidth?: number\n gap?: number\n}\n\ntype MasonryItemProps = Omit<HTMLMotionProps<\"div\">, \"children\"> & {\n span?: number\n children?: React.ReactNode\n}\n\nfunction Masonry({\n columns,\n columnWidth,\n gap = 4,\n className,\n children,\n ...props\n}: MasonryProps) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const rafRef = React.useRef<number>(0)\n const staggerCounterRef = React.useRef(0)\n\n // Reset counter each render so new items in a batch get fresh 0-based indices\n staggerCounterRef.current = 0\n\n const getStaggerIndex = React.useCallback(\n () => staggerCounterRef.current++,\n [],\n )\n\n React.useLayoutEffect(() => {\n const container = containerRef.current\n if (!container) return\n\n const remPx = parseFloat(\n getComputedStyle(document.documentElement).fontSize,\n )\n const gapPx = gap * 0.25 * remPx\n\n function reflow() {\n const allChildren = Array.from(container!.children) as HTMLElement[]\n // Skip exiting items — they keep their position during exit animation\n const items = allChildren.filter((el) => el.dataset.exiting == null)\n\n if (items.length === 0) {\n container!.style.removeProperty(\"height\")\n return\n }\n\n const containerWidth = container!.clientWidth\n if (containerWidth === 0) return\n\n let colCount: number\n if (columns != null) {\n colCount = Math.max(1, columns)\n } else if (columnWidth != null) {\n colCount = Math.max(\n 1,\n Math.floor((containerWidth + gapPx) / (columnWidth + gapPx)),\n )\n } else {\n colCount = Math.max(\n 1,\n Math.floor((containerWidth + gapPx) / (240 + gapPx)),\n )\n }\n\n // Single column: use normal flow with gap\n if (colCount <= 1) {\n container!.style.removeProperty(\"height\")\n container!.style.display = \"flex\"\n container!.style.flexDirection = \"column\"\n container!.style.gap = `${gapPx}px`\n for (const item of items) {\n item.style.removeProperty(\"position\")\n item.style.removeProperty(\"top\")\n item.style.removeProperty(\"left\")\n item.style.removeProperty(\"width\")\n }\n return\n }\n\n // Multi-column: clear single-column styles\n container!.style.removeProperty(\"display\")\n container!.style.removeProperty(\"flex-direction\")\n container!.style.removeProperty(\"gap\")\n\n const colWidth = (containerWidth - (colCount - 1) * gapPx) / colCount\n const columnBottoms = new Array<number>(colCount).fill(0)\n\n // Partition items: spanning (top-pinned) vs regular\n const topItems: { el: HTMLElement; span: number }[] = []\n const regularItems: HTMLElement[] = []\n for (const item of items) {\n const raw = parseInt(item.dataset.span || \"1\", 10)\n if (raw > 1) {\n topItems.push({ el: item, span: Math.min(raw, colCount) })\n } else {\n regularItems.push(item)\n }\n }\n\n // First pass: set width on all items for correct height measurement\n for (const { el, span } of topItems) {\n el.style.position = \"absolute\"\n el.style.width = `${span * colWidth + (span - 1) * gapPx}px`\n }\n for (const item of regularItems) {\n item.style.position = \"absolute\"\n item.style.width = `${colWidth}px`\n }\n\n // Second pass: batch-read heights\n const topHeights: number[] = []\n for (const { el } of topItems) {\n topHeights.push(el.offsetHeight)\n }\n const regularHeights: number[] = []\n for (const item of regularItems) {\n regularHeights.push(item.offsetHeight)\n }\n\n // Third pass: place top items at Y=0, left-to-right\n let nextCol = 0\n for (let i = 0; i < topItems.length; i++) {\n const { el, span } = topItems[i]!\n const s = Math.min(span, colCount - nextCol)\n\n const x = nextCol * (colWidth + gapPx)\n el.style.top = \"0px\"\n el.style.left = `${x}px`\n // Recalculate width if span was clamped\n if (s !== span) {\n el.style.width = `${s * colWidth + (s - 1) * gapPx}px`\n }\n\n const bottom = topHeights[i]! + gapPx\n for (let c = nextCol; c < nextCol + s; c++) {\n columnBottoms[c] = bottom\n }\n\n nextCol += s\n }\n\n // Fourth pass: place regular items in shortest column\n for (let i = 0; i < regularItems.length; i++) {\n let shortestCol = 0\n for (let c = 1; c < colCount; c++) {\n if (columnBottoms[c]! < columnBottoms[shortestCol]!) {\n shortestCol = c\n }\n }\n\n const x = shortestCol * (colWidth + gapPx)\n const y = columnBottoms[shortestCol]!\n\n regularItems[i]!.style.top = `${y}px`\n regularItems[i]!.style.left = `${x}px`\n\n columnBottoms[shortestCol] = y + regularHeights[i]! + gapPx\n }\n\n const maxBottom = Math.max(...columnBottoms) - gapPx\n container!.style.height = `${Math.max(0, maxBottom)}px`\n }\n\n function scheduleReflow() {\n cancelAnimationFrame(rafRef.current)\n rafRef.current = requestAnimationFrame(reflow)\n }\n\n reflow()\n\n const ro = new ResizeObserver(scheduleReflow)\n ro.observe(container)\n\n const mo = new MutationObserver(scheduleReflow)\n mo.observe(container, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"data-exiting\", \"data-span\"],\n })\n\n // Detect image/media loads that change item heights\n container.addEventListener(\"load\", scheduleReflow, true)\n\n return () => {\n cancelAnimationFrame(rafRef.current)\n ro.disconnect()\n mo.disconnect()\n container.removeEventListener(\"load\", scheduleReflow, true)\n container.style.removeProperty(\"height\")\n container.style.removeProperty(\"display\")\n container.style.removeProperty(\"flex-direction\")\n container.style.removeProperty(\"gap\")\n const items = Array.from(container.children) as HTMLElement[]\n for (const item of items) {\n item.style.removeProperty(\"position\")\n item.style.removeProperty(\"top\")\n item.style.removeProperty(\"left\")\n item.style.removeProperty(\"width\")\n }\n }\n }, [columns, columnWidth, gap])\n\n return (\n <MasonryStaggerContext.Provider value={getStaggerIndex}>\n <div\n ref={containerRef}\n data-slot=\"masonry\"\n className={cn(\"relative\", className)}\n {...props}\n >\n <AnimatePresence>\n {children}\n </AnimatePresence>\n </div>\n </MasonryStaggerContext.Provider>\n )\n}\n\nfunction FeaturedBadge() {\n return (\n <span\n data-slot=\"masonry-badge\"\n className=\"absolute top-2 right-2 z-10 flex size-5 items-center justify-center pointer-events-none\"\n aria-label=\"Featured\"\n >\n <StarIcon width={10} height={10} fill=\"currentColor\" aria-hidden />\n </span>\n )\n}\n\nfunction MasonryItem({\n className,\n span,\n children,\n ...props\n}: MasonryItemProps) {\n const isSpanned = span != null && span > 1\n const getStaggerIndex = React.useContext(MasonryStaggerContext)\n\n // Capture stagger index once on mount — useState initializer runs exactly once\n const [staggerDelay] = React.useState(() =>\n getStaggerIndex ? getStaggerIndex() * STAGGER_STEP : 0,\n )\n\n return (\n <motion.div\n data-slot=\"masonry-item\"\n data-span={isSpanned ? span : undefined}\n className={cn(\"relative\", className)}\n initial={{\n opacity: 0,\n y: 10,\n filter: \"blur(8px)\"\n }}\n animate={{\n opacity: 1,\n y: 0,\n filter: \"blur(0px)\"\n }}\n transition={{\n type: \"spring\",\n stiffness: 100,\n damping: 10,\n delay: staggerDelay,\n }}\n exit={{\n opacity: 0,\n scale: 1.2,\n filter: \"blur(8px)\",\n }}\n {...props}\n >\n {children}\n {isSpanned && <FeaturedBadge />}\n </motion.div>\n )\n}\n\nexport { Masonry, MasonryItem }\n"]}
1
+ {"version":3,"file":"masonry.js","names":[],"sources":["../src/masonry.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\n\nimport { AnimatePresence, type HTMLMotionProps, motion } from \"motion/react\"\n\nimport { StarIcon } from \"./lib/internal-icons\"\nimport { cn } from \"./lib/utils\"\n\nconst STAGGER_STEP = 0.05 // 50ms between each item's enter animation\n\nconst MasonryStaggerContext = React.createContext<(() => number) | null>(null)\n\ntype MasonryProps = React.ComponentProps<\"div\"> & {\n columns?: number\n columnWidth?: number\n gap?: number\n}\n\ntype MasonryItemProps = Omit<HTMLMotionProps<\"div\">, \"children\"> & {\n span?: number\n children?: React.ReactNode\n}\n\nfunction Masonry({\n columns,\n columnWidth,\n gap = 4,\n className,\n children,\n ...props\n}: MasonryProps) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const rafRef = React.useRef<number>(0)\n const staggerCounterRef = React.useRef(0)\n\n // Reset counter each render so new items in a batch get fresh 0-based indices\n staggerCounterRef.current = 0\n\n const getStaggerIndex = React.useCallback(\n () => staggerCounterRef.current++,\n [],\n )\n\n React.useLayoutEffect(() => {\n const container = containerRef.current\n if (!container) return\n\n const remPx = parseFloat(\n getComputedStyle(document.documentElement).fontSize,\n )\n const gapPx = gap * 0.25 * remPx\n\n function reflow() {\n const allChildren = Array.from(container!.children) as HTMLElement[]\n // Skip exiting items — they keep their position during exit animation\n const items = allChildren.filter((el) => el.dataset.exiting == null)\n\n if (items.length === 0) {\n container!.style.removeProperty(\"height\")\n return\n }\n\n const containerWidth = container!.clientWidth\n if (containerWidth === 0) return\n\n let colCount: number\n if (columns != null) {\n colCount = Math.max(1, columns)\n } else if (columnWidth != null) {\n colCount = Math.max(\n 1,\n Math.floor((containerWidth + gapPx) / (columnWidth + gapPx)),\n )\n } else {\n colCount = Math.max(\n 1,\n Math.floor((containerWidth + gapPx) / (240 + gapPx)),\n )\n }\n\n // Single column: use normal flow with gap\n if (colCount <= 1) {\n container!.style.removeProperty(\"height\")\n container!.style.display = \"flex\"\n container!.style.flexDirection = \"column\"\n container!.style.gap = `${gapPx}px`\n for (const item of items) {\n item.style.removeProperty(\"position\")\n item.style.removeProperty(\"top\")\n item.style.removeProperty(\"left\")\n item.style.removeProperty(\"width\")\n }\n return\n }\n\n // Multi-column: clear single-column styles\n container!.style.removeProperty(\"display\")\n container!.style.removeProperty(\"flex-direction\")\n container!.style.removeProperty(\"gap\")\n\n const colWidth = (containerWidth - (colCount - 1) * gapPx) / colCount\n const columnBottoms = new Array<number>(colCount).fill(0)\n\n // Partition items: spanning (top-pinned) vs regular\n const topItems: { el: HTMLElement; span: number }[] = []\n const regularItems: HTMLElement[] = []\n for (const item of items) {\n const raw = parseInt(item.dataset.span || \"1\", 10)\n if (raw > 1) {\n topItems.push({ el: item, span: Math.min(raw, colCount) })\n } else {\n regularItems.push(item)\n }\n }\n\n // First pass: set width on all items for correct height measurement\n for (const { el, span } of topItems) {\n el.style.position = \"absolute\"\n el.style.width = `${span * colWidth + (span - 1) * gapPx}px`\n }\n for (const item of regularItems) {\n item.style.position = \"absolute\"\n item.style.width = `${colWidth}px`\n }\n\n // Second pass: batch-read heights\n const topHeights: number[] = []\n for (const { el } of topItems) {\n topHeights.push(el.offsetHeight)\n }\n const regularHeights: number[] = []\n for (const item of regularItems) {\n regularHeights.push(item.offsetHeight)\n }\n\n // Third pass: place top items at Y=0, left-to-right\n let nextCol = 0\n for (let i = 0; i < topItems.length; i++) {\n const { el, span } = topItems[i]!\n const s = Math.min(span, colCount - nextCol)\n\n const x = nextCol * (colWidth + gapPx)\n el.style.top = \"0px\"\n el.style.left = `${x}px`\n // Recalculate width if span was clamped\n if (s !== span) {\n el.style.width = `${s * colWidth + (s - 1) * gapPx}px`\n }\n\n const bottom = topHeights[i]! + gapPx\n for (let c = nextCol; c < nextCol + s; c++) {\n columnBottoms[c] = bottom\n }\n\n nextCol += s\n }\n\n // Fourth pass: place regular items in shortest column\n for (let i = 0; i < regularItems.length; i++) {\n let shortestCol = 0\n for (let c = 1; c < colCount; c++) {\n if (columnBottoms[c]! < columnBottoms[shortestCol]!) {\n shortestCol = c\n }\n }\n\n const x = shortestCol * (colWidth + gapPx)\n const y = columnBottoms[shortestCol]!\n\n regularItems[i]!.style.top = `${y}px`\n regularItems[i]!.style.left = `${x}px`\n\n columnBottoms[shortestCol] = y + regularHeights[i]! + gapPx\n }\n\n const maxBottom = Math.max(...columnBottoms) - gapPx\n container!.style.height = `${Math.max(0, maxBottom)}px`\n }\n\n function scheduleReflow() {\n cancelAnimationFrame(rafRef.current)\n rafRef.current = requestAnimationFrame(reflow)\n }\n\n reflow()\n\n const ro = new ResizeObserver(scheduleReflow)\n ro.observe(container)\n\n const mo = new MutationObserver(scheduleReflow)\n mo.observe(container, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"data-exiting\", \"data-span\"],\n })\n\n // Detect image/media loads that change item heights\n container.addEventListener(\"load\", scheduleReflow, true)\n\n return () => {\n cancelAnimationFrame(rafRef.current)\n ro.disconnect()\n mo.disconnect()\n container.removeEventListener(\"load\", scheduleReflow, true)\n container.style.removeProperty(\"height\")\n container.style.removeProperty(\"display\")\n container.style.removeProperty(\"flex-direction\")\n container.style.removeProperty(\"gap\")\n const items = Array.from(container.children) as HTMLElement[]\n for (const item of items) {\n item.style.removeProperty(\"position\")\n item.style.removeProperty(\"top\")\n item.style.removeProperty(\"left\")\n item.style.removeProperty(\"width\")\n }\n }\n }, [columns, columnWidth, gap])\n\n return (\n <MasonryStaggerContext.Provider value={getStaggerIndex}>\n <div\n ref={containerRef}\n data-slot=\"masonry\"\n className={cn(\"relative\", className)}\n {...props}\n >\n <AnimatePresence>\n {children}\n </AnimatePresence>\n </div>\n </MasonryStaggerContext.Provider>\n )\n}\n\nfunction FeaturedBadge() {\n return (\n <span\n data-slot=\"masonry-badge\"\n className=\"absolute top-2 right-2 z-10 flex size-5 items-center justify-center pointer-events-none\"\n aria-label=\"Featured\"\n >\n <StarIcon width={10} height={10} fill=\"currentColor\" aria-hidden />\n </span>\n )\n}\n\nfunction MasonryItem({\n className,\n span,\n children,\n ...props\n}: MasonryItemProps) {\n const isSpanned = span != null && span > 1\n const getStaggerIndex = React.useContext(MasonryStaggerContext)\n\n // Capture stagger index once on mount — useState initializer runs exactly once\n const [staggerDelay] = React.useState(() =>\n getStaggerIndex ? getStaggerIndex() * STAGGER_STEP : 0,\n )\n\n return (\n <motion.div\n data-slot=\"masonry-item\"\n data-span={isSpanned ? span : undefined}\n className={cn(\"relative\", className)}\n initial={{\n opacity: 0,\n y: 10,\n filter: \"blur(8px)\"\n }}\n animate={{\n opacity: 1,\n y: 0,\n filter: \"blur(0px)\"\n }}\n transition={{\n type: \"spring\",\n stiffness: 100,\n damping: 10,\n delay: staggerDelay,\n }}\n exit={{\n opacity: 0,\n scale: 1.2,\n filter: \"blur(8px)\",\n }}\n {...props}\n >\n {children}\n {isSpanned && <FeaturedBadge />}\n </motion.div>\n )\n}\n\nexport { Masonry, MasonryItem }\n"],"mappings":";;;;;;;AASA,MAAM,eAAe;AAErB,MAAM,wBAAwB,MAAM,cAAqC,KAAK;AAa9E,SAAS,QAAQ,EACf,SACA,aACA,MAAM,GACN,WACA,UACA,GAAG,SACY;CACf,MAAM,eAAe,MAAM,OAAuB,KAAK;CACvD,MAAM,SAAS,MAAM,OAAe,EAAE;CACtC,MAAM,oBAAoB,MAAM,OAAO,EAAE;AAGzC,mBAAkB,UAAU;CAE5B,MAAM,kBAAkB,MAAM,kBACtB,kBAAkB,WACxB,EAAE,CACH;AAED,OAAM,sBAAsB;EAC1B,MAAM,YA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EACE,aAAU;EACV,WAAU;EACV,cAAW;YAEX,oBAAC,UAAD;GAAU,OAAO;GAAI,QAAQ;GAAI,MAAK;GAAe,eAAA;GAAc,CAAA;EAC9D,CAAA;;AAIX,SAAS,YAAY,EACnB,WACA,MACA,UACA,GAAG,SACgB;CACnB,MAAM,YAAY,QAAQ,QAAQ,OAAO;CACzC,MAAM,kBAAkB,MAAM,WAAW,sBAAsB;CAG/D,MAAM,CAAC,gBAAgB,MAAM,eAC3B,kBAAkB,iBAAiB,GAAG,eAAe,EACtD;AAED,QACE,qBAAC,OAAO,KAAR;EACE,aAAU;EACV,aAAW,YAAY,OAAO,KAAA;EAC9B,WAAW,GAAG,YAAY,UAAU;EACpC,SAAS;GACP,SAAS;GACT,GAAG;GACH,QAAQ;GACT;EACD,SAAS;GACP,SAAS;GACT,GAAG;GACH,QAAQ;GACT;EACD,YAAY;GACV,MAAM;GACN,WAAW;GACX,SAAS;GACT,OAAO;GACR;EACD,MAAM;GACJ,SAAS;GACT,OAAO;GACP,QAAQ;GACT;EACD,GAAI;YAzBN,CA2BG,UACA,aAAa,oBAAC,eAAD,EAAiB,CAAA,CACpB"}
package/dist/menu.d.ts CHANGED
@@ -1,47 +1,105 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React from 'react';
3
- import { Menu as Menu$1 } from '@base-ui/react/menu';
1
+ import { RestoreFocusOnClose } from "./lib/focus.js";
2
+ import * as React from "react";
3
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
+ import { Menu as Menu$1 } from "@base-ui/react/menu";
4
5
 
6
+ //#region src/menu.d.ts
5
7
  type MenuProps = React.ComponentProps<typeof Menu$1.Root>;
6
8
  type MenuPortalProps = React.ComponentProps<typeof Menu$1.Portal>;
7
9
  type MenuTriggerProps = React.ComponentProps<typeof Menu$1.Trigger>;
8
- type MenuContentProps = React.ComponentProps<typeof Menu$1.Popup> & Pick<React.ComponentProps<typeof Menu$1.Positioner>, "align" | "alignOffset" | "side" | "sideOffset">;
10
+ type MenuContentProps = React.ComponentProps<typeof Menu$1.Popup> & Pick<React.ComponentProps<typeof Menu$1.Positioner>, "align" | "alignOffset" | "side" | "sideOffset"> & {
11
+ /**
12
+ * Focus-restoration policy when the menu closes. Defaults to Base
13
+ * UI's behaviour (restore to the trigger). Use `"keyboard"` when
14
+ * the trigger is hover/focus-within–revealed so a pointer close
15
+ * doesn't keep it pinned visible. See {@link RestoreFocusOnClose}.
16
+ */
17
+ restoreFocusOnClose?: RestoreFocusOnClose;
18
+ };
9
19
  type MenuGroupProps = React.ComponentProps<typeof Menu$1.Group>;
10
20
  type MenuLabelProps = React.ComponentProps<typeof Menu$1.GroupLabel> & {
11
- inset?: boolean;
21
+ inset?: boolean;
12
22
  };
13
23
  type MenuItemProps = React.ComponentProps<typeof Menu$1.Item> & {
14
- inset?: boolean;
15
- variant?: "default" | "destructive";
24
+ inset?: boolean;
25
+ variant?: "default" | "destructive";
16
26
  };
17
27
  type MenuSubProps = React.ComponentProps<typeof Menu$1.SubmenuRoot>;
18
28
  type MenuSubTriggerProps = React.ComponentProps<typeof Menu$1.SubmenuTrigger> & {
19
- inset?: boolean;
29
+ inset?: boolean;
20
30
  };
21
31
  type MenuSubContentProps = MenuContentProps;
22
32
  type MenuCheckboxItemProps = React.ComponentProps<typeof Menu$1.CheckboxItem> & {
23
- inset?: boolean;
33
+ inset?: boolean;
24
34
  };
25
35
  type MenuRadioGroupProps = React.ComponentProps<typeof Menu$1.RadioGroup>;
26
36
  type MenuRadioItemProps = React.ComponentProps<typeof Menu$1.RadioItem> & {
27
- inset?: boolean;
37
+ inset?: boolean;
28
38
  };
29
39
  type MenuSeparatorProps = React.ComponentProps<typeof Menu$1.Separator>;
30
40
  type MenuShortcutProps = React.ComponentProps<"span">;
31
- declare function Menu(props: MenuProps): react_jsx_runtime.JSX.Element;
32
- declare function MenuPortal(props: MenuPortalProps): react_jsx_runtime.JSX.Element;
33
- declare function MenuTrigger(props: MenuTriggerProps): react_jsx_runtime.JSX.Element;
34
- declare function MenuContent({ align, alignOffset, side, sideOffset, className, ...props }: MenuContentProps): react_jsx_runtime.JSX.Element;
35
- declare function MenuGroup(props: MenuGroupProps): react_jsx_runtime.JSX.Element;
36
- declare function MenuLabel({ className, inset, ...props }: MenuLabelProps): react_jsx_runtime.JSX.Element;
37
- declare function MenuItem({ className, inset, variant, ...props }: MenuItemProps): react_jsx_runtime.JSX.Element;
38
- declare function MenuSub(props: MenuSubProps): react_jsx_runtime.JSX.Element;
39
- declare function MenuSubTrigger({ className, inset, children, ...props }: MenuSubTriggerProps): react_jsx_runtime.JSX.Element;
40
- declare function MenuSubContent({ align, alignOffset, side, sideOffset, className, ...props }: MenuSubContentProps): react_jsx_runtime.JSX.Element;
41
- declare function MenuCheckboxItem({ className, children, checked, inset, ...props }: MenuCheckboxItemProps): react_jsx_runtime.JSX.Element;
42
- declare function MenuRadioGroup(props: MenuRadioGroupProps): react_jsx_runtime.JSX.Element;
43
- declare function MenuRadioItem({ className, children, inset, ...props }: MenuRadioItemProps): react_jsx_runtime.JSX.Element;
44
- declare function MenuSeparator({ className, ...props }: MenuSeparatorProps): react_jsx_runtime.JSX.Element;
45
- declare function MenuShortcut({ className, ...props }: MenuShortcutProps): react_jsx_runtime.JSX.Element;
46
-
41
+ declare function Menu(props: MenuProps): _$react_jsx_runtime0.JSX.Element;
42
+ declare function MenuPortal(props: MenuPortalProps): _$react_jsx_runtime0.JSX.Element;
43
+ declare function MenuTrigger(props: MenuTriggerProps): _$react_jsx_runtime0.JSX.Element;
44
+ declare function MenuContent({
45
+ align,
46
+ alignOffset,
47
+ side,
48
+ sideOffset,
49
+ className,
50
+ restoreFocusOnClose,
51
+ finalFocus,
52
+ ...props
53
+ }: MenuContentProps): _$react_jsx_runtime0.JSX.Element;
54
+ declare function MenuGroup(props: MenuGroupProps): _$react_jsx_runtime0.JSX.Element;
55
+ declare function MenuLabel({
56
+ className,
57
+ inset,
58
+ ...props
59
+ }: MenuLabelProps): _$react_jsx_runtime0.JSX.Element;
60
+ declare function MenuItem({
61
+ className,
62
+ inset,
63
+ variant,
64
+ ...props
65
+ }: MenuItemProps): _$react_jsx_runtime0.JSX.Element;
66
+ declare function MenuSub(props: MenuSubProps): _$react_jsx_runtime0.JSX.Element;
67
+ declare function MenuSubTrigger({
68
+ className,
69
+ inset,
70
+ children,
71
+ ...props
72
+ }: MenuSubTriggerProps): _$react_jsx_runtime0.JSX.Element;
73
+ declare function MenuSubContent({
74
+ align,
75
+ alignOffset,
76
+ side,
77
+ sideOffset,
78
+ className,
79
+ ...props
80
+ }: MenuSubContentProps): _$react_jsx_runtime0.JSX.Element;
81
+ declare function MenuCheckboxItem({
82
+ className,
83
+ children,
84
+ checked,
85
+ inset,
86
+ ...props
87
+ }: MenuCheckboxItemProps): _$react_jsx_runtime0.JSX.Element;
88
+ declare function MenuRadioGroup(props: MenuRadioGroupProps): _$react_jsx_runtime0.JSX.Element;
89
+ declare function MenuRadioItem({
90
+ className,
91
+ children,
92
+ inset,
93
+ ...props
94
+ }: MenuRadioItemProps): _$react_jsx_runtime0.JSX.Element;
95
+ declare function MenuSeparator({
96
+ className,
97
+ ...props
98
+ }: MenuSeparatorProps): _$react_jsx_runtime0.JSX.Element;
99
+ declare function MenuShortcut({
100
+ className,
101
+ ...props
102
+ }: MenuShortcutProps): _$react_jsx_runtime0.JSX.Element;
103
+ //#endregion
47
104
  export { Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuPortal, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuShortcut, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger };
105
+ //# sourceMappingURL=menu.d.ts.map