@dxos/plugin-masonry 0.8.4-main.03d5cd7b56

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.
Files changed (86) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +15 -0
  3. package/dist/lib/neutral/MasonryContainer-KP37NJFB.mjs +103 -0
  4. package/dist/lib/neutral/MasonryContainer-KP37NJFB.mjs.map +7 -0
  5. package/dist/lib/neutral/MasonryPlugin.mjs +26 -0
  6. package/dist/lib/neutral/MasonryPlugin.mjs.map +7 -0
  7. package/dist/lib/neutral/capabilities/index.mjs +11 -0
  8. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  9. package/dist/lib/neutral/chunk-E42CTC55.mjs +19 -0
  10. package/dist/lib/neutral/chunk-E42CTC55.mjs.map +7 -0
  11. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  12. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  13. package/dist/lib/neutral/chunk-YG4D3X6I.mjs +69 -0
  14. package/dist/lib/neutral/chunk-YG4D3X6I.mjs.map +7 -0
  15. package/dist/lib/neutral/components/index.mjs +1 -0
  16. package/dist/lib/neutral/components/index.mjs.map +7 -0
  17. package/dist/lib/neutral/containers/index.mjs +9 -0
  18. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  19. package/dist/lib/neutral/create-object-WRCYV4HT.mjs +39 -0
  20. package/dist/lib/neutral/create-object-WRCYV4HT.mjs.map +7 -0
  21. package/dist/lib/neutral/index.mjs +14 -0
  22. package/dist/lib/neutral/index.mjs.map +7 -0
  23. package/dist/lib/neutral/meta.json +1 -0
  24. package/dist/lib/neutral/meta.mjs +8 -0
  25. package/dist/lib/neutral/meta.mjs.map +7 -0
  26. package/dist/lib/neutral/plugin.mjs +12 -0
  27. package/dist/lib/neutral/plugin.mjs.map +7 -0
  28. package/dist/lib/neutral/react-surface-367CTRTD.mjs +36 -0
  29. package/dist/lib/neutral/react-surface-367CTRTD.mjs.map +7 -0
  30. package/dist/lib/neutral/translations.mjs +30 -0
  31. package/dist/lib/neutral/translations.mjs.map +7 -0
  32. package/dist/lib/neutral/types/index.mjs +10 -0
  33. package/dist/lib/neutral/types/index.mjs.map +7 -0
  34. package/dist/types/src/MasonryPlugin.d.ts +4 -0
  35. package/dist/types/src/MasonryPlugin.d.ts.map +1 -0
  36. package/dist/types/src/MasonryPlugin.test.d.ts +2 -0
  37. package/dist/types/src/MasonryPlugin.test.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/create-object.d.ts +11 -0
  39. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  40. package/dist/types/src/capabilities/index.d.ts +9 -0
  41. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  42. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  43. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  44. package/dist/types/src/components/index.d.ts +1 -0
  45. package/dist/types/src/components/index.d.ts.map +1 -0
  46. package/dist/types/src/containers/MasonryContainer/MasonryContainer.d.ts +12 -0
  47. package/dist/types/src/containers/MasonryContainer/MasonryContainer.d.ts.map +1 -0
  48. package/dist/types/src/containers/MasonryContainer/MasonryContainer.stories.d.ts +15 -0
  49. package/dist/types/src/containers/MasonryContainer/MasonryContainer.stories.d.ts.map +1 -0
  50. package/dist/types/src/containers/MasonryContainer/index.d.ts +2 -0
  51. package/dist/types/src/containers/MasonryContainer/index.d.ts.map +1 -0
  52. package/dist/types/src/containers/index.d.ts +3 -0
  53. package/dist/types/src/containers/index.d.ts.map +1 -0
  54. package/dist/types/src/index.d.ts +3 -0
  55. package/dist/types/src/index.d.ts.map +1 -0
  56. package/dist/types/src/meta.d.ts +3 -0
  57. package/dist/types/src/meta.d.ts.map +1 -0
  58. package/dist/types/src/plugin.d.ts +3 -0
  59. package/dist/types/src/plugin.d.ts.map +1 -0
  60. package/dist/types/src/translations.d.ts +28 -0
  61. package/dist/types/src/translations.d.ts.map +1 -0
  62. package/dist/types/src/types/Masonry.d.ts +22 -0
  63. package/dist/types/src/types/Masonry.d.ts.map +1 -0
  64. package/dist/types/src/types/MasonryAction.d.ts +6 -0
  65. package/dist/types/src/types/MasonryAction.d.ts.map +1 -0
  66. package/dist/types/src/types/index.d.ts +3 -0
  67. package/dist/types/src/types/index.d.ts.map +1 -0
  68. package/dist/types/tsconfig.tsbuildinfo +1 -0
  69. package/package.json +120 -0
  70. package/src/MasonryPlugin.test.ts +26 -0
  71. package/src/MasonryPlugin.tsx +21 -0
  72. package/src/capabilities/create-object.ts +36 -0
  73. package/src/capabilities/index.ts +8 -0
  74. package/src/capabilities/react-surface.tsx +34 -0
  75. package/src/components/index.ts +3 -0
  76. package/src/containers/MasonryContainer/MasonryContainer.stories.tsx +78 -0
  77. package/src/containers/MasonryContainer/MasonryContainer.tsx +130 -0
  78. package/src/containers/MasonryContainer/index.ts +5 -0
  79. package/src/containers/index.ts +7 -0
  80. package/src/index.ts +6 -0
  81. package/src/meta.ts +19 -0
  82. package/src/plugin.ts +9 -0
  83. package/src/translations.ts +30 -0
  84. package/src/types/Masonry.ts +48 -0
  85. package/src/types/MasonryAction.ts +20 -0
  86. package/src/types/index.ts +6 -0
package/package.json ADDED
@@ -0,0 +1,120 @@
1
+ {
2
+ "name": "@dxos/plugin-masonry",
3
+ "version": "0.8.4-main.03d5cd7b56",
4
+ "description": "Masonry DXOS Surface plugin",
5
+ "homepage": "https://dxos.org",
6
+ "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
11
+ "license": "MIT",
12
+ "author": "DXOS.org",
13
+ "sideEffects": true,
14
+ "type": "module",
15
+ "imports": {
16
+ "#capabilities": {
17
+ "source": "./src/capabilities/index.ts",
18
+ "types": "./dist/types/src/capabilities/index.d.ts",
19
+ "default": "./dist/lib/neutral/capabilities/index.mjs"
20
+ },
21
+ "#components": {
22
+ "source": "./src/components/index.ts",
23
+ "types": "./dist/types/src/components/index.d.ts",
24
+ "default": "./dist/lib/neutral/components/index.mjs"
25
+ },
26
+ "#containers": {
27
+ "source": "./src/containers/index.ts",
28
+ "types": "./dist/types/src/containers/index.d.ts",
29
+ "default": "./dist/lib/neutral/containers/index.mjs"
30
+ },
31
+ "#meta": {
32
+ "source": "./src/meta.ts",
33
+ "types": "./dist/types/src/meta.d.ts",
34
+ "default": "./dist/lib/neutral/meta.mjs"
35
+ },
36
+ "#plugin": {
37
+ "source": "./src/MasonryPlugin.tsx",
38
+ "types": "./dist/types/src/MasonryPlugin.d.ts",
39
+ "default": "./dist/lib/neutral/MasonryPlugin.mjs"
40
+ },
41
+ "#translations": {
42
+ "source": "./src/translations.ts",
43
+ "types": "./dist/types/src/translations.d.ts",
44
+ "default": "./dist/lib/neutral/translations.mjs"
45
+ },
46
+ "#types": {
47
+ "source": "./src/types/index.ts",
48
+ "types": "./dist/types/src/types/index.d.ts",
49
+ "default": "./dist/lib/neutral/types/index.mjs"
50
+ }
51
+ },
52
+ "exports": {
53
+ ".": {
54
+ "source": "./src/index.ts",
55
+ "types": "./dist/types/src/index.d.ts",
56
+ "default": "./dist/lib/neutral/index.mjs"
57
+ },
58
+ "./plugin": {
59
+ "source": "./src/plugin.ts",
60
+ "types": "./dist/types/src/plugin.d.ts",
61
+ "default": "./dist/lib/neutral/plugin.mjs"
62
+ },
63
+ "./translations": {
64
+ "source": "./src/translations.ts",
65
+ "types": "./dist/types/src/translations.d.ts",
66
+ "default": "./dist/lib/neutral/translations.mjs"
67
+ }
68
+ },
69
+ "types": "dist/types/src/index.d.ts",
70
+ "files": [
71
+ "dist",
72
+ "src"
73
+ ],
74
+ "dependencies": {
75
+ "@dxos/compute": "0.8.4-main.03d5cd7b56",
76
+ "@dxos/app-framework": "0.8.4-main.03d5cd7b56",
77
+ "@dxos/app-toolkit": "0.8.4-main.03d5cd7b56",
78
+ "@dxos/echo": "0.8.4-main.03d5cd7b56",
79
+ "@dxos/plugin-client": "0.8.4-main.03d5cd7b56",
80
+ "@dxos/effect": "0.8.4-main.03d5cd7b56",
81
+ "@dxos/plugin-search": "0.8.4-main.03d5cd7b56",
82
+ "@dxos/react-ui": "0.8.4-main.03d5cd7b56",
83
+ "@dxos/plugin-space": "0.8.4-main.03d5cd7b56",
84
+ "@dxos/react-client": "0.8.4-main.03d5cd7b56",
85
+ "@dxos/react-ui-form": "0.8.4-main.03d5cd7b56",
86
+ "@dxos/react-ui-list": "0.8.4-main.03d5cd7b56",
87
+ "@dxos/react-ui-masonry": "0.8.4-main.03d5cd7b56",
88
+ "@dxos/react-ui-mosaic": "0.8.4-main.03d5cd7b56",
89
+ "@dxos/react-ui-search": "0.8.4-main.03d5cd7b56",
90
+ "@dxos/react-ui-stack": "0.8.4-main.03d5cd7b56",
91
+ "@dxos/schema": "0.8.4-main.03d5cd7b56",
92
+ "@dxos/types": "0.8.4-main.03d5cd7b56",
93
+ "@dxos/util": "0.8.4-main.03d5cd7b56",
94
+ "@dxos/react-ui-menu": "0.8.4-main.03d5cd7b56"
95
+ },
96
+ "devDependencies": {
97
+ "@types/react": "~19.2.7",
98
+ "@types/react-dom": "~19.2.3",
99
+ "effect": "3.20.0",
100
+ "react": "~19.2.3",
101
+ "react-dom": "~19.2.3",
102
+ "vite": "^8.0.10",
103
+ "@dxos/random": "0.8.4-main.03d5cd7b56",
104
+ "@dxos/plugin-testing": "0.8.4-main.03d5cd7b56",
105
+ "@dxos/ui-theme": "0.8.4-main.03d5cd7b56",
106
+ "@dxos/storybook-utils": "0.8.4-main.03d5cd7b56",
107
+ "@dxos/plugin-preview": "0.8.4-main.03d5cd7b56",
108
+ "@dxos/plugin-theme": "0.8.4-main.03d5cd7b56"
109
+ },
110
+ "peerDependencies": {
111
+ "effect": "3.20.0",
112
+ "react": "~19.2.3",
113
+ "react-dom": "~19.2.3",
114
+ "@dxos/ui-theme": "0.8.4-main.03d5cd7b56",
115
+ "@dxos/react-ui": "0.8.4-main.03d5cd7b56"
116
+ },
117
+ "publishConfig": {
118
+ "access": "public"
119
+ }
120
+ }
@@ -0,0 +1,26 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, test } from 'vitest';
6
+
7
+ import { ClientPlugin } from '@dxos/plugin-client/plugin';
8
+ import { createComposerTestApp } from '@dxos/plugin-testing/harness';
9
+
10
+ import { MasonryPlugin } from '#plugin';
11
+
12
+ import { meta } from './meta';
13
+
14
+ const moduleId = (name: string) => `${meta.id}.module.${name}`;
15
+
16
+ describe('MasonryPlugin', () => {
17
+ test('modules activate on the expected events', async ({ expect }) => {
18
+ await using harness = await createComposerTestApp({
19
+ plugins: [ClientPlugin({}), MasonryPlugin()],
20
+ });
21
+
22
+ expect(harness.manager.getActive()).toEqual(
23
+ expect.arrayContaining([moduleId('CreateObject'), moduleId('schema'), moduleId('ReactSurface')]),
24
+ );
25
+ });
26
+ });
@@ -0,0 +1,21 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
7
+
8
+ import { CreateObject, ReactSurface } from '#capabilities';
9
+ import { meta } from '#meta';
10
+ import { translations } from '#translations';
11
+ import { Masonry } from '#types';
12
+
13
+ export const MasonryPlugin = Plugin.define(meta).pipe(
14
+ AppPlugin.addCreateObjectModule({ activate: CreateObject }),
15
+ AppPlugin.addSchemaModule({ schema: [Masonry.Masonry] }),
16
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
17
+ AppPlugin.addTranslationsModule({ translations }),
18
+ Plugin.make,
19
+ );
20
+
21
+ export default MasonryPlugin;
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capability } from '@dxos/app-framework';
8
+ import { Operation } from '@dxos/compute';
9
+ import { Type } from '@dxos/echo';
10
+ import { SpaceOperation } from '@dxos/plugin-space';
11
+ import { SpaceCapabilities } from '@dxos/plugin-space';
12
+ import { ViewModel } from '@dxos/schema';
13
+
14
+ import { Masonry, MasonryAction } from '#types';
15
+
16
+ export default Capability.makeModule(
17
+ Effect.fnUntraced(function* () {
18
+ return Capability.contributes(SpaceCapabilities.CreateObjectEntry, {
19
+ id: Type.getTypename(Masonry.Masonry),
20
+ inputSchema: MasonryAction.MasonryProps,
21
+ createObject: (props, options) =>
22
+ Effect.gen(function* () {
23
+ const object = yield* Effect.promise(async () => {
24
+ const { view } = await ViewModel.makeFromDatabase({ db: options.db, typename: props.typename });
25
+ return Masonry.make({ name: props.name, view });
26
+ });
27
+ return yield* Operation.invoke(SpaceOperation.AddObject, {
28
+ object,
29
+ target: options.target,
30
+ hidden: true,
31
+ targetNodeId: options.targetNodeId,
32
+ });
33
+ }),
34
+ });
35
+ }),
36
+ );
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const CreateObject = Capability.lazy('CreateObject', () => import('./create-object'));
8
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -0,0 +1,34 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import React from 'react';
7
+
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
11
+ import { Obj } from '@dxos/echo';
12
+ import { View } from '@dxos/echo';
13
+
14
+ import { MasonryContainer } from '#containers';
15
+ import { Masonry } from '#types';
16
+
17
+ export default Capability.makeModule(() =>
18
+ Effect.succeed(
19
+ Capability.contributes(Capabilities.ReactSurface, [
20
+ Surface.create({
21
+ id: 'root',
22
+ // TODO(wittjosiah): Split into multiple surfaces if this filter proves too strict for non-article roles.
23
+ filter: AppSurface.oneOf(
24
+ AppSurface.object(AppSurface.Article, [Masonry.Masonry, View.View]),
25
+ AppSurface.object(AppSurface.Section, [Masonry.Masonry, View.View]),
26
+ ),
27
+ component: ({ data, role }) => {
28
+ const view = Obj.instanceOf(View.View, data.subject) ? data.subject : data.subject.view;
29
+ return <MasonryContainer view={view} role={role} />;
30
+ },
31
+ }),
32
+ ]),
33
+ ),
34
+ );
@@ -0,0 +1,3 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
@@ -0,0 +1,78 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import * as Effect from 'effect/Effect';
7
+ import React from 'react';
8
+
9
+ import { withPluginManager } from '@dxos/app-framework/testing';
10
+ import { View } from '@dxos/echo';
11
+ import { ClientPlugin } from '@dxos/plugin-client/plugin';
12
+ import { initializeIdentity } from '@dxos/plugin-client/testing';
13
+ import { PreviewPlugin } from '@dxos/plugin-preview/testing';
14
+ import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
15
+ import { random } from '@dxos/random';
16
+ import { Filter, useObject, useQuery, useSpaces } from '@dxos/react-client/echo';
17
+ import { ViewModel } from '@dxos/schema';
18
+ import { createObjectFactory } from '@dxos/schema/testing';
19
+ import { Organization } from '@dxos/types';
20
+
21
+ import { Masonry } from '#types';
22
+
23
+ import { MasonryContainer } from './MasonryContainer';
24
+
25
+ random.seed(0);
26
+
27
+ const StorybookMasonry = () => {
28
+ const spaces = useSpaces();
29
+ const space = spaces[spaces.length - 1];
30
+ const masonries = useQuery(space?.db, Filter.type(Masonry.Masonry));
31
+ const [masonry] = useObject(masonries.at(0));
32
+
33
+ return masonry ? <MasonryContainer view={masonry.view} role='story' /> : null;
34
+ };
35
+
36
+ const meta = {
37
+ title: 'plugins/plugin-masonry/containers/Masonry',
38
+ component: StorybookMasonry,
39
+ render: () => <StorybookMasonry />,
40
+ decorators: [
41
+ withPluginManager({
42
+ plugins: [
43
+ ...corePlugins(),
44
+ StorybookPlugin({}),
45
+ ClientPlugin({
46
+ types: [Organization.Organization, View.View, Masonry.Masonry],
47
+ onClientInitialized: ({ client }) =>
48
+ Effect.gen(function* () {
49
+ yield* initializeIdentity(client);
50
+ const space = yield* Effect.promise(() => client.spaces.create());
51
+ yield* Effect.promise(() => space.waitUntilReady());
52
+ const { view } = yield* Effect.promise(() =>
53
+ ViewModel.makeFromDatabase({
54
+ db: space.db,
55
+ typename: Organization.Organization.typename,
56
+ }),
57
+ );
58
+ const masonry = Masonry.make({ view });
59
+ space.db.add(masonry);
60
+ const factory = createObjectFactory(space.db, random as any);
61
+ yield* Effect.promise(() => factory([{ type: Organization.Organization, count: 64 }]));
62
+ }),
63
+ }),
64
+
65
+ PreviewPlugin(),
66
+ ],
67
+ }),
68
+ ],
69
+ parameters: {
70
+ layout: 'fullscreen',
71
+ },
72
+ } satisfies Meta;
73
+
74
+ export default meta;
75
+
76
+ type Story = StoryObj<typeof meta>;
77
+
78
+ export const Default: Story = {};
@@ -0,0 +1,130 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Function from 'effect/Function';
6
+ import * as Option from 'effect/Option';
7
+ import type * as Schema from 'effect/Schema';
8
+ import React, { useEffect, useMemo, useState } from 'react';
9
+
10
+ import { Surface, useCapabilities } from '@dxos/app-framework/ui';
11
+ import { AppCapabilities } from '@dxos/app-toolkit';
12
+ import { AppSurface, useObjectMenuItems } from '@dxos/app-toolkit/ui';
13
+ import { Annotation, Filter, Obj, Query, type Ref, Type } from '@dxos/echo';
14
+ import { type View } from '@dxos/echo';
15
+ import { useObject, useQuery } from '@dxos/react-client/echo';
16
+ import { Card, Panel, Toolbar } from '@dxos/react-ui';
17
+ import { Masonry as MasonryComponent } from '@dxos/react-ui-masonry';
18
+ import { Menu } from '@dxos/react-ui-menu';
19
+ import { SearchList, useSearchListResults } from '@dxos/react-ui-search';
20
+ import { getTagFromQuery, getTypenameFromQuery } from '@dxos/schema';
21
+ import { isNonNullable } from '@dxos/util';
22
+
23
+ export type MasonryContainerProps = {
24
+ view: View.View;
25
+ role?: string;
26
+ };
27
+
28
+ export const MasonryContainer = ({
29
+ view: viewOrRef,
30
+ role: _role,
31
+ }: {
32
+ view: View.View | Ref.Ref<View.View>;
33
+ role?: string;
34
+ }) => {
35
+ const [view] = useObject(viewOrRef);
36
+ const schemas = useCapabilities(AppCapabilities.Schema);
37
+ const db = view && Obj.getDatabase(view);
38
+ const typename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
39
+ const tag = view?.query ? getTagFromQuery(view.query.ast) : undefined;
40
+
41
+ const [cardSchema, setCardSchema] = useState<Schema.Schema.AnyNoContext>();
42
+
43
+ useEffect(() => {
44
+ const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
45
+ if (staticSchema) {
46
+ setCardSchema(() => staticSchema);
47
+ }
48
+ if (!staticSchema && typename && db) {
49
+ const query = db.schemaRegistry.query({ typename });
50
+ const unsubscribe = query.subscribe(
51
+ () => {
52
+ const [schema] = query.results;
53
+ if (schema) {
54
+ setCardSchema(schema);
55
+ }
56
+ },
57
+ { fire: true },
58
+ );
59
+ return unsubscribe;
60
+ }
61
+ }, [schemas, typename, db]);
62
+
63
+ const query = useMemo(() => {
64
+ const baseFilter = cardSchema ? Filter.type(cardSchema) : Filter.nothing();
65
+ return tag ? Query.select(baseFilter).select(Filter.tag(tag)) : Query.select(baseFilter);
66
+ }, [cardSchema, tag]);
67
+ const objects = useQuery(db, query);
68
+
69
+ const sortedObjects = useMemo(
70
+ () =>
71
+ objects.filter(isNonNullable).toSorted((a, b) => (Obj.getLabel(a) ?? '').localeCompare(Obj.getLabel(b) ?? '')),
72
+ [objects],
73
+ );
74
+
75
+ const { results, handleSearch } = useSearchListResults({
76
+ items: sortedObjects,
77
+ extract: (obj) => Obj.getLabel(obj) ?? '',
78
+ });
79
+
80
+ return (
81
+ <MasonryComponent.Root Tile={Item}>
82
+ <SearchList.Root onSearch={handleSearch}>
83
+ <Panel.Root>
84
+ <Panel.Toolbar asChild>
85
+ <Toolbar.Root>
86
+ <SearchList.Input placeholder='Search...' />
87
+ </Toolbar.Root>
88
+ </Panel.Toolbar>
89
+ <Panel.Content>
90
+ <MasonryComponent.Content>
91
+ <MasonryComponent.Viewport items={results} getId={(data: any) => data?.id} />
92
+ </MasonryComponent.Content>
93
+ </Panel.Content>
94
+ </Panel.Root>
95
+ </SearchList.Root>
96
+ </MasonryComponent.Root>
97
+ );
98
+ };
99
+
100
+ const Item = ({ data }: { data: any }) => {
101
+ const objectMenuItems = useObjectMenuItems(data);
102
+ const icon = Function.pipe(
103
+ Obj.getSchema(data),
104
+ Option.fromNullable,
105
+ Option.flatMap(Annotation.IconAnnotation.get),
106
+ Option.map(({ icon }) => icon),
107
+ Option.getOrElse(() => 'ph--placeholder--regular'),
108
+ );
109
+
110
+ return (
111
+ <Menu.Root>
112
+ <Card.Root>
113
+ <Card.Toolbar>
114
+ <Card.Icon icon={icon} />
115
+ <Card.Title>{Obj.getLabel(data)}</Card.Title>
116
+ {/* TODO(wittjosiah): Reconcile with Card.Menu. */}
117
+ <Menu.Trigger asChild disabled={!objectMenuItems?.length}>
118
+ <Toolbar.IconButton iconOnly variant='ghost' icon='ph--dots-three-vertical--regular' label='Actions' />
119
+ </Menu.Trigger>
120
+ <Menu.Content items={objectMenuItems} />
121
+ </Card.Toolbar>
122
+ <Surface.Surface
123
+ type={AppSurface.Card}
124
+ limit={1}
125
+ data={{ subject: data } satisfies AppSurface.ObjectCardData}
126
+ />
127
+ </Card.Root>
128
+ </Menu.Root>
129
+ );
130
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export { MasonryContainer as default } from './MasonryContainer';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type ComponentType, lazy } from 'react';
6
+
7
+ export const MasonryContainer: ComponentType<any> = lazy(() => import('./MasonryContainer'));
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './meta';
6
+ export * from './types';
package/src/meta.ts ADDED
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
7
+
8
+ export const meta: Plugin.Meta = {
9
+ id: 'org.dxos.plugin.masonry',
10
+ name: 'Masonry',
11
+ description: trim`
12
+ Responsive grid layout that displays query results in an adaptive masonry pattern.
13
+ Visualize collections of cards, images, or mixed content that automatically adjusts to available screen space.
14
+ `,
15
+ icon: 'ph--wall--regular',
16
+ iconHue: 'green',
17
+ source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-masonry',
18
+ screenshots: [],
19
+ };
package/src/plugin.ts ADDED
@@ -0,0 +1,9 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+
7
+ import { meta } from './meta';
8
+
9
+ export const MasonryPlugin = Plugin.lazy(meta, () => import('#plugin'));
@@ -0,0 +1,30 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Type } from '@dxos/echo';
6
+ import { type Resource } from '@dxos/react-ui';
7
+
8
+ import { meta } from '#meta';
9
+ import { Masonry } from '#types';
10
+
11
+ export const translations = [
12
+ {
13
+ 'en-US': {
14
+ [Type.getTypename(Masonry.Masonry)]: {
15
+ 'typename.label': 'Masonry',
16
+ 'typename.label_zero': 'Masonries',
17
+ 'typename.label_one': 'Masonry',
18
+ 'typename.label_other': 'Masonries',
19
+ 'object-name.placeholder': 'New masonry',
20
+ 'add-object.label': 'Add masonry',
21
+ 'rename-object.label': 'Rename masonry',
22
+ 'delete-object.label': 'Delete masonry',
23
+ 'object-deleted.label': 'Masonry deleted',
24
+ },
25
+ [meta.id]: {
26
+ 'plugin.name': 'Masonry',
27
+ },
28
+ },
29
+ },
30
+ ] as const satisfies Resource[];
@@ -0,0 +1,48 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { Annotation, Obj, Ref, Type } from '@dxos/echo';
8
+ import { View } from '@dxos/echo';
9
+ import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
10
+ import { ViewAnnotation } from '@dxos/schema';
11
+
12
+ export const Masonry = Schema.Struct({
13
+ name: Schema.String.pipe(Schema.optional),
14
+
15
+ view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
16
+
17
+ arrangement: Schema.Array(
18
+ Schema.Struct({
19
+ ids: Schema.Array(Obj.ID),
20
+ hidden: Schema.optional(Schema.Boolean),
21
+ }),
22
+ ).pipe(FormInputAnnotation.set(false), Schema.optional),
23
+ // TODO(wittjosiah): Consider Masonry supporting not being just a view but referencing arbitrary data directly.
24
+ }).pipe(
25
+ Type.object({
26
+ typename: 'org.dxos.type.masonry',
27
+ version: '0.1.0',
28
+ }),
29
+ LabelAnnotation.set(['name']),
30
+ ViewAnnotation.set(['view']),
31
+ Annotation.IconAnnotation.set({
32
+ icon: 'ph--wall--regular',
33
+ hue: 'green',
34
+ }),
35
+ );
36
+
37
+ export interface Masonry extends Schema.Schema.Type<typeof Masonry> {}
38
+
39
+ type MakeProps = Omit<Partial<Obj.MakeProps<typeof Masonry>>, 'view'> & {
40
+ view: View.View;
41
+ };
42
+
43
+ /**
44
+ * Make a masonry as a view of a data set.
45
+ */
46
+ export const make = ({ name, arrangement = [], view }: MakeProps): Masonry => {
47
+ return Obj.make(Masonry, { name, view: Ref.make(view), arrangement });
48
+ };
@@ -0,0 +1,20 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { TypeInputOptionsAnnotation } from '@dxos/plugin-space';
8
+
9
+ export const MasonryProps = Schema.Struct({
10
+ name: Schema.optional(Schema.String),
11
+ // TODO(wittjosiah): This should be a query input instead.
12
+ typename: Schema.String.pipe(
13
+ Schema.annotations({ title: 'Select card type' }),
14
+ TypeInputOptionsAnnotation.set({
15
+ location: ['database', 'runtime'],
16
+ kind: ['user'],
17
+ }),
18
+ Schema.optional,
19
+ ),
20
+ });
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * as Masonry from './Masonry';
6
+ export * as MasonryAction from './MasonryAction';