@dxos/plugin-masonry 0.8.4-main.c85a9c8dae → 0.8.4-main.d9fc60f731
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/LICENSE +102 -5
- package/PLUGIN.mdl +328 -0
- package/README.md +1 -1
- package/dist/lib/neutral/MasonryContainer-XXJXCOOA.mjs +96 -0
- package/dist/lib/neutral/MasonryContainer-XXJXCOOA.mjs.map +7 -0
- package/dist/lib/neutral/MasonryPlugin.mjs +38 -0
- package/dist/lib/neutral/MasonryPlugin.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +11 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IJ2FIXSI.mjs +32 -0
- package/dist/lib/neutral/chunk-IJ2FIXSI.mjs.map +7 -0
- package/dist/lib/{browser/chunk-JYUFXVAU.mjs → neutral/chunk-SS54S63V.mjs} +12 -23
- package/dist/lib/neutral/chunk-SS54S63V.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +1 -0
- package/dist/lib/neutral/containers/index.mjs +9 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-WRCYV4HT.mjs +39 -0
- package/dist/lib/neutral/create-object-WRCYV4HT.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +14 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +12 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/react-surface-TJ6V3IKD.mjs → neutral/react-surface-7CZHE3XA.mjs} +15 -22
- package/dist/lib/neutral/react-surface-7CZHE3XA.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +30 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/types/index.mjs +1 -1
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/MasonryPlugin.d.ts +1 -0
- package/dist/types/src/MasonryPlugin.d.ts.map +1 -1
- package/dist/types/src/MasonryPlugin.test.d.ts +2 -0
- package/dist/types/src/MasonryPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +8 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/containers/MasonryContainer/MasonryContainer.d.ts +1 -2
- package/dist/types/src/containers/MasonryContainer/MasonryContainer.d.ts.map +1 -1
- package/dist/types/src/containers/MasonryContainer/MasonryContainer.stories.d.ts.map +1 -1
- package/dist/types/src/containers/MasonryContainer/index.d.ts +1 -2
- package/dist/types/src/containers/MasonryContainer/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +20 -18
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Masonry.d.ts +6 -12
- package/dist/types/src/types/Masonry.d.ts.map +1 -1
- package/dist/types/src/types/MasonryAction.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +79 -46
- package/src/MasonryPlugin.test.ts +26 -0
- package/src/MasonryPlugin.tsx +13 -24
- package/src/capabilities/create-object.ts +36 -0
- package/src/capabilities/index.ts +4 -1
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +10 -9
- package/src/containers/MasonryContainer/MasonryContainer.stories.tsx +11 -13
- package/src/containers/MasonryContainer/MasonryContainer.tsx +64 -34
- package/src/containers/MasonryContainer/index.ts +1 -3
- package/src/index.ts +1 -2
- package/src/meta.ts +19 -7
- package/src/plugin.ts +9 -0
- package/src/translations.ts +12 -11
- package/src/types/Masonry.ts +12 -27
- package/src/types/MasonryAction.ts +1 -2
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/MasonryContainer-G5D7SXNF.mjs +0 -82
- package/dist/lib/browser/MasonryContainer-G5D7SXNF.mjs.map +0 -7
- package/dist/lib/browser/chunk-JYUFXVAU.mjs.map +0 -7
- package/dist/lib/browser/chunk-U46AGJ2D.mjs +0 -19
- package/dist/lib/browser/chunk-U46AGJ2D.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -76
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-TJ6V3IKD.mjs.map +0 -7
- package/dist/lib/node-esm/MasonryContainer-HB775HET.mjs +0 -83
- package/dist/lib/node-esm/MasonryContainer-HB775HET.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4PU4KL3A.mjs +0 -78
- package/dist/lib/node-esm/chunk-4PU4KL3A.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-P6EZJITS.mjs +0 -21
- package/dist/lib/node-esm/chunk-P6EZJITS.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -77
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-A7GOFCCK.mjs +0 -43
- package/dist/lib/node-esm/react-surface-A7GOFCCK.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/src/capabilities/react-surface/index.ts +0 -7
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser/types → neutral/components}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.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.
|
|
3
|
+
"version": "0.8.4-main.d9fc60f731",
|
|
4
4
|
"description": "Masonry DXOS Surface plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -8,76 +8,109 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"sideEffects": true,
|
|
14
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
|
+
},
|
|
15
52
|
"exports": {
|
|
16
53
|
".": {
|
|
17
54
|
"source": "./src/index.ts",
|
|
18
55
|
"types": "./dist/types/src/index.d.ts",
|
|
19
|
-
"
|
|
20
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
56
|
+
"default": "./dist/lib/neutral/index.mjs"
|
|
21
57
|
},
|
|
22
|
-
"./
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
58
|
+
"./assets/PLUGIN.mdl": "./PLUGIN.mdl",
|
|
59
|
+
"./plugin": {
|
|
60
|
+
"source": "./src/plugin.ts",
|
|
61
|
+
"types": "./dist/types/src/plugin.d.ts",
|
|
62
|
+
"default": "./dist/lib/neutral/plugin.mjs"
|
|
63
|
+
},
|
|
64
|
+
"./translations": {
|
|
65
|
+
"source": "./src/translations.ts",
|
|
66
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
67
|
+
"default": "./dist/lib/neutral/translations.mjs"
|
|
27
68
|
}
|
|
28
69
|
},
|
|
29
70
|
"types": "dist/types/src/index.d.ts",
|
|
30
|
-
"typesVersions": {
|
|
31
|
-
"*": {
|
|
32
|
-
"types": [
|
|
33
|
-
"dist/types/src/types/index.d.ts"
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
71
|
"files": [
|
|
38
72
|
"dist",
|
|
39
|
-
"src"
|
|
73
|
+
"src",
|
|
74
|
+
"PLUGIN.mdl"
|
|
40
75
|
],
|
|
41
76
|
"dependencies": {
|
|
42
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/effect": "0.8.4-main.
|
|
47
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/react-ui
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/react-ui-
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/react-ui-masonry": "0.8.4-main.c85a9c8dae",
|
|
59
|
-
"@dxos/react-ui-menu": "0.8.4-main.c85a9c8dae"
|
|
77
|
+
"@dxos/app-framework": "0.8.4-main.d9fc60f731",
|
|
78
|
+
"@dxos/compute": "0.8.4-main.d9fc60f731",
|
|
79
|
+
"@dxos/app-toolkit": "0.8.4-main.d9fc60f731",
|
|
80
|
+
"@dxos/echo": "0.8.4-main.d9fc60f731",
|
|
81
|
+
"@dxos/effect": "0.8.4-main.d9fc60f731",
|
|
82
|
+
"@dxos/plugin-client": "0.8.4-main.d9fc60f731",
|
|
83
|
+
"@dxos/keys": "0.8.4-main.d9fc60f731",
|
|
84
|
+
"@dxos/react-client": "0.8.4-main.d9fc60f731",
|
|
85
|
+
"@dxos/plugin-space": "0.8.4-main.d9fc60f731",
|
|
86
|
+
"@dxos/react-ui": "0.8.4-main.d9fc60f731",
|
|
87
|
+
"@dxos/react-ui-masonry": "0.8.4-main.d9fc60f731",
|
|
88
|
+
"@dxos/react-ui-menu": "0.8.4-main.d9fc60f731",
|
|
89
|
+
"@dxos/react-ui-search": "0.8.4-main.d9fc60f731",
|
|
90
|
+
"@dxos/schema": "0.8.4-main.d9fc60f731",
|
|
91
|
+
"@dxos/types": "0.8.4-main.d9fc60f731",
|
|
92
|
+
"@dxos/util": "0.8.4-main.d9fc60f731"
|
|
60
93
|
},
|
|
61
94
|
"devDependencies": {
|
|
62
95
|
"@types/react": "~19.2.7",
|
|
63
96
|
"@types/react-dom": "~19.2.3",
|
|
64
|
-
"effect": "3.
|
|
97
|
+
"effect": "3.21.2",
|
|
65
98
|
"react": "~19.2.3",
|
|
66
99
|
"react-dom": "~19.2.3",
|
|
67
|
-
"vite": "^
|
|
68
|
-
"@dxos/plugin-
|
|
69
|
-
"@dxos/plugin-
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
100
|
+
"vite": "^8.0.14",
|
|
101
|
+
"@dxos/plugin-testing": "0.8.4-main.d9fc60f731",
|
|
102
|
+
"@dxos/plugin-preview": "0.8.4-main.d9fc60f731",
|
|
103
|
+
"@dxos/random": "0.8.4-main.d9fc60f731",
|
|
104
|
+
"@dxos/storybook-utils": "0.8.4-main.d9fc60f731",
|
|
105
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731",
|
|
106
|
+
"@dxos/plugin-theme": "0.8.4-main.d9fc60f731"
|
|
74
107
|
},
|
|
75
108
|
"peerDependencies": {
|
|
76
|
-
"effect": "3.
|
|
109
|
+
"effect": "3.21.2",
|
|
77
110
|
"react": "~19.2.3",
|
|
78
111
|
"react-dom": "~19.2.3",
|
|
79
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
80
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
112
|
+
"@dxos/react-ui": "0.8.4-main.d9fc60f731",
|
|
113
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731"
|
|
81
114
|
},
|
|
82
115
|
"publishConfig": {
|
|
83
116
|
"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/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
|
+
});
|
package/src/MasonryPlugin.tsx
CHANGED
|
@@ -2,37 +2,26 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
|
|
7
5
|
import { Plugin } from '@dxos/app-framework';
|
|
8
6
|
import { AppPlugin } from '@dxos/app-toolkit';
|
|
9
|
-
import { Type } from '@dxos/echo';
|
|
10
|
-
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
11
|
-
import { ViewModel } from '@dxos/schema';
|
|
12
7
|
|
|
13
|
-
import { ReactSurface } from '
|
|
14
|
-
import { meta } from '
|
|
15
|
-
import { translations } from '
|
|
16
|
-
import { Masonry
|
|
8
|
+
import { CreateObject, ReactSurface } from '#capabilities';
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
import { translations } from '#translations';
|
|
11
|
+
import { Masonry } from '#types';
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line import/no-relative-packages
|
|
14
|
+
import pluginSpec from '../PLUGIN.mdl?raw';
|
|
17
15
|
|
|
18
16
|
export const MasonryPlugin = Plugin.define(meta).pipe(
|
|
19
|
-
AppPlugin.
|
|
20
|
-
metadata: {
|
|
21
|
-
id: Type.getTypename(Masonry.Masonry),
|
|
22
|
-
metadata: {
|
|
23
|
-
icon: 'ph--wall--regular',
|
|
24
|
-
iconHue: 'green',
|
|
25
|
-
inputSchema: MasonryAction.MasonryProps,
|
|
26
|
-
createObject: ((props, { db }) =>
|
|
27
|
-
Effect.promise(async () => {
|
|
28
|
-
const { view } = await ViewModel.makeFromDatabase({ db, typename: props.typename });
|
|
29
|
-
return Masonry.make({ name: props.name, view });
|
|
30
|
-
})) satisfies CreateObject,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
17
|
+
AppPlugin.addCreateObjectModule({ activate: CreateObject }),
|
|
34
18
|
AppPlugin.addSchemaModule({ schema: [Masonry.Masonry] }),
|
|
35
19
|
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
36
20
|
AppPlugin.addTranslationsModule({ translations }),
|
|
21
|
+
AppPlugin.addPluginAssetModule({
|
|
22
|
+
asset: { pluginId: meta.id, path: 'PLUGIN.mdl', content: pluginSpec, mimeType: 'application/x-mdl' },
|
|
23
|
+
}),
|
|
37
24
|
Plugin.make,
|
|
38
25
|
);
|
|
26
|
+
|
|
27
|
+
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
|
+
);
|
|
@@ -2,4 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
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'));
|
|
@@ -7,21 +7,22 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
9
|
import { Surface } from '@dxos/app-framework/ui';
|
|
10
|
-
import {
|
|
11
|
-
import { View } from '@dxos/echo';
|
|
10
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { Obj, View } from '@dxos/echo';
|
|
12
12
|
|
|
13
|
-
import { MasonryContainer } from '
|
|
14
|
-
import {
|
|
15
|
-
import { Masonry } from '../../types';
|
|
13
|
+
import { MasonryContainer } from '#containers';
|
|
14
|
+
import { Masonry } from '#types';
|
|
16
15
|
|
|
17
16
|
export default Capability.makeModule(() =>
|
|
18
17
|
Effect.succeed(
|
|
19
18
|
Capability.contributes(Capabilities.ReactSurface, [
|
|
20
19
|
Surface.create({
|
|
21
|
-
id:
|
|
22
|
-
|
|
23
|
-
filter: (
|
|
24
|
-
|
|
20
|
+
id: 'root',
|
|
21
|
+
// TODO(wittjosiah): Split into multiple surfaces if this filter proves too strict for non-article roles.
|
|
22
|
+
filter: AppSurface.oneOf(
|
|
23
|
+
AppSurface.object(AppSurface.Article, [Masonry.Masonry, View.View]),
|
|
24
|
+
AppSurface.object(AppSurface.Section, [Masonry.Masonry, View.View]),
|
|
25
|
+
),
|
|
25
26
|
component: ({ data, role }) => {
|
|
26
27
|
const view = Obj.instanceOf(View.View, data.subject) ? data.subject : data.subject.view;
|
|
27
28
|
return <MasonryContainer view={view} role={role} />;
|
|
@@ -7,22 +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';
|
|
11
|
-
import { ClientPlugin } from '@dxos/plugin-client';
|
|
12
|
-
import {
|
|
10
|
+
import { Filter, Type, View } from '@dxos/echo';
|
|
11
|
+
import { ClientPlugin } from '@dxos/plugin-client/testing';
|
|
12
|
+
import { initializeIdentity } from '@dxos/plugin-client/testing';
|
|
13
|
+
import { PreviewPlugin } from '@dxos/plugin-preview/testing';
|
|
13
14
|
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
15
|
+
import { random } from '@dxos/random';
|
|
16
|
+
import { useObject, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
17
17
|
import { ViewModel } from '@dxos/schema';
|
|
18
18
|
import { createObjectFactory } from '@dxos/schema/testing';
|
|
19
19
|
import { Organization } from '@dxos/types';
|
|
20
20
|
|
|
21
|
-
import { Masonry } from '
|
|
21
|
+
import { Masonry } from '#types';
|
|
22
22
|
|
|
23
23
|
import { MasonryContainer } from './MasonryContainer';
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
random.seed(0);
|
|
26
26
|
|
|
27
27
|
const StorybookMasonry = () => {
|
|
28
28
|
const spaces = useSpaces();
|
|
@@ -38,8 +38,6 @@ const meta = {
|
|
|
38
38
|
component: StorybookMasonry,
|
|
39
39
|
render: () => <StorybookMasonry />,
|
|
40
40
|
decorators: [
|
|
41
|
-
withTheme(),
|
|
42
|
-
withLayout({ layout: 'fullscreen' }),
|
|
43
41
|
withPluginManager({
|
|
44
42
|
plugins: [
|
|
45
43
|
...corePlugins(),
|
|
@@ -48,18 +46,18 @@ const meta = {
|
|
|
48
46
|
types: [Organization.Organization, View.View, Masonry.Masonry],
|
|
49
47
|
onClientInitialized: ({ client }) =>
|
|
50
48
|
Effect.gen(function* () {
|
|
51
|
-
yield*
|
|
49
|
+
yield* initializeIdentity(client);
|
|
52
50
|
const space = yield* Effect.promise(() => client.spaces.create());
|
|
53
51
|
yield* Effect.promise(() => space.waitUntilReady());
|
|
54
52
|
const { view } = yield* Effect.promise(() =>
|
|
55
53
|
ViewModel.makeFromDatabase({
|
|
56
54
|
db: space.db,
|
|
57
|
-
typename: Organization.Organization
|
|
55
|
+
typename: Type.getTypename(Organization.Organization),
|
|
58
56
|
}),
|
|
59
57
|
);
|
|
60
58
|
const masonry = Masonry.make({ view });
|
|
61
59
|
space.db.add(masonry);
|
|
62
|
-
const factory = createObjectFactory(space.db,
|
|
60
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
63
61
|
yield* Effect.promise(() => factory([{ type: Organization.Organization, count: 64 }]));
|
|
64
62
|
}),
|
|
65
63
|
}),
|
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
7
6
|
|
|
8
7
|
import { Surface, useCapabilities } from '@dxos/app-framework/ui';
|
|
9
8
|
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
10
|
-
import { useObjectMenuItems,
|
|
11
|
-
import { Filter, Obj, type Ref, Type } from '@dxos/echo';
|
|
12
|
-
import { type View } from '@dxos/echo';
|
|
13
|
-
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
9
|
+
import { AppSurface, useObjectMenuItems, useSchemaFilter } from '@dxos/app-toolkit/ui';
|
|
10
|
+
import { Filter, Obj, Query, type Ref, Type, type View } from '@dxos/echo';
|
|
14
11
|
import { useObject, useQuery } from '@dxos/react-client/echo';
|
|
15
|
-
import { Card, Toolbar } from '@dxos/react-ui';
|
|
12
|
+
import { Card, Panel, Toolbar } from '@dxos/react-ui';
|
|
16
13
|
import { Masonry as MasonryComponent } from '@dxos/react-ui-masonry';
|
|
17
14
|
import { Menu } from '@dxos/react-ui-menu';
|
|
18
|
-
import {
|
|
15
|
+
import { SearchList, useSearchListResults } from '@dxos/react-ui-search';
|
|
16
|
+
import { getTagFromQuery, getTypenameFromQuery } from '@dxos/schema';
|
|
17
|
+
import { isNonNullable } from '@dxos/util';
|
|
19
18
|
|
|
20
19
|
export type MasonryContainerProps = {
|
|
21
20
|
view: View.View;
|
|
@@ -33,58 +32,89 @@ export const MasonryContainer = ({
|
|
|
33
32
|
const schemas = useCapabilities(AppCapabilities.Schema);
|
|
34
33
|
const db = view && Obj.getDatabase(view);
|
|
35
34
|
const typename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
|
|
35
|
+
const tag = view?.query ? getTagFromQuery(view.query.ast) : undefined;
|
|
36
36
|
|
|
37
|
-
const [cardSchema, setCardSchema] = useState<
|
|
37
|
+
const [cardSchema, setCardSchema] = useState<Type.AnyEntity>();
|
|
38
38
|
|
|
39
39
|
useEffect(() => {
|
|
40
40
|
const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
|
|
41
41
|
if (staticSchema) {
|
|
42
42
|
setCardSchema(() => staticSchema);
|
|
43
|
+
return;
|
|
43
44
|
}
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
55
|
-
return unsubscribe;
|
|
45
|
+
if (typename && db) {
|
|
46
|
+
const findInRegistry = () =>
|
|
47
|
+
db.graph.registry
|
|
48
|
+
.list()
|
|
49
|
+
.filter(Type.isType)
|
|
50
|
+
.find((t) => Type.getTypename(t) === typename);
|
|
51
|
+
setCardSchema(() => findInRegistry());
|
|
52
|
+
return db.graph.registry.changed.on(() => {
|
|
53
|
+
setCardSchema(() => findInRegistry());
|
|
54
|
+
});
|
|
56
55
|
}
|
|
56
|
+
setCardSchema(undefined);
|
|
57
57
|
}, [schemas, typename, db]);
|
|
58
58
|
|
|
59
|
-
const
|
|
60
|
-
const
|
|
59
|
+
const baseFilter = useSchemaFilter(cardSchema);
|
|
60
|
+
const query = useMemo(
|
|
61
|
+
() => (tag ? Query.select(baseFilter).select(Filter.tag(tag)) : Query.select(baseFilter)),
|
|
62
|
+
[baseFilter, tag],
|
|
63
|
+
);
|
|
64
|
+
const objects = useQuery(db, query);
|
|
65
|
+
|
|
66
|
+
const sortedObjects = useMemo(
|
|
67
|
+
() =>
|
|
68
|
+
objects.filter(isNonNullable).toSorted((a, b) => (Obj.getLabel(a) ?? '').localeCompare(Obj.getLabel(b) ?? '')),
|
|
69
|
+
[objects],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const { results, handleSearch } = useSearchListResults({
|
|
73
|
+
items: sortedObjects,
|
|
74
|
+
extract: (obj) => Obj.getLabel(obj) ?? '',
|
|
75
|
+
});
|
|
61
76
|
|
|
62
77
|
return (
|
|
63
|
-
<MasonryComponent.Root
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
<MasonryComponent.Root Tile={Item}>
|
|
79
|
+
<SearchList.Root onSearch={handleSearch}>
|
|
80
|
+
<Panel.Root>
|
|
81
|
+
<Panel.Toolbar asChild>
|
|
82
|
+
<Toolbar.Root>
|
|
83
|
+
<SearchList.Input placeholder='Search...' />
|
|
84
|
+
</Toolbar.Root>
|
|
85
|
+
</Panel.Toolbar>
|
|
86
|
+
<Panel.Content>
|
|
87
|
+
<MasonryComponent.Content>
|
|
88
|
+
<MasonryComponent.Viewport items={results} getId={(data: any) => data?.id} />
|
|
89
|
+
</MasonryComponent.Content>
|
|
90
|
+
</Panel.Content>
|
|
91
|
+
</Panel.Root>
|
|
92
|
+
</SearchList.Root>
|
|
93
|
+
</MasonryComponent.Root>
|
|
68
94
|
);
|
|
69
95
|
};
|
|
70
96
|
|
|
71
97
|
const Item = ({ data }: { data: any }) => {
|
|
72
98
|
const objectMenuItems = useObjectMenuItems(data);
|
|
73
|
-
const
|
|
99
|
+
const icon = Obj.getIcon(data)?.icon ?? 'ph--circle-dashed--regular';
|
|
74
100
|
|
|
75
101
|
return (
|
|
76
102
|
<Menu.Root>
|
|
77
103
|
<Card.Root>
|
|
78
|
-
<Card.
|
|
79
|
-
<
|
|
80
|
-
<Card.Title
|
|
104
|
+
<Card.Header>
|
|
105
|
+
<Card.Icon icon={icon} />
|
|
106
|
+
<Card.Title>{Obj.getLabel(data, { fallback: 'typename' })}</Card.Title>
|
|
81
107
|
{/* TODO(wittjosiah): Reconcile with Card.Menu. */}
|
|
82
108
|
<Menu.Trigger asChild disabled={!objectMenuItems?.length}>
|
|
83
109
|
<Toolbar.IconButton iconOnly variant='ghost' icon='ph--dots-three-vertical--regular' label='Actions' />
|
|
84
110
|
</Menu.Trigger>
|
|
85
111
|
<Menu.Content items={objectMenuItems} />
|
|
86
|
-
</Card.
|
|
87
|
-
<Surface.Surface
|
|
112
|
+
</Card.Header>
|
|
113
|
+
<Surface.Surface
|
|
114
|
+
type={AppSurface.Card}
|
|
115
|
+
limit={1}
|
|
116
|
+
data={{ subject: data } satisfies AppSurface.ObjectCardData}
|
|
117
|
+
/>
|
|
88
118
|
</Card.Root>
|
|
89
119
|
</Menu.Root>
|
|
90
120
|
);
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,18 +2,30 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { DXN } from '@dxos/keys';
|
|
6
7
|
import { trim } from '@dxos/util';
|
|
7
8
|
|
|
8
|
-
export const meta
|
|
9
|
-
|
|
9
|
+
export const meta = Plugin.makeMeta({
|
|
10
|
+
key: DXN.make('org.dxos.plugin.masonry'),
|
|
10
11
|
name: 'Masonry',
|
|
12
|
+
author: 'DXOS',
|
|
11
13
|
description: trim`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
Masonry renders a live, query-driven collection as a responsive column-balanced card grid.
|
|
15
|
+
|
|
16
|
+
A Masonry object wraps an ECHO View that defines which objects to show and in what order.
|
|
17
|
+
As objects are added or removed — by any peer — the grid reflows automatically, keeping cards
|
|
18
|
+
balanced across columns without manual arrangement.
|
|
19
|
+
|
|
20
|
+
Each card delegates its body to a Surface slot, so other plugins can supply rich, type-specific
|
|
21
|
+
content while Masonry handles layout, search, and context menus.
|
|
22
|
+
|
|
23
|
+
A built-in search bar filters cards client-side by label without modifying the underlying query,
|
|
24
|
+
making it easy to explore large collections without leaving the view.
|
|
14
25
|
`,
|
|
15
26
|
icon: 'ph--wall--regular',
|
|
16
|
-
iconHue: '
|
|
27
|
+
iconHue: 'teal',
|
|
17
28
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-masonry',
|
|
29
|
+
spec: 'PLUGIN.mdl',
|
|
18
30
|
screenshots: [],
|
|
19
|
-
};
|
|
31
|
+
});
|
package/src/plugin.ts
ADDED
package/src/translations.ts
CHANGED
|
@@ -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 '
|
|
9
|
-
import { Masonry } from '
|
|
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
|
|
16
|
-
'typename
|
|
17
|
-
'typename
|
|
18
|
-
'typename
|
|
19
|
-
'object
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'object
|
|
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
|
|
26
|
+
'plugin.name': 'Masonry',
|
|
26
27
|
},
|
|
27
28
|
},
|
|
28
29
|
},
|