@dxos/plugin-masonry 0.8.4-main.21d9917

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 (62) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +15 -0
  3. package/dist/lib/browser/chunk-2QCFP5QL.mjs +78 -0
  4. package/dist/lib/browser/chunk-2QCFP5QL.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-U46AGJ2D.mjs +19 -0
  6. package/dist/lib/browser/chunk-U46AGJ2D.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +74 -0
  8. package/dist/lib/browser/index.mjs.map +7 -0
  9. package/dist/lib/browser/meta.json +1 -0
  10. package/dist/lib/browser/react-surface-BNMIVM2K.mjs +94 -0
  11. package/dist/lib/browser/react-surface-BNMIVM2K.mjs.map +7 -0
  12. package/dist/lib/browser/types/index.mjs +9 -0
  13. package/dist/lib/browser/types/index.mjs.map +7 -0
  14. package/dist/lib/node-esm/chunk-6SGZVU7G.mjs +79 -0
  15. package/dist/lib/node-esm/chunk-6SGZVU7G.mjs.map +7 -0
  16. package/dist/lib/node-esm/chunk-P6EZJITS.mjs +21 -0
  17. package/dist/lib/node-esm/chunk-P6EZJITS.mjs.map +7 -0
  18. package/dist/lib/node-esm/index.mjs +75 -0
  19. package/dist/lib/node-esm/index.mjs.map +7 -0
  20. package/dist/lib/node-esm/meta.json +1 -0
  21. package/dist/lib/node-esm/react-surface-OK33CG7H.mjs +95 -0
  22. package/dist/lib/node-esm/react-surface-OK33CG7H.mjs.map +7 -0
  23. package/dist/lib/node-esm/types/index.mjs +10 -0
  24. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  25. package/dist/types/src/MasonryPlugin.d.ts +3 -0
  26. package/dist/types/src/MasonryPlugin.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/index.d.ts +2 -0
  28. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  29. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  30. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  31. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  32. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  33. package/dist/types/src/components/MasonryContainer.d.ts +12 -0
  34. package/dist/types/src/components/MasonryContainer.d.ts.map +1 -0
  35. package/dist/types/src/components/MasonryContainer.stories.d.ts +15 -0
  36. package/dist/types/src/components/MasonryContainer.stories.d.ts.map +1 -0
  37. package/dist/types/src/index.d.ts +3 -0
  38. package/dist/types/src/index.d.ts.map +1 -0
  39. package/dist/types/src/meta.d.ts +3 -0
  40. package/dist/types/src/meta.d.ts.map +1 -0
  41. package/dist/types/src/translations.d.ts +26 -0
  42. package/dist/types/src/translations.d.ts.map +1 -0
  43. package/dist/types/src/types/Masonry.d.ts +28 -0
  44. package/dist/types/src/types/Masonry.d.ts.map +1 -0
  45. package/dist/types/src/types/MasonryAction.d.ts +6 -0
  46. package/dist/types/src/types/MasonryAction.d.ts.map +1 -0
  47. package/dist/types/src/types/index.d.ts +3 -0
  48. package/dist/types/src/types/index.d.ts.map +1 -0
  49. package/dist/types/tsconfig.tsbuildinfo +1 -0
  50. package/package.json +83 -0
  51. package/src/MasonryPlugin.tsx +37 -0
  52. package/src/capabilities/index.ts +5 -0
  53. package/src/capabilities/react-surface/index.ts +7 -0
  54. package/src/capabilities/react-surface/react-surface.tsx +31 -0
  55. package/src/components/MasonryContainer.stories.tsx +78 -0
  56. package/src/components/MasonryContainer.tsx +79 -0
  57. package/src/index.ts +7 -0
  58. package/src/meta.ts +19 -0
  59. package/src/translations.ts +29 -0
  60. package/src/types/Masonry.ts +61 -0
  61. package/src/types/MasonryAction.ts +21 -0
  62. package/src/types/index.ts +6 -0
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@dxos/plugin-masonry",
3
+ "version": "0.8.4-main.21d9917",
4
+ "description": "Masonry DXOS Surface plugin",
5
+ "homepage": "https://dxos.org",
6
+ "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
11
+ "license": "MIT",
12
+ "author": "DXOS.org",
13
+ "sideEffects": true,
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "source": "./src/index.ts",
18
+ "types": "./dist/types/src/index.d.ts",
19
+ "browser": "./dist/lib/browser/index.mjs",
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"
27
+ }
28
+ },
29
+ "types": "dist/types/src/index.d.ts",
30
+ "typesVersions": {
31
+ "*": {
32
+ "types": [
33
+ "dist/types/src/types/index.d.ts"
34
+ ]
35
+ }
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "src"
40
+ ],
41
+ "dependencies": {
42
+ "@dxos/echo": "0.8.4-main.21d9917",
43
+ "@dxos/app-framework": "0.8.4-main.21d9917",
44
+ "@dxos/effect": "0.8.4-main.21d9917",
45
+ "@dxos/operation": "0.8.4-main.21d9917",
46
+ "@dxos/plugin-client": "0.8.4-main.21d9917",
47
+ "@dxos/plugin-search": "0.8.4-main.21d9917",
48
+ "@dxos/plugin-space": "0.8.4-main.21d9917",
49
+ "@dxos/react-ui-form": "0.8.4-main.21d9917",
50
+ "@dxos/react-ui-mosaic": "0.8.4-main.21d9917",
51
+ "@dxos/react-ui": "0.8.4-main.21d9917",
52
+ "@dxos/react-client": "0.8.4-main.21d9917",
53
+ "@dxos/react-ui-stack": "0.8.4-main.21d9917",
54
+ "@dxos/react-ui-masonry": "0.8.4-main.21d9917",
55
+ "@dxos/types": "0.8.4-main.21d9917",
56
+ "@dxos/util": "0.8.4-main.21d9917",
57
+ "@dxos/schema": "0.8.4-main.21d9917"
58
+ },
59
+ "devDependencies": {
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",
65
+ "vite": "7.1.9",
66
+ "@dxos/plugin-preview": "0.8.4-main.21d9917",
67
+ "@dxos/plugin-theme": "0.8.4-main.21d9917",
68
+ "@dxos/random": "0.8.4-main.21d9917",
69
+ "@dxos/ui-theme": "0.8.4-main.21d9917",
70
+ "@dxos/storybook-utils": "0.8.4-main.21d9917",
71
+ "@dxos/plugin-testing": "0.8.4-main.21d9917"
72
+ },
73
+ "peerDependencies": {
74
+ "effect": "3.19.11",
75
+ "react": "~19.2.3",
76
+ "react-dom": "~19.2.3",
77
+ "@dxos/react-ui": "0.8.4-main.21d9917",
78
+ "@dxos/ui-theme": "0.8.4-main.21d9917"
79
+ },
80
+ "publishConfig": {
81
+ "access": "public"
82
+ }
83
+ }
@@ -0,0 +1,37 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Common, Plugin } from '@dxos/app-framework';
8
+ import { Type } from '@dxos/echo';
9
+ import { type CreateObject } from '@dxos/plugin-space/types';
10
+ import { View } from '@dxos/schema';
11
+
12
+ import { ReactSurface } from './capabilities';
13
+ import { meta } from './meta';
14
+ import { translations } from './translations';
15
+ import { Masonry, MasonryAction } from './types';
16
+
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
+ },
34
+ }),
35
+ Common.Plugin.addSchemaModule({ schema: [Masonry.Masonry] }),
36
+ Plugin.make,
37
+ );
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './react-surface';
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -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
+ );
@@ -0,0 +1,78 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import * as Effect from 'effect/Effect';
7
+ import React from 'react';
8
+
9
+ import { withPluginManager } from '@dxos/app-framework/testing';
10
+ import { ClientPlugin } from '@dxos/plugin-client';
11
+ import { PreviewPlugin } from '@dxos/plugin-preview';
12
+ import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
13
+ import { faker } from '@dxos/random';
14
+ 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 { createObjectFactory } from '@dxos/schema/testing';
18
+ import { Organization } from '@dxos/types';
19
+
20
+ import { Masonry } from '../types';
21
+
22
+ import { MasonryContainer } from './MasonryContainer';
23
+
24
+ faker.seed(0);
25
+
26
+ const StorybookMasonry = () => {
27
+ const spaces = useSpaces();
28
+ const space = spaces[spaces.length - 1];
29
+ const masonries = useQuery(space?.db, Filter.type(Masonry.Masonry));
30
+ const [masonry] = useObject(masonries.at(0));
31
+
32
+ return masonry ? <MasonryContainer view={masonry.view} role='story' /> : null;
33
+ };
34
+
35
+ const meta = {
36
+ title: 'plugins/plugin-masonry/Masonry',
37
+ component: StorybookMasonry,
38
+ render: () => <StorybookMasonry />,
39
+ decorators: [
40
+ withTheme,
41
+ withPluginManager({
42
+ plugins: [
43
+ ...corePlugins(),
44
+ StorybookPlugin({}),
45
+ ClientPlugin({
46
+ types: [Organization.Organization, View.View, Masonry.Masonry],
47
+ onClientInitialized: ({ client }) =>
48
+ Effect.gen(function* () {
49
+ yield* 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
+ }),
63
+ }),
64
+
65
+ PreviewPlugin(),
66
+ ],
67
+ }),
68
+ ],
69
+ parameters: {
70
+ layout: 'fullscreen',
71
+ },
72
+ } satisfies Meta;
73
+
74
+ export default meta;
75
+
76
+ type Story = StoryObj<typeof meta>;
77
+
78
+ export const Default: Story = {};
@@ -0,0 +1,79 @@
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 { Common } from '@dxos/app-framework';
9
+ import { Surface, useCapabilities } from '@dxos/app-framework/react';
10
+ import { Filter, Obj, type Ref, Type } from '@dxos/echo';
11
+ import { useGlobalFilteredObjects } from '@dxos/plugin-search';
12
+ import { useObject, useQuery } from '@dxos/react-client/echo';
13
+ import { Masonry as MasonryComponent } from '@dxos/react-ui-masonry';
14
+ import { Card } from '@dxos/react-ui-mosaic';
15
+ import { type View, getTypenameFromQuery } from '@dxos/schema';
16
+
17
+ export type MasonryContainerProps = {
18
+ view: View.View;
19
+ role?: string;
20
+ };
21
+
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;
33
+
34
+ const [cardSchema, setCardSchema] = useState<Schema.Schema.AnyNoContext>();
35
+
36
+ useEffect(() => {
37
+ const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
38
+ if (staticSchema) {
39
+ setCardSchema(() => staticSchema);
40
+ }
41
+ if (!staticSchema && typename && db) {
42
+ const query = db.schemaRegistry.query({ typename });
43
+ const unsubscribe = query.subscribe(
44
+ () => {
45
+ const [schema] = query.results;
46
+ if (schema) {
47
+ setCardSchema(schema);
48
+ }
49
+ },
50
+ { fire: true },
51
+ );
52
+ return unsubscribe;
53
+ }
54
+ }, [schemas, typename, db]);
55
+
56
+ const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
57
+ const filteredObjects = useGlobalFilteredObjects(objects);
58
+
59
+ return (
60
+ <MasonryComponent.Root
61
+ items={filteredObjects}
62
+ render={Item as any}
63
+ classNames='is-full max-is-full bs-full max-bs-full overflow-y-auto p-4'
64
+ />
65
+ );
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/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './meta';
6
+
7
+ export * from './MasonryPlugin';
package/src/meta.ts ADDED
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
7
+
8
+ export const meta: Plugin.Meta = {
9
+ id: 'dxos.org/plugin/masonry',
10
+ name: 'Masonry',
11
+ description: trim`
12
+ Responsive grid layout that displays query results in an adaptive masonry pattern.
13
+ Visualize collections of cards, images, or mixed content that automatically adjusts to available screen space.
14
+ `,
15
+ icon: 'ph--wall--regular',
16
+ iconHue: 'green',
17
+ source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-masonry',
18
+ screenshots: [],
19
+ };
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Type } from '@dxos/echo';
6
+ import { type Resource } from '@dxos/react-ui';
7
+
8
+ import { meta } from './meta';
9
+ import { Masonry } from './types';
10
+
11
+ export const translations = [
12
+ {
13
+ 'en-US': {
14
+ [Type.getTypename(Masonry.Masonry)]: {
15
+ 'typename label': 'Masonry',
16
+ 'typename label_zero': 'Masonries',
17
+ 'typename label_one': 'Masonry',
18
+ 'typename label_other': 'Masonries',
19
+ 'object name placeholder': 'New masonry',
20
+ 'rename object label': 'Rename masonry',
21
+ 'delete object label': 'Delete masonry',
22
+ 'object deleted label': 'Masonry deleted',
23
+ },
24
+ [meta.id]: {
25
+ 'plugin name': 'Masonry',
26
+ },
27
+ },
28
+ },
29
+ ] as const satisfies Resource[];
@@ -0,0 +1,61 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { Obj, Ref, Type } from '@dxos/echo';
8
+ import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
9
+ import { View, ViewAnnotation } from '@dxos/schema';
10
+
11
+ export const Masonry = Schema.Struct({
12
+ name: Schema.String.pipe(Schema.optional),
13
+
14
+ view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),
15
+
16
+ arrangement: Schema.Array(
17
+ Schema.Struct({
18
+ ids: Schema.Array(Obj.ID),
19
+ hidden: Schema.optional(Schema.Boolean),
20
+ }).pipe(Schema.mutable),
21
+ ).pipe(Schema.mutable, FormInputAnnotation.set(false), Schema.optional),
22
+ // TODO(wittjosiah): Consider Masonry supporting not being just a view but referencing arbitrary data directly.
23
+ }).pipe(
24
+ Type.object({
25
+ typename: 'dxos.org/type/Masonry',
26
+ version: '0.2.0',
27
+ }),
28
+ LabelAnnotation.set(['name']),
29
+ ViewAnnotation.set(true),
30
+ );
31
+
32
+ export interface Masonry extends Schema.Schema.Type<typeof Masonry> {}
33
+
34
+ type MakeProps = Omit<Partial<Obj.MakeProps<typeof Masonry>>, 'view'> & {
35
+ view: View.View;
36
+ };
37
+
38
+ /**
39
+ * Make a masonry as a view of a data set.
40
+ */
41
+ export const make = ({ name, arrangement = [], view }: MakeProps): Masonry => {
42
+ return Obj.make(Masonry, { name, view: Ref.make(view), arrangement });
43
+ };
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
+ }).pipe(Schema.mutable),
55
+ ).pipe(Schema.mutable, Schema.optional),
56
+ }).pipe(
57
+ Type.object({
58
+ typename: 'dxos.org/type/Masonry',
59
+ version: '0.1.0',
60
+ }),
61
+ );
@@ -0,0 +1,21 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';
8
+
9
+ export const MasonryProps = Schema.Struct({
10
+ name: Schema.optional(Schema.String),
11
+ // TODO(wittjosiah): This should be a query input instead.
12
+ typename: Schema.String.pipe(
13
+ Schema.annotations({ title: 'Select card type' }),
14
+ TypeInputOptionsAnnotation.set({
15
+ location: ['database', 'runtime'],
16
+ kind: ['user'],
17
+ registered: ['registered'],
18
+ }),
19
+ Schema.optional,
20
+ ),
21
+ });
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * as Masonry from './Masonry';
6
+ export * as MasonryAction from './MasonryAction';