@dxos/plugin-masonry 0.8.4-main.7ace549 → 0.8.4-main.937b3ca
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/{chunk-4I5S2QKH.mjs → chunk-2QCFP5QL.mjs} +4 -35
- package/dist/lib/browser/chunk-2QCFP5QL.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 +39 -54
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-BNMIVM2K.mjs +94 -0
- package/dist/lib/browser/react-surface-BNMIVM2K.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-VKN225ZV.mjs → chunk-6SGZVU7G.mjs} +4 -35
- package/dist/lib/node-esm/chunk-6SGZVU7G.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 +39 -54
- 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-OK33CG7H.mjs +95 -0
- package/dist/lib/node-esm/react-surface-OK33CG7H.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- 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/MasonryContainer.d.ts +8 -3
- package/dist/types/src/components/MasonryContainer.d.ts.map +1 -1
- package/dist/types/src/components/MasonryContainer.stories.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types/Masonry.d.ts +15 -18
- 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 +37 -33
- package/src/MasonryPlugin.tsx +26 -45
- package/src/capabilities/index.ts +1 -4
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +31 -0
- package/src/components/MasonryContainer.stories.tsx +25 -26
- package/src/components/MasonryContainer.tsx +41 -21
- package/src/meta.ts +2 -2
- package/src/types/Masonry.ts +5 -6
- package/src/types/MasonryAction.ts +0 -14
- package/dist/lib/browser/chunk-4I5S2QKH.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-7WOSAD4H.mjs +0 -35
- package/dist/lib/browser/intent-resolver-7WOSAD4H.mjs.map +0 -7
- package/dist/lib/browser/react-surface-CFD3AW3U.mjs +0 -95
- package/dist/lib/browser/react-surface-CFD3AW3U.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VKN225ZV.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-AXT5HIJX.mjs +0 -36
- package/dist/lib/node-esm/intent-resolver-AXT5HIJX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7MHZZTKP.mjs +0 -96
- package/dist/lib/node-esm/react-surface-7MHZZTKP.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/src/capabilities/intent-resolver.ts +0 -22
- package/src/capabilities/react-surface.tsx +0 -22
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.937b3ca",
|
|
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,
|
|
@@ -35,43 +39,43 @@
|
|
|
35
39
|
"src"
|
|
36
40
|
],
|
|
37
41
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/react-
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
49
|
-
"@dxos/react-ui-
|
|
50
|
-
"@dxos/react-ui-
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/util": "0.8.4-main.7ace549"
|
|
42
|
+
"@dxos/app-framework": "0.8.4-main.937b3ca",
|
|
43
|
+
"@dxos/echo": "0.8.4-main.937b3ca",
|
|
44
|
+
"@dxos/effect": "0.8.4-main.937b3ca",
|
|
45
|
+
"@dxos/plugin-search": "0.8.4-main.937b3ca",
|
|
46
|
+
"@dxos/plugin-client": "0.8.4-main.937b3ca",
|
|
47
|
+
"@dxos/plugin-space": "0.8.4-main.937b3ca",
|
|
48
|
+
"@dxos/react-client": "0.8.4-main.937b3ca",
|
|
49
|
+
"@dxos/operation": "0.8.4-main.937b3ca",
|
|
50
|
+
"@dxos/react-ui-form": "0.8.4-main.937b3ca",
|
|
51
|
+
"@dxos/react-ui": "0.8.4-main.937b3ca",
|
|
52
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.937b3ca",
|
|
53
|
+
"@dxos/react-ui-stack": "0.8.4-main.937b3ca",
|
|
54
|
+
"@dxos/react-ui-masonry": "0.8.4-main.937b3ca",
|
|
55
|
+
"@dxos/types": "0.8.4-main.937b3ca",
|
|
56
|
+
"@dxos/schema": "0.8.4-main.937b3ca",
|
|
57
|
+
"@dxos/util": "0.8.4-main.937b3ca"
|
|
55
58
|
},
|
|
56
59
|
"devDependencies": {
|
|
57
|
-
"@types/react": "~19.2.
|
|
58
|
-
"@types/react-dom": "~19.2.
|
|
59
|
-
"effect": "3.
|
|
60
|
-
"react": "~19.2.
|
|
61
|
-
"react-dom": "~19.2.
|
|
60
|
+
"@types/react": "~19.2.7",
|
|
61
|
+
"@types/react-dom": "~19.2.3",
|
|
62
|
+
"effect": "3.19.11",
|
|
63
|
+
"react": "~19.2.3",
|
|
64
|
+
"react-dom": "~19.2.3",
|
|
62
65
|
"vite": "7.1.9",
|
|
63
|
-
"@dxos/plugin-
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
66
|
+
"@dxos/plugin-theme": "0.8.4-main.937b3ca",
|
|
67
|
+
"@dxos/random": "0.8.4-main.937b3ca",
|
|
68
|
+
"@dxos/plugin-preview": "0.8.4-main.937b3ca",
|
|
69
|
+
"@dxos/storybook-utils": "0.8.4-main.937b3ca",
|
|
70
|
+
"@dxos/plugin-testing": "0.8.4-main.937b3ca",
|
|
71
|
+
"@dxos/ui-theme": "0.8.4-main.937b3ca"
|
|
68
72
|
},
|
|
69
73
|
"peerDependencies": {
|
|
70
|
-
"effect": "
|
|
71
|
-
"react": "
|
|
72
|
-
"react-dom": "
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/react-ui
|
|
74
|
+
"effect": "3.19.11",
|
|
75
|
+
"react": "~19.2.3",
|
|
76
|
+
"react-dom": "~19.2.3",
|
|
77
|
+
"@dxos/ui-theme": "0.8.4-main.937b3ca",
|
|
78
|
+
"@dxos/react-ui": "0.8.4-main.937b3ca"
|
|
75
79
|
},
|
|
76
80
|
"publishConfig": {
|
|
77
81
|
"access": "public"
|
package/src/MasonryPlugin.tsx
CHANGED
|
@@ -2,55 +2,36 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Common, Plugin } from '@dxos/app-framework';
|
|
6
8
|
import { Type } from '@dxos/echo';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
+
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
10
|
+
import { View } from '@dxos/schema';
|
|
9
11
|
|
|
10
|
-
import {
|
|
12
|
+
import { ReactSurface } from './capabilities';
|
|
11
13
|
import { meta } from './meta';
|
|
12
14
|
import { translations } from './translations';
|
|
13
15
|
import { Masonry, MasonryAction } from './types';
|
|
14
16
|
|
|
15
|
-
export const MasonryPlugin =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
metadata: {
|
|
33
|
-
icon: 'ph--wall--regular',
|
|
34
|
-
iconHue: 'green',
|
|
35
|
-
inputSchema: MasonryAction.MasonryProps,
|
|
36
|
-
createObjectIntent: ((props, options) =>
|
|
37
|
-
createIntent(MasonryAction.CreateMasonry, { ...props, space: options.space })) satisfies CreateObjectIntent,
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
}),
|
|
41
|
-
defineModule({
|
|
42
|
-
id: `${meta.id}/module/schema`,
|
|
43
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
44
|
-
activate: () => contributes(ClientCapabilities.Schema, [Masonry.Masonry]),
|
|
45
|
-
}),
|
|
46
|
-
defineModule({
|
|
47
|
-
id: `${meta.id}/module/react-surface`,
|
|
48
|
-
activatesOn: Events.SetupReactSurface,
|
|
49
|
-
activate: ReactSurface,
|
|
50
|
-
}),
|
|
51
|
-
defineModule({
|
|
52
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
53
|
-
activatesOn: Events.SetupIntentResolver,
|
|
54
|
-
activate: IntentResolver,
|
|
17
|
+
export const MasonryPlugin = Plugin.define(meta).pipe(
|
|
18
|
+
Common.Plugin.addTranslationsModule({ translations }),
|
|
19
|
+
Common.Plugin.addSurfaceModule({ activate: ReactSurface }),
|
|
20
|
+
Common.Plugin.addMetadataModule({
|
|
21
|
+
metadata: {
|
|
22
|
+
id: Type.getTypename(Masonry.Masonry),
|
|
23
|
+
metadata: {
|
|
24
|
+
icon: 'ph--wall--regular',
|
|
25
|
+
iconHue: 'green',
|
|
26
|
+
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 });
|
|
31
|
+
})) satisfies CreateObject,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
55
34
|
}),
|
|
56
|
-
])
|
|
35
|
+
Common.Plugin.addSchemaModule({ schema: [Masonry.Masonry] }),
|
|
36
|
+
Plugin.make,
|
|
37
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Capability, Common } from '@dxos/app-framework';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { View } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { MasonryContainer } from '../../components/MasonryContainer';
|
|
13
|
+
import { meta } from '../../meta';
|
|
14
|
+
import { Masonry } from '../../types';
|
|
15
|
+
|
|
16
|
+
export default Capability.makeModule(() =>
|
|
17
|
+
Effect.succeed(
|
|
18
|
+
Capability.contributes(Common.Capability.ReactSurface, [
|
|
19
|
+
Common.createSurface({
|
|
20
|
+
id: meta.id,
|
|
21
|
+
role: ['article', 'section'],
|
|
22
|
+
filter: (data): data is { subject: Masonry.Masonry | View.View } =>
|
|
23
|
+
Obj.instanceOf(Masonry.Masonry, data.subject) || Obj.instanceOf(View.View, data.subject),
|
|
24
|
+
component: ({ data, role }) => {
|
|
25
|
+
const view = Obj.instanceOf(View.View, data.subject) ? data.subject : data.subject.view;
|
|
26
|
+
return <MasonryContainer view={view} role={role} />;
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
]),
|
|
30
|
+
),
|
|
31
|
+
);
|
|
@@ -3,19 +3,16 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
|
|
8
|
-
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
9
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
10
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
11
11
|
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
12
|
-
import {
|
|
13
|
-
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
14
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
12
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
15
13
|
import { faker } from '@dxos/random';
|
|
16
|
-
import { Filter, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
14
|
+
import { Filter, useObject, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
17
15
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
18
|
-
import { defaultTx } from '@dxos/react-ui-theme';
|
|
19
16
|
import { View } from '@dxos/schema';
|
|
20
17
|
import { createObjectFactory } from '@dxos/schema/testing';
|
|
21
18
|
import { Organization } from '@dxos/types';
|
|
@@ -29,10 +26,10 @@ faker.seed(0);
|
|
|
29
26
|
const StorybookMasonry = () => {
|
|
30
27
|
const spaces = useSpaces();
|
|
31
28
|
const space = spaces[spaces.length - 1];
|
|
32
|
-
const masonries = useQuery(space, Filter.type(Masonry.Masonry));
|
|
33
|
-
const masonry = masonries.at(0);
|
|
29
|
+
const masonries = useQuery(space?.db, Filter.type(Masonry.Masonry));
|
|
30
|
+
const [masonry] = useObject(masonries.at(0));
|
|
34
31
|
|
|
35
|
-
return masonry ? <MasonryContainer
|
|
32
|
+
return masonry ? <MasonryContainer view={masonry.view} role='story' /> : null;
|
|
36
33
|
};
|
|
37
34
|
|
|
38
35
|
const meta = {
|
|
@@ -43,27 +40,29 @@ const meta = {
|
|
|
43
40
|
withTheme,
|
|
44
41
|
withPluginManager({
|
|
45
42
|
plugins: [
|
|
43
|
+
...corePlugins(),
|
|
44
|
+
StorybookPlugin({}),
|
|
46
45
|
ClientPlugin({
|
|
47
46
|
types: [Organization.Organization, View.View, Masonry.Masonry],
|
|
48
|
-
onClientInitialized:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
onClientInitialized: ({ client }) =>
|
|
48
|
+
Effect.gen(function* () {
|
|
49
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
50
|
+
const space = yield* Effect.promise(() => client.spaces.create());
|
|
51
|
+
yield* Effect.promise(() => space.waitUntilReady());
|
|
52
|
+
const { view } = yield* Effect.promise(() =>
|
|
53
|
+
View.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, faker as any);
|
|
61
|
+
yield* Effect.promise(() => factory([{ type: Organization.Organization, count: 64 }]));
|
|
62
|
+
}),
|
|
60
63
|
}),
|
|
61
|
-
|
|
62
|
-
IntentPlugin(),
|
|
63
|
-
SettingsPlugin(),
|
|
64
|
-
ThemePlugin({ tx: defaultTx }),
|
|
64
|
+
|
|
65
65
|
PreviewPlugin(),
|
|
66
|
-
StorybookLayoutPlugin({}),
|
|
67
66
|
],
|
|
68
67
|
}),
|
|
69
68
|
],
|
|
@@ -2,37 +2,44 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
5
6
|
import React, { useEffect, useState } from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { type
|
|
8
|
+
import { Common } from '@dxos/app-framework';
|
|
9
|
+
import { Surface, useCapabilities } from '@dxos/app-framework/react';
|
|
10
|
+
import { Filter, Obj, type Ref, Type } from '@dxos/echo';
|
|
10
11
|
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
11
|
-
import {
|
|
12
|
-
import { getSpace, useQuery } from '@dxos/react-client/echo';
|
|
12
|
+
import { useObject, useQuery } from '@dxos/react-client/echo';
|
|
13
13
|
import { Masonry as MasonryComponent } from '@dxos/react-ui-masonry';
|
|
14
|
-
import {
|
|
14
|
+
import { Card } from '@dxos/react-ui-mosaic';
|
|
15
|
+
import { type View, getTypenameFromQuery } from '@dxos/schema';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return <Surface role='card' limit={1} data={{ subject: data }} />;
|
|
17
|
+
export type MasonryContainerProps = {
|
|
18
|
+
view: View.View;
|
|
19
|
+
role?: string;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export const MasonryContainer = ({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
export const MasonryContainer = ({
|
|
23
|
+
view: viewOrRef,
|
|
24
|
+
role,
|
|
25
|
+
}: {
|
|
26
|
+
view: View.View | Ref.Ref<View.View>;
|
|
27
|
+
role?: string;
|
|
28
|
+
}) => {
|
|
29
|
+
const [view] = useObject(viewOrRef);
|
|
30
|
+
const schemas = useCapabilities(Common.Capability.Schema);
|
|
31
|
+
const db = view && Obj.getDatabase(view);
|
|
32
|
+
const typename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
|
|
26
33
|
|
|
27
|
-
const [cardSchema, setCardSchema] = useState<
|
|
34
|
+
const [cardSchema, setCardSchema] = useState<Schema.Schema.AnyNoContext>();
|
|
28
35
|
|
|
29
36
|
useEffect(() => {
|
|
30
|
-
const staticSchema =
|
|
37
|
+
const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
|
|
31
38
|
if (staticSchema) {
|
|
32
|
-
setCardSchema(() => staticSchema
|
|
39
|
+
setCardSchema(() => staticSchema);
|
|
33
40
|
}
|
|
34
|
-
if (!staticSchema && typename &&
|
|
35
|
-
const query =
|
|
41
|
+
if (!staticSchema && typename && db) {
|
|
42
|
+
const query = db.schemaRegistry.query({ typename });
|
|
36
43
|
const unsubscribe = query.subscribe(
|
|
37
44
|
() => {
|
|
38
45
|
const [schema] = query.results;
|
|
@@ -44,9 +51,9 @@ export const MasonryContainer = ({ object, role }: { object: Masonry.Masonry; ro
|
|
|
44
51
|
);
|
|
45
52
|
return unsubscribe;
|
|
46
53
|
}
|
|
47
|
-
}, [typename,
|
|
54
|
+
}, [schemas, typename, db]);
|
|
48
55
|
|
|
49
|
-
const objects = useQuery(
|
|
56
|
+
const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
|
|
50
57
|
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
51
58
|
|
|
52
59
|
return (
|
|
@@ -57,3 +64,16 @@ export const MasonryContainer = ({ object, role }: { object: Masonry.Masonry; ro
|
|
|
57
64
|
/>
|
|
58
65
|
);
|
|
59
66
|
};
|
|
67
|
+
|
|
68
|
+
const Item = ({ data }: { data: any }) => {
|
|
69
|
+
return (
|
|
70
|
+
<Card.Root>
|
|
71
|
+
<Card.Toolbar>
|
|
72
|
+
<span />
|
|
73
|
+
<Card.Title>{Obj.getLabel(data)}</Card.Title>
|
|
74
|
+
<Card.Menu />
|
|
75
|
+
</Card.Toolbar>
|
|
76
|
+
<Surface role='card--content' limit={1} data={{ subject: data }} />
|
|
77
|
+
</Card.Root>
|
|
78
|
+
);
|
|
79
|
+
};
|
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/types/Masonry.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Obj, Ref, Type } from '@dxos/echo';
|
|
|
8
8
|
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
9
9
|
import { View, ViewAnnotation } from '@dxos/schema';
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
export const Masonry = Schema.Struct({
|
|
12
12
|
name: Schema.String.pipe(Schema.optional),
|
|
13
13
|
|
|
14
14
|
view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
@@ -21,16 +21,15 @@ const MasonrySchema = Schema.Struct({
|
|
|
21
21
|
).pipe(Schema.mutable, FormInputAnnotation.set(false), Schema.optional),
|
|
22
22
|
// TODO(wittjosiah): Consider Masonry supporting not being just a view but referencing arbitrary data directly.
|
|
23
23
|
}).pipe(
|
|
24
|
-
Type.
|
|
24
|
+
Type.object({
|
|
25
25
|
typename: 'dxos.org/type/Masonry',
|
|
26
26
|
version: '0.2.0',
|
|
27
27
|
}),
|
|
28
28
|
LabelAnnotation.set(['name']),
|
|
29
29
|
ViewAnnotation.set(true),
|
|
30
30
|
);
|
|
31
|
-
|
|
32
|
-
export interface
|
|
33
|
-
export const Masonry: Schema.Schema<Masonry, MasonryEncoded> = MasonrySchema;
|
|
31
|
+
|
|
32
|
+
export interface Masonry extends Schema.Schema.Type<typeof Masonry> {}
|
|
34
33
|
|
|
35
34
|
type MakeProps = Omit<Partial<Obj.MakeProps<typeof Masonry>>, 'view'> & {
|
|
36
35
|
view: View.View;
|
|
@@ -55,7 +54,7 @@ export const MasonryV1 = Schema.Struct({
|
|
|
55
54
|
}).pipe(Schema.mutable),
|
|
56
55
|
).pipe(Schema.mutable, Schema.optional),
|
|
57
56
|
}).pipe(
|
|
58
|
-
Type.
|
|
57
|
+
Type.object({
|
|
59
58
|
typename: 'dxos.org/type/Masonry',
|
|
60
59
|
version: '0.1.0',
|
|
61
60
|
}),
|
|
@@ -5,13 +5,6 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';
|
|
8
|
-
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
9
|
-
|
|
10
|
-
import { meta } from '../meta';
|
|
11
|
-
|
|
12
|
-
import * as Masonry from './Masonry';
|
|
13
|
-
|
|
14
|
-
const MASONRY_ACTION = `${meta.id}/action`;
|
|
15
8
|
|
|
16
9
|
export const MasonryProps = Schema.Struct({
|
|
17
10
|
name: Schema.optional(Schema.String),
|
|
@@ -26,10 +19,3 @@ export const MasonryProps = Schema.Struct({
|
|
|
26
19
|
Schema.optional,
|
|
27
20
|
),
|
|
28
21
|
});
|
|
29
|
-
|
|
30
|
-
export class CreateMasonry extends Schema.TaggedClass<CreateMasonry>()(`${MASONRY_ACTION}/create`, {
|
|
31
|
-
input: Schema.extend(Schema.Struct({ space: SpaceSchema }), MasonryProps),
|
|
32
|
-
output: Schema.Struct({
|
|
33
|
-
object: Masonry.Masonry,
|
|
34
|
-
}),
|
|
35
|
-
}) {}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/Masonry.ts", "../../../src/types/MasonryAction.ts", "../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { View, ViewAnnotation } from '@dxos/schema';\n\nconst MasonrySchema = Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n\n view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),\n\n arrangement: Schema.Array(\n Schema.Struct({\n ids: Schema.Array(Obj.ID),\n hidden: Schema.optional(Schema.Boolean),\n }).pipe(Schema.mutable),\n ).pipe(Schema.mutable, FormInputAnnotation.set(false), Schema.optional),\n // TODO(wittjosiah): Consider Masonry supporting not being just a view but referencing arbitrary data directly.\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Masonry',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\n);\nexport interface Masonry extends Schema.Schema.Type<typeof MasonrySchema> {}\nexport interface MasonryEncoded extends Schema.Schema.Encoded<typeof MasonrySchema> {}\nexport const Masonry: Schema.Schema<Masonry, MasonryEncoded> = MasonrySchema;\n\ntype MakeProps = Omit<Partial<Obj.MakeProps<typeof Masonry>>, 'view'> & {\n view: View.View;\n};\n\n/**\n * Make a masonry as a view of a data set.\n */\nexport const make = ({ name, arrangement = [], view }: MakeProps): Masonry => {\n return Obj.make(Masonry, { name, view: Ref.make(view), arrangement });\n};\n\n//\n// V1\n//\n\nexport const MasonryV1 = Schema.Struct({\n arrangement: Schema.Array(\n Schema.Struct({\n ids: Schema.Array(Obj.ID),\n hidden: Schema.optional(Schema.Boolean),\n }).pipe(Schema.mutable),\n ).pipe(Schema.mutable, Schema.optional),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Masonry',\n version: '0.1.0',\n }),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';\nimport { SpaceSchema } from '@dxos/react-client/echo';\n\nimport { meta } from '../meta';\n\nimport * as Masonry from './Masonry';\n\nconst MASONRY_ACTION = `${meta.id}/action`;\n\nexport const MasonryProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n // TODO(wittjosiah): This should be a query input instead.\n typename: Schema.String.pipe(\n Schema.annotations({ title: 'Select card type' }),\n TypeInputOptionsAnnotation.set({\n location: ['database', 'runtime'],\n kind: ['user'],\n registered: ['registered'],\n }),\n Schema.optional,\n ),\n});\n\nexport class CreateMasonry extends Schema.TaggedClass<CreateMasonry>()(`${MASONRY_ACTION}/create`, {\n input: Schema.extend(Schema.Struct({ space: SpaceSchema }), MasonryProps),\n output: Schema.Struct({\n object: Masonry.Masonry,\n }),\n}) {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/masonry',\n name: 'Masonry',\n description: trim`\n Responsive grid layout that displays query results in an adaptive masonry pattern.\n Visualize collections of cards, images, or mixed content that automatically adjusts to available screen space.\n `,\n icon: 'ph--wall--regular',\n iconHue: 'green',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-masonry',\n screenshots: [],\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAAA;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,KAAKC,KAAKC,YAAY;AAC/B,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,MAAMC,sBAAsB;AAErC,IAAMC,gBAAuBC,cAAO;EAClCC,MAAaC,cAAOC,KAAYC,eAAQ;EAExCC,MAAMC,KAAKC,IAAIC,KAAKA,IAAI,EAAEL,KAAKM,oBAAoBC,IAAI,KAAA,CAAA;EAEvDC,aAAoBC,aACXZ,cAAO;IACZa,KAAYD,aAAME,IAAIC,EAAE;IACxBC,QAAeZ,gBAAgBa,cAAO;EACxC,CAAA,EAAGd,KAAYe,cAAO,CAAA,EACtBf,KAAYe,gBAAST,oBAAoBC,IAAI,KAAA,GAAeN,eAAQ;AAExE,CAAA,EAAGD,KACDG,KAAKQ,IAAI;EACPK,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBX,IAAI;EAAC;CAAO,GAC5BY,eAAeZ,IAAI,IAAA,CAAA;AAId,IAAMa,UAAkDxB;AASxD,IAAMyB,OAAO,CAAC,EAAEvB,MAAMU,cAAc,CAAA,GAAIN,KAAI,MAAa;AAC9D,SAAOS,IAAIU,KAAKD,SAAS;IAAEtB;IAAMI,MAAME,IAAIiB,KAAKnB,IAAAA;IAAOM;EAAY,CAAA;AACrE;AAMO,IAAMc,YAAmBzB,cAAO;EACrCW,aAAoBC,aACXZ,cAAO;IACZa,KAAYD,aAAME,IAAIC,EAAE;IACxBC,QAAeZ,gBAAgBa,cAAO;EACxC,CAAA,EAAGd,KAAYe,cAAO,CAAA,EACtBf,KAAYe,gBAAgBd,eAAQ;AACxC,CAAA,EAAGD,KACDG,KAAKQ,IAAI;EACPK,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;;;AC5DF;;;;;AAIA,YAAYM,aAAY;AAExB,SAASC,kCAAkC;AAC3C,SAASC,mBAAmB;;;ACF5B,SAASC,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,aAAa,CAAA;AACf;;;ADLA,IAAMC,iBAAiB,GAAGC,KAAKC,EAAE;AAE1B,IAAMC,eAAsBC,eAAO;EACxCC,MAAaC,iBAAgBC,cAAM;;EAEnCC,UAAiBD,eAAOE,KACfC,oBAAY;IAAEC,OAAO;EAAmB,CAAA,GAC/CC,2BAA2BC,IAAI;IAC7BC,UAAU;MAAC;MAAY;;IACvBC,MAAM;MAAC;;IACPC,YAAY;MAAC;;EACf,CAAA,GACOV,gBAAQ;AAEnB,CAAA;AAEO,IAAMW,gBAAN,cAAmCC,oBAAW,EAAkB,GAAGlB,cAAAA,WAAyB;EACjGmB,OAAcC,eAAchB,eAAO;IAAEiB,OAAOC;EAAY,CAAA,GAAInB,YAAAA;EAC5DoB,QAAenB,eAAO;IACpBoB,QAAgBC;EAClB,CAAA;AACF,CAAA,EAAA;AAAI;",
|
|
6
|
-
"names": ["Schema", "Obj", "Ref", "Type", "FormInputAnnotation", "LabelAnnotation", "View", "ViewAnnotation", "MasonrySchema", "Struct", "name", "String", "pipe", "optional", "view", "Type", "Ref", "View", "FormInputAnnotation", "set", "arrangement", "Array", "ids", "Obj", "ID", "hidden", "Boolean", "mutable", "typename", "version", "LabelAnnotation", "ViewAnnotation", "Masonry", "make", "MasonryV1", "Schema", "TypeInputOptionsAnnotation", "SpaceSchema", "trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source", "screenshots", "MASONRY_ACTION", "meta", "id", "MasonryProps", "Struct", "name", "optional", "String", "typename", "pipe", "annotations", "title", "TypeInputOptionsAnnotation", "set", "location", "kind", "registered", "CreateMasonry", "TaggedClass", "input", "extend", "space", "SpaceSchema", "output", "object", "Masonry"]
|
|
7
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MasonryAction_exports,
|
|
3
|
-
Masonry_exports
|
|
4
|
-
} from "./chunk-4I5S2QKH.mjs";
|
|
5
|
-
|
|
6
|
-
// src/capabilities/intent-resolver.ts
|
|
7
|
-
import { Capabilities, contributes, createResolver } from "@dxos/app-framework";
|
|
8
|
-
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
9
|
-
import { View } from "@dxos/schema";
|
|
10
|
-
var intent_resolver_default = ((context) => contributes(Capabilities.IntentResolver, [
|
|
11
|
-
createResolver({
|
|
12
|
-
intent: MasonryAction_exports.CreateMasonry,
|
|
13
|
-
resolve: async ({ space, name, typename }) => {
|
|
14
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
15
|
-
const { view } = await View.makeFromSpace({
|
|
16
|
-
client,
|
|
17
|
-
space,
|
|
18
|
-
typename
|
|
19
|
-
});
|
|
20
|
-
const masonry = Masonry_exports.make({
|
|
21
|
-
name,
|
|
22
|
-
view
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
data: {
|
|
26
|
-
object: masonry
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
]));
|
|
32
|
-
export {
|
|
33
|
-
intent_resolver_default as default
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=intent-resolver-7WOSAD4H.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { View } from '@dxos/schema';\n\nimport { Masonry, MasonryAction } from '../types';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.IntentResolver, [\n createResolver({\n intent: MasonryAction.CreateMasonry,\n resolve: async ({ space, name, typename }) => {\n const client = context.getCapability(ClientCapabilities.Client);\n const { view } = await View.makeFromSpace({ client, space, typename });\n const masonry = Masonry.make({ name, view });\n return { data: { object: masonry } };\n },\n }),\n ]);\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,cAAkCC,aAAaC,sBAAsB;AAC9E,SAASC,0BAA0B;AACnC,SAASC,YAAY;AAIrB,IAAA,2BAAe,CAACC,YACdC,YAAYC,aAAaC,gBAAgB;EACvCC,eAAe;IACbC,QAAQC,sBAAcC;IACtBC,SAAS,OAAO,EAAEC,OAAOC,MAAMC,SAAQ,MAAE;AACvC,YAAMC,SAASZ,QAAQa,cAAcC,mBAAmBC,MAAM;AAC9D,YAAM,EAAEC,KAAI,IAAK,MAAMC,KAAKC,cAAc;QAAEN;QAAQH;QAAOE;MAAS,CAAA;AACpE,YAAMQ,UAAUC,gBAAQC,KAAK;QAAEX;QAAMM;MAAK,CAAA;AAC1C,aAAO;QAAEM,MAAM;UAAEC,QAAQJ;QAAQ;MAAE;IACrC;EACF,CAAA;CACD;",
|
|
6
|
-
"names": ["Capabilities", "contributes", "createResolver", "ClientCapabilities", "View", "context", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "MasonryAction", "CreateMasonry", "resolve", "space", "name", "typename", "client", "getCapability", "ClientCapabilities", "Client", "view", "View", "makeFromSpace", "masonry", "Masonry", "make", "data", "object"]
|
|
7
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Masonry_exports,
|
|
3
|
-
meta
|
|
4
|
-
} from "./chunk-4I5S2QKH.mjs";
|
|
5
|
-
|
|
6
|
-
// src/capabilities/react-surface.tsx
|
|
7
|
-
import React2 from "react";
|
|
8
|
-
import { Capabilities, contributes, createSurface } from "@dxos/app-framework";
|
|
9
|
-
import { Obj } from "@dxos/echo";
|
|
10
|
-
|
|
11
|
-
// src/components/MasonryContainer.tsx
|
|
12
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
13
|
-
import React, { useEffect, useState } from "react";
|
|
14
|
-
import { Surface } from "@dxos/app-framework/react";
|
|
15
|
-
import { Filter, Type } from "@dxos/echo";
|
|
16
|
-
import { useGlobalFilteredObjects } from "@dxos/plugin-search";
|
|
17
|
-
import { useClient } from "@dxos/react-client";
|
|
18
|
-
import { getSpace, useQuery } from "@dxos/react-client/echo";
|
|
19
|
-
import { Masonry as MasonryComponent } from "@dxos/react-ui-masonry";
|
|
20
|
-
import { getTypenameFromQuery } from "@dxos/schema";
|
|
21
|
-
var Item = ({ data }) => {
|
|
22
|
-
var _effect = _useSignals();
|
|
23
|
-
try {
|
|
24
|
-
return /* @__PURE__ */ React.createElement(Surface, {
|
|
25
|
-
role: "card",
|
|
26
|
-
limit: 1,
|
|
27
|
-
data: {
|
|
28
|
-
subject: data
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} finally {
|
|
32
|
-
_effect.f();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var MasonryContainer = ({ object, role }) => {
|
|
36
|
-
var _effect = _useSignals();
|
|
37
|
-
try {
|
|
38
|
-
const client = useClient();
|
|
39
|
-
const space = getSpace(object);
|
|
40
|
-
const typename = object.view.target?.query ? getTypenameFromQuery(object.view.target.query.ast) : void 0;
|
|
41
|
-
const [cardSchema, setCardSchema] = useState();
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
const staticSchema = client.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
|
|
44
|
-
if (staticSchema) {
|
|
45
|
-
setCardSchema(() => staticSchema);
|
|
46
|
-
}
|
|
47
|
-
if (!staticSchema && typename && space) {
|
|
48
|
-
const query = space.db.schemaRegistry.query({
|
|
49
|
-
typename
|
|
50
|
-
});
|
|
51
|
-
const unsubscribe = query.subscribe(() => {
|
|
52
|
-
const [schema] = query.results;
|
|
53
|
-
if (schema) {
|
|
54
|
-
setCardSchema(schema);
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
fire: true
|
|
58
|
-
});
|
|
59
|
-
return unsubscribe;
|
|
60
|
-
}
|
|
61
|
-
}, [
|
|
62
|
-
typename,
|
|
63
|
-
space
|
|
64
|
-
]);
|
|
65
|
-
const objects = useQuery(space, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
|
|
66
|
-
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
67
|
-
return /* @__PURE__ */ React.createElement(MasonryComponent.Root, {
|
|
68
|
-
items: filteredObjects,
|
|
69
|
-
render: Item,
|
|
70
|
-
classNames: "is-full max-is-full bs-full max-bs-full overflow-y-auto p-4"
|
|
71
|
-
});
|
|
72
|
-
} finally {
|
|
73
|
-
_effect.f();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// src/capabilities/react-surface.tsx
|
|
78
|
-
var react_surface_default = (() => contributes(Capabilities.ReactSurface, [
|
|
79
|
-
createSurface({
|
|
80
|
-
id: meta.id,
|
|
81
|
-
role: [
|
|
82
|
-
"article",
|
|
83
|
-
"section"
|
|
84
|
-
],
|
|
85
|
-
filter: (data) => Obj.instanceOf(Masonry_exports.Masonry, data.subject),
|
|
86
|
-
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(MasonryContainer, {
|
|
87
|
-
object: data.subject,
|
|
88
|
-
role
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
]));
|
|
92
|
-
export {
|
|
93
|
-
react_surface_default as default
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=react-surface-CFD3AW3U.mjs.map
|