@stonecrop/desktop 0.32.0 → 0.34.0
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/README.md +42 -32
- package/dist/assets/index.css +339 -170
- package/dist/desktop.js +483 -137
- package/dist/desktop.js.map +1 -1
- package/dist/src/components/ActionSet.vue.d.ts +6 -1
- package/dist/src/components/ActionSet.vue.d.ts.map +1 -1
- package/dist/src/components/Desktop.vue.d.ts +18 -2
- package/dist/src/components/Desktop.vue.d.ts.map +1 -1
- package/dist/src/components/SheetNav.vue.d.ts +11 -1
- package/dist/src/components/SheetNav.vue.d.ts.map +1 -1
- package/dist/src/composables/useActionSet.d.ts +23 -0
- package/dist/src/composables/useActionSet.d.ts.map +1 -0
- package/dist/src/icons/index.d.ts +22 -0
- package/dist/src/icons/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +5 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/plugins/index.d.ts.map +1 -1
- package/dist/src/sheet-nav-toolbar.d.ts +8 -0
- package/dist/src/sheet-nav-toolbar.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +27 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
A three-view UI shell for Stonecrop applications. Renders a doctype list → records list → record form layout driven by the host application's Registry and HST state.
|
|
4
4
|
|
|
5
|
-
Desktop reads through Stonecrop
|
|
5
|
+
Desktop reads through Stonecrop: on navigating to a list or a record it calls `Stonecrop.getRecords` / `Stonecrop.getRecord`, which fetch through the host's registered `DataClient` and write into HST. Writes are the host's: Desktop emits `action` and the host dispatches it.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Three-view layout**: doctypes → records → record form, navigated by route or adapter
|
|
10
|
-
- **ActionSet
|
|
10
|
+
- **ActionSet tile column**: expandable tile UI with Search, host slots, and an Actions drawer; FSM transitions populate the actions list automatically from the doctype workflow
|
|
11
11
|
- **CommandPalette**: `Ctrl+K` / `Cmd+K` search across doctypes and records
|
|
12
|
-
- **SheetNav**: tabbed navigation between open records
|
|
12
|
+
- **SheetNav**: tabbed navigation between open records, with a toolbar for host controls in the footer (see [Slots](#slots))
|
|
13
13
|
- **Event-driven**: all significant interactions emit typed events for the host to respond to
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
@@ -28,7 +28,7 @@ import planDoctype from './doctypes/plan.json'
|
|
|
28
28
|
|
|
29
29
|
const app = createApp(App)
|
|
30
30
|
|
|
31
|
-
// The plugin constructs the Registry itself and provides it as `$registry
|
|
31
|
+
// The plugin constructs the Registry itself and provides it as `$registry`; it does not
|
|
32
32
|
// accept one. Register doctypes on that instance, after install.
|
|
33
33
|
app.use(Stonecrop, { router, client: new RestDataClient() })
|
|
34
34
|
|
|
@@ -38,8 +38,7 @@ registry.addDoctype(Doctype.fromObject(planDoctype))
|
|
|
38
38
|
app.mount('#app')
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
`client` is the `DataClient` Desktop reads through. It can also be supplied later with
|
|
42
|
-
`stonecrop.setClient(client)` — Nuxt hosts do this from a plugin via `useStonecropSetup().registerClient`.
|
|
41
|
+
`client` is the `DataClient` Desktop reads through. It can also be supplied later with `stonecrop.setClient(client)`; Nuxt hosts do this from a plugin via `useStonecropSetup().registerClient`.
|
|
43
42
|
|
|
44
43
|
## Basic Usage
|
|
45
44
|
|
|
@@ -50,7 +49,7 @@ import { useClientAction } from '@stonecrop/stonecrop'
|
|
|
50
49
|
|
|
51
50
|
// Runs an action's clientHandler when the doctype declares one, dispatches to the server
|
|
52
51
|
// otherwise, and reconciles the store and the route with the identity the server settled on.
|
|
53
|
-
// In a Nuxt host this is auto-imported
|
|
52
|
+
// In a Nuxt host this is auto-imported, so drop the import line.
|
|
54
53
|
const { run } = useClientAction()
|
|
55
54
|
</script>
|
|
56
55
|
|
|
@@ -67,27 +66,49 @@ const { run } = useClientAction()
|
|
|
67
66
|
| Prop | Type | Default | Description |
|
|
68
67
|
|------|------|---------|-------------|
|
|
69
68
|
| `availableDoctypes` | `string[]` | `[]` | Doctype slugs to display in the doctypes list |
|
|
70
|
-
| `routeAdapter` | `RouteAdapter` |
|
|
69
|
+
| `routeAdapter` | `RouteAdapter` | none | Custom routing layer (required for Nuxt/custom hosts) |
|
|
70
|
+
| `actionSetSlots` | `ActionSetSlot[]` | `[]` | Host drawer slots shown as tiles in ActionSet |
|
|
71
|
+
| `hostActions` | `ActionElements[]` | none | Actions listed in the Actions drawer in place of those derived from the doctype; `[]` lists none |
|
|
71
72
|
|
|
72
|
-
Record identity is not a prop. It is declared per doctype (`primaryKey`, falling back to `id`) and
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
Record identity is not a prop. It is declared per doctype (`primaryKey`, falling back to `id`) and resolved through `Doctype.getRecordId`, so a row's link always matches the key the record is stored under. One shell renders many doctypes, so a single prop could never answer this correctly.
|
|
74
|
+
|
|
75
|
+
## Slots
|
|
76
|
+
|
|
77
|
+
| Slot | Renders |
|
|
78
|
+
|------|---------|
|
|
79
|
+
| `sheetnav-toolbar` | Host controls in the footer, immediately left of the navigation tabs |
|
|
80
|
+
|
|
81
|
+
A control deeper in the page than this slot can reach, such as a custom field inside the record form, teleports into the same place:
|
|
82
|
+
|
|
83
|
+
```vue
|
|
84
|
+
<script setup lang="ts">
|
|
85
|
+
import { SHEET_NAV_TOOLBAR_SELECTOR } from '@stonecrop/desktop'
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<Teleport :to="SHEET_NAV_TOOLBAR_SELECTOR">
|
|
90
|
+
<MyToolbar />
|
|
91
|
+
</Teleport>
|
|
92
|
+
</template>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Mount one SheetNav per page: with two, teleported content lands in the first and SheetNav logs a warning. When the toolbar and the tabs do not fit on one row, the toolbar moves to a row above the tabs. The Nuxt playground's country records (`/country/US`) carry a working example.
|
|
75
96
|
|
|
76
97
|
## Emitted Events
|
|
77
98
|
|
|
78
99
|
| Event | When |
|
|
79
100
|
|-------|------|
|
|
80
|
-
| `action` | User triggers a declared action
|
|
101
|
+
| `action` | User triggers a declared action: an FSM transition or a Command |
|
|
81
102
|
| `navigate` | Desktop wants to change views |
|
|
82
103
|
| `record:open` | User opens a specific record |
|
|
83
|
-
| `load-records` | Desktop is about to read a records list (notification
|
|
84
|
-
| `load-record` | Desktop is about to read a single record (notification
|
|
104
|
+
| `load-records` | Desktop is about to read a records list (a notification: Desktop performs the read) |
|
|
105
|
+
| `load-record` | Desktop is about to read a single record (a notification: Desktop performs the read) |
|
|
85
106
|
|
|
86
107
|
See [api.md](./api.md) for payload type definitions.
|
|
87
108
|
|
|
88
109
|
### Event Handling Notes
|
|
89
110
|
|
|
90
|
-
- **action**: Desktop merges `Doctype.getAvailableTransitions` and `Doctype.getAvailableCommands`, both resolved against `Stonecrop.getRecordState`, into
|
|
111
|
+
- **action**: Desktop merges `Doctype.getAvailableTransitions` and `Doctype.getAvailableCommands`, both resolved against `Stonecrop.getRecordState`, into the ActionSet Actions drawer. **Desktop never dispatches**: that is the host application's responsibility.
|
|
91
112
|
- **load-records / load-record**: notifications, not fetch requests. Desktop reads through `Stonecrop.getRecords` / `Stonecrop.getRecord` itself, using the registered `DataClient`; these events announce that read so a host can hang analytics off it. A host that fetches here races Desktop's own read into the same HST key. `load-record` is not emitted for a draft, which has nothing to fetch.
|
|
92
113
|
|
|
93
114
|
## Router Adapter
|
|
@@ -125,13 +146,9 @@ function useCustomRouteAdapter(): RouteAdapter {
|
|
|
125
146
|
|
|
126
147
|
## Handling `action` Events
|
|
127
148
|
|
|
128
|
-
Dispatching is not the whole job: the result has to land in HST under the identity the *server*
|
|
129
|
-
settled on, which for a newly created record is not the id that was dispatched.
|
|
149
|
+
Dispatching is not the whole job: the result has to land in HST under the identity the *server* settled on, which for a newly created record is not the id that was dispatched.
|
|
130
150
|
|
|
131
|
-
Bind `@action` to `useClientAction`'s `run`, as in Basic Usage above. It runs an action's
|
|
132
|
-
`clientHandler` when it has one, dispatches otherwise, and reconciles the store and the route. It
|
|
133
|
-
lives in `@stonecrop/stonecrop`, so every Vue 3 host gets the same one; Nuxt hosts also get it as an
|
|
134
|
-
auto-import from `@stonecrop/nuxt`.
|
|
151
|
+
Bind `@action` to `useClientAction`'s `run`, as in Basic Usage above. It runs an action's `clientHandler` when it has one, dispatches otherwise, and reconciles the store and the route. It lives in `@stonecrop/stonecrop`, so every Vue 3 host gets the same one; Nuxt hosts also get it as an auto-import from `@stonecrop/nuxt`.
|
|
135
152
|
|
|
136
153
|
Three things are adjustable, for the cases that genuinely differ between applications:
|
|
137
154
|
|
|
@@ -141,18 +158,11 @@ Three things are adjustable, for the cases that genuinely differ between applica
|
|
|
141
158
|
| `followRecord` | `router.replace('/{doctype}/{id}')` | a locale prefix, a nested route, or staying put |
|
|
142
159
|
| `onError` | a blocking `window.alert` | your own notification system |
|
|
143
160
|
|
|
144
|
-
`args` is an opaque JSON array: nothing validates it, so both ends of your own stack have to agree.
|
|
145
|
-
A backend taking positional `[recordId, data]` supplies `buildArgs` to say so.
|
|
161
|
+
`args` is an opaque JSON array: nothing validates it, so both ends of your own stack have to agree. A backend taking positional `[recordId, data]` supplies `buildArgs` to say so.
|
|
146
162
|
|
|
147
|
-
Resolving a record's identity and keying it into HST are deliberately **not** adjustable. That rule
|
|
148
|
-
is declared on the doctype and re-derived server-side by the adapter, and every host that re-derived
|
|
149
|
-
it client-side got it wrong. If you dispatch through `Stonecrop.dispatchAction` directly instead of
|
|
150
|
-
using this composable, that method still files the returned record under the settled identity — you
|
|
151
|
-
cannot store it under the wrong key by accident. What you lose is the stale-key cleanup and the
|
|
152
|
-
route-follow, which need the id you dispatched.
|
|
163
|
+
Resolving a record's identity and keying it into HST are deliberately **not** adjustable. That rule is declared on the doctype and re-derived server-side by the adapter, and every host that re-derived it client-side got it wrong. If you dispatch through `Stonecrop.dispatchAction` directly instead of using this composable, that method still files the returned record under the settled identity, so you cannot store it under the wrong key by accident. What you lose is the stale-key cleanup and the route-follow, which need the id you dispatched.
|
|
153
164
|
|
|
154
|
-
Do not copy form data into HST before dispatching. Desktop already hands you the current form
|
|
155
|
-
snapshot in `payload.data`, and an unsaved record has no HST node to write to.
|
|
165
|
+
Do not copy form data into HST before dispatching. Desktop already hands you the current form snapshot in `payload.data`, and an unsaved record has no HST node to write to.
|
|
156
166
|
|
|
157
167
|
See the [host integration guide](../nuxt/documentation/content/guides/desktop-integration.md) for the full wiring.
|
|
158
168
|
|
|
@@ -169,4 +179,4 @@ const { navigateToDoctype, openRecord, createNewRecord, emitAction } =
|
|
|
169
179
|
|
|
170
180
|
`emitAction(name, data?)` is a convenience wrapper for emitting an `action` event from deeply nested slot content without passing refs down manually.
|
|
171
181
|
|
|
172
|
-
Desktop blesses no action name. It used to expose a `handleDelete` method and a `confirmFn` prop, which together emitted a hardcoded `DELETE` action and prompted before it
|
|
182
|
+
Desktop blesses no action name. It used to expose a `handleDelete` method and a `confirmFn` prop, which together emitted a hardcoded `DELETE` action and prompted before it; but no doctype declares `DELETE`, so it failed on every click, and only the host knows which of its actions are destructive. Removal is a workflow outcome: declare an action with a `nextState` such as `Archived` or `CANCELLED`, and confirm inside your own `@action` handler before dispatching.
|