@edifice.io/react 2.6.11-develop-b2school.20261029150712 → 2.6.11-develop-b2school.20261029152056

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ export interface MasonryItemProps {
3
+ /**
4
+ * Number of columns the item spans (capped to the number of columns).
5
+ * @default 1
6
+ */
7
+ span?: number;
8
+ children: ReactNode;
9
+ }
10
+ export interface MasonryProps extends HTMLAttributes<HTMLDivElement> {
11
+ /**
12
+ * Items to lay out. Each child is one masonry item, in reading order.
13
+ */
14
+ children: ReactNode;
15
+ /**
16
+ * Number of columns. Each column takes an equal share of the available
17
+ * width, gap excluded.
18
+ * @default 2
19
+ */
20
+ columns?: number;
21
+ /**
22
+ * Gap between columns and between items, as a spacing token (e.g. `16`).
23
+ * @default '16'
24
+ */
25
+ gap?: string;
26
+ /**
27
+ * Optional class for styling purpose
28
+ */
29
+ className?: string;
30
+ }
31
+ export declare const Masonry: {
32
+ ({ children, columns, gap, className, style, ...restProps }: MasonryProps): import("react/jsx-runtime").JSX.Element;
33
+ displayName: string;
34
+ } & {
35
+ Item: {
36
+ ({ children }: MasonryItemProps): import("react/jsx-runtime").JSX.Element;
37
+ displayName: string;
38
+ };
39
+ };
40
+ export default Masonry;
@@ -0,0 +1,50 @@
1
+ import { jsx, Fragment } from "react/jsx-runtime";
2
+ import { useRef, useState, Children, useCallback, useLayoutEffect, isValidElement } from "react";
3
+ import clsx from "clsx";
4
+ const MasonryItem = ({
5
+ children
6
+ }) => /* @__PURE__ */ jsx(Fragment, { children }), Root = ({
7
+ children,
8
+ columns = 2,
9
+ gap = "16",
10
+ className,
11
+ style,
12
+ ...restProps
13
+ }) => {
14
+ const columnCount = Math.max(1, Math.floor(columns)), gridRef = useRef(null), itemRefs = useRef(/* @__PURE__ */ new Map()), [spans, setSpans] = useState({}), items = Children.toArray(children), measure = useCallback(() => {
15
+ const grid = gridRef.current;
16
+ if (!grid) return;
17
+ const rowGap = parseFloat(getComputedStyle(grid).columnGap) || 0, next = {};
18
+ itemRefs.current.forEach((el, key) => {
19
+ next[key] = Math.ceil(el.getBoundingClientRect().height + rowGap);
20
+ }), setSpans((prev) => {
21
+ const keys = Object.keys(next);
22
+ return keys.length === Object.keys(prev).length && keys.every((key) => prev[key] === next[key]) ? prev : next;
23
+ });
24
+ }, []);
25
+ return useLayoutEffect(() => {
26
+ if (measure(), typeof ResizeObserver > "u") return;
27
+ const observer = new ResizeObserver(measure);
28
+ return gridRef.current && observer.observe(gridRef.current), itemRefs.current.forEach((el) => observer.observe(el)), () => observer.disconnect();
29
+ }, [measure, columnCount, items.length]), /* @__PURE__ */ jsx("div", { ref: gridRef, className: clsx("masonry", `column-gap-${gap}`, className), style: {
30
+ display: "grid",
31
+ gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))`,
32
+ gridAutoRows: "1px",
33
+ alignItems: "start",
34
+ ...style
35
+ }, ...restProps, children: items.map((item, index) => {
36
+ const key = String(item.key ?? index), span = /* @__PURE__ */ isValidElement(item) && item.type === MasonryItem ? Math.min(Math.max(1, Math.floor(item.props.span ?? 1)), columnCount) : 1;
37
+ return /* @__PURE__ */ jsx("div", { ref: (el) => {
38
+ el ? itemRefs.current.set(key, el) : itemRefs.current.delete(key);
39
+ }, className: "masonry__item", "data-testid": `masonry-item-${index}`, style: {
40
+ gridColumn: `span ${span}`,
41
+ gridRowEnd: `span ${spans[key] ?? 1}`
42
+ }, children: item }, key);
43
+ }) });
44
+ }, Masonry = Object.assign(Root, {
45
+ Item: MasonryItem
46
+ });
47
+ export {
48
+ Masonry,
49
+ Masonry as default
50
+ };
@@ -0,0 +1,2 @@
1
+ export { default as Masonry } from './Masonry';
2
+ export * from './Masonry';
@@ -34,6 +34,7 @@ export * from './Loading';
34
34
  export * from './LoadingScreen';
35
35
  export * from './Logo';
36
36
  export * from './LogoBeta';
37
+ export * from './Masonry';
37
38
  export * from './MediaViewer';
38
39
  export * from './Menu';
39
40
  export * from './Modal';
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ import { default as default40 } from "./components/Loading/Loading.js";
42
42
  import { default as default41 } from "./components/LoadingScreen/LoadingScreen.js";
43
43
  import { default as default42 } from "./components/Logo/Logo.js";
44
44
  import { default as default43 } from "./components/LogoBeta/LogoBeta.js";
45
+ import { Masonry } from "./components/Masonry/Masonry.js";
45
46
  import { default as default44 } from "./modules/multimedia/MediaLibrary/MediaLibrary.js";
46
47
  import { default as default45 } from "./components/MediaViewer/MediaViewer.js";
47
48
  import { default as default46 } from "./components/Modal/Modal.js";
@@ -230,6 +231,7 @@ export {
230
231
  default41 as LoadingScreen,
231
232
  default42 as Logo,
232
233
  default43 as LogoBeta,
234
+ Masonry,
233
235
  default44 as MediaLibrary,
234
236
  default45 as MediaViewer,
235
237
  Menu,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.6.11-develop-b2school.20261029150712",
3
+ "version": "2.6.11-develop-b2school.20261029152056",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -140,9 +140,9 @@
140
140
  "swiper": "10.1.0",
141
141
  "ua-parser-js": "1.0.36",
142
142
  "zustand": "4.5.7",
143
- "@edifice.io/bootstrap": "2.6.11-develop-b2school.20261029150712",
144
- "@edifice.io/tiptap-extensions": "2.6.11-develop-b2school.20261029150712",
145
- "@edifice.io/utilities": "2.6.11-develop-b2school.20261029150712"
143
+ "@edifice.io/bootstrap": "2.6.11-develop-b2school.20261029152056",
144
+ "@edifice.io/tiptap-extensions": "2.6.11-develop-b2school.20261029152056",
145
+ "@edifice.io/utilities": "2.6.11-develop-b2school.20261029152056"
146
146
  },
147
147
  "devDependencies": {
148
148
  "@babel/plugin-transform-react-pure-annotations": "7.27.1",
@@ -174,8 +174,8 @@
174
174
  "vite": "5.4.14",
175
175
  "vite-plugin-dts": "4.5.4",
176
176
  "vite-tsconfig-paths": "5.1.4",
177
- "@edifice.io/client": "2.6.11-develop-b2school.20261029150712",
178
- "@edifice.io/config": "2.6.11-develop-b2school.20261029150712"
177
+ "@edifice.io/client": "2.6.11-develop-b2school.20261029152056",
178
+ "@edifice.io/config": "2.6.11-develop-b2school.20261029152056"
179
179
  },
180
180
  "peerDependencies": {
181
181
  "@react-spring/web": "9.7.5",