@dxos/plugin-masonry 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe
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 +66 -43
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +60 -3
- package/dist/lib/browser/types/index.mjs.map +4 -4
- 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 +66 -43
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +60 -3
- package/dist/lib/node-esm/types/index.mjs.map +4 -4
- package/dist/types/src/MasonryPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/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/{components → containers/MasonryContainer}/MasonryContainer.d.ts +2 -2
- 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/translations.d.ts +20 -18
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Masonry.d.ts +1 -7
- package/dist/types/src/types/Masonry.d.ts.map +1 -1
- package/dist/types/src/types/MasonryAction.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +38 -28
- package/src/MasonryPlugin.tsx +29 -16
- package/src/capabilities/index.ts +3 -1
- package/src/capabilities/react-surface.tsx +32 -0
- package/src/components/index.ts +3 -0
- package/src/{components → containers/MasonryContainer}/MasonryContainer.stories.tsx +10 -10
- package/src/containers/MasonryContainer/MasonryContainer.tsx +124 -0
- package/src/containers/MasonryContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/meta.ts +1 -1
- package/src/translations.ts +12 -11
- package/src/types/Masonry.ts +10 -23
- package/src/types/MasonryAction.ts +0 -1
- package/dist/lib/browser/chunk-S5JKAK4O.mjs +0 -78
- package/dist/lib/browser/chunk-S5JKAK4O.mjs.map +0 -7
- package/dist/lib/browser/chunk-U46AGJ2D.mjs +0 -19
- package/dist/lib/browser/chunk-U46AGJ2D.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UCYEF4QU.mjs +0 -94
- package/dist/lib/browser/react-surface-UCYEF4QU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-P6EZJITS.mjs +0 -21
- package/dist/lib/node-esm/chunk-P6EZJITS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YNA44I6R.mjs +0 -79
- package/dist/lib/node-esm/chunk-YNA44I6R.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-LG7FTGYA.mjs +0 -95
- package/dist/lib/node-esm/react-surface-LG7FTGYA.mjs.map +0 -7
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- 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/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -31
- package/src/components/MasonryContainer.tsx +0 -79
- /package/dist/types/src/{components → containers/MasonryContainer}/MasonryContainer.stories.d.ts +0 -0
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-U46AGJ2D.mjs";
|
|
4
|
-
import {
|
|
5
|
-
Masonry_exports
|
|
6
|
-
} from "./chunk-S5JKAK4O.mjs";
|
|
7
|
-
|
|
8
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
9
|
-
import * as Effect from "effect/Effect";
|
|
10
|
-
import React2 from "react";
|
|
11
|
-
import { Capability, Common as Common2 } from "@dxos/app-framework";
|
|
12
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
13
|
-
import { View } from "@dxos/schema";
|
|
14
|
-
|
|
15
|
-
// src/components/MasonryContainer.tsx
|
|
16
|
-
import React, { useEffect, useState } from "react";
|
|
17
|
-
import { Common } from "@dxos/app-framework";
|
|
18
|
-
import { Surface, useCapabilities } from "@dxos/app-framework/react";
|
|
19
|
-
import { Filter, Obj, Type } from "@dxos/echo";
|
|
20
|
-
import { useGlobalFilteredObjects } from "@dxos/plugin-search";
|
|
21
|
-
import { useObject, useQuery } from "@dxos/react-client/echo";
|
|
22
|
-
import { Masonry as MasonryComponent } from "@dxos/react-ui-masonry";
|
|
23
|
-
import { Card } from "@dxos/react-ui-mosaic";
|
|
24
|
-
import { getTypenameFromQuery } from "@dxos/schema";
|
|
25
|
-
var MasonryContainer = ({ view: viewOrRef, role }) => {
|
|
26
|
-
const [view] = useObject(viewOrRef);
|
|
27
|
-
const schemas = useCapabilities(Common.Capability.Schema);
|
|
28
|
-
const db = view && Obj.getDatabase(view);
|
|
29
|
-
const typename = view?.query ? getTypenameFromQuery(view.query.ast) : void 0;
|
|
30
|
-
const [cardSchema, setCardSchema] = useState();
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
|
|
33
|
-
if (staticSchema) {
|
|
34
|
-
setCardSchema(() => staticSchema);
|
|
35
|
-
}
|
|
36
|
-
if (!staticSchema && typename && db) {
|
|
37
|
-
const query = db.schemaRegistry.query({
|
|
38
|
-
typename
|
|
39
|
-
});
|
|
40
|
-
const unsubscribe = query.subscribe(() => {
|
|
41
|
-
const [schema] = query.results;
|
|
42
|
-
if (schema) {
|
|
43
|
-
setCardSchema(schema);
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
fire: true
|
|
47
|
-
});
|
|
48
|
-
return unsubscribe;
|
|
49
|
-
}
|
|
50
|
-
}, [
|
|
51
|
-
schemas,
|
|
52
|
-
typename,
|
|
53
|
-
db
|
|
54
|
-
]);
|
|
55
|
-
const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
|
|
56
|
-
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
57
|
-
return /* @__PURE__ */ React.createElement(MasonryComponent.Root, {
|
|
58
|
-
items: filteredObjects,
|
|
59
|
-
render: Item,
|
|
60
|
-
classNames: "is-full max-is-full bs-full max-bs-full overflow-y-auto p-4"
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
var Item = ({ data }) => {
|
|
64
|
-
return /* @__PURE__ */ React.createElement(Card.Root, null, /* @__PURE__ */ React.createElement(Card.Toolbar, null, /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement(Card.Title, null, Obj.getLabel(data)), /* @__PURE__ */ React.createElement(Card.Menu, null)), /* @__PURE__ */ React.createElement(Surface, {
|
|
65
|
-
role: "card--content",
|
|
66
|
-
limit: 1,
|
|
67
|
-
data: {
|
|
68
|
-
subject: data
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
74
|
-
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Common2.Capability.ReactSurface, [
|
|
75
|
-
Common2.createSurface({
|
|
76
|
-
id: meta.id,
|
|
77
|
-
role: [
|
|
78
|
-
"article",
|
|
79
|
-
"section"
|
|
80
|
-
],
|
|
81
|
-
filter: (data) => Obj2.instanceOf(Masonry_exports.Masonry, data.subject) || Obj2.instanceOf(View.View, data.subject),
|
|
82
|
-
component: ({ data, role }) => {
|
|
83
|
-
const view = Obj2.instanceOf(View.View, data.subject) ? data.subject : data.subject.view;
|
|
84
|
-
return /* @__PURE__ */ React2.createElement(MasonryContainer, {
|
|
85
|
-
view,
|
|
86
|
-
role
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
])));
|
|
91
|
-
export {
|
|
92
|
-
react_surface_default as default
|
|
93
|
-
};
|
|
94
|
-
//# sourceMappingURL=react-surface-UCYEF4QU.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface/react-surface.tsx", "../../../src/components/MasonryContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { View } from '@dxos/schema';\n\nimport { MasonryContainer } from '../../components/MasonryContainer';\nimport { meta } from '../../meta';\nimport { Masonry } from '../../types';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Common.Capability.ReactSurface, [\n Common.createSurface({\n id: meta.id,\n role: ['article', 'section'],\n filter: (data): data is { subject: Masonry.Masonry | View.View } =>\n Obj.instanceOf(Masonry.Masonry, data.subject) || Obj.instanceOf(View.View, data.subject),\n component: ({ data, role }) => {\n const view = Obj.instanceOf(View.View, data.subject) ? data.subject : data.subject.view;\n return <MasonryContainer view={view} role={role} />;\n },\n }),\n ]),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { Common } from '@dxos/app-framework';\nimport { Surface, useCapabilities } from '@dxos/app-framework/react';\nimport { Filter, Obj, type Ref, Type } from '@dxos/echo';\nimport { useGlobalFilteredObjects } from '@dxos/plugin-search';\nimport { useObject, useQuery } from '@dxos/react-client/echo';\nimport { Masonry as MasonryComponent } from '@dxos/react-ui-masonry';\nimport { Card } from '@dxos/react-ui-mosaic';\nimport { type View, getTypenameFromQuery } from '@dxos/schema';\n\nexport type MasonryContainerProps = {\n view: View.View;\n role?: string;\n};\n\nexport const MasonryContainer = ({\n view: viewOrRef,\n role,\n}: {\n view: View.View | Ref.Ref<View.View>;\n role?: string;\n}) => {\n const [view] = useObject(viewOrRef);\n const schemas = useCapabilities(Common.Capability.Schema);\n const db = view && Obj.getDatabase(view);\n const typename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;\n\n const [cardSchema, setCardSchema] = useState<Schema.Schema.AnyNoContext>();\n\n useEffect(() => {\n const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);\n if (staticSchema) {\n setCardSchema(() => staticSchema);\n }\n if (!staticSchema && typename && db) {\n const query = db.schemaRegistry.query({ typename });\n const unsubscribe = query.subscribe(\n () => {\n const [schema] = query.results;\n if (schema) {\n setCardSchema(schema);\n }\n },\n { fire: true },\n );\n return unsubscribe;\n }\n }, [schemas, typename, db]);\n\n const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());\n const filteredObjects = useGlobalFilteredObjects(objects);\n\n return (\n <MasonryComponent.Root\n items={filteredObjects}\n render={Item as any}\n classNames='is-full max-is-full bs-full max-bs-full overflow-y-auto p-4'\n />\n );\n};\n\nconst Item = ({ data }: { data: any }) => {\n return (\n <Card.Root>\n <Card.Toolbar>\n <span />\n <Card.Title>{Obj.getLabel(data)}</Card.Title>\n <Card.Menu />\n </Card.Toolbar>\n <Surface role='card--content' limit={1} data={{ subject: data }} />\n </Card.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,YAAW;AAElB,SAASC,YAAYC,UAAAA,eAAc;AACnC,SAASC,OAAAA,YAAW;AACpB,SAASC,YAAY;;;ACJrB,OAAOC,SAASC,WAAWC,gBAAgB;AAE3C,SAASC,cAAc;AACvB,SAASC,SAASC,uBAAuB;AACzC,SAASC,QAAQC,KAAeC,YAAY;AAC5C,SAASC,gCAAgC;AACzC,SAASC,WAAWC,gBAAgB;AACpC,SAASC,WAAWC,wBAAwB;AAC5C,SAASC,YAAY;AACrB,SAAoBC,4BAA4B;AAOzC,IAAMC,mBAAmB,CAAC,EAC/BC,MAAMC,WACNC,KAAI,MAIL;AACC,QAAM,CAACF,IAAAA,IAAQG,UAAUF,SAAAA;AACzB,QAAMG,UAAUC,gBAAgBC,OAAOC,WAAWC,MAAM;AACxD,QAAMC,KAAKT,QAAQU,IAAIC,YAAYX,IAAAA;AACnC,QAAMY,WAAWZ,MAAMa,QAAQC,qBAAqBd,KAAKa,MAAME,GAAG,IAAIC;AAEtE,QAAM,CAACC,YAAYC,aAAAA,IAAiBC,SAAAA;AAEpCC,YAAU,MAAA;AACR,UAAMC,eAAejB,QAAQkB,KAAI,EAAGC,KAAK,CAACC,WAAWC,KAAKC,YAAYF,MAAAA,MAAYZ,QAAAA;AAClF,QAAIS,cAAc;AAChBH,oBAAc,MAAMG,YAAAA;IACtB;AACA,QAAI,CAACA,gBAAgBT,YAAYH,IAAI;AACnC,YAAMI,QAAQJ,GAAGkB,eAAed,MAAM;QAAED;MAAS,CAAA;AACjD,YAAMgB,cAAcf,MAAMgB,UACxB,MAAA;AACE,cAAM,CAACL,MAAAA,IAAUX,MAAMiB;AACvB,YAAIN,QAAQ;AACVN,wBAAcM,MAAAA;QAChB;MACF,GACA;QAAEO,MAAM;MAAK,CAAA;AAEf,aAAOH;IACT;EACF,GAAG;IAACxB;IAASQ;IAAUH;GAAG;AAE1B,QAAMuB,UAAUC,SAASxB,IAAIQ,aAAaiB,OAAOC,KAAKlB,UAAAA,IAAciB,OAAOE,QAAO,CAAA;AAClF,QAAMC,kBAAkBC,yBAAyBN,OAAAA;AAEjD,SACE,sBAAA,cAACO,iBAAiBC,MAAI;IACpBC,OAAOJ;IACPK,QAAQC;IACRC,YAAW;;AAGjB;AAEA,IAAMD,OAAO,CAAC,EAAEE,KAAI,MAAiB;AACnC,SACE,sBAAA,cAACC,KAAKN,MAAI,MACR,sBAAA,cAACM,KAAKC,SAAO,MACX,sBAAA,cAACC,QAAAA,IAAAA,GACD,sBAAA,cAACF,KAAKG,OAAK,MAAEvC,IAAIwC,SAASL,IAAAA,CAAAA,GAC1B,sBAAA,cAACC,KAAKK,MAAI,IAAA,CAAA,GAEZ,sBAAA,cAACC,SAAAA;IAAQlD,MAAK;IAAgBmD,OAAO;IAAGR,MAAM;MAAES,SAAST;IAAK;;AAGpE;;;AD/DA,IAAA,wBAAeU,WAAWC,WAAW,MAC5BC,eACLF,WAAWG,YAAYC,QAAOJ,WAAWK,cAAc;EACrDD,QAAOE,cAAc;IACnBC,IAAIC,KAAKD;IACTE,MAAM;MAAC;MAAW;;IAClBC,QAAQ,CAACC,SACPC,KAAIC,WAAWC,gBAAQA,SAASH,KAAKI,OAAO,KAAKH,KAAIC,WAAWG,KAAKA,MAAML,KAAKI,OAAO;IACzFE,WAAW,CAAC,EAAEN,MAAMF,KAAI,MAAE;AACxB,YAAMS,OAAON,KAAIC,WAAWG,KAAKA,MAAML,KAAKI,OAAO,IAAIJ,KAAKI,UAAUJ,KAAKI,QAAQG;AACnF,aAAO,gBAAAC,OAAA,cAACC,kBAAAA;QAAiBF;QAAYT;;IACvC;EACF,CAAA;CACD,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "React", "Capability", "Common", "Obj", "View", "React", "useEffect", "useState", "Common", "Surface", "useCapabilities", "Filter", "Obj", "Type", "useGlobalFilteredObjects", "useObject", "useQuery", "Masonry", "MasonryComponent", "Card", "getTypenameFromQuery", "MasonryContainer", "view", "viewOrRef", "role", "useObject", "schemas", "useCapabilities", "Common", "Capability", "Schema", "db", "Obj", "getDatabase", "typename", "query", "getTypenameFromQuery", "ast", "undefined", "cardSchema", "setCardSchema", "useState", "useEffect", "staticSchema", "flat", "find", "schema", "Type", "getTypename", "schemaRegistry", "unsubscribe", "subscribe", "results", "fire", "objects", "useQuery", "Filter", "type", "nothing", "filteredObjects", "useGlobalFilteredObjects", "MasonryComponent", "Root", "items", "render", "Item", "classNames", "data", "Card", "Toolbar", "span", "Title", "getLabel", "Menu", "Surface", "limit", "subject", "Capability", "makeModule", "succeed", "contributes", "Common", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Masonry", "subject", "View", "component", "view", "React", "MasonryContainer"]
|
|
7
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/meta.ts
|
|
4
|
-
import { trim } from "@dxos/util";
|
|
5
|
-
var meta = {
|
|
6
|
-
id: "dxos.org/plugin/masonry",
|
|
7
|
-
name: "Masonry",
|
|
8
|
-
description: trim`
|
|
9
|
-
Responsive grid layout that displays query results in an adaptive masonry pattern.
|
|
10
|
-
Visualize collections of cards, images, or mixed content that automatically adjusts to available screen space.
|
|
11
|
-
`,
|
|
12
|
-
icon: "ph--wall--regular",
|
|
13
|
-
iconHue: "green",
|
|
14
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-masonry",
|
|
15
|
-
screenshots: []
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
meta
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=chunk-P6EZJITS.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\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": ";;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,aAAa,CAAA;AACf;",
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source", "screenshots"]
|
|
7
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __export = (target, all) => {
|
|
4
|
-
for (var name in all)
|
|
5
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// src/types/Masonry.ts
|
|
9
|
-
var Masonry_exports = {};
|
|
10
|
-
__export(Masonry_exports, {
|
|
11
|
-
Masonry: () => Masonry,
|
|
12
|
-
MasonryV1: () => MasonryV1,
|
|
13
|
-
make: () => make
|
|
14
|
-
});
|
|
15
|
-
import * as Schema from "effect/Schema";
|
|
16
|
-
import { Obj, Ref, Type } from "@dxos/echo";
|
|
17
|
-
import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/internal";
|
|
18
|
-
import { View, ViewAnnotation } from "@dxos/schema";
|
|
19
|
-
var Masonry = Schema.Struct({
|
|
20
|
-
name: Schema.String.pipe(Schema.optional),
|
|
21
|
-
view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
22
|
-
arrangement: Schema.Array(Schema.Struct({
|
|
23
|
-
ids: Schema.Array(Obj.ID),
|
|
24
|
-
hidden: Schema.optional(Schema.Boolean)
|
|
25
|
-
})).pipe(FormInputAnnotation.set(false), Schema.optional)
|
|
26
|
-
}).pipe(Type.object({
|
|
27
|
-
typename: "dxos.org/type/Masonry",
|
|
28
|
-
version: "0.2.0"
|
|
29
|
-
}), LabelAnnotation.set([
|
|
30
|
-
"name"
|
|
31
|
-
]), ViewAnnotation.set(true));
|
|
32
|
-
var make = ({ name, arrangement = [], view }) => {
|
|
33
|
-
return Obj.make(Masonry, {
|
|
34
|
-
name,
|
|
35
|
-
view: Ref.make(view),
|
|
36
|
-
arrangement
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
var MasonryV1 = Schema.Struct({
|
|
40
|
-
arrangement: Schema.Array(Schema.Struct({
|
|
41
|
-
ids: Schema.Array(Obj.ID),
|
|
42
|
-
hidden: Schema.optional(Schema.Boolean)
|
|
43
|
-
})).pipe(Schema.optional)
|
|
44
|
-
}).pipe(Type.object({
|
|
45
|
-
typename: "dxos.org/type/Masonry",
|
|
46
|
-
version: "0.1.0"
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
// src/types/MasonryAction.ts
|
|
50
|
-
var MasonryAction_exports = {};
|
|
51
|
-
__export(MasonryAction_exports, {
|
|
52
|
-
MasonryProps: () => MasonryProps
|
|
53
|
-
});
|
|
54
|
-
import * as Schema2 from "effect/Schema";
|
|
55
|
-
import { TypeInputOptionsAnnotation } from "@dxos/plugin-space/types";
|
|
56
|
-
var MasonryProps = Schema2.Struct({
|
|
57
|
-
name: Schema2.optional(Schema2.String),
|
|
58
|
-
// TODO(wittjosiah): This should be a query input instead.
|
|
59
|
-
typename: Schema2.String.pipe(Schema2.annotations({
|
|
60
|
-
title: "Select card type"
|
|
61
|
-
}), TypeInputOptionsAnnotation.set({
|
|
62
|
-
location: [
|
|
63
|
-
"database",
|
|
64
|
-
"runtime"
|
|
65
|
-
],
|
|
66
|
-
kind: [
|
|
67
|
-
"user"
|
|
68
|
-
],
|
|
69
|
-
registered: [
|
|
70
|
-
"registered"
|
|
71
|
-
]
|
|
72
|
-
}), Schema2.optional)
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
Masonry_exports,
|
|
77
|
-
MasonryAction_exports
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=chunk-YNA44I6R.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/Masonry.ts", "../../../src/types/MasonryAction.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\nexport const Masonry = 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 }),\n ).pipe(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.object({\n typename: 'dxos.org/type/Masonry',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\n);\n\nexport interface Masonry extends Schema.Schema.Type<typeof Masonry> {}\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 }),\n ).pipe(Schema.optional),\n}).pipe(\n Type.object({\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';\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"],
|
|
5
|
-
"mappings": ";;;;;;;;AAAA;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,KAAKC,KAAKC,YAAY;AAC/B,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,MAAMC,sBAAsB;AAE9B,IAAMC,UAAiBC,cAAO;EACnCC,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,CAAA,EACAd,KAAKM,oBAAoBC,IAAI,KAAA,GAAeN,eAAQ;AAExD,CAAA,EAAGD,KACDG,KAAKY,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBX,IAAI;EAAC;CAAO,GAC5BY,eAAeZ,IAAI,IAAA,CAAA;AAYd,IAAMa,OAAO,CAAC,EAAEtB,MAAMU,cAAc,CAAA,GAAIN,KAAI,MAAa;AAC9D,SAAOS,IAAIS,KAAKxB,SAAS;IAAEE;IAAMI,MAAME,IAAIgB,KAAKlB,IAAAA;IAAOM;EAAY,CAAA;AACrE;AAMO,IAAMa,YAAmBxB,cAAO;EACrCW,aAAoBC,aACXZ,cAAO;IACZa,KAAYD,aAAME,IAAIC,EAAE;IACxBC,QAAeZ,gBAAgBa,cAAO;EACxC,CAAA,CAAA,EACAd,KAAYC,eAAQ;AACxB,CAAA,EAAGD,KACDG,KAAKY,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;;;AC3DF;;;;AAIA,YAAYK,aAAY;AAExB,SAASC,kCAAkC;AAEpC,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;",
|
|
6
|
-
"names": ["Schema", "Obj", "Ref", "Type", "FormInputAnnotation", "LabelAnnotation", "View", "ViewAnnotation", "Masonry", "Struct", "name", "String", "pipe", "optional", "view", "Type", "Ref", "View", "FormInputAnnotation", "set", "arrangement", "Array", "ids", "Obj", "ID", "hidden", "Boolean", "object", "typename", "version", "LabelAnnotation", "ViewAnnotation", "make", "MasonryV1", "Schema", "TypeInputOptionsAnnotation", "MasonryProps", "Struct", "name", "optional", "String", "typename", "pipe", "annotations", "title", "TypeInputOptionsAnnotation", "set", "location", "kind", "registered"]
|
|
7
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
meta
|
|
4
|
-
} from "./chunk-P6EZJITS.mjs";
|
|
5
|
-
import {
|
|
6
|
-
Masonry_exports
|
|
7
|
-
} from "./chunk-YNA44I6R.mjs";
|
|
8
|
-
|
|
9
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
10
|
-
import * as Effect from "effect/Effect";
|
|
11
|
-
import React2 from "react";
|
|
12
|
-
import { Capability, Common as Common2 } from "@dxos/app-framework";
|
|
13
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
14
|
-
import { View } from "@dxos/schema";
|
|
15
|
-
|
|
16
|
-
// src/components/MasonryContainer.tsx
|
|
17
|
-
import React, { useEffect, useState } from "react";
|
|
18
|
-
import { Common } from "@dxos/app-framework";
|
|
19
|
-
import { Surface, useCapabilities } from "@dxos/app-framework/react";
|
|
20
|
-
import { Filter, Obj, Type } from "@dxos/echo";
|
|
21
|
-
import { useGlobalFilteredObjects } from "@dxos/plugin-search";
|
|
22
|
-
import { useObject, useQuery } from "@dxos/react-client/echo";
|
|
23
|
-
import { Masonry as MasonryComponent } from "@dxos/react-ui-masonry";
|
|
24
|
-
import { Card } from "@dxos/react-ui-mosaic";
|
|
25
|
-
import { getTypenameFromQuery } from "@dxos/schema";
|
|
26
|
-
var MasonryContainer = ({ view: viewOrRef, role }) => {
|
|
27
|
-
const [view] = useObject(viewOrRef);
|
|
28
|
-
const schemas = useCapabilities(Common.Capability.Schema);
|
|
29
|
-
const db = view && Obj.getDatabase(view);
|
|
30
|
-
const typename = view?.query ? getTypenameFromQuery(view.query.ast) : void 0;
|
|
31
|
-
const [cardSchema, setCardSchema] = useState();
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
|
|
34
|
-
if (staticSchema) {
|
|
35
|
-
setCardSchema(() => staticSchema);
|
|
36
|
-
}
|
|
37
|
-
if (!staticSchema && typename && db) {
|
|
38
|
-
const query = db.schemaRegistry.query({
|
|
39
|
-
typename
|
|
40
|
-
});
|
|
41
|
-
const unsubscribe = query.subscribe(() => {
|
|
42
|
-
const [schema] = query.results;
|
|
43
|
-
if (schema) {
|
|
44
|
-
setCardSchema(schema);
|
|
45
|
-
}
|
|
46
|
-
}, {
|
|
47
|
-
fire: true
|
|
48
|
-
});
|
|
49
|
-
return unsubscribe;
|
|
50
|
-
}
|
|
51
|
-
}, [
|
|
52
|
-
schemas,
|
|
53
|
-
typename,
|
|
54
|
-
db
|
|
55
|
-
]);
|
|
56
|
-
const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
|
|
57
|
-
const filteredObjects = useGlobalFilteredObjects(objects);
|
|
58
|
-
return /* @__PURE__ */ React.createElement(MasonryComponent.Root, {
|
|
59
|
-
items: filteredObjects,
|
|
60
|
-
render: Item,
|
|
61
|
-
classNames: "is-full max-is-full bs-full max-bs-full overflow-y-auto p-4"
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
var Item = ({ data }) => {
|
|
65
|
-
return /* @__PURE__ */ React.createElement(Card.Root, null, /* @__PURE__ */ React.createElement(Card.Toolbar, null, /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement(Card.Title, null, Obj.getLabel(data)), /* @__PURE__ */ React.createElement(Card.Menu, null)), /* @__PURE__ */ React.createElement(Surface, {
|
|
66
|
-
role: "card--content",
|
|
67
|
-
limit: 1,
|
|
68
|
-
data: {
|
|
69
|
-
subject: data
|
|
70
|
-
}
|
|
71
|
-
}));
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
75
|
-
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Common2.Capability.ReactSurface, [
|
|
76
|
-
Common2.createSurface({
|
|
77
|
-
id: meta.id,
|
|
78
|
-
role: [
|
|
79
|
-
"article",
|
|
80
|
-
"section"
|
|
81
|
-
],
|
|
82
|
-
filter: (data) => Obj2.instanceOf(Masonry_exports.Masonry, data.subject) || Obj2.instanceOf(View.View, data.subject),
|
|
83
|
-
component: ({ data, role }) => {
|
|
84
|
-
const view = Obj2.instanceOf(View.View, data.subject) ? data.subject : data.subject.view;
|
|
85
|
-
return /* @__PURE__ */ React2.createElement(MasonryContainer, {
|
|
86
|
-
view,
|
|
87
|
-
role
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
])));
|
|
92
|
-
export {
|
|
93
|
-
react_surface_default as default
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=react-surface-LG7FTGYA.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface/react-surface.tsx", "../../../src/components/MasonryContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { View } from '@dxos/schema';\n\nimport { MasonryContainer } from '../../components/MasonryContainer';\nimport { meta } from '../../meta';\nimport { Masonry } from '../../types';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Common.Capability.ReactSurface, [\n Common.createSurface({\n id: meta.id,\n role: ['article', 'section'],\n filter: (data): data is { subject: Masonry.Masonry | View.View } =>\n Obj.instanceOf(Masonry.Masonry, data.subject) || Obj.instanceOf(View.View, data.subject),\n component: ({ data, role }) => {\n const view = Obj.instanceOf(View.View, data.subject) ? data.subject : data.subject.view;\n return <MasonryContainer view={view} role={role} />;\n },\n }),\n ]),\n ),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { Common } from '@dxos/app-framework';\nimport { Surface, useCapabilities } from '@dxos/app-framework/react';\nimport { Filter, Obj, type Ref, Type } from '@dxos/echo';\nimport { useGlobalFilteredObjects } from '@dxos/plugin-search';\nimport { useObject, useQuery } from '@dxos/react-client/echo';\nimport { Masonry as MasonryComponent } from '@dxos/react-ui-masonry';\nimport { Card } from '@dxos/react-ui-mosaic';\nimport { type View, getTypenameFromQuery } from '@dxos/schema';\n\nexport type MasonryContainerProps = {\n view: View.View;\n role?: string;\n};\n\nexport const MasonryContainer = ({\n view: viewOrRef,\n role,\n}: {\n view: View.View | Ref.Ref<View.View>;\n role?: string;\n}) => {\n const [view] = useObject(viewOrRef);\n const schemas = useCapabilities(Common.Capability.Schema);\n const db = view && Obj.getDatabase(view);\n const typename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;\n\n const [cardSchema, setCardSchema] = useState<Schema.Schema.AnyNoContext>();\n\n useEffect(() => {\n const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);\n if (staticSchema) {\n setCardSchema(() => staticSchema);\n }\n if (!staticSchema && typename && db) {\n const query = db.schemaRegistry.query({ typename });\n const unsubscribe = query.subscribe(\n () => {\n const [schema] = query.results;\n if (schema) {\n setCardSchema(schema);\n }\n },\n { fire: true },\n );\n return unsubscribe;\n }\n }, [schemas, typename, db]);\n\n const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());\n const filteredObjects = useGlobalFilteredObjects(objects);\n\n return (\n <MasonryComponent.Root\n items={filteredObjects}\n render={Item as any}\n classNames='is-full max-is-full bs-full max-bs-full overflow-y-auto p-4'\n />\n );\n};\n\nconst Item = ({ data }: { data: any }) => {\n return (\n <Card.Root>\n <Card.Toolbar>\n <span />\n <Card.Title>{Obj.getLabel(data)}</Card.Title>\n <Card.Menu />\n </Card.Toolbar>\n <Surface role='card--content' limit={1} data={{ subject: data }} />\n </Card.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,YAAW;AAElB,SAASC,YAAYC,UAAAA,eAAc;AACnC,SAASC,OAAAA,YAAW;AACpB,SAASC,YAAY;;;ACJrB,OAAOC,SAASC,WAAWC,gBAAgB;AAE3C,SAASC,cAAc;AACvB,SAASC,SAASC,uBAAuB;AACzC,SAASC,QAAQC,KAAeC,YAAY;AAC5C,SAASC,gCAAgC;AACzC,SAASC,WAAWC,gBAAgB;AACpC,SAASC,WAAWC,wBAAwB;AAC5C,SAASC,YAAY;AACrB,SAAoBC,4BAA4B;AAOzC,IAAMC,mBAAmB,CAAC,EAC/BC,MAAMC,WACNC,KAAI,MAIL;AACC,QAAM,CAACF,IAAAA,IAAQG,UAAUF,SAAAA;AACzB,QAAMG,UAAUC,gBAAgBC,OAAOC,WAAWC,MAAM;AACxD,QAAMC,KAAKT,QAAQU,IAAIC,YAAYX,IAAAA;AACnC,QAAMY,WAAWZ,MAAMa,QAAQC,qBAAqBd,KAAKa,MAAME,GAAG,IAAIC;AAEtE,QAAM,CAACC,YAAYC,aAAAA,IAAiBC,SAAAA;AAEpCC,YAAU,MAAA;AACR,UAAMC,eAAejB,QAAQkB,KAAI,EAAGC,KAAK,CAACC,WAAWC,KAAKC,YAAYF,MAAAA,MAAYZ,QAAAA;AAClF,QAAIS,cAAc;AAChBH,oBAAc,MAAMG,YAAAA;IACtB;AACA,QAAI,CAACA,gBAAgBT,YAAYH,IAAI;AACnC,YAAMI,QAAQJ,GAAGkB,eAAed,MAAM;QAAED;MAAS,CAAA;AACjD,YAAMgB,cAAcf,MAAMgB,UACxB,MAAA;AACE,cAAM,CAACL,MAAAA,IAAUX,MAAMiB;AACvB,YAAIN,QAAQ;AACVN,wBAAcM,MAAAA;QAChB;MACF,GACA;QAAEO,MAAM;MAAK,CAAA;AAEf,aAAOH;IACT;EACF,GAAG;IAACxB;IAASQ;IAAUH;GAAG;AAE1B,QAAMuB,UAAUC,SAASxB,IAAIQ,aAAaiB,OAAOC,KAAKlB,UAAAA,IAAciB,OAAOE,QAAO,CAAA;AAClF,QAAMC,kBAAkBC,yBAAyBN,OAAAA;AAEjD,SACE,sBAAA,cAACO,iBAAiBC,MAAI;IACpBC,OAAOJ;IACPK,QAAQC;IACRC,YAAW;;AAGjB;AAEA,IAAMD,OAAO,CAAC,EAAEE,KAAI,MAAiB;AACnC,SACE,sBAAA,cAACC,KAAKN,MAAI,MACR,sBAAA,cAACM,KAAKC,SAAO,MACX,sBAAA,cAACC,QAAAA,IAAAA,GACD,sBAAA,cAACF,KAAKG,OAAK,MAAEvC,IAAIwC,SAASL,IAAAA,CAAAA,GAC1B,sBAAA,cAACC,KAAKK,MAAI,IAAA,CAAA,GAEZ,sBAAA,cAACC,SAAAA;IAAQlD,MAAK;IAAgBmD,OAAO;IAAGR,MAAM;MAAES,SAAST;IAAK;;AAGpE;;;AD/DA,IAAA,wBAAeU,WAAWC,WAAW,MAC5BC,eACLF,WAAWG,YAAYC,QAAOJ,WAAWK,cAAc;EACrDD,QAAOE,cAAc;IACnBC,IAAIC,KAAKD;IACTE,MAAM;MAAC;MAAW;;IAClBC,QAAQ,CAACC,SACPC,KAAIC,WAAWC,gBAAQA,SAASH,KAAKI,OAAO,KAAKH,KAAIC,WAAWG,KAAKA,MAAML,KAAKI,OAAO;IACzFE,WAAW,CAAC,EAAEN,MAAMF,KAAI,MAAE;AACxB,YAAMS,OAAON,KAAIC,WAAWG,KAAKA,MAAML,KAAKI,OAAO,IAAIJ,KAAKI,UAAUJ,KAAKI,QAAQG;AACnF,aAAO,gBAAAC,OAAA,cAACC,kBAAAA;QAAiBF;QAAYT;;IACvC;EACF,CAAA;CACD,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "React", "Capability", "Common", "Obj", "View", "React", "useEffect", "useState", "Common", "Surface", "useCapabilities", "Filter", "Obj", "Type", "useGlobalFilteredObjects", "useObject", "useQuery", "Masonry", "MasonryComponent", "Card", "getTypenameFromQuery", "MasonryContainer", "view", "viewOrRef", "role", "useObject", "schemas", "useCapabilities", "Common", "Capability", "Schema", "db", "Obj", "getDatabase", "typename", "query", "getTypenameFromQuery", "ast", "undefined", "cardSchema", "setCardSchema", "useState", "useEffect", "staticSchema", "flat", "find", "schema", "Type", "getTypename", "schemaRegistry", "unsubscribe", "subscribe", "results", "fire", "objects", "useQuery", "Filter", "type", "nothing", "filteredObjects", "useGlobalFilteredObjects", "MasonryComponent", "Root", "items", "render", "Item", "classNames", "data", "Card", "Toolbar", "span", "Title", "getLabel", "Menu", "Surface", "limit", "subject", "Capability", "makeModule", "succeed", "contributes", "Common", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Masonry", "subject", "View", "component", "view", "React", "MasonryContainer"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/react-surface/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,YAAY,sJAAmE,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { Capability, Common } from '@dxos/app-framework';
|
|
3
|
-
declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<Common.Capability.ReactSurface>>, never, never>;
|
|
4
|
-
export default _default;
|
|
5
|
-
//# sourceMappingURL=react-surface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/react-surface/react-surface.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;;AAQzD,wBAeE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MasonryContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/MasonryContainer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,EAAe,KAAK,GAAG,EAAQ,MAAM,YAAY,CAAC;AAKzD,OAAO,EAAE,KAAK,IAAI,EAAwB,MAAM,cAAc,CAAC;AAE/D,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,4BAG9B;IACD,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,sBAsCA,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MasonryContainer.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/MasonryContainer.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,MAAM,OAAO,CAAC;AA4B1B,QAAA,MAAM,IAAI;;;;;;;;CAqCM,CAAC;AAEjB,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
);
|
|
@@ -1,79 +0,0 @@
|
|
|
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/dist/types/src/{components → containers/MasonryContainer}/MasonryContainer.stories.d.ts
RENAMED
|
File without changes
|