@dxos/plugin-stack 0.8.4-main.8360d9e660 → 0.8.4-main.8baae0fced
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/StackArticle-3FE52PUH.mjs +126 -0
- package/dist/lib/neutral/StackArticle-3FE52PUH.mjs.map +7 -0
- package/dist/lib/neutral/StackPlugin.mjs +22 -0
- package/dist/lib/neutral/StackPlugin.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +7 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/{browser/chunk-YPQYUBQP.mjs → neutral/chunk-IPU3C6TT.mjs} +2 -2
- package/dist/lib/{browser/chunk-YPQYUBQP.mjs.map → neutral/chunk-IPU3C6TT.mjs.map} +3 -3
- package/dist/lib/{browser/chunk-G4CLPE5A.mjs → neutral/chunk-LAZU5N5N.mjs} +3 -2
- package/dist/lib/neutral/chunk-LAZU5N5N.mjs.map +7 -0
- package/dist/lib/{browser/StackContainer-RE6RUEUV.mjs → neutral/components/index.mjs} +34 -146
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +7 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +15 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +9 -0
- package/dist/lib/neutral/plugin.mjs +11 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-MD3CVY2N.mjs +23 -0
- package/dist/lib/neutral/react-surface-MD3CVY2N.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +37 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/types/index.mjs +1 -1
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/StackPlugin.d.ts +1 -0
- package/dist/types/src/StackPlugin.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.map +1 -0
- package/dist/types/src/components/StackContext/StackContext.d.ts +1 -1
- package/dist/types/src/components/StackContext/StackContext.d.ts.map +1 -1
- package/dist/types/src/components/StackSection/CaretDownUp.d.ts +1 -1
- package/dist/types/src/components/StackSection/CaretDownUp.d.ts.map +1 -1
- package/dist/types/src/components/StackSection/StackSection.d.ts +1 -1
- package/dist/types/src/components/StackSection/StackSection.d.ts.map +1 -1
- package/dist/types/src/components/StackSettings/StackSettings.d.ts +1 -1
- package/dist/types/src/components/StackSettings/StackSettings.d.ts.map +1 -1
- package/dist/types/src/containers/StackArticle/StackArticle.d.ts +7 -0
- package/dist/types/src/containers/StackArticle/StackArticle.d.ts.map +1 -0
- package/dist/types/src/containers/StackArticle/index.d.ts +2 -0
- package/dist/types/src/containers/StackArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +1 -1
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +30 -30
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +1 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +78 -44
- package/src/StackPlugin.ts +6 -22
- package/src/capabilities/index.ts +3 -1
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +5 -8
- package/src/components/StackContext/StackContext.tsx +1 -1
- package/src/components/StackSection/StackSection.tsx +17 -16
- package/src/components/StackSettings/StackSettings.tsx +13 -15
- package/src/containers/{StackContainer/StackContainer.tsx → StackArticle/StackArticle.tsx} +14 -16
- package/src/containers/StackArticle/index.ts +5 -0
- package/src/containers/index.ts +1 -1
- package/src/index.ts +1 -1
- package/src/meta.ts +2 -1
- package/src/plugin.ts +9 -0
- package/src/translations.ts +23 -22
- package/src/types/stack.ts +1 -1
- package/src/types/types.ts +1 -2
- package/dist/lib/browser/StackContainer-RE6RUEUV.mjs.map +0 -7
- package/dist/lib/browser/chunk-G4CLPE5A.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -84
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-FZ42XC67.mjs +0 -33
- package/dist/lib/browser/react-surface-FZ42XC67.mjs.map +0 -7
- package/dist/lib/node-esm/StackContainer-OPQ76B4H.mjs +0 -295
- package/dist/lib/node-esm/StackContainer-OPQ76B4H.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LELGTQAL.mjs +0 -29
- package/dist/lib/node-esm/chunk-LELGTQAL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LOZ6GH5A.mjs +0 -23
- package/dist/lib/node-esm/chunk-LOZ6GH5A.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -85
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-CYNJK3QD.mjs +0 -34
- package/dist/lib/node-esm/react-surface-CYNJK3QD.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -10
- 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.map +0 -1
- package/dist/types/src/containers/StackContainer/StackContainer.d.ts +0 -7
- package/dist/types/src/containers/StackContainer/StackContainer.d.ts.map +0 -1
- package/dist/types/src/containers/StackContainer/index.d.ts +0 -3
- package/dist/types/src/containers/StackContainer/index.d.ts.map +0 -1
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/containers/StackContainer/index.ts +0 -7
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/types/index.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -12,4 +12,4 @@ Surface plugin for Stack entities.
|
|
|
12
12
|
|
|
13
13
|
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
14
14
|
|
|
15
|
-
License: [
|
|
15
|
+
License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2023 © DXOS
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// src/containers/StackArticle/StackArticle.tsx
|
|
2
|
+
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import React, { useCallback, useState } from "react";
|
|
5
|
+
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
6
|
+
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
7
|
+
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
8
|
+
import { Annotation, Obj } from "@dxos/echo";
|
|
9
|
+
import { AtomObj } from "@dxos/echo-atom";
|
|
10
|
+
import { Graph } from "@dxos/plugin-graph";
|
|
11
|
+
import { SpaceOperation } from "@dxos/plugin-space";
|
|
12
|
+
import { Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
13
|
+
import { Stack, StackItem } from "@dxos/react-ui-stack";
|
|
14
|
+
import { isNonNullable } from "@dxos/util";
|
|
15
|
+
import { StackContext, StackSection } from "#components";
|
|
16
|
+
import { meta } from "#meta";
|
|
17
|
+
var collectionObjectsFamily = Atom.family((collection) => Atom.make((get) => {
|
|
18
|
+
const snapshot = get(AtomObj.make(collection));
|
|
19
|
+
return snapshot.objects.map((ref) => get(AtomObj.makeWithReactive(ref))).filter(isNonNullable);
|
|
20
|
+
}));
|
|
21
|
+
var StackArticle = ({ attendableId, subject: collection }) => {
|
|
22
|
+
const { invokePromise } = useOperationInvoker();
|
|
23
|
+
const { graph } = useAppGraph();
|
|
24
|
+
const { t } = useTranslation(meta.id);
|
|
25
|
+
const [collapsedSections, setCollapsedSections] = useState({});
|
|
26
|
+
const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
|
|
27
|
+
const items = collectionObjects.map((object) => {
|
|
28
|
+
const schema = Obj.getSchema(object);
|
|
29
|
+
const iconAnnotation = schema ? Option.getOrUndefined(Annotation.IconAnnotation.get(schema)) : void 0;
|
|
30
|
+
const metadata = {
|
|
31
|
+
icon: iconAnnotation?.icon
|
|
32
|
+
};
|
|
33
|
+
const view = {
|
|
34
|
+
// ...stack.sections[object.id],
|
|
35
|
+
collapsed: collapsedSections[Obj.getDXN(object).toString()],
|
|
36
|
+
title: object?.title ?? // TODO(wittjosiah): `getNode` is not reactive.
|
|
37
|
+
toLocalizedString(Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label, t)
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
id: Obj.getDXN(object).toString(),
|
|
41
|
+
object,
|
|
42
|
+
metadata,
|
|
43
|
+
view
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
const handleDelete = useCallback(async (id) => {
|
|
47
|
+
const index = collection.objects.map((object2) => object2.target).filter(isNonNullable).findIndex((section) => Obj.getDXN(section).toString() === id);
|
|
48
|
+
const object = collection.objects[index].target;
|
|
49
|
+
if (Obj.isObject(object)) {
|
|
50
|
+
await invokePromise(SpaceOperation.RemoveObjects, {
|
|
51
|
+
objects: [
|
|
52
|
+
object
|
|
53
|
+
],
|
|
54
|
+
target: collection
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, [
|
|
58
|
+
collection,
|
|
59
|
+
invokePromise
|
|
60
|
+
]);
|
|
61
|
+
const handleAdd = useCallback(async (id, position) => {
|
|
62
|
+
await invokePromise(LayoutOperation.UpdateDialog, {
|
|
63
|
+
subject: `${meta.id}.AddSectionDialog`,
|
|
64
|
+
blockAlign: "start",
|
|
65
|
+
props: {
|
|
66
|
+
path: id,
|
|
67
|
+
position,
|
|
68
|
+
collection
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}, [
|
|
72
|
+
collection,
|
|
73
|
+
invokePromise
|
|
74
|
+
]);
|
|
75
|
+
const handleNavigate = useCallback(async (id) => {
|
|
76
|
+
await invokePromise(LayoutOperation.Open, {
|
|
77
|
+
subject: [
|
|
78
|
+
id
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
}, [
|
|
82
|
+
invokePromise
|
|
83
|
+
]);
|
|
84
|
+
const handleCollapse = useCallback((id, collapsed) => setCollapsedSections((prev) => ({
|
|
85
|
+
...prev,
|
|
86
|
+
[id]: collapsed
|
|
87
|
+
})), []);
|
|
88
|
+
const handleAddSection = useCallback(() => invokePromise(SpaceOperation.OpenCreateObject, {
|
|
89
|
+
target: collection,
|
|
90
|
+
navigable: false
|
|
91
|
+
}), [
|
|
92
|
+
collection,
|
|
93
|
+
invokePromise
|
|
94
|
+
]);
|
|
95
|
+
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
96
|
+
toolbar: true,
|
|
97
|
+
classNames: "dx-document"
|
|
98
|
+
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
99
|
+
icon: "ph--plus--regular",
|
|
100
|
+
iconOnly: true,
|
|
101
|
+
label: "Add section",
|
|
102
|
+
"data-testid": "stack.addSection",
|
|
103
|
+
onClick: handleAddSection
|
|
104
|
+
})), /* @__PURE__ */ React.createElement(StackContext.Provider, {
|
|
105
|
+
value: {
|
|
106
|
+
attendableId,
|
|
107
|
+
onCollapse: handleCollapse,
|
|
108
|
+
onNavigate: handleNavigate,
|
|
109
|
+
onDelete: handleDelete,
|
|
110
|
+
onAdd: handleAdd
|
|
111
|
+
}
|
|
112
|
+
}, /* @__PURE__ */ React.createElement(Stack, {
|
|
113
|
+
orientation: "vertical",
|
|
114
|
+
size: "intrinsic",
|
|
115
|
+
id: Obj.getDXN(collection).toString(),
|
|
116
|
+
"data-testid": "main.stack",
|
|
117
|
+
classNames: "overflow-y-auto"
|
|
118
|
+
}, items.map((item) => /* @__PURE__ */ React.createElement(StackSection, {
|
|
119
|
+
key: item.id,
|
|
120
|
+
...item
|
|
121
|
+
})))));
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
StackArticle as default
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=StackArticle-3FE52PUH.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/containers/StackArticle/StackArticle.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Atom, useAtomValue } from '@effect-atom/atom-react';\nimport * as Option from 'effect/Option';\nimport React, { useCallback, useState } from 'react';\n\nimport { useOperationInvoker } from '@dxos/app-framework/ui';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { useAppGraph, type AppSurface } from '@dxos/app-toolkit/ui';\nimport { Annotation, type Collection, Obj, type Ref } from '@dxos/echo';\nimport { AtomObj } from '@dxos/echo-atom';\nimport { Graph } from '@dxos/plugin-graph';\nimport { SpaceOperation } from '@dxos/plugin-space';\nimport { Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { Stack, StackItem } from '@dxos/react-ui-stack';\nimport { isNonNullable } from '@dxos/util';\n\nimport { StackContext, StackSection } from '#components';\nimport { meta } from '#meta';\nimport {\n type AddSectionPosition,\n type CollapsedSections,\n type StackSectionItem,\n type StackSectionMetadata,\n type StackSectionView,\n} from '#types';\n\nconst collectionObjectsFamily = Atom.family((collection: Collection.Collection) =>\n Atom.make((get) => {\n const snapshot = get(AtomObj.make(collection));\n return (\n snapshot.objects\n // TODO(wittjosiah): Why isn't this type inferred correctly?\n .map((ref: Ref.Ref<Obj.Unknown>) => get(AtomObj.makeWithReactive(ref)))\n .filter(isNonNullable)\n );\n }),\n);\n\ntype StackArticleProps = AppSurface.ObjectArticleProps<Collection.Collection>;\n\nexport const StackArticle = ({ attendableId, subject: collection }: StackArticleProps) => {\n const { invokePromise } = useOperationInvoker();\n const { graph } = useAppGraph();\n const { t } = useTranslation(meta.id);\n const [collapsedSections, setCollapsedSections] = useState<CollapsedSections>({});\n\n // TODO(wittjosiah): Re-implement stack views with relations.\n // const defaultStack = useMemo(() => Obj.make(StackViewType, { sections: {} }), [collection]);\n // const stack = (collection.views[StackViewType.typename]?.target as StackViewType | undefined) ?? defaultStack;\n // useEffect(() => {\n // if (!collection.views[StackViewType.typename]) {\n // collection.views[StackViewType.typename] = Ref.make(stack);\n // }\n // }, [collection, stack]);\n\n const collectionObjects = useAtomValue(collectionObjectsFamily(collection));\n const items = collectionObjects.map((object: Obj.Unknown) => {\n const schema = Obj.getSchema(object);\n const iconAnnotation = schema ? Option.getOrUndefined(Annotation.IconAnnotation.get(schema)) : undefined;\n const metadata: StackSectionMetadata = { icon: iconAnnotation?.icon };\n const view = {\n // ...stack.sections[object.id],\n collapsed: collapsedSections[Obj.getDXN(object).toString()],\n title:\n (object as any)?.title ??\n // TODO(wittjosiah): `getNode` is not reactive.\n toLocalizedString(\n Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label,\n t,\n ),\n } as StackSectionView;\n return { id: Obj.getDXN(object).toString(), object, metadata, view } satisfies StackSectionItem;\n });\n\n const handleDelete = useCallback(\n async (id: string) => {\n const index = collection.objects\n .map((object) => object.target)\n .filter(isNonNullable)\n .findIndex((section) => Obj.getDXN(section).toString() === id);\n const object = collection.objects[index].target;\n if (Obj.isObject(object)) {\n await invokePromise(SpaceOperation.RemoveObjects, {\n objects: [object],\n target: collection,\n });\n\n // TODO(wittjosiah): The section should also be removed, but needs to be restored if the action is undone.\n // delete stack.sections[Path.last(path)];\n }\n },\n [collection, invokePromise],\n );\n\n const handleAdd = useCallback(\n async (id: string, position: AddSectionPosition) => {\n // TODO(wittjosiah): Use object creation dialog.\n await invokePromise(LayoutOperation.UpdateDialog, {\n subject: `${meta.id}.AddSectionDialog`,\n blockAlign: 'start',\n props: {\n path: id,\n position,\n collection,\n },\n });\n },\n [collection, invokePromise],\n );\n\n const handleNavigate = useCallback(\n async (id: string) => {\n await invokePromise(LayoutOperation.Open, { subject: [id] });\n },\n [invokePromise],\n );\n\n const handleCollapse = useCallback(\n (id: string, collapsed: boolean) => setCollapsedSections((prev) => ({ ...prev, [id]: collapsed })),\n [],\n );\n\n const handleAddSection = useCallback(\n () =>\n invokePromise(SpaceOperation.OpenCreateObject, {\n target: collection,\n navigable: false,\n }),\n [collection, invokePromise],\n );\n\n return (\n <StackItem.Content toolbar classNames='dx-document'>\n <Toolbar.Root>\n <Toolbar.IconButton\n icon='ph--plus--regular'\n iconOnly\n label='Add section'\n data-testid='stack.addSection'\n onClick={handleAddSection}\n />\n </Toolbar.Root>\n <StackContext.Provider\n value={{\n attendableId,\n onCollapse: handleCollapse,\n onNavigate: handleNavigate,\n onDelete: handleDelete,\n onAdd: handleAdd,\n }}\n >\n <Stack\n orientation='vertical'\n size='intrinsic'\n id={Obj.getDXN(collection).toString()}\n data-testid='main.stack'\n classNames='overflow-y-auto'\n >\n {items.map((item) => (\n <StackSection key={item.id} {...item} />\n ))}\n </Stack>\n </StackContext.Provider>\n </StackItem.Content>\n );\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Atom", "useAtomValue", "Option", "React", "useCallback", "useState", "useOperationInvoker", "LayoutOperation", "useAppGraph", "Annotation", "Obj", "AtomObj", "Graph", "SpaceOperation", "Toolbar", "toLocalizedString", "useTranslation", "Stack", "StackItem", "isNonNullable", "StackContext", "StackSection", "meta", "collectionObjectsFamily", "family", "collection", "make", "get", "snapshot", "objects", "map", "ref", "makeWithReactive", "filter", "StackArticle", "attendableId", "subject", "invokePromise", "graph", "t", "id", "collapsedSections", "setCollapsedSections", "collectionObjects", "items", "object", "schema", "getSchema", "iconAnnotation", "getOrUndefined", "IconAnnotation", "undefined", "metadata", "icon", "view", "collapsed", "getDXN", "toString", "title", "getNode", "pipe", "getOrNull", "properties", "label", "handleDelete", "index", "target", "findIndex", "section", "isObject", "RemoveObjects", "handleAdd", "position", "UpdateDialog", "blockAlign", "props", "path", "handleNavigate", "Open", "handleCollapse", "prev", "handleAddSection", "OpenCreateObject", "navigable", "Content", "toolbar", "classNames", "Root", "IconButton", "iconOnly", "data-testid", "onClick", "Provider", "value", "onCollapse", "onNavigate", "onDelete", "onAdd", "orientation", "size", "item", "key"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/StackPlugin.ts
|
|
2
|
+
import { Plugin } from "@dxos/app-framework";
|
|
3
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
4
|
+
import { ReactSurface } from "#capabilities";
|
|
5
|
+
import { meta } from "#meta";
|
|
6
|
+
import { translations } from "#translations";
|
|
7
|
+
import { StackViewType } from "#types";
|
|
8
|
+
var StackPlugin = Plugin.define(meta).pipe(AppPlugin.addSchemaModule({
|
|
9
|
+
schema: [
|
|
10
|
+
StackViewType
|
|
11
|
+
]
|
|
12
|
+
}), AppPlugin.addSurfaceModule({
|
|
13
|
+
activate: ReactSurface
|
|
14
|
+
}), AppPlugin.addTranslationsModule({
|
|
15
|
+
translations
|
|
16
|
+
}), Plugin.make);
|
|
17
|
+
var StackPlugin_default = StackPlugin;
|
|
18
|
+
export {
|
|
19
|
+
StackPlugin,
|
|
20
|
+
StackPlugin_default as default
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=StackPlugin.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/StackPlugin.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { ReactSurface } from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { StackViewType } from '#types';\n\nexport const StackPlugin = Plugin.define(meta).pipe(\n AppPlugin.addSchemaModule({ schema: [StackViewType] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\n);\n\nexport default StackPlugin;\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,oBAAoB;AAC7B,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,qBAAqB;AAEvB,IAAMC,cAAcN,OAAOO,OAAOJ,IAAAA,EAAMK,KAC7CP,UAAUQ,gBAAgB;EAAEC,QAAQ;IAACL;;AAAe,CAAA,GACpDJ,UAAUU,iBAAiB;EAAEC,UAAUV;AAAa,CAAA,GACpDD,UAAUY,sBAAsB;EAAET;AAAa,CAAA,GAC/CJ,OAAOc,IAAI;AAGb,IAAA,sBAAeR;",
|
|
6
|
+
"names": ["Plugin", "AppPlugin", "ReactSurface", "meta", "translations", "StackViewType", "StackPlugin", "define", "pipe", "addSchemaModule", "schema", "addSurfaceModule", "activate", "addTranslationsModule", "make"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/capabilities/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,kBAAkB;AAEpB,IAAMC,eAAeD,WAAWE,KAAK,gBAAgB,MAAM,OAAO,+BAAA,CAAA;",
|
|
6
|
+
"names": ["Capability", "ReactSurface", "lazy"]
|
|
7
|
+
}
|
|
@@ -16,7 +16,7 @@ var StackViewType = Schema.Struct({
|
|
|
16
16
|
value: SectionSchema
|
|
17
17
|
})
|
|
18
18
|
}).pipe(Type.object({
|
|
19
|
-
typename: "org.dxos.type.
|
|
19
|
+
typename: "org.dxos.type.stackView",
|
|
20
20
|
version: "0.1.0"
|
|
21
21
|
}));
|
|
22
22
|
|
|
@@ -24,4 +24,4 @@ export {
|
|
|
24
24
|
SectionSchema,
|
|
25
25
|
StackViewType
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-IPU3C6TT.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/types/stack.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Type } from '@dxos/echo';\n\n// All section metadata needs to be optional/have defaults.\n// Any objects added to the collection will start with the section defaults.\n// If an object is removed from the collection without removing the section metadata this is fine.\n// Stack components should clean-up the superfluous data on future edits.\n\nexport const SectionSchema = Schema.Struct({\n height: Schema.optional(Schema.Number),\n // Space for data that isn't stack-specific but is specific to this view instance.\n // e.g. cover/fill for an image\n custom: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n});\n\n// TODO(wittjosiah): This needs a relation to be connected to a stack.\nexport const StackViewType = Schema.Struct({\n sections: Schema.Record({ key: Schema.String, value: SectionSchema }),\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.
|
|
5
|
-
"mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,YAAY;AAOd,IAAMC,gBAAuBC,cAAO;EACzCC,QAAeC,gBAAgBC,aAAM;;;EAGrCC,QAAeF,gBAAgBG,cAAO;IAAEC,KAAYC;IAAQC,OAAcC;EAAI,CAAA,CAAA;AAChF,CAAA;AAGO,IAAMC,gBAAuBV,cAAO;EACzCW,UAAiBN,cAAO;IAAEC,KAAYC;IAAQC,OAAOT;EAAc,CAAA;AACrE,CAAA,EAAGa,
|
|
6
|
-
"names": ["Schema", "Type", "SectionSchema", "Struct", "height", "optional", "Number", "custom", "Record", "key", "String", "value", "Any", "StackViewType", "sections", "pipe", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Type } from '@dxos/echo';\n\n// All section metadata needs to be optional/have defaults.\n// Any objects added to the collection will start with the section defaults.\n// If an object is removed from the collection without removing the section metadata this is fine.\n// Stack components should clean-up the superfluous data on future edits.\n\nexport const SectionSchema = Schema.Struct({\n height: Schema.optional(Schema.Number),\n // Space for data that isn't stack-specific but is specific to this view instance.\n // e.g. cover/fill for an image\n custom: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n});\n\n// TODO(wittjosiah): This needs a relation to be connected to a stack.\nexport const StackViewType = Schema.Struct({\n sections: Schema.Record({ key: Schema.String, value: SectionSchema }),\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.stackView',\n version: '0.1.0',\n }),\n);\n\nexport interface StackViewType extends Schema.Schema.Type<typeof StackViewType> {}\n"],
|
|
5
|
+
"mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,YAAY;AAOd,IAAMC,gBAAuBC,cAAO;EACzCC,QAAeC,gBAAgBC,aAAM;;;EAGrCC,QAAeF,gBAAgBG,cAAO;IAAEC,KAAYC;IAAQC,OAAcC;EAAI,CAAA,CAAA;AAChF,CAAA;AAGO,IAAMC,gBAAuBV,cAAO;EACzCW,UAAiBN,cAAO;IAAEC,KAAYC;IAAQC,OAAOT;EAAc,CAAA;AACrE,CAAA,EAAGa,KACDd,KAAKe,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
|
|
6
|
+
"names": ["Schema", "Type", "SectionSchema", "Struct", "height", "optional", "Number", "custom", "Record", "key", "String", "value", "Any", "StackViewType", "sections", "pipe", "object", "typename", "version"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// src/meta.ts
|
|
2
2
|
import { trim } from "@dxos/util";
|
|
3
|
-
var SECTION_IDENTIFIER = "org.dxos.type.
|
|
3
|
+
var SECTION_IDENTIFIER = "org.dxos.type.stackSection";
|
|
4
4
|
var meta = {
|
|
5
5
|
id: "org.dxos.plugin.stack",
|
|
6
6
|
// TODO(wittjosiah): Prevents "stacks" language from being exposed to users in settings panel.
|
|
7
7
|
// Conside renaming this to the collection plugin and trying to factor more collections logic from the space plugin.
|
|
8
8
|
name: "Collections",
|
|
9
|
+
author: "DXOS",
|
|
9
10
|
description: trim`
|
|
10
11
|
Organize and view curated collections of workspace objects in customizable layouts.
|
|
11
12
|
Group related items together and manage collections with sections and filtering.
|
|
@@ -18,4 +19,4 @@ export {
|
|
|
18
19
|
SECTION_IDENTIFIER,
|
|
19
20
|
meta
|
|
20
21
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
22
|
+
//# sourceMappingURL=chunk-LAZU5N5N.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const SECTION_IDENTIFIER = 'org.dxos.type.stackSection';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.stack',\n // TODO(wittjosiah): Prevents \"stacks\" language from being exposed to users in settings panel.\n // Conside renaming this to the collection plugin and trying to factor more collections logic from the space plugin.\n name: 'Collections',\n author: 'DXOS',\n description: trim`\n Organize and view curated collections of workspace objects in customizable layouts.\n Group related items together and manage collections with sections and filtering.\n `,\n icon: 'ph--stack-simple--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-stack',\n};\n"],
|
|
5
|
+
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,qBAAqB;AAE3B,IAAMC,OAAoB;EAC/BC,IAAI;;;EAGJC,MAAM;EACNC,QAAQ;EACRC,aAAaN;;;;EAIbO,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
+
"names": ["trim", "SECTION_IDENTIFIER", "meta", "id", "name", "author", "description", "icon", "source"]
|
|
7
|
+
}
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-G4CLPE5A.mjs";
|
|
4
|
-
|
|
5
|
-
// src/containers/StackContainer/StackContainer.tsx
|
|
6
|
-
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
7
|
-
import * as Option from "effect/Option";
|
|
8
|
-
import React4, { useCallback, useState as useState2 } from "react";
|
|
9
|
-
import { useCapabilities, useOperationInvoker } from "@dxos/app-framework/ui";
|
|
10
|
-
import { AppCapabilities, LayoutOperation } from "@dxos/app-toolkit";
|
|
11
|
-
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
12
|
-
import { Obj } from "@dxos/echo";
|
|
13
|
-
import { AtomObj } from "@dxos/echo-atom";
|
|
14
|
-
import { Graph } from "@dxos/plugin-graph";
|
|
15
|
-
import { SpaceOperation } from "@dxos/plugin-space/types";
|
|
16
|
-
import { Toolbar, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
17
|
-
import { Stack, StackItem as StackItem2 } from "@dxos/react-ui-stack";
|
|
18
|
-
import { isNonNullable } from "@dxos/util";
|
|
19
|
-
|
|
20
1
|
// src/components/StackContext/StackContext.tsx
|
|
21
2
|
import { createContext, useContext } from "react";
|
|
22
3
|
var StackContext = /* @__PURE__ */ createContext({
|
|
@@ -36,10 +17,12 @@ var useStack = () => useContext(StackContext);
|
|
|
36
17
|
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
37
18
|
import React2, { useMemo, useState } from "react";
|
|
38
19
|
import { Surface } from "@dxos/app-framework/ui";
|
|
20
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
39
21
|
import { DropdownMenu, Icon, IconButton, useTranslation } from "@dxos/react-ui";
|
|
40
22
|
import { useAttentionAttributes } from "@dxos/react-ui-attention";
|
|
41
23
|
import { StackItem } from "@dxos/react-ui-stack";
|
|
42
24
|
import { getSize, mx } from "@dxos/ui-theme";
|
|
25
|
+
import { meta } from "#meta";
|
|
43
26
|
|
|
44
27
|
// src/components/StackSection/CaretDownUp.tsx
|
|
45
28
|
import React from "react";
|
|
@@ -108,64 +91,59 @@ var StackSection = ({ id, view, object, metadata: { icon = "ph--placeholder--reg
|
|
|
108
91
|
asChild: true
|
|
109
92
|
}, /* @__PURE__ */ React2.createElement(StackItem.SigilButton, null, /* @__PURE__ */ React2.createElement(Icon, {
|
|
110
93
|
icon,
|
|
111
|
-
size: 5,
|
|
112
94
|
classNames: "transition-opacity"
|
|
113
95
|
}))), /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, view.collapsed ? /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
114
96
|
onClick: () => onNavigate(id),
|
|
115
97
|
"data-testid": "section.navigate-to"
|
|
116
98
|
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
117
|
-
icon: "ph--arrow-right--regular"
|
|
118
|
-
size: 5
|
|
99
|
+
icon: "ph--arrow-right--regular"
|
|
119
100
|
}), /* @__PURE__ */ React2.createElement("span", {
|
|
120
101
|
className: "ms-2 grow"
|
|
121
|
-
}, t("navigate
|
|
102
|
+
}, t("navigate-to-section.label"))) : /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
|
|
122
103
|
asChild: true
|
|
123
104
|
}, /* @__PURE__ */ React2.createElement(DropdownMenu.Item, null, /* @__PURE__ */ React2.createElement(CaretDownUp, {
|
|
124
105
|
className: getSize(5)
|
|
125
106
|
}), /* @__PURE__ */ React2.createElement("span", {
|
|
126
107
|
className: "ms-2 grow"
|
|
127
|
-
}, t("collapse
|
|
108
|
+
}, t("collapse.label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
128
109
|
onClick: () => onAdd(id, "before"),
|
|
129
110
|
"data-testid": "section.add-before"
|
|
130
111
|
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
131
|
-
icon: "ph--arrow-line-up--regular"
|
|
132
|
-
size: 5
|
|
112
|
+
icon: "ph--arrow-line-up--regular"
|
|
133
113
|
}), /* @__PURE__ */ React2.createElement("span", {
|
|
134
114
|
className: "ms-2 grow"
|
|
135
|
-
}, t("add
|
|
115
|
+
}, t("add-section-before.label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
136
116
|
onClick: () => onAdd(id, "after"),
|
|
137
117
|
"data-testid": "section.add-after"
|
|
138
118
|
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
139
|
-
icon: "ph--arrow-line-down--regular"
|
|
140
|
-
size: 5
|
|
119
|
+
icon: "ph--arrow-line-down--regular"
|
|
141
120
|
}), /* @__PURE__ */ React2.createElement("span", {
|
|
142
121
|
className: "ms-2 grow"
|
|
143
|
-
}, t("add
|
|
122
|
+
}, t("add-section-after.label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
144
123
|
onClick: () => onDelete(id),
|
|
145
124
|
"data-testid": "section.remove"
|
|
146
125
|
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
147
|
-
icon: "ph--trash--regular"
|
|
148
|
-
size: 5
|
|
126
|
+
icon: "ph--trash--regular"
|
|
149
127
|
}), /* @__PURE__ */ React2.createElement("span", {
|
|
150
128
|
className: "ms-2 grow"
|
|
151
|
-
}, t("remove
|
|
129
|
+
}, t("remove-section.label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)))), view.collapsed ? /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
|
|
152
130
|
asChild: true
|
|
153
131
|
}, /* @__PURE__ */ React2.createElement(IconButton, {
|
|
154
132
|
iconOnly: true,
|
|
155
133
|
variant: "ghost",
|
|
156
|
-
label: t("expand
|
|
134
|
+
label: t("expand.label"),
|
|
157
135
|
icon: "ph--caret-up-down--regular",
|
|
158
136
|
classNames: sectionActionDimensions
|
|
159
137
|
})) : /* @__PURE__ */ React2.createElement(IconButton, {
|
|
160
138
|
iconOnly: true,
|
|
161
139
|
variant: "ghost",
|
|
162
140
|
onClick: () => onNavigate(id),
|
|
163
|
-
label: t("navigate
|
|
141
|
+
label: t("navigate-to-section.label"),
|
|
164
142
|
icon: "ph--arrow-right--regular",
|
|
165
143
|
"data-testid": "section.navigate-to",
|
|
166
144
|
classNames: sectionActionDimensions
|
|
167
145
|
}))), /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Content, null, /* @__PURE__ */ React2.createElement(Surface.Surface, {
|
|
168
|
-
|
|
146
|
+
type: AppSurface.Section,
|
|
169
147
|
data,
|
|
170
148
|
limit: 1,
|
|
171
149
|
placeholder: /* @__PURE__ */ React2.createElement(React2.Fragment, null)
|
|
@@ -179,116 +157,26 @@ var StackSection = ({ id, view, object, metadata: { icon = "ph--placeholder--reg
|
|
|
179
157
|
// src/components/StackSettings/StackSettings.tsx
|
|
180
158
|
import React3 from "react";
|
|
181
159
|
import { Input, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
182
|
-
import { Settings } from "@dxos/react-ui-form";
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const metadata = allMetadata.find((m) => m.id === (Obj.getTypename(object) ?? "never"))?.metadata;
|
|
198
|
-
const view = {
|
|
199
|
-
// ...stack.sections[object.id],
|
|
200
|
-
collapsed: collapsedSections[Obj.getDXN(object).toString()],
|
|
201
|
-
title: object?.title ?? // TODO(wittjosiah): `getNode` is not reactive.
|
|
202
|
-
toLocalizedString(Graph.getNode(graph, Obj.getDXN(object).toString()).pipe(Option.getOrNull)?.properties.label, t)
|
|
203
|
-
};
|
|
204
|
-
return {
|
|
205
|
-
id: Obj.getDXN(object).toString(),
|
|
206
|
-
object,
|
|
207
|
-
metadata,
|
|
208
|
-
view
|
|
209
|
-
};
|
|
210
|
-
});
|
|
211
|
-
const handleDelete = useCallback(async (id) => {
|
|
212
|
-
const index = collection.objects.map((object2) => object2.target).filter(isNonNullable).findIndex((section) => Obj.getDXN(section).toString() === id);
|
|
213
|
-
const object = collection.objects[index].target;
|
|
214
|
-
if (Obj.isObject(object)) {
|
|
215
|
-
await invokePromise(SpaceOperation.RemoveObjects, {
|
|
216
|
-
objects: [
|
|
217
|
-
object
|
|
218
|
-
],
|
|
219
|
-
target: collection
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
}, [
|
|
223
|
-
collection,
|
|
224
|
-
invokePromise
|
|
225
|
-
]);
|
|
226
|
-
const handleAdd = useCallback(async (id, position) => {
|
|
227
|
-
await invokePromise(LayoutOperation.UpdateDialog, {
|
|
228
|
-
subject: `${meta.id}.AddSectionDialog`,
|
|
229
|
-
blockAlign: "start",
|
|
230
|
-
props: {
|
|
231
|
-
path: id,
|
|
232
|
-
position,
|
|
233
|
-
collection
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}, [
|
|
237
|
-
collection,
|
|
238
|
-
invokePromise
|
|
239
|
-
]);
|
|
240
|
-
const handleNavigate = useCallback(async (id) => {
|
|
241
|
-
await invokePromise(LayoutOperation.Open, {
|
|
242
|
-
subject: [
|
|
243
|
-
id
|
|
244
|
-
]
|
|
245
|
-
});
|
|
246
|
-
}, [
|
|
247
|
-
invokePromise
|
|
248
|
-
]);
|
|
249
|
-
const handleCollapse = useCallback((id, collapsed) => setCollapsedSections((prev) => ({
|
|
250
|
-
...prev,
|
|
251
|
-
[id]: collapsed
|
|
252
|
-
})), []);
|
|
253
|
-
const handleAddSection = useCallback(() => invokePromise(SpaceOperation.OpenCreateObject, {
|
|
254
|
-
target: collection,
|
|
255
|
-
navigable: false
|
|
256
|
-
}), [
|
|
257
|
-
collection,
|
|
258
|
-
invokePromise
|
|
259
|
-
]);
|
|
260
|
-
return /* @__PURE__ */ React4.createElement(StackItem2.Content, {
|
|
261
|
-
toolbar: true,
|
|
262
|
-
classNames: "dx-document"
|
|
263
|
-
}, /* @__PURE__ */ React4.createElement(Toolbar.Root, null, /* @__PURE__ */ React4.createElement(Toolbar.IconButton, {
|
|
264
|
-
icon: "ph--plus--regular",
|
|
265
|
-
iconOnly: true,
|
|
266
|
-
label: "Add section",
|
|
267
|
-
"data-testid": "stack.addSection",
|
|
268
|
-
onClick: handleAddSection
|
|
269
|
-
})), /* @__PURE__ */ React4.createElement(StackContext.Provider, {
|
|
270
|
-
value: {
|
|
271
|
-
attendableId,
|
|
272
|
-
onCollapse: handleCollapse,
|
|
273
|
-
onNavigate: handleNavigate,
|
|
274
|
-
onDelete: handleDelete,
|
|
275
|
-
onAdd: handleAdd
|
|
276
|
-
}
|
|
277
|
-
}, /* @__PURE__ */ React4.createElement(Stack, {
|
|
278
|
-
orientation: "vertical",
|
|
279
|
-
size: "intrinsic",
|
|
280
|
-
id: Obj.getDXN(collection).toString(),
|
|
281
|
-
"data-testid": "main.stack",
|
|
282
|
-
classNames: "overflow-y-auto"
|
|
283
|
-
}, items.map((item) => /* @__PURE__ */ React4.createElement(StackSection, {
|
|
284
|
-
key: item.id,
|
|
285
|
-
...item
|
|
286
|
-
})))));
|
|
160
|
+
import { Settings as SettingsForm } from "@dxos/react-ui-form";
|
|
161
|
+
import { meta as meta2 } from "#meta";
|
|
162
|
+
var StackSettings = ({ settings }) => {
|
|
163
|
+
const { t } = useTranslation2(meta2.id);
|
|
164
|
+
return /* @__PURE__ */ React3.createElement(SettingsForm.Viewport, null, /* @__PURE__ */ React3.createElement(SettingsForm.Section, {
|
|
165
|
+
title: t("settings.title", {
|
|
166
|
+
ns: meta2.id
|
|
167
|
+
})
|
|
168
|
+
}, /* @__PURE__ */ React3.createElement(SettingsForm.Item, {
|
|
169
|
+
title: t("settings.separation.label"),
|
|
170
|
+
description: t("settings.separation.description")
|
|
171
|
+
}, /* @__PURE__ */ React3.createElement(Input.Switch, {
|
|
172
|
+
checked: settings.separation,
|
|
173
|
+
onCheckedChange: (checked) => settings.separation = !!checked
|
|
174
|
+
}))));
|
|
287
175
|
};
|
|
288
|
-
|
|
289
|
-
// src/containers/StackContainer/index.ts
|
|
290
|
-
var StackContainer_default = StackContainer;
|
|
291
176
|
export {
|
|
292
|
-
|
|
177
|
+
StackContext,
|
|
178
|
+
StackSection,
|
|
179
|
+
StackSettings,
|
|
180
|
+
useStack
|
|
293
181
|
};
|
|
294
|
-
//# sourceMappingURL=
|
|
182
|
+
//# sourceMappingURL=index.mjs.map
|