@stonecrop/desktop 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/desktop.d.ts +42 -2
- package/dist/desktop.js +61 -46
- package/dist/desktop.js.map +1 -1
- package/dist/desktop.umd.cjs +1 -1
- package/dist/desktop.umd.cjs.map +1 -1
- package/dist/plugins/index.js +1 -2
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/plugins/index.d.ts +1 -2
- package/dist/src/plugins/index.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +37 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/dist/types/index.js +0 -0
- package/package.json +5 -5
- package/src/components/ActionSet.vue +5 -18
- package/src/index.ts +1 -0
- package/src/plugins/index.ts +1 -2
- package/src/types/index.ts +41 -0
package/dist/desktop.d.ts
CHANGED
|
@@ -5,19 +5,59 @@ import { Plugin as Plugin_2 } from 'vue';
|
|
|
5
5
|
import Records from './components/Records.vue';
|
|
6
6
|
import SheetNav from './components/SheetNav.vue';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Superset of all element types in the Action Set
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare type ActionElements = ButtonElement | DropdownElement;
|
|
13
|
+
|
|
8
14
|
export { ActionSet }
|
|
9
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Base type for elements in the Action Set
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare type BaseElement = {
|
|
21
|
+
label: string;
|
|
22
|
+
show?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Button elements
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare type ButtonElement = BaseElement & ElementAction & {
|
|
30
|
+
type: 'button';
|
|
31
|
+
};
|
|
32
|
+
|
|
10
33
|
export { CommandPalette }
|
|
11
34
|
|
|
12
35
|
export { Doctype }
|
|
13
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Dropdown elements
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare type DropdownElement = BaseElement & {
|
|
42
|
+
type: 'dropdown';
|
|
43
|
+
actions: ElementAction[];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Element actions
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare type ElementAction = BaseElement & {
|
|
51
|
+
link?: string;
|
|
52
|
+
action?: () => void;
|
|
53
|
+
};
|
|
54
|
+
|
|
14
55
|
export { Records }
|
|
15
56
|
|
|
16
57
|
export { SheetNav }
|
|
17
58
|
|
|
18
59
|
/**
|
|
19
|
-
* This is the main plugin
|
|
20
|
-
* that we want to use in our application.
|
|
60
|
+
* This is the main plugin that will be used to register all the desktop components.
|
|
21
61
|
* @public
|
|
22
62
|
*/
|
|
23
63
|
export declare const StonecropDesktop: Plugin_2;
|
package/dist/desktop.js
CHANGED
|
@@ -11,7 +11,7 @@ const es = { class: "action-menu-icon" }, ts = ["onclick"], ns = { key: 1 }, os
|
|
|
11
11
|
});
|
|
12
12
|
const a = () => {
|
|
13
13
|
for (const d of t.value)
|
|
14
|
-
d.
|
|
14
|
+
d.type === "dropdown" && (d.show = !1);
|
|
15
15
|
}, i = () => {
|
|
16
16
|
r.value = !0, o.value = setTimeout(() => {
|
|
17
17
|
r.value && (n.value = !0);
|
|
@@ -69,12 +69,12 @@ const es = { class: "action-menu-icon" }, ts = ["onclick"], ns = { key: 1 }, os
|
|
|
69
69
|
class: "action-element",
|
|
70
70
|
key: p.label
|
|
71
71
|
}, [
|
|
72
|
-
p.
|
|
72
|
+
p.type == "button" ? (A(), B("button", {
|
|
73
73
|
key: 0,
|
|
74
74
|
onclick: p.action,
|
|
75
75
|
class: "button-default"
|
|
76
76
|
}, ve(p.label), 9, ts)) : ge("", !0),
|
|
77
|
-
p.
|
|
77
|
+
p.type == "dropdown" ? (A(), B("div", ns, [
|
|
78
78
|
W("button", {
|
|
79
79
|
class: "button-default",
|
|
80
80
|
onClick: (h) => c(f)
|
|
@@ -108,7 +108,7 @@ const es = { class: "action-menu-icon" }, ts = ["onclick"], ns = { key: 1 }, os
|
|
|
108
108
|
for (const [o, r] of t)
|
|
109
109
|
n[o] = r;
|
|
110
110
|
return n;
|
|
111
|
-
}, us = /* @__PURE__ */ En(ls, [["__scopeId", "data-v-
|
|
111
|
+
}, us = /* @__PURE__ */ En(ls, [["__scopeId", "data-v-38e7af34"]]), ds = {};
|
|
112
112
|
function ps(e, t) {
|
|
113
113
|
return A(), B("dialog");
|
|
114
114
|
}
|
|
@@ -174,18 +174,18 @@ on.prototype = Object.create(Error.prototype, {
|
|
|
174
174
|
});
|
|
175
175
|
const Mo = class kt {
|
|
176
176
|
/**
|
|
177
|
-
* @
|
|
178
|
-
* @param
|
|
179
|
-
* @param
|
|
180
|
-
* @param
|
|
181
|
-
* @param
|
|
182
|
-
* @
|
|
183
|
-
* @returns {Stonecrop} The Stonecrop instance
|
|
184
|
-
* @description The Stonecrop constructor initializes a new Stonecrop instance with the given registry, store, schema, workflow, and actions. If a Stonecrop instance has already been created, it returns the existing instance instead of creating a new one.
|
|
177
|
+
* @param registry - The immutable registry
|
|
178
|
+
* @param store - The mutable Pinia store
|
|
179
|
+
* @param schema - The Stonecrop schema
|
|
180
|
+
* @param workflow - The Stonecrop workflow
|
|
181
|
+
* @param actions - The Stonecrop actions
|
|
182
|
+
* @returns The Stonecrop instance with the given registry, store, schema, workflow, and actions. If a Stonecrop instance has already been created, it returns the existing instance instead of creating a new one.
|
|
185
183
|
* @example
|
|
184
|
+
* ```ts
|
|
186
185
|
* const registry = new Registry()
|
|
187
186
|
* const store = useDataStore()
|
|
188
|
-
* const stonecrop = new Stonecrop(registry, store
|
|
187
|
+
* const stonecrop = new Stonecrop(registry, store)
|
|
188
|
+
* ```
|
|
189
189
|
*/
|
|
190
190
|
constructor(t, n, o, r, s) {
|
|
191
191
|
if (oe(this, "name", "Stonecrop"), oe(this, "registry"), oe(this, "schema"), oe(this, "workflow"), oe(this, "actions"), oe(this, "store"), kt._root)
|
|
@@ -193,70 +193,73 @@ const Mo = class kt {
|
|
|
193
193
|
kt._root = this, this.registry = t, this.store = n, this.schema = o, this.workflow = r, this.actions = s;
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
|
-
*
|
|
197
|
-
* @param
|
|
198
|
-
* @returns {void}
|
|
199
|
-
* @description Sets up the Stonecrop instance with the given doctype
|
|
196
|
+
* Sets up the Stonecrop instance with the given doctype
|
|
197
|
+
* @param doctype - The doctype to setup
|
|
200
198
|
* @example
|
|
199
|
+
* ```ts
|
|
201
200
|
* const doctype = await registry.getMeta('Task')
|
|
202
201
|
* stonecrop.setup(doctype)
|
|
202
|
+
* ```
|
|
203
203
|
*/
|
|
204
204
|
setup(t) {
|
|
205
205
|
this.getMeta(t), this.getWorkflow(t), this.getActions(t);
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
|
-
*
|
|
209
|
-
* @param
|
|
210
|
-
* @returns
|
|
211
|
-
* @see {@link DoctypeMeta}
|
|
208
|
+
* Gets the meta for the given doctype
|
|
209
|
+
* @param doctype - The doctype to get meta for
|
|
210
|
+
* @returns The meta for the given doctype
|
|
212
211
|
* @throws NotImplementedError
|
|
213
|
-
* @description Gets the meta for the given doctype
|
|
214
212
|
* @example
|
|
213
|
+
* ```ts
|
|
215
214
|
* const doctype = await registry.getMeta('Task')
|
|
216
215
|
* const meta = stonecrop.getMeta(doctype)
|
|
216
|
+
* ```
|
|
217
|
+
* @see {@link DoctypeMeta}
|
|
217
218
|
*/
|
|
218
219
|
getMeta(t) {
|
|
219
220
|
return this.registry.getMeta ? this.registry.getMeta(t.doctype) : new on(t.doctype);
|
|
220
221
|
}
|
|
221
222
|
/**
|
|
222
|
-
*
|
|
223
|
-
* @param
|
|
224
|
-
* @returns {void}
|
|
225
|
-
* @description Gets the workflow for the given doctype
|
|
223
|
+
* Gets the workflow for the given doctype
|
|
224
|
+
* @param doctype - The doctype to get workflow for
|
|
226
225
|
* @example
|
|
226
|
+
* ```ts
|
|
227
227
|
* const doctype = await registry.getMeta('Task')
|
|
228
228
|
* stonecrop.getWorkflow(doctype)
|
|
229
|
+
* ```
|
|
229
230
|
*/
|
|
230
231
|
getWorkflow(t) {
|
|
231
232
|
const n = this.registry.registry[t.slug];
|
|
232
233
|
this.workflow = n.workflow;
|
|
233
234
|
}
|
|
234
235
|
/**
|
|
235
|
-
*
|
|
236
|
-
* @param
|
|
237
|
-
* @returns {void}
|
|
238
|
-
* @description Gets the actions for the given doctype
|
|
236
|
+
* Gets the actions for the given doctype
|
|
237
|
+
* @param doctype - The doctype to get actions for
|
|
239
238
|
* @example
|
|
239
|
+
* ```ts
|
|
240
240
|
* const doctype = await registry.getMeta('Task')
|
|
241
241
|
* stonecrop.getActions(doctype)
|
|
242
|
+
* ```
|
|
242
243
|
*/
|
|
243
244
|
getActions(t) {
|
|
244
245
|
const n = this.registry.registry[t.slug];
|
|
245
246
|
this.actions = n.actions;
|
|
246
247
|
}
|
|
247
248
|
/**
|
|
248
|
-
*
|
|
249
|
-
* @param
|
|
250
|
-
* @param
|
|
251
|
-
* @returns {Promise<void>}
|
|
252
|
-
* @description Gets the records for the given doctype
|
|
249
|
+
* Gets the records for the given doctype
|
|
250
|
+
* @param doctype - The doctype to get records for
|
|
251
|
+
* @param filters - The filters to apply to the records
|
|
253
252
|
* @example
|
|
253
|
+
* ```ts
|
|
254
254
|
* const doctype = await registry.getMeta('Task')
|
|
255
255
|
* await stonecrop.getRecords(doctype)
|
|
256
|
+
* ```
|
|
256
257
|
* @example
|
|
258
|
+
* ```ts
|
|
257
259
|
* const doctype = await registry.getMeta('Task')
|
|
258
260
|
* const filters = JSON.stringify({ status: 'Open' })
|
|
259
261
|
* await stonecrop.getRecords(doctype, { body: filters })
|
|
262
|
+
* ```
|
|
260
263
|
*/
|
|
261
264
|
async getRecords(t, n) {
|
|
262
265
|
this.store.$patch({ records: [] });
|
|
@@ -264,14 +267,14 @@ const Mo = class kt {
|
|
|
264
267
|
this.store.$patch({ records: o });
|
|
265
268
|
}
|
|
266
269
|
/**
|
|
267
|
-
*
|
|
268
|
-
* @param
|
|
269
|
-
* @param
|
|
270
|
-
* @returns {Promise<void>}
|
|
271
|
-
* @description Gets the record for the given doctype and id
|
|
270
|
+
* Gets the record for the given doctype and id
|
|
271
|
+
* @param doctype - The doctype to get record for
|
|
272
|
+
* @param id - The id of the record to get
|
|
272
273
|
* @example
|
|
274
|
+
* ```ts
|
|
273
275
|
* const doctype = await registry.getMeta('Task')
|
|
274
276
|
* await stonecrop.getRecord(doctype, 'TASK-00001')
|
|
277
|
+
* ```
|
|
275
278
|
*/
|
|
276
279
|
async getRecord(t, n) {
|
|
277
280
|
this.store.$patch({ record: {} });
|
|
@@ -279,24 +282,30 @@ const Mo = class kt {
|
|
|
279
282
|
this.store.$patch({ record: o });
|
|
280
283
|
}
|
|
281
284
|
/**
|
|
282
|
-
*
|
|
283
|
-
* @param
|
|
284
|
-
* @param
|
|
285
|
-
* @param
|
|
286
|
-
* @returns {void}
|
|
287
|
-
* @description Runs the action for the given doctype and id
|
|
285
|
+
* Runs the action for the given doctype and id
|
|
286
|
+
* @param doctype - The doctype to run action for
|
|
287
|
+
* @param action - The action to run
|
|
288
|
+
* @param id - The id(s) of the record(s) to run action on
|
|
288
289
|
* @example
|
|
290
|
+
* ```ts
|
|
289
291
|
* const doctype = await registry.getMeta('Task')
|
|
290
292
|
* stonecrop.runAction(doctype, 'CREATE')
|
|
293
|
+
* ```
|
|
291
294
|
* @example
|
|
295
|
+
* ```ts
|
|
292
296
|
* const doctype = await registry.getMeta('Task')
|
|
293
297
|
* stonecrop.runAction(doctype, 'UPDATE', ['TASK-00001'])
|
|
298
|
+
* ```
|
|
294
299
|
* @example
|
|
300
|
+
* ```ts
|
|
295
301
|
* const doctype = await registry.getMeta('Task')
|
|
296
302
|
* stonecrop.runAction(doctype, 'DELETE', ['TASK-00001'])
|
|
303
|
+
* ```
|
|
297
304
|
* @example
|
|
305
|
+
* ```ts
|
|
298
306
|
* const doctype = await registry.getMeta('Task')
|
|
299
307
|
* stonecrop.runAction(doctype, 'TRANSITION', ['TASK-00001', 'TASK-00002'])
|
|
308
|
+
* ```
|
|
300
309
|
*/
|
|
301
310
|
runAction(t, n, o) {
|
|
302
311
|
const r = this.registry.registry[t.slug].actions.get(n), { initialState: s } = this.workflow;
|
|
@@ -1291,6 +1300,12 @@ const Ks = class St {
|
|
|
1291
1300
|
return St._root;
|
|
1292
1301
|
St._root = this, this.name = "Registry", this.router = t, this.registry = {}, this.getMeta = n;
|
|
1293
1302
|
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Get doctype metadata
|
|
1305
|
+
* @param doctype - The doctype to fetch metadata for
|
|
1306
|
+
* @returns The doctype metadata
|
|
1307
|
+
* @see {@link DoctypeMeta}
|
|
1308
|
+
*/
|
|
1294
1309
|
addDoctype(t) {
|
|
1295
1310
|
t.doctype in Object.keys(this.registry) || (this.registry[t.slug] = t), this.router.hasRoute(t.doctype) || this.router.addRoute({
|
|
1296
1311
|
path: `/${t.slug}`,
|