@dxos/plugin-stack 0.8.4-main.fffef41 → 0.8.4-staging.60fe92afc8
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/PLUGIN.mdl +326 -0
- package/README.md +1 -1
- package/dist/lib/neutral/StackArticle-R7IS6TYR.mjs +124 -0
- package/dist/lib/neutral/StackArticle-R7IS6TYR.mjs.map +7 -0
- package/dist/lib/neutral/StackPlugin.mjs +34 -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/neutral/chunk-RGJSGQGF.mjs +36 -0
- package/dist/lib/neutral/chunk-RGJSGQGF.mjs.map +7 -0
- package/dist/lib/{browser/chunk-NHMDZYOB.mjs → neutral/chunk-T4NSFSPH.mjs} +6 -10
- package/dist/lib/neutral/chunk-T4NSFSPH.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +182 -0
- 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 +3 -1
- 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 +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/{StackContext.d.ts → StackContext/StackContext.d.ts} +2 -1
- package/dist/types/src/components/StackContext/StackContext.d.ts.map +1 -0
- package/dist/types/src/components/StackContext/index.d.ts +2 -0
- package/dist/types/src/components/StackContext/index.d.ts.map +1 -0
- package/dist/types/src/components/{CaretDownUp.d.ts → StackSection/CaretDownUp.d.ts} +1 -1
- package/dist/types/src/components/StackSection/CaretDownUp.d.ts.map +1 -0
- package/dist/types/src/components/{StackSection.d.ts → StackSection/StackSection.d.ts} +1 -1
- package/dist/types/src/components/StackSection/StackSection.d.ts.map +1 -0
- package/dist/types/src/components/StackSection/index.d.ts +2 -0
- package/dist/types/src/components/StackSection/index.d.ts.map +1 -0
- package/dist/types/src/components/{StackSettings.d.ts → StackSettings/StackSettings.d.ts} +1 -1
- package/dist/types/src/components/StackSettings/StackSettings.d.ts.map +1 -0
- package/dist/types/src/components/StackSettings/index.d.ts +2 -0
- package/dist/types/src/components/StackSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -7
- package/dist/types/src/components/index.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 +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- 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 +4 -3
- 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 +31 -31
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/stack.d.ts +12 -14
- package/dist/types/src/types/stack.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -3
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +87 -54
- package/src/StackPlugin.ts +19 -44
- package/src/capabilities/index.ts +2 -2
- package/src/capabilities/react-surface.tsx +20 -21
- package/src/components/{StackContext.tsx → StackContext/StackContext.tsx} +3 -1
- package/src/components/StackContext/index.ts +5 -0
- package/src/components/{StackSection.tsx → StackSection/StackSection.tsx} +28 -25
- package/src/components/StackSection/index.ts +5 -0
- package/src/components/StackSettings/StackSettings.tsx +28 -0
- package/src/components/StackSettings/index.ts +5 -0
- package/src/components/index.ts +2 -4
- package/src/containers/StackArticle/StackArticle.tsx +164 -0
- package/src/containers/StackArticle/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/index.ts +1 -1
- package/src/meta.ts +21 -7
- package/src/plugin.ts +9 -0
- package/src/translations.ts +23 -22
- package/src/types/stack.ts +6 -7
- package/src/types/types.ts +2 -3
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/StackContainer-DD3ZD5OE.mjs +0 -299
- package/dist/lib/browser/StackContainer-DD3ZD5OE.mjs.map +0 -7
- package/dist/lib/browser/chunk-NHMDZYOB.mjs.map +0 -7
- package/dist/lib/browser/chunk-UIKFKRFJ.mjs +0 -21
- package/dist/lib/browser/chunk-UIKFKRFJ.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -99
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-HVPK7YZQ.mjs +0 -39
- package/dist/lib/browser/react-surface-HVPK7YZQ.mjs.map +0 -7
- package/dist/lib/node-esm/StackContainer-JGWPXSUF.mjs +0 -300
- package/dist/lib/node-esm/StackContainer-JGWPXSUF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BGVQYUYP.mjs +0 -23
- package/dist/lib/node-esm/chunk-BGVQYUYP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZZFA7HIV.mjs +0 -30
- package/dist/lib/node-esm/chunk-ZZFA7HIV.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -100
- 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-HYSD7AC2.mjs +0 -40
- package/dist/lib/node-esm/react-surface-HYSD7AC2.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -10
- package/dist/types/src/components/CaretDownUp.d.ts.map +0 -1
- package/dist/types/src/components/StackContainer.d.ts +0 -9
- package/dist/types/src/components/StackContainer.d.ts.map +0 -1
- package/dist/types/src/components/StackContext.d.ts.map +0 -1
- package/dist/types/src/components/StackSection.d.ts.map +0 -1
- package/dist/types/src/components/StackSettings.d.ts.map +0 -1
- package/src/components/StackContainer.tsx +0 -172
- package/src/components/StackSettings.tsx +0 -30
- /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/src/components/{CaretDownUp.tsx → StackSection/CaretDownUp.tsx} +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/PLUGIN.mdl
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: org.dxos.plugin.stack
|
|
3
|
+
name: StackPlugin
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Collections plugin for `DXOS` Composer — renders any `Collection` object as a vertically scrollable stack of collapsible sections, where each section displays an arbitrary ECHO object via the `section` surface role. Supports adding, removing, navigating, and collapsing individual sections.
|
|
8
|
+
|
|
9
|
+
## Extensions
|
|
10
|
+
|
|
11
|
+
The following extension dialects are used in this document.
|
|
12
|
+
Each extension is defined in the Appendix or resolved via its URI.
|
|
13
|
+
|
|
14
|
+
| Term | URI |
|
|
15
|
+
|-------------|--------------------------------|
|
|
16
|
+
| `type` | `org.dxos.mdl.type@1.0` |
|
|
17
|
+
| `feat` | `org.dxos.mdl.feat@1.0` |
|
|
18
|
+
| `test` | `org.dxos.mdl.test@1.0` |
|
|
19
|
+
| `component` | `org.dxos.mdl.component@1.0` |
|
|
20
|
+
| `op` | `org.dxos.mdl.op@1.0` |
|
|
21
|
+
|
|
22
|
+
## Types
|
|
23
|
+
|
|
24
|
+
```mdl
|
|
25
|
+
type SectionSchema
|
|
26
|
+
fields:
|
|
27
|
+
height?: number # explicit height override for the section
|
|
28
|
+
custom?: Record<string, any> # view-instance-specific data (e.g. cover mode for images)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```mdl
|
|
32
|
+
type StackViewType
|
|
33
|
+
typename: org.dxos.type.stackView
|
|
34
|
+
version: 0.1.0
|
|
35
|
+
fields:
|
|
36
|
+
sections: Record<string, SectionSchema>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```mdl
|
|
40
|
+
type StackSectionView
|
|
41
|
+
fields:
|
|
42
|
+
title?: string
|
|
43
|
+
size?: StackItemSize
|
|
44
|
+
height?: number
|
|
45
|
+
collapsed?: boolean
|
|
46
|
+
custom?: Record<string, any>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```mdl
|
|
50
|
+
type StackSectionMetadata
|
|
51
|
+
fields:
|
|
52
|
+
icon?: string
|
|
53
|
+
placeholder?: Label
|
|
54
|
+
viewActions?: (item: CollectionItem) => StackSectionAction
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```mdl
|
|
58
|
+
type StackSectionItem
|
|
59
|
+
fields:
|
|
60
|
+
id: string # DXN string for the contained object
|
|
61
|
+
object: Obj.Unknown
|
|
62
|
+
view: StackSectionView
|
|
63
|
+
metadata: StackSectionMetadata
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```mdl
|
|
67
|
+
type AddSectionPosition
|
|
68
|
+
literals: before | after | beforeAll | afterAll
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```mdl
|
|
72
|
+
type StackSettingsProps
|
|
73
|
+
fields:
|
|
74
|
+
separation: boolean # whether visual separators are shown between sections
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Components
|
|
78
|
+
|
|
79
|
+
```mdl
|
|
80
|
+
component StackArticle
|
|
81
|
+
desc: Full-page article view of a Collection — renders items as a vertical stack of StackSection components with a toolbar for adding sections.
|
|
82
|
+
props:
|
|
83
|
+
subject: Collection
|
|
84
|
+
role: AppSurface.Role
|
|
85
|
+
attendableId?: string
|
|
86
|
+
state:
|
|
87
|
+
collapsedSections: Record<string, boolean> # collapsed state by DXN string
|
|
88
|
+
items: StackSectionItem[] # derived from collection objects
|
|
89
|
+
slots:
|
|
90
|
+
(none)
|
|
91
|
+
actions:
|
|
92
|
+
handleAdd(id: string, position: AddSectionPosition)
|
|
93
|
+
handleDelete(id: string)
|
|
94
|
+
handleNavigate(id: string)
|
|
95
|
+
handleCollapse(id: string, collapsed: boolean)
|
|
96
|
+
handleAddSection()
|
|
97
|
+
emits:
|
|
98
|
+
(none)
|
|
99
|
+
layout: |
|
|
100
|
+
┌──────────────────────────────┐
|
|
101
|
+
│ Toolbar [+ Add Section] │
|
|
102
|
+
├──────────────────────────────┤
|
|
103
|
+
│ Stack (vertical, intrinsic) │
|
|
104
|
+
│ ┌────────────────────────┐ │
|
|
105
|
+
│ │ StackSection │ │
|
|
106
|
+
│ │ ▾ [icon] Title [→] │ │
|
|
107
|
+
│ │ └─ Surface:section │ │
|
|
108
|
+
│ └────────────────────────┘ │
|
|
109
|
+
│ ┌────────────────────────┐ │
|
|
110
|
+
│ │ StackSection (collapsed│ │
|
|
111
|
+
│ │ ▸ [icon] Title [↕] │ │
|
|
112
|
+
│ └────────────────────────┘ │
|
|
113
|
+
│ … │
|
|
114
|
+
└──────────────────────────────┘
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```mdl
|
|
118
|
+
component StackSection
|
|
119
|
+
desc: A single collapsible section in the stack — shows a sigil icon button with a dropdown menu and delegates content rendering to the section surface slot.
|
|
120
|
+
props:
|
|
121
|
+
id: string
|
|
122
|
+
object: Obj.Unknown
|
|
123
|
+
view: StackSectionView
|
|
124
|
+
metadata: StackSectionMetadata
|
|
125
|
+
state:
|
|
126
|
+
optionsMenuOpen: boolean
|
|
127
|
+
attendableId: string # composed as parentAttendableId/object.id
|
|
128
|
+
slots:
|
|
129
|
+
content: ReactNode # rendered by Surface(type=section, subject=object)
|
|
130
|
+
actions:
|
|
131
|
+
navigate(id: string)
|
|
132
|
+
add(id: string, position: AddSectionPosition)
|
|
133
|
+
collapse(id: string, collapsed: boolean)
|
|
134
|
+
delete(id: string)
|
|
135
|
+
layout: |
|
|
136
|
+
┌─────────────────────────────────┐
|
|
137
|
+
│ StackItem.Heading │
|
|
138
|
+
│ [sigil▾] (sticky) [→ or ↕] │
|
|
139
|
+
├─────────────────────────────────┤
|
|
140
|
+
│ CollapsibleContent │
|
|
141
|
+
│ Surface type=section │
|
|
142
|
+
└─────────────────────────────────┘
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
```mdl
|
|
146
|
+
component StackSettings
|
|
147
|
+
desc: Settings panel for configuring stack-level display preferences such as section separation.
|
|
148
|
+
props:
|
|
149
|
+
settings: StackSettingsProps
|
|
150
|
+
layout: |
|
|
151
|
+
┌─────────────────────────────┐
|
|
152
|
+
│ Settings.Section │
|
|
153
|
+
│ Separation [toggle] │
|
|
154
|
+
└─────────────────────────────┘
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Features
|
|
158
|
+
|
|
159
|
+
```mdl
|
|
160
|
+
feat F-1: Stack Rendering
|
|
161
|
+
|
|
162
|
+
req F-1.1: StackPlugin registers a surface for the article role filtered to Collection objects.
|
|
163
|
+
req F-1.2: StackArticle renders each item in the collection as a StackSection in document order.
|
|
164
|
+
req F-1.3: Each StackSection title is derived from the object's title property or graph node label.
|
|
165
|
+
req F-1.4: The icon displayed on the section sigil is taken from the object schema's IconAnnotation.
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
```mdl
|
|
169
|
+
feat F-2: Section Management
|
|
170
|
+
|
|
171
|
+
req F-2.1:
|
|
172
|
+
when: user clicks the Add Section button in the toolbar
|
|
173
|
+
then: SpaceOperation.OpenCreateObject dialog is invoked with the collection as target
|
|
174
|
+
req F-2.2:
|
|
175
|
+
when: user selects "Add Before" or "Add After" from a section dropdown
|
|
176
|
+
then: LayoutOperation.UpdateDialog is invoked with the AddSectionDialog, position, and collection context
|
|
177
|
+
req F-2.3:
|
|
178
|
+
when: user selects "Remove" from a section dropdown
|
|
179
|
+
then: SpaceOperation.RemoveObjects is invoked; section is removed from the collection
|
|
180
|
+
req F-2.4:
|
|
181
|
+
when: user selects "Navigate to" from a collapsed section dropdown or the navigate button
|
|
182
|
+
then: LayoutOperation.Open is invoked with the section's id
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```mdl
|
|
186
|
+
feat F-3: Collapse / Expand
|
|
187
|
+
|
|
188
|
+
req F-3.1: Each section can be individually collapsed via the dropdown menu or caret trigger.
|
|
189
|
+
req F-3.2:
|
|
190
|
+
when: section is expanded
|
|
191
|
+
then: full Surface:section content is visible; navigate button shown in heading
|
|
192
|
+
req F-3.3:
|
|
193
|
+
when: section is collapsed
|
|
194
|
+
then: only the title is shown in StackItem.Content; expand toggle shown in heading
|
|
195
|
+
req F-3.4: Collapsed state is managed locally in StackArticle component state (not persisted).
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```mdl
|
|
199
|
+
feat F-4: Settings
|
|
200
|
+
|
|
201
|
+
req F-4.1: StackPlugin exposes a settings panel via the StackSettings component.
|
|
202
|
+
req F-4.2: The separation setting controls whether visual separators appear between sections.
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
```mdl
|
|
206
|
+
feat F-5: Schema Registration
|
|
207
|
+
|
|
208
|
+
req F-5.1: StackPlugin registers StackViewType with the ECHO schema module on activation.
|
|
209
|
+
req F-5.2: StackViewType stores per-section metadata (height, custom data) keyed by object id.
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Acceptance
|
|
213
|
+
|
|
214
|
+
```mdl
|
|
215
|
+
test T-1: Collection renders as stack
|
|
216
|
+
given: a Collection with three objects is opened in article role
|
|
217
|
+
then:
|
|
218
|
+
- StackArticle is displayed
|
|
219
|
+
- three StackSection components are rendered in order
|
|
220
|
+
- each section shows the object's title
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
```mdl
|
|
224
|
+
test T-2: Add section via toolbar
|
|
225
|
+
given: StackArticle is open
|
|
226
|
+
when: user clicks the Add Section toolbar button
|
|
227
|
+
then: SpaceOperation.OpenCreateObject is invoked with the collection as target
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
```mdl
|
|
231
|
+
test T-3: Remove section
|
|
232
|
+
given: StackArticle is open with at least one section
|
|
233
|
+
when: user selects Remove from a section dropdown
|
|
234
|
+
then:
|
|
235
|
+
- SpaceOperation.RemoveObjects is invoked
|
|
236
|
+
- section no longer appears in the stack
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```mdl
|
|
240
|
+
test T-4: Collapse section
|
|
241
|
+
given: a section is expanded
|
|
242
|
+
when: user selects Collapse from the section dropdown
|
|
243
|
+
then:
|
|
244
|
+
- section content is hidden
|
|
245
|
+
- section title is shown in collapsed state
|
|
246
|
+
- expand toggle is visible in heading
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
```mdl
|
|
250
|
+
test T-5: Navigate to section
|
|
251
|
+
given: StackArticle is open
|
|
252
|
+
when: user clicks the navigate button on a section heading
|
|
253
|
+
then: LayoutOperation.Open is invoked with the section's DXN id
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
```mdl
|
|
257
|
+
test T-6: StackViewType registered
|
|
258
|
+
given: StackPlugin is active
|
|
259
|
+
then: StackViewType (typename org.dxos.type.stackView) is registered with the ECHO schema module
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Appendix: Extension Definitions
|
|
265
|
+
|
|
266
|
+
```mdl
|
|
267
|
+
ext type
|
|
268
|
+
uri: org.dxos.mdl.type@1.0
|
|
269
|
+
desc: A named data structure with typed fields and optional literals.
|
|
270
|
+
fields:
|
|
271
|
+
desc?: Prose
|
|
272
|
+
fields?: FieldMap
|
|
273
|
+
literals?: UnionList
|
|
274
|
+
extends?: TypeRef[]
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
```mdl
|
|
278
|
+
ext feat
|
|
279
|
+
uri: org.dxos.mdl.feat@1.0
|
|
280
|
+
desc: A named feature grouping one or more requirements.
|
|
281
|
+
fields:
|
|
282
|
+
desc?: Prose
|
|
283
|
+
req: RequirementList
|
|
284
|
+
nesting: self
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
```mdl
|
|
288
|
+
ext test
|
|
289
|
+
uri: org.dxos.mdl.test@1.0
|
|
290
|
+
desc: An acceptance scenario expressed as given / when / then steps.
|
|
291
|
+
fields:
|
|
292
|
+
given?: Step | Step[]
|
|
293
|
+
when?: Step | Step[]
|
|
294
|
+
then: Step | Step[]
|
|
295
|
+
tags?: TagList
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
```mdl
|
|
299
|
+
ext component
|
|
300
|
+
uri: org.dxos.mdl.component@1.0
|
|
301
|
+
desc: A UI component with props, internal state, slots, actions, and events.
|
|
302
|
+
fields:
|
|
303
|
+
desc?: Prose
|
|
304
|
+
props?: FieldMap
|
|
305
|
+
state?: FieldMap
|
|
306
|
+
slots?: FieldMap
|
|
307
|
+
actions?: ActionMap
|
|
308
|
+
emits?: EventMap
|
|
309
|
+
layout?: CodeBlock
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
```mdl
|
|
313
|
+
ext op
|
|
314
|
+
uri: org.dxos.mdl.op@1.0
|
|
315
|
+
desc: |
|
|
316
|
+
A named operation with typed inputs, outputs, and declared errors.
|
|
317
|
+
Pure ops have no effects or requires. Effectful ops declare both.
|
|
318
|
+
fields:
|
|
319
|
+
desc?: Prose
|
|
320
|
+
input?: FieldMap
|
|
321
|
+
output?: TypeExpr
|
|
322
|
+
errors?: ErrorMap
|
|
323
|
+
effects?: EffectList
|
|
324
|
+
requires?: ServiceList
|
|
325
|
+
note?: Prose
|
|
326
|
+
```
|
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,124 @@
|
|
|
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 { Obj } from "@dxos/echo";
|
|
9
|
+
import { Graph } from "@dxos/plugin-graph";
|
|
10
|
+
import { SpaceOperation } from "@dxos/plugin-space";
|
|
11
|
+
import { Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
12
|
+
import { Stack, StackItem } from "@dxos/react-ui-stack";
|
|
13
|
+
import { isNonNullable } from "@dxos/util";
|
|
14
|
+
import { StackContext, StackSection } from "#components";
|
|
15
|
+
import { meta } from "#meta";
|
|
16
|
+
var collectionObjectsFamily = Atom.family((collection) => Atom.make((get) => {
|
|
17
|
+
const snapshot = get(Obj.atom(collection));
|
|
18
|
+
return snapshot.objects.map((ref) => get(Obj.atomReactive(ref))).filter(isNonNullable);
|
|
19
|
+
}));
|
|
20
|
+
var StackArticle = ({ attendableId, subject: collection }) => {
|
|
21
|
+
const { invokePromise } = useOperationInvoker();
|
|
22
|
+
const { graph } = useAppGraph();
|
|
23
|
+
const { t } = useTranslation(meta.id);
|
|
24
|
+
const [collapsedSections, setCollapsedSections] = useState({});
|
|
25
|
+
const collectionObjects = useAtomValue(collectionObjectsFamily(collection));
|
|
26
|
+
const items = collectionObjects.map((object) => {
|
|
27
|
+
const iconAnnotation = Obj.getIcon(object);
|
|
28
|
+
const metadata = {
|
|
29
|
+
icon: iconAnnotation?.icon
|
|
30
|
+
};
|
|
31
|
+
const view = {
|
|
32
|
+
// ...stack.sections[object.id],
|
|
33
|
+
collapsed: collapsedSections[Obj.getURI(object)],
|
|
34
|
+
title: object?.title ?? // TODO(wittjosiah): `getNode` is not reactive.
|
|
35
|
+
toLocalizedString(Graph.getNode(graph, Obj.getURI(object)).pipe(Option.getOrNull)?.properties.label, t)
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
id: Obj.getURI(object),
|
|
39
|
+
object,
|
|
40
|
+
metadata,
|
|
41
|
+
view
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
const handleDelete = useCallback(async (id) => {
|
|
45
|
+
const index = collection.objects.map((object2) => object2.target).filter(isNonNullable).findIndex((section) => Obj.getURI(section) === id);
|
|
46
|
+
const object = collection.objects[index].target;
|
|
47
|
+
if (Obj.isObject(object)) {
|
|
48
|
+
await invokePromise(SpaceOperation.RemoveObjects, {
|
|
49
|
+
objects: [
|
|
50
|
+
object
|
|
51
|
+
],
|
|
52
|
+
target: collection
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, [
|
|
56
|
+
collection,
|
|
57
|
+
invokePromise
|
|
58
|
+
]);
|
|
59
|
+
const handleAdd = useCallback(async (id, position) => {
|
|
60
|
+
await invokePromise(LayoutOperation.UpdateDialog, {
|
|
61
|
+
subject: `${meta.id}.AddSectionDialog`,
|
|
62
|
+
blockAlign: "start",
|
|
63
|
+
props: {
|
|
64
|
+
path: id,
|
|
65
|
+
position,
|
|
66
|
+
collection
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}, [
|
|
70
|
+
collection,
|
|
71
|
+
invokePromise
|
|
72
|
+
]);
|
|
73
|
+
const handleNavigate = useCallback(async (id) => {
|
|
74
|
+
await invokePromise(LayoutOperation.Open, {
|
|
75
|
+
subject: [
|
|
76
|
+
id
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
}, [
|
|
80
|
+
invokePromise
|
|
81
|
+
]);
|
|
82
|
+
const handleCollapse = useCallback((id, collapsed) => setCollapsedSections((prev) => ({
|
|
83
|
+
...prev,
|
|
84
|
+
[id]: collapsed
|
|
85
|
+
})), []);
|
|
86
|
+
const handleAddSection = useCallback(() => invokePromise(SpaceOperation.OpenCreateObject, {
|
|
87
|
+
target: collection,
|
|
88
|
+
navigable: false
|
|
89
|
+
}), [
|
|
90
|
+
collection,
|
|
91
|
+
invokePromise
|
|
92
|
+
]);
|
|
93
|
+
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
94
|
+
toolbar: true,
|
|
95
|
+
classNames: "dx-document"
|
|
96
|
+
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Toolbar.IconButton, {
|
|
97
|
+
icon: "ph--plus--regular",
|
|
98
|
+
iconOnly: true,
|
|
99
|
+
label: "Add section",
|
|
100
|
+
"data-testid": "stack.addSection",
|
|
101
|
+
onClick: handleAddSection
|
|
102
|
+
})), /* @__PURE__ */ React.createElement(StackContext.Provider, {
|
|
103
|
+
value: {
|
|
104
|
+
attendableId,
|
|
105
|
+
onCollapse: handleCollapse,
|
|
106
|
+
onNavigate: handleNavigate,
|
|
107
|
+
onDelete: handleDelete,
|
|
108
|
+
onAdd: handleAdd
|
|
109
|
+
}
|
|
110
|
+
}, /* @__PURE__ */ React.createElement(Stack, {
|
|
111
|
+
orientation: "vertical",
|
|
112
|
+
size: "intrinsic",
|
|
113
|
+
id: Obj.getURI(collection),
|
|
114
|
+
"data-testid": "main.stack",
|
|
115
|
+
classNames: "overflow-y-auto"
|
|
116
|
+
}, items.map((item) => /* @__PURE__ */ React.createElement(StackSection, {
|
|
117
|
+
key: item.id,
|
|
118
|
+
...item
|
|
119
|
+
})))));
|
|
120
|
+
};
|
|
121
|
+
export {
|
|
122
|
+
StackArticle as default
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=StackArticle-R7IS6TYR.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 { type Collection, Obj, type Ref } from '@dxos/echo';\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(Obj.atom(collection));\n return (\n snapshot.objects\n // TODO(wittjosiah): Why isn't this type inferred correctly?\n .map((ref: Ref.Ref<Obj.Unknown>) => get(Obj.atomReactive(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 iconAnnotation = Obj.getIcon(object);\n const metadata: StackSectionMetadata = { icon: iconAnnotation?.icon };\n const view = {\n // ...stack.sections[object.id],\n collapsed: collapsedSections[Obj.getURI(object)],\n title:\n (object as any)?.title ??\n // TODO(wittjosiah): `getNode` is not reactive.\n toLocalizedString(Graph.getNode(graph, Obj.getURI(object)).pipe(Option.getOrNull)?.properties.label, t),\n } as StackSectionView;\n return { id: Obj.getURI(object), 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.getURI(section) === 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.getURI(collection)}\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", "Obj", "Graph", "SpaceOperation", "Toolbar", "toLocalizedString", "useTranslation", "Stack", "StackItem", "isNonNullable", "StackContext", "StackSection", "meta", "collectionObjectsFamily", "family", "collection", "make", "get", "snapshot", "atom", "objects", "map", "ref", "atomReactive", "filter", "StackArticle", "attendableId", "subject", "invokePromise", "graph", "t", "id", "collapsedSections", "setCollapsedSections", "collectionObjects", "items", "object", "iconAnnotation", "getIcon", "metadata", "icon", "view", "collapsed", "getURI", "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,34 @@
|
|
|
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
|
+
|
|
9
|
+
// raw-loader:/__w/dxos/dxos/packages/plugins/plugin-stack/PLUGIN.mdl?raw
|
|
10
|
+
var PLUGIN_default = '---\nid: org.dxos.plugin.stack\nname: StackPlugin\nversion: 0.1.0\n---\n\nCollections plugin for `DXOS` Composer \u2014 renders any `Collection` object as a vertically scrollable stack of collapsible sections, where each section displays an arbitrary ECHO object via the `section` surface role. Supports adding, removing, navigating, and collapsing individual sections.\n\n## Extensions\n\nThe following extension dialects are used in this document.\nEach extension is defined in the Appendix or resolved via its URI.\n\n| Term | URI |\n|-------------|--------------------------------|\n| `type` | `org.dxos.mdl.type@1.0` |\n| `feat` | `org.dxos.mdl.feat@1.0` |\n| `test` | `org.dxos.mdl.test@1.0` |\n| `component` | `org.dxos.mdl.component@1.0` |\n| `op` | `org.dxos.mdl.op@1.0` |\n\n## Types\n\n```mdl\ntype SectionSchema\n fields:\n height?: number # explicit height override for the section\n custom?: Record<string, any> # view-instance-specific data (e.g. cover mode for images)\n```\n\n```mdl\ntype StackViewType\n typename: org.dxos.type.stackView\n version: 0.1.0\n fields:\n sections: Record<string, SectionSchema>\n```\n\n```mdl\ntype StackSectionView\n fields:\n title?: string\n size?: StackItemSize\n height?: number\n collapsed?: boolean\n custom?: Record<string, any>\n```\n\n```mdl\ntype StackSectionMetadata\n fields:\n icon?: string\n placeholder?: Label\n viewActions?: (item: CollectionItem) => StackSectionAction\n```\n\n```mdl\ntype StackSectionItem\n fields:\n id: string # DXN string for the contained object\n object: Obj.Unknown\n view: StackSectionView\n metadata: StackSectionMetadata\n```\n\n```mdl\ntype AddSectionPosition\n literals: before | after | beforeAll | afterAll\n```\n\n```mdl\ntype StackSettingsProps\n fields:\n separation: boolean # whether visual separators are shown between sections\n```\n\n## Components\n\n```mdl\ncomponent StackArticle\n desc: Full-page article view of a Collection \u2014 renders items as a vertical stack of StackSection components with a toolbar for adding sections.\n props:\n subject: Collection\n role: AppSurface.Role\n attendableId?: string\n state:\n collapsedSections: Record<string, boolean> # collapsed state by DXN string\n items: StackSectionItem[] # derived from collection objects\n slots:\n (none)\n actions:\n handleAdd(id: string, position: AddSectionPosition)\n handleDelete(id: string)\n handleNavigate(id: string)\n handleCollapse(id: string, collapsed: boolean)\n handleAddSection()\n emits:\n (none)\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 Toolbar [+ Add Section] \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 Stack (vertical, intrinsic) \u2502\n \u2502 \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2502\n \u2502 \u2502 StackSection \u2502 \u2502\n \u2502 \u2502 \u25BE [icon] Title [\u2192] \u2502 \u2502\n \u2502 \u2502 \u2514\u2500 Surface:section \u2502 \u2502\n \u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2502\n \u2502 \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2502\n \u2502 \u2502 StackSection (collapsed\u2502 \u2502\n \u2502 \u2502 \u25B8 [icon] Title [\u2195] \u2502 \u2502\n \u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2502\n \u2502 \u2026 \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n```mdl\ncomponent StackSection\n desc: A single collapsible section in the stack \u2014 shows a sigil icon button with a dropdown menu and delegates content rendering to the section surface slot.\n props:\n id: string\n object: Obj.Unknown\n view: StackSectionView\n metadata: StackSectionMetadata\n state:\n optionsMenuOpen: boolean\n attendableId: string # composed as parentAttendableId/object.id\n slots:\n content: ReactNode # rendered by Surface(type=section, subject=object)\n actions:\n navigate(id: string)\n add(id: string, position: AddSectionPosition)\n collapse(id: string, collapsed: boolean)\n delete(id: string)\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 StackItem.Heading \u2502\n \u2502 [sigil\u25BE] (sticky) [\u2192 or \u2195] \u2502\n \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n \u2502 CollapsibleContent \u2502\n \u2502 Surface type=section \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n```mdl\ncomponent StackSettings\n desc: Settings panel for configuring stack-level display preferences such as section separation.\n props:\n settings: StackSettingsProps\n layout: |\n \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 Settings.Section \u2502\n \u2502 Separation [toggle] \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n## Features\n\n```mdl\nfeat F-1: Stack Rendering\n\n req F-1.1: StackPlugin registers a surface for the article role filtered to Collection objects.\n req F-1.2: StackArticle renders each item in the collection as a StackSection in document order.\n req F-1.3: Each StackSection title is derived from the object\'s title property or graph node label.\n req F-1.4: The icon displayed on the section sigil is taken from the object schema\'s IconAnnotation.\n```\n\n```mdl\nfeat F-2: Section Management\n\n req F-2.1:\n when: user clicks the Add Section button in the toolbar\n then: SpaceOperation.OpenCreateObject dialog is invoked with the collection as target\n req F-2.2:\n when: user selects "Add Before" or "Add After" from a section dropdown\n then: LayoutOperation.UpdateDialog is invoked with the AddSectionDialog, position, and collection context\n req F-2.3:\n when: user selects "Remove" from a section dropdown\n then: SpaceOperation.RemoveObjects is invoked; section is removed from the collection\n req F-2.4:\n when: user selects "Navigate to" from a collapsed section dropdown or the navigate button\n then: LayoutOperation.Open is invoked with the section\'s id\n```\n\n```mdl\nfeat F-3: Collapse / Expand\n\n req F-3.1: Each section can be individually collapsed via the dropdown menu or caret trigger.\n req F-3.2:\n when: section is expanded\n then: full Surface:section content is visible; navigate button shown in heading\n req F-3.3:\n when: section is collapsed\n then: only the title is shown in StackItem.Content; expand toggle shown in heading\n req F-3.4: Collapsed state is managed locally in StackArticle component state (not persisted).\n```\n\n```mdl\nfeat F-4: Settings\n\n req F-4.1: StackPlugin exposes a settings panel via the StackSettings component.\n req F-4.2: The separation setting controls whether visual separators appear between sections.\n```\n\n```mdl\nfeat F-5: Schema Registration\n\n req F-5.1: StackPlugin registers StackViewType with the ECHO schema module on activation.\n req F-5.2: StackViewType stores per-section metadata (height, custom data) keyed by object id.\n```\n\n## Acceptance\n\n```mdl\ntest T-1: Collection renders as stack\n given: a Collection with three objects is opened in article role\n then:\n - StackArticle is displayed\n - three StackSection components are rendered in order\n - each section shows the object\'s title\n```\n\n```mdl\ntest T-2: Add section via toolbar\n given: StackArticle is open\n when: user clicks the Add Section toolbar button\n then: SpaceOperation.OpenCreateObject is invoked with the collection as target\n```\n\n```mdl\ntest T-3: Remove section\n given: StackArticle is open with at least one section\n when: user selects Remove from a section dropdown\n then:\n - SpaceOperation.RemoveObjects is invoked\n - section no longer appears in the stack\n```\n\n```mdl\ntest T-4: Collapse section\n given: a section is expanded\n when: user selects Collapse from the section dropdown\n then:\n - section content is hidden\n - section title is shown in collapsed state\n - expand toggle is visible in heading\n```\n\n```mdl\ntest T-5: Navigate to section\n given: StackArticle is open\n when: user clicks the navigate button on a section heading\n then: LayoutOperation.Open is invoked with the section\'s DXN id\n```\n\n```mdl\ntest T-6: StackViewType registered\n given: StackPlugin is active\n then: StackViewType (typename org.dxos.type.stackView) is registered with the ECHO schema module\n```\n\n---\n\n## Appendix: Extension Definitions\n\n```mdl\next type\n uri: org.dxos.mdl.type@1.0\n desc: A named data structure with typed fields and optional literals.\n fields:\n desc?: Prose\n fields?: FieldMap\n literals?: UnionList\n extends?: TypeRef[]\n```\n\n```mdl\next feat\n uri: org.dxos.mdl.feat@1.0\n desc: A named feature grouping one or more requirements.\n fields:\n desc?: Prose\n req: RequirementList\n nesting: self\n```\n\n```mdl\next test\n uri: org.dxos.mdl.test@1.0\n desc: An acceptance scenario expressed as given / when / then steps.\n fields:\n given?: Step | Step[]\n when?: Step | Step[]\n then: Step | Step[]\n tags?: TagList\n```\n\n```mdl\next component\n uri: org.dxos.mdl.component@1.0\n desc: A UI component with props, internal state, slots, actions, and events.\n fields:\n desc?: Prose\n props?: FieldMap\n state?: FieldMap\n slots?: FieldMap\n actions?: ActionMap\n emits?: EventMap\n layout?: CodeBlock\n```\n\n```mdl\next op\n uri: org.dxos.mdl.op@1.0\n desc: |\n A named operation with typed inputs, outputs, and declared errors.\n Pure ops have no effects or requires. Effectful ops declare both.\n fields:\n desc?: Prose\n input?: FieldMap\n output?: TypeExpr\n errors?: ErrorMap\n effects?: EffectList\n requires?: ServiceList\n note?: Prose\n```\n';
|
|
11
|
+
|
|
12
|
+
// src/StackPlugin.ts
|
|
13
|
+
var StackPlugin = Plugin.define(meta).pipe(AppPlugin.addSchemaModule({
|
|
14
|
+
schema: [
|
|
15
|
+
StackViewType
|
|
16
|
+
]
|
|
17
|
+
}), AppPlugin.addSurfaceModule({
|
|
18
|
+
activate: ReactSurface
|
|
19
|
+
}), AppPlugin.addTranslationsModule({
|
|
20
|
+
translations
|
|
21
|
+
}), AppPlugin.addPluginAssetModule({
|
|
22
|
+
asset: {
|
|
23
|
+
pluginId: meta.id,
|
|
24
|
+
path: "PLUGIN.mdl",
|
|
25
|
+
content: PLUGIN_default,
|
|
26
|
+
mimeType: "application/x-mdl"
|
|
27
|
+
}
|
|
28
|
+
}), Plugin.make);
|
|
29
|
+
var StackPlugin_default = StackPlugin;
|
|
30
|
+
export {
|
|
31
|
+
StackPlugin,
|
|
32
|
+
StackPlugin_default as default
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=StackPlugin.mjs.map
|