@dxos/react-ui-masonry 0.8.4-main.ead640a → 0.8.4-main.ef1bc66f44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-masonry",
3
- "version": "0.8.4-main.ead640a",
3
+ "version": "0.8.4-main.ef1bc66f44",
4
4
  "description": "A masonry component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
- "sideEffects": true,
13
+ "sideEffects": false,
10
14
  "type": "module",
11
15
  "exports": {
12
16
  ".": {
@@ -24,34 +28,37 @@
24
28
  "dependencies": {
25
29
  "@radix-ui/react-compose-refs": "1.1.1",
26
30
  "masonic": "^4.1.0",
27
- "@dxos/react-hooks": "0.8.4-main.ead640a"
31
+ "react-resize-detector": "^11.0.1",
32
+ "@dxos/react-hooks": "0.8.4-main.ef1bc66f44",
33
+ "@dxos/react-ui-mosaic": "0.8.4-main.ef1bc66f44",
34
+ "@dxos/types": "0.8.4-main.ef1bc66f44"
28
35
  },
29
36
  "devDependencies": {
30
- "@types/react": "~19.2.2",
31
- "@types/react-dom": "~19.2.1",
32
- "effect": "3.18.3",
33
- "react": "~19.2.0",
34
- "react-dom": "~19.2.0",
37
+ "@types/react": "~19.2.7",
38
+ "@types/react-dom": "~19.2.3",
39
+ "effect": "3.19.16",
40
+ "react": "~19.2.3",
41
+ "react-dom": "~19.2.3",
35
42
  "vite": "7.1.9",
36
- "@dxos/client": "0.8.4-main.ead640a",
37
- "@dxos/react-client": "0.8.4-main.ead640a",
38
- "@dxos/echo": "0.8.4-main.ead640a",
39
- "@dxos/react-ui": "0.8.4-main.ead640a",
40
- "@dxos/react-ui-form": "0.8.4-main.ead640a",
41
- "@dxos/random": "0.8.4-main.ead640a",
42
- "@dxos/react-ui-stack": "0.8.4-main.ead640a",
43
- "@dxos/schema": "0.8.4-main.ead640a",
44
- "@dxos/storybook-utils": "0.8.4-main.ead640a",
45
- "@dxos/react-ui-theme": "0.8.4-main.ead640a",
46
- "@dxos/test-utils": "0.8.4-main.ead640a"
43
+ "@dxos/client": "0.8.4-main.ef1bc66f44",
44
+ "@dxos/echo": "0.8.4-main.ef1bc66f44",
45
+ "@dxos/random": "0.8.4-main.ef1bc66f44",
46
+ "@dxos/react-client": "0.8.4-main.ef1bc66f44",
47
+ "@dxos/react-ui": "0.8.4-main.ef1bc66f44",
48
+ "@dxos/react-ui-form": "0.8.4-main.ef1bc66f44",
49
+ "@dxos/react-ui-stack": "0.8.4-main.ef1bc66f44",
50
+ "@dxos/schema": "0.8.4-main.ef1bc66f44",
51
+ "@dxos/storybook-utils": "0.8.4-main.ef1bc66f44",
52
+ "@dxos/test-utils": "0.8.4-main.ef1bc66f44",
53
+ "@dxos/ui-theme": "0.8.4-main.ef1bc66f44"
47
54
  },
48
55
  "peerDependencies": {
49
- "effect": "^3.13.3",
50
- "react": "^19.0.0",
51
- "react-dom": "^19.0.0",
52
- "@dxos/random": "0.8.4-main.ead640a",
53
- "@dxos/react-ui-theme": "0.8.4-main.ead640a",
54
- "@dxos/react-ui": "0.8.4-main.ead640a"
56
+ "effect": "3.19.16",
57
+ "react": "~19.2.3",
58
+ "react-dom": "~19.2.3",
59
+ "@dxos/random": "0.8.4-main.ef1bc66f44",
60
+ "@dxos/react-ui": "0.8.4-main.ef1bc66f44",
61
+ "@dxos/ui-theme": "0.8.4-main.ef1bc66f44"
55
62
  },
56
63
  "publishConfig": {
57
64
  "access": "public"
@@ -8,33 +8,30 @@ import React from 'react';
8
8
  import { Filter } from '@dxos/client/echo';
9
9
  import { faker } from '@dxos/random';
10
10
  import { useQuery } from '@dxos/react-client/echo';
11
- import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
11
+ import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
12
12
  import { withTheme } from '@dxos/react-ui/testing';
13
- import { Card, cardNoSpacing, cardSpacing } from '@dxos/react-ui-stack';
14
- import { mx } from '@dxos/react-ui-theme';
15
- import { DataType } from '@dxos/schema';
13
+ import { Card } from '@dxos/react-ui-mosaic';
16
14
  import { createObjectFactory } from '@dxos/schema/testing';
15
+ import { Organization } from '@dxos/types';
17
16
 
18
17
  import { Masonry } from './Masonry';
19
18
 
20
- const StoryItem = ({ data: { image, name, description } }: { data: DataType.Organization }) => {
19
+ const StoryItem = ({ data: { image, name, description } }: { data: Organization.Organization }) => {
21
20
  return (
22
- <Card.StaticRoot>
21
+ <Card.Root>
23
22
  <Card.Poster alt={name!} {...(image ? { image } : { icon: 'ph--building-office--regular' })} />
24
- <div role='none' className={mx('flex items-center gap-2', cardSpacing)}>
25
- <Card.Heading classNames={cardNoSpacing}>{name}</Card.Heading>
26
- </div>
27
- {description && <Card.Text classNames='line-clamp-2'>{description}</Card.Text>}
28
- </Card.StaticRoot>
23
+ <Card.Heading>{name}</Card.Heading>
24
+ {description && <Card.Text variant='description'>{description}</Card.Text>}
25
+ </Card.Root>
29
26
  );
30
27
  };
31
28
 
32
29
  const DefaultStory = () => {
33
- const { space } = useClientProvider();
34
- const organizations = useQuery(space, Filter.type(DataType.Organization));
30
+ const { space } = useClientStory();
31
+ const organizations = useQuery(space?.db, Filter.type(Organization.Organization));
35
32
 
36
33
  return (
37
- <Masonry.Root<DataType.Organization>
34
+ <Masonry.Root<Organization.Organization>
38
35
  items={organizations}
39
36
  render={StoryItem}
40
37
  classNames='is-full max-is-full bs-full max-bs-full overflow-y-auto p-4'
@@ -45,14 +42,14 @@ const DefaultStory = () => {
45
42
  const meta = {
46
43
  title: 'ui/react-ui-masonry/Masonry',
47
44
  decorators: [
48
- withTheme,
45
+ withTheme(),
49
46
  withClientProvider({
50
- types: [DataType.Organization],
47
+ types: [Organization.Organization],
51
48
  createIdentity: true,
52
49
  createSpace: true,
53
50
  onCreateSpace: async ({ space }) => {
54
51
  const factory = createObjectFactory(space.db, faker as any);
55
- await factory([{ type: DataType.Organization, count: 36 }]);
52
+ await factory([{ type: Organization.Organization, count: 36 }]);
56
53
  },
57
54
  }),
58
55
  ],
package/src/Masonry.tsx CHANGED
@@ -19,10 +19,12 @@ import React, {
19
19
  useMemo,
20
20
  useRef,
21
21
  } from 'react';
22
+ import { useResizeDetector } from 'react-resize-detector';
22
23
 
23
- import { useScroller, useSize } from '@dxos/react-hooks';
24
+ import { useScroller } from '@dxos/react-hooks';
24
25
  import { type ThemedClassName, usePx } from '@dxos/react-ui';
25
- import { mx } from '@dxos/react-ui-theme';
26
+ import { cardMaxInlineSize, cardMinInlineSize } from '@dxos/ui-theme';
27
+ import { mx } from '@dxos/ui-theme';
26
28
 
27
29
  type MasonryRootProps<Item> = ThemedClassName<ComponentPropsWithRef<'div'>> &
28
30
  Omit<UsePositionerOptions, 'width'> &
@@ -61,8 +63,8 @@ const MasonryRootImpl = <Item,>(
61
63
  {
62
64
  columnCount,
63
65
  maxColumnCount,
64
- columnWidth = 18,
65
- maxColumnWidth,
66
+ columnWidth = cardMinInlineSize,
67
+ maxColumnWidth = cardMaxInlineSize,
66
68
  columnGutter = 1,
67
69
  rowGutter,
68
70
  items,
@@ -79,21 +81,22 @@ const MasonryRootImpl = <Item,>(
79
81
  ) => {
80
82
  const rootRef = useRef<HTMLDivElement | null>(null);
81
83
  const ref = useComposedRefs(rootRef, forwardedRef);
82
- const { width, height } = useSize(rootRef);
84
+ const { width = 0, height = 0 } = useResizeDetector({ targetRef: rootRef });
83
85
  const { scrollTop, isScrolling } = useScroller(rootRef);
84
86
  const remProps = useMemo(
85
87
  () => ({ columnWidth, maxColumnWidth, columnGutter, rowGutter }),
86
88
  [columnWidth, maxColumnWidth, columnGutter, rowGutter],
87
89
  );
88
90
  const pxProps = usePxProps(remProps);
89
- const positionerProps = useMemo(
91
+ const numItems = items.length;
92
+ const positionerProps = useMemo<UsePositionerOptions>(
90
93
  () => ({
91
94
  width,
92
95
  columnCount,
93
- maxColumnCount,
96
+ maxColumnCount: Math.max(maxColumnCount ?? 1, numItems),
94
97
  ...pxProps,
95
98
  }),
96
- [width, pxProps, columnCount, maxColumnCount],
99
+ [width, columnCount, maxColumnCount, numItems, pxProps],
97
100
  );
98
101
  const positioner = usePositioner(positionerProps, [positionerProps]);
99
102
  const resizeObserver = useResizeObserver(positioner);
@@ -110,6 +113,7 @@ const MasonryRootImpl = <Item,>(
110
113
  render,
111
114
  onRender,
112
115
  });
116
+
113
117
  return (
114
118
  <div className={mx(classNames)} {...props} ref={ref}>
115
119
  {children}