@dxos/plugin-masonry 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef

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 (84) hide show
  1. package/dist/lib/browser/MasonryPlugin-KWQYOKCW.mjs +57 -0
  2. package/dist/lib/browser/MasonryPlugin-KWQYOKCW.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  4. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +19 -66
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/translations.mjs +30 -0
  9. package/dist/lib/browser/translations.mjs.map +7 -0
  10. package/dist/lib/browser/types/index.mjs +62 -3
  11. package/dist/lib/browser/types/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/MasonryPlugin-YENAI2WP.mjs +58 -0
  13. package/dist/lib/node-esm/MasonryPlugin-YENAI2WP.mjs.map +7 -0
  14. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  15. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +19 -66
  17. package/dist/lib/node-esm/index.mjs.map +4 -4
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/translations.mjs +31 -0
  20. package/dist/lib/node-esm/translations.mjs.map +7 -0
  21. package/dist/lib/node-esm/types/index.mjs +62 -3
  22. package/dist/lib/node-esm/types/index.mjs.map +4 -4
  23. package/dist/types/src/MasonryPlugin.d.ts +1 -0
  24. package/dist/types/src/MasonryPlugin.d.ts.map +1 -1
  25. package/dist/types/src/MasonryPlugin.test.d.ts +2 -0
  26. package/dist/types/src/MasonryPlugin.test.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/index.d.ts +2 -1
  28. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  29. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  30. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  31. package/dist/types/src/components/index.d.ts +1 -0
  32. package/dist/types/src/components/index.d.ts.map +1 -0
  33. package/dist/types/src/{components → containers/MasonryContainer}/MasonryContainer.d.ts +2 -2
  34. package/dist/types/src/containers/MasonryContainer/MasonryContainer.d.ts.map +1 -0
  35. package/dist/types/src/containers/MasonryContainer/MasonryContainer.stories.d.ts.map +1 -0
  36. package/dist/types/src/containers/MasonryContainer/index.d.ts +2 -0
  37. package/dist/types/src/containers/MasonryContainer/index.d.ts.map +1 -0
  38. package/dist/types/src/containers/index.d.ts +3 -0
  39. package/dist/types/src/containers/index.d.ts.map +1 -0
  40. package/dist/types/src/index.d.ts +2 -1
  41. package/dist/types/src/index.d.ts.map +1 -1
  42. package/dist/types/src/translations.d.ts +20 -18
  43. package/dist/types/src/translations.d.ts.map +1 -1
  44. package/dist/types/src/types/Masonry.d.ts +3 -9
  45. package/dist/types/src/types/Masonry.d.ts.map +1 -1
  46. package/dist/types/src/types/MasonryAction.d.ts.map +1 -1
  47. package/dist/types/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +47 -35
  49. package/src/MasonryPlugin.test.ts +26 -0
  50. package/src/MasonryPlugin.tsx +31 -17
  51. package/src/capabilities/index.ts +3 -1
  52. package/src/capabilities/react-surface.tsx +34 -0
  53. package/src/components/index.ts +3 -0
  54. package/src/{components → containers/MasonryContainer}/MasonryContainer.stories.tsx +10 -10
  55. package/src/containers/MasonryContainer/MasonryContainer.tsx +130 -0
  56. package/src/containers/MasonryContainer/index.ts +5 -0
  57. package/src/containers/index.ts +7 -0
  58. package/src/index.ts +6 -2
  59. package/src/meta.ts +1 -1
  60. package/src/translations.ts +12 -11
  61. package/src/types/Masonry.ts +11 -24
  62. package/src/types/MasonryAction.ts +0 -1
  63. package/dist/lib/browser/chunk-S5JKAK4O.mjs +0 -78
  64. package/dist/lib/browser/chunk-S5JKAK4O.mjs.map +0 -7
  65. package/dist/lib/browser/chunk-U46AGJ2D.mjs +0 -19
  66. package/dist/lib/browser/chunk-U46AGJ2D.mjs.map +0 -7
  67. package/dist/lib/browser/react-surface-UCYEF4QU.mjs +0 -94
  68. package/dist/lib/browser/react-surface-UCYEF4QU.mjs.map +0 -7
  69. package/dist/lib/node-esm/chunk-P6EZJITS.mjs +0 -21
  70. package/dist/lib/node-esm/chunk-P6EZJITS.mjs.map +0 -7
  71. package/dist/lib/node-esm/chunk-YNA44I6R.mjs +0 -79
  72. package/dist/lib/node-esm/chunk-YNA44I6R.mjs.map +0 -7
  73. package/dist/lib/node-esm/react-surface-LG7FTGYA.mjs +0 -95
  74. package/dist/lib/node-esm/react-surface-LG7FTGYA.mjs.map +0 -7
  75. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  76. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  77. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  78. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  79. package/dist/types/src/components/MasonryContainer.d.ts.map +0 -1
  80. package/dist/types/src/components/MasonryContainer.stories.d.ts.map +0 -1
  81. package/src/capabilities/react-surface/index.ts +0 -7
  82. package/src/capabilities/react-surface/react-surface.tsx +0 -31
  83. package/src/components/MasonryContainer.tsx +0 -79
  84. /package/dist/types/src/{components → containers/MasonryContainer}/MasonryContainer.stories.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-masonry",
3
- "version": "0.8.4-main.9735255",
3
+ "version": "0.8.4-main.abd8ff62ef",
4
4
  "description": "Masonry DXOS Surface plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -12,6 +12,15 @@
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": true,
14
14
  "type": "module",
15
+ "imports": {
16
+ "#plugin": "./src/MasonryPlugin.tsx",
17
+ "#capabilities": "./src/capabilities/index.ts",
18
+ "#components": "./src/components/index.ts",
19
+ "#containers": "./src/containers/index.ts",
20
+ "#meta": "./src/meta.ts",
21
+ "#translations": "./src/translations.ts",
22
+ "#types": "./src/types/index.ts"
23
+ },
15
24
  "exports": {
16
25
  ".": {
17
26
  "source": "./src/index.ts",
@@ -19,6 +28,12 @@
19
28
  "browser": "./dist/lib/browser/index.mjs",
20
29
  "node": "./dist/lib/node-esm/index.mjs"
21
30
  },
31
+ "./translations": {
32
+ "source": "./src/translations.ts",
33
+ "types": "./dist/types/src/translations.d.ts",
34
+ "browser": "./dist/lib/browser/translations.mjs",
35
+ "node": "./dist/lib/node-esm/translations.mjs"
36
+ },
22
37
  "./types": {
23
38
  "source": "./src/types/index.ts",
24
39
  "types": "./dist/types/src/types/index.d.ts",
@@ -27,55 +42,52 @@
27
42
  }
28
43
  },
29
44
  "types": "dist/types/src/index.d.ts",
30
- "typesVersions": {
31
- "*": {
32
- "types": [
33
- "dist/types/src/types/index.d.ts"
34
- ]
35
- }
36
- },
37
45
  "files": [
38
46
  "dist",
39
47
  "src"
40
48
  ],
41
49
  "dependencies": {
42
- "@dxos/app-framework": "0.8.4-main.9735255",
43
- "@dxos/effect": "0.8.4-main.9735255",
44
- "@dxos/echo": "0.8.4-main.9735255",
45
- "@dxos/operation": "0.8.4-main.9735255",
46
- "@dxos/plugin-client": "0.8.4-main.9735255",
47
- "@dxos/plugin-search": "0.8.4-main.9735255",
48
- "@dxos/plugin-space": "0.8.4-main.9735255",
49
- "@dxos/react-client": "0.8.4-main.9735255",
50
- "@dxos/react-ui": "0.8.4-main.9735255",
51
- "@dxos/react-ui-masonry": "0.8.4-main.9735255",
52
- "@dxos/react-ui-form": "0.8.4-main.9735255",
53
- "@dxos/react-ui-mosaic": "0.8.4-main.9735255",
54
- "@dxos/react-ui-stack": "0.8.4-main.9735255",
55
- "@dxos/types": "0.8.4-main.9735255",
56
- "@dxos/util": "0.8.4-main.9735255",
57
- "@dxos/schema": "0.8.4-main.9735255"
50
+ "@dxos/app-framework": "0.8.4-main.abd8ff62ef",
51
+ "@dxos/app-toolkit": "0.8.4-main.abd8ff62ef",
52
+ "@dxos/echo": "0.8.4-main.abd8ff62ef",
53
+ "@dxos/compute": "0.8.4-main.abd8ff62ef",
54
+ "@dxos/plugin-client": "0.8.4-main.abd8ff62ef",
55
+ "@dxos/plugin-space": "0.8.4-main.abd8ff62ef",
56
+ "@dxos/plugin-search": "0.8.4-main.abd8ff62ef",
57
+ "@dxos/react-client": "0.8.4-main.abd8ff62ef",
58
+ "@dxos/effect": "0.8.4-main.abd8ff62ef",
59
+ "@dxos/react-ui": "0.8.4-main.abd8ff62ef",
60
+ "@dxos/react-ui-form": "0.8.4-main.abd8ff62ef",
61
+ "@dxos/react-ui-list": "0.8.4-main.abd8ff62ef",
62
+ "@dxos/react-ui-menu": "0.8.4-main.abd8ff62ef",
63
+ "@dxos/react-ui-masonry": "0.8.4-main.abd8ff62ef",
64
+ "@dxos/react-ui-mosaic": "0.8.4-main.abd8ff62ef",
65
+ "@dxos/react-ui-stack": "0.8.4-main.abd8ff62ef",
66
+ "@dxos/schema": "0.8.4-main.abd8ff62ef",
67
+ "@dxos/react-ui-search": "0.8.4-main.abd8ff62ef",
68
+ "@dxos/util": "0.8.4-main.abd8ff62ef",
69
+ "@dxos/types": "0.8.4-main.abd8ff62ef"
58
70
  },
59
71
  "devDependencies": {
60
72
  "@types/react": "~19.2.7",
61
73
  "@types/react-dom": "~19.2.3",
62
- "effect": "3.19.11",
74
+ "effect": "3.20.0",
63
75
  "react": "~19.2.3",
64
76
  "react-dom": "~19.2.3",
65
- "vite": "7.1.9",
66
- "@dxos/plugin-preview": "0.8.4-main.9735255",
67
- "@dxos/random": "0.8.4-main.9735255",
68
- "@dxos/plugin-testing": "0.8.4-main.9735255",
69
- "@dxos/storybook-utils": "0.8.4-main.9735255",
70
- "@dxos/plugin-theme": "0.8.4-main.9735255",
71
- "@dxos/ui-theme": "0.8.4-main.9735255"
77
+ "vite": "^8.0.10",
78
+ "@dxos/plugin-testing": "0.8.4-main.abd8ff62ef",
79
+ "@dxos/plugin-preview": "0.8.4-main.abd8ff62ef",
80
+ "@dxos/plugin-theme": "0.8.4-main.abd8ff62ef",
81
+ "@dxos/random": "0.8.4-main.abd8ff62ef",
82
+ "@dxos/ui-theme": "0.8.4-main.abd8ff62ef",
83
+ "@dxos/storybook-utils": "0.8.4-main.abd8ff62ef"
72
84
  },
73
85
  "peerDependencies": {
74
- "effect": "3.19.11",
86
+ "effect": "3.20.0",
75
87
  "react": "~19.2.3",
76
88
  "react-dom": "~19.2.3",
77
- "@dxos/react-ui": "0.8.4-main.9735255",
78
- "@dxos/ui-theme": "0.8.4-main.9735255"
89
+ "@dxos/react-ui": "0.8.4-main.abd8ff62ef",
90
+ "@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
79
91
  },
80
92
  "publishConfig": {
81
93
  "access": "public"
@@ -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';
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('metadata'), moduleId('schema'), moduleId('ReactSurface')]),
24
+ );
25
+ });
26
+ });
@@ -3,35 +3,49 @@
3
3
  //
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
+ import * as Option from 'effect/Option';
6
7
 
7
- import { Common, Plugin } from '@dxos/app-framework';
8
- import { Type } from '@dxos/echo';
8
+ import { Plugin } from '@dxos/app-framework';
9
+ import { AppPlugin } from '@dxos/app-toolkit';
10
+ import { Operation } from '@dxos/compute';
11
+ import { Annotation, Type } from '@dxos/echo';
12
+ import { SpaceOperation } from '@dxos/plugin-space/operations';
9
13
  import { type CreateObject } from '@dxos/plugin-space/types';
10
- import { View } from '@dxos/schema';
14
+ import { ViewModel } from '@dxos/schema';
11
15
 
12
- import { ReactSurface } from './capabilities';
13
- import { meta } from './meta';
14
- import { translations } from './translations';
15
- import { Masonry, MasonryAction } from './types';
16
+ import { ReactSurface } from '#capabilities';
17
+ import { meta } from '#meta';
18
+ import { translations } from '#translations';
19
+ import { Masonry, MasonryAction } from '#types';
16
20
 
17
21
  export const MasonryPlugin = Plugin.define(meta).pipe(
18
- Common.Plugin.addTranslationsModule({ translations }),
19
- Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
20
- Common.Plugin.addMetadataModule({
22
+ AppPlugin.addMetadataModule({
21
23
  metadata: {
22
24
  id: Type.getTypename(Masonry.Masonry),
23
25
  metadata: {
24
- icon: 'ph--wall--regular',
25
- iconHue: 'green',
26
+ icon: Annotation.IconAnnotation.get(Masonry.Masonry).pipe(Option.getOrThrow).icon,
27
+ iconHue: Annotation.IconAnnotation.get(Masonry.Masonry).pipe(Option.getOrThrow).hue ?? 'white',
26
28
  inputSchema: MasonryAction.MasonryProps,
27
- createObject: ((props, { db }) =>
28
- Effect.promise(async () => {
29
- const { view } = await View.makeFromDatabase({ db, typename: props.typename });
30
- return Masonry.make({ name: props.name, view });
29
+ createObject: ((props, options) =>
30
+ Effect.gen(function* () {
31
+ const object = yield* Effect.promise(async () => {
32
+ const { view } = await ViewModel.makeFromDatabase({ db: options.db, typename: props.typename });
33
+ return Masonry.make({ name: props.name, view });
34
+ });
35
+ return yield* Operation.invoke(SpaceOperation.AddObject, {
36
+ object,
37
+ target: options.target,
38
+ hidden: true,
39
+ targetNodeId: options.targetNodeId,
40
+ });
31
41
  })) satisfies CreateObject,
32
42
  },
33
43
  },
34
44
  }),
35
- Common.Plugin.addSchemaModule({ schema: [Masonry.Masonry] }),
45
+ AppPlugin.addSchemaModule({ schema: [Masonry.Masonry] }),
46
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
47
+ AppPlugin.addTranslationsModule({ translations }),
36
48
  Plugin.make,
37
49
  );
50
+
51
+ export default MasonryPlugin;
@@ -2,4 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './react-surface';
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ 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
+ //
@@ -7,21 +7,22 @@ import * as Effect from 'effect/Effect';
7
7
  import React from 'react';
8
8
 
9
9
  import { withPluginManager } from '@dxos/app-framework/testing';
10
+ import { View } from '@dxos/echo';
10
11
  import { ClientPlugin } from '@dxos/plugin-client';
12
+ import { initializeIdentity } from '@dxos/plugin-client/testing';
11
13
  import { PreviewPlugin } from '@dxos/plugin-preview';
12
14
  import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
13
- import { faker } from '@dxos/random';
15
+ import { random } from '@dxos/random';
14
16
  import { Filter, useObject, useQuery, useSpaces } from '@dxos/react-client/echo';
15
- import { withTheme } from '@dxos/react-ui/testing';
16
- import { View } from '@dxos/schema';
17
+ import { ViewModel } from '@dxos/schema';
17
18
  import { createObjectFactory } from '@dxos/schema/testing';
18
19
  import { Organization } from '@dxos/types';
19
20
 
20
- import { Masonry } from '../types';
21
+ import { Masonry } from '#types';
21
22
 
22
23
  import { MasonryContainer } from './MasonryContainer';
23
24
 
24
- faker.seed(0);
25
+ random.seed(0);
25
26
 
26
27
  const StorybookMasonry = () => {
27
28
  const spaces = useSpaces();
@@ -33,11 +34,10 @@ const StorybookMasonry = () => {
33
34
  };
34
35
 
35
36
  const meta = {
36
- title: 'plugins/plugin-masonry/Masonry',
37
+ title: 'plugins/plugin-masonry/containers/Masonry',
37
38
  component: StorybookMasonry,
38
39
  render: () => <StorybookMasonry />,
39
40
  decorators: [
40
- withTheme,
41
41
  withPluginManager({
42
42
  plugins: [
43
43
  ...corePlugins(),
@@ -46,18 +46,18 @@ const meta = {
46
46
  types: [Organization.Organization, View.View, Masonry.Masonry],
47
47
  onClientInitialized: ({ client }) =>
48
48
  Effect.gen(function* () {
49
- yield* Effect.promise(() => client.halo.createIdentity());
49
+ yield* initializeIdentity(client);
50
50
  const space = yield* Effect.promise(() => client.spaces.create());
51
51
  yield* Effect.promise(() => space.waitUntilReady());
52
52
  const { view } = yield* Effect.promise(() =>
53
- View.makeFromDatabase({
53
+ ViewModel.makeFromDatabase({
54
54
  db: space.db,
55
55
  typename: Organization.Organization.typename,
56
56
  }),
57
57
  );
58
58
  const masonry = Masonry.make({ view });
59
59
  space.db.add(masonry);
60
- const factory = createObjectFactory(space.db, faker as any);
60
+ const factory = createObjectFactory(space.db, random as any);
61
61
  yield* Effect.promise(() => factory([{ type: Organization.Organization, count: 64 }]));
62
62
  }),
63
63
  }),
@@ -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 CHANGED
@@ -2,6 +2,10 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './meta';
5
+ import { Plugin } from '@dxos/app-framework';
6
+
7
+ import { meta } from './meta';
6
8
 
7
- export * from './MasonryPlugin';
9
+ export const MasonryPlugin = Plugin.lazy(meta, () => import('./MasonryPlugin'));
10
+
11
+ export * from './meta';
package/src/meta.ts CHANGED
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
6
6
  import { trim } from '@dxos/util';
7
7
 
8
8
  export const meta: Plugin.Meta = {
9
- id: 'dxos.org/plugin/masonry',
9
+ id: 'org.dxos.plugin.masonry',
10
10
  name: 'Masonry',
11
11
  description: trim`
12
12
  Responsive grid layout that displays query results in an adaptive masonry pattern.
@@ -5,24 +5,25 @@
5
5
  import { Type } from '@dxos/echo';
6
6
  import { type Resource } from '@dxos/react-ui';
7
7
 
8
- import { meta } from './meta';
9
- import { Masonry } from './types';
8
+ import { meta } from '#meta';
9
+ import { Masonry } from '#types';
10
10
 
11
11
  export const translations = [
12
12
  {
13
13
  'en-US': {
14
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
- 'rename object label': 'Rename masonry',
21
- 'delete object label': 'Delete masonry',
22
- 'object deleted label': 'Masonry deleted',
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',
23
24
  },
24
25
  [meta.id]: {
25
- 'plugin name': 'Masonry',
26
+ 'plugin.name': 'Masonry',
26
27
  },
27
28
  },
28
29
  },
@@ -4,14 +4,15 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { Obj, Ref, Type } from '@dxos/echo';
7
+ import { Annotation, Obj, Ref, Type } from '@dxos/echo';
8
+ import { View } from '@dxos/echo';
8
9
  import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
9
- import { View, ViewAnnotation } from '@dxos/schema';
10
+ import { ViewAnnotation } from '@dxos/schema';
10
11
 
11
12
  export const Masonry = Schema.Struct({
12
13
  name: Schema.String.pipe(Schema.optional),
13
14
 
14
- view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),
15
+ view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),
15
16
 
16
17
  arrangement: Schema.Array(
17
18
  Schema.Struct({
@@ -22,11 +23,15 @@ export const Masonry = Schema.Struct({
22
23
  // TODO(wittjosiah): Consider Masonry supporting not being just a view but referencing arbitrary data directly.
23
24
  }).pipe(
24
25
  Type.object({
25
- typename: 'dxos.org/type/Masonry',
26
- version: '0.2.0',
26
+ typename: 'org.dxos.type.masonry',
27
+ version: '0.1.0',
27
28
  }),
28
29
  LabelAnnotation.set(['name']),
29
- ViewAnnotation.set(true),
30
+ ViewAnnotation.set(['view']),
31
+ Annotation.IconAnnotation.set({
32
+ icon: 'ph--wall--regular',
33
+ hue: 'green',
34
+ }),
30
35
  );
31
36
 
32
37
  export interface Masonry extends Schema.Schema.Type<typeof Masonry> {}
@@ -41,21 +46,3 @@ type MakeProps = Omit<Partial<Obj.MakeProps<typeof Masonry>>, 'view'> & {
41
46
  export const make = ({ name, arrangement = [], view }: MakeProps): Masonry => {
42
47
  return Obj.make(Masonry, { name, view: Ref.make(view), arrangement });
43
48
  };
44
-
45
- //
46
- // V1
47
- //
48
-
49
- export const MasonryV1 = Schema.Struct({
50
- arrangement: Schema.Array(
51
- Schema.Struct({
52
- ids: Schema.Array(Obj.ID),
53
- hidden: Schema.optional(Schema.Boolean),
54
- }),
55
- ).pipe(Schema.optional),
56
- }).pipe(
57
- Type.object({
58
- typename: 'dxos.org/type/Masonry',
59
- version: '0.1.0',
60
- }),
61
- );
@@ -14,7 +14,6 @@ export const MasonryProps = Schema.Struct({
14
14
  TypeInputOptionsAnnotation.set({
15
15
  location: ['database', 'runtime'],
16
16
  kind: ['user'],
17
- registered: ['registered'],
18
17
  }),
19
18
  Schema.optional,
20
19
  ),