@dxos/react-ui-masonry 0.8.4-main.406dc2a → 0.8.4-main.422d1c7879

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.
@@ -1,78 +1,127 @@
1
1
  // src/Masonry.tsx
2
+ import { useArrowNavigationGroup } from "@fluentui/react-tabster";
2
3
  import { useComposedRefs } from "@radix-ui/react-compose-refs";
3
- import { useMasonry, usePositioner, useResizeObserver } from "masonic";
4
- import React, { forwardRef, useMemo, useRef } from "react";
5
- import { useScroller, useSize } from "@dxos/react-hooks";
6
- import { usePx } from "@dxos/react-ui";
7
- import { mx } from "@dxos/react-ui-theme";
8
- var usePxProps = (remProps) => {
9
- const remInPx = usePx(1);
10
- return useMemo(() => {
11
- return Object.fromEntries(Object.entries(remProps).filter(([_, value]) => Number.isFinite(value)).map(([key, value]) => {
12
- return [
13
- key,
14
- value * remInPx
15
- ];
4
+ import { createContext } from "@radix-ui/react-context";
5
+ import { VirtuosoMasonry } from "@virtuoso.dev/masonry";
6
+ import React, { useMemo, useRef } from "react";
7
+ import { useResizeDetector } from "react-resize-detector";
8
+ import { ScrollArea, usePx } from "@dxos/react-ui";
9
+ import { cardMaxInlineSize, cardMinInlineSize, composable, composableProps, scrollbar } from "@dxos/ui-theme";
10
+ var MASONRY_NAME = "Masonry";
11
+ var [MasonryProvider, useMasonryContext] = createContext(MASONRY_NAME);
12
+ var [MasonryContentProvider, useMasonryContentContext] = createContext("Masonry.Content");
13
+ var MasonryRoot = ({ children, Tile, columns = void 0, maxColumns = void 0, minColumnWidth = cardMinInlineSize, maxColumnWidth = cardMaxInlineSize, gutter = 0.75 }) => /* @__PURE__ */ React.createElement(MasonryProvider, {
14
+ Tile,
15
+ columns,
16
+ maxColumns,
17
+ minColumnWidth,
18
+ maxColumnWidth,
19
+ gutter
20
+ }, children);
21
+ MasonryRoot.displayName = "Masonry.Root";
22
+ var MasonryContentInner = composable(({ children, centered, thin = true, padding = true, ...props }, forwardedRef) => {
23
+ const rootRef = useRef(null);
24
+ const composedRef = useComposedRefs(rootRef, forwardedRef);
25
+ const { width = 0 } = useResizeDetector({
26
+ targetRef: rootRef
27
+ });
28
+ return /* @__PURE__ */ React.createElement(ScrollArea.Root, {
29
+ ...composableProps(props),
30
+ centered,
31
+ thin,
32
+ padding,
33
+ ref: composedRef
34
+ }, /* @__PURE__ */ React.createElement(MasonryContentProvider, {
35
+ width
36
+ }, children));
37
+ });
38
+ MasonryContentInner.displayName = "Masonry.Content";
39
+ var MasonryViewportInner = composable(({ items, getId, ...props }, forwardedRef) => {
40
+ const { Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter } = useMasonryContext("Masonry.Viewport");
41
+ const { width } = useMasonryContentContext("Masonry.Viewport");
42
+ const columnCount = useColumnCount(width - (scrollbar.thin.size + scrollbar.thin.padding), columns, maxColumns, minColumnWidth, maxColumnWidth, gutter);
43
+ const arrowNavigationAttrs = useArrowNavigationGroup({
44
+ axis: "both",
45
+ memorizeCurrent: true,
46
+ tabbable: true
47
+ });
48
+ const TileAdapter = useMemo(() => {
49
+ const Adapter = ({ data, index }) => /* @__PURE__ */ React.createElement("div", {
50
+ role: "listitem",
51
+ style: {
52
+ paddingBottom: `${gutter}rem`
53
+ }
54
+ }, /* @__PURE__ */ React.createElement(Tile, {
55
+ index,
56
+ data
16
57
  }));
58
+ Adapter.displayName = "Masonry.TileAdapter";
59
+ return Adapter;
17
60
  }, [
18
- remProps,
19
- remInPx
20
- ]);
21
- };
22
- var MasonryRootImpl = ({ columnCount, maxColumnCount, columnWidth = 18, maxColumnWidth, columnGutter = 1, rowGutter, items, itemHeightEstimate = 256, itemKey, overscanBy = 6, render, onRender, classNames, intrinsicHeight, ...props }, forwardedRef) => {
23
- const rootRef = useRef(null);
24
- const ref = useComposedRefs(rootRef, forwardedRef);
25
- const { width, height } = useSize(rootRef);
26
- const { scrollTop, isScrolling } = useScroller(rootRef);
27
- const remProps = useMemo(() => ({
28
- columnWidth,
29
- maxColumnWidth,
30
- columnGutter,
31
- rowGutter
32
- }), [
33
- columnWidth,
34
- maxColumnWidth,
35
- columnGutter,
36
- rowGutter
61
+ Tile,
62
+ gutter
37
63
  ]);
38
- const pxProps = usePxProps(remProps);
39
- const positionerProps = useMemo(() => ({
40
- width,
64
+ if (width <= 0) {
65
+ return null;
66
+ }
67
+ return /* @__PURE__ */ React.createElement(ScrollArea.Viewport, {
68
+ asChild: true
69
+ }, /* @__PURE__ */ React.createElement(ComposableVirtuosoMasonry, {
70
+ ...arrowNavigationAttrs,
71
+ ...composableProps(props),
72
+ ref: forwardedRef,
73
+ style: {
74
+ gap: `${gutter}rem`
75
+ },
76
+ data: items,
41
77
  columnCount,
42
- maxColumnCount,
43
- ...pxProps
44
- }), [
78
+ ItemContent: TileAdapter
79
+ }));
80
+ });
81
+ var ComposableVirtuosoMasonry = composable(({ ...props }, _forwardedRef) => {
82
+ return /* @__PURE__ */ React.createElement(VirtuosoMasonry, props);
83
+ });
84
+ MasonryViewportInner.displayName = "Masonry.Viewport";
85
+ var MasonryContent = MasonryContentInner;
86
+ var MasonryViewport = MasonryViewportInner;
87
+ var useColumnCount = (width, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter) => {
88
+ const remInPx = usePx(1);
89
+ return useMemo(() => {
90
+ if (columns != null) {
91
+ return columns;
92
+ }
93
+ const minColumnWidthPx = minColumnWidth * remInPx;
94
+ const maxColumnWidthPx = maxColumnWidth * remInPx;
95
+ const gutterPx = gutter * remInPx;
96
+ if (width <= 0 || minColumnWidthPx <= 0) {
97
+ return 1;
98
+ }
99
+ let cols = Math.floor(width / (minColumnWidthPx + gutterPx));
100
+ if (maxColumnWidthPx > 0) {
101
+ const effectiveColWidth = width / cols - gutterPx;
102
+ if (effectiveColWidth > maxColumnWidthPx) {
103
+ const maxCols = Math.ceil(width / (maxColumnWidthPx + gutterPx));
104
+ if (width / maxCols - gutterPx >= minColumnWidthPx) {
105
+ cols = maxCols;
106
+ }
107
+ }
108
+ }
109
+ const clamped = maxColumns != null ? Math.min(cols, maxColumns) : cols;
110
+ return Math.max(1, clamped);
111
+ }, [
112
+ remInPx,
45
113
  width,
46
- pxProps,
47
- columnCount,
48
- maxColumnCount
49
- ]);
50
- const positioner = usePositioner(positionerProps, [
51
- positionerProps
114
+ columns,
115
+ maxColumns,
116
+ minColumnWidth,
117
+ maxColumnWidth,
118
+ gutter
52
119
  ]);
53
- const resizeObserver = useResizeObserver(positioner);
54
- const children = useMasonry({
55
- height: intrinsicHeight ? Infinity : height,
56
- scrollTop,
57
- isScrolling,
58
- resizeObserver,
59
- positioner,
60
- items,
61
- itemHeightEstimate,
62
- itemKey,
63
- overscanBy,
64
- render,
65
- onRender
66
- });
67
- return /* @__PURE__ */ React.createElement("div", {
68
- className: mx(classNames),
69
- ...props,
70
- ref
71
- }, children);
72
120
  };
73
- var MasonryRoot = /* @__PURE__ */ forwardRef(MasonryRootImpl);
74
121
  var Masonry = {
75
- Root: MasonryRoot
122
+ Root: MasonryRoot,
123
+ Content: MasonryContent,
124
+ Viewport: MasonryViewport
76
125
  };
77
126
  export {
78
127
  Masonry
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/Masonry.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport {\n type UseMasonryOptions,\n type UsePositionerOptions,\n useMasonry,\n usePositioner,\n useResizeObserver,\n} from 'masonic';\nimport React, {\n type ComponentPropsWithRef,\n type ForwardedRef,\n type JSX,\n type Ref,\n forwardRef,\n useMemo,\n useRef,\n} from 'react';\n\nimport { useScroller, useSize } from '@dxos/react-hooks';\nimport { type ThemedClassName, usePx } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\ntype MasonryRootProps<Item> = ThemedClassName<ComponentPropsWithRef<'div'>> &\n Omit<UsePositionerOptions, 'width'> &\n Omit<\n UseMasonryOptions<Item>,\n | 'height'\n | 'scrollTop'\n | 'isScrolling'\n | 'resizeObserver'\n | 'positioner'\n | 'as'\n | 'id'\n | 'itemAs'\n | 'itemStyle'\n | 'className'\n | 'style'\n | 'role'\n | 'tabIndex'\n | 'containerRef'\n > & { intrinsicHeight?: boolean };\n\nconst usePxProps = (remProps: Omit<UsePositionerOptions, 'width' | 'columnCount' | 'maxColumnCount'>) => {\n const remInPx = usePx(1);\n return useMemo(() => {\n return Object.fromEntries(\n Object.entries(remProps)\n .filter(([_, value]) => Number.isFinite(value))\n .map(([key, value]) => {\n return [key, value * remInPx];\n }),\n );\n }, [remProps, remInPx]);\n};\n\nconst MasonryRootImpl = <Item,>(\n {\n columnCount,\n maxColumnCount,\n columnWidth = 18,\n maxColumnWidth,\n columnGutter = 1,\n rowGutter,\n items,\n itemHeightEstimate = 256,\n itemKey,\n overscanBy = 6,\n render,\n onRender,\n classNames,\n intrinsicHeight,\n ...props\n }: MasonryRootProps<Item>,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const ref = useComposedRefs(rootRef, forwardedRef);\n const { width, height } = useSize(rootRef);\n const { scrollTop, isScrolling } = useScroller(rootRef);\n const remProps = useMemo(\n () => ({ columnWidth, maxColumnWidth, columnGutter, rowGutter }),\n [columnWidth, maxColumnWidth, columnGutter, rowGutter],\n );\n const pxProps = usePxProps(remProps);\n const positionerProps = useMemo(\n () => ({\n width,\n columnCount,\n maxColumnCount,\n ...pxProps,\n }),\n [width, pxProps, columnCount, maxColumnCount],\n );\n const positioner = usePositioner(positionerProps, [positionerProps]);\n const resizeObserver = useResizeObserver(positioner);\n const children = useMasonry({\n height: intrinsicHeight ? Infinity : height,\n scrollTop,\n isScrolling,\n resizeObserver,\n positioner,\n items,\n itemHeightEstimate,\n itemKey,\n overscanBy,\n render,\n onRender,\n });\n return (\n <div className={mx(classNames)} {...props} ref={ref}>\n {children}\n </div>\n );\n};\n\nconst MasonryRoot = forwardRef(MasonryRootImpl) as <Item>(\n props: MasonryRootProps<Item> & {\n ref?: Ref<HTMLDivElement | null>;\n },\n) => JSX.Element;\n\nexport const Masonry = {\n Root: MasonryRoot,\n};\n\nexport type { MasonryRootProps };\n"],
5
- "mappings": ";AAIA,SAASA,uBAAuB;AAChC,SAGEC,YACAC,eACAC,yBACK;AACP,OAAOC,SAKLC,YACAC,SACAC,cACK;AAEP,SAASC,aAAaC,eAAe;AACrC,SAA+BC,aAAa;AAC5C,SAASC,UAAU;AAsBnB,IAAMC,aAAa,CAACC,aAAAA;AAClB,QAAMC,UAAUC,MAAM,CAAA;AACtB,SAAOC,QAAQ,MAAA;AACb,WAAOC,OAAOC,YACZD,OAAOE,QAAQN,QAAAA,EACZO,OAAO,CAAC,CAACC,GAAGC,KAAAA,MAAWC,OAAOC,SAASF,KAAAA,CAAAA,EACvCG,IAAI,CAAC,CAACC,KAAKJ,KAAAA,MAAM;AAChB,aAAO;QAACI;QAAKJ,QAAQR;;IACvB,CAAA,CAAA;EAEN,GAAG;IAACD;IAAUC;GAAQ;AACxB;AAEA,IAAMa,kBAAkB,CACtB,EACEC,aACAC,gBACAC,cAAc,IACdC,gBACAC,eAAe,GACfC,WACAC,OACAC,qBAAqB,KACrBC,SACAC,aAAa,GACbC,QACAC,UACAC,YACAC,iBACA,GAAGC,MAAAA,GAELC,iBAAAA;AAEA,QAAMC,UAAUC,OAA8B,IAAA;AAC9C,QAAMC,MAAMC,gBAAgBH,SAASD,YAAAA;AACrC,QAAM,EAAEK,OAAOC,OAAM,IAAKC,QAAQN,OAAAA;AAClC,QAAM,EAAEO,WAAWC,YAAW,IAAKC,YAAYT,OAAAA;AAC/C,QAAM/B,WAAWG,QACf,OAAO;IAAEc;IAAaC;IAAgBC;IAAcC;EAAU,IAC9D;IAACH;IAAaC;IAAgBC;IAAcC;GAAU;AAExD,QAAMqB,UAAU1C,WAAWC,QAAAA;AAC3B,QAAM0C,kBAAkBvC,QACtB,OAAO;IACLgC;IACApB;IACAC;IACA,GAAGyB;EACL,IACA;IAACN;IAAOM;IAAS1B;IAAaC;GAAe;AAE/C,QAAM2B,aAAaC,cAAcF,iBAAiB;IAACA;GAAgB;AACnE,QAAMG,iBAAiBC,kBAAkBH,UAAAA;AACzC,QAAMI,WAAWC,WAAW;IAC1BZ,QAAQR,kBAAkBqB,WAAWb;IACrCE;IACAC;IACAM;IACAF;IACAtB;IACAC;IACAC;IACAC;IACAC;IACAC;EACF,CAAA;AACA,SACE,sBAAA,cAACwB,OAAAA;IAAIC,WAAWC,GAAGzB,UAAAA;IAAc,GAAGE;IAAOI;KACxCc,QAAAA;AAGP;AAEA,IAAMM,cAAcC,2BAAWxC,eAAAA;AAMxB,IAAMyC,UAAU;EACrBC,MAAMH;AACR;",
6
- "names": ["useComposedRefs", "useMasonry", "usePositioner", "useResizeObserver", "React", "forwardRef", "useMemo", "useRef", "useScroller", "useSize", "usePx", "mx", "usePxProps", "remProps", "remInPx", "usePx", "useMemo", "Object", "fromEntries", "entries", "filter", "_", "value", "Number", "isFinite", "map", "key", "MasonryRootImpl", "columnCount", "maxColumnCount", "columnWidth", "maxColumnWidth", "columnGutter", "rowGutter", "items", "itemHeightEstimate", "itemKey", "overscanBy", "render", "onRender", "classNames", "intrinsicHeight", "props", "forwardedRef", "rootRef", "useRef", "ref", "useComposedRefs", "width", "height", "useSize", "scrollTop", "isScrolling", "useScroller", "pxProps", "positionerProps", "positioner", "usePositioner", "resizeObserver", "useResizeObserver", "children", "useMasonry", "Infinity", "div", "className", "mx", "MasonryRoot", "forwardRef", "Masonry", "Root"]
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext } from '@radix-ui/react-context';\nimport { VirtuosoMasonry, type VirtuosoMasonryProps } from '@virtuoso.dev/masonry';\nimport React, { type ComponentType, type JSX, type PropsWithChildren, type Ref, useMemo, useRef } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { ScrollArea, ScrollAreaRootProps, ThemedClassName, usePx } from '@dxos/react-ui';\nimport { cardMaxInlineSize, cardMinInlineSize, composable, composableProps, scrollbar } from '@dxos/ui-theme';\n\n//\n// Context\n//\n\ntype MasonryContextValue = {\n /** Render component for each masonry item. */\n Tile: ComponentType<{ data: any; index: number }>;\n /** Override auto-calculated column count. */\n columns: number | undefined;\n /** Upper bound on number of columns. */\n maxColumns: number | undefined;\n /** Minimum column width in rem. */\n minColumnWidth: number;\n /** Maximum column width in rem. */\n maxColumnWidth: number;\n /** Space between columns and rows in rem. */\n gutter: number;\n};\n\nconst MASONRY_NAME = 'Masonry';\n\nconst [MasonryProvider, useMasonryContext] = createContext<MasonryContextValue>(MASONRY_NAME);\n\n/** Content-scoped context: measured width of the ScrollArea.Root, shared with Viewport. */\ntype MasonryContentContextValue = {\n width: number;\n};\n\nconst [MasonryContentProvider, useMasonryContentContext] = createContext<MasonryContentContextValue>('Masonry.Content');\n\n//\n// Root\n//\n\ntype MasonryRootProps = PropsWithChildren<Partial<MasonryContextValue>>;\n\nconst MasonryRoot = ({\n children,\n Tile,\n columns = undefined,\n maxColumns = undefined,\n minColumnWidth = cardMinInlineSize,\n maxColumnWidth = cardMaxInlineSize,\n gutter = 0.75,\n}: MasonryRootProps) => (\n <MasonryProvider\n Tile={Tile!}\n columns={columns}\n maxColumns={maxColumns}\n minColumnWidth={minColumnWidth}\n maxColumnWidth={maxColumnWidth}\n gutter={gutter}\n >\n {children}\n </MasonryProvider>\n);\n\nMasonryRoot.displayName = 'Masonry.Root';\n\n//\n// Content\n//\n// The outer wrapper: renders the ScrollArea.Root, measures available width,\n// and publishes that width via context for Masonry.Viewport to consume.\n// Style this layer (centered/thin/padding) to control the scroll container.\n//\n\ntype MasonryContentProps = ThemedClassName<\n PropsWithChildren<Pick<ScrollAreaRootProps, 'centered' | 'thin' | 'padding'>>\n>;\n\nconst MasonryContentInner = composable<HTMLDivElement, MasonryContentProps>(\n ({ children, centered, thin = true, padding = true, ...props }, forwardedRef) => {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const composedRef = useComposedRefs(rootRef, forwardedRef);\n const { width = 0 } = useResizeDetector({ targetRef: rootRef });\n\n // NOTE: Masonry currently doesn't support an external scroller.\n // https://github.com/petyosi/react-virtuoso/issues/1305\n return (\n <ScrollArea.Root {...composableProps(props)} centered={centered} thin={thin} padding={padding} ref={composedRef}>\n <MasonryContentProvider width={width}>{children}</MasonryContentProvider>\n </ScrollArea.Root>\n );\n },\n);\n\nMasonryContentInner.displayName = 'Masonry.Content';\n\n//\n// Viewport\n//\n// The inner render layer: renders the ScrollArea.Viewport wrapped around\n// VirtuosoMasonry. Style this layer separately from Content to control\n// the tile grid (e.g. inner padding, alignment).\n//\n\ntype MasonryViewportProps<Item> = ThemedClassName<{\n /** Items to render in the masonry grid. */\n items: Item[];\n /** Extract a stable key from an item, aligned with react-ui-mosaic's getId. */\n getId?: (data: Item) => string;\n}>;\n\nconst MasonryViewportInner = composable<HTMLDivElement, MasonryViewportProps<any>>(\n ({ items, getId, ...props }, forwardedRef) => {\n const { Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter } = useMasonryContext('Masonry.Viewport');\n const { width } = useMasonryContentContext('Masonry.Viewport');\n const columnCount = useColumnCount(\n width - (scrollbar.thin.size + scrollbar.thin.padding),\n columns,\n maxColumns,\n minColumnWidth,\n maxColumnWidth,\n gutter,\n );\n\n // Arrow-key navigation across tiles. Uses Tabster's `both` axis so all\n // four arrows move focus through the items. True 2D (grid) axis doesn't\n // work inside a masonry because VirtuosoMasonry lays items out column-\n // first in the DOM — tabster's Grid direction requires the next DOM\n // element to be to the right of the current for ArrowRight, which is\n // never the case between columns here. `both` treats the keys as flat\n // next/previous-focusable, which gives predictable wrap-around in DOM\n // order for all four directions.\n const arrowNavigationAttrs = useArrowNavigationGroup({\n axis: 'both',\n memorizeCurrent: true,\n tabbable: true,\n });\n\n const TileAdapter = useMemo(() => {\n const Adapter = ({ data, index }: { data: any; index: number }) => (\n <div role='listitem' style={{ paddingBottom: `${gutter}rem` }}>\n <Tile index={index} data={data} />\n </div>\n );\n Adapter.displayName = 'Masonry.TileAdapter';\n return Adapter;\n }, [Tile, gutter]);\n\n if (width <= 0) {\n return null;\n }\n\n return (\n <ScrollArea.Viewport asChild>\n <ComposableVirtuosoMasonry\n {...arrowNavigationAttrs}\n {...composableProps(props)}\n ref={forwardedRef}\n style={{ gap: `${gutter}rem` }}\n data={items}\n columnCount={columnCount}\n ItemContent={TileAdapter}\n />\n </ScrollArea.Viewport>\n );\n },\n);\n\nconst ComposableVirtuosoMasonry = composable<HTMLDivElement, VirtuosoMasonryProps<any, any>>(\n ({ ...props }, _forwardedRef) => {\n return <VirtuosoMasonry {...props} />;\n },\n);\n\nMasonryViewportInner.displayName = 'Masonry.Viewport';\n\nconst MasonryContent = MasonryContentInner as (\n props: MasonryContentProps & {\n ref?: Ref<HTMLDivElement | null>;\n },\n) => JSX.Element;\n\nconst MasonryViewport = MasonryViewportInner as <Item>(\n props: MasonryViewportProps<Item> & {\n ref?: Ref<HTMLDivElement | null>;\n },\n) => JSX.Element;\n\n/** Compute column count from container width and column constraints. */\nconst useColumnCount = (\n width: number,\n columns: number | undefined,\n maxColumns: number | undefined,\n minColumnWidth: number,\n maxColumnWidth: number,\n gutter: number,\n) => {\n const remInPx = usePx(1);\n return useMemo(() => {\n if (columns != null) {\n return columns;\n }\n\n const minColumnWidthPx = minColumnWidth * remInPx;\n const maxColumnWidthPx = maxColumnWidth * remInPx;\n const gutterPx = gutter * remInPx;\n if (width <= 0 || minColumnWidthPx <= 0) {\n return 1;\n }\n\n // Each tile has paddingRight: gutter, so every slot (including the last) occupies\n // (colWidth + gutterPx). The container therefore fits floor(containerWidth / (colWidth + gutterPx)) columns.\n let cols = Math.floor(width / (minColumnWidthPx + gutterPx));\n if (maxColumnWidthPx > 0) {\n const effectiveColWidth = width / cols - gutterPx;\n if (effectiveColWidth > maxColumnWidthPx) {\n // Try to add columns to keep cards below maxColumnWidth, but never violate minColumnWidth.\n const maxCols = Math.ceil(width / (maxColumnWidthPx + gutterPx));\n if (width / maxCols - gutterPx >= minColumnWidthPx) {\n cols = maxCols;\n }\n }\n }\n\n const clamped = maxColumns != null ? Math.min(cols, maxColumns) : cols;\n return Math.max(1, clamped);\n }, [remInPx, width, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter]);\n};\n\n//\n// Masonry\n//\n\nexport const Masonry = {\n Root: MasonryRoot,\n Content: MasonryContent,\n Viewport: MasonryViewport,\n};\n\nexport type { MasonryRootProps, MasonryContentProps, MasonryViewportProps };\n"],
5
+ "mappings": "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",
6
+ "names": ["useArrowNavigationGroup", "useComposedRefs", "createContext", "VirtuosoMasonry", "React", "useMemo", "useRef", "useResizeDetector", "ScrollArea", "usePx", "cardMaxInlineSize", "cardMinInlineSize", "composable", "composableProps", "scrollbar", "MASONRY_NAME", "MasonryProvider", "useMasonryContext", "createContext", "MasonryContentProvider", "useMasonryContentContext", "MasonryRoot", "children", "Tile", "columns", "undefined", "maxColumns", "minColumnWidth", "cardMinInlineSize", "maxColumnWidth", "cardMaxInlineSize", "gutter", "displayName", "MasonryContentInner", "composable", "centered", "thin", "padding", "props", "forwardedRef", "rootRef", "useRef", "composedRef", "useComposedRefs", "width", "useResizeDetector", "targetRef", "ScrollArea", "Root", "composableProps", "ref", "MasonryViewportInner", "items", "getId", "columnCount", "useColumnCount", "scrollbar", "size", "arrowNavigationAttrs", "useArrowNavigationGroup", "axis", "memorizeCurrent", "tabbable", "TileAdapter", "useMemo", "Adapter", "data", "index", "div", "role", "style", "paddingBottom", "Viewport", "asChild", "ComposableVirtuosoMasonry", "gap", "ItemContent", "_forwardedRef", "VirtuosoMasonry", "MasonryContent", "MasonryViewport", "remInPx", "usePx", "minColumnWidthPx", "maxColumnWidthPx", "gutterPx", "cols", "Math", "floor", "effectiveColWidth", "maxCols", "ceil", "clamped", "min", "max", "Masonry", "Content"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/Masonry.tsx":{"bytes":9891,"imports":[{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"masonic","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":454,"imports":[{"path":"src/Masonry.tsx","kind":"import-statement","original":"./Masonry"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5568},"dist/lib/browser/index.mjs":{"imports":[{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"masonic","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"exports":["Masonry"],"entryPoint":"src/index.ts","inputs":{"src/Masonry.tsx":{"bytesInOutput":2121},"src/index.ts":{"bytesInOutput":0}},"bytes":2197}}}
1
+ {"inputs":{"src/Masonry.tsx":{"bytes":23084,"imports":[{"path":"@fluentui/react-tabster","kind":"import-statement","external":true},{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@virtuoso.dev/masonry","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":454,"imports":[{"path":"src/Masonry.tsx","kind":"import-statement","original":"./Masonry"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12484},"dist/lib/browser/index.mjs":{"imports":[{"path":"@fluentui/react-tabster","kind":"import-statement","external":true},{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@virtuoso.dev/masonry","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["Masonry"],"entryPoint":"src/index.ts","inputs":{"src/Masonry.tsx":{"bytesInOutput":4434},"src/index.ts":{"bytesInOutput":0}},"bytes":4510}}}
@@ -1,80 +1,129 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // src/Masonry.tsx
4
+ import { useArrowNavigationGroup } from "@fluentui/react-tabster";
4
5
  import { useComposedRefs } from "@radix-ui/react-compose-refs";
5
- import { useMasonry, usePositioner, useResizeObserver } from "masonic";
6
- import React, { forwardRef, useMemo, useRef } from "react";
7
- import { useScroller, useSize } from "@dxos/react-hooks";
8
- import { usePx } from "@dxos/react-ui";
9
- import { mx } from "@dxos/react-ui-theme";
10
- var usePxProps = (remProps) => {
11
- const remInPx = usePx(1);
12
- return useMemo(() => {
13
- return Object.fromEntries(Object.entries(remProps).filter(([_, value]) => Number.isFinite(value)).map(([key, value]) => {
14
- return [
15
- key,
16
- value * remInPx
17
- ];
6
+ import { createContext } from "@radix-ui/react-context";
7
+ import { VirtuosoMasonry } from "@virtuoso.dev/masonry";
8
+ import React, { useMemo, useRef } from "react";
9
+ import { useResizeDetector } from "react-resize-detector";
10
+ import { ScrollArea, usePx } from "@dxos/react-ui";
11
+ import { cardMaxInlineSize, cardMinInlineSize, composable, composableProps, scrollbar } from "@dxos/ui-theme";
12
+ var MASONRY_NAME = "Masonry";
13
+ var [MasonryProvider, useMasonryContext] = createContext(MASONRY_NAME);
14
+ var [MasonryContentProvider, useMasonryContentContext] = createContext("Masonry.Content");
15
+ var MasonryRoot = ({ children, Tile, columns = void 0, maxColumns = void 0, minColumnWidth = cardMinInlineSize, maxColumnWidth = cardMaxInlineSize, gutter = 0.75 }) => /* @__PURE__ */ React.createElement(MasonryProvider, {
16
+ Tile,
17
+ columns,
18
+ maxColumns,
19
+ minColumnWidth,
20
+ maxColumnWidth,
21
+ gutter
22
+ }, children);
23
+ MasonryRoot.displayName = "Masonry.Root";
24
+ var MasonryContentInner = composable(({ children, centered, thin = true, padding = true, ...props }, forwardedRef) => {
25
+ const rootRef = useRef(null);
26
+ const composedRef = useComposedRefs(rootRef, forwardedRef);
27
+ const { width = 0 } = useResizeDetector({
28
+ targetRef: rootRef
29
+ });
30
+ return /* @__PURE__ */ React.createElement(ScrollArea.Root, {
31
+ ...composableProps(props),
32
+ centered,
33
+ thin,
34
+ padding,
35
+ ref: composedRef
36
+ }, /* @__PURE__ */ React.createElement(MasonryContentProvider, {
37
+ width
38
+ }, children));
39
+ });
40
+ MasonryContentInner.displayName = "Masonry.Content";
41
+ var MasonryViewportInner = composable(({ items, getId, ...props }, forwardedRef) => {
42
+ const { Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter } = useMasonryContext("Masonry.Viewport");
43
+ const { width } = useMasonryContentContext("Masonry.Viewport");
44
+ const columnCount = useColumnCount(width - (scrollbar.thin.size + scrollbar.thin.padding), columns, maxColumns, minColumnWidth, maxColumnWidth, gutter);
45
+ const arrowNavigationAttrs = useArrowNavigationGroup({
46
+ axis: "both",
47
+ memorizeCurrent: true,
48
+ tabbable: true
49
+ });
50
+ const TileAdapter = useMemo(() => {
51
+ const Adapter = ({ data, index }) => /* @__PURE__ */ React.createElement("div", {
52
+ role: "listitem",
53
+ style: {
54
+ paddingBottom: `${gutter}rem`
55
+ }
56
+ }, /* @__PURE__ */ React.createElement(Tile, {
57
+ index,
58
+ data
18
59
  }));
60
+ Adapter.displayName = "Masonry.TileAdapter";
61
+ return Adapter;
19
62
  }, [
20
- remProps,
21
- remInPx
22
- ]);
23
- };
24
- var MasonryRootImpl = ({ columnCount, maxColumnCount, columnWidth = 18, maxColumnWidth, columnGutter = 1, rowGutter, items, itemHeightEstimate = 256, itemKey, overscanBy = 6, render, onRender, classNames, intrinsicHeight, ...props }, forwardedRef) => {
25
- const rootRef = useRef(null);
26
- const ref = useComposedRefs(rootRef, forwardedRef);
27
- const { width, height } = useSize(rootRef);
28
- const { scrollTop, isScrolling } = useScroller(rootRef);
29
- const remProps = useMemo(() => ({
30
- columnWidth,
31
- maxColumnWidth,
32
- columnGutter,
33
- rowGutter
34
- }), [
35
- columnWidth,
36
- maxColumnWidth,
37
- columnGutter,
38
- rowGutter
63
+ Tile,
64
+ gutter
39
65
  ]);
40
- const pxProps = usePxProps(remProps);
41
- const positionerProps = useMemo(() => ({
42
- width,
66
+ if (width <= 0) {
67
+ return null;
68
+ }
69
+ return /* @__PURE__ */ React.createElement(ScrollArea.Viewport, {
70
+ asChild: true
71
+ }, /* @__PURE__ */ React.createElement(ComposableVirtuosoMasonry, {
72
+ ...arrowNavigationAttrs,
73
+ ...composableProps(props),
74
+ ref: forwardedRef,
75
+ style: {
76
+ gap: `${gutter}rem`
77
+ },
78
+ data: items,
43
79
  columnCount,
44
- maxColumnCount,
45
- ...pxProps
46
- }), [
80
+ ItemContent: TileAdapter
81
+ }));
82
+ });
83
+ var ComposableVirtuosoMasonry = composable(({ ...props }, _forwardedRef) => {
84
+ return /* @__PURE__ */ React.createElement(VirtuosoMasonry, props);
85
+ });
86
+ MasonryViewportInner.displayName = "Masonry.Viewport";
87
+ var MasonryContent = MasonryContentInner;
88
+ var MasonryViewport = MasonryViewportInner;
89
+ var useColumnCount = (width, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter) => {
90
+ const remInPx = usePx(1);
91
+ return useMemo(() => {
92
+ if (columns != null) {
93
+ return columns;
94
+ }
95
+ const minColumnWidthPx = minColumnWidth * remInPx;
96
+ const maxColumnWidthPx = maxColumnWidth * remInPx;
97
+ const gutterPx = gutter * remInPx;
98
+ if (width <= 0 || minColumnWidthPx <= 0) {
99
+ return 1;
100
+ }
101
+ let cols = Math.floor(width / (minColumnWidthPx + gutterPx));
102
+ if (maxColumnWidthPx > 0) {
103
+ const effectiveColWidth = width / cols - gutterPx;
104
+ if (effectiveColWidth > maxColumnWidthPx) {
105
+ const maxCols = Math.ceil(width / (maxColumnWidthPx + gutterPx));
106
+ if (width / maxCols - gutterPx >= minColumnWidthPx) {
107
+ cols = maxCols;
108
+ }
109
+ }
110
+ }
111
+ const clamped = maxColumns != null ? Math.min(cols, maxColumns) : cols;
112
+ return Math.max(1, clamped);
113
+ }, [
114
+ remInPx,
47
115
  width,
48
- pxProps,
49
- columnCount,
50
- maxColumnCount
51
- ]);
52
- const positioner = usePositioner(positionerProps, [
53
- positionerProps
116
+ columns,
117
+ maxColumns,
118
+ minColumnWidth,
119
+ maxColumnWidth,
120
+ gutter
54
121
  ]);
55
- const resizeObserver = useResizeObserver(positioner);
56
- const children = useMasonry({
57
- height: intrinsicHeight ? Infinity : height,
58
- scrollTop,
59
- isScrolling,
60
- resizeObserver,
61
- positioner,
62
- items,
63
- itemHeightEstimate,
64
- itemKey,
65
- overscanBy,
66
- render,
67
- onRender
68
- });
69
- return /* @__PURE__ */ React.createElement("div", {
70
- className: mx(classNames),
71
- ...props,
72
- ref
73
- }, children);
74
122
  };
75
- var MasonryRoot = /* @__PURE__ */ forwardRef(MasonryRootImpl);
76
123
  var Masonry = {
77
- Root: MasonryRoot
124
+ Root: MasonryRoot,
125
+ Content: MasonryContent,
126
+ Viewport: MasonryViewport
78
127
  };
79
128
  export {
80
129
  Masonry
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/Masonry.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport {\n type UseMasonryOptions,\n type UsePositionerOptions,\n useMasonry,\n usePositioner,\n useResizeObserver,\n} from 'masonic';\nimport React, {\n type ComponentPropsWithRef,\n type ForwardedRef,\n type JSX,\n type Ref,\n forwardRef,\n useMemo,\n useRef,\n} from 'react';\n\nimport { useScroller, useSize } from '@dxos/react-hooks';\nimport { type ThemedClassName, usePx } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\ntype MasonryRootProps<Item> = ThemedClassName<ComponentPropsWithRef<'div'>> &\n Omit<UsePositionerOptions, 'width'> &\n Omit<\n UseMasonryOptions<Item>,\n | 'height'\n | 'scrollTop'\n | 'isScrolling'\n | 'resizeObserver'\n | 'positioner'\n | 'as'\n | 'id'\n | 'itemAs'\n | 'itemStyle'\n | 'className'\n | 'style'\n | 'role'\n | 'tabIndex'\n | 'containerRef'\n > & { intrinsicHeight?: boolean };\n\nconst usePxProps = (remProps: Omit<UsePositionerOptions, 'width' | 'columnCount' | 'maxColumnCount'>) => {\n const remInPx = usePx(1);\n return useMemo(() => {\n return Object.fromEntries(\n Object.entries(remProps)\n .filter(([_, value]) => Number.isFinite(value))\n .map(([key, value]) => {\n return [key, value * remInPx];\n }),\n );\n }, [remProps, remInPx]);\n};\n\nconst MasonryRootImpl = <Item,>(\n {\n columnCount,\n maxColumnCount,\n columnWidth = 18,\n maxColumnWidth,\n columnGutter = 1,\n rowGutter,\n items,\n itemHeightEstimate = 256,\n itemKey,\n overscanBy = 6,\n render,\n onRender,\n classNames,\n intrinsicHeight,\n ...props\n }: MasonryRootProps<Item>,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const ref = useComposedRefs(rootRef, forwardedRef);\n const { width, height } = useSize(rootRef);\n const { scrollTop, isScrolling } = useScroller(rootRef);\n const remProps = useMemo(\n () => ({ columnWidth, maxColumnWidth, columnGutter, rowGutter }),\n [columnWidth, maxColumnWidth, columnGutter, rowGutter],\n );\n const pxProps = usePxProps(remProps);\n const positionerProps = useMemo(\n () => ({\n width,\n columnCount,\n maxColumnCount,\n ...pxProps,\n }),\n [width, pxProps, columnCount, maxColumnCount],\n );\n const positioner = usePositioner(positionerProps, [positionerProps]);\n const resizeObserver = useResizeObserver(positioner);\n const children = useMasonry({\n height: intrinsicHeight ? Infinity : height,\n scrollTop,\n isScrolling,\n resizeObserver,\n positioner,\n items,\n itemHeightEstimate,\n itemKey,\n overscanBy,\n render,\n onRender,\n });\n return (\n <div className={mx(classNames)} {...props} ref={ref}>\n {children}\n </div>\n );\n};\n\nconst MasonryRoot = forwardRef(MasonryRootImpl) as <Item>(\n props: MasonryRootProps<Item> & {\n ref?: Ref<HTMLDivElement | null>;\n },\n) => JSX.Element;\n\nexport const Masonry = {\n Root: MasonryRoot,\n};\n\nexport type { MasonryRootProps };\n"],
5
- "mappings": ";;;AAIA,SAASA,uBAAuB;AAChC,SAGEC,YACAC,eACAC,yBACK;AACP,OAAOC,SAKLC,YACAC,SACAC,cACK;AAEP,SAASC,aAAaC,eAAe;AACrC,SAA+BC,aAAa;AAC5C,SAASC,UAAU;AAsBnB,IAAMC,aAAa,CAACC,aAAAA;AAClB,QAAMC,UAAUC,MAAM,CAAA;AACtB,SAAOC,QAAQ,MAAA;AACb,WAAOC,OAAOC,YACZD,OAAOE,QAAQN,QAAAA,EACZO,OAAO,CAAC,CAACC,GAAGC,KAAAA,MAAWC,OAAOC,SAASF,KAAAA,CAAAA,EACvCG,IAAI,CAAC,CAACC,KAAKJ,KAAAA,MAAM;AAChB,aAAO;QAACI;QAAKJ,QAAQR;;IACvB,CAAA,CAAA;EAEN,GAAG;IAACD;IAAUC;GAAQ;AACxB;AAEA,IAAMa,kBAAkB,CACtB,EACEC,aACAC,gBACAC,cAAc,IACdC,gBACAC,eAAe,GACfC,WACAC,OACAC,qBAAqB,KACrBC,SACAC,aAAa,GACbC,QACAC,UACAC,YACAC,iBACA,GAAGC,MAAAA,GAELC,iBAAAA;AAEA,QAAMC,UAAUC,OAA8B,IAAA;AAC9C,QAAMC,MAAMC,gBAAgBH,SAASD,YAAAA;AACrC,QAAM,EAAEK,OAAOC,OAAM,IAAKC,QAAQN,OAAAA;AAClC,QAAM,EAAEO,WAAWC,YAAW,IAAKC,YAAYT,OAAAA;AAC/C,QAAM/B,WAAWG,QACf,OAAO;IAAEc;IAAaC;IAAgBC;IAAcC;EAAU,IAC9D;IAACH;IAAaC;IAAgBC;IAAcC;GAAU;AAExD,QAAMqB,UAAU1C,WAAWC,QAAAA;AAC3B,QAAM0C,kBAAkBvC,QACtB,OAAO;IACLgC;IACApB;IACAC;IACA,GAAGyB;EACL,IACA;IAACN;IAAOM;IAAS1B;IAAaC;GAAe;AAE/C,QAAM2B,aAAaC,cAAcF,iBAAiB;IAACA;GAAgB;AACnE,QAAMG,iBAAiBC,kBAAkBH,UAAAA;AACzC,QAAMI,WAAWC,WAAW;IAC1BZ,QAAQR,kBAAkBqB,WAAWb;IACrCE;IACAC;IACAM;IACAF;IACAtB;IACAC;IACAC;IACAC;IACAC;IACAC;EACF,CAAA;AACA,SACE,sBAAA,cAACwB,OAAAA;IAAIC,WAAWC,GAAGzB,UAAAA;IAAc,GAAGE;IAAOI;KACxCc,QAAAA;AAGP;AAEA,IAAMM,cAAcC,2BAAWxC,eAAAA;AAMxB,IAAMyC,UAAU;EACrBC,MAAMH;AACR;",
6
- "names": ["useComposedRefs", "useMasonry", "usePositioner", "useResizeObserver", "React", "forwardRef", "useMemo", "useRef", "useScroller", "useSize", "usePx", "mx", "usePxProps", "remProps", "remInPx", "usePx", "useMemo", "Object", "fromEntries", "entries", "filter", "_", "value", "Number", "isFinite", "map", "key", "MasonryRootImpl", "columnCount", "maxColumnCount", "columnWidth", "maxColumnWidth", "columnGutter", "rowGutter", "items", "itemHeightEstimate", "itemKey", "overscanBy", "render", "onRender", "classNames", "intrinsicHeight", "props", "forwardedRef", "rootRef", "useRef", "ref", "useComposedRefs", "width", "height", "useSize", "scrollTop", "isScrolling", "useScroller", "pxProps", "positionerProps", "positioner", "usePositioner", "resizeObserver", "useResizeObserver", "children", "useMasonry", "Infinity", "div", "className", "mx", "MasonryRoot", "forwardRef", "Masonry", "Root"]
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContext } from '@radix-ui/react-context';\nimport { VirtuosoMasonry, type VirtuosoMasonryProps } from '@virtuoso.dev/masonry';\nimport React, { type ComponentType, type JSX, type PropsWithChildren, type Ref, useMemo, useRef } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { ScrollArea, ScrollAreaRootProps, ThemedClassName, usePx } from '@dxos/react-ui';\nimport { cardMaxInlineSize, cardMinInlineSize, composable, composableProps, scrollbar } from '@dxos/ui-theme';\n\n//\n// Context\n//\n\ntype MasonryContextValue = {\n /** Render component for each masonry item. */\n Tile: ComponentType<{ data: any; index: number }>;\n /** Override auto-calculated column count. */\n columns: number | undefined;\n /** Upper bound on number of columns. */\n maxColumns: number | undefined;\n /** Minimum column width in rem. */\n minColumnWidth: number;\n /** Maximum column width in rem. */\n maxColumnWidth: number;\n /** Space between columns and rows in rem. */\n gutter: number;\n};\n\nconst MASONRY_NAME = 'Masonry';\n\nconst [MasonryProvider, useMasonryContext] = createContext<MasonryContextValue>(MASONRY_NAME);\n\n/** Content-scoped context: measured width of the ScrollArea.Root, shared with Viewport. */\ntype MasonryContentContextValue = {\n width: number;\n};\n\nconst [MasonryContentProvider, useMasonryContentContext] = createContext<MasonryContentContextValue>('Masonry.Content');\n\n//\n// Root\n//\n\ntype MasonryRootProps = PropsWithChildren<Partial<MasonryContextValue>>;\n\nconst MasonryRoot = ({\n children,\n Tile,\n columns = undefined,\n maxColumns = undefined,\n minColumnWidth = cardMinInlineSize,\n maxColumnWidth = cardMaxInlineSize,\n gutter = 0.75,\n}: MasonryRootProps) => (\n <MasonryProvider\n Tile={Tile!}\n columns={columns}\n maxColumns={maxColumns}\n minColumnWidth={minColumnWidth}\n maxColumnWidth={maxColumnWidth}\n gutter={gutter}\n >\n {children}\n </MasonryProvider>\n);\n\nMasonryRoot.displayName = 'Masonry.Root';\n\n//\n// Content\n//\n// The outer wrapper: renders the ScrollArea.Root, measures available width,\n// and publishes that width via context for Masonry.Viewport to consume.\n// Style this layer (centered/thin/padding) to control the scroll container.\n//\n\ntype MasonryContentProps = ThemedClassName<\n PropsWithChildren<Pick<ScrollAreaRootProps, 'centered' | 'thin' | 'padding'>>\n>;\n\nconst MasonryContentInner = composable<HTMLDivElement, MasonryContentProps>(\n ({ children, centered, thin = true, padding = true, ...props }, forwardedRef) => {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const composedRef = useComposedRefs(rootRef, forwardedRef);\n const { width = 0 } = useResizeDetector({ targetRef: rootRef });\n\n // NOTE: Masonry currently doesn't support an external scroller.\n // https://github.com/petyosi/react-virtuoso/issues/1305\n return (\n <ScrollArea.Root {...composableProps(props)} centered={centered} thin={thin} padding={padding} ref={composedRef}>\n <MasonryContentProvider width={width}>{children}</MasonryContentProvider>\n </ScrollArea.Root>\n );\n },\n);\n\nMasonryContentInner.displayName = 'Masonry.Content';\n\n//\n// Viewport\n//\n// The inner render layer: renders the ScrollArea.Viewport wrapped around\n// VirtuosoMasonry. Style this layer separately from Content to control\n// the tile grid (e.g. inner padding, alignment).\n//\n\ntype MasonryViewportProps<Item> = ThemedClassName<{\n /** Items to render in the masonry grid. */\n items: Item[];\n /** Extract a stable key from an item, aligned with react-ui-mosaic's getId. */\n getId?: (data: Item) => string;\n}>;\n\nconst MasonryViewportInner = composable<HTMLDivElement, MasonryViewportProps<any>>(\n ({ items, getId, ...props }, forwardedRef) => {\n const { Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter } = useMasonryContext('Masonry.Viewport');\n const { width } = useMasonryContentContext('Masonry.Viewport');\n const columnCount = useColumnCount(\n width - (scrollbar.thin.size + scrollbar.thin.padding),\n columns,\n maxColumns,\n minColumnWidth,\n maxColumnWidth,\n gutter,\n );\n\n // Arrow-key navigation across tiles. Uses Tabster's `both` axis so all\n // four arrows move focus through the items. True 2D (grid) axis doesn't\n // work inside a masonry because VirtuosoMasonry lays items out column-\n // first in the DOM — tabster's Grid direction requires the next DOM\n // element to be to the right of the current for ArrowRight, which is\n // never the case between columns here. `both` treats the keys as flat\n // next/previous-focusable, which gives predictable wrap-around in DOM\n // order for all four directions.\n const arrowNavigationAttrs = useArrowNavigationGroup({\n axis: 'both',\n memorizeCurrent: true,\n tabbable: true,\n });\n\n const TileAdapter = useMemo(() => {\n const Adapter = ({ data, index }: { data: any; index: number }) => (\n <div role='listitem' style={{ paddingBottom: `${gutter}rem` }}>\n <Tile index={index} data={data} />\n </div>\n );\n Adapter.displayName = 'Masonry.TileAdapter';\n return Adapter;\n }, [Tile, gutter]);\n\n if (width <= 0) {\n return null;\n }\n\n return (\n <ScrollArea.Viewport asChild>\n <ComposableVirtuosoMasonry\n {...arrowNavigationAttrs}\n {...composableProps(props)}\n ref={forwardedRef}\n style={{ gap: `${gutter}rem` }}\n data={items}\n columnCount={columnCount}\n ItemContent={TileAdapter}\n />\n </ScrollArea.Viewport>\n );\n },\n);\n\nconst ComposableVirtuosoMasonry = composable<HTMLDivElement, VirtuosoMasonryProps<any, any>>(\n ({ ...props }, _forwardedRef) => {\n return <VirtuosoMasonry {...props} />;\n },\n);\n\nMasonryViewportInner.displayName = 'Masonry.Viewport';\n\nconst MasonryContent = MasonryContentInner as (\n props: MasonryContentProps & {\n ref?: Ref<HTMLDivElement | null>;\n },\n) => JSX.Element;\n\nconst MasonryViewport = MasonryViewportInner as <Item>(\n props: MasonryViewportProps<Item> & {\n ref?: Ref<HTMLDivElement | null>;\n },\n) => JSX.Element;\n\n/** Compute column count from container width and column constraints. */\nconst useColumnCount = (\n width: number,\n columns: number | undefined,\n maxColumns: number | undefined,\n minColumnWidth: number,\n maxColumnWidth: number,\n gutter: number,\n) => {\n const remInPx = usePx(1);\n return useMemo(() => {\n if (columns != null) {\n return columns;\n }\n\n const minColumnWidthPx = minColumnWidth * remInPx;\n const maxColumnWidthPx = maxColumnWidth * remInPx;\n const gutterPx = gutter * remInPx;\n if (width <= 0 || minColumnWidthPx <= 0) {\n return 1;\n }\n\n // Each tile has paddingRight: gutter, so every slot (including the last) occupies\n // (colWidth + gutterPx). The container therefore fits floor(containerWidth / (colWidth + gutterPx)) columns.\n let cols = Math.floor(width / (minColumnWidthPx + gutterPx));\n if (maxColumnWidthPx > 0) {\n const effectiveColWidth = width / cols - gutterPx;\n if (effectiveColWidth > maxColumnWidthPx) {\n // Try to add columns to keep cards below maxColumnWidth, but never violate minColumnWidth.\n const maxCols = Math.ceil(width / (maxColumnWidthPx + gutterPx));\n if (width / maxCols - gutterPx >= minColumnWidthPx) {\n cols = maxCols;\n }\n }\n }\n\n const clamped = maxColumns != null ? Math.min(cols, maxColumns) : cols;\n return Math.max(1, clamped);\n }, [remInPx, width, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter]);\n};\n\n//\n// Masonry\n//\n\nexport const Masonry = {\n Root: MasonryRoot,\n Content: MasonryContent,\n Viewport: MasonryViewport,\n};\n\nexport type { MasonryRootProps, MasonryContentProps, MasonryViewportProps };\n"],
5
+ "mappings": ";;;AAIA,SAASA,+BAA+B;AACxC,SAASC,uBAAuB;AAChC,SAASC,qBAAqB;AAC9B,SAASC,uBAAkD;AAC3D,OAAOC,SAAyEC,SAASC,cAAc;AACvG,SAASC,yBAAyB;AAElC,SAASC,YAAkDC,aAAa;AACxE,SAASC,mBAAmBC,mBAAmBC,YAAYC,iBAAiBC,iBAAiB;AAqB7F,IAAMC,eAAe;AAErB,IAAM,CAACC,iBAAiBC,iBAAAA,IAAqBC,cAAmCH,YAAAA;AAOhF,IAAM,CAACI,wBAAwBC,wBAAAA,IAA4BF,cAA0C,iBAAA;AAQrG,IAAMG,cAAc,CAAC,EACnBC,UACAC,MACAC,UAAUC,QACVC,aAAaD,QACbE,iBAAiBC,mBACjBC,iBAAiBC,mBACjBC,SAAS,KAAI,MAEb,sBAAA,cAACf,iBAAAA;EACCO;EACAC;EACAE;EACAC;EACAE;EACAE;GAECT,QAAAA;AAILD,YAAYW,cAAc;AAc1B,IAAMC,sBAAsBC,WAC1B,CAAC,EAAEZ,UAAUa,UAAUC,OAAO,MAAMC,UAAU,MAAM,GAAGC,MAAAA,GAASC,iBAAAA;AAC9D,QAAMC,UAAUC,OAA8B,IAAA;AAC9C,QAAMC,cAAcC,gBAAgBH,SAASD,YAAAA;AAC7C,QAAM,EAAEK,QAAQ,EAAC,IAAKC,kBAAkB;IAAEC,WAAWN;EAAQ,CAAA;AAI7D,SACE,sBAAA,cAACO,WAAWC,MAAI;IAAE,GAAGC,gBAAgBX,KAAAA;IAAQH;IAAoBC;IAAYC;IAAkBa,KAAKR;KAClG,sBAAA,cAACvB,wBAAAA;IAAuByB;KAAetB,QAAAA,CAAAA;AAG7C,CAAA;AAGFW,oBAAoBD,cAAc;AAiBlC,IAAMmB,uBAAuBjB,WAC3B,CAAC,EAAEkB,OAAOC,OAAO,GAAGf,MAAAA,GAASC,iBAAAA;AAC3B,QAAM,EAAEhB,MAAMC,SAASE,YAAYC,gBAAgBE,gBAAgBE,OAAM,IAAKd,kBAAkB,kBAAA;AAChG,QAAM,EAAE2B,MAAK,IAAKxB,yBAAyB,kBAAA;AAC3C,QAAMkC,cAAcC,eAClBX,SAASY,UAAUpB,KAAKqB,OAAOD,UAAUpB,KAAKC,UAC9Cb,SACAE,YACAC,gBACAE,gBACAE,MAAAA;AAWF,QAAM2B,uBAAuBC,wBAAwB;IACnDC,MAAM;IACNC,iBAAiB;IACjBC,UAAU;EACZ,CAAA;AAEA,QAAMC,cAAcC,QAAQ,MAAA;AAC1B,UAAMC,UAAU,CAAC,EAAEC,MAAMC,MAAK,MAC5B,sBAAA,cAACC,OAAAA;MAAIC,MAAK;MAAWC,OAAO;QAAEC,eAAe,GAAGxC,MAAAA;MAAY;OAC1D,sBAAA,cAACR,MAAAA;MAAK4C;MAAcD;;AAGxBD,YAAQjC,cAAc;AACtB,WAAOiC;EACT,GAAG;IAAC1C;IAAMQ;GAAO;AAEjB,MAAIa,SAAS,GAAG;AACd,WAAO;EACT;AAEA,SACE,sBAAA,cAACG,WAAWyB,UAAQ;IAACC,SAAAA;KACnB,sBAAA,cAACC,2BAAAA;IACE,GAAGhB;IACH,GAAGT,gBAAgBX,KAAAA;IACpBY,KAAKX;IACL+B,OAAO;MAAEK,KAAK,GAAG5C,MAAAA;IAAY;IAC7BmC,MAAMd;IACNE;IACAsB,aAAab;;AAIrB,CAAA;AAGF,IAAMW,4BAA4BxC,WAChC,CAAC,EAAE,GAAGI,MAAAA,GAASuC,kBAAAA;AACb,SAAO,sBAAA,cAACC,iBAAoBxC,KAAAA;AAC9B,CAAA;AAGFa,qBAAqBnB,cAAc;AAEnC,IAAM+C,iBAAiB9C;AAMvB,IAAM+C,kBAAkB7B;AAOxB,IAAMI,iBAAiB,CACrBX,OACApB,SACAE,YACAC,gBACAE,gBACAE,WAAAA;AAEA,QAAMkD,UAAUC,MAAM,CAAA;AACtB,SAAOlB,QAAQ,MAAA;AACb,QAAIxC,WAAW,MAAM;AACnB,aAAOA;IACT;AAEA,UAAM2D,mBAAmBxD,iBAAiBsD;AAC1C,UAAMG,mBAAmBvD,iBAAiBoD;AAC1C,UAAMI,WAAWtD,SAASkD;AAC1B,QAAIrC,SAAS,KAAKuC,oBAAoB,GAAG;AACvC,aAAO;IACT;AAIA,QAAIG,OAAOC,KAAKC,MAAM5C,SAASuC,mBAAmBE,SAAO;AACzD,QAAID,mBAAmB,GAAG;AACxB,YAAMK,oBAAoB7C,QAAQ0C,OAAOD;AACzC,UAAII,oBAAoBL,kBAAkB;AAExC,cAAMM,UAAUH,KAAKI,KAAK/C,SAASwC,mBAAmBC,SAAO;AAC7D,YAAIzC,QAAQ8C,UAAUL,YAAYF,kBAAkB;AAClDG,iBAAOI;QACT;MACF;IACF;AAEA,UAAME,UAAUlE,cAAc,OAAO6D,KAAKM,IAAIP,MAAM5D,UAAAA,IAAc4D;AAClE,WAAOC,KAAKO,IAAI,GAAGF,OAAAA;EACrB,GAAG;IAACX;IAASrC;IAAOpB;IAASE;IAAYC;IAAgBE;IAAgBE;GAAO;AAClF;AAMO,IAAMgE,UAAU;EACrB/C,MAAM3B;EACN2E,SAASjB;EACTP,UAAUQ;AACZ;",
6
+ "names": ["useArrowNavigationGroup", "useComposedRefs", "createContext", "VirtuosoMasonry", "React", "useMemo", "useRef", "useResizeDetector", "ScrollArea", "usePx", "cardMaxInlineSize", "cardMinInlineSize", "composable", "composableProps", "scrollbar", "MASONRY_NAME", "MasonryProvider", "useMasonryContext", "createContext", "MasonryContentProvider", "useMasonryContentContext", "MasonryRoot", "children", "Tile", "columns", "undefined", "maxColumns", "minColumnWidth", "cardMinInlineSize", "maxColumnWidth", "cardMaxInlineSize", "gutter", "displayName", "MasonryContentInner", "composable", "centered", "thin", "padding", "props", "forwardedRef", "rootRef", "useRef", "composedRef", "useComposedRefs", "width", "useResizeDetector", "targetRef", "ScrollArea", "Root", "composableProps", "ref", "MasonryViewportInner", "items", "getId", "columnCount", "useColumnCount", "scrollbar", "size", "arrowNavigationAttrs", "useArrowNavigationGroup", "axis", "memorizeCurrent", "tabbable", "TileAdapter", "useMemo", "Adapter", "data", "index", "div", "role", "style", "paddingBottom", "Viewport", "asChild", "ComposableVirtuosoMasonry", "gap", "ItemContent", "_forwardedRef", "VirtuosoMasonry", "MasonryContent", "MasonryViewport", "remInPx", "usePx", "minColumnWidthPx", "maxColumnWidthPx", "gutterPx", "cols", "Math", "floor", "effectiveColWidth", "maxCols", "ceil", "clamped", "min", "max", "Masonry", "Content"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/Masonry.tsx":{"bytes":9891,"imports":[{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"masonic","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":454,"imports":[{"path":"src/Masonry.tsx","kind":"import-statement","original":"./Masonry"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5570},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"masonic","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"exports":["Masonry"],"entryPoint":"src/index.ts","inputs":{"src/Masonry.tsx":{"bytesInOutput":2121},"src/index.ts":{"bytesInOutput":0}},"bytes":2290}}}
1
+ {"inputs":{"src/Masonry.tsx":{"bytes":23084,"imports":[{"path":"@fluentui/react-tabster","kind":"import-statement","external":true},{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@virtuoso.dev/masonry","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":454,"imports":[{"path":"src/Masonry.tsx","kind":"import-statement","original":"./Masonry"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12486},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@fluentui/react-tabster","kind":"import-statement","external":true},{"path":"@radix-ui/react-compose-refs","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@virtuoso.dev/masonry","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"exports":["Masonry"],"entryPoint":"src/index.ts","inputs":{"src/Masonry.tsx":{"bytesInOutput":4434},"src/index.ts":{"bytesInOutput":0}},"bytes":4603}}}
@@ -1,13 +1,41 @@
1
- import { type UseMasonryOptions, type UsePositionerOptions } from 'masonic';
2
- import { type ComponentPropsWithRef, type JSX, type Ref } from 'react';
3
- import { type ThemedClassName } from '@dxos/react-ui';
4
- type MasonryRootProps<Item> = ThemedClassName<ComponentPropsWithRef<'div'>> & Omit<UsePositionerOptions, 'width'> & Omit<UseMasonryOptions<Item>, 'height' | 'scrollTop' | 'isScrolling' | 'resizeObserver' | 'positioner' | 'as' | 'id' | 'itemAs' | 'itemStyle' | 'className' | 'style' | 'role' | 'tabIndex' | 'containerRef'> & {
5
- intrinsicHeight?: boolean;
1
+ import { type ComponentType, type JSX, type PropsWithChildren, type Ref } from 'react';
2
+ import { ScrollAreaRootProps, ThemedClassName } from '@dxos/react-ui';
3
+ type MasonryContextValue = {
4
+ /** Render component for each masonry item. */
5
+ Tile: ComponentType<{
6
+ data: any;
7
+ index: number;
8
+ }>;
9
+ /** Override auto-calculated column count. */
10
+ columns: number | undefined;
11
+ /** Upper bound on number of columns. */
12
+ maxColumns: number | undefined;
13
+ /** Minimum column width in rem. */
14
+ minColumnWidth: number;
15
+ /** Maximum column width in rem. */
16
+ maxColumnWidth: number;
17
+ /** Space between columns and rows in rem. */
18
+ gutter: number;
6
19
  };
20
+ type MasonryRootProps = PropsWithChildren<Partial<MasonryContextValue>>;
21
+ type MasonryContentProps = ThemedClassName<PropsWithChildren<Pick<ScrollAreaRootProps, 'centered' | 'thin' | 'padding'>>>;
22
+ type MasonryViewportProps<Item> = ThemedClassName<{
23
+ /** Items to render in the masonry grid. */
24
+ items: Item[];
25
+ /** Extract a stable key from an item, aligned with react-ui-mosaic's getId. */
26
+ getId?: (data: Item) => string;
27
+ }>;
7
28
  export declare const Masonry: {
8
- Root: <Item>(props: MasonryRootProps<Item> & {
29
+ Root: {
30
+ ({ children, Tile, columns, maxColumns, minColumnWidth, maxColumnWidth, gutter, }: MasonryRootProps): JSX.Element;
31
+ displayName: string;
32
+ };
33
+ Content: (props: MasonryContentProps & {
34
+ ref?: Ref<HTMLDivElement | null>;
35
+ }) => JSX.Element;
36
+ Viewport: <Item>(props: MasonryViewportProps<Item> & {
9
37
  ref?: Ref<HTMLDivElement | null>;
10
38
  }) => JSX.Element;
11
39
  };
12
- export type { MasonryRootProps };
40
+ export type { MasonryRootProps, MasonryContentProps, MasonryViewportProps };
13
41
  //# sourceMappingURL=Masonry.d.ts.map