@stonecrop/stonecrop 0.31.0 → 0.32.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/dist/stonecrop.js +3548 -2740
- package/dist/stonecrop.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +33 -27
- package/dist/src/client-action.d.ts +0 -31
- package/dist/src/client-action.d.ts.map +0 -1
- package/dist/src/client-action.js +0 -169
- package/dist/src/client-handler.d.ts +0 -43
- package/dist/src/client-handler.d.ts.map +0 -1
- package/dist/src/client-handler.js +0 -42
- package/dist/src/composables/lazy-link.d.ts +0 -25
- package/dist/src/composables/lazy-link.d.ts.map +0 -1
- package/dist/src/composables/lazy-link.js +0 -124
- package/dist/src/composables/operation-log.d.ts +0 -136
- package/dist/src/composables/operation-log.d.ts.map +0 -1
- package/dist/src/composables/operation-log.js +0 -224
- package/dist/src/composables/stonecrop.d.ts +0 -37
- package/dist/src/composables/stonecrop.d.ts.map +0 -1
- package/dist/src/composables/stonecrop.js +0 -433
- package/dist/src/doctype.d.ts +0 -243
- package/dist/src/doctype.d.ts.map +0 -1
- package/dist/src/doctype.js +0 -325
- package/dist/src/draft.d.ts +0 -35
- package/dist/src/draft.d.ts.map +0 -1
- package/dist/src/draft.js +0 -36
- package/dist/src/exceptions.d.ts +0 -14
- package/dist/src/exceptions.d.ts.map +0 -1
- package/dist/src/exceptions.js +0 -16
- package/dist/src/field-triggers.d.ts +0 -184
- package/dist/src/field-triggers.d.ts.map +0 -1
- package/dist/src/field-triggers.js +0 -577
- package/dist/src/index.d.ts +0 -25
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -39
- package/dist/src/plugins/index.d.ts +0 -35
- package/dist/src/plugins/index.d.ts.map +0 -1
- package/dist/src/plugins/index.js +0 -98
- package/dist/src/registry.d.ts +0 -161
- package/dist/src/registry.d.ts.map +0 -1
- package/dist/src/registry.js +0 -384
- package/dist/src/schema-validator.d.ts +0 -78
- package/dist/src/schema-validator.d.ts.map +0 -1
- package/dist/src/schema-validator.js +0 -398
- package/dist/src/stonecrop.d.ts +0 -539
- package/dist/src/stonecrop.d.ts.map +0 -1
- package/dist/src/stonecrop.js +0 -610
- package/dist/src/stores/hst.d.ts +0 -92
- package/dist/src/stores/hst.d.ts.map +0 -1
- package/dist/src/stores/hst.js +0 -487
- package/dist/src/stores/index.d.ts +0 -9
- package/dist/src/stores/index.d.ts.map +0 -1
- package/dist/src/stores/index.js +0 -13
- package/dist/src/stores/operation-log.d.ts +0 -262
- package/dist/src/stores/operation-log.d.ts.map +0 -1
- package/dist/src/stores/operation-log.js +0 -571
- package/dist/src/stores/validation.d.ts +0 -83
- package/dist/src/stores/validation.d.ts.map +0 -1
- package/dist/src/stores/validation.js +0 -104
- package/dist/src/types/client-action.d.ts +0 -121
- package/dist/src/types/client-action.d.ts.map +0 -1
- package/dist/src/types/client-action.js +0 -0
- package/dist/src/types/composable.d.ts +0 -268
- package/dist/src/types/composable.d.ts.map +0 -1
- package/dist/src/types/composable.js +0 -0
- package/dist/src/types/doctype.d.ts +0 -34
- package/dist/src/types/doctype.d.ts.map +0 -1
- package/dist/src/types/doctype.js +0 -0
- package/dist/src/types/field-triggers.d.ts +0 -186
- package/dist/src/types/field-triggers.d.ts.map +0 -1
- package/dist/src/types/field-triggers.js +0 -4
- package/dist/src/types/hst.d.ts +0 -70
- package/dist/src/types/hst.d.ts.map +0 -1
- package/dist/src/types/hst.js +0 -0
- package/dist/src/types/index.d.ts +0 -11
- package/dist/src/types/index.d.ts.map +0 -1
- package/dist/src/types/index.js +0 -11
- package/dist/src/types/operation-log.d.ts +0 -163
- package/dist/src/types/operation-log.d.ts.map +0 -1
- package/dist/src/types/operation-log.js +0 -0
- package/dist/src/types/plugin.d.ts +0 -37
- package/dist/src/types/plugin.d.ts.map +0 -1
- package/dist/src/types/plugin.js +0 -0
- package/dist/src/types/registry.d.ts +0 -11
- package/dist/src/types/registry.d.ts.map +0 -1
- package/dist/src/types/registry.js +0 -0
- package/dist/src/types/schema-validator.d.ts +0 -66
- package/dist/src/types/schema-validator.d.ts.map +0 -1
- package/dist/src/types/schema-validator.js +0 -13
- package/dist/src/types/stonecrop.d.ts +0 -32
- package/dist/src/types/stonecrop.d.ts.map +0 -1
- package/dist/src/types/stonecrop.js +0 -0
- package/dist/stonecrop.tsbuildinfo +0 -1
- package/src/client-action.ts +0 -207
- package/src/client-handler.ts +0 -55
- package/src/composables/lazy-link.ts +0 -145
- package/src/composables/operation-log.ts +0 -257
- package/src/composables/stonecrop.ts +0 -556
- package/src/doctype.ts +0 -360
- package/src/draft.ts +0 -38
- package/src/exceptions.ts +0 -16
- package/src/field-triggers.ts +0 -686
- package/src/index.ts +0 -81
- package/src/plugins/index.ts +0 -113
- package/src/registry.ts +0 -433
- package/src/schema-validator.ts +0 -476
- package/src/stonecrop.ts +0 -721
- package/src/stores/hst.ts +0 -626
- package/src/stores/index.ts +0 -21
- package/src/stores/operation-log.ts +0 -675
- package/src/stores/validation.ts +0 -138
- package/src/types/client-action.ts +0 -121
- package/src/types/composable.ts +0 -288
- package/src/types/doctype.ts +0 -35
- package/src/types/field-triggers.ts +0 -201
- package/src/types/hst.ts +0 -77
- package/src/types/index.ts +0 -11
- package/src/types/operation-log.ts +0 -202
- package/src/types/plugin.ts +0 -38
- package/src/types/registry.ts +0 -10
- package/src/types/schema-validator.ts +0 -69
- package/src/types/stonecrop.ts +0 -33
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import type { HSTNode } from '../types/hst';
|
|
2
|
-
import type { OperationLogConfig } from '../types/operation-log';
|
|
3
|
-
/**
|
|
4
|
-
* Composable for operation log management
|
|
5
|
-
* Provides easy access to undo/redo functionality and operation history
|
|
6
|
-
*
|
|
7
|
-
* @param config - Optional configuration for the operation log
|
|
8
|
-
* @returns Operation log interface
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const { undo, redo, canUndo, canRedo, operations, configure } = useOperationLog()
|
|
13
|
-
*
|
|
14
|
-
* // Configure the log
|
|
15
|
-
* configure({
|
|
16
|
-
* maxOperations: 50,
|
|
17
|
-
* enableCrossTabSync: true,
|
|
18
|
-
* enablePersistence: true
|
|
19
|
-
* })
|
|
20
|
-
*
|
|
21
|
-
* // Undo/redo
|
|
22
|
-
* await undo(hstStore)
|
|
23
|
-
* await redo(hstStore)
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @public
|
|
27
|
-
*/
|
|
28
|
-
export declare function useOperationLog(config?: Partial<OperationLogConfig>): {
|
|
29
|
-
operations: import("vue").Ref<{
|
|
30
|
-
id: string;
|
|
31
|
-
type: import("..").HSTOperationType;
|
|
32
|
-
path: string;
|
|
33
|
-
fieldname: string;
|
|
34
|
-
beforeValue: any;
|
|
35
|
-
afterValue: any;
|
|
36
|
-
doctype: string;
|
|
37
|
-
recordId?: string | undefined;
|
|
38
|
-
timestamp: Date;
|
|
39
|
-
source?: import("..").OperationSource | undefined;
|
|
40
|
-
reversible: boolean;
|
|
41
|
-
irreversibleReason?: string | undefined;
|
|
42
|
-
transition?: string | undefined;
|
|
43
|
-
currentState?: string | undefined;
|
|
44
|
-
targetState?: string | undefined;
|
|
45
|
-
actionName?: string | undefined;
|
|
46
|
-
actionRecordIds?: string[] | undefined;
|
|
47
|
-
actionResult?: "success" | "failure" | "pending" | undefined;
|
|
48
|
-
actionError?: string | undefined;
|
|
49
|
-
userId?: string | undefined;
|
|
50
|
-
metadata?: Record<string, any> | undefined;
|
|
51
|
-
ancestorOperationId?: string | undefined;
|
|
52
|
-
descendantOperationIds?: string[] | undefined;
|
|
53
|
-
}[], import("..").HSTOperation[] | {
|
|
54
|
-
id: string;
|
|
55
|
-
type: import("..").HSTOperationType;
|
|
56
|
-
path: string;
|
|
57
|
-
fieldname: string;
|
|
58
|
-
beforeValue: any;
|
|
59
|
-
afterValue: any;
|
|
60
|
-
doctype: string;
|
|
61
|
-
recordId?: string | undefined;
|
|
62
|
-
timestamp: Date;
|
|
63
|
-
source?: import("..").OperationSource | undefined;
|
|
64
|
-
reversible: boolean;
|
|
65
|
-
irreversibleReason?: string | undefined;
|
|
66
|
-
transition?: string | undefined;
|
|
67
|
-
currentState?: string | undefined;
|
|
68
|
-
targetState?: string | undefined;
|
|
69
|
-
actionName?: string | undefined;
|
|
70
|
-
actionRecordIds?: string[] | undefined;
|
|
71
|
-
actionResult?: "success" | "failure" | "pending" | undefined;
|
|
72
|
-
actionError?: string | undefined;
|
|
73
|
-
userId?: string | undefined;
|
|
74
|
-
metadata?: Record<string, any> | undefined;
|
|
75
|
-
ancestorOperationId?: string | undefined;
|
|
76
|
-
descendantOperationIds?: string[] | undefined;
|
|
77
|
-
}[]>;
|
|
78
|
-
currentIndex: import("vue").Ref<number, number>;
|
|
79
|
-
undoRedoState: import("vue").ComputedRef<import("..").UndoRedoState>;
|
|
80
|
-
canUndo: import("vue").ComputedRef<boolean>;
|
|
81
|
-
canRedo: import("vue").ComputedRef<boolean>;
|
|
82
|
-
undoCount: import("vue").ComputedRef<number>;
|
|
83
|
-
redoCount: import("vue").ComputedRef<number>;
|
|
84
|
-
undo: (hstStore: HSTNode) => boolean;
|
|
85
|
-
redo: (hstStore: HSTNode) => boolean;
|
|
86
|
-
startBatch: () => void;
|
|
87
|
-
commitBatch: (description?: string) => string | null;
|
|
88
|
-
cancelBatch: () => void;
|
|
89
|
-
clear: () => void;
|
|
90
|
-
getOperationsFor: (doctype: string, recordId?: string) => import("..").HSTOperation[];
|
|
91
|
-
getSnapshot: () => import("..").OperationLogSnapshot;
|
|
92
|
-
markIrreversible: (operationId: string, reason: string) => void;
|
|
93
|
-
logAction: (doctype: string, actionName: string, recordIds?: string[], result?: "success" | "failure" | "pending", error?: string) => string;
|
|
94
|
-
configure: (options: Partial<OperationLogConfig>) => void;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Keyboard shortcut handler for undo/redo
|
|
98
|
-
* Automatically binds Ctrl+Z (undo) and Ctrl+Shift+Z/Ctrl+Y (redo) using VueUse
|
|
99
|
-
*
|
|
100
|
-
* @param hstStore - The HST store to operate on
|
|
101
|
-
* @param enabled - Whether shortcuts are enabled (default: true)
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```typescript
|
|
105
|
-
* import { onMounted } from 'vue'
|
|
106
|
-
*
|
|
107
|
-
* const stonecrop = useStonecrop({ doctype, recordId })
|
|
108
|
-
* useUndoRedoShortcuts(stonecrop.hstStore)
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @public
|
|
112
|
-
*/
|
|
113
|
-
export declare function useUndoRedoShortcuts(hstStore: HSTNode, enabled?: boolean): void;
|
|
114
|
-
/**
|
|
115
|
-
* Batch operation helper
|
|
116
|
-
* Wraps a function execution in a batch operation
|
|
117
|
-
*
|
|
118
|
-
* @param fn - The function to execute within a batch
|
|
119
|
-
* @param description - Optional description for the batch
|
|
120
|
-
* @returns The batch operation ID
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* const { withBatch } = useOperationLog()
|
|
125
|
-
*
|
|
126
|
-
* const batchId = await withBatch(() => {
|
|
127
|
-
* hstStore.set('task.123.title', 'New Title')
|
|
128
|
-
* hstStore.set('task.123.status', 'active')
|
|
129
|
-
* hstStore.set('task.123.priority', 'high')
|
|
130
|
-
* }, 'Update task details')
|
|
131
|
-
* ```
|
|
132
|
-
*
|
|
133
|
-
* @public
|
|
134
|
-
*/
|
|
135
|
-
export declare function withBatch<T>(fn: () => T | Promise<T>, description?: string): Promise<string | null>;
|
|
136
|
-
//# sourceMappingURL=operation-log.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operation-log.d.ts","sourceRoot":"","sources":["../../../src/composables/operation-log.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoB3C,OAAO,KAAG,OAAO;qBAOjB,OAAO,KAAG,OAAO;;gCAcN,MAAM,KAAG,MAAM,GAAG,IAAI;;;gCAqBtB,MAAM,aAAa,MAAM;;oCAgBrB,MAAM,UAAU,MAAM;yBAcnD,MAAM,cACH,MAAM,cACN,MAAM,EAAE,WACZ,SAAS,GAAG,SAAS,GAAG,SAAS,UACjC,MAAM,KACZ,MAAM;yBAQmB,OAAO,CAAC,kBAAkB,CAAC;EA2BvD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,UAAO,QAqCrE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYzG"}
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { useMagicKeys, whenever } from '@vueuse/core';
|
|
2
|
-
import { storeToRefs } from 'pinia';
|
|
3
|
-
import { getCurrentInstance, inject } from 'vue';
|
|
4
|
-
import { useOperationLogStore } from '../stores/operation-log';
|
|
5
|
-
/**
|
|
6
|
-
* Composable for operation log management
|
|
7
|
-
* Provides easy access to undo/redo functionality and operation history
|
|
8
|
-
*
|
|
9
|
-
* @param config - Optional configuration for the operation log
|
|
10
|
-
* @returns Operation log interface
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const { undo, redo, canUndo, canRedo, operations, configure } = useOperationLog()
|
|
15
|
-
*
|
|
16
|
-
* // Configure the log
|
|
17
|
-
* configure({
|
|
18
|
-
* maxOperations: 50,
|
|
19
|
-
* enableCrossTabSync: true,
|
|
20
|
-
* enablePersistence: true
|
|
21
|
-
* })
|
|
22
|
-
*
|
|
23
|
-
* // Undo/redo
|
|
24
|
-
* await undo(hstStore)
|
|
25
|
-
* await redo(hstStore)
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
export function useOperationLog(config) {
|
|
31
|
-
// inject() is only valid inside a component setup() context. When this
|
|
32
|
-
// composable is called outside one (e.g. directly in test bodies or plain
|
|
33
|
-
// scripts) skip the injection entirely and fall back to the Pinia store.
|
|
34
|
-
const injectedStore = getCurrentInstance()
|
|
35
|
-
? inject('$operationLogStore', undefined)
|
|
36
|
-
: undefined;
|
|
37
|
-
const store = injectedStore || useOperationLogStore();
|
|
38
|
-
// Apply configuration if provided
|
|
39
|
-
if (config) {
|
|
40
|
-
store.configure(config);
|
|
41
|
-
}
|
|
42
|
-
// Extract reactive state
|
|
43
|
-
const { operations, currentIndex, undoRedoState, canUndo, canRedo, undoCount, redoCount } = storeToRefs(store);
|
|
44
|
-
/**
|
|
45
|
-
* Undo the last operation
|
|
46
|
-
*/
|
|
47
|
-
function undo(hstStore) {
|
|
48
|
-
return store.undo(hstStore);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Redo the next operation
|
|
52
|
-
*/
|
|
53
|
-
function redo(hstStore) {
|
|
54
|
-
return store.redo(hstStore);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Start a batch operation
|
|
58
|
-
*/
|
|
59
|
-
function startBatch() {
|
|
60
|
-
store.startBatch();
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Commit the current batch
|
|
64
|
-
*/
|
|
65
|
-
function commitBatch(description) {
|
|
66
|
-
return store.commitBatch(description);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Cancel the current batch
|
|
70
|
-
*/
|
|
71
|
-
function cancelBatch() {
|
|
72
|
-
store.cancelBatch();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Clear all operations
|
|
76
|
-
*/
|
|
77
|
-
function clear() {
|
|
78
|
-
store.clear();
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get operations for a specific doctype/record
|
|
82
|
-
*/
|
|
83
|
-
function getOperationsFor(doctype, recordId) {
|
|
84
|
-
return store.getOperationsFor(doctype, recordId);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Get a snapshot of the operation log
|
|
88
|
-
*/
|
|
89
|
-
function getSnapshot() {
|
|
90
|
-
return store.getSnapshot();
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Mark an operation as irreversible
|
|
94
|
-
* @param operationId - The ID of the operation to mark
|
|
95
|
-
* @param reason - The reason why the operation is irreversible
|
|
96
|
-
*/
|
|
97
|
-
function markIrreversible(operationId, reason) {
|
|
98
|
-
store.markIrreversible(operationId, reason);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Log an action execution (stateless actions like print, email, etc.)
|
|
102
|
-
* @param doctype - The doctype the action was executed on
|
|
103
|
-
* @param actionName - The name of the action that was executed
|
|
104
|
-
* @param recordIds - Optional array of record IDs the action was executed on
|
|
105
|
-
* @param result - The result of the action execution
|
|
106
|
-
* @param error - Optional error message if action failed
|
|
107
|
-
* @returns The operation ID
|
|
108
|
-
*/
|
|
109
|
-
function logAction(doctype, actionName, recordIds, result = 'success', error) {
|
|
110
|
-
return store.logAction(doctype, actionName, recordIds, result, error);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Update configuration
|
|
114
|
-
* @param options - Configuration options to update
|
|
115
|
-
*/
|
|
116
|
-
function configure(options) {
|
|
117
|
-
store.configure(options);
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
// State
|
|
121
|
-
operations,
|
|
122
|
-
currentIndex,
|
|
123
|
-
undoRedoState,
|
|
124
|
-
canUndo,
|
|
125
|
-
canRedo,
|
|
126
|
-
undoCount,
|
|
127
|
-
redoCount,
|
|
128
|
-
// Methods
|
|
129
|
-
undo,
|
|
130
|
-
redo,
|
|
131
|
-
startBatch,
|
|
132
|
-
commitBatch,
|
|
133
|
-
cancelBatch,
|
|
134
|
-
clear,
|
|
135
|
-
getOperationsFor,
|
|
136
|
-
getSnapshot,
|
|
137
|
-
markIrreversible,
|
|
138
|
-
logAction,
|
|
139
|
-
configure,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Keyboard shortcut handler for undo/redo
|
|
144
|
-
* Automatically binds Ctrl+Z (undo) and Ctrl+Shift+Z/Ctrl+Y (redo) using VueUse
|
|
145
|
-
*
|
|
146
|
-
* @param hstStore - The HST store to operate on
|
|
147
|
-
* @param enabled - Whether shortcuts are enabled (default: true)
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```typescript
|
|
151
|
-
* import { onMounted } from 'vue'
|
|
152
|
-
*
|
|
153
|
-
* const stonecrop = useStonecrop({ doctype, recordId })
|
|
154
|
-
* useUndoRedoShortcuts(stonecrop.hstStore)
|
|
155
|
-
* ```
|
|
156
|
-
*
|
|
157
|
-
* @public
|
|
158
|
-
*/
|
|
159
|
-
export function useUndoRedoShortcuts(hstStore, enabled = true) {
|
|
160
|
-
if (!enabled)
|
|
161
|
-
return;
|
|
162
|
-
const { undo, redo, canUndo, canRedo } = useOperationLog();
|
|
163
|
-
const keys = useMagicKeys();
|
|
164
|
-
// Undo shortcuts: Ctrl+Z or Cmd+Z (Mac)
|
|
165
|
-
whenever(keys['Ctrl+Z'], () => {
|
|
166
|
-
if (canUndo.value) {
|
|
167
|
-
undo(hstStore);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
whenever(keys['Meta+Z'], () => {
|
|
171
|
-
if (canUndo.value) {
|
|
172
|
-
undo(hstStore);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
// Redo shortcuts: Ctrl+Shift+Z, Cmd+Shift+Z (Mac), or Ctrl+Y
|
|
176
|
-
whenever(keys['Ctrl+Shift+Z'], () => {
|
|
177
|
-
if (canRedo.value) {
|
|
178
|
-
redo(hstStore);
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
whenever(keys['Meta+Shift+Z'], () => {
|
|
182
|
-
if (canRedo.value) {
|
|
183
|
-
redo(hstStore);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
whenever(keys['Ctrl+Y'], () => {
|
|
187
|
-
if (canRedo.value) {
|
|
188
|
-
redo(hstStore);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Batch operation helper
|
|
194
|
-
* Wraps a function execution in a batch operation
|
|
195
|
-
*
|
|
196
|
-
* @param fn - The function to execute within a batch
|
|
197
|
-
* @param description - Optional description for the batch
|
|
198
|
-
* @returns The batch operation ID
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```typescript
|
|
202
|
-
* const { withBatch } = useOperationLog()
|
|
203
|
-
*
|
|
204
|
-
* const batchId = await withBatch(() => {
|
|
205
|
-
* hstStore.set('task.123.title', 'New Title')
|
|
206
|
-
* hstStore.set('task.123.status', 'active')
|
|
207
|
-
* hstStore.set('task.123.priority', 'high')
|
|
208
|
-
* }, 'Update task details')
|
|
209
|
-
* ```
|
|
210
|
-
*
|
|
211
|
-
* @public
|
|
212
|
-
*/
|
|
213
|
-
export async function withBatch(fn, description) {
|
|
214
|
-
const { startBatch, commitBatch, cancelBatch } = useOperationLog();
|
|
215
|
-
startBatch();
|
|
216
|
-
try {
|
|
217
|
-
await fn();
|
|
218
|
-
return commitBatch(description);
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
cancelBatch();
|
|
222
|
-
throw error;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import Doctype from '../doctype';
|
|
2
|
-
import Registry from '../registry';
|
|
3
|
-
import type { BaseStonecropReturn, HSTStonecropReturn } from '../types/composable';
|
|
4
|
-
/**
|
|
5
|
-
* Unified Stonecrop composable - handles both general operations and HST reactive integration.
|
|
6
|
-
*
|
|
7
|
-
* Called with no doctype, it returns the Stonecrop instance and the operation log, and touches
|
|
8
|
-
* the network not at all. Name a doctype to get the HST surface.
|
|
9
|
-
*
|
|
10
|
-
* @returns The Stonecrop instance and the operation log
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export declare function useStonecrop(): BaseStonecropReturn;
|
|
14
|
-
/**
|
|
15
|
-
* Unified Stonecrop composable with HST integration for a specific doctype and record.
|
|
16
|
-
*
|
|
17
|
-
* When a `Doctype` instance is passed, all synchronous initialisation (`hstStore`,
|
|
18
|
-
* `resolvedSchema`, `formData`, `handleHSTChange`, operation-log wiring) is performed
|
|
19
|
-
* during `setup()` — before the first render and without awaiting any lifecycle hook.
|
|
20
|
-
* Callers can read `hstStore.value`, `resolvedSchema.value`, and `formData.value`
|
|
21
|
-
* immediately after calling this composable; no `nextTick`, `flushPromises`, or
|
|
22
|
-
* `setTimeout` is required.
|
|
23
|
-
*
|
|
24
|
-
* The only async work in `onMounted` is fetching an existing record from the server when
|
|
25
|
-
* `recordId` is not a draft, and lazy-loading a doctype by slug string. Both need a doctype
|
|
26
|
-
* named here — nothing is inferred from the route.
|
|
27
|
-
*
|
|
28
|
-
* @param options - Configuration with doctype (string slug or Doctype instance) and optional recordId
|
|
29
|
-
* @returns Stonecrop instance with full HST integration utilities
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export declare function useStonecrop(options: {
|
|
33
|
-
registry?: Registry;
|
|
34
|
-
doctype: Doctype | string;
|
|
35
|
-
recordId?: string;
|
|
36
|
-
}): HSTStonecropReturn;
|
|
37
|
-
//# sourceMappingURL=stonecrop.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../../src/composables/stonecrop.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,YAAY,CAAA;AAEhC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAGlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAkC,MAAM,qBAAqB,CAAA;AAIlH;;;;;;;;GAQG;AACH,wBAAgB,YAAY,IAAI,mBAAmB,CAAA;AACnD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACrC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,OAAO,EAAE,OAAO,GAAG,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,kBAAkB,CAAA"}
|