@dxos/react-ui-masonry 0.8.4-main.ae835ea → 0.8.4-main.c351d160a8

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.ae835ea",
3
+ "version": "0.8.4-main.c351d160a8",
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.ae835ea"
31
+ "react-resize-detector": "^11.0.1",
32
+ "@dxos/react-ui-mosaic": "0.8.4-main.c351d160a8",
33
+ "@dxos/types": "0.8.4-main.c351d160a8",
34
+ "@dxos/react-hooks": "0.8.4-main.c351d160a8"
28
35
  },
29
36
  "devDependencies": {
30
- "@types/react": "~19.2.2",
31
- "@types/react-dom": "~19.2.2",
32
- "effect": "3.18.3",
33
- "react": "~19.2.0",
34
- "react-dom": "~19.2.0",
35
- "vite": "7.1.9",
36
- "@dxos/client": "0.8.4-main.ae835ea",
37
- "@dxos/echo": "0.8.4-main.ae835ea",
38
- "@dxos/random": "0.8.4-main.ae835ea",
39
- "@dxos/react-ui": "0.8.4-main.ae835ea",
40
- "@dxos/react-client": "0.8.4-main.ae835ea",
41
- "@dxos/react-ui-stack": "0.8.4-main.ae835ea",
42
- "@dxos/react-ui-theme": "0.8.4-main.ae835ea",
43
- "@dxos/schema": "0.8.4-main.ae835ea",
44
- "@dxos/storybook-utils": "0.8.4-main.ae835ea",
45
- "@dxos/react-ui-form": "0.8.4-main.ae835ea",
46
- "@dxos/test-utils": "0.8.4-main.ae835ea"
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",
42
+ "vite": "^7.1.11",
43
+ "@dxos/client": "0.8.4-main.c351d160a8",
44
+ "@dxos/random": "0.8.4-main.c351d160a8",
45
+ "@dxos/react-client": "0.8.4-main.c351d160a8",
46
+ "@dxos/react-ui": "0.8.4-main.c351d160a8",
47
+ "@dxos/react-ui-form": "0.8.4-main.c351d160a8",
48
+ "@dxos/react-ui-stack": "0.8.4-main.c351d160a8",
49
+ "@dxos/test-utils": "0.8.4-main.c351d160a8",
50
+ "@dxos/ui-theme": "0.8.4-main.c351d160a8",
51
+ "@dxos/echo": "0.8.4-main.c351d160a8",
52
+ "@dxos/storybook-utils": "0.8.4-main.c351d160a8",
53
+ "@dxos/schema": "0.8.4-main.c351d160a8"
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.ae835ea",
53
- "@dxos/react-ui-theme": "0.8.4-main.ae835ea",
54
- "@dxos/react-ui": "0.8.4-main.ae835ea"
56
+ "effect": "3.19.16",
57
+ "react": "~19.2.3",
58
+ "react-dom": "~19.2.3",
59
+ "@dxos/random": "0.8.4-main.c351d160a8",
60
+ "@dxos/ui-theme": "0.8.4-main.c351d160a8",
61
+ "@dxos/react-ui": "0.8.4-main.c351d160a8"
55
62
  },
56
63
  "publishConfig": {
57
64
  "access": "public"
@@ -8,36 +8,33 @@ 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';
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';
11
+ import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
12
+ import { Card } from '@dxos/react-ui';
13
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
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
- classNames='is-full max-is-full bs-full max-bs-full overflow-y-auto p-4'
37
+ classNames='w-full max-w-full h-full max-h-full overflow-y-auto p-4'
41
38
  />
42
39
  );
43
40
  };
@@ -45,14 +42,15 @@ const DefaultStory = () => {
45
42
  const meta = {
46
43
  title: 'ui/react-ui-masonry/Masonry',
47
44
  decorators: [
48
- withTheme,
45
+ withTheme(),
46
+ withLayout({ layout: 'fullscreen' }),
49
47
  withClientProvider({
50
- types: [DataType.Organization],
48
+ types: [Organization.Organization],
51
49
  createIdentity: true,
52
50
  createSpace: true,
53
51
  onCreateSpace: async ({ space }) => {
54
52
  const factory = createObjectFactory(space.db, faker as any);
55
- await factory([{ type: DataType.Organization, count: 36 }]);
53
+ await factory([{ type: Organization.Organization, count: 36 }]);
56
54
  },
57
55
  }),
58
56
  ],
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'> &
@@ -57,13 +59,12 @@ const usePxProps = (remProps: Omit<UsePositionerOptions, 'width' | 'columnCount'
57
59
  }, [remProps, remInPx]);
58
60
  };
59
61
 
60
- // TODO(burdon): Currently not responsive to width.
61
62
  const MasonryRootImpl = <Item,>(
62
63
  {
63
64
  columnCount,
64
65
  maxColumnCount,
65
- columnWidth = 18, // cardMaxWidth
66
- maxColumnWidth = 22,
66
+ columnWidth = cardMinInlineSize,
67
+ maxColumnWidth = cardMaxInlineSize,
67
68
  columnGutter = 1,
68
69
  rowGutter,
69
70
  items,
@@ -80,21 +81,22 @@ const MasonryRootImpl = <Item,>(
80
81
  ) => {
81
82
  const rootRef = useRef<HTMLDivElement | null>(null);
82
83
  const ref = useComposedRefs(rootRef, forwardedRef);
83
- const { width, height } = useSize(rootRef);
84
+ const { width = 0, height = 0 } = useResizeDetector({ targetRef: rootRef });
84
85
  const { scrollTop, isScrolling } = useScroller(rootRef);
85
86
  const remProps = useMemo(
86
87
  () => ({ columnWidth, maxColumnWidth, columnGutter, rowGutter }),
87
88
  [columnWidth, maxColumnWidth, columnGutter, rowGutter],
88
89
  );
89
90
  const pxProps = usePxProps(remProps);
91
+ const numItems = items.length;
90
92
  const positionerProps = useMemo<UsePositionerOptions>(
91
93
  () => ({
92
94
  width,
93
95
  columnCount,
94
- maxColumnCount,
96
+ maxColumnCount: Math.max(maxColumnCount ?? 1, numItems),
95
97
  ...pxProps,
96
98
  }),
97
- [width, pxProps, columnCount, maxColumnCount],
99
+ [width, columnCount, maxColumnCount, numItems, pxProps],
98
100
  );
99
101
  const positioner = usePositioner(positionerProps, [positionerProps]);
100
102
  const resizeObserver = useResizeObserver(positioner);