@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
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
import { DataType } from '@dxos/schema';
|
|
10
|
-
|
|
11
|
-
import { MasonryContainer } from '../components/MasonryContainer';
|
|
12
|
-
import { meta } from '../meta';
|
|
13
|
-
import { Masonry } from '../types';
|
|
14
|
-
|
|
15
|
-
export default () =>
|
|
16
|
-
contributes(Capabilities.ReactSurface, [
|
|
17
|
-
createSurface({
|
|
18
|
-
id: meta.id,
|
|
19
|
-
role: ['article', 'section'],
|
|
20
|
-
filter: (data): data is { subject: DataType.View } =>
|
|
21
|
-
Obj.instanceOf(DataType.View, data.subject) &&
|
|
22
|
-
Obj.instanceOf(Masonry.Masonry, data.subject.presentation?.target),
|
|
23
|
-
component: ({ data, role }) => <MasonryContainer view={data.subject} role={role} />,
|
|
24
|
-
}),
|
|
25
|
-
]);
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import React, { useEffect, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
|
|
9
|
-
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
-
import { ClientPlugin } from '@dxos/plugin-client';
|
|
11
|
-
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
12
|
-
import { SpacePlugin } from '@dxos/plugin-space';
|
|
13
|
-
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
14
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
15
|
-
import { faker } from '@dxos/random';
|
|
16
|
-
import { Filter, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
17
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
18
|
-
import { defaultTx } from '@dxos/react-ui-theme';
|
|
19
|
-
import { DataType } from '@dxos/schema';
|
|
20
|
-
import { createObjectFactory } from '@dxos/schema/testing';
|
|
21
|
-
|
|
22
|
-
import { Masonry } from '../types';
|
|
23
|
-
|
|
24
|
-
import { MasonryContainer } from './MasonryContainer';
|
|
25
|
-
|
|
26
|
-
faker.seed(0);
|
|
27
|
-
|
|
28
|
-
const StorybookMasonry = () => {
|
|
29
|
-
const spaces = useSpaces();
|
|
30
|
-
const space = spaces[spaces.length - 1];
|
|
31
|
-
const views = useQuery(space, Filter.type(DataType.View));
|
|
32
|
-
const [view, setView] = useState<DataType.View>();
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (views.length && !view) {
|
|
35
|
-
const view = views[0];
|
|
36
|
-
setView(view);
|
|
37
|
-
}
|
|
38
|
-
}, [views]);
|
|
39
|
-
|
|
40
|
-
return view ? <MasonryContainer view={view} role='story' /> : null;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const meta = {
|
|
44
|
-
title: 'plugins/plugin-masonry/Masonry',
|
|
45
|
-
component: StorybookMasonry,
|
|
46
|
-
render: () => <StorybookMasonry />,
|
|
47
|
-
decorators: [
|
|
48
|
-
withTheme,
|
|
49
|
-
withPluginManager({
|
|
50
|
-
plugins: [
|
|
51
|
-
ClientPlugin({
|
|
52
|
-
types: [DataType.Organization, DataType.View, Masonry.Masonry],
|
|
53
|
-
onClientInitialized: async ({ client }) => {
|
|
54
|
-
await client.halo.createIdentity();
|
|
55
|
-
const space = await client.spaces.create();
|
|
56
|
-
await space.waitUntilReady();
|
|
57
|
-
|
|
58
|
-
const { view } = await Masonry.makeView({ space, client, typename: DataType.Organization.typename });
|
|
59
|
-
space.db.add(view);
|
|
60
|
-
|
|
61
|
-
const factory = createObjectFactory(space.db, faker as any);
|
|
62
|
-
await factory([{ type: DataType.Organization, count: 64 }]);
|
|
63
|
-
},
|
|
64
|
-
}),
|
|
65
|
-
SpacePlugin({}),
|
|
66
|
-
IntentPlugin(),
|
|
67
|
-
SettingsPlugin(),
|
|
68
|
-
ThemePlugin({ tx: defaultTx }),
|
|
69
|
-
PreviewPlugin(),
|
|
70
|
-
StorybookLayoutPlugin({}),
|
|
71
|
-
],
|
|
72
|
-
}),
|
|
73
|
-
],
|
|
74
|
-
parameters: {
|
|
75
|
-
layout: 'fullscreen',
|
|
76
|
-
},
|
|
77
|
-
} satisfies Meta;
|
|
78
|
-
|
|
79
|
-
export default meta;
|
|
80
|
-
|
|
81
|
-
type Story = StoryObj<typeof meta>;
|
|
82
|
-
|
|
83
|
-
export const Default: Story = {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Surface } from '@dxos/app-framework';
|
|
8
|
-
import { Filter, Type } from '@dxos/echo';
|
|
9
|
-
import { EchoSchema, type TypedObject } from '@dxos/echo/internal';
|
|
10
|
-
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
11
|
-
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import { getSpace, useQuery } from '@dxos/react-client/echo';
|
|
13
|
-
import { Masonry } from '@dxos/react-ui-masonry';
|
|
14
|
-
import { type DataType, ProjectionModel, getTypenameFromQuery } from '@dxos/schema';
|
|
15
|
-
|
|
16
|
-
const Item = ({ data }: { data: any }) => {
|
|
17
|
-
return <Surface role='card' limit={1} data={{ subject: data }} />;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const MasonryContainer = ({ view, role }: { view: DataType.View; role: string }) => {
|
|
21
|
-
const client = useClient();
|
|
22
|
-
const space = getSpace(view);
|
|
23
|
-
const typename = view.query ? getTypenameFromQuery(view.query.ast) : undefined;
|
|
24
|
-
|
|
25
|
-
const [cardSchema, setCardSchema] = useState<TypedObject<any, any>>();
|
|
26
|
-
const [projection, setProjection] = useState<ProjectionModel>();
|
|
27
|
-
|
|
28
|
-
const jsonSchema = useMemo(() => {
|
|
29
|
-
if (!cardSchema) return undefined;
|
|
30
|
-
return cardSchema instanceof EchoSchema ? cardSchema.jsonSchema : Type.toJsonSchema(cardSchema);
|
|
31
|
-
}, [cardSchema]);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const staticSchema = client.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
|
|
35
|
-
if (staticSchema) {
|
|
36
|
-
setCardSchema(() => staticSchema as TypedObject<any, any>);
|
|
37
|
-
}
|
|
38
|
-
if (!staticSchema && typename && space) {
|
|
39
|
-
const query = space.db.schemaRegistry.query({ typename });
|
|
40
|
-
const unsubscribe = query.subscribe(
|
|
41
|
-
() => {
|
|
42
|
-
const [schema] = query.results;
|
|
43
|
-
if (schema) {
|
|
44
|
-
setCardSchema(schema);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
{ fire: true },
|
|
48
|
-
);
|
|
49
|
-
return unsubscribe;
|
|
50
|
-
}
|
|
51
|
-
}, [typename, space]);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (jsonSchema) {
|
|
55
|
-
setProjection(new ProjectionModel(jsonSchema, view.projection));
|
|
56
|
-
}
|
|
57
|
-
}, [view.projection, JSON.stringify(jsonSchema)]);
|
|
58
|
-
|
|
59
|
-
const objects = useQuery(space, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
|
|
60
|
-
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<Masonry.Root
|
|
64
|
-
items={filteredObjects}
|
|
65
|
-
render={Item as any}
|
|
66
|
-
classNames='is-full max-is-full bs-full max-bs-full overflow-y-auto p-4'
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
69
|
-
};
|
/package/dist/types/src/{components → containers/MasonryContainer}/MasonryContainer.stories.d.ts
RENAMED
|
File without changes
|