@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/dist/lib/browser/index.mjs +13 -7
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +13 -7
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/Masonry.d.ts.map +1 -1
- package/dist/types/src/Masonry.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -25
- package/src/Masonry.stories.tsx +14 -17
- package/src/Masonry.tsx +12 -8
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-masonry",
|
|
3
|
-
"version": "0.8.4-main.
|
|
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":
|
|
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
|
-
"
|
|
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.
|
|
31
|
-
"@types/react-dom": "~19.2.
|
|
32
|
-
"effect": "3.
|
|
33
|
-
"react": "~19.2.
|
|
34
|
-
"react-dom": "~19.2.
|
|
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.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/react-
|
|
40
|
-
"@dxos/react-ui
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/react-ui-stack": "0.8.4-main.
|
|
43
|
-
"@dxos/schema": "0.8.4-main.
|
|
44
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
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": "
|
|
50
|
-
"react": "
|
|
51
|
-
"react-dom": "
|
|
52
|
-
"@dxos/random": "0.8.4-main.
|
|
53
|
-
"@dxos/react-ui
|
|
54
|
-
"@dxos/
|
|
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"
|
package/src/Masonry.stories.tsx
CHANGED
|
@@ -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 {
|
|
11
|
+
import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
12
12
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
13
|
-
import { Card
|
|
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:
|
|
19
|
+
const StoryItem = ({ data: { image, name, description } }: { data: Organization.Organization }) => {
|
|
21
20
|
return (
|
|
22
|
-
<Card.
|
|
21
|
+
<Card.Root>
|
|
23
22
|
<Card.Poster alt={name!} {...(image ? { image } : { icon: 'ph--building-office--regular' })} />
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
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 } =
|
|
34
|
-
const organizations = useQuery(space, Filter.type(
|
|
30
|
+
const { space } = useClientStory();
|
|
31
|
+
const organizations = useQuery(space?.db, Filter.type(Organization.Organization));
|
|
35
32
|
|
|
36
33
|
return (
|
|
37
|
-
<Masonry.Root<
|
|
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: [
|
|
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:
|
|
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
|
|
24
|
+
import { useScroller } from '@dxos/react-hooks';
|
|
24
25
|
import { type ThemedClassName, usePx } from '@dxos/react-ui';
|
|
25
|
-
import {
|
|
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 =
|
|
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 } =
|
|
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
|
|
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,
|
|
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}
|