@dxos/plugin-masonry 0.8.4-main.ae835ea → 0.8.4-main.c85a9c8dae
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/MasonryContainer-G5D7SXNF.mjs +82 -0
- package/dist/lib/browser/MasonryContainer-G5D7SXNF.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-JYUFXVAU.mjs +77 -0
- package/dist/lib/browser/chunk-JYUFXVAU.mjs.map +7 -0
- package/dist/lib/browser/chunk-U46AGJ2D.mjs +19 -0
- package/dist/lib/browser/chunk-U46AGJ2D.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +47 -58
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-TJ6V3IKD.mjs +42 -0
- package/dist/lib/browser/react-surface-TJ6V3IKD.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +10 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node-esm/MasonryContainer-HB775HET.mjs +83 -0
- package/dist/lib/node-esm/MasonryContainer-HB775HET.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4PU4KL3A.mjs +78 -0
- package/dist/lib/node-esm/chunk-4PU4KL3A.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-P6EZJITS.mjs +21 -0
- package/dist/lib/node-esm/chunk-P6EZJITS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +47 -58
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-A7GOFCCK.mjs +43 -0
- package/dist/lib/node-esm/react-surface-A7GOFCCK.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +11 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/MasonryPlugin.d.ts +2 -1
- package/dist/types/src/MasonryPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/containers/MasonryContainer/MasonryContainer.d.ts +12 -0
- package/dist/types/src/containers/MasonryContainer/MasonryContainer.d.ts.map +1 -0
- package/dist/types/src/containers/MasonryContainer/MasonryContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/MasonryContainer/index.d.ts +3 -0
- package/dist/types/src/containers/MasonryContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +14 -5
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Masonry.d.ts +22 -21
- package/dist/types/src/types/Masonry.d.ts.map +1 -1
- package/dist/types/src/types/MasonryAction.d.ts +0 -17
- package/dist/types/src/types/MasonryAction.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +53 -33
- package/src/MasonryPlugin.tsx +28 -52
- package/src/capabilities/index.ts +1 -4
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +32 -0
- package/src/components/index.ts +3 -0
- package/src/containers/MasonryContainer/MasonryContainer.stories.tsx +80 -0
- package/src/containers/MasonryContainer/MasonryContainer.tsx +91 -0
- package/src/containers/MasonryContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/meta.ts +2 -2
- package/src/translations.ts +5 -1
- package/src/types/Masonry.ts +39 -27
- package/src/types/MasonryAction.ts +9 -17
- package/dist/lib/browser/chunk-RVOTJON5.mjs +0 -92
- package/dist/lib/browser/chunk-RVOTJON5.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-WM3U563P.mjs +0 -31
- package/dist/lib/browser/intent-resolver-WM3U563P.mjs.map +0 -7
- package/dist/lib/browser/react-surface-Z7W24EZP.mjs +0 -112
- package/dist/lib/browser/react-surface-Z7W24EZP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KTVJZX5B.mjs +0 -93
- package/dist/lib/node-esm/chunk-KTVJZX5B.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YKIFA4JI.mjs +0 -32
- package/dist/lib/node-esm/intent-resolver-YKIFA4JI.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-BSDKYPZH.mjs +0 -113
- package/dist/lib/node-esm/react-surface-BSDKYPZH.mjs.map +0 -7
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/MasonryContainer.d.ts +0 -7
- package/dist/types/src/components/MasonryContainer.d.ts.map +0 -1
- package/dist/types/src/components/MasonryContainer.stories.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -25
- package/src/capabilities/react-surface.tsx +0 -25
- package/src/components/MasonryContainer.stories.tsx +0 -83
- package/src/components/MasonryContainer.tsx +0 -69
- /package/dist/types/src/{components → containers/MasonryContainer}/MasonryContainer.stories.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-masonry",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.c85a9c8dae",
|
|
4
4
|
"description": "Masonry DXOS Surface plugin",
|
|
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
13
|
"sideEffects": true,
|
|
@@ -14,50 +18,66 @@
|
|
|
14
18
|
"types": "./dist/types/src/index.d.ts",
|
|
15
19
|
"browser": "./dist/lib/browser/index.mjs",
|
|
16
20
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./types": {
|
|
23
|
+
"source": "./src/types/index.ts",
|
|
24
|
+
"types": "./dist/types/src/types/index.d.ts",
|
|
25
|
+
"browser": "./dist/lib/browser/types/index.mjs",
|
|
26
|
+
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
"types": "dist/types/src/index.d.ts",
|
|
30
|
+
"typesVersions": {
|
|
31
|
+
"*": {
|
|
32
|
+
"types": [
|
|
33
|
+
"dist/types/src/types/index.d.ts"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
20
37
|
"files": [
|
|
21
38
|
"dist",
|
|
22
39
|
"src"
|
|
23
40
|
],
|
|
24
41
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/plugin-search": "0.8.4-main.
|
|
33
|
-
"@dxos/react-
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/react-
|
|
42
|
+
"@dxos/app-framework": "0.8.4-main.c85a9c8dae",
|
|
43
|
+
"@dxos/app-toolkit": "0.8.4-main.c85a9c8dae",
|
|
44
|
+
"@dxos/echo": "0.8.4-main.c85a9c8dae",
|
|
45
|
+
"@dxos/operation": "0.8.4-main.c85a9c8dae",
|
|
46
|
+
"@dxos/effect": "0.8.4-main.c85a9c8dae",
|
|
47
|
+
"@dxos/plugin-client": "0.8.4-main.c85a9c8dae",
|
|
48
|
+
"@dxos/plugin-space": "0.8.4-main.c85a9c8dae",
|
|
49
|
+
"@dxos/plugin-search": "0.8.4-main.c85a9c8dae",
|
|
50
|
+
"@dxos/react-client": "0.8.4-main.c85a9c8dae",
|
|
51
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.c85a9c8dae",
|
|
52
|
+
"@dxos/schema": "0.8.4-main.c85a9c8dae",
|
|
53
|
+
"@dxos/types": "0.8.4-main.c85a9c8dae",
|
|
54
|
+
"@dxos/react-ui-stack": "0.8.4-main.c85a9c8dae",
|
|
55
|
+
"@dxos/util": "0.8.4-main.c85a9c8dae",
|
|
56
|
+
"@dxos/react-ui": "0.8.4-main.c85a9c8dae",
|
|
57
|
+
"@dxos/react-ui-form": "0.8.4-main.c85a9c8dae",
|
|
58
|
+
"@dxos/react-ui-masonry": "0.8.4-main.c85a9c8dae",
|
|
59
|
+
"@dxos/react-ui-menu": "0.8.4-main.c85a9c8dae"
|
|
41
60
|
},
|
|
42
61
|
"devDependencies": {
|
|
43
|
-
"@types/react": "~19.2.
|
|
44
|
-
"@types/react-dom": "~19.2.
|
|
45
|
-
"effect": "3.
|
|
46
|
-
"react": "~19.2.
|
|
47
|
-
"react-dom": "~19.2.
|
|
48
|
-
"vite": "7.1.
|
|
49
|
-
"@dxos/plugin-preview": "0.8.4-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/plugin-theme": "0.8.4-main.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
62
|
+
"@types/react": "~19.2.7",
|
|
63
|
+
"@types/react-dom": "~19.2.3",
|
|
64
|
+
"effect": "3.19.16",
|
|
65
|
+
"react": "~19.2.3",
|
|
66
|
+
"react-dom": "~19.2.3",
|
|
67
|
+
"vite": "^7.1.11",
|
|
68
|
+
"@dxos/plugin-preview": "0.8.4-main.c85a9c8dae",
|
|
69
|
+
"@dxos/plugin-testing": "0.8.4-main.c85a9c8dae",
|
|
70
|
+
"@dxos/plugin-theme": "0.8.4-main.c85a9c8dae",
|
|
71
|
+
"@dxos/random": "0.8.4-main.c85a9c8dae",
|
|
72
|
+
"@dxos/storybook-utils": "0.8.4-main.c85a9c8dae",
|
|
73
|
+
"@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
|
|
54
74
|
},
|
|
55
75
|
"peerDependencies": {
|
|
56
|
-
"effect": "
|
|
57
|
-
"react": "
|
|
58
|
-
"react-dom": "
|
|
59
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
60
|
-
"@dxos/
|
|
76
|
+
"effect": "3.19.16",
|
|
77
|
+
"react": "~19.2.3",
|
|
78
|
+
"react-dom": "~19.2.3",
|
|
79
|
+
"@dxos/react-ui": "0.8.4-main.c85a9c8dae",
|
|
80
|
+
"@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
|
|
61
81
|
},
|
|
62
82
|
"publishConfig": {
|
|
63
83
|
"access": "public"
|
package/src/MasonryPlugin.tsx
CHANGED
|
@@ -2,61 +2,37 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import { ClientEvents } from '@dxos/plugin-client';
|
|
7
|
-
import { SpaceCapabilities } from '@dxos/plugin-space';
|
|
8
|
-
import { defineObjectForm } from '@dxos/plugin-space/types';
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
9
6
|
|
|
10
|
-
import {
|
|
7
|
+
import { Plugin } from '@dxos/app-framework';
|
|
8
|
+
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
|
+
|
|
13
|
+
import { ReactSurface } from './capabilities';
|
|
11
14
|
import { meta } from './meta';
|
|
12
15
|
import { translations } from './translations';
|
|
13
16
|
import { Masonry, MasonryAction } from './types';
|
|
14
17
|
|
|
15
|
-
export const MasonryPlugin =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
contributes(Capabilities.Metadata, {
|
|
31
|
-
id: Masonry.Masonry.typename,
|
|
32
|
-
metadata: {
|
|
33
|
-
icon: 'ph--wall--regular',
|
|
34
|
-
iconHue: 'green',
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
}),
|
|
38
|
-
defineModule({
|
|
39
|
-
id: `${meta.id}/module/object-form`,
|
|
40
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
41
|
-
activate: () =>
|
|
42
|
-
contributes(
|
|
43
|
-
SpaceCapabilities.ObjectForm,
|
|
44
|
-
defineObjectForm({
|
|
45
|
-
objectSchema: Masonry.Masonry,
|
|
46
|
-
formSchema: MasonryAction.MasonryProps,
|
|
47
|
-
hidden: true,
|
|
48
|
-
getIntent: (props, options) => createIntent(MasonryAction.CreateMasonry, { ...props, space: options.space }),
|
|
49
|
-
}),
|
|
50
|
-
),
|
|
51
|
-
}),
|
|
52
|
-
defineModule({
|
|
53
|
-
id: `${meta.id}/module/react-surface`,
|
|
54
|
-
activatesOn: Events.SetupReactSurface,
|
|
55
|
-
activate: ReactSurface,
|
|
56
|
-
}),
|
|
57
|
-
defineModule({
|
|
58
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
59
|
-
activatesOn: Events.SetupIntentResolver,
|
|
60
|
-
activate: IntentResolver,
|
|
18
|
+
export const MasonryPlugin = Plugin.define(meta).pipe(
|
|
19
|
+
AppPlugin.addMetadataModule({
|
|
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
|
+
},
|
|
61
33
|
}),
|
|
62
|
-
])
|
|
34
|
+
AppPlugin.addSchemaModule({ schema: [Masonry.Masonry] }),
|
|
35
|
+
AppPlugin.addSurfaceModule({ activate: ReactSurface }),
|
|
36
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
37
|
+
Plugin.make,
|
|
38
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { Obj } from '@dxos/echo';
|
|
11
|
+
import { View } from '@dxos/echo';
|
|
12
|
+
|
|
13
|
+
import { MasonryContainer } from '../../containers';
|
|
14
|
+
import { meta } from '../../meta';
|
|
15
|
+
import { Masonry } from '../../types';
|
|
16
|
+
|
|
17
|
+
export default Capability.makeModule(() =>
|
|
18
|
+
Effect.succeed(
|
|
19
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
20
|
+
Surface.create({
|
|
21
|
+
id: meta.id,
|
|
22
|
+
role: ['article', 'section'],
|
|
23
|
+
filter: (data): data is { subject: Masonry.Masonry | View.View } =>
|
|
24
|
+
Obj.instanceOf(Masonry.Masonry, data.subject) || Obj.instanceOf(View.View, data.subject),
|
|
25
|
+
component: ({ data, role }) => {
|
|
26
|
+
const view = Obj.instanceOf(View.View, data.subject) ? data.subject : data.subject.view;
|
|
27
|
+
return <MasonryContainer view={view} role={role} />;
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
]),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
@@ -0,0 +1,80 @@
|
|
|
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';
|
|
12
|
+
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
13
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
14
|
+
import { faker } from '@dxos/random';
|
|
15
|
+
import { Filter, useObject, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
16
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
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
|
+
faker.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
|
+
withTheme(),
|
|
42
|
+
withLayout({ layout: 'fullscreen' }),
|
|
43
|
+
withPluginManager({
|
|
44
|
+
plugins: [
|
|
45
|
+
...corePlugins(),
|
|
46
|
+
StorybookPlugin({}),
|
|
47
|
+
ClientPlugin({
|
|
48
|
+
types: [Organization.Organization, View.View, Masonry.Masonry],
|
|
49
|
+
onClientInitialized: ({ client }) =>
|
|
50
|
+
Effect.gen(function* () {
|
|
51
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
52
|
+
const space = yield* Effect.promise(() => client.spaces.create());
|
|
53
|
+
yield* Effect.promise(() => space.waitUntilReady());
|
|
54
|
+
const { view } = yield* Effect.promise(() =>
|
|
55
|
+
ViewModel.makeFromDatabase({
|
|
56
|
+
db: space.db,
|
|
57
|
+
typename: Organization.Organization.typename,
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
const masonry = Masonry.make({ view });
|
|
61
|
+
space.db.add(masonry);
|
|
62
|
+
const factory = createObjectFactory(space.db, faker as any);
|
|
63
|
+
yield* Effect.promise(() => factory([{ type: Organization.Organization, count: 64 }]));
|
|
64
|
+
}),
|
|
65
|
+
}),
|
|
66
|
+
|
|
67
|
+
PreviewPlugin(),
|
|
68
|
+
],
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
71
|
+
parameters: {
|
|
72
|
+
layout: 'fullscreen',
|
|
73
|
+
},
|
|
74
|
+
} satisfies Meta;
|
|
75
|
+
|
|
76
|
+
export default meta;
|
|
77
|
+
|
|
78
|
+
type Story = StoryObj<typeof meta>;
|
|
79
|
+
|
|
80
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Surface, useCapabilities } from '@dxos/app-framework/ui';
|
|
9
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
10
|
+
import { useObjectMenuItems, useObjectNavigate } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { Filter, Obj, type Ref, Type } from '@dxos/echo';
|
|
12
|
+
import { type View } from '@dxos/echo';
|
|
13
|
+
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
14
|
+
import { useObject, useQuery } from '@dxos/react-client/echo';
|
|
15
|
+
import { Card, Toolbar } from '@dxos/react-ui';
|
|
16
|
+
import { Masonry as MasonryComponent } from '@dxos/react-ui-masonry';
|
|
17
|
+
import { Menu } from '@dxos/react-ui-menu';
|
|
18
|
+
import { getTypenameFromQuery } from '@dxos/schema';
|
|
19
|
+
|
|
20
|
+
export type MasonryContainerProps = {
|
|
21
|
+
view: View.View;
|
|
22
|
+
role?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const MasonryContainer = ({
|
|
26
|
+
view: viewOrRef,
|
|
27
|
+
role: _role,
|
|
28
|
+
}: {
|
|
29
|
+
view: View.View | Ref.Ref<View.View>;
|
|
30
|
+
role?: string;
|
|
31
|
+
}) => {
|
|
32
|
+
const [view] = useObject(viewOrRef);
|
|
33
|
+
const schemas = useCapabilities(AppCapabilities.Schema);
|
|
34
|
+
const db = view && Obj.getDatabase(view);
|
|
35
|
+
const typename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
|
|
36
|
+
|
|
37
|
+
const [cardSchema, setCardSchema] = useState<Schema.Schema.AnyNoContext>();
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
|
|
41
|
+
if (staticSchema) {
|
|
42
|
+
setCardSchema(() => staticSchema);
|
|
43
|
+
}
|
|
44
|
+
if (!staticSchema && typename && db) {
|
|
45
|
+
const query = db.schemaRegistry.query({ typename });
|
|
46
|
+
const unsubscribe = query.subscribe(
|
|
47
|
+
() => {
|
|
48
|
+
const [schema] = query.results;
|
|
49
|
+
if (schema) {
|
|
50
|
+
setCardSchema(schema);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{ fire: true },
|
|
54
|
+
);
|
|
55
|
+
return unsubscribe;
|
|
56
|
+
}
|
|
57
|
+
}, [schemas, typename, db]);
|
|
58
|
+
|
|
59
|
+
const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
|
|
60
|
+
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<MasonryComponent.Root
|
|
64
|
+
items={filteredObjects}
|
|
65
|
+
render={Item as any}
|
|
66
|
+
classNames='w-full max-w-full h-full max-h-full overflow-y-auto p-4'
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const Item = ({ data }: { data: any }) => {
|
|
72
|
+
const objectMenuItems = useObjectMenuItems(data);
|
|
73
|
+
const handleNavigate = useObjectNavigate(data);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Menu.Root>
|
|
77
|
+
<Card.Root>
|
|
78
|
+
<Card.Toolbar>
|
|
79
|
+
<span />
|
|
80
|
+
<Card.Title onClick={handleNavigate}>{Obj.getLabel(data)}</Card.Title>
|
|
81
|
+
{/* TODO(wittjosiah): Reconcile with Card.Menu. */}
|
|
82
|
+
<Menu.Trigger asChild disabled={!objectMenuItems?.length}>
|
|
83
|
+
<Toolbar.IconButton iconOnly variant='ghost' icon='ph--dots-three-vertical--regular' label='Actions' />
|
|
84
|
+
</Menu.Trigger>
|
|
85
|
+
<Menu.Content items={objectMenuItems} />
|
|
86
|
+
</Card.Toolbar>
|
|
87
|
+
<Surface.Surface role='card--content' limit={1} data={{ subject: data }} />
|
|
88
|
+
</Card.Root>
|
|
89
|
+
</Menu.Root>
|
|
90
|
+
);
|
|
91
|
+
};
|
package/src/meta.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'dxos.org/plugin/masonry',
|
|
10
10
|
name: 'Masonry',
|
|
11
11
|
description: trim`
|
package/src/translations.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Type } from '@dxos/echo';
|
|
5
6
|
import { type Resource } from '@dxos/react-ui';
|
|
6
7
|
|
|
7
8
|
import { meta } from './meta';
|
|
@@ -10,12 +11,15 @@ import { Masonry } from './types';
|
|
|
10
11
|
export const translations = [
|
|
11
12
|
{
|
|
12
13
|
'en-US': {
|
|
13
|
-
[Masonry.Masonry
|
|
14
|
+
[Type.getTypename(Masonry.Masonry)]: {
|
|
14
15
|
'typename label': 'Masonry',
|
|
15
16
|
'typename label_zero': 'Masonries',
|
|
16
17
|
'typename label_one': 'Masonry',
|
|
17
18
|
'typename label_other': 'Masonries',
|
|
18
19
|
'object name placeholder': 'New masonry',
|
|
20
|
+
'rename object label': 'Rename masonry',
|
|
21
|
+
'delete object label': 'Delete masonry',
|
|
22
|
+
'object deleted label': 'Masonry deleted',
|
|
19
23
|
},
|
|
20
24
|
[meta.id]: {
|
|
21
25
|
'plugin name': 'Masonry',
|
package/src/types/Masonry.ts
CHANGED
|
@@ -4,47 +4,59 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Obj, Type } from '@dxos/echo';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { 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';
|
|
10
11
|
|
|
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
|
+
|
|
12
17
|
arrangement: Schema.Array(
|
|
13
18
|
Schema.Struct({
|
|
14
|
-
ids: Schema.Array(
|
|
19
|
+
ids: Schema.Array(Obj.ID),
|
|
15
20
|
hidden: Schema.optional(Schema.Boolean),
|
|
16
|
-
})
|
|
17
|
-
).pipe(
|
|
21
|
+
}),
|
|
22
|
+
).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
18
23
|
// TODO(wittjosiah): Consider Masonry supporting not being just a view but referencing arbitrary data directly.
|
|
19
24
|
}).pipe(
|
|
20
|
-
Type.
|
|
25
|
+
Type.object({
|
|
21
26
|
typename: 'dxos.org/type/Masonry',
|
|
22
|
-
version: '0.
|
|
27
|
+
version: '0.2.0',
|
|
23
28
|
}),
|
|
29
|
+
LabelAnnotation.set(['name']),
|
|
24
30
|
ViewAnnotation.set(true),
|
|
25
31
|
);
|
|
26
32
|
|
|
27
|
-
export
|
|
33
|
+
export interface Masonry extends Schema.Schema.Type<typeof Masonry> {}
|
|
34
|
+
|
|
35
|
+
type MakeProps = Omit<Partial<Obj.MakeProps<typeof Masonry>>, 'view'> & {
|
|
36
|
+
view: View.View;
|
|
37
|
+
};
|
|
28
38
|
|
|
29
39
|
/**
|
|
30
|
-
* Make a masonry
|
|
40
|
+
* Make a masonry as a view of a data set.
|
|
31
41
|
*/
|
|
32
|
-
export const make = (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export const makeView = async ({
|
|
37
|
-
...props
|
|
38
|
-
}: MakeViewProps): Promise<{
|
|
39
|
-
jsonSchema: JsonSchemaType;
|
|
40
|
-
view: DataType.View;
|
|
41
|
-
schema: ReturnType<typeof toEffectSchema>;
|
|
42
|
-
}> => {
|
|
43
|
-
const masonry = Obj.make(Masonry, {});
|
|
44
|
-
const { jsonSchema, view } = await createViewFromSpace({ ...props, presentation: masonry });
|
|
42
|
+
export const make = ({ name, arrangement = [], view }: MakeProps): Masonry => {
|
|
43
|
+
return Obj.make(Masonry, { name, view: Ref.make(view), arrangement });
|
|
44
|
+
};
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
//
|
|
47
|
+
// V1
|
|
48
|
+
//
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
export const MasonryV1 = Schema.Struct({
|
|
51
|
+
arrangement: Schema.Array(
|
|
52
|
+
Schema.Struct({
|
|
53
|
+
ids: Schema.Array(Obj.ID),
|
|
54
|
+
hidden: Schema.optional(Schema.Boolean),
|
|
55
|
+
}),
|
|
56
|
+
).pipe(Schema.optional),
|
|
57
|
+
}).pipe(
|
|
58
|
+
Type.object({
|
|
59
|
+
typename: 'dxos.org/type/Masonry',
|
|
60
|
+
version: '0.1.0',
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
@@ -4,26 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { DataType, TypenameAnnotationId } from '@dxos/schema';
|
|
9
|
-
|
|
10
|
-
import { meta } from '../meta';
|
|
11
|
-
|
|
12
|
-
const MASONRY_ACTION = `${meta.id}/action`;
|
|
7
|
+
import { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';
|
|
13
8
|
|
|
14
9
|
export const MasonryProps = Schema.Struct({
|
|
15
10
|
name: Schema.optional(Schema.String),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
registered: ['registered'],
|
|
20
18
|
}),
|
|
19
|
+
Schema.optional,
|
|
21
20
|
),
|
|
22
21
|
});
|
|
23
|
-
|
|
24
|
-
export class CreateMasonry extends Schema.TaggedClass<CreateMasonry>()(`${MASONRY_ACTION}/create`, {
|
|
25
|
-
input: Schema.extend(Schema.Struct({ space: SpaceSchema }), MasonryProps),
|
|
26
|
-
output: Schema.Struct({
|
|
27
|
-
object: DataType.View,
|
|
28
|
-
}),
|
|
29
|
-
}) {}
|