@dxos/plugin-masonry 0.8.4-main.ead640a → 0.8.4-main.fcc0d83b33
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-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +62 -78
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +30 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +68 -0
- package/dist/lib/browser/types/index.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/index.mjs +62 -78
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +31 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +69 -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 +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- 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 +2 -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 +22 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Masonry.d.ts +17 -22
- 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 +61 -32
- package/src/MasonryPlugin.tsx +42 -55
- package/src/capabilities/index.ts +2 -3
- package/src/capabilities/react-surface.tsx +25 -16
- package/src/components/index.ts +3 -0
- package/src/containers/MasonryContainer/MasonryContainer.stories.tsx +78 -0
- package/src/containers/MasonryContainer/MasonryContainer.tsx +130 -0
- package/src/containers/MasonryContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/meta.ts +9 -4
- package/src/translations.ts +14 -9
- package/src/types/Masonry.ts +27 -29
- package/src/types/MasonryAction.ts +8 -17
- package/dist/lib/browser/chunk-VRZWIUS7.mjs +0 -87
- package/dist/lib/browser/chunk-VRZWIUS7.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YK7KRGIJ.mjs +0 -31
- package/dist/lib/browser/intent-resolver-YK7KRGIJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-R2TDTTUL.mjs +0 -112
- package/dist/lib/browser/react-surface-R2TDTTUL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Z4PPM6OA.mjs +0 -88
- package/dist/lib/node-esm/chunk-Z4PPM6OA.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-VVQIEZTT.mjs +0 -32
- package/dist/lib/node-esm/intent-resolver-VVQIEZTT.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-YTC42VZ3.mjs +0 -113
- package/dist/lib/node-esm/react-surface-YTC42VZ3.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/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/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 { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';
|
|
6
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
7
|
-
|
|
8
|
-
import { Masonry, MasonryAction } from '../types';
|
|
9
|
-
|
|
10
|
-
export default (context: PluginContext) =>
|
|
11
|
-
contributes(Capabilities.IntentResolver, [
|
|
12
|
-
createResolver({
|
|
13
|
-
intent: MasonryAction.CreateMasonry,
|
|
14
|
-
resolve: async ({ space, name, typename }) => {
|
|
15
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
16
|
-
const { view } = await Masonry.makeView({
|
|
17
|
-
client,
|
|
18
|
-
space,
|
|
19
|
-
name,
|
|
20
|
-
typename,
|
|
21
|
-
});
|
|
22
|
-
return { data: { object: view } };
|
|
23
|
-
},
|
|
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
|