@stonecrop/desktop 0.10.1 → 0.10.3
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 +184 -7
- package/dist/desktop.d.ts +49 -0
- package/dist/desktop.js +1615 -1622
- package/dist/desktop.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +45 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/package.json +15 -6
- package/src/components/Desktop.vue +157 -251
- package/src/index.ts +1 -0
- package/src/types/index.ts +49 -0
package/dist/desktop.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as be, ref as $, onMounted as xe, openBlock as P, createElementBlock as j, normalizeClass as De, createElementVNode as x, Fragment as ue, renderList as ye, toDisplayString as X, createCommentVNode as ce, withDirectives as Oe, vShow as Je, useTemplateRef as pt, computed as R, watch as H, nextTick as de, createBlock as Qe, Teleport as Ot, createVNode as ne, Transition as At, withCtx as me, withModifiers as ft, vModelText as ht, renderSlot as Ve, createTextVNode as Ae, toRaw as vt, isRef as pe, isReactive as Te, toRef as re, hasInjectionContext as ze, inject as we, getCurrentInstance as gt, reactive as yt, markRaw as he, effectScope as $t, getCurrentScope as Xe, onScopeDispose as Ye, toRefs as tt, provide as Ge, shallowRef as Se, toValue as K, readonly as Pe, customRef as et, unref as Ne, useModel as It, watchEffect as Rt, resolveComponent as mt, resolveDynamicComponent as xt, mergeProps as Tt, mergeModels as ot, withKeys as fe, normalizeStyle as je } from "vue";
|
|
2
|
+
const Pt = { class: "action-menu-icon" }, Vt = ["disabled", "onClick"], jt = { key: 1 }, Mt = ["onClick"], Ft = { class: "dropdown-container" }, Lt = { class: "dropdown" }, Bt = ["onClick"], Wt = ["href"], Ht = { class: "dropdown-item" }, Ut = /* @__PURE__ */ be({
|
|
3
3
|
__name: "ActionSet",
|
|
4
4
|
props: {
|
|
5
5
|
elements: { default: () => [] }
|
|
6
6
|
},
|
|
7
7
|
emits: ["actionClick"],
|
|
8
|
-
setup(
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
setup(n, { emit: e }) {
|
|
9
|
+
const t = e, o = $({}), r = $(!1), a = $(-1), s = $(!1), c = $(!1);
|
|
10
|
+
xe(() => {
|
|
11
|
+
d();
|
|
12
12
|
});
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const d = () => {
|
|
14
|
+
o.value = {};
|
|
15
|
+
}, u = () => {
|
|
16
|
+
s.value = !0, a.value = setTimeout(() => {
|
|
17
|
+
s.value && (r.value = !0);
|
|
18
18
|
}, 500);
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
const m = !
|
|
23
|
-
|
|
24
|
-
}, h = (
|
|
25
|
-
|
|
19
|
+
}, w = () => {
|
|
20
|
+
s.value = !1, c.value = !1, clearTimeout(a.value), r.value = !1;
|
|
21
|
+
}, v = (b) => {
|
|
22
|
+
const m = !o.value[b];
|
|
23
|
+
d(), m && (o.value[b] = !0);
|
|
24
|
+
}, h = (b, m) => {
|
|
25
|
+
t("actionClick", m, b);
|
|
26
26
|
};
|
|
27
|
-
return (
|
|
28
|
-
class:
|
|
29
|
-
onMouseover:
|
|
30
|
-
onMouseleave:
|
|
27
|
+
return (b, m) => (P(), j("div", {
|
|
28
|
+
class: De([{ "open-set": r.value, "hovered-and-closed": c.value }, "action-set collapse"]),
|
|
29
|
+
onMouseover: u,
|
|
30
|
+
onMouseleave: w
|
|
31
31
|
}, [
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
x("div", Pt, [
|
|
33
|
+
x("div", {
|
|
34
34
|
id: "chevron",
|
|
35
|
-
onClick: m[0] || (m[0] = (
|
|
35
|
+
onClick: m[0] || (m[0] = (k) => c.value = !c.value)
|
|
36
36
|
}, [...m[1] || (m[1] = [
|
|
37
|
-
|
|
37
|
+
x("svg", {
|
|
38
38
|
id: "Layer_1",
|
|
39
39
|
class: "leftBar",
|
|
40
40
|
version: "1.1",
|
|
@@ -47,9 +47,9 @@ const jt = { class: "action-menu-icon" }, Mt = ["disabled", "onClick"], Ft = { k
|
|
|
47
47
|
width: "50",
|
|
48
48
|
height: "50"
|
|
49
49
|
}, [
|
|
50
|
-
|
|
50
|
+
x("polygon", { points: "54.2,33.4 29.2,58.8 25,54.6 50,29.2 " })
|
|
51
51
|
], -1),
|
|
52
|
-
|
|
52
|
+
x("svg", {
|
|
53
53
|
id: "Layer_1",
|
|
54
54
|
class: "rightBar",
|
|
55
55
|
version: "1.1",
|
|
@@ -62,62 +62,62 @@ const jt = { class: "action-menu-icon" }, Mt = ["disabled", "onClick"], Ft = { k
|
|
|
62
62
|
width: "50",
|
|
63
63
|
height: "50"
|
|
64
64
|
}, [
|
|
65
|
-
|
|
65
|
+
x("polygon", { points: "70.8,58.8 45.8,33.4 50,29.2 75,54.6 " })
|
|
66
66
|
], -1)
|
|
67
67
|
])])
|
|
68
68
|
]),
|
|
69
|
-
m[2] || (m[2] =
|
|
70
|
-
(P(!0),
|
|
71
|
-
key:
|
|
69
|
+
m[2] || (m[2] = x("div", { style: { "margin-right": "30px" } }, null, -1)),
|
|
70
|
+
(P(!0), j(ue, null, ye(n.elements, (k, I) => (P(), j("div", {
|
|
71
|
+
key: k.label,
|
|
72
72
|
class: "action-element"
|
|
73
73
|
}, [
|
|
74
|
-
|
|
74
|
+
k.type == "button" ? (P(), j("button", {
|
|
75
75
|
key: 0,
|
|
76
|
-
disabled:
|
|
76
|
+
disabled: k.disabled,
|
|
77
77
|
class: "button-default",
|
|
78
|
-
onClick: (
|
|
79
|
-
}, X(
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
onClick: (T) => h(k.action, k.label)
|
|
79
|
+
}, X(k.label), 9, Vt)) : ce("", !0),
|
|
80
|
+
k.type == "dropdown" ? (P(), j("div", jt, [
|
|
81
|
+
x("button", {
|
|
82
82
|
class: "button-default",
|
|
83
|
-
onClick: (
|
|
84
|
-
}, X(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
(P(!0),
|
|
88
|
-
key:
|
|
83
|
+
onClick: (T) => v(I)
|
|
84
|
+
}, X(k.label), 9, Mt),
|
|
85
|
+
Oe(x("div", Ft, [
|
|
86
|
+
x("div", Lt, [
|
|
87
|
+
(P(!0), j(ue, null, ye(k.actions, (T, Z) => (P(), j("div", {
|
|
88
|
+
key: T.label
|
|
89
89
|
}, [
|
|
90
|
-
|
|
90
|
+
T.action != null ? (P(), j("button", {
|
|
91
91
|
key: 0,
|
|
92
92
|
class: "dropdown-item",
|
|
93
|
-
onClick: (U) => h(
|
|
94
|
-
}, X(
|
|
93
|
+
onClick: (U) => h(T.action, T.label)
|
|
94
|
+
}, X(T.label), 9, Bt)) : T.link != null ? (P(), j("a", {
|
|
95
95
|
key: 1,
|
|
96
|
-
href:
|
|
96
|
+
href: T.link
|
|
97
97
|
}, [
|
|
98
|
-
|
|
99
|
-
], 8,
|
|
98
|
+
x("button", Ht, X(T.label), 1)
|
|
99
|
+
], 8, Wt)) : ce("", !0)
|
|
100
100
|
]))), 128))
|
|
101
101
|
])
|
|
102
102
|
], 512), [
|
|
103
|
-
[
|
|
103
|
+
[Je, o.value[I]]
|
|
104
104
|
])
|
|
105
|
-
])) :
|
|
105
|
+
])) : ce("", !0)
|
|
106
106
|
]))), 128))
|
|
107
107
|
], 34));
|
|
108
108
|
}
|
|
109
|
-
}),
|
|
110
|
-
const
|
|
111
|
-
for (const [
|
|
112
|
-
o
|
|
113
|
-
return
|
|
114
|
-
},
|
|
109
|
+
}), wt = (n, e) => {
|
|
110
|
+
const t = n.__vccOpts || n;
|
|
111
|
+
for (const [o, r] of e)
|
|
112
|
+
t[o] = r;
|
|
113
|
+
return t;
|
|
114
|
+
}, bt = /* @__PURE__ */ wt(Ut, [["__scopeId", "data-v-eb01c863"]]), Jt = { class: "command-palette-header" }, zt = ["placeholder"], Gt = {
|
|
115
115
|
key: 0,
|
|
116
116
|
class: "command-palette-results"
|
|
117
|
-
},
|
|
117
|
+
}, qt = ["onClick", "onMouseover"], Kt = { class: "result-title" }, Zt = { class: "result-content" }, Qt = {
|
|
118
118
|
key: 1,
|
|
119
119
|
class: "command-palette-no-results"
|
|
120
|
-
}, St = /* @__PURE__ */
|
|
120
|
+
}, St = /* @__PURE__ */ be({
|
|
121
121
|
__name: "CommandPalette",
|
|
122
122
|
props: {
|
|
123
123
|
search: { type: Function },
|
|
@@ -126,913 +126,913 @@ const jt = { class: "action-menu-icon" }, Mt = ["disabled", "onClick"], Ft = { k
|
|
|
126
126
|
maxResults: { default: 10 }
|
|
127
127
|
},
|
|
128
128
|
emits: ["select", "close"],
|
|
129
|
-
setup(
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
() =>
|
|
133
|
-
async (
|
|
134
|
-
|
|
129
|
+
setup(n, { emit: e }) {
|
|
130
|
+
const t = e, o = $(""), r = $(0), a = pt("input"), s = R(() => o.value ? n.search(o.value).slice(0, n.maxResults) : []);
|
|
131
|
+
H(
|
|
132
|
+
() => n.isOpen,
|
|
133
|
+
async (w) => {
|
|
134
|
+
w && (o.value = "", r.value = 0, await de(), a.value?.focus());
|
|
135
135
|
}
|
|
136
|
-
),
|
|
136
|
+
), H(s, () => {
|
|
137
137
|
r.value = 0;
|
|
138
138
|
});
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
},
|
|
142
|
-
switch (
|
|
139
|
+
const c = () => {
|
|
140
|
+
t("close");
|
|
141
|
+
}, d = (w) => {
|
|
142
|
+
switch (w.key) {
|
|
143
143
|
case "Escape":
|
|
144
|
-
|
|
144
|
+
c();
|
|
145
145
|
break;
|
|
146
146
|
case "ArrowDown":
|
|
147
|
-
|
|
147
|
+
w.preventDefault(), s.value.length && (r.value = (r.value + 1) % s.value.length);
|
|
148
148
|
break;
|
|
149
149
|
case "ArrowUp":
|
|
150
|
-
|
|
150
|
+
w.preventDefault(), s.value.length && (r.value = (r.value - 1 + s.value.length) % s.value.length);
|
|
151
151
|
break;
|
|
152
152
|
case "Enter":
|
|
153
|
-
|
|
153
|
+
s.value.length && r.value >= 0 && u(s.value[r.value]);
|
|
154
154
|
break;
|
|
155
155
|
}
|
|
156
|
-
},
|
|
157
|
-
|
|
156
|
+
}, u = (w) => {
|
|
157
|
+
t("select", w), c();
|
|
158
158
|
};
|
|
159
|
-
return (
|
|
160
|
-
ne(
|
|
161
|
-
default:
|
|
162
|
-
|
|
159
|
+
return (w, v) => (P(), Qe(Ot, { to: "body" }, [
|
|
160
|
+
ne(At, { name: "fade" }, {
|
|
161
|
+
default: me(() => [
|
|
162
|
+
n.isOpen ? (P(), j("div", {
|
|
163
163
|
key: 0,
|
|
164
164
|
class: "command-palette-overlay",
|
|
165
|
-
onClick:
|
|
165
|
+
onClick: c
|
|
166
166
|
}, [
|
|
167
|
-
|
|
167
|
+
x("div", {
|
|
168
168
|
class: "command-palette",
|
|
169
|
-
onClick:
|
|
169
|
+
onClick: v[1] || (v[1] = ft(() => {
|
|
170
170
|
}, ["stop"]))
|
|
171
171
|
}, [
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
x("div", Jt, [
|
|
173
|
+
Oe(x("input", {
|
|
174
174
|
ref: "input",
|
|
175
|
-
"onUpdate:modelValue":
|
|
175
|
+
"onUpdate:modelValue": v[0] || (v[0] = (h) => o.value = h),
|
|
176
176
|
type: "text",
|
|
177
177
|
class: "command-palette-input",
|
|
178
|
-
placeholder:
|
|
178
|
+
placeholder: n.placeholder,
|
|
179
179
|
autofocus: "",
|
|
180
|
-
onKeydown:
|
|
181
|
-
}, null, 40,
|
|
182
|
-
[ht,
|
|
180
|
+
onKeydown: d
|
|
181
|
+
}, null, 40, zt), [
|
|
182
|
+
[ht, o.value]
|
|
183
183
|
])
|
|
184
184
|
]),
|
|
185
|
-
|
|
186
|
-
(P(!0),
|
|
187
|
-
key:
|
|
188
|
-
class:
|
|
189
|
-
onClick: (m) =>
|
|
190
|
-
onMouseover: (m) => r.value =
|
|
185
|
+
s.value.length ? (P(), j("div", Gt, [
|
|
186
|
+
(P(!0), j(ue, null, ye(s.value, (h, b) => (P(), j("div", {
|
|
187
|
+
key: b,
|
|
188
|
+
class: De(["command-palette-result", { selected: b === r.value }]),
|
|
189
|
+
onClick: (m) => u(h),
|
|
190
|
+
onMouseover: (m) => r.value = b
|
|
191
191
|
}, [
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
x("div", Kt, [
|
|
193
|
+
Ve(w.$slots, "title", { result: h })
|
|
194
194
|
]),
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
x("div", Zt, [
|
|
196
|
+
Ve(w.$slots, "content", { result: h })
|
|
197
197
|
])
|
|
198
|
-
], 42,
|
|
199
|
-
])) :
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
], 42, qt))), 128))
|
|
199
|
+
])) : o.value && !s.value.length ? (P(), j("div", Qt, [
|
|
200
|
+
Ve(w.$slots, "empty", {}, () => [
|
|
201
|
+
Ae(' No results found for "' + X(o.value) + '" ', 1)
|
|
202
202
|
])
|
|
203
|
-
])) :
|
|
203
|
+
])) : ce("", !0)
|
|
204
204
|
])
|
|
205
|
-
])) :
|
|
205
|
+
])) : ce("", !0)
|
|
206
206
|
]),
|
|
207
207
|
_: 3
|
|
208
208
|
})
|
|
209
209
|
]));
|
|
210
210
|
}
|
|
211
211
|
});
|
|
212
|
-
const
|
|
212
|
+
const ie = typeof window < "u";
|
|
213
213
|
let oe;
|
|
214
|
-
const
|
|
214
|
+
const $e = (n) => oe = n;
|
|
215
215
|
process.env.NODE_ENV;
|
|
216
|
-
const
|
|
216
|
+
const qe = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia") : (
|
|
217
217
|
/* istanbul ignore next */
|
|
218
218
|
/* @__PURE__ */ Symbol()
|
|
219
219
|
);
|
|
220
|
-
function
|
|
221
|
-
return
|
|
220
|
+
function ae(n) {
|
|
221
|
+
return n && typeof n == "object" && Object.prototype.toString.call(n) === "[object Object]" && typeof n.toJSON != "function";
|
|
222
222
|
}
|
|
223
223
|
var ve;
|
|
224
|
-
(function(
|
|
225
|
-
|
|
224
|
+
(function(n) {
|
|
225
|
+
n.direct = "direct", n.patchObject = "patch object", n.patchFunction = "patch function";
|
|
226
226
|
})(ve || (ve = {}));
|
|
227
|
-
function
|
|
228
|
-
for (const
|
|
229
|
-
const
|
|
230
|
-
if (!(
|
|
227
|
+
function _t(n, e) {
|
|
228
|
+
for (const t in e) {
|
|
229
|
+
const o = e[t];
|
|
230
|
+
if (!(t in n))
|
|
231
231
|
continue;
|
|
232
|
-
const r = t
|
|
233
|
-
|
|
232
|
+
const r = n[t];
|
|
233
|
+
ae(r) && ae(o) && !pe(o) && !Te(o) ? n[t] = _t(r, o) : n[t] = o;
|
|
234
234
|
}
|
|
235
|
-
return
|
|
235
|
+
return n;
|
|
236
236
|
}
|
|
237
|
-
const
|
|
237
|
+
const Et = () => {
|
|
238
238
|
};
|
|
239
|
-
function nt(
|
|
240
|
-
|
|
239
|
+
function nt(n, e, t, o = Et) {
|
|
240
|
+
n.add(e);
|
|
241
241
|
const r = () => {
|
|
242
|
-
|
|
242
|
+
n.delete(e) && o();
|
|
243
243
|
};
|
|
244
|
-
return !
|
|
244
|
+
return !t && Xe() && Ye(r), r;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
function se(n, ...e) {
|
|
247
|
+
n.forEach((t) => {
|
|
248
|
+
t(...e);
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
const
|
|
252
|
-
function Ke(
|
|
253
|
-
|
|
254
|
-
for (const
|
|
255
|
-
if (!e.hasOwnProperty(
|
|
251
|
+
const Xt = (n) => n(), rt = /* @__PURE__ */ Symbol(), Me = /* @__PURE__ */ Symbol();
|
|
252
|
+
function Ke(n, e) {
|
|
253
|
+
n instanceof Map && e instanceof Map ? e.forEach((t, o) => n.set(o, t)) : n instanceof Set && e instanceof Set && e.forEach(n.add, n);
|
|
254
|
+
for (const t in e) {
|
|
255
|
+
if (!e.hasOwnProperty(t))
|
|
256
256
|
continue;
|
|
257
|
-
const
|
|
258
|
-
|
|
257
|
+
const o = e[t], r = n[t];
|
|
258
|
+
ae(r) && ae(o) && n.hasOwnProperty(t) && !pe(o) && !Te(o) ? n[t] = Ke(r, o) : n[t] = o;
|
|
259
259
|
}
|
|
260
|
-
return
|
|
260
|
+
return n;
|
|
261
261
|
}
|
|
262
|
-
const
|
|
262
|
+
const Yt = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia:skipHydration") : (
|
|
263
263
|
/* istanbul ignore next */
|
|
264
264
|
/* @__PURE__ */ Symbol()
|
|
265
265
|
);
|
|
266
|
-
function
|
|
267
|
-
return !
|
|
266
|
+
function eo(n) {
|
|
267
|
+
return !ae(n) || !Object.prototype.hasOwnProperty.call(n, Yt);
|
|
268
268
|
}
|
|
269
|
-
const { assign:
|
|
270
|
-
function at(
|
|
271
|
-
return !!(
|
|
269
|
+
const { assign: q } = Object;
|
|
270
|
+
function at(n) {
|
|
271
|
+
return !!(pe(n) && n.effect);
|
|
272
272
|
}
|
|
273
|
-
function st(
|
|
274
|
-
const { state: r, actions:
|
|
275
|
-
let
|
|
276
|
-
function
|
|
277
|
-
!
|
|
278
|
-
const
|
|
273
|
+
function st(n, e, t, o) {
|
|
274
|
+
const { state: r, actions: a, getters: s } = e, c = t.state.value[n];
|
|
275
|
+
let d;
|
|
276
|
+
function u() {
|
|
277
|
+
!c && (process.env.NODE_ENV === "production" || !o) && (t.state.value[n] = r ? r() : {});
|
|
278
|
+
const w = process.env.NODE_ENV !== "production" && o ? (
|
|
279
279
|
// use ref() to unwrap refs inside state TODO: check if this is still necessary
|
|
280
|
-
tt(
|
|
281
|
-
) : tt(
|
|
282
|
-
return
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
return
|
|
286
|
-
})),
|
|
287
|
-
}
|
|
288
|
-
return
|
|
280
|
+
tt($(r ? r() : {}).value)
|
|
281
|
+
) : tt(t.state.value[n]);
|
|
282
|
+
return q(w, a, Object.keys(s || {}).reduce((v, h) => (process.env.NODE_ENV !== "production" && h in w && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${h}" in store "${n}".`), v[h] = he(R(() => {
|
|
283
|
+
$e(t);
|
|
284
|
+
const b = t._s.get(n);
|
|
285
|
+
return s[h].call(b, b);
|
|
286
|
+
})), v), {}));
|
|
287
|
+
}
|
|
288
|
+
return d = Ze(n, u, e, t, o, !0), d;
|
|
289
289
|
}
|
|
290
|
-
function
|
|
291
|
-
let
|
|
292
|
-
const
|
|
293
|
-
if (process.env.NODE_ENV !== "production" && !
|
|
290
|
+
function Ze(n, e, t = {}, o, r, a) {
|
|
291
|
+
let s;
|
|
292
|
+
const c = q({ actions: {} }, t);
|
|
293
|
+
if (process.env.NODE_ENV !== "production" && !o._e.active)
|
|
294
294
|
throw new Error("Pinia destroyed");
|
|
295
|
-
const
|
|
296
|
-
process.env.NODE_ENV !== "production" && (
|
|
297
|
-
|
|
295
|
+
const d = { deep: !0 };
|
|
296
|
+
process.env.NODE_ENV !== "production" && (d.onTrigger = (g) => {
|
|
297
|
+
u ? b = g : u == !1 && !E._hotUpdating && (Array.isArray(b) ? b.push(g) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
|
|
298
298
|
});
|
|
299
|
-
let
|
|
300
|
-
const m =
|
|
301
|
-
!
|
|
302
|
-
const
|
|
303
|
-
let
|
|
304
|
-
function
|
|
305
|
-
let
|
|
306
|
-
|
|
299
|
+
let u, w, v = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), b;
|
|
300
|
+
const m = o.state.value[n];
|
|
301
|
+
!a && !m && (process.env.NODE_ENV === "production" || !r) && (o.state.value[n] = {});
|
|
302
|
+
const k = $({});
|
|
303
|
+
let I;
|
|
304
|
+
function T(g) {
|
|
305
|
+
let y;
|
|
306
|
+
u = w = !1, process.env.NODE_ENV !== "production" && (b = []), typeof g == "function" ? (g(o.state.value[n]), y = {
|
|
307
307
|
type: ve.patchFunction,
|
|
308
|
-
storeId:
|
|
309
|
-
events:
|
|
310
|
-
}) : (Ke(
|
|
308
|
+
storeId: n,
|
|
309
|
+
events: b
|
|
310
|
+
}) : (Ke(o.state.value[n], g), y = {
|
|
311
311
|
type: ve.patchObject,
|
|
312
|
-
payload:
|
|
313
|
-
storeId:
|
|
314
|
-
events:
|
|
312
|
+
payload: g,
|
|
313
|
+
storeId: n,
|
|
314
|
+
events: b
|
|
315
315
|
});
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}),
|
|
320
|
-
}
|
|
321
|
-
const
|
|
322
|
-
const { state:
|
|
323
|
-
this.$patch((
|
|
324
|
-
|
|
316
|
+
const D = I = /* @__PURE__ */ Symbol();
|
|
317
|
+
de().then(() => {
|
|
318
|
+
I === D && (u = !0);
|
|
319
|
+
}), w = !0, se(v, y, o.state.value[n]);
|
|
320
|
+
}
|
|
321
|
+
const Z = a ? function() {
|
|
322
|
+
const { state: y } = t, D = y ? y() : {};
|
|
323
|
+
this.$patch((F) => {
|
|
324
|
+
q(F, D);
|
|
325
325
|
});
|
|
326
326
|
} : (
|
|
327
327
|
/* istanbul ignore next */
|
|
328
328
|
process.env.NODE_ENV !== "production" ? () => {
|
|
329
|
-
throw new Error(`🍍: Store "${
|
|
330
|
-
} :
|
|
329
|
+
throw new Error(`🍍: Store "${n}" is built using the setup syntax and does not implement $reset().`);
|
|
330
|
+
} : Et
|
|
331
331
|
);
|
|
332
332
|
function U() {
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
const
|
|
336
|
-
if (rt in
|
|
337
|
-
return
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
function
|
|
342
|
-
|
|
333
|
+
s.stop(), v.clear(), h.clear(), o._s.delete(n);
|
|
334
|
+
}
|
|
335
|
+
const z = (g, y = "") => {
|
|
336
|
+
if (rt in g)
|
|
337
|
+
return g[Me] = y, g;
|
|
338
|
+
const D = function() {
|
|
339
|
+
$e(o);
|
|
340
|
+
const F = Array.from(arguments), N = /* @__PURE__ */ new Set(), V = /* @__PURE__ */ new Set();
|
|
341
|
+
function M(S) {
|
|
342
|
+
N.add(S);
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
344
|
+
function _(S) {
|
|
345
|
+
V.add(S);
|
|
346
346
|
}
|
|
347
|
-
|
|
348
|
-
args:
|
|
349
|
-
name:
|
|
347
|
+
se(h, {
|
|
348
|
+
args: F,
|
|
349
|
+
name: D[Me],
|
|
350
350
|
store: E,
|
|
351
|
-
after:
|
|
352
|
-
onError:
|
|
351
|
+
after: M,
|
|
352
|
+
onError: _
|
|
353
353
|
});
|
|
354
|
-
let
|
|
354
|
+
let C;
|
|
355
355
|
try {
|
|
356
|
-
|
|
356
|
+
C = g.apply(this && this.$id === n ? this : E, F);
|
|
357
357
|
} catch (S) {
|
|
358
|
-
throw
|
|
358
|
+
throw se(V, S), S;
|
|
359
359
|
}
|
|
360
|
-
return
|
|
360
|
+
return C instanceof Promise ? C.then((S) => (se(N, S), S)).catch((S) => (se(V, S), Promise.reject(S))) : (se(N, C), C);
|
|
361
361
|
};
|
|
362
|
-
return
|
|
363
|
-
},
|
|
362
|
+
return D[rt] = !0, D[Me] = y, D;
|
|
363
|
+
}, L = /* @__PURE__ */ he({
|
|
364
364
|
actions: {},
|
|
365
365
|
getters: {},
|
|
366
366
|
state: [],
|
|
367
|
-
hotState:
|
|
368
|
-
}),
|
|
369
|
-
_p:
|
|
367
|
+
hotState: k
|
|
368
|
+
}), G = {
|
|
369
|
+
_p: o,
|
|
370
370
|
// _s: scope,
|
|
371
|
-
$id:
|
|
371
|
+
$id: n,
|
|
372
372
|
$onAction: nt.bind(null, h),
|
|
373
|
-
$patch:
|
|
374
|
-
$reset:
|
|
375
|
-
$subscribe(
|
|
376
|
-
const
|
|
377
|
-
(
|
|
378
|
-
storeId:
|
|
373
|
+
$patch: T,
|
|
374
|
+
$reset: Z,
|
|
375
|
+
$subscribe(g, y = {}) {
|
|
376
|
+
const D = nt(v, g, y.detached, () => F()), F = s.run(() => H(() => o.state.value[n], (N) => {
|
|
377
|
+
(y.flush === "sync" ? w : u) && g({
|
|
378
|
+
storeId: n,
|
|
379
379
|
type: ve.direct,
|
|
380
|
-
events:
|
|
381
|
-
},
|
|
382
|
-
},
|
|
383
|
-
return
|
|
380
|
+
events: b
|
|
381
|
+
}, N);
|
|
382
|
+
}, q({}, d, y)));
|
|
383
|
+
return D;
|
|
384
384
|
},
|
|
385
385
|
$dispose: U
|
|
386
|
-
}, E =
|
|
386
|
+
}, E = yt(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && ie ? q(
|
|
387
387
|
{
|
|
388
|
-
_hmrPayload:
|
|
388
|
+
_hmrPayload: L,
|
|
389
389
|
_customProperties: he(/* @__PURE__ */ new Set())
|
|
390
390
|
// devtools custom properties
|
|
391
391
|
},
|
|
392
|
-
|
|
392
|
+
G
|
|
393
393
|
// must be added later
|
|
394
394
|
// setupStore
|
|
395
|
-
) :
|
|
396
|
-
|
|
397
|
-
const B = (
|
|
398
|
-
for (const
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
401
|
-
process.env.NODE_ENV !== "production" && r ?
|
|
402
|
-
else if (typeof
|
|
403
|
-
const
|
|
404
|
-
B[
|
|
405
|
-
} else process.env.NODE_ENV !== "production" && at(
|
|
395
|
+
) : G);
|
|
396
|
+
o._s.set(n, E);
|
|
397
|
+
const B = (o._a && o._a.runWithContext || Xt)(() => o._e.run(() => (s = $t()).run(() => e({ action: z }))));
|
|
398
|
+
for (const g in B) {
|
|
399
|
+
const y = B[g];
|
|
400
|
+
if (pe(y) && !at(y) || Te(y))
|
|
401
|
+
process.env.NODE_ENV !== "production" && r ? k.value[g] = re(B, g) : a || (m && eo(y) && (pe(y) ? y.value = m[g] : Ke(y, m[g])), o.state.value[n][g] = y), process.env.NODE_ENV !== "production" && L.state.push(g);
|
|
402
|
+
else if (typeof y == "function") {
|
|
403
|
+
const D = process.env.NODE_ENV !== "production" && r ? y : z(y, g);
|
|
404
|
+
B[g] = D, process.env.NODE_ENV !== "production" && (L.actions[g] = y), c.actions[g] = y;
|
|
405
|
+
} else process.env.NODE_ENV !== "production" && at(y) && (L.getters[g] = a ? (
|
|
406
406
|
// @ts-expect-error
|
|
407
|
-
|
|
408
|
-
) :
|
|
409
|
-
(B._getters = he([]))).push(
|
|
407
|
+
t.getters[g]
|
|
408
|
+
) : y, ie && (B._getters || // @ts-expect-error: same
|
|
409
|
+
(B._getters = he([]))).push(g));
|
|
410
410
|
}
|
|
411
|
-
if (
|
|
412
|
-
get: () => process.env.NODE_ENV !== "production" && r ?
|
|
413
|
-
set: (
|
|
411
|
+
if (q(E, B), q(vt(E), B), Object.defineProperty(E, "$state", {
|
|
412
|
+
get: () => process.env.NODE_ENV !== "production" && r ? k.value : o.state.value[n],
|
|
413
|
+
set: (g) => {
|
|
414
414
|
if (process.env.NODE_ENV !== "production" && r)
|
|
415
415
|
throw new Error("cannot set hotState");
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
T((y) => {
|
|
417
|
+
q(y, g);
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
|
-
}), process.env.NODE_ENV !== "production" && (E._hotUpdate = he((
|
|
421
|
-
E._hotUpdating = !0,
|
|
422
|
-
if (
|
|
423
|
-
const
|
|
424
|
-
typeof
|
|
420
|
+
}), process.env.NODE_ENV !== "production" && (E._hotUpdate = he((g) => {
|
|
421
|
+
E._hotUpdating = !0, g._hmrPayload.state.forEach((y) => {
|
|
422
|
+
if (y in E.$state) {
|
|
423
|
+
const D = g.$state[y], F = E.$state[y];
|
|
424
|
+
typeof D == "object" && ae(D) && ae(F) ? _t(D, F) : g.$state[y] = F;
|
|
425
425
|
}
|
|
426
|
-
E[
|
|
427
|
-
}), Object.keys(E.$state).forEach((
|
|
428
|
-
|
|
429
|
-
}),
|
|
430
|
-
|
|
426
|
+
E[y] = re(g.$state, y);
|
|
427
|
+
}), Object.keys(E.$state).forEach((y) => {
|
|
428
|
+
y in g.$state || delete E[y];
|
|
429
|
+
}), u = !1, w = !1, o.state.value[n] = re(g._hmrPayload, "hotState"), w = !0, de().then(() => {
|
|
430
|
+
u = !0;
|
|
431
431
|
});
|
|
432
|
-
for (const
|
|
433
|
-
const
|
|
434
|
-
E[
|
|
435
|
-
|
|
432
|
+
for (const y in g._hmrPayload.actions) {
|
|
433
|
+
const D = g[y];
|
|
434
|
+
E[y] = //
|
|
435
|
+
z(D, y);
|
|
436
436
|
}
|
|
437
|
-
for (const
|
|
438
|
-
const
|
|
437
|
+
for (const y in g._hmrPayload.getters) {
|
|
438
|
+
const D = g._hmrPayload.getters[y], F = a ? (
|
|
439
439
|
// special handling of options api
|
|
440
|
-
|
|
441
|
-
) :
|
|
442
|
-
E[
|
|
443
|
-
|
|
440
|
+
R(() => ($e(o), D.call(E, E)))
|
|
441
|
+
) : D;
|
|
442
|
+
E[y] = //
|
|
443
|
+
F;
|
|
444
444
|
}
|
|
445
|
-
Object.keys(E._hmrPayload.getters).forEach((
|
|
446
|
-
|
|
447
|
-
}), Object.keys(E._hmrPayload.actions).forEach((
|
|
448
|
-
|
|
449
|
-
}), E._hmrPayload =
|
|
450
|
-
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" &&
|
|
451
|
-
const
|
|
445
|
+
Object.keys(E._hmrPayload.getters).forEach((y) => {
|
|
446
|
+
y in g._hmrPayload.getters || delete E[y];
|
|
447
|
+
}), Object.keys(E._hmrPayload.actions).forEach((y) => {
|
|
448
|
+
y in g._hmrPayload.actions || delete E[y];
|
|
449
|
+
}), E._hmrPayload = g._hmrPayload, E._getters = g._getters, E._hotUpdating = !1;
|
|
450
|
+
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && ie) {
|
|
451
|
+
const g = {
|
|
452
452
|
writable: !0,
|
|
453
453
|
configurable: !0,
|
|
454
454
|
// avoid warning on devtools trying to display this property
|
|
455
455
|
enumerable: !1
|
|
456
456
|
};
|
|
457
|
-
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((
|
|
458
|
-
Object.defineProperty(E,
|
|
457
|
+
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((y) => {
|
|
458
|
+
Object.defineProperty(E, y, q({ value: E[y] }, g));
|
|
459
459
|
});
|
|
460
460
|
}
|
|
461
|
-
return
|
|
462
|
-
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" &&
|
|
463
|
-
const
|
|
461
|
+
return o._p.forEach((g) => {
|
|
462
|
+
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && ie) {
|
|
463
|
+
const y = s.run(() => g({
|
|
464
464
|
store: E,
|
|
465
|
-
app:
|
|
466
|
-
pinia:
|
|
467
|
-
options:
|
|
465
|
+
app: o._a,
|
|
466
|
+
pinia: o,
|
|
467
|
+
options: c
|
|
468
468
|
}));
|
|
469
|
-
Object.keys(
|
|
469
|
+
Object.keys(y || {}).forEach((D) => E._customProperties.add(D)), q(E, y);
|
|
470
470
|
} else
|
|
471
|
-
|
|
471
|
+
q(E, s.run(() => g({
|
|
472
472
|
store: E,
|
|
473
|
-
app:
|
|
474
|
-
pinia:
|
|
475
|
-
options:
|
|
473
|
+
app: o._a,
|
|
474
|
+
pinia: o,
|
|
475
|
+
options: c
|
|
476
476
|
})));
|
|
477
477
|
}), process.env.NODE_ENV !== "production" && E.$state && typeof E.$state == "object" && typeof E.$state.constructor == "function" && !E.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
478
478
|
state: () => new MyClass()
|
|
479
|
-
Found in store "${E.$id}".`), m &&
|
|
479
|
+
Found in store "${E.$id}".`), m && a && t.hydrate && t.hydrate(E.$state, m), u = !0, w = !0, E;
|
|
480
480
|
}
|
|
481
481
|
// @__NO_SIDE_EFFECTS__
|
|
482
|
-
function
|
|
483
|
-
let
|
|
482
|
+
function to(n, e, t) {
|
|
483
|
+
let o;
|
|
484
484
|
const r = typeof e == "function";
|
|
485
|
-
|
|
486
|
-
function
|
|
487
|
-
const
|
|
488
|
-
if (
|
|
485
|
+
o = r ? t : e;
|
|
486
|
+
function a(s, c) {
|
|
487
|
+
const d = ze();
|
|
488
|
+
if (s = // in test mode, ignore the argument provided as we can always retrieve a
|
|
489
489
|
// pinia instance with getActivePinia()
|
|
490
|
-
(process.env.NODE_ENV === "test" && oe && oe._testing ? null :
|
|
490
|
+
(process.env.NODE_ENV === "test" && oe && oe._testing ? null : s) || (d ? we(qe, null) : null), s && $e(s), process.env.NODE_ENV !== "production" && !oe)
|
|
491
491
|
throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
|
|
492
492
|
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
493
493
|
This will fail in production.`);
|
|
494
|
-
|
|
495
|
-
const
|
|
496
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
497
|
-
const
|
|
498
|
-
|
|
494
|
+
s = oe, s._s.has(n) || (r ? Ze(n, e, o, s) : st(n, o, s), process.env.NODE_ENV !== "production" && (a._pinia = s));
|
|
495
|
+
const u = s._s.get(n);
|
|
496
|
+
if (process.env.NODE_ENV !== "production" && c) {
|
|
497
|
+
const w = "__hot:" + n, v = r ? Ze(w, e, o, s, !0) : st(w, q({}, o), s, !0);
|
|
498
|
+
c._hotUpdate(v), delete s.state.value[w], s._s.delete(w);
|
|
499
499
|
}
|
|
500
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
503
|
-
!
|
|
504
|
-
const
|
|
505
|
-
h[
|
|
500
|
+
if (process.env.NODE_ENV !== "production" && ie) {
|
|
501
|
+
const w = gt();
|
|
502
|
+
if (w && w.proxy && // avoid adding stores that are just built for hot module replacement
|
|
503
|
+
!c) {
|
|
504
|
+
const v = w.proxy, h = "_pStores" in v ? v._pStores : v._pStores = {};
|
|
505
|
+
h[n] = u;
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
return
|
|
508
|
+
return u;
|
|
509
509
|
}
|
|
510
|
-
return
|
|
510
|
+
return a.$id = n, a;
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
const e = vt(
|
|
514
|
-
for (const
|
|
515
|
-
const r = e[
|
|
516
|
-
r.effect ? o
|
|
517
|
-
|
|
518
|
-
get: () =>
|
|
519
|
-
set(
|
|
520
|
-
|
|
512
|
+
function oo(n) {
|
|
513
|
+
const e = vt(n), t = {};
|
|
514
|
+
for (const o in e) {
|
|
515
|
+
const r = e[o];
|
|
516
|
+
r.effect ? t[o] = // ...
|
|
517
|
+
R({
|
|
518
|
+
get: () => n[o],
|
|
519
|
+
set(a) {
|
|
520
|
+
n[o] = a;
|
|
521
521
|
}
|
|
522
|
-
}) : (
|
|
523
|
-
re(
|
|
522
|
+
}) : (pe(r) || Te(r)) && (t[o] = // ---
|
|
523
|
+
re(n, o));
|
|
524
524
|
}
|
|
525
|
-
return
|
|
525
|
+
return t;
|
|
526
526
|
}
|
|
527
|
-
const
|
|
527
|
+
const no = typeof window < "u" && typeof document < "u";
|
|
528
528
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
529
|
-
const
|
|
529
|
+
const ro = Object.prototype.toString, ao = (n) => ro.call(n) === "[object Object]", so = () => {
|
|
530
530
|
};
|
|
531
|
-
function
|
|
532
|
-
if (
|
|
533
|
-
const e =
|
|
534
|
-
return typeof e == "function" ?
|
|
531
|
+
function io(...n) {
|
|
532
|
+
if (n.length !== 1) return re(...n);
|
|
533
|
+
const e = n[0];
|
|
534
|
+
return typeof e == "function" ? Pe(et(() => ({
|
|
535
535
|
get: e,
|
|
536
|
-
set:
|
|
537
|
-
}))) :
|
|
536
|
+
set: so
|
|
537
|
+
}))) : $(e);
|
|
538
538
|
}
|
|
539
|
-
function
|
|
540
|
-
function
|
|
541
|
-
return new Promise((r,
|
|
542
|
-
Promise.resolve(
|
|
539
|
+
function lo(n, e) {
|
|
540
|
+
function t(...o) {
|
|
541
|
+
return new Promise((r, a) => {
|
|
542
|
+
Promise.resolve(n(() => e.apply(this, o), {
|
|
543
543
|
fn: e,
|
|
544
544
|
thisArg: this,
|
|
545
|
-
args:
|
|
546
|
-
})).then(r).catch(
|
|
545
|
+
args: o
|
|
546
|
+
})).then(r).catch(a);
|
|
547
547
|
});
|
|
548
548
|
}
|
|
549
|
-
return
|
|
549
|
+
return t;
|
|
550
550
|
}
|
|
551
|
-
const kt = (
|
|
552
|
-
function
|
|
553
|
-
const { initialState:
|
|
551
|
+
const kt = (n) => n();
|
|
552
|
+
function co(n = kt, e = {}) {
|
|
553
|
+
const { initialState: t = "active" } = e, o = io(t === "active");
|
|
554
554
|
function r() {
|
|
555
|
-
|
|
555
|
+
o.value = !1;
|
|
556
556
|
}
|
|
557
|
-
function
|
|
558
|
-
|
|
557
|
+
function a() {
|
|
558
|
+
o.value = !0;
|
|
559
559
|
}
|
|
560
|
-
const
|
|
561
|
-
|
|
560
|
+
const s = (...c) => {
|
|
561
|
+
o.value && n(...c);
|
|
562
562
|
};
|
|
563
563
|
return {
|
|
564
|
-
isActive:
|
|
564
|
+
isActive: Pe(o),
|
|
565
565
|
pause: r,
|
|
566
|
-
resume:
|
|
567
|
-
eventFilter:
|
|
566
|
+
resume: a,
|
|
567
|
+
eventFilter: s
|
|
568
568
|
};
|
|
569
569
|
}
|
|
570
|
-
function
|
|
571
|
-
return Array.isArray(
|
|
570
|
+
function Fe(n) {
|
|
571
|
+
return Array.isArray(n) ? n : [n];
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function uo(n) {
|
|
574
574
|
return gt();
|
|
575
575
|
}
|
|
576
|
-
function
|
|
577
|
-
const { eventFilter:
|
|
578
|
-
return
|
|
576
|
+
function po(n, e, t = {}) {
|
|
577
|
+
const { eventFilter: o = kt, ...r } = t;
|
|
578
|
+
return H(n, lo(o, e), r);
|
|
579
579
|
}
|
|
580
|
-
function
|
|
581
|
-
const { eventFilter:
|
|
580
|
+
function fo(n, e, t = {}) {
|
|
581
|
+
const { eventFilter: o, initialState: r = "active", ...a } = t, { eventFilter: s, pause: c, resume: d, isActive: u } = co(o, { initialState: r });
|
|
582
582
|
return {
|
|
583
|
-
stop:
|
|
584
|
-
...
|
|
585
|
-
eventFilter:
|
|
583
|
+
stop: po(n, e, {
|
|
584
|
+
...a,
|
|
585
|
+
eventFilter: s
|
|
586
586
|
}),
|
|
587
|
-
pause:
|
|
588
|
-
resume:
|
|
589
|
-
isActive:
|
|
587
|
+
pause: c,
|
|
588
|
+
resume: d,
|
|
589
|
+
isActive: u
|
|
590
590
|
};
|
|
591
591
|
}
|
|
592
|
-
function
|
|
593
|
-
|
|
592
|
+
function ho(n, e = !0, t) {
|
|
593
|
+
uo() ? xe(n, t) : e ? n() : de(n);
|
|
594
594
|
}
|
|
595
|
-
function
|
|
596
|
-
return
|
|
597
|
-
...
|
|
595
|
+
function vo(n, e, t) {
|
|
596
|
+
return H(n, e, {
|
|
597
|
+
...t,
|
|
598
598
|
immediate: !0
|
|
599
599
|
});
|
|
600
600
|
}
|
|
601
|
-
const
|
|
602
|
-
function
|
|
601
|
+
const Ie = no ? window : void 0;
|
|
602
|
+
function go(n) {
|
|
603
603
|
var e;
|
|
604
|
-
const
|
|
605
|
-
return (e =
|
|
604
|
+
const t = K(n);
|
|
605
|
+
return (e = t?.$el) !== null && e !== void 0 ? e : t;
|
|
606
606
|
}
|
|
607
|
-
function it(...
|
|
608
|
-
const e = (
|
|
609
|
-
const
|
|
610
|
-
return
|
|
607
|
+
function it(...n) {
|
|
608
|
+
const e = (o, r, a, s) => (o.addEventListener(r, a, s), () => o.removeEventListener(r, a, s)), t = R(() => {
|
|
609
|
+
const o = Fe(K(n[0])).filter((r) => r != null);
|
|
610
|
+
return o.every((r) => typeof r != "string") ? o : void 0;
|
|
611
611
|
});
|
|
612
|
-
return
|
|
613
|
-
var
|
|
612
|
+
return vo(() => {
|
|
613
|
+
var o, r;
|
|
614
614
|
return [
|
|
615
|
-
(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
615
|
+
(o = (r = t.value) === null || r === void 0 ? void 0 : r.map((a) => go(a))) !== null && o !== void 0 ? o : [Ie].filter((a) => a != null),
|
|
616
|
+
Fe(K(t.value ? n[1] : n[0])),
|
|
617
|
+
Fe(Ne(t.value ? n[2] : n[1])),
|
|
618
|
+
K(t.value ? n[3] : n[2])
|
|
619
619
|
];
|
|
620
|
-
}, ([
|
|
621
|
-
if (!
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
620
|
+
}, ([o, r, a, s], c, d) => {
|
|
621
|
+
if (!o?.length || !r?.length || !a?.length) return;
|
|
622
|
+
const u = ao(s) ? { ...s } : s, w = o.flatMap((v) => r.flatMap((h) => a.map((b) => e(v, h, b, u))));
|
|
623
|
+
d(() => {
|
|
624
|
+
w.forEach((v) => v());
|
|
625
625
|
});
|
|
626
626
|
}, { flush: "post" });
|
|
627
627
|
}
|
|
628
|
-
const Ee = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {},
|
|
629
|
-
function
|
|
630
|
-
return
|
|
628
|
+
const Ee = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, ke = "__vueuse_ssr_handlers__", yo = /* @__PURE__ */ mo();
|
|
629
|
+
function mo() {
|
|
630
|
+
return ke in Ee || (Ee[ke] = Ee[ke] || {}), Ee[ke];
|
|
631
631
|
}
|
|
632
|
-
function
|
|
633
|
-
return
|
|
632
|
+
function wo(n, e) {
|
|
633
|
+
return yo[n] || e;
|
|
634
634
|
}
|
|
635
|
-
function
|
|
636
|
-
return
|
|
635
|
+
function bo(n) {
|
|
636
|
+
return n == null ? "any" : n instanceof Set ? "set" : n instanceof Map ? "map" : n instanceof Date ? "date" : typeof n == "boolean" ? "boolean" : typeof n == "string" ? "string" : typeof n == "object" ? "object" : Number.isNaN(n) ? "any" : "number";
|
|
637
637
|
}
|
|
638
|
-
const
|
|
638
|
+
const So = {
|
|
639
639
|
boolean: {
|
|
640
|
-
read: (
|
|
641
|
-
write: (
|
|
640
|
+
read: (n) => n === "true",
|
|
641
|
+
write: (n) => String(n)
|
|
642
642
|
},
|
|
643
643
|
object: {
|
|
644
|
-
read: (
|
|
645
|
-
write: (
|
|
644
|
+
read: (n) => JSON.parse(n),
|
|
645
|
+
write: (n) => JSON.stringify(n)
|
|
646
646
|
},
|
|
647
647
|
number: {
|
|
648
|
-
read: (
|
|
649
|
-
write: (
|
|
648
|
+
read: (n) => Number.parseFloat(n),
|
|
649
|
+
write: (n) => String(n)
|
|
650
650
|
},
|
|
651
651
|
any: {
|
|
652
|
-
read: (
|
|
653
|
-
write: (
|
|
652
|
+
read: (n) => n,
|
|
653
|
+
write: (n) => String(n)
|
|
654
654
|
},
|
|
655
655
|
string: {
|
|
656
|
-
read: (
|
|
657
|
-
write: (
|
|
656
|
+
read: (n) => n,
|
|
657
|
+
write: (n) => String(n)
|
|
658
658
|
},
|
|
659
659
|
map: {
|
|
660
|
-
read: (
|
|
661
|
-
write: (
|
|
660
|
+
read: (n) => new Map(JSON.parse(n)),
|
|
661
|
+
write: (n) => JSON.stringify(Array.from(n.entries()))
|
|
662
662
|
},
|
|
663
663
|
set: {
|
|
664
|
-
read: (
|
|
665
|
-
write: (
|
|
664
|
+
read: (n) => new Set(JSON.parse(n)),
|
|
665
|
+
write: (n) => JSON.stringify(Array.from(n))
|
|
666
666
|
},
|
|
667
667
|
date: {
|
|
668
|
-
read: (
|
|
669
|
-
write: (
|
|
668
|
+
read: (n) => new Date(n),
|
|
669
|
+
write: (n) => n.toISOString()
|
|
670
670
|
}
|
|
671
671
|
}, lt = "vueuse-storage";
|
|
672
|
-
function
|
|
672
|
+
function _o(n, e, t, o = {}) {
|
|
673
673
|
var r;
|
|
674
|
-
const { flush:
|
|
675
|
-
console.error(
|
|
676
|
-
}, initOnMounted: m } =
|
|
677
|
-
if (!
|
|
678
|
-
|
|
679
|
-
} catch (
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
if (!
|
|
683
|
-
const
|
|
684
|
-
flush:
|
|
685
|
-
deep:
|
|
674
|
+
const { flush: a = "pre", deep: s = !0, listenToStorageChanges: c = !0, writeDefaults: d = !0, mergeDefaults: u = !1, shallow: w, window: v = Ie, eventFilter: h, onError: b = (N) => {
|
|
675
|
+
console.error(N);
|
|
676
|
+
}, initOnMounted: m } = o, k = (w ? Se : $)(e), I = R(() => K(n));
|
|
677
|
+
if (!t) try {
|
|
678
|
+
t = wo("getDefaultStorage", () => Ie?.localStorage)();
|
|
679
|
+
} catch (N) {
|
|
680
|
+
b(N);
|
|
681
|
+
}
|
|
682
|
+
if (!t) return k;
|
|
683
|
+
const T = K(e), Z = bo(T), U = (r = o.serializer) !== null && r !== void 0 ? r : So[Z], { pause: z, resume: L } = fo(k, (N) => g(N), {
|
|
684
|
+
flush: a,
|
|
685
|
+
deep: s,
|
|
686
686
|
eventFilter: h
|
|
687
687
|
});
|
|
688
|
-
|
|
689
|
-
let
|
|
690
|
-
const E = (
|
|
691
|
-
m && !
|
|
692
|
-
}, Y = (
|
|
693
|
-
m && !
|
|
688
|
+
H(I, () => D(), { flush: a });
|
|
689
|
+
let G = !1;
|
|
690
|
+
const E = (N) => {
|
|
691
|
+
m && !G || D(N);
|
|
692
|
+
}, Y = (N) => {
|
|
693
|
+
m && !G || F(N);
|
|
694
694
|
};
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
}) :
|
|
698
|
-
function B(
|
|
699
|
-
if (
|
|
700
|
-
const
|
|
701
|
-
key:
|
|
702
|
-
oldValue:
|
|
703
|
-
newValue:
|
|
704
|
-
storageArea:
|
|
695
|
+
v && c && (t instanceof Storage ? it(v, "storage", E, { passive: !0 }) : it(v, lt, Y)), m ? ho(() => {
|
|
696
|
+
G = !0, D();
|
|
697
|
+
}) : D();
|
|
698
|
+
function B(N, V) {
|
|
699
|
+
if (v) {
|
|
700
|
+
const M = {
|
|
701
|
+
key: I.value,
|
|
702
|
+
oldValue: N,
|
|
703
|
+
newValue: V,
|
|
704
|
+
storageArea: t
|
|
705
705
|
};
|
|
706
|
-
|
|
706
|
+
v.dispatchEvent(t instanceof Storage ? new StorageEvent("storage", M) : new CustomEvent(lt, { detail: M }));
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
|
-
function
|
|
709
|
+
function g(N) {
|
|
710
710
|
try {
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
713
|
-
B(
|
|
711
|
+
const V = t.getItem(I.value);
|
|
712
|
+
if (N == null)
|
|
713
|
+
B(V, null), t.removeItem(I.value);
|
|
714
714
|
else {
|
|
715
|
-
const
|
|
716
|
-
|
|
715
|
+
const M = U.write(N);
|
|
716
|
+
V !== M && (t.setItem(I.value, M), B(V, M));
|
|
717
717
|
}
|
|
718
|
-
} catch (
|
|
719
|
-
|
|
718
|
+
} catch (V) {
|
|
719
|
+
b(V);
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
|
-
function
|
|
723
|
-
const
|
|
724
|
-
if (
|
|
725
|
-
return
|
|
726
|
-
if (!
|
|
727
|
-
const
|
|
728
|
-
return typeof
|
|
729
|
-
...
|
|
730
|
-
...
|
|
731
|
-
} :
|
|
732
|
-
} else return typeof
|
|
733
|
-
}
|
|
734
|
-
function
|
|
735
|
-
if (!(
|
|
736
|
-
if (
|
|
737
|
-
|
|
722
|
+
function y(N) {
|
|
723
|
+
const V = N ? N.newValue : t.getItem(I.value);
|
|
724
|
+
if (V == null)
|
|
725
|
+
return d && T != null && t.setItem(I.value, U.write(T)), T;
|
|
726
|
+
if (!N && u) {
|
|
727
|
+
const M = U.read(V);
|
|
728
|
+
return typeof u == "function" ? u(M, T) : Z === "object" && !Array.isArray(M) ? {
|
|
729
|
+
...T,
|
|
730
|
+
...M
|
|
731
|
+
} : M;
|
|
732
|
+
} else return typeof V != "string" ? V : U.read(V);
|
|
733
|
+
}
|
|
734
|
+
function D(N) {
|
|
735
|
+
if (!(N && N.storageArea !== t)) {
|
|
736
|
+
if (N && N.key == null) {
|
|
737
|
+
k.value = T;
|
|
738
738
|
return;
|
|
739
739
|
}
|
|
740
|
-
if (!(
|
|
741
|
-
|
|
740
|
+
if (!(N && N.key !== I.value)) {
|
|
741
|
+
z();
|
|
742
742
|
try {
|
|
743
|
-
const
|
|
744
|
-
(
|
|
745
|
-
} catch (
|
|
746
|
-
|
|
743
|
+
const V = U.write(k.value);
|
|
744
|
+
(N === void 0 || N?.newValue !== V) && (k.value = y(N));
|
|
745
|
+
} catch (V) {
|
|
746
|
+
b(V);
|
|
747
747
|
} finally {
|
|
748
|
-
|
|
748
|
+
N ? de(L) : L();
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
|
-
function
|
|
754
|
-
|
|
753
|
+
function F(N) {
|
|
754
|
+
D(N.detail);
|
|
755
755
|
}
|
|
756
|
-
return
|
|
756
|
+
return k;
|
|
757
757
|
}
|
|
758
|
-
function
|
|
759
|
-
const { window:
|
|
760
|
-
return
|
|
758
|
+
function Eo(n, e, t = {}) {
|
|
759
|
+
const { window: o = Ie } = t;
|
|
760
|
+
return _o(n, e, o?.localStorage, t);
|
|
761
761
|
}
|
|
762
|
-
function
|
|
762
|
+
function Le() {
|
|
763
763
|
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
764
764
|
}
|
|
765
|
-
function
|
|
765
|
+
function Ce(n) {
|
|
766
766
|
const e = {
|
|
767
|
-
type:
|
|
768
|
-
clientId:
|
|
769
|
-
timestamp:
|
|
767
|
+
type: n.type,
|
|
768
|
+
clientId: n.clientId,
|
|
769
|
+
timestamp: n.timestamp.toISOString()
|
|
770
770
|
};
|
|
771
|
-
return
|
|
772
|
-
...
|
|
773
|
-
timestamp:
|
|
774
|
-
}),
|
|
775
|
-
...
|
|
776
|
-
timestamp:
|
|
771
|
+
return n.operation && (e.operation = {
|
|
772
|
+
...n.operation,
|
|
773
|
+
timestamp: n.operation.timestamp.toISOString()
|
|
774
|
+
}), n.operations && (e.operations = n.operations.map((t) => ({
|
|
775
|
+
...t,
|
|
776
|
+
timestamp: t.timestamp.toISOString()
|
|
777
777
|
}))), e;
|
|
778
778
|
}
|
|
779
|
-
function
|
|
779
|
+
function ko(n) {
|
|
780
780
|
const e = {
|
|
781
|
-
type:
|
|
782
|
-
clientId:
|
|
783
|
-
timestamp: new Date(
|
|
781
|
+
type: n.type,
|
|
782
|
+
clientId: n.clientId,
|
|
783
|
+
timestamp: new Date(n.timestamp)
|
|
784
784
|
};
|
|
785
|
-
return
|
|
786
|
-
...
|
|
787
|
-
timestamp: new Date(
|
|
788
|
-
}),
|
|
789
|
-
...
|
|
790
|
-
timestamp: new Date(
|
|
785
|
+
return n.operation && (e.operation = {
|
|
786
|
+
...n.operation,
|
|
787
|
+
timestamp: new Date(n.operation.timestamp)
|
|
788
|
+
}), n.operations && (e.operations = n.operations.map((t) => ({
|
|
789
|
+
...t,
|
|
790
|
+
timestamp: new Date(t.timestamp)
|
|
791
791
|
}))), e;
|
|
792
792
|
}
|
|
793
|
-
const
|
|
794
|
-
const
|
|
793
|
+
const Ct = /* @__PURE__ */ to("hst-operation-log", () => {
|
|
794
|
+
const n = $({
|
|
795
795
|
maxOperations: 100,
|
|
796
796
|
enableCrossTabSync: !0,
|
|
797
797
|
autoSyncInterval: 3e4,
|
|
798
798
|
enablePersistence: !1,
|
|
799
799
|
persistenceKeyPrefix: "stonecrop-ops"
|
|
800
|
-
}), e =
|
|
801
|
-
let
|
|
802
|
-
for (let
|
|
803
|
-
|
|
804
|
-
return
|
|
805
|
-
}),
|
|
806
|
-
canUndo:
|
|
807
|
-
canRedo:
|
|
808
|
-
undoCount:
|
|
809
|
-
redoCount:
|
|
810
|
-
currentIndex:
|
|
800
|
+
}), e = $([]), t = $(-1), o = $(Le()), r = $(!1), a = $([]), s = $(null), c = R(() => t.value < 0 ? !1 : e.value[t.value]?.reversible ?? !1), d = R(() => t.value < e.value.length - 1), u = R(() => {
|
|
801
|
+
let p = 0;
|
|
802
|
+
for (let f = t.value; f >= 0 && e.value[f]?.reversible; f--)
|
|
803
|
+
p++;
|
|
804
|
+
return p;
|
|
805
|
+
}), w = R(() => e.value.length - 1 - t.value), v = R(() => ({
|
|
806
|
+
canUndo: c.value,
|
|
807
|
+
canRedo: d.value,
|
|
808
|
+
undoCount: u.value,
|
|
809
|
+
redoCount: w.value,
|
|
810
|
+
currentIndex: t.value
|
|
811
811
|
}));
|
|
812
|
-
function h(
|
|
813
|
-
|
|
812
|
+
function h(p) {
|
|
813
|
+
n.value = { ...n.value, ...p }, n.value.enablePersistence && (_(), S()), n.value.enableCrossTabSync && y();
|
|
814
814
|
}
|
|
815
|
-
function
|
|
816
|
-
const
|
|
817
|
-
...
|
|
818
|
-
id:
|
|
815
|
+
function b(p, f = "user") {
|
|
816
|
+
const i = {
|
|
817
|
+
...p,
|
|
818
|
+
id: Le(),
|
|
819
819
|
timestamp: /* @__PURE__ */ new Date(),
|
|
820
|
-
source:
|
|
821
|
-
userId:
|
|
820
|
+
source: f,
|
|
821
|
+
userId: n.value.userId
|
|
822
822
|
};
|
|
823
|
-
if (
|
|
824
|
-
return
|
|
823
|
+
if (n.value.operationFilter && !n.value.operationFilter(i))
|
|
824
|
+
return i.id;
|
|
825
825
|
if (r.value)
|
|
826
|
-
return
|
|
827
|
-
if (
|
|
828
|
-
const
|
|
829
|
-
e.value = e.value.slice(
|
|
826
|
+
return a.value.push(i), i.id;
|
|
827
|
+
if (t.value < e.value.length - 1 && (e.value = e.value.slice(0, t.value + 1)), e.value.push(i), t.value++, n.value.maxOperations && e.value.length > n.value.maxOperations) {
|
|
828
|
+
const l = e.value.length - n.value.maxOperations;
|
|
829
|
+
e.value = e.value.slice(l), t.value -= l;
|
|
830
830
|
}
|
|
831
|
-
return
|
|
831
|
+
return n.value.enableCrossTabSync && D(i), i.id;
|
|
832
832
|
}
|
|
833
833
|
function m() {
|
|
834
|
-
r.value = !0,
|
|
834
|
+
r.value = !0, a.value = [], s.value = Le();
|
|
835
835
|
}
|
|
836
|
-
function
|
|
837
|
-
if (!r.value ||
|
|
838
|
-
return r.value = !1,
|
|
839
|
-
const
|
|
840
|
-
id:
|
|
836
|
+
function k(p) {
|
|
837
|
+
if (!r.value || a.value.length === 0)
|
|
838
|
+
return r.value = !1, a.value = [], s.value = null, null;
|
|
839
|
+
const f = s.value, i = a.value.every((O) => O.reversible), l = {
|
|
840
|
+
id: f,
|
|
841
841
|
type: "batch",
|
|
842
842
|
path: "",
|
|
843
843
|
// Batch doesn't have a single path
|
|
844
844
|
fieldname: "",
|
|
845
845
|
beforeValue: null,
|
|
846
846
|
afterValue: null,
|
|
847
|
-
doctype:
|
|
847
|
+
doctype: a.value[0]?.doctype || "",
|
|
848
848
|
timestamp: /* @__PURE__ */ new Date(),
|
|
849
849
|
source: "user",
|
|
850
|
-
reversible:
|
|
851
|
-
irreversibleReason:
|
|
852
|
-
childOperationIds:
|
|
853
|
-
metadata: { description:
|
|
850
|
+
reversible: i,
|
|
851
|
+
irreversibleReason: i ? void 0 : "Contains irreversible operations",
|
|
852
|
+
childOperationIds: a.value.map((O) => O.id),
|
|
853
|
+
metadata: { description: p }
|
|
854
854
|
};
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}), e.value.push(...
|
|
858
|
-
const
|
|
859
|
-
return r.value = !1,
|
|
860
|
-
}
|
|
861
|
-
function
|
|
862
|
-
r.value = !1,
|
|
863
|
-
}
|
|
864
|
-
function
|
|
865
|
-
if (!
|
|
866
|
-
const
|
|
867
|
-
if (!
|
|
868
|
-
return typeof console < "u" &&
|
|
855
|
+
a.value.forEach((O) => {
|
|
856
|
+
O.parentOperationId = f;
|
|
857
|
+
}), e.value.push(...a.value, l), t.value = e.value.length - 1, n.value.enableCrossTabSync && F(a.value, l);
|
|
858
|
+
const A = f;
|
|
859
|
+
return r.value = !1, a.value = [], s.value = null, A;
|
|
860
|
+
}
|
|
861
|
+
function I() {
|
|
862
|
+
r.value = !1, a.value = [], s.value = null;
|
|
863
|
+
}
|
|
864
|
+
function T(p) {
|
|
865
|
+
if (!c.value) return !1;
|
|
866
|
+
const f = e.value[t.value];
|
|
867
|
+
if (!f.reversible)
|
|
868
|
+
return typeof console < "u" && f.irreversibleReason && console.warn("Cannot undo irreversible operation:", f.irreversibleReason), !1;
|
|
869
869
|
try {
|
|
870
|
-
if (
|
|
871
|
-
for (let
|
|
872
|
-
const
|
|
873
|
-
|
|
870
|
+
if (f.type === "batch" && f.childOperationIds)
|
|
871
|
+
for (let i = f.childOperationIds.length - 1; i >= 0; i--) {
|
|
872
|
+
const l = f.childOperationIds[i], A = e.value.find((O) => O.id === l);
|
|
873
|
+
A && U(A, p);
|
|
874
874
|
}
|
|
875
875
|
else
|
|
876
|
-
U(
|
|
877
|
-
return
|
|
878
|
-
} catch (
|
|
879
|
-
return typeof console < "u" && console.error("Undo failed:",
|
|
876
|
+
U(f, p);
|
|
877
|
+
return t.value--, n.value.enableCrossTabSync && N(f), !0;
|
|
878
|
+
} catch (i) {
|
|
879
|
+
return typeof console < "u" && console.error("Undo failed:", i), !1;
|
|
880
880
|
}
|
|
881
881
|
}
|
|
882
|
-
function
|
|
883
|
-
if (!
|
|
884
|
-
const
|
|
882
|
+
function Z(p) {
|
|
883
|
+
if (!d.value) return !1;
|
|
884
|
+
const f = e.value[t.value + 1];
|
|
885
885
|
try {
|
|
886
|
-
if (
|
|
887
|
-
for (const
|
|
888
|
-
const
|
|
889
|
-
|
|
886
|
+
if (f.type === "batch" && f.childOperationIds)
|
|
887
|
+
for (const i of f.childOperationIds) {
|
|
888
|
+
const l = e.value.find((A) => A.id === i);
|
|
889
|
+
l && z(l, p);
|
|
890
890
|
}
|
|
891
891
|
else
|
|
892
|
-
|
|
893
|
-
return
|
|
894
|
-
} catch (
|
|
895
|
-
return typeof console < "u" && console.error("Redo failed:",
|
|
892
|
+
z(f, p);
|
|
893
|
+
return t.value++, n.value.enableCrossTabSync && V(f), !0;
|
|
894
|
+
} catch (i) {
|
|
895
|
+
return typeof console < "u" && console.error("Redo failed:", i), !1;
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
function U(
|
|
899
|
-
(
|
|
898
|
+
function U(p, f) {
|
|
899
|
+
(p.type === "set" || p.type === "delete") && f && typeof f.set == "function" && f.set(p.path, p.beforeValue, "undo");
|
|
900
900
|
}
|
|
901
|
-
function
|
|
902
|
-
(
|
|
901
|
+
function z(p, f) {
|
|
902
|
+
(p.type === "set" || p.type === "delete") && f && typeof f.set == "function" && f.set(p.path, p.afterValue, "redo");
|
|
903
903
|
}
|
|
904
|
-
function
|
|
905
|
-
const
|
|
904
|
+
function L() {
|
|
905
|
+
const p = e.value.filter((i) => i.reversible).length, f = e.value.map((i) => i.timestamp);
|
|
906
906
|
return {
|
|
907
907
|
operations: [...e.value],
|
|
908
|
-
currentIndex:
|
|
908
|
+
currentIndex: t.value,
|
|
909
909
|
totalOperations: e.value.length,
|
|
910
|
-
reversibleOperations:
|
|
911
|
-
irreversibleOperations: e.value.length -
|
|
912
|
-
oldestOperation:
|
|
913
|
-
newestOperation:
|
|
910
|
+
reversibleOperations: p,
|
|
911
|
+
irreversibleOperations: e.value.length - p,
|
|
912
|
+
oldestOperation: f.length > 0 ? new Date(Math.min(...f.map((i) => i.getTime()))) : void 0,
|
|
913
|
+
newestOperation: f.length > 0 ? new Date(Math.max(...f.map((i) => i.getTime()))) : void 0
|
|
914
914
|
};
|
|
915
915
|
}
|
|
916
|
-
function
|
|
917
|
-
e.value = [],
|
|
916
|
+
function G() {
|
|
917
|
+
e.value = [], t.value = -1;
|
|
918
918
|
}
|
|
919
|
-
function E(
|
|
920
|
-
return e.value.filter((
|
|
919
|
+
function E(p, f) {
|
|
920
|
+
return e.value.filter((i) => i.doctype === p && (f === void 0 || i.recordId === f));
|
|
921
921
|
}
|
|
922
|
-
function Y(
|
|
923
|
-
const
|
|
924
|
-
|
|
922
|
+
function Y(p, f) {
|
|
923
|
+
const i = e.value.find((l) => l.id === p);
|
|
924
|
+
i && (i.reversible = !1, i.irreversibleReason = f);
|
|
925
925
|
}
|
|
926
|
-
function B(
|
|
927
|
-
const
|
|
926
|
+
function B(p, f, i, l = "success", A) {
|
|
927
|
+
const O = {
|
|
928
928
|
type: "action",
|
|
929
|
-
path:
|
|
929
|
+
path: i && i.length > 0 ? `${p}.${i[0]}` : p,
|
|
930
930
|
fieldname: "",
|
|
931
931
|
beforeValue: null,
|
|
932
932
|
afterValue: null,
|
|
933
|
-
doctype:
|
|
934
|
-
recordId:
|
|
933
|
+
doctype: p,
|
|
934
|
+
recordId: i && i.length > 0 ? i[0] : void 0,
|
|
935
935
|
reversible: !1,
|
|
936
936
|
// Actions are typically not reversible
|
|
937
|
-
actionName:
|
|
938
|
-
actionRecordIds:
|
|
939
|
-
actionResult:
|
|
940
|
-
actionError:
|
|
937
|
+
actionName: f,
|
|
938
|
+
actionRecordIds: i,
|
|
939
|
+
actionResult: l,
|
|
940
|
+
actionError: A
|
|
941
941
|
};
|
|
942
|
-
return
|
|
943
|
-
}
|
|
944
|
-
let
|
|
945
|
-
function
|
|
946
|
-
typeof window > "u" || !window.BroadcastChannel || (
|
|
947
|
-
const
|
|
948
|
-
if (!
|
|
949
|
-
const
|
|
950
|
-
|
|
942
|
+
return b(O);
|
|
943
|
+
}
|
|
944
|
+
let g = null;
|
|
945
|
+
function y() {
|
|
946
|
+
typeof window > "u" || !window.BroadcastChannel || (g = new BroadcastChannel("stonecrop-operation-log"), g.addEventListener("message", (p) => {
|
|
947
|
+
const f = p.data;
|
|
948
|
+
if (!f || typeof f != "object") return;
|
|
949
|
+
const i = ko(f);
|
|
950
|
+
i.clientId !== o.value && (i.type === "operation" && i.operation ? (e.value.push({ ...i.operation, source: "sync" }), t.value = e.value.length - 1) : i.type === "operation" && i.operations && (e.value.push(...i.operations.map((l) => ({ ...l, source: "sync" }))), t.value = e.value.length - 1));
|
|
951
951
|
}));
|
|
952
952
|
}
|
|
953
|
-
function
|
|
954
|
-
if (!
|
|
955
|
-
const
|
|
953
|
+
function D(p) {
|
|
954
|
+
if (!g) return;
|
|
955
|
+
const f = {
|
|
956
956
|
type: "operation",
|
|
957
|
-
operation:
|
|
958
|
-
clientId:
|
|
957
|
+
operation: p,
|
|
958
|
+
clientId: o.value,
|
|
959
959
|
timestamp: /* @__PURE__ */ new Date()
|
|
960
960
|
};
|
|
961
|
-
|
|
961
|
+
g.postMessage(Ce(f));
|
|
962
962
|
}
|
|
963
|
-
function
|
|
964
|
-
if (!
|
|
965
|
-
const
|
|
963
|
+
function F(p, f) {
|
|
964
|
+
if (!g) return;
|
|
965
|
+
const i = {
|
|
966
966
|
type: "operation",
|
|
967
|
-
operations: [...
|
|
968
|
-
clientId:
|
|
967
|
+
operations: [...p, f],
|
|
968
|
+
clientId: o.value,
|
|
969
969
|
timestamp: /* @__PURE__ */ new Date()
|
|
970
970
|
};
|
|
971
|
-
|
|
971
|
+
g.postMessage(Ce(i));
|
|
972
972
|
}
|
|
973
|
-
function
|
|
974
|
-
if (!
|
|
975
|
-
const
|
|
973
|
+
function N(p) {
|
|
974
|
+
if (!g) return;
|
|
975
|
+
const f = {
|
|
976
976
|
type: "undo",
|
|
977
|
-
operation:
|
|
978
|
-
clientId:
|
|
977
|
+
operation: p,
|
|
978
|
+
clientId: o.value,
|
|
979
979
|
timestamp: /* @__PURE__ */ new Date()
|
|
980
980
|
};
|
|
981
|
-
|
|
981
|
+
g.postMessage(Ce(f));
|
|
982
982
|
}
|
|
983
|
-
function
|
|
984
|
-
if (!
|
|
985
|
-
const
|
|
983
|
+
function V(p) {
|
|
984
|
+
if (!g) return;
|
|
985
|
+
const f = {
|
|
986
986
|
type: "redo",
|
|
987
|
-
operation:
|
|
988
|
-
clientId:
|
|
987
|
+
operation: p,
|
|
988
|
+
clientId: o.value,
|
|
989
989
|
timestamp: /* @__PURE__ */ new Date()
|
|
990
990
|
};
|
|
991
|
-
|
|
991
|
+
g.postMessage(Ce(f));
|
|
992
992
|
}
|
|
993
|
-
const
|
|
993
|
+
const M = Eo("stonecrop-ops-operations", null, {
|
|
994
994
|
serializer: {
|
|
995
|
-
read: (
|
|
995
|
+
read: (p) => {
|
|
996
996
|
try {
|
|
997
|
-
return JSON.parse(
|
|
997
|
+
return JSON.parse(p);
|
|
998
998
|
} catch {
|
|
999
999
|
return null;
|
|
1000
1000
|
}
|
|
1001
1001
|
},
|
|
1002
|
-
write: (
|
|
1002
|
+
write: (p) => p ? JSON.stringify(p) : ""
|
|
1003
1003
|
}
|
|
1004
1004
|
});
|
|
1005
|
-
function
|
|
1005
|
+
function _() {
|
|
1006
1006
|
if (!(typeof window > "u"))
|
|
1007
1007
|
try {
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
...
|
|
1011
|
-
timestamp: new Date(
|
|
1012
|
-
})),
|
|
1013
|
-
} catch (
|
|
1014
|
-
typeof console < "u" && console.error("Failed to load operations from persistence:",
|
|
1008
|
+
const p = M.value;
|
|
1009
|
+
p && Array.isArray(p.operations) && (e.value = p.operations.map((f) => ({
|
|
1010
|
+
...f,
|
|
1011
|
+
timestamp: new Date(f.timestamp)
|
|
1012
|
+
})), t.value = p.currentIndex ?? -1);
|
|
1013
|
+
} catch (p) {
|
|
1014
|
+
typeof console < "u" && console.error("Failed to load operations from persistence:", p);
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
|
-
function
|
|
1017
|
+
function C() {
|
|
1018
1018
|
if (!(typeof window > "u"))
|
|
1019
1019
|
try {
|
|
1020
|
-
|
|
1021
|
-
operations: e.value.map((
|
|
1022
|
-
...
|
|
1023
|
-
timestamp:
|
|
1020
|
+
M.value = {
|
|
1021
|
+
operations: e.value.map((p) => ({
|
|
1022
|
+
...p,
|
|
1023
|
+
timestamp: p.timestamp.toISOString()
|
|
1024
1024
|
})),
|
|
1025
|
-
currentIndex:
|
|
1025
|
+
currentIndex: t.value
|
|
1026
1026
|
};
|
|
1027
|
-
} catch (
|
|
1028
|
-
typeof console < "u" && console.error("Failed to save operations to persistence:",
|
|
1027
|
+
} catch (p) {
|
|
1028
|
+
typeof console < "u" && console.error("Failed to save operations to persistence:", p);
|
|
1029
1029
|
}
|
|
1030
1030
|
}
|
|
1031
1031
|
function S() {
|
|
1032
|
-
|
|
1033
|
-
[e,
|
|
1032
|
+
H(
|
|
1033
|
+
[e, t],
|
|
1034
1034
|
() => {
|
|
1035
|
-
|
|
1035
|
+
n.value.enablePersistence && C();
|
|
1036
1036
|
},
|
|
1037
1037
|
{ deep: !0 }
|
|
1038
1038
|
);
|
|
@@ -1040,26 +1040,26 @@ const Dt = /* @__PURE__ */ no("hst-operation-log", () => {
|
|
|
1040
1040
|
return {
|
|
1041
1041
|
// State
|
|
1042
1042
|
operations: e,
|
|
1043
|
-
currentIndex:
|
|
1044
|
-
config:
|
|
1045
|
-
clientId:
|
|
1046
|
-
undoRedoState:
|
|
1043
|
+
currentIndex: t,
|
|
1044
|
+
config: n,
|
|
1045
|
+
clientId: o,
|
|
1046
|
+
undoRedoState: v,
|
|
1047
1047
|
// Computed
|
|
1048
|
-
canUndo:
|
|
1049
|
-
canRedo:
|
|
1050
|
-
undoCount:
|
|
1051
|
-
redoCount:
|
|
1048
|
+
canUndo: c,
|
|
1049
|
+
canRedo: d,
|
|
1050
|
+
undoCount: u,
|
|
1051
|
+
redoCount: w,
|
|
1052
1052
|
// Methods
|
|
1053
1053
|
configure: h,
|
|
1054
|
-
addOperation:
|
|
1054
|
+
addOperation: b,
|
|
1055
1055
|
startBatch: m,
|
|
1056
|
-
commitBatch:
|
|
1057
|
-
cancelBatch:
|
|
1058
|
-
undo:
|
|
1059
|
-
redo:
|
|
1060
|
-
clear:
|
|
1056
|
+
commitBatch: k,
|
|
1057
|
+
cancelBatch: I,
|
|
1058
|
+
undo: T,
|
|
1059
|
+
redo: Z,
|
|
1060
|
+
clear: G,
|
|
1061
1061
|
getOperationsFor: E,
|
|
1062
|
-
getSnapshot:
|
|
1062
|
+
getSnapshot: L,
|
|
1063
1063
|
markIrreversible: Y,
|
|
1064
1064
|
logAction: B
|
|
1065
1065
|
};
|
|
@@ -1099,16 +1099,16 @@ class ge {
|
|
|
1099
1099
|
* @param name - The name of the action
|
|
1100
1100
|
* @param fn - The action function
|
|
1101
1101
|
*/
|
|
1102
|
-
registerAction(e,
|
|
1103
|
-
this.globalActions.set(e,
|
|
1102
|
+
registerAction(e, t) {
|
|
1103
|
+
this.globalActions.set(e, t);
|
|
1104
1104
|
}
|
|
1105
1105
|
/**
|
|
1106
1106
|
* Register a global XState transition action function
|
|
1107
1107
|
* @param name - The name of the transition action
|
|
1108
1108
|
* @param fn - The transition action function
|
|
1109
1109
|
*/
|
|
1110
|
-
registerTransitionAction(e,
|
|
1111
|
-
this.globalTransitionActions.set(e,
|
|
1110
|
+
registerTransitionAction(e, t) {
|
|
1111
|
+
this.globalTransitionActions.set(e, t);
|
|
1112
1112
|
}
|
|
1113
1113
|
/**
|
|
1114
1114
|
* Configure rollback behavior for a specific field trigger
|
|
@@ -1116,14 +1116,14 @@ class ge {
|
|
|
1116
1116
|
* @param fieldname - The field name
|
|
1117
1117
|
* @param enableRollback - Whether to enable rollback
|
|
1118
1118
|
*/
|
|
1119
|
-
setFieldRollback(e,
|
|
1120
|
-
this.fieldRollbackConfig.has(e) || this.fieldRollbackConfig.set(e, /* @__PURE__ */ new Map()), this.fieldRollbackConfig.get(e).set(
|
|
1119
|
+
setFieldRollback(e, t, o) {
|
|
1120
|
+
this.fieldRollbackConfig.has(e) || this.fieldRollbackConfig.set(e, /* @__PURE__ */ new Map()), this.fieldRollbackConfig.get(e).set(t, o);
|
|
1121
1121
|
}
|
|
1122
1122
|
/**
|
|
1123
1123
|
* Get rollback configuration for a specific field trigger
|
|
1124
1124
|
*/
|
|
1125
|
-
getFieldRollback(e,
|
|
1126
|
-
return this.fieldRollbackConfig.get(e)?.get(
|
|
1125
|
+
getFieldRollback(e, t) {
|
|
1126
|
+
return this.fieldRollbackConfig.get(e)?.get(t);
|
|
1127
1127
|
}
|
|
1128
1128
|
/**
|
|
1129
1129
|
* Register actions from a doctype - both regular actions and field triggers
|
|
@@ -1131,27 +1131,27 @@ class ge {
|
|
|
1131
1131
|
* @param doctype - The doctype name
|
|
1132
1132
|
* @param actions - The actions to register (supports Immutable Map, Map, or plain object)
|
|
1133
1133
|
*/
|
|
1134
|
-
registerDoctypeActions(e,
|
|
1135
|
-
if (!
|
|
1136
|
-
const
|
|
1137
|
-
if (typeof
|
|
1138
|
-
|
|
1139
|
-
this.categorizeAction(
|
|
1134
|
+
registerDoctypeActions(e, t) {
|
|
1135
|
+
if (!t) return;
|
|
1136
|
+
const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
1137
|
+
if (typeof t.entrySeq == "function")
|
|
1138
|
+
t.entrySeq().forEach(([a, s]) => {
|
|
1139
|
+
this.categorizeAction(a, s, o, r);
|
|
1140
1140
|
});
|
|
1141
|
-
else if (
|
|
1142
|
-
for (const [
|
|
1143
|
-
this.categorizeAction(
|
|
1144
|
-
else
|
|
1145
|
-
this.categorizeAction(
|
|
1141
|
+
else if (t instanceof Map)
|
|
1142
|
+
for (const [a, s] of t)
|
|
1143
|
+
this.categorizeAction(a, s, o, r);
|
|
1144
|
+
else t && typeof t == "object" && Object.entries(t).forEach(([a, s]) => {
|
|
1145
|
+
this.categorizeAction(a, s, o, r);
|
|
1146
1146
|
});
|
|
1147
|
-
this.doctypeActions.set(e,
|
|
1147
|
+
this.doctypeActions.set(e, o), this.doctypeTransitions.set(e, r);
|
|
1148
1148
|
}
|
|
1149
1149
|
/**
|
|
1150
1150
|
* Categorize an action as either a field trigger or XState transition
|
|
1151
1151
|
* Uses uppercase convention: UPPERCASE = transition, lowercase/mixed = field trigger
|
|
1152
1152
|
*/
|
|
1153
|
-
categorizeAction(e,
|
|
1154
|
-
this.isTransitionKey(e) ? r.set(e,
|
|
1153
|
+
categorizeAction(e, t, o, r) {
|
|
1154
|
+
this.isTransitionKey(e) ? r.set(e, t) : o.set(e, t);
|
|
1155
1155
|
}
|
|
1156
1156
|
/**
|
|
1157
1157
|
* Determine if a key represents an XState transition
|
|
@@ -1165,9 +1165,9 @@ class ge {
|
|
|
1165
1165
|
* @param context - The field change context
|
|
1166
1166
|
* @param options - Execution options (timeout and enableRollback)
|
|
1167
1167
|
*/
|
|
1168
|
-
async executeFieldTriggers(e,
|
|
1169
|
-
const { doctype:
|
|
1170
|
-
if (
|
|
1168
|
+
async executeFieldTriggers(e, t = {}) {
|
|
1169
|
+
const { doctype: o, fieldname: r } = e, a = this.findFieldTriggers(o, r);
|
|
1170
|
+
if (a.length === 0)
|
|
1171
1171
|
return {
|
|
1172
1172
|
path: e.path,
|
|
1173
1173
|
actionResults: [],
|
|
@@ -1176,49 +1176,49 @@ class ge {
|
|
|
1176
1176
|
stoppedOnError: !1,
|
|
1177
1177
|
rolledBack: !1
|
|
1178
1178
|
};
|
|
1179
|
-
const
|
|
1180
|
-
let
|
|
1181
|
-
const
|
|
1182
|
-
h && e.store && (
|
|
1183
|
-
for (const
|
|
1179
|
+
const s = performance.now(), c = [];
|
|
1180
|
+
let d = !1, u = !1, w;
|
|
1181
|
+
const v = this.getFieldRollback(o, r), h = t.enableRollback ?? v ?? this.options.enableRollback;
|
|
1182
|
+
h && e.store && (w = this.captureSnapshot(e));
|
|
1183
|
+
for (const k of a)
|
|
1184
1184
|
try {
|
|
1185
|
-
const
|
|
1186
|
-
if (
|
|
1187
|
-
|
|
1185
|
+
const I = await this.executeAction(k, e, t.timeout);
|
|
1186
|
+
if (c.push(I), !I.success) {
|
|
1187
|
+
d = !0;
|
|
1188
1188
|
break;
|
|
1189
1189
|
}
|
|
1190
|
-
} catch (
|
|
1191
|
-
const
|
|
1190
|
+
} catch (I) {
|
|
1191
|
+
const T = {
|
|
1192
1192
|
success: !1,
|
|
1193
|
-
error:
|
|
1193
|
+
error: I instanceof Error ? I : new Error(String(I)),
|
|
1194
1194
|
executionTime: 0,
|
|
1195
|
-
action:
|
|
1195
|
+
action: k
|
|
1196
1196
|
};
|
|
1197
|
-
|
|
1197
|
+
c.push(T), d = !0;
|
|
1198
1198
|
break;
|
|
1199
1199
|
}
|
|
1200
|
-
if (h &&
|
|
1200
|
+
if (h && d && w && e.store)
|
|
1201
1201
|
try {
|
|
1202
|
-
this.restoreSnapshot(e,
|
|
1203
|
-
} catch (
|
|
1204
|
-
console.error("[FieldTriggers] Rollback failed:",
|
|
1202
|
+
this.restoreSnapshot(e, w), u = !0;
|
|
1203
|
+
} catch (k) {
|
|
1204
|
+
console.error("[FieldTriggers] Rollback failed:", k);
|
|
1205
1205
|
}
|
|
1206
|
-
const
|
|
1206
|
+
const b = performance.now() - s, m = c.filter((k) => !k.success);
|
|
1207
1207
|
if (m.length > 0 && this.options.errorHandler)
|
|
1208
|
-
for (const
|
|
1208
|
+
for (const k of m)
|
|
1209
1209
|
try {
|
|
1210
|
-
this.options.errorHandler(
|
|
1211
|
-
} catch (
|
|
1212
|
-
console.error("[FieldTriggers] Error in global error handler:",
|
|
1210
|
+
this.options.errorHandler(k.error, e, k.action);
|
|
1211
|
+
} catch (I) {
|
|
1212
|
+
console.error("[FieldTriggers] Error in global error handler:", I);
|
|
1213
1213
|
}
|
|
1214
1214
|
return {
|
|
1215
1215
|
path: e.path,
|
|
1216
|
-
actionResults:
|
|
1217
|
-
totalExecutionTime:
|
|
1218
|
-
allSucceeded:
|
|
1219
|
-
stoppedOnError:
|
|
1220
|
-
rolledBack:
|
|
1221
|
-
snapshot: this.options.debug && h ?
|
|
1216
|
+
actionResults: c,
|
|
1217
|
+
totalExecutionTime: b,
|
|
1218
|
+
allSucceeded: c.every((k) => k.success),
|
|
1219
|
+
stoppedOnError: d,
|
|
1220
|
+
rolledBack: u,
|
|
1221
|
+
snapshot: this.options.debug && h ? w : void 0
|
|
1222
1222
|
// Only include snapshot in debug mode if rollback is enabled
|
|
1223
1223
|
};
|
|
1224
1224
|
}
|
|
@@ -1228,71 +1228,71 @@ class ge {
|
|
|
1228
1228
|
* @param context - The transition change context
|
|
1229
1229
|
* @param options - Execution options (timeout)
|
|
1230
1230
|
*/
|
|
1231
|
-
async executeTransitionActions(e,
|
|
1232
|
-
const { doctype:
|
|
1233
|
-
if (
|
|
1231
|
+
async executeTransitionActions(e, t = {}) {
|
|
1232
|
+
const { doctype: o, transition: r } = e, a = this.findTransitionActions(o, r);
|
|
1233
|
+
if (a.length === 0)
|
|
1234
1234
|
return [];
|
|
1235
|
-
const
|
|
1236
|
-
for (const
|
|
1235
|
+
const s = [];
|
|
1236
|
+
for (const d of a)
|
|
1237
1237
|
try {
|
|
1238
|
-
const
|
|
1239
|
-
if (
|
|
1238
|
+
const u = await this.executeTransitionAction(d, e, t.timeout);
|
|
1239
|
+
if (s.push(u), !u.success)
|
|
1240
1240
|
break;
|
|
1241
|
-
} catch (
|
|
1242
|
-
const
|
|
1241
|
+
} catch (u) {
|
|
1242
|
+
const w = {
|
|
1243
1243
|
success: !1,
|
|
1244
|
-
error:
|
|
1244
|
+
error: u instanceof Error ? u : new Error(String(u)),
|
|
1245
1245
|
executionTime: 0,
|
|
1246
|
-
action:
|
|
1246
|
+
action: d,
|
|
1247
1247
|
transition: r
|
|
1248
1248
|
};
|
|
1249
|
-
|
|
1249
|
+
s.push(w);
|
|
1250
1250
|
break;
|
|
1251
1251
|
}
|
|
1252
|
-
const
|
|
1253
|
-
if (
|
|
1254
|
-
for (const
|
|
1252
|
+
const c = s.filter((d) => !d.success);
|
|
1253
|
+
if (c.length > 0 && this.options.errorHandler)
|
|
1254
|
+
for (const d of c)
|
|
1255
1255
|
try {
|
|
1256
|
-
this.options.errorHandler(
|
|
1257
|
-
} catch (
|
|
1258
|
-
console.error("[FieldTriggers] Error in global error handler:",
|
|
1256
|
+
this.options.errorHandler(d.error, e, d.action);
|
|
1257
|
+
} catch (u) {
|
|
1258
|
+
console.error("[FieldTriggers] Error in global error handler:", u);
|
|
1259
1259
|
}
|
|
1260
|
-
return
|
|
1260
|
+
return s;
|
|
1261
1261
|
}
|
|
1262
1262
|
/**
|
|
1263
1263
|
* Find transition actions for a specific doctype and transition
|
|
1264
1264
|
*/
|
|
1265
|
-
findTransitionActions(e,
|
|
1266
|
-
const
|
|
1267
|
-
return
|
|
1265
|
+
findTransitionActions(e, t) {
|
|
1266
|
+
const o = this.doctypeTransitions.get(e);
|
|
1267
|
+
return o ? o.get(t) || [] : [];
|
|
1268
1268
|
}
|
|
1269
1269
|
/**
|
|
1270
1270
|
* Execute a single transition action by name
|
|
1271
1271
|
*/
|
|
1272
|
-
async executeTransitionAction(e,
|
|
1273
|
-
const r = performance.now(),
|
|
1272
|
+
async executeTransitionAction(e, t, o) {
|
|
1273
|
+
const r = performance.now(), a = o ?? this.options.defaultTimeout;
|
|
1274
1274
|
try {
|
|
1275
|
-
let
|
|
1276
|
-
if (!
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1275
|
+
let s = this.globalTransitionActions.get(e);
|
|
1276
|
+
if (!s) {
|
|
1277
|
+
const c = this.globalActions.get(e);
|
|
1278
|
+
c && (s = c);
|
|
1279
1279
|
}
|
|
1280
|
-
if (!
|
|
1280
|
+
if (!s)
|
|
1281
1281
|
throw new Error(`Transition action "${e}" not found in registry`);
|
|
1282
|
-
return await this.executeWithTimeout(
|
|
1282
|
+
return await this.executeWithTimeout(s, t, a), {
|
|
1283
1283
|
success: !0,
|
|
1284
1284
|
executionTime: performance.now() - r,
|
|
1285
1285
|
action: e,
|
|
1286
|
-
transition:
|
|
1286
|
+
transition: t.transition
|
|
1287
1287
|
};
|
|
1288
|
-
} catch (
|
|
1289
|
-
const
|
|
1288
|
+
} catch (s) {
|
|
1289
|
+
const c = performance.now() - r;
|
|
1290
1290
|
return {
|
|
1291
1291
|
success: !1,
|
|
1292
|
-
error:
|
|
1293
|
-
executionTime:
|
|
1292
|
+
error: s instanceof Error ? s : new Error(String(s)),
|
|
1293
|
+
executionTime: c,
|
|
1294
1294
|
action: e,
|
|
1295
|
-
transition:
|
|
1295
|
+
transition: t.transition
|
|
1296
1296
|
};
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
@@ -1300,12 +1300,12 @@ class ge {
|
|
|
1300
1300
|
* Find field triggers for a specific doctype and field
|
|
1301
1301
|
* Field triggers are identified by keys that look like field paths (contain dots or match field names)
|
|
1302
1302
|
*/
|
|
1303
|
-
findFieldTriggers(e,
|
|
1304
|
-
const
|
|
1305
|
-
if (!
|
|
1303
|
+
findFieldTriggers(e, t) {
|
|
1304
|
+
const o = this.doctypeActions.get(e);
|
|
1305
|
+
if (!o) return [];
|
|
1306
1306
|
const r = [];
|
|
1307
|
-
for (const [
|
|
1308
|
-
this.isFieldTriggerKey(
|
|
1307
|
+
for (const [a, s] of o)
|
|
1308
|
+
this.isFieldTriggerKey(a, t) && r.push(...s);
|
|
1309
1309
|
return r;
|
|
1310
1310
|
}
|
|
1311
1311
|
/**
|
|
@@ -1315,20 +1315,20 @@ class ge {
|
|
|
1315
1315
|
* - Wildcard patterns: "emailAddress.*", "*.is_primary"
|
|
1316
1316
|
* - Nested field paths: "address.street", "contact.email"
|
|
1317
1317
|
*/
|
|
1318
|
-
isFieldTriggerKey(e,
|
|
1319
|
-
return e ===
|
|
1318
|
+
isFieldTriggerKey(e, t) {
|
|
1319
|
+
return e === t ? !0 : e.includes(".") ? this.matchFieldPattern(e, t) : e.includes("*") ? this.matchFieldPattern(e, t) : !1;
|
|
1320
1320
|
}
|
|
1321
1321
|
/**
|
|
1322
1322
|
* Match a field pattern against a field name
|
|
1323
1323
|
* Supports wildcards (*) for dynamic segments
|
|
1324
1324
|
*/
|
|
1325
|
-
matchFieldPattern(e,
|
|
1326
|
-
const
|
|
1327
|
-
if (
|
|
1325
|
+
matchFieldPattern(e, t) {
|
|
1326
|
+
const o = e.split("."), r = t.split(".");
|
|
1327
|
+
if (o.length !== r.length)
|
|
1328
1328
|
return !1;
|
|
1329
|
-
for (let
|
|
1330
|
-
const
|
|
1331
|
-
if (
|
|
1329
|
+
for (let a = 0; a < o.length; a++) {
|
|
1330
|
+
const s = o[a], c = r[a];
|
|
1331
|
+
if (s !== "*" && s !== c)
|
|
1332
1332
|
return !1;
|
|
1333
1333
|
}
|
|
1334
1334
|
return !0;
|
|
@@ -1336,23 +1336,23 @@ class ge {
|
|
|
1336
1336
|
/**
|
|
1337
1337
|
* Execute a single action by name
|
|
1338
1338
|
*/
|
|
1339
|
-
async executeAction(e,
|
|
1340
|
-
const r = performance.now(),
|
|
1339
|
+
async executeAction(e, t, o) {
|
|
1340
|
+
const r = performance.now(), a = o ?? this.options.defaultTimeout;
|
|
1341
1341
|
try {
|
|
1342
|
-
const
|
|
1343
|
-
if (!
|
|
1342
|
+
const s = this.globalActions.get(e);
|
|
1343
|
+
if (!s)
|
|
1344
1344
|
throw new Error(`Action "${e}" not found in registry`);
|
|
1345
|
-
return await this.executeWithTimeout(
|
|
1345
|
+
return await this.executeWithTimeout(s, t, a), {
|
|
1346
1346
|
success: !0,
|
|
1347
1347
|
executionTime: performance.now() - r,
|
|
1348
1348
|
action: e
|
|
1349
1349
|
};
|
|
1350
|
-
} catch (
|
|
1351
|
-
const
|
|
1350
|
+
} catch (s) {
|
|
1351
|
+
const c = performance.now() - r;
|
|
1352
1352
|
return {
|
|
1353
1353
|
success: !1,
|
|
1354
|
-
error:
|
|
1355
|
-
executionTime:
|
|
1354
|
+
error: s instanceof Error ? s : new Error(String(s)),
|
|
1355
|
+
executionTime: c,
|
|
1356
1356
|
action: e
|
|
1357
1357
|
};
|
|
1358
1358
|
}
|
|
@@ -1360,15 +1360,15 @@ class ge {
|
|
|
1360
1360
|
/**
|
|
1361
1361
|
* Execute a function with timeout
|
|
1362
1362
|
*/
|
|
1363
|
-
async executeWithTimeout(e,
|
|
1364
|
-
return new Promise((r,
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
},
|
|
1368
|
-
Promise.resolve(e(
|
|
1369
|
-
clearTimeout(
|
|
1370
|
-
}).catch((
|
|
1371
|
-
clearTimeout(
|
|
1363
|
+
async executeWithTimeout(e, t, o) {
|
|
1364
|
+
return new Promise((r, a) => {
|
|
1365
|
+
const s = setTimeout(() => {
|
|
1366
|
+
a(new Error(`Action timeout after ${o}ms`));
|
|
1367
|
+
}, o);
|
|
1368
|
+
Promise.resolve(e(t)).then((c) => {
|
|
1369
|
+
clearTimeout(s), r(c);
|
|
1370
|
+
}).catch((c) => {
|
|
1371
|
+
clearTimeout(s), a(c);
|
|
1372
1372
|
});
|
|
1373
1373
|
});
|
|
1374
1374
|
}
|
|
@@ -1379,10 +1379,10 @@ class ge {
|
|
|
1379
1379
|
captureSnapshot(e) {
|
|
1380
1380
|
if (!(!e.store || !e.doctype || !e.recordId))
|
|
1381
1381
|
try {
|
|
1382
|
-
const
|
|
1383
|
-
return !
|
|
1384
|
-
} catch (
|
|
1385
|
-
this.options.debug && console.warn("[FieldTriggers] Failed to capture snapshot:",
|
|
1382
|
+
const t = `${e.doctype}.${e.recordId}`, o = e.store.get(t);
|
|
1383
|
+
return !o || typeof o != "object" ? void 0 : JSON.parse(JSON.stringify(o));
|
|
1384
|
+
} catch (t) {
|
|
1385
|
+
this.options.debug && console.warn("[FieldTriggers] Failed to capture snapshot:", t);
|
|
1386
1386
|
return;
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
@@ -1390,34 +1390,34 @@ class ge {
|
|
|
1390
1390
|
* Restore a previously captured snapshot
|
|
1391
1391
|
* This reverts the record to its state before actions were executed
|
|
1392
1392
|
*/
|
|
1393
|
-
restoreSnapshot(e,
|
|
1394
|
-
if (!(!e.store || !e.doctype || !e.recordId || !
|
|
1393
|
+
restoreSnapshot(e, t) {
|
|
1394
|
+
if (!(!e.store || !e.doctype || !e.recordId || !t))
|
|
1395
1395
|
try {
|
|
1396
|
-
const
|
|
1397
|
-
e.store.set(
|
|
1398
|
-
} catch (
|
|
1399
|
-
throw console.error("[FieldTriggers] Failed to restore snapshot:",
|
|
1396
|
+
const o = `${e.doctype}.${e.recordId}`;
|
|
1397
|
+
e.store.set(o, t), this.options.debug && console.log(`[FieldTriggers] Rolled back ${o} to previous state`);
|
|
1398
|
+
} catch (o) {
|
|
1399
|
+
throw console.error("[FieldTriggers] Failed to restore snapshot:", o), o;
|
|
1400
1400
|
}
|
|
1401
1401
|
}
|
|
1402
1402
|
}
|
|
1403
|
-
function ct(
|
|
1404
|
-
return new ge(
|
|
1403
|
+
function ct(n) {
|
|
1404
|
+
return new ge(n);
|
|
1405
1405
|
}
|
|
1406
1406
|
function ut() {
|
|
1407
1407
|
try {
|
|
1408
|
-
return
|
|
1408
|
+
return Ct();
|
|
1409
1409
|
} catch {
|
|
1410
1410
|
return null;
|
|
1411
1411
|
}
|
|
1412
1412
|
}
|
|
1413
|
-
class
|
|
1413
|
+
class le {
|
|
1414
1414
|
static instance;
|
|
1415
1415
|
/**
|
|
1416
1416
|
* Gets the singleton instance of HST
|
|
1417
1417
|
* @returns The HST singleton instance
|
|
1418
1418
|
*/
|
|
1419
1419
|
static getInstance() {
|
|
1420
|
-
return
|
|
1420
|
+
return le.instance || (le.instance = new le()), le.instance;
|
|
1421
1421
|
}
|
|
1422
1422
|
/**
|
|
1423
1423
|
* Gets the global registry instance
|
|
@@ -1446,28 +1446,28 @@ class ce {
|
|
|
1446
1446
|
* @returns The doctype metadata object or undefined if not found
|
|
1447
1447
|
*/
|
|
1448
1448
|
getDoctypeMeta(e) {
|
|
1449
|
-
const
|
|
1450
|
-
if (
|
|
1451
|
-
return
|
|
1449
|
+
const t = this.getRegistry();
|
|
1450
|
+
if (t && typeof t == "object" && "registry" in t)
|
|
1451
|
+
return t.registry[e];
|
|
1452
1452
|
}
|
|
1453
1453
|
}
|
|
1454
|
-
class
|
|
1454
|
+
class Re {
|
|
1455
1455
|
target;
|
|
1456
1456
|
parentPath;
|
|
1457
1457
|
rootNode;
|
|
1458
1458
|
doctype;
|
|
1459
1459
|
parentDoctype;
|
|
1460
1460
|
hst;
|
|
1461
|
-
constructor(e,
|
|
1462
|
-
return this.target = e, this.parentPath =
|
|
1463
|
-
get(
|
|
1464
|
-
if (
|
|
1465
|
-
const
|
|
1466
|
-
return
|
|
1461
|
+
constructor(e, t, o = "", r = null, a) {
|
|
1462
|
+
return this.target = e, this.parentPath = o, this.rootNode = r || this, this.doctype = t, this.parentDoctype = a, this.hst = le.getInstance(), new Proxy(this, {
|
|
1463
|
+
get(s, c) {
|
|
1464
|
+
if (c in s) return s[c];
|
|
1465
|
+
const d = String(c);
|
|
1466
|
+
return s.getNode(d);
|
|
1467
1467
|
},
|
|
1468
|
-
set(
|
|
1469
|
-
const
|
|
1470
|
-
return
|
|
1468
|
+
set(s, c, d) {
|
|
1469
|
+
const u = String(c);
|
|
1470
|
+
return s.set(u, d), !0;
|
|
1471
1471
|
}
|
|
1472
1472
|
});
|
|
1473
1473
|
}
|
|
@@ -1476,47 +1476,47 @@ class Ie {
|
|
|
1476
1476
|
}
|
|
1477
1477
|
// Method to get a tree-wrapped node for navigation
|
|
1478
1478
|
getNode(e) {
|
|
1479
|
-
const
|
|
1480
|
-
let
|
|
1481
|
-
return this.doctype === "StonecropStore" && r.length >= 1 && (
|
|
1482
|
-
}
|
|
1483
|
-
set(e,
|
|
1484
|
-
const r = this.resolvePath(e),
|
|
1485
|
-
if (
|
|
1486
|
-
const
|
|
1487
|
-
if (
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1479
|
+
const t = this.resolvePath(e), o = this.resolveValue(e), r = t.split(".");
|
|
1480
|
+
let a = this.doctype;
|
|
1481
|
+
return this.doctype === "StonecropStore" && r.length >= 1 && (a = r[0]), typeof o == "object" && o !== null && !this.isPrimitive(o) ? new Re(o, a, t, this.rootNode, this.parentDoctype) : new Re(o, a, t, this.rootNode, this.parentDoctype);
|
|
1482
|
+
}
|
|
1483
|
+
set(e, t, o = "user") {
|
|
1484
|
+
const r = this.resolvePath(e), a = this.has(e) ? this.get(e) : void 0;
|
|
1485
|
+
if (o !== "undo" && o !== "redo") {
|
|
1486
|
+
const s = ut();
|
|
1487
|
+
if (s && typeof s.addOperation == "function") {
|
|
1488
|
+
const c = r.split("."), d = this.doctype === "StonecropStore" && c.length >= 1 ? c[0] : this.doctype, u = c.length >= 2 ? c[1] : void 0, w = c.slice(2).join(".") || c[c.length - 1], v = t === void 0 && a !== void 0 ? "delete" : "set";
|
|
1489
|
+
s.addOperation(
|
|
1490
1490
|
{
|
|
1491
|
-
type:
|
|
1491
|
+
type: v,
|
|
1492
1492
|
path: r,
|
|
1493
|
-
fieldname:
|
|
1494
|
-
beforeValue:
|
|
1495
|
-
afterValue:
|
|
1496
|
-
doctype:
|
|
1497
|
-
recordId:
|
|
1493
|
+
fieldname: w,
|
|
1494
|
+
beforeValue: a,
|
|
1495
|
+
afterValue: t,
|
|
1496
|
+
doctype: d,
|
|
1497
|
+
recordId: u,
|
|
1498
1498
|
reversible: !0
|
|
1499
1499
|
// Default to reversible, can be changed by field triggers
|
|
1500
1500
|
},
|
|
1501
|
-
|
|
1501
|
+
o
|
|
1502
1502
|
);
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
|
-
this.updateValue(e,
|
|
1505
|
+
this.updateValue(e, t), this.triggerFieldActions(r, a, t);
|
|
1506
1506
|
}
|
|
1507
1507
|
has(e) {
|
|
1508
1508
|
try {
|
|
1509
1509
|
if (e === "")
|
|
1510
1510
|
return !0;
|
|
1511
|
-
const
|
|
1512
|
-
let
|
|
1513
|
-
for (let r = 0; r <
|
|
1514
|
-
const
|
|
1515
|
-
if (
|
|
1511
|
+
const t = this.parsePath(e);
|
|
1512
|
+
let o = this.target;
|
|
1513
|
+
for (let r = 0; r < t.length; r++) {
|
|
1514
|
+
const a = t[r];
|
|
1515
|
+
if (o == null)
|
|
1516
1516
|
return !1;
|
|
1517
|
-
if (r ===
|
|
1518
|
-
return this.isImmutable(
|
|
1519
|
-
|
|
1517
|
+
if (r === t.length - 1)
|
|
1518
|
+
return this.isImmutable(o) ? o.has(a) : this.isPiniaStore(o) && o.$state && a in o.$state || a in o;
|
|
1519
|
+
o = this.getProperty(o, a);
|
|
1520
1520
|
}
|
|
1521
1521
|
return !1;
|
|
1522
1522
|
} catch {
|
|
@@ -1544,46 +1544,46 @@ class Ie {
|
|
|
1544
1544
|
/**
|
|
1545
1545
|
* Trigger an XState transition with optional context data
|
|
1546
1546
|
*/
|
|
1547
|
-
async triggerTransition(e,
|
|
1548
|
-
const
|
|
1549
|
-
let
|
|
1550
|
-
this.doctype === "StonecropStore" && r.length >= 1 && (
|
|
1551
|
-
const
|
|
1547
|
+
async triggerTransition(e, t) {
|
|
1548
|
+
const o = ct(), r = this.parentPath.split(".");
|
|
1549
|
+
let a = this.doctype, s;
|
|
1550
|
+
this.doctype === "StonecropStore" && r.length >= 1 && (a = r[0]), r.length >= 2 && (s = r[1]);
|
|
1551
|
+
const c = {
|
|
1552
1552
|
path: this.parentPath,
|
|
1553
1553
|
fieldname: "",
|
|
1554
1554
|
// No specific field for transitions
|
|
1555
1555
|
beforeValue: void 0,
|
|
1556
1556
|
afterValue: void 0,
|
|
1557
1557
|
operation: "set",
|
|
1558
|
-
doctype:
|
|
1559
|
-
recordId:
|
|
1558
|
+
doctype: a,
|
|
1559
|
+
recordId: s,
|
|
1560
1560
|
timestamp: /* @__PURE__ */ new Date(),
|
|
1561
1561
|
store: this.rootNode || void 0,
|
|
1562
1562
|
transition: e,
|
|
1563
|
-
currentState:
|
|
1564
|
-
targetState:
|
|
1565
|
-
fsmContext:
|
|
1566
|
-
},
|
|
1567
|
-
return
|
|
1563
|
+
currentState: t?.currentState,
|
|
1564
|
+
targetState: t?.targetState,
|
|
1565
|
+
fsmContext: t?.fsmContext
|
|
1566
|
+
}, d = ut();
|
|
1567
|
+
return d && typeof d.addOperation == "function" && d.addOperation(
|
|
1568
1568
|
{
|
|
1569
1569
|
type: "transition",
|
|
1570
1570
|
path: this.parentPath,
|
|
1571
1571
|
fieldname: e,
|
|
1572
|
-
beforeValue:
|
|
1573
|
-
afterValue:
|
|
1574
|
-
doctype:
|
|
1575
|
-
recordId:
|
|
1572
|
+
beforeValue: t?.currentState,
|
|
1573
|
+
afterValue: t?.targetState,
|
|
1574
|
+
doctype: a,
|
|
1575
|
+
recordId: s,
|
|
1576
1576
|
reversible: !1,
|
|
1577
1577
|
// FSM transitions are generally not reversible
|
|
1578
1578
|
metadata: {
|
|
1579
1579
|
transition: e,
|
|
1580
|
-
currentState:
|
|
1581
|
-
targetState:
|
|
1582
|
-
fsmContext:
|
|
1580
|
+
currentState: t?.currentState,
|
|
1581
|
+
targetState: t?.targetState,
|
|
1582
|
+
fsmContext: t?.fsmContext
|
|
1583
1583
|
}
|
|
1584
1584
|
},
|
|
1585
1585
|
"user"
|
|
1586
|
-
), await
|
|
1586
|
+
), await o.executeTransitionActions(c);
|
|
1587
1587
|
}
|
|
1588
1588
|
// Private helper methods
|
|
1589
1589
|
resolvePath(e) {
|
|
@@ -1592,62 +1592,62 @@ class Ie {
|
|
|
1592
1592
|
resolveValue(e) {
|
|
1593
1593
|
if (e === "")
|
|
1594
1594
|
return this.target;
|
|
1595
|
-
const
|
|
1596
|
-
let
|
|
1597
|
-
for (const r of
|
|
1598
|
-
if (
|
|
1595
|
+
const t = this.parsePath(e);
|
|
1596
|
+
let o = this.target;
|
|
1597
|
+
for (const r of t) {
|
|
1598
|
+
if (o == null)
|
|
1599
1599
|
return;
|
|
1600
|
-
|
|
1600
|
+
o = this.getProperty(o, r);
|
|
1601
1601
|
}
|
|
1602
|
-
return
|
|
1602
|
+
return o;
|
|
1603
1603
|
}
|
|
1604
|
-
updateValue(e,
|
|
1604
|
+
updateValue(e, t) {
|
|
1605
1605
|
if (e === "")
|
|
1606
1606
|
throw new Error("Cannot set value on empty path");
|
|
1607
|
-
const
|
|
1608
|
-
let
|
|
1609
|
-
for (const
|
|
1610
|
-
if (
|
|
1607
|
+
const o = this.parsePath(e), r = o.pop();
|
|
1608
|
+
let a = this.target;
|
|
1609
|
+
for (const s of o)
|
|
1610
|
+
if (a = this.getProperty(a, s), a == null)
|
|
1611
1611
|
throw new Error(`Cannot set property on null/undefined path: ${e}`);
|
|
1612
|
-
this.setProperty(
|
|
1612
|
+
this.setProperty(a, r, t);
|
|
1613
1613
|
}
|
|
1614
|
-
getProperty(e,
|
|
1615
|
-
return this.isImmutable(e) ? e.get(
|
|
1614
|
+
getProperty(e, t) {
|
|
1615
|
+
return this.isImmutable(e) ? e.get(t) : this.isVueReactive(e) ? e[t] : this.isPiniaStore(e) ? e.$state?.[t] ?? e[t] : e[t];
|
|
1616
1616
|
}
|
|
1617
|
-
setProperty(e,
|
|
1617
|
+
setProperty(e, t, o) {
|
|
1618
1618
|
if (this.isImmutable(e))
|
|
1619
1619
|
throw new Error("Cannot directly mutate immutable objects. Use immutable update methods instead.");
|
|
1620
1620
|
if (this.isPiniaStore(e)) {
|
|
1621
|
-
e.$patch ? e.$patch({ [
|
|
1621
|
+
e.$patch ? e.$patch({ [t]: o }) : e[t] = o;
|
|
1622
1622
|
return;
|
|
1623
1623
|
}
|
|
1624
|
-
e[
|
|
1624
|
+
e[t] = o;
|
|
1625
1625
|
}
|
|
1626
|
-
async triggerFieldActions(e,
|
|
1626
|
+
async triggerFieldActions(e, t, o) {
|
|
1627
1627
|
try {
|
|
1628
|
-
if (!e || typeof e != "string" || Object.is(
|
|
1628
|
+
if (!e || typeof e != "string" || Object.is(t, o))
|
|
1629
1629
|
return;
|
|
1630
1630
|
const r = e.split(".");
|
|
1631
1631
|
if (r.length < 3)
|
|
1632
1632
|
return;
|
|
1633
|
-
const
|
|
1634
|
-
let
|
|
1635
|
-
this.doctype === "StonecropStore" && r.length >= 1 && (
|
|
1636
|
-
let
|
|
1637
|
-
r.length >= 2 && (
|
|
1638
|
-
const
|
|
1633
|
+
const a = ct(), s = r.slice(2).join(".") || r[r.length - 1];
|
|
1634
|
+
let c = this.doctype;
|
|
1635
|
+
this.doctype === "StonecropStore" && r.length >= 1 && (c = r[0]);
|
|
1636
|
+
let d;
|
|
1637
|
+
r.length >= 2 && (d = r[1]);
|
|
1638
|
+
const u = {
|
|
1639
1639
|
path: e,
|
|
1640
|
-
fieldname:
|
|
1641
|
-
beforeValue:
|
|
1642
|
-
afterValue:
|
|
1640
|
+
fieldname: s,
|
|
1641
|
+
beforeValue: t,
|
|
1642
|
+
afterValue: o,
|
|
1643
1643
|
operation: "set",
|
|
1644
|
-
doctype:
|
|
1645
|
-
recordId:
|
|
1644
|
+
doctype: c,
|
|
1645
|
+
recordId: d,
|
|
1646
1646
|
timestamp: /* @__PURE__ */ new Date(),
|
|
1647
1647
|
store: this.rootNode || void 0
|
|
1648
1648
|
// Pass the root store for snapshot/rollback capabilities
|
|
1649
1649
|
};
|
|
1650
|
-
await
|
|
1650
|
+
await a.executeFieldTriggers(u);
|
|
1651
1651
|
} catch (r) {
|
|
1652
1652
|
r instanceof Error && console.warn("Field trigger error:", r.message);
|
|
1653
1653
|
}
|
|
@@ -1661,19 +1661,19 @@ class Ie {
|
|
|
1661
1661
|
isImmutable(e) {
|
|
1662
1662
|
if (!e || typeof e != "object")
|
|
1663
1663
|
return !1;
|
|
1664
|
-
const
|
|
1665
|
-
let
|
|
1664
|
+
const t = "get" in e && typeof e.get == "function", o = "set" in e && typeof e.set == "function", r = "has" in e && typeof e.has == "function", a = "__ownerID" in e || "_map" in e || "_list" in e || "_origin" in e || "_capacity" in e || "_defaultValues" in e || "_tail" in e || "_root" in e || "size" in e && t && o;
|
|
1665
|
+
let s;
|
|
1666
1666
|
try {
|
|
1667
|
-
const
|
|
1668
|
-
if ("constructor" in
|
|
1669
|
-
const
|
|
1670
|
-
|
|
1667
|
+
const d = e;
|
|
1668
|
+
if ("constructor" in d && d.constructor && typeof d.constructor == "object" && "name" in d.constructor) {
|
|
1669
|
+
const u = d.constructor.name;
|
|
1670
|
+
s = typeof u == "string" ? u : void 0;
|
|
1671
1671
|
}
|
|
1672
1672
|
} catch {
|
|
1673
|
-
|
|
1673
|
+
s = void 0;
|
|
1674
1674
|
}
|
|
1675
|
-
const
|
|
1676
|
-
return !!(
|
|
1675
|
+
const c = s && (s.includes("Map") || s.includes("List") || s.includes("Set") || s.includes("Stack") || s.includes("Seq")) && (t || o);
|
|
1676
|
+
return !!(t && o && r && a || t && o && c);
|
|
1677
1677
|
}
|
|
1678
1678
|
isPrimitive(e) {
|
|
1679
1679
|
return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "function" || typeof e == "symbol" || typeof e == "bigint";
|
|
@@ -1684,49 +1684,74 @@ class Ie {
|
|
|
1684
1684
|
* @returns Array of path segments (e.g., ['order', '456', 'line_items', '0', 'product'])
|
|
1685
1685
|
*/
|
|
1686
1686
|
parsePath(e) {
|
|
1687
|
-
return e ? e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((
|
|
1687
|
+
return e ? e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((t) => t.length > 0) : [];
|
|
1688
1688
|
}
|
|
1689
1689
|
}
|
|
1690
|
-
function
|
|
1691
|
-
return new
|
|
1690
|
+
function Co(n, e, t) {
|
|
1691
|
+
return new Re(n, e, "", null, t);
|
|
1692
1692
|
}
|
|
1693
|
-
class
|
|
1693
|
+
class No {
|
|
1694
1694
|
hstStore;
|
|
1695
1695
|
_operationLogStore;
|
|
1696
1696
|
_operationLogConfig;
|
|
1697
|
+
_client;
|
|
1697
1698
|
/** The registry instance containing all doctype definitions */
|
|
1698
1699
|
registry;
|
|
1699
1700
|
/**
|
|
1700
1701
|
* Creates a new Stonecrop instance with HST integration
|
|
1701
1702
|
* @param registry - The Registry instance containing doctype definitions
|
|
1702
1703
|
* @param operationLogConfig - Optional configuration for the operation log
|
|
1704
|
+
* @param options - Options including the data client (can be set later via setClient)
|
|
1703
1705
|
*/
|
|
1704
|
-
constructor(e, o) {
|
|
1705
|
-
this.registry = e, this._operationLogConfig = o, this.initializeHSTStore(), this.setupRegistrySync();
|
|
1706
|
+
constructor(e, t, o) {
|
|
1707
|
+
this.registry = e, this._operationLogConfig = t, this._client = o?.client, this.initializeHSTStore(), this.setupRegistrySync();
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Set the data client for fetching doctype metadata and records.
|
|
1711
|
+
* Use this for deferred configuration in Nuxt/Vue plugin setups.
|
|
1712
|
+
*
|
|
1713
|
+
* @param client - DataClient implementation (e.g., StonecropClient from \@stonecrop/graphql-client)
|
|
1714
|
+
*
|
|
1715
|
+
* @example
|
|
1716
|
+
* ```ts
|
|
1717
|
+
* const { setClient } = useStonecropRegistry()
|
|
1718
|
+
* const client = new StonecropClient({ endpoint: '/graphql' })
|
|
1719
|
+
* setClient(client)
|
|
1720
|
+
* ```
|
|
1721
|
+
*/
|
|
1722
|
+
setClient(e) {
|
|
1723
|
+
this._client = e;
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Get the current data client
|
|
1727
|
+
* @returns The DataClient instance or undefined if not set
|
|
1728
|
+
*/
|
|
1729
|
+
getClient() {
|
|
1730
|
+
return this._client;
|
|
1706
1731
|
}
|
|
1707
1732
|
/**
|
|
1708
1733
|
* Get the operation log store (lazy initialization)
|
|
1709
1734
|
* @internal
|
|
1710
1735
|
*/
|
|
1711
1736
|
getOperationLogStore() {
|
|
1712
|
-
return this._operationLogStore || (this._operationLogStore =
|
|
1737
|
+
return this._operationLogStore || (this._operationLogStore = Ct(), this._operationLogConfig && this._operationLogStore.configure(this._operationLogConfig)), this._operationLogStore;
|
|
1713
1738
|
}
|
|
1714
1739
|
/**
|
|
1715
1740
|
* Initialize the HST store structure
|
|
1716
1741
|
*/
|
|
1717
1742
|
initializeHSTStore() {
|
|
1718
1743
|
const e = {};
|
|
1719
|
-
Object.keys(this.registry.registry).forEach((
|
|
1720
|
-
e[
|
|
1721
|
-
}), this.hstStore =
|
|
1744
|
+
Object.keys(this.registry.registry).forEach((t) => {
|
|
1745
|
+
e[t] = {};
|
|
1746
|
+
}), this.hstStore = Co(yt(e), "StonecropStore");
|
|
1722
1747
|
}
|
|
1723
1748
|
/**
|
|
1724
1749
|
* Setup automatic sync with Registry when doctypes are added
|
|
1725
1750
|
*/
|
|
1726
1751
|
setupRegistrySync() {
|
|
1727
1752
|
const e = this.registry.addDoctype.bind(this.registry);
|
|
1728
|
-
this.registry.addDoctype = (
|
|
1729
|
-
e(
|
|
1753
|
+
this.registry.addDoctype = (t) => {
|
|
1754
|
+
e(t), this.hstStore.has(t.slug) || this.hstStore.set(t.slug, {});
|
|
1730
1755
|
};
|
|
1731
1756
|
}
|
|
1732
1757
|
/**
|
|
@@ -1735,8 +1760,8 @@ class $o {
|
|
|
1735
1760
|
* @returns HST node containing records hash
|
|
1736
1761
|
*/
|
|
1737
1762
|
records(e) {
|
|
1738
|
-
const
|
|
1739
|
-
return this.ensureDoctypeExists(
|
|
1763
|
+
const t = typeof e == "string" ? e : e.slug;
|
|
1764
|
+
return this.ensureDoctypeExists(t), this.hstStore.getNode(t);
|
|
1740
1765
|
}
|
|
1741
1766
|
/**
|
|
1742
1767
|
* Add a record to the store
|
|
@@ -1744,9 +1769,9 @@ class $o {
|
|
|
1744
1769
|
* @param recordId - The record ID
|
|
1745
1770
|
* @param recordData - The record data
|
|
1746
1771
|
*/
|
|
1747
|
-
addRecord(e,
|
|
1772
|
+
addRecord(e, t, o) {
|
|
1748
1773
|
const r = typeof e == "string" ? e : e.slug;
|
|
1749
|
-
this.ensureDoctypeExists(r), this.hstStore.set(`${r}.${
|
|
1774
|
+
this.ensureDoctypeExists(r), this.hstStore.set(`${r}.${t}`, o);
|
|
1750
1775
|
}
|
|
1751
1776
|
/**
|
|
1752
1777
|
* Get a specific record
|
|
@@ -1754,19 +1779,19 @@ class $o {
|
|
|
1754
1779
|
* @param recordId - The record ID
|
|
1755
1780
|
* @returns HST node for the record or undefined
|
|
1756
1781
|
*/
|
|
1757
|
-
getRecordById(e,
|
|
1758
|
-
const
|
|
1759
|
-
if (this.ensureDoctypeExists(
|
|
1760
|
-
return this.hstStore.getNode(`${
|
|
1782
|
+
getRecordById(e, t) {
|
|
1783
|
+
const o = typeof e == "string" ? e : e.slug;
|
|
1784
|
+
if (this.ensureDoctypeExists(o), !(!this.hstStore.has(`${o}.${t}`) || this.hstStore.get(`${o}.${t}`) === void 0))
|
|
1785
|
+
return this.hstStore.getNode(`${o}.${t}`);
|
|
1761
1786
|
}
|
|
1762
1787
|
/**
|
|
1763
1788
|
* Remove a record from the store
|
|
1764
1789
|
* @param doctype - The doctype
|
|
1765
1790
|
* @param recordId - The record ID
|
|
1766
1791
|
*/
|
|
1767
|
-
removeRecord(e,
|
|
1768
|
-
const
|
|
1769
|
-
this.ensureDoctypeExists(
|
|
1792
|
+
removeRecord(e, t) {
|
|
1793
|
+
const o = typeof e == "string" ? e : e.slug;
|
|
1794
|
+
this.ensureDoctypeExists(o), this.hstStore.has(`${o}.${t}`) && this.hstStore.set(`${o}.${t}`, void 0);
|
|
1770
1795
|
}
|
|
1771
1796
|
/**
|
|
1772
1797
|
* Get all record IDs for a doctype
|
|
@@ -1774,19 +1799,19 @@ class $o {
|
|
|
1774
1799
|
* @returns Array of record IDs
|
|
1775
1800
|
*/
|
|
1776
1801
|
getRecordIds(e) {
|
|
1777
|
-
const
|
|
1778
|
-
this.ensureDoctypeExists(
|
|
1779
|
-
const
|
|
1780
|
-
return !
|
|
1802
|
+
const t = typeof e == "string" ? e : e.slug;
|
|
1803
|
+
this.ensureDoctypeExists(t);
|
|
1804
|
+
const o = this.hstStore.get(t);
|
|
1805
|
+
return !o || typeof o != "object" ? [] : Object.keys(o).filter((r) => o[r] !== void 0);
|
|
1781
1806
|
}
|
|
1782
1807
|
/**
|
|
1783
1808
|
* Clear all records for a doctype
|
|
1784
1809
|
* @param doctype - The doctype
|
|
1785
1810
|
*/
|
|
1786
1811
|
clearRecords(e) {
|
|
1787
|
-
const
|
|
1788
|
-
this.ensureDoctypeExists(
|
|
1789
|
-
this.hstStore.set(`${
|
|
1812
|
+
const t = typeof e == "string" ? e : e.slug;
|
|
1813
|
+
this.ensureDoctypeExists(t), this.getRecordIds(t).forEach((o) => {
|
|
1814
|
+
this.hstStore.set(`${t}.${o}`, void 0);
|
|
1790
1815
|
});
|
|
1791
1816
|
}
|
|
1792
1817
|
/**
|
|
@@ -1803,39 +1828,66 @@ class $o {
|
|
|
1803
1828
|
* @param action - The action to run
|
|
1804
1829
|
* @param args - Action arguments (typically record IDs)
|
|
1805
1830
|
*/
|
|
1806
|
-
runAction(e,
|
|
1807
|
-
const r = this.registry.registry[e.slug]?.actions?.get(
|
|
1808
|
-
let
|
|
1831
|
+
runAction(e, t, o) {
|
|
1832
|
+
const r = this.registry.registry[e.slug]?.actions?.get(t), a = Array.isArray(o) ? o.filter((u) => typeof u == "string") : void 0, s = this.getOperationLogStore();
|
|
1833
|
+
let c = "success", d;
|
|
1809
1834
|
try {
|
|
1810
|
-
r && r.length > 0 && r.forEach((
|
|
1835
|
+
r && r.length > 0 && r.forEach((u) => {
|
|
1811
1836
|
try {
|
|
1812
|
-
new Function("args",
|
|
1813
|
-
} catch (
|
|
1814
|
-
throw
|
|
1837
|
+
new Function("args", u)(o);
|
|
1838
|
+
} catch (w) {
|
|
1839
|
+
throw c = "failure", d = w instanceof Error ? w.message : "Unknown error", w;
|
|
1815
1840
|
}
|
|
1816
1841
|
});
|
|
1817
1842
|
} catch {
|
|
1818
1843
|
} finally {
|
|
1819
|
-
|
|
1844
|
+
s.logAction(e.doctype, t, a, c, d);
|
|
1820
1845
|
}
|
|
1821
1846
|
}
|
|
1822
1847
|
/**
|
|
1823
|
-
* Get records from server
|
|
1848
|
+
* Get records from server using the configured data client.
|
|
1824
1849
|
* @param doctype - The doctype
|
|
1850
|
+
* @throws Error if no data client has been configured
|
|
1825
1851
|
*/
|
|
1826
1852
|
async getRecords(e) {
|
|
1827
|
-
|
|
1828
|
-
|
|
1853
|
+
if (!this._client)
|
|
1854
|
+
throw new Error(
|
|
1855
|
+
"No data client configured. Call setClient() with a DataClient implementation (e.g., StonecropClient from @stonecrop/graphql-client) before fetching records."
|
|
1856
|
+
);
|
|
1857
|
+
(await this._client.getRecords(e)).forEach((t) => {
|
|
1858
|
+
t.id && this.addRecord(e, t.id, t);
|
|
1829
1859
|
});
|
|
1830
1860
|
}
|
|
1831
1861
|
/**
|
|
1832
|
-
* Get single record from server
|
|
1862
|
+
* Get single record from server using the configured data client.
|
|
1833
1863
|
* @param doctype - The doctype
|
|
1834
1864
|
* @param recordId - The record ID
|
|
1865
|
+
* @throws Error if no data client has been configured
|
|
1835
1866
|
*/
|
|
1836
|
-
async getRecord(e,
|
|
1837
|
-
|
|
1838
|
-
|
|
1867
|
+
async getRecord(e, t) {
|
|
1868
|
+
if (!this._client)
|
|
1869
|
+
throw new Error(
|
|
1870
|
+
"No data client configured. Call setClient() with a DataClient implementation (e.g., StonecropClient from @stonecrop/graphql-client) before fetching records."
|
|
1871
|
+
);
|
|
1872
|
+
const o = await this._client.getRecord(e, t);
|
|
1873
|
+
o && this.addRecord(e, t, o);
|
|
1874
|
+
}
|
|
1875
|
+
/**
|
|
1876
|
+
* Dispatch an action to the server via the configured data client.
|
|
1877
|
+
* All state changes flow through this single mutation endpoint.
|
|
1878
|
+
*
|
|
1879
|
+
* @param doctype - The doctype
|
|
1880
|
+
* @param action - Action name to execute (e.g., 'SUBMIT', 'APPROVE', 'save')
|
|
1881
|
+
* @param args - Action arguments (typically record ID and/or form data)
|
|
1882
|
+
* @returns Action result with success status, response data, and any error
|
|
1883
|
+
* @throws Error if no data client has been configured
|
|
1884
|
+
*/
|
|
1885
|
+
async dispatchAction(e, t, o) {
|
|
1886
|
+
if (!this._client)
|
|
1887
|
+
throw new Error(
|
|
1888
|
+
"No data client configured. Call setClient() with a DataClient implementation (e.g., StonecropClient from @stonecrop/graphql-client) before dispatching actions."
|
|
1889
|
+
);
|
|
1890
|
+
return this._client.runAction(e, t, o);
|
|
1839
1891
|
}
|
|
1840
1892
|
/**
|
|
1841
1893
|
* Ensure doctype section exists in HST store
|
|
@@ -1861,252 +1913,271 @@ class $o {
|
|
|
1861
1913
|
getStore() {
|
|
1862
1914
|
return this.hstStore;
|
|
1863
1915
|
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Determine the current workflow state for a record.
|
|
1918
|
+
*
|
|
1919
|
+
* Reads the record's `status` field from the HST store. If the field is absent or
|
|
1920
|
+
* empty the doctype's declared `workflow.initial` state is used as the fallback,
|
|
1921
|
+
* giving callers a reliable state name without having to duplicate that logic.
|
|
1922
|
+
*
|
|
1923
|
+
* @param doctype - The doctype slug or DoctypeMeta instance
|
|
1924
|
+
* @param recordId - The record identifier
|
|
1925
|
+
* @returns The current state name, or an empty string if the doctype has no workflow
|
|
1926
|
+
*
|
|
1927
|
+
* @public
|
|
1928
|
+
*/
|
|
1929
|
+
getRecordState(e, t) {
|
|
1930
|
+
const o = typeof e == "string" ? e : e.slug, r = this.registry.getDoctype(o);
|
|
1931
|
+
if (!r?.workflow) return "";
|
|
1932
|
+
const a = this.getRecordById(o, t)?.get("status"), s = typeof r.workflow.initial == "string" ? r.workflow.initial : Object.keys(r.workflow.states ?? {})[0] ?? "";
|
|
1933
|
+
return a || s;
|
|
1934
|
+
}
|
|
1864
1935
|
}
|
|
1865
|
-
function
|
|
1866
|
-
|
|
1867
|
-
const e =
|
|
1868
|
-
if (
|
|
1869
|
-
const
|
|
1870
|
-
|
|
1871
|
-
}
|
|
1872
|
-
const
|
|
1873
|
-
() =>
|
|
1936
|
+
function Do(n) {
|
|
1937
|
+
n || (n = {});
|
|
1938
|
+
const e = n.registry || we("$registry"), t = we("$stonecrop"), o = $(), r = $(), a = $({}), s = $(), c = $(), d = $([]);
|
|
1939
|
+
if (n.doctype && e) {
|
|
1940
|
+
const _ = n.doctype.schema ? Array.isArray(n.doctype.schema) ? n.doctype.schema : Array.from(n.doctype.schema) : [];
|
|
1941
|
+
d.value = e.resolveSchema(_);
|
|
1942
|
+
}
|
|
1943
|
+
const u = $([]), w = $(-1), v = R(() => o.value?.getOperationLogStore().canUndo ?? !1), h = R(() => o.value?.getOperationLogStore().canRedo ?? !1), b = R(() => o.value?.getOperationLogStore().undoCount ?? 0), m = R(() => o.value?.getOperationLogStore().redoCount ?? 0), k = R(
|
|
1944
|
+
() => o.value?.getOperationLogStore().undoRedoState ?? {
|
|
1874
1945
|
canUndo: !1,
|
|
1875
1946
|
canRedo: !1,
|
|
1876
1947
|
undoCount: 0,
|
|
1877
1948
|
redoCount: 0,
|
|
1878
1949
|
currentIndex: -1
|
|
1879
1950
|
}
|
|
1880
|
-
),
|
|
1881
|
-
|
|
1882
|
-
}, U = (
|
|
1883
|
-
|
|
1884
|
-
},
|
|
1885
|
-
|
|
1886
|
-
},
|
|
1951
|
+
), I = (_) => o.value?.getOperationLogStore().undo(_) ?? !1, T = (_) => o.value?.getOperationLogStore().redo(_) ?? !1, Z = () => {
|
|
1952
|
+
o.value?.getOperationLogStore().startBatch();
|
|
1953
|
+
}, U = (_) => o.value?.getOperationLogStore().commitBatch(_) ?? null, z = () => {
|
|
1954
|
+
o.value?.getOperationLogStore().cancelBatch();
|
|
1955
|
+
}, L = () => {
|
|
1956
|
+
o.value?.getOperationLogStore().clear();
|
|
1957
|
+
}, G = (_, C) => o.value?.getOperationLogStore().getOperationsFor(_, C) ?? [], E = () => o.value?.getOperationLogStore().getSnapshot() ?? {
|
|
1887
1958
|
operations: [],
|
|
1888
1959
|
currentIndex: -1,
|
|
1889
1960
|
totalOperations: 0,
|
|
1890
1961
|
reversibleOperations: 0,
|
|
1891
1962
|
irreversibleOperations: 0
|
|
1892
|
-
}, Y = (
|
|
1893
|
-
|
|
1894
|
-
}, B = (
|
|
1895
|
-
|
|
1963
|
+
}, Y = (_, C) => {
|
|
1964
|
+
o.value?.getOperationLogStore().markIrreversible(_, C);
|
|
1965
|
+
}, B = (_, C, S, p = "success", f) => o.value?.getOperationLogStore().logAction(_, C, S, p, f) ?? "", g = (_) => {
|
|
1966
|
+
o.value?.getOperationLogStore().configure(_);
|
|
1896
1967
|
};
|
|
1897
|
-
|
|
1968
|
+
xe(async () => {
|
|
1898
1969
|
if (e) {
|
|
1899
|
-
|
|
1970
|
+
o.value = t || new No(e);
|
|
1900
1971
|
try {
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
() =>
|
|
1972
|
+
const _ = o.value.getOperationLogStore(), C = oo(_);
|
|
1973
|
+
u.value = C.operations.value, w.value = C.currentIndex.value, H(
|
|
1974
|
+
() => C.operations.value,
|
|
1904
1975
|
(S) => {
|
|
1905
|
-
|
|
1976
|
+
u.value = S;
|
|
1906
1977
|
}
|
|
1907
|
-
),
|
|
1908
|
-
() =>
|
|
1978
|
+
), H(
|
|
1979
|
+
() => C.currentIndex.value,
|
|
1909
1980
|
(S) => {
|
|
1910
|
-
|
|
1981
|
+
w.value = S;
|
|
1911
1982
|
}
|
|
1912
1983
|
);
|
|
1913
1984
|
} catch {
|
|
1914
1985
|
}
|
|
1915
|
-
if (!
|
|
1916
|
-
const
|
|
1917
|
-
if (!
|
|
1918
|
-
const
|
|
1919
|
-
if (
|
|
1920
|
-
const
|
|
1921
|
-
path:
|
|
1922
|
-
segments:
|
|
1923
|
-
},
|
|
1924
|
-
if (
|
|
1925
|
-
if (e.addDoctype(
|
|
1926
|
-
const
|
|
1927
|
-
|
|
1986
|
+
if (!n.doctype && e.router) {
|
|
1987
|
+
const _ = e.router.currentRoute.value;
|
|
1988
|
+
if (!_.path) return;
|
|
1989
|
+
const C = _.path.split("/").filter((p) => p.length > 0), S = C[1]?.toLowerCase();
|
|
1990
|
+
if (C.length > 0) {
|
|
1991
|
+
const p = {
|
|
1992
|
+
path: _.path,
|
|
1993
|
+
segments: C
|
|
1994
|
+
}, f = await e.getMeta?.(p);
|
|
1995
|
+
if (f) {
|
|
1996
|
+
if (e.addDoctype(f), o.value.setup(f), s.value = f, c.value = S, r.value = o.value.getStore(), e) {
|
|
1997
|
+
const i = f.schema ? Array.isArray(f.schema) ? f.schema : Array.from(f.schema) : [];
|
|
1998
|
+
d.value = e.resolveSchema(i);
|
|
1928
1999
|
}
|
|
1929
2000
|
if (S && S !== "new") {
|
|
1930
|
-
const
|
|
1931
|
-
if (
|
|
1932
|
-
|
|
2001
|
+
const i = o.value.getRecordById(f, S);
|
|
2002
|
+
if (i)
|
|
2003
|
+
a.value = i.get("") || {};
|
|
1933
2004
|
else
|
|
1934
2005
|
try {
|
|
1935
|
-
await
|
|
1936
|
-
const
|
|
1937
|
-
|
|
2006
|
+
await o.value.getRecord(f, S);
|
|
2007
|
+
const l = o.value.getRecordById(f, S);
|
|
2008
|
+
l && (a.value = l.get("") || {});
|
|
1938
2009
|
} catch {
|
|
1939
|
-
|
|
2010
|
+
a.value = te(f);
|
|
1940
2011
|
}
|
|
1941
2012
|
} else
|
|
1942
|
-
|
|
1943
|
-
r.value && dt(
|
|
2013
|
+
a.value = te(f);
|
|
2014
|
+
r.value && dt(f, S || "new", a, r.value), o.value.runAction(f, "load", S ? [S] : void 0);
|
|
1944
2015
|
}
|
|
1945
2016
|
}
|
|
1946
2017
|
}
|
|
1947
|
-
if (
|
|
1948
|
-
r.value =
|
|
1949
|
-
const
|
|
1950
|
-
if (
|
|
1951
|
-
const S =
|
|
2018
|
+
if (n.doctype) {
|
|
2019
|
+
r.value = o.value.getStore();
|
|
2020
|
+
const _ = n.doctype, C = n.recordId;
|
|
2021
|
+
if (C && C !== "new") {
|
|
2022
|
+
const S = o.value.getRecordById(_, C);
|
|
1952
2023
|
if (S)
|
|
1953
|
-
|
|
2024
|
+
a.value = S.get("") || {};
|
|
1954
2025
|
else
|
|
1955
2026
|
try {
|
|
1956
|
-
await
|
|
1957
|
-
const
|
|
1958
|
-
|
|
2027
|
+
await o.value.getRecord(_, C);
|
|
2028
|
+
const p = o.value.getRecordById(_, C);
|
|
2029
|
+
p && (a.value = p.get("") || {});
|
|
1959
2030
|
} catch {
|
|
1960
|
-
|
|
2031
|
+
a.value = te(_);
|
|
1961
2032
|
}
|
|
1962
2033
|
} else
|
|
1963
|
-
|
|
1964
|
-
r.value && dt(
|
|
2034
|
+
a.value = te(_);
|
|
2035
|
+
r.value && dt(_, C || "new", a, r.value);
|
|
1965
2036
|
}
|
|
1966
2037
|
}
|
|
1967
2038
|
});
|
|
1968
|
-
const
|
|
1969
|
-
const S =
|
|
2039
|
+
const y = (_, C) => {
|
|
2040
|
+
const S = n.doctype || s.value;
|
|
1970
2041
|
if (!S) return "";
|
|
1971
|
-
const
|
|
1972
|
-
return `${S.slug}.${
|
|
1973
|
-
},
|
|
1974
|
-
const
|
|
1975
|
-
if (!(!r.value || !
|
|
2042
|
+
const p = C || n.recordId || c.value || "new";
|
|
2043
|
+
return `${S.slug}.${p}.${_}`;
|
|
2044
|
+
}, D = (_) => {
|
|
2045
|
+
const C = n.doctype || s.value;
|
|
2046
|
+
if (!(!r.value || !o.value || !C))
|
|
1976
2047
|
try {
|
|
1977
|
-
const S =
|
|
2048
|
+
const S = _.path.split(".");
|
|
1978
2049
|
if (S.length >= 2) {
|
|
1979
|
-
const
|
|
1980
|
-
if (r.value.has(`${
|
|
1981
|
-
const
|
|
1982
|
-
let
|
|
1983
|
-
for (let
|
|
1984
|
-
if (
|
|
1985
|
-
const
|
|
1986
|
-
r.value.set(
|
|
2050
|
+
const i = S[0], l = S[1];
|
|
2051
|
+
if (r.value.has(`${i}.${l}`) || o.value.addRecord(C, l, { ...a.value }), S.length > 3) {
|
|
2052
|
+
const A = `${i}.${l}`, O = S.slice(2);
|
|
2053
|
+
let W = A;
|
|
2054
|
+
for (let J = 0; J < O.length - 1; J++)
|
|
2055
|
+
if (W += `.${O[J]}`, !r.value.has(W)) {
|
|
2056
|
+
const Q = O[J + 1], _e = !isNaN(Number(Q));
|
|
2057
|
+
r.value.set(W, _e ? [] : {});
|
|
1987
2058
|
}
|
|
1988
2059
|
}
|
|
1989
2060
|
}
|
|
1990
|
-
r.value.set(
|
|
1991
|
-
const
|
|
1992
|
-
|
|
2061
|
+
r.value.set(_.path, _.value);
|
|
2062
|
+
const p = _.fieldname.split("."), f = { ...a.value };
|
|
2063
|
+
p.length === 1 ? f[p[0]] = _.value : Oo(f, p, _.value), a.value = f;
|
|
1993
2064
|
} catch {
|
|
1994
2065
|
}
|
|
1995
2066
|
};
|
|
1996
|
-
(
|
|
1997
|
-
const
|
|
1998
|
-
if (!
|
|
1999
|
-
return
|
|
2067
|
+
(n.doctype || e?.router) && (Ge("hstPathProvider", y), Ge("hstChangeHandler", D));
|
|
2068
|
+
const F = (_, C, S) => {
|
|
2069
|
+
if (!o.value)
|
|
2070
|
+
return te(C);
|
|
2000
2071
|
if (S)
|
|
2001
2072
|
try {
|
|
2002
|
-
const
|
|
2003
|
-
return
|
|
2073
|
+
const p = r.value?.get(_);
|
|
2074
|
+
return p && typeof p == "object" ? p : te(C);
|
|
2004
2075
|
} catch {
|
|
2005
|
-
return
|
|
2076
|
+
return te(C);
|
|
2006
2077
|
}
|
|
2007
|
-
return
|
|
2008
|
-
},
|
|
2009
|
-
if (!r.value || !
|
|
2078
|
+
return te(C);
|
|
2079
|
+
}, N = (_, C) => {
|
|
2080
|
+
if (!r.value || !o.value)
|
|
2010
2081
|
throw new Error("HST store not initialized");
|
|
2011
|
-
const S = `${
|
|
2012
|
-
(
|
|
2082
|
+
const S = `${_.slug}.${C}`, p = { ...r.value.get(S) || {} }, f = _.schema ? Array.isArray(_.schema) ? _.schema : Array.from(_.schema) : [], i = (e ? e.resolveSchema(f) : f).filter(
|
|
2083
|
+
(l) => "fieldtype" in l && l.fieldtype === "Doctype" && "schema" in l && Array.isArray(l.schema)
|
|
2013
2084
|
);
|
|
2014
|
-
for (const
|
|
2015
|
-
const
|
|
2016
|
-
|
|
2085
|
+
for (const l of i) {
|
|
2086
|
+
const A = l, O = `${S}.${A.fieldname}`, W = Nt(A.schema, O, r.value);
|
|
2087
|
+
p[A.fieldname] = W;
|
|
2017
2088
|
}
|
|
2018
|
-
return
|
|
2019
|
-
},
|
|
2020
|
-
provideHSTPath: (S) => `${
|
|
2089
|
+
return p;
|
|
2090
|
+
}, V = (_, C) => ({
|
|
2091
|
+
provideHSTPath: (S) => `${_}.${S}`,
|
|
2021
2092
|
handleHSTChange: (S) => {
|
|
2022
|
-
const
|
|
2023
|
-
|
|
2093
|
+
const p = S.path.startsWith(_) ? S.path : `${_}.${S.fieldname}`;
|
|
2094
|
+
D({
|
|
2024
2095
|
...S,
|
|
2025
|
-
path:
|
|
2096
|
+
path: p
|
|
2026
2097
|
});
|
|
2027
2098
|
}
|
|
2028
|
-
}),
|
|
2029
|
-
operations:
|
|
2030
|
-
currentIndex:
|
|
2031
|
-
undoRedoState:
|
|
2032
|
-
canUndo:
|
|
2099
|
+
}), M = {
|
|
2100
|
+
operations: u,
|
|
2101
|
+
currentIndex: w,
|
|
2102
|
+
undoRedoState: k,
|
|
2103
|
+
canUndo: v,
|
|
2033
2104
|
canRedo: h,
|
|
2034
|
-
undoCount:
|
|
2105
|
+
undoCount: b,
|
|
2035
2106
|
redoCount: m,
|
|
2036
|
-
undo:
|
|
2037
|
-
redo:
|
|
2038
|
-
startBatch:
|
|
2107
|
+
undo: I,
|
|
2108
|
+
redo: T,
|
|
2109
|
+
startBatch: Z,
|
|
2039
2110
|
commitBatch: U,
|
|
2040
|
-
cancelBatch:
|
|
2041
|
-
clear:
|
|
2042
|
-
getOperationsFor:
|
|
2111
|
+
cancelBatch: z,
|
|
2112
|
+
clear: L,
|
|
2113
|
+
getOperationsFor: G,
|
|
2043
2114
|
getSnapshot: E,
|
|
2044
2115
|
markIrreversible: Y,
|
|
2045
2116
|
logAction: B,
|
|
2046
|
-
configure:
|
|
2117
|
+
configure: g
|
|
2047
2118
|
};
|
|
2048
|
-
return
|
|
2049
|
-
stonecrop:
|
|
2050
|
-
operationLog:
|
|
2051
|
-
provideHSTPath:
|
|
2052
|
-
handleHSTChange:
|
|
2119
|
+
return n.doctype ? {
|
|
2120
|
+
stonecrop: o,
|
|
2121
|
+
operationLog: M,
|
|
2122
|
+
provideHSTPath: y,
|
|
2123
|
+
handleHSTChange: D,
|
|
2053
2124
|
hstStore: r,
|
|
2054
|
-
formData:
|
|
2055
|
-
resolvedSchema:
|
|
2056
|
-
loadNestedData:
|
|
2057
|
-
saveRecursive:
|
|
2058
|
-
createNestedContext:
|
|
2059
|
-
} : !
|
|
2060
|
-
stonecrop:
|
|
2061
|
-
operationLog:
|
|
2062
|
-
provideHSTPath:
|
|
2063
|
-
handleHSTChange:
|
|
2125
|
+
formData: a,
|
|
2126
|
+
resolvedSchema: d,
|
|
2127
|
+
loadNestedData: F,
|
|
2128
|
+
saveRecursive: N,
|
|
2129
|
+
createNestedContext: V
|
|
2130
|
+
} : !n.doctype && e?.router ? {
|
|
2131
|
+
stonecrop: o,
|
|
2132
|
+
operationLog: M,
|
|
2133
|
+
provideHSTPath: y,
|
|
2134
|
+
handleHSTChange: D,
|
|
2064
2135
|
hstStore: r,
|
|
2065
|
-
formData:
|
|
2066
|
-
resolvedSchema:
|
|
2067
|
-
loadNestedData:
|
|
2068
|
-
saveRecursive:
|
|
2069
|
-
createNestedContext:
|
|
2136
|
+
formData: a,
|
|
2137
|
+
resolvedSchema: d,
|
|
2138
|
+
loadNestedData: F,
|
|
2139
|
+
saveRecursive: N,
|
|
2140
|
+
createNestedContext: V
|
|
2070
2141
|
} : {
|
|
2071
|
-
stonecrop:
|
|
2072
|
-
operationLog:
|
|
2142
|
+
stonecrop: o,
|
|
2143
|
+
operationLog: M
|
|
2073
2144
|
};
|
|
2074
2145
|
}
|
|
2075
|
-
function
|
|
2146
|
+
function te(n) {
|
|
2076
2147
|
const e = {};
|
|
2077
|
-
return
|
|
2078
|
-
switch ("fieldtype" in
|
|
2148
|
+
return n.schema && n.schema.forEach((t) => {
|
|
2149
|
+
switch ("fieldtype" in t ? t.fieldtype : "Data") {
|
|
2079
2150
|
case "Data":
|
|
2080
2151
|
case "Text":
|
|
2081
|
-
e[
|
|
2152
|
+
e[t.fieldname] = "";
|
|
2082
2153
|
break;
|
|
2083
2154
|
case "Check":
|
|
2084
|
-
e[
|
|
2155
|
+
e[t.fieldname] = !1;
|
|
2085
2156
|
break;
|
|
2086
2157
|
case "Int":
|
|
2087
2158
|
case "Float":
|
|
2088
|
-
e[
|
|
2159
|
+
e[t.fieldname] = 0;
|
|
2089
2160
|
break;
|
|
2090
2161
|
case "Table":
|
|
2091
|
-
e[
|
|
2162
|
+
e[t.fieldname] = [];
|
|
2092
2163
|
break;
|
|
2093
2164
|
case "JSON":
|
|
2094
|
-
e[
|
|
2165
|
+
e[t.fieldname] = {};
|
|
2095
2166
|
break;
|
|
2096
2167
|
default:
|
|
2097
|
-
e[
|
|
2168
|
+
e[t.fieldname] = null;
|
|
2098
2169
|
}
|
|
2099
2170
|
}), e;
|
|
2100
2171
|
}
|
|
2101
|
-
function dt(
|
|
2102
|
-
|
|
2103
|
-
|
|
2172
|
+
function dt(n, e, t, o) {
|
|
2173
|
+
H(
|
|
2174
|
+
t,
|
|
2104
2175
|
(r) => {
|
|
2105
|
-
const
|
|
2106
|
-
Object.keys(r).forEach((
|
|
2107
|
-
const
|
|
2176
|
+
const a = `${n.slug}.${e}`;
|
|
2177
|
+
Object.keys(r).forEach((s) => {
|
|
2178
|
+
const c = `${a}.${s}`;
|
|
2108
2179
|
try {
|
|
2109
|
-
|
|
2180
|
+
o.set(c, r[s]);
|
|
2110
2181
|
} catch {
|
|
2111
2182
|
}
|
|
2112
2183
|
});
|
|
@@ -2114,152 +2185,152 @@ function dt(t, e, o, n) {
|
|
|
2114
2185
|
{ deep: !0 }
|
|
2115
2186
|
);
|
|
2116
2187
|
}
|
|
2117
|
-
function
|
|
2118
|
-
let
|
|
2119
|
-
for (let
|
|
2120
|
-
const
|
|
2121
|
-
(!(
|
|
2188
|
+
function Oo(n, e, t) {
|
|
2189
|
+
let o = n;
|
|
2190
|
+
for (let a = 0; a < e.length - 1; a++) {
|
|
2191
|
+
const s = e[a];
|
|
2192
|
+
(!(s in o) || typeof o[s] != "object") && (o[s] = isNaN(Number(e[a + 1])) ? {} : []), o = o[s];
|
|
2122
2193
|
}
|
|
2123
2194
|
const r = e[e.length - 1];
|
|
2124
|
-
|
|
2195
|
+
o[r] = t;
|
|
2125
2196
|
}
|
|
2126
|
-
function
|
|
2127
|
-
const
|
|
2128
|
-
(
|
|
2197
|
+
function Nt(n, e, t) {
|
|
2198
|
+
const o = { ...t.get(e) || {} }, r = n.filter(
|
|
2199
|
+
(a) => "fieldtype" in a && a.fieldtype === "Doctype" && "schema" in a && Array.isArray(a.schema)
|
|
2129
2200
|
);
|
|
2130
|
-
for (const
|
|
2131
|
-
const
|
|
2132
|
-
|
|
2201
|
+
for (const a of r) {
|
|
2202
|
+
const s = a, c = `${e}.${s.fieldname}`, d = Nt(s.schema, c, t);
|
|
2203
|
+
o[s.fieldname] = d;
|
|
2133
2204
|
}
|
|
2134
|
-
return
|
|
2205
|
+
return o;
|
|
2135
2206
|
}
|
|
2136
2207
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
2137
|
-
function
|
|
2138
|
-
return
|
|
2208
|
+
function Ao(n, e) {
|
|
2209
|
+
return Xe() ? (Ye(n, e), !0) : !1;
|
|
2139
2210
|
}
|
|
2140
2211
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
2141
|
-
const
|
|
2212
|
+
const $o = () => {
|
|
2142
2213
|
};
|
|
2143
|
-
function
|
|
2144
|
-
if (
|
|
2145
|
-
const e =
|
|
2146
|
-
return typeof e == "function" ?
|
|
2214
|
+
function Io(...n) {
|
|
2215
|
+
if (n.length !== 1) return re(...n);
|
|
2216
|
+
const e = n[0];
|
|
2217
|
+
return typeof e == "function" ? Pe(et(() => ({
|
|
2147
2218
|
get: e,
|
|
2148
|
-
set:
|
|
2149
|
-
}))) :
|
|
2219
|
+
set: $o
|
|
2220
|
+
}))) : $(e);
|
|
2150
2221
|
}
|
|
2151
|
-
function
|
|
2152
|
-
return typeof Window < "u" &&
|
|
2222
|
+
function Be(n) {
|
|
2223
|
+
return typeof Window < "u" && n instanceof Window ? n.document.documentElement : typeof Document < "u" && n instanceof Document ? n.documentElement : n;
|
|
2153
2224
|
}
|
|
2154
|
-
const
|
|
2155
|
-
function
|
|
2156
|
-
const
|
|
2157
|
-
let
|
|
2158
|
-
|
|
2159
|
-
const
|
|
2160
|
-
if (
|
|
2161
|
-
const
|
|
2162
|
-
if (
|
|
2163
|
-
if (
|
|
2225
|
+
const We = /* @__PURE__ */ new WeakMap();
|
|
2226
|
+
function Ro(n, e = !1) {
|
|
2227
|
+
const t = Se(e);
|
|
2228
|
+
let o = "";
|
|
2229
|
+
H(Io(n), (s) => {
|
|
2230
|
+
const c = Be(K(s));
|
|
2231
|
+
if (c) {
|
|
2232
|
+
const d = c;
|
|
2233
|
+
if (We.get(d) || We.set(d, d.style.overflow), d.style.overflow !== "hidden" && (o = d.style.overflow), d.style.overflow === "hidden") return t.value = !0;
|
|
2234
|
+
if (t.value) return d.style.overflow = "hidden";
|
|
2164
2235
|
}
|
|
2165
2236
|
}, { immediate: !0 });
|
|
2166
2237
|
const r = () => {
|
|
2167
|
-
const
|
|
2168
|
-
!
|
|
2169
|
-
},
|
|
2170
|
-
const
|
|
2171
|
-
!
|
|
2238
|
+
const s = Be(K(n));
|
|
2239
|
+
!s || t.value || (s.style.overflow = "hidden", t.value = !0);
|
|
2240
|
+
}, a = () => {
|
|
2241
|
+
const s = Be(K(n));
|
|
2242
|
+
!s || !t.value || (s.style.overflow = o, We.delete(s), t.value = !1);
|
|
2172
2243
|
};
|
|
2173
|
-
return
|
|
2244
|
+
return Ao(a), R({
|
|
2174
2245
|
get() {
|
|
2175
|
-
return
|
|
2246
|
+
return t.value;
|
|
2176
2247
|
},
|
|
2177
|
-
set(
|
|
2178
|
-
|
|
2248
|
+
set(s) {
|
|
2249
|
+
s ? r() : a();
|
|
2179
2250
|
}
|
|
2180
2251
|
});
|
|
2181
2252
|
}
|
|
2182
|
-
function
|
|
2183
|
-
let
|
|
2253
|
+
function xo() {
|
|
2254
|
+
let n = !1;
|
|
2184
2255
|
const e = Se(!1);
|
|
2185
|
-
return (
|
|
2186
|
-
if (e.value =
|
|
2187
|
-
|
|
2188
|
-
const r =
|
|
2189
|
-
|
|
2256
|
+
return (t, o) => {
|
|
2257
|
+
if (e.value = o.value, n) return;
|
|
2258
|
+
n = !0;
|
|
2259
|
+
const r = Ro(t, o.value);
|
|
2260
|
+
H(e, (a) => r.value = a);
|
|
2190
2261
|
};
|
|
2191
2262
|
}
|
|
2192
|
-
|
|
2193
|
-
const
|
|
2194
|
-
const
|
|
2195
|
-
for (const [
|
|
2196
|
-
o
|
|
2197
|
-
return
|
|
2263
|
+
xo();
|
|
2264
|
+
const To = (n, e) => {
|
|
2265
|
+
const t = n.__vccOpts || n;
|
|
2266
|
+
for (const [o, r] of e)
|
|
2267
|
+
t[o] = r;
|
|
2268
|
+
return t;
|
|
2198
2269
|
};
|
|
2199
|
-
function
|
|
2200
|
-
return
|
|
2270
|
+
function Po(n, e) {
|
|
2271
|
+
return Xe() ? (Ye(n, e), !0) : !1;
|
|
2201
2272
|
}
|
|
2202
2273
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
2203
|
-
const
|
|
2274
|
+
const Vo = () => {
|
|
2204
2275
|
};
|
|
2205
|
-
function
|
|
2206
|
-
if (
|
|
2207
|
-
const e =
|
|
2208
|
-
return typeof e == "function" ?
|
|
2276
|
+
function jo(...n) {
|
|
2277
|
+
if (n.length !== 1) return re(...n);
|
|
2278
|
+
const e = n[0];
|
|
2279
|
+
return typeof e == "function" ? Pe(et(() => ({
|
|
2209
2280
|
get: e,
|
|
2210
|
-
set:
|
|
2211
|
-
}))) :
|
|
2281
|
+
set: Vo
|
|
2282
|
+
}))) : $(e);
|
|
2212
2283
|
}
|
|
2213
|
-
function
|
|
2214
|
-
return typeof Window < "u" &&
|
|
2284
|
+
function He(n) {
|
|
2285
|
+
return typeof Window < "u" && n instanceof Window ? n.document.documentElement : typeof Document < "u" && n instanceof Document ? n.documentElement : n;
|
|
2215
2286
|
}
|
|
2216
|
-
const
|
|
2217
|
-
function
|
|
2218
|
-
const
|
|
2219
|
-
let
|
|
2220
|
-
|
|
2221
|
-
const
|
|
2222
|
-
if (
|
|
2223
|
-
const
|
|
2224
|
-
if (
|
|
2225
|
-
if (
|
|
2287
|
+
const Ue = /* @__PURE__ */ new WeakMap();
|
|
2288
|
+
function Mo(n, e = !1) {
|
|
2289
|
+
const t = Se(e);
|
|
2290
|
+
let o = "";
|
|
2291
|
+
H(jo(n), (s) => {
|
|
2292
|
+
const c = He(K(s));
|
|
2293
|
+
if (c) {
|
|
2294
|
+
const d = c;
|
|
2295
|
+
if (Ue.get(d) || Ue.set(d, d.style.overflow), d.style.overflow !== "hidden" && (o = d.style.overflow), d.style.overflow === "hidden") return t.value = !0;
|
|
2296
|
+
if (t.value) return d.style.overflow = "hidden";
|
|
2226
2297
|
}
|
|
2227
2298
|
}, { immediate: !0 });
|
|
2228
2299
|
const r = () => {
|
|
2229
|
-
const
|
|
2230
|
-
!
|
|
2231
|
-
},
|
|
2232
|
-
const
|
|
2233
|
-
!
|
|
2300
|
+
const s = He(K(n));
|
|
2301
|
+
!s || t.value || (s.style.overflow = "hidden", t.value = !0);
|
|
2302
|
+
}, a = () => {
|
|
2303
|
+
const s = He(K(n));
|
|
2304
|
+
!s || !t.value || (s.style.overflow = o, Ue.delete(s), t.value = !1);
|
|
2234
2305
|
};
|
|
2235
|
-
return
|
|
2306
|
+
return Po(a), R({
|
|
2236
2307
|
get() {
|
|
2237
|
-
return
|
|
2308
|
+
return t.value;
|
|
2238
2309
|
},
|
|
2239
|
-
set(
|
|
2240
|
-
|
|
2310
|
+
set(s) {
|
|
2311
|
+
s ? r() : a();
|
|
2241
2312
|
}
|
|
2242
2313
|
});
|
|
2243
2314
|
}
|
|
2244
|
-
function
|
|
2245
|
-
let
|
|
2315
|
+
function Fo() {
|
|
2316
|
+
let n = !1;
|
|
2246
2317
|
const e = Se(!1);
|
|
2247
|
-
return (
|
|
2248
|
-
if (e.value =
|
|
2249
|
-
|
|
2250
|
-
const r =
|
|
2251
|
-
|
|
2318
|
+
return (t, o) => {
|
|
2319
|
+
if (e.value = o.value, n) return;
|
|
2320
|
+
n = !0;
|
|
2321
|
+
const r = Mo(t, o.value);
|
|
2322
|
+
H(e, (a) => r.value = a);
|
|
2252
2323
|
};
|
|
2253
2324
|
}
|
|
2254
|
-
|
|
2325
|
+
Fo();
|
|
2255
2326
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
2256
|
-
const
|
|
2327
|
+
const Lo = { class: "aform" }, Bo = {
|
|
2257
2328
|
key: 0,
|
|
2258
2329
|
class: "aform-nested-section"
|
|
2259
|
-
},
|
|
2330
|
+
}, Wo = {
|
|
2260
2331
|
key: 0,
|
|
2261
2332
|
class: "aform-nested-label"
|
|
2262
|
-
},
|
|
2333
|
+
}, Ho = /* @__PURE__ */ be({
|
|
2263
2334
|
__name: "AForm",
|
|
2264
2335
|
props: /* @__PURE__ */ ot({
|
|
2265
2336
|
schema: {},
|
|
@@ -2269,110 +2340,110 @@ const Wo = { class: "aform" }, Ho = {
|
|
|
2269
2340
|
dataModifiers: {}
|
|
2270
2341
|
}),
|
|
2271
2342
|
emits: /* @__PURE__ */ ot(["update:schema", "update:data"], ["update:data"]),
|
|
2272
|
-
setup(
|
|
2273
|
-
const
|
|
2274
|
-
|
|
2275
|
-
() =>
|
|
2276
|
-
(
|
|
2277
|
-
!
|
|
2278
|
-
"schema" in h && Array.isArray(h.schema) && h.schema.length > 0 && (r.value[h.fieldname] =
|
|
2343
|
+
setup(n, { emit: e }) {
|
|
2344
|
+
const t = e, o = It(n, "data"), r = $({});
|
|
2345
|
+
H(
|
|
2346
|
+
() => o.value,
|
|
2347
|
+
(v) => {
|
|
2348
|
+
!n.schema || !v || n.schema.forEach((h) => {
|
|
2349
|
+
"schema" in h && Array.isArray(h.schema) && h.schema.length > 0 && (r.value[h.fieldname] = v[h.fieldname] ?? {});
|
|
2279
2350
|
});
|
|
2280
2351
|
},
|
|
2281
2352
|
{ immediate: !0 }
|
|
2282
2353
|
);
|
|
2283
|
-
const
|
|
2284
|
-
r.value[
|
|
2285
|
-
},
|
|
2354
|
+
const a = (v, h) => {
|
|
2355
|
+
r.value[v] = h, o.value && (o.value[v] = h, t("update:data", { ...o.value }));
|
|
2356
|
+
}, s = (v) => {
|
|
2286
2357
|
const h = {};
|
|
2287
|
-
for (const [
|
|
2288
|
-
["component", "fieldtype", "mode"].includes(
|
|
2358
|
+
for (const [b, m] of Object.entries(v))
|
|
2359
|
+
["component", "fieldtype", "mode"].includes(b) || (h[b] = m), b === "rows" && (!m || Array.isArray(m) && m.length === 0) && (h.rows = o.value[v.fieldname] || []);
|
|
2289
2360
|
return h;
|
|
2290
|
-
},
|
|
2291
|
-
function
|
|
2292
|
-
return
|
|
2361
|
+
}, c = R(() => n.mode ?? "edit");
|
|
2362
|
+
function d(v) {
|
|
2363
|
+
return v.mode || c.value;
|
|
2293
2364
|
}
|
|
2294
|
-
const
|
|
2295
|
-
|
|
2296
|
-
|
|
2365
|
+
const u = $([]);
|
|
2366
|
+
Rt(() => {
|
|
2367
|
+
n.schema && u.value.length !== n.schema.length && (u.value = n.schema.map((v, h) => R({
|
|
2297
2368
|
get() {
|
|
2298
|
-
return
|
|
2369
|
+
return o.value?.[n.schema[h].fieldname];
|
|
2299
2370
|
},
|
|
2300
|
-
set: (
|
|
2301
|
-
const m =
|
|
2302
|
-
m &&
|
|
2371
|
+
set: (b) => {
|
|
2372
|
+
const m = n.schema[h].fieldname;
|
|
2373
|
+
m && o.value && (o.value[m] = b, t("update:data", { ...o.value })), t("update:schema", n.schema);
|
|
2303
2374
|
}
|
|
2304
2375
|
})));
|
|
2305
2376
|
});
|
|
2306
|
-
const
|
|
2307
|
-
return (
|
|
2308
|
-
const
|
|
2309
|
-
return P(),
|
|
2310
|
-
(P(!0),
|
|
2311
|
-
"schema" in m && Array.isArray(m.schema) && m.schema.length > 0 ? (P(),
|
|
2312
|
-
m.label ? (P(),
|
|
2313
|
-
ne(
|
|
2377
|
+
const w = R(() => u.value);
|
|
2378
|
+
return (v, h) => {
|
|
2379
|
+
const b = mt("AForm", !0);
|
|
2380
|
+
return P(), j("form", Lo, [
|
|
2381
|
+
(P(!0), j(ue, null, ye(n.schema, (m, k) => (P(), j(ue, { key: k }, [
|
|
2382
|
+
"schema" in m && Array.isArray(m.schema) && m.schema.length > 0 ? (P(), j("div", Bo, [
|
|
2383
|
+
m.label ? (P(), j("h4", Wo, X(m.label), 1)) : ce("", !0),
|
|
2384
|
+
ne(b, {
|
|
2314
2385
|
data: r.value[m.fieldname],
|
|
2315
|
-
mode:
|
|
2386
|
+
mode: d(m),
|
|
2316
2387
|
schema: m.schema,
|
|
2317
|
-
"onUpdate:data": (
|
|
2388
|
+
"onUpdate:data": (I) => a(m.fieldname, I)
|
|
2318
2389
|
}, null, 8, ["data", "mode", "schema", "onUpdate:data"])
|
|
2319
|
-
])) : (P(),
|
|
2390
|
+
])) : (P(), Qe(xt(m.component), Tt({
|
|
2320
2391
|
key: 1,
|
|
2321
|
-
modelValue:
|
|
2322
|
-
"onUpdate:modelValue": (
|
|
2392
|
+
modelValue: w.value[k].value,
|
|
2393
|
+
"onUpdate:modelValue": (I) => w.value[k].value = I,
|
|
2323
2394
|
schema: m,
|
|
2324
|
-
data:
|
|
2325
|
-
mode:
|
|
2326
|
-
}, { ref_for: !0 },
|
|
2395
|
+
data: o.value[m.fieldname],
|
|
2396
|
+
mode: d(m)
|
|
2397
|
+
}, { ref_for: !0 }, s(m)), null, 16, ["modelValue", "onUpdate:modelValue", "schema", "data", "mode"]))
|
|
2327
2398
|
], 64))), 128))
|
|
2328
2399
|
]);
|
|
2329
2400
|
};
|
|
2330
2401
|
}
|
|
2331
|
-
}),
|
|
2402
|
+
}), Uo = /* @__PURE__ */ To(Ho, [["__scopeId", "data-v-5c01cea5"]]), Jo = { class: "tabs" }, zo = { tabindex: "0" }, Go = { tabindex: "0" }, qo = /* @__PURE__ */ be({
|
|
2332
2403
|
__name: "SheetNav",
|
|
2333
2404
|
props: {
|
|
2334
2405
|
breadcrumbs: { default: () => [] }
|
|
2335
2406
|
},
|
|
2336
|
-
setup(
|
|
2337
|
-
const e =
|
|
2407
|
+
setup(n) {
|
|
2408
|
+
const e = $(!0), t = $(!1), o = $(""), r = pt("searchinput"), a = R(() => e.value ? "unrotated" : "rotated"), s = () => {
|
|
2338
2409
|
e.value = !e.value;
|
|
2339
|
-
},
|
|
2340
|
-
|
|
2410
|
+
}, c = async () => {
|
|
2411
|
+
t.value = !t.value, await de(() => {
|
|
2341
2412
|
r.value?.focus();
|
|
2342
2413
|
});
|
|
2343
|
-
},
|
|
2344
|
-
|
|
2345
|
-
},
|
|
2346
|
-
|
|
2347
|
-
},
|
|
2414
|
+
}, d = (v) => {
|
|
2415
|
+
v.preventDefault(), v.stopPropagation();
|
|
2416
|
+
}, u = async (v) => {
|
|
2417
|
+
v.preventDefault(), v.stopPropagation(), await c();
|
|
2418
|
+
}, w = () => {
|
|
2348
2419
|
};
|
|
2349
|
-
return (
|
|
2350
|
-
const
|
|
2351
|
-
return P(),
|
|
2352
|
-
|
|
2353
|
-
|
|
2420
|
+
return (v, h) => {
|
|
2421
|
+
const b = mt("router-link");
|
|
2422
|
+
return P(), j("footer", null, [
|
|
2423
|
+
x("ul", Jo, [
|
|
2424
|
+
x("li", {
|
|
2354
2425
|
class: "hidebreadcrumbs",
|
|
2355
|
-
onClick:
|
|
2356
|
-
onKeydown:
|
|
2426
|
+
onClick: s,
|
|
2427
|
+
onKeydown: fe(s, ["enter"])
|
|
2357
2428
|
}, [
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
class:
|
|
2429
|
+
x("a", zo, [
|
|
2430
|
+
x("div", {
|
|
2431
|
+
class: De(a.value)
|
|
2361
2432
|
}, "×", 2)
|
|
2362
2433
|
])
|
|
2363
2434
|
], 32),
|
|
2364
|
-
|
|
2435
|
+
x("li", {
|
|
2365
2436
|
class: "hometab",
|
|
2366
|
-
style:
|
|
2367
|
-
onClick:
|
|
2368
|
-
onKeydown:
|
|
2437
|
+
style: je({ display: e.value ? "block" : "none" }),
|
|
2438
|
+
onClick: w,
|
|
2439
|
+
onKeydown: fe(w, ["enter"])
|
|
2369
2440
|
}, [
|
|
2370
|
-
ne(
|
|
2441
|
+
ne(b, {
|
|
2371
2442
|
to: "/",
|
|
2372
2443
|
tabindex: "0"
|
|
2373
2444
|
}, {
|
|
2374
|
-
default:
|
|
2375
|
-
|
|
2445
|
+
default: me(() => [...h[5] || (h[5] = [
|
|
2446
|
+
x("svg", {
|
|
2376
2447
|
class: "icon",
|
|
2377
2448
|
"aria-label": "Home",
|
|
2378
2449
|
viewBox: "0 0 24 24",
|
|
@@ -2380,19 +2451,19 @@ const Wo = { class: "aform" }, Ho = {
|
|
|
2380
2451
|
stroke: "currentColor",
|
|
2381
2452
|
"stroke-width": "2"
|
|
2382
2453
|
}, [
|
|
2383
|
-
|
|
2384
|
-
|
|
2454
|
+
x("path", { d: "M3 12l9-9 9 9" }),
|
|
2455
|
+
x("path", { d: "M9 21V12h6v9" })
|
|
2385
2456
|
], -1)
|
|
2386
2457
|
])]),
|
|
2387
2458
|
_: 1
|
|
2388
2459
|
})
|
|
2389
2460
|
], 36),
|
|
2390
|
-
|
|
2391
|
-
class:
|
|
2392
|
-
style:
|
|
2461
|
+
x("li", {
|
|
2462
|
+
class: De(["searchtab", { "search-active": t.value }]),
|
|
2463
|
+
style: je({ display: e.value ? "block" : "none" })
|
|
2393
2464
|
}, [
|
|
2394
|
-
|
|
2395
|
-
|
|
2465
|
+
x("a", Go, [
|
|
2466
|
+
Oe((P(), j("svg", {
|
|
2396
2467
|
class: "icon search-icon",
|
|
2397
2468
|
role: "button",
|
|
2398
2469
|
"aria-label": "Search",
|
|
@@ -2400,47 +2471,47 @@ const Wo = { class: "aform" }, Ho = {
|
|
|
2400
2471
|
fill: "none",
|
|
2401
2472
|
stroke: "currentColor",
|
|
2402
2473
|
"stroke-width": "2",
|
|
2403
|
-
onClick:
|
|
2404
|
-
onKeydown:
|
|
2474
|
+
onClick: c,
|
|
2475
|
+
onKeydown: fe(c, ["enter"])
|
|
2405
2476
|
}, [...h[6] || (h[6] = [
|
|
2406
|
-
|
|
2477
|
+
x("circle", {
|
|
2407
2478
|
cx: "11",
|
|
2408
2479
|
cy: "11",
|
|
2409
2480
|
r: "7"
|
|
2410
2481
|
}, null, -1),
|
|
2411
|
-
|
|
2482
|
+
x("path", { d: "M21 21l-4.35-4.35" }, null, -1)
|
|
2412
2483
|
])], 544)), [
|
|
2413
|
-
[
|
|
2484
|
+
[Je, !t.value]
|
|
2414
2485
|
]),
|
|
2415
|
-
|
|
2486
|
+
Oe(x("input", {
|
|
2416
2487
|
ref: "searchinput",
|
|
2417
|
-
"onUpdate:modelValue": h[0] || (h[0] = (m) =>
|
|
2488
|
+
"onUpdate:modelValue": h[0] || (h[0] = (m) => o.value = m),
|
|
2418
2489
|
type: "text",
|
|
2419
2490
|
placeholder: "Search...",
|
|
2420
|
-
onClick: h[1] || (h[1] =
|
|
2491
|
+
onClick: h[1] || (h[1] = ft(() => {
|
|
2421
2492
|
}, ["stop"])),
|
|
2422
|
-
onInput: h[2] || (h[2] = (m) =>
|
|
2423
|
-
onBlur: h[3] || (h[3] = (m) =>
|
|
2493
|
+
onInput: h[2] || (h[2] = (m) => d(m)),
|
|
2494
|
+
onBlur: h[3] || (h[3] = (m) => u(m)),
|
|
2424
2495
|
onKeydown: [
|
|
2425
|
-
h[4] || (h[4] =
|
|
2426
|
-
|
|
2496
|
+
h[4] || (h[4] = fe((m) => u(m), ["enter"])),
|
|
2497
|
+
fe(c, ["escape"])
|
|
2427
2498
|
]
|
|
2428
2499
|
}, null, 544), [
|
|
2429
|
-
[
|
|
2430
|
-
[ht,
|
|
2500
|
+
[Je, t.value],
|
|
2501
|
+
[ht, o.value]
|
|
2431
2502
|
])
|
|
2432
2503
|
])
|
|
2433
2504
|
], 6),
|
|
2434
|
-
(P(!0),
|
|
2505
|
+
(P(!0), j(ue, null, ye(n.breadcrumbs, (m) => (P(), j("li", {
|
|
2435
2506
|
key: m.title,
|
|
2436
|
-
style:
|
|
2507
|
+
style: je({ display: e.value ? "block" : "none" })
|
|
2437
2508
|
}, [
|
|
2438
|
-
ne(
|
|
2509
|
+
ne(b, {
|
|
2439
2510
|
tabindex: "0",
|
|
2440
2511
|
to: m.to
|
|
2441
2512
|
}, {
|
|
2442
|
-
default:
|
|
2443
|
-
|
|
2513
|
+
default: me(() => [
|
|
2514
|
+
Ae(X(m.title), 1)
|
|
2444
2515
|
]),
|
|
2445
2516
|
_: 2
|
|
2446
2517
|
}, 1032, ["to"])
|
|
@@ -2449,135 +2520,117 @@ const Wo = { class: "aform" }, Ho = {
|
|
|
2449
2520
|
]);
|
|
2450
2521
|
};
|
|
2451
2522
|
}
|
|
2452
|
-
}),
|
|
2523
|
+
}), Dt = /* @__PURE__ */ wt(qo, [["__scopeId", "data-v-eb5bcbb6"]]), Ko = {
|
|
2453
2524
|
key: 1,
|
|
2454
2525
|
class: "loading"
|
|
2455
|
-
},
|
|
2526
|
+
}, Zo = {
|
|
2456
2527
|
key: 2,
|
|
2457
2528
|
class: "loading"
|
|
2458
|
-
},
|
|
2529
|
+
}, Qo = /* @__PURE__ */ be({
|
|
2459
2530
|
__name: "Desktop",
|
|
2460
2531
|
props: {
|
|
2461
|
-
availableDoctypes: {
|
|
2532
|
+
availableDoctypes: {},
|
|
2533
|
+
routeAdapter: {},
|
|
2534
|
+
confirmFn: { type: Function }
|
|
2462
2535
|
},
|
|
2463
|
-
|
|
2464
|
-
|
|
2536
|
+
emits: ["action", "navigate", "record:open"],
|
|
2537
|
+
setup(n, { emit: e }) {
|
|
2538
|
+
const t = n, o = e, { availableDoctypes: r = [] } = t, { stonecrop: a } = Do(), s = $(!1), c = $(!1), d = R({
|
|
2465
2539
|
get() {
|
|
2466
|
-
if (!
|
|
2540
|
+
if (!a.value || !v.value || !b.value)
|
|
2467
2541
|
return {};
|
|
2468
2542
|
try {
|
|
2469
|
-
return { ...
|
|
2543
|
+
return { ...a.value.getRecordById(v.value, b.value)?.get("") || {} };
|
|
2470
2544
|
} catch {
|
|
2471
2545
|
return {};
|
|
2472
2546
|
}
|
|
2473
2547
|
},
|
|
2474
|
-
set(
|
|
2475
|
-
if (!(!
|
|
2548
|
+
set(i) {
|
|
2549
|
+
if (!(!a.value || !v.value || !b.value))
|
|
2476
2550
|
try {
|
|
2477
|
-
const l =
|
|
2478
|
-
for (const [
|
|
2479
|
-
const
|
|
2480
|
-
(l.has(
|
|
2551
|
+
const l = a.value.getStore();
|
|
2552
|
+
for (const [A, O] of Object.entries(i)) {
|
|
2553
|
+
const W = `${v.value}.${b.value}.${A}`;
|
|
2554
|
+
(l.has(W) ? l.get(W) : void 0) !== O && l.set(W, O);
|
|
2481
2555
|
}
|
|
2482
2556
|
} catch (l) {
|
|
2483
2557
|
console.warn("HST update failed:", l);
|
|
2484
2558
|
}
|
|
2485
2559
|
}
|
|
2486
|
-
}),
|
|
2487
|
-
if (
|
|
2488
|
-
if (
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
if (
|
|
2497
|
-
|
|
2498
|
-
if (
|
|
2499
|
-
return
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2560
|
+
}), u = R(() => t.routeAdapter ? null : Ne(a.value?.registry.router?.currentRoute)), w = R(() => t.routeAdapter ? null : a.value?.registry.router), v = R(() => {
|
|
2561
|
+
if (t.routeAdapter) return t.routeAdapter.getCurrentDoctype();
|
|
2562
|
+
if (!u.value) return "";
|
|
2563
|
+
if (u.value.meta?.actualDoctype)
|
|
2564
|
+
return u.value.meta.actualDoctype;
|
|
2565
|
+
if (u.value.params.doctype)
|
|
2566
|
+
return u.value.params.doctype;
|
|
2567
|
+
const i = u.value.params.pathMatch;
|
|
2568
|
+
return i && i.length > 0 ? i[0] : "";
|
|
2569
|
+
}), h = R(() => {
|
|
2570
|
+
if (t.routeAdapter) return t.routeAdapter.getCurrentDoctype();
|
|
2571
|
+
if (!u.value) return "";
|
|
2572
|
+
if (u.value.meta?.doctype)
|
|
2573
|
+
return u.value.meta.doctype;
|
|
2574
|
+
if (u.value.params.doctype)
|
|
2575
|
+
return u.value.params.doctype;
|
|
2576
|
+
const i = u.value.params.pathMatch;
|
|
2577
|
+
return i && i.length > 0 ? i[0] : "";
|
|
2578
|
+
}), b = R(() => {
|
|
2579
|
+
if (t.routeAdapter) return t.routeAdapter.getCurrentRecordId();
|
|
2580
|
+
if (!u.value) return "";
|
|
2581
|
+
if (u.value.params.recordId)
|
|
2582
|
+
return u.value.params.recordId;
|
|
2583
|
+
const i = u.value.params.pathMatch;
|
|
2584
|
+
return i && i.length > 1 ? i[1] : "";
|
|
2585
|
+
}), m = R(() => b.value?.startsWith("new-")), k = R(() => {
|
|
2586
|
+
if (t.routeAdapter) return t.routeAdapter.getCurrentView();
|
|
2587
|
+
if (!u.value || u.value.name === "home" || u.value.path === "/")
|
|
2510
2588
|
return "doctypes";
|
|
2511
|
-
if (
|
|
2512
|
-
const l =
|
|
2513
|
-
if (l.includes("form") ||
|
|
2589
|
+
if (u.value.name && u.value.name !== "catch-all") {
|
|
2590
|
+
const l = u.value.name;
|
|
2591
|
+
if (l.includes("form") || u.value.params.recordId)
|
|
2514
2592
|
return "record";
|
|
2515
|
-
if (l.includes("list") ||
|
|
2593
|
+
if (l.includes("list") || u.value.params.doctype)
|
|
2516
2594
|
return "records";
|
|
2517
2595
|
}
|
|
2518
|
-
const
|
|
2519
|
-
return
|
|
2520
|
-
}),
|
|
2521
|
-
if (!
|
|
2596
|
+
const i = u.value.params.pathMatch;
|
|
2597
|
+
return i && i.length > 0 ? i.length === 1 ? "records" : "record" : "doctypes";
|
|
2598
|
+
}), I = () => {
|
|
2599
|
+
if (!a.value || !v.value || !b.value)
|
|
2522
2600
|
return [];
|
|
2523
2601
|
try {
|
|
2524
|
-
const
|
|
2525
|
-
if (!
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
return {
|
|
2541
|
-
label: `${W} (→ ${q})`,
|
|
2542
|
-
action: $t
|
|
2543
|
-
};
|
|
2544
|
-
}) : [];
|
|
2545
|
-
} catch (s) {
|
|
2546
|
-
return console.warn("Error getting available transitions:", s), [];
|
|
2602
|
+
const i = a.value.registry.getDoctype(v.value);
|
|
2603
|
+
if (!i?.workflow) return [];
|
|
2604
|
+
const l = a.value.getRecordState(v.value, b.value), A = i.getAvailableTransitions(l), O = d.value || {};
|
|
2605
|
+
return A.map(({ name: W, targetState: J }) => ({
|
|
2606
|
+
label: `${W} (→ ${J})`,
|
|
2607
|
+
action: () => {
|
|
2608
|
+
o("action", {
|
|
2609
|
+
name: W,
|
|
2610
|
+
doctype: v.value,
|
|
2611
|
+
recordId: b.value,
|
|
2612
|
+
data: O
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
}));
|
|
2616
|
+
} catch (i) {
|
|
2617
|
+
return console.warn("Error getting available transitions:", i), [];
|
|
2547
2618
|
}
|
|
2548
|
-
},
|
|
2549
|
-
const
|
|
2550
|
-
switch (
|
|
2551
|
-
case "
|
|
2552
|
-
|
|
2619
|
+
}, T = R(() => {
|
|
2620
|
+
const i = [];
|
|
2621
|
+
switch (k.value) {
|
|
2622
|
+
case "records":
|
|
2623
|
+
i.push({
|
|
2553
2624
|
type: "button",
|
|
2554
|
-
label: "
|
|
2625
|
+
label: "New Record",
|
|
2555
2626
|
action: () => {
|
|
2556
|
-
|
|
2627
|
+
g();
|
|
2557
2628
|
}
|
|
2558
2629
|
});
|
|
2559
2630
|
break;
|
|
2560
|
-
case "records":
|
|
2561
|
-
s.push(
|
|
2562
|
-
{
|
|
2563
|
-
type: "button",
|
|
2564
|
-
label: "New Record",
|
|
2565
|
-
action: () => {
|
|
2566
|
-
z();
|
|
2567
|
-
}
|
|
2568
|
-
},
|
|
2569
|
-
{
|
|
2570
|
-
type: "button",
|
|
2571
|
-
label: "Refresh",
|
|
2572
|
-
action: () => {
|
|
2573
|
-
window.location.reload();
|
|
2574
|
-
}
|
|
2575
|
-
}
|
|
2576
|
-
);
|
|
2577
|
-
break;
|
|
2578
2631
|
case "record": {
|
|
2579
|
-
const l =
|
|
2580
|
-
l.length > 0 &&
|
|
2632
|
+
const l = I();
|
|
2633
|
+
l.length > 0 && i.push({
|
|
2581
2634
|
type: "dropdown",
|
|
2582
2635
|
label: "Actions",
|
|
2583
2636
|
actions: l
|
|
@@ -2585,77 +2638,80 @@ const Wo = { class: "aform" }, Ho = {
|
|
|
2585
2638
|
break;
|
|
2586
2639
|
}
|
|
2587
2640
|
}
|
|
2588
|
-
return
|
|
2589
|
-
}),
|
|
2590
|
-
const
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2641
|
+
return i;
|
|
2642
|
+
}), Z = R(() => {
|
|
2643
|
+
const i = [];
|
|
2644
|
+
if (k.value === "records" && h.value)
|
|
2645
|
+
i.push(
|
|
2646
|
+
{ title: "Home", to: "/" },
|
|
2647
|
+
{ title: L(h.value), to: `/${h.value}` }
|
|
2648
|
+
);
|
|
2649
|
+
else if (k.value === "record" && h.value) {
|
|
2650
|
+
const l = b.value ? `/${h.value}/${b.value}` : u.value?.fullPath ?? "";
|
|
2651
|
+
i.push(
|
|
2652
|
+
{ title: "Home", to: "/" },
|
|
2653
|
+
{ title: L(h.value), to: `/${h.value}` },
|
|
2654
|
+
{ title: m.value ? "New Record" : "Edit Record", to: l }
|
|
2655
|
+
);
|
|
2656
|
+
}
|
|
2657
|
+
return i;
|
|
2658
|
+
}), U = (i) => {
|
|
2600
2659
|
const l = [
|
|
2601
2660
|
{
|
|
2602
2661
|
title: "Go Home",
|
|
2603
2662
|
description: "Navigate to the home page",
|
|
2604
2663
|
action: () => {
|
|
2605
|
-
|
|
2664
|
+
E({ view: "doctypes" });
|
|
2606
2665
|
}
|
|
2607
2666
|
},
|
|
2608
2667
|
{
|
|
2609
2668
|
title: "Toggle Command Palette",
|
|
2610
2669
|
description: "Open/close the command palette",
|
|
2611
|
-
action: () =>
|
|
2670
|
+
action: () => c.value = !c.value
|
|
2612
2671
|
}
|
|
2613
2672
|
];
|
|
2614
|
-
return
|
|
2615
|
-
title: `View ${
|
|
2616
|
-
description: `Navigate to ${
|
|
2673
|
+
return h.value && (l.push({
|
|
2674
|
+
title: `View ${L(h.value)} Records`,
|
|
2675
|
+
description: `Navigate to ${h.value} list`,
|
|
2617
2676
|
action: () => {
|
|
2618
|
-
|
|
2677
|
+
E({ view: "records", doctype: h.value });
|
|
2619
2678
|
}
|
|
2620
2679
|
}), l.push({
|
|
2621
|
-
title: `Create New ${
|
|
2622
|
-
description: `Create a new ${
|
|
2680
|
+
title: `Create New ${L(h.value)}`,
|
|
2681
|
+
description: `Create a new ${h.value} record`,
|
|
2623
2682
|
action: () => {
|
|
2624
|
-
|
|
2683
|
+
g();
|
|
2625
2684
|
}
|
|
2626
|
-
})),
|
|
2685
|
+
})), r.forEach((A) => {
|
|
2627
2686
|
l.push({
|
|
2628
|
-
title: `View ${
|
|
2629
|
-
description: `Navigate to ${
|
|
2687
|
+
title: `View ${L(A)}`,
|
|
2688
|
+
description: `Navigate to ${A} list`,
|
|
2630
2689
|
action: () => {
|
|
2631
|
-
|
|
2690
|
+
E({ view: "records", doctype: A });
|
|
2632
2691
|
}
|
|
2633
2692
|
});
|
|
2634
|
-
}),
|
|
2635
|
-
(
|
|
2693
|
+
}), i ? l.filter(
|
|
2694
|
+
(A) => A.title.toLowerCase().includes(i.toLowerCase()) || A.description.toLowerCase().includes(i.toLowerCase())
|
|
2636
2695
|
) : l;
|
|
2637
|
-
},
|
|
2638
|
-
|
|
2639
|
-
},
|
|
2640
|
-
await
|
|
2641
|
-
},
|
|
2642
|
-
await
|
|
2643
|
-
},
|
|
2644
|
-
const
|
|
2645
|
-
await
|
|
2646
|
-
},
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
}, Y = () => {
|
|
2653
|
-
if (!t.availableDoctypes.length) return [];
|
|
2654
|
-
const s = t.availableDoctypes.map((l) => ({
|
|
2696
|
+
}, z = (i) => {
|
|
2697
|
+
i.action(), c.value = !1;
|
|
2698
|
+
}, L = (i) => i.split("-").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join(" "), G = (i) => a.value ? a.value.getRecordIds(i).length : 0, E = async (i) => {
|
|
2699
|
+
o("navigate", i), t.routeAdapter ? await t.routeAdapter.navigate(i) : i.view === "doctypes" ? await w.value?.push("/") : i.view === "records" && i.doctype ? await w.value?.push(`/${i.doctype}`) : i.view === "record" && i.doctype && i.recordId && await w.value?.push(`/${i.doctype}/${i.recordId}`);
|
|
2700
|
+
}, Y = async (i) => {
|
|
2701
|
+
await E({ view: "records", doctype: i });
|
|
2702
|
+
}, B = async (i) => {
|
|
2703
|
+
const l = h.value;
|
|
2704
|
+
o("record:open", { doctype: l, recordId: i }), await E({ view: "record", doctype: l, recordId: i });
|
|
2705
|
+
}, g = async () => {
|
|
2706
|
+
const i = `new-${Date.now()}`;
|
|
2707
|
+
await E({ view: "record", doctype: h.value, recordId: i });
|
|
2708
|
+
}, y = () => {
|
|
2709
|
+
if (!r.length) return [];
|
|
2710
|
+
const i = r.map((l) => ({
|
|
2655
2711
|
id: l,
|
|
2656
2712
|
doctype: l,
|
|
2657
|
-
display_name:
|
|
2658
|
-
record_count:
|
|
2713
|
+
display_name: L(l),
|
|
2714
|
+
record_count: G(l),
|
|
2659
2715
|
actions: "View Records"
|
|
2660
2716
|
}));
|
|
2661
2717
|
return [
|
|
@@ -2700,19 +2756,19 @@ const Wo = { class: "aform" }, Ho = {
|
|
|
2700
2756
|
view: "list",
|
|
2701
2757
|
fullWidth: !0
|
|
2702
2758
|
},
|
|
2703
|
-
rows:
|
|
2759
|
+
rows: i
|
|
2704
2760
|
}
|
|
2705
2761
|
];
|
|
2706
|
-
},
|
|
2707
|
-
if (!
|
|
2708
|
-
if (!
|
|
2709
|
-
const
|
|
2762
|
+
}, D = () => {
|
|
2763
|
+
if (!v.value) return [];
|
|
2764
|
+
if (!a.value) return [];
|
|
2765
|
+
const i = N(), l = V();
|
|
2710
2766
|
if (l.length === 0)
|
|
2711
2767
|
return [];
|
|
2712
|
-
const
|
|
2713
|
-
...
|
|
2768
|
+
const A = i.map((O) => ({
|
|
2769
|
+
...O,
|
|
2714
2770
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2715
|
-
id:
|
|
2771
|
+
id: O.id || "",
|
|
2716
2772
|
actions: "Edit | Delete"
|
|
2717
2773
|
}));
|
|
2718
2774
|
return [
|
|
@@ -2720,10 +2776,10 @@ const Wo = { class: "aform" }, Ho = {
|
|
|
2720
2776
|
fieldname: "records_table",
|
|
2721
2777
|
component: "ATable",
|
|
2722
2778
|
columns: [
|
|
2723
|
-
...l.map((
|
|
2724
|
-
label:
|
|
2725
|
-
name:
|
|
2726
|
-
fieldtype:
|
|
2779
|
+
...l.map((O) => ({
|
|
2780
|
+
label: O.label,
|
|
2781
|
+
name: O.fieldname,
|
|
2782
|
+
fieldtype: O.fieldtype,
|
|
2727
2783
|
align: "left",
|
|
2728
2784
|
edit: !1,
|
|
2729
2785
|
width: "20ch"
|
|
@@ -2741,235 +2797,172 @@ const Wo = { class: "aform" }, Ho = {
|
|
|
2741
2797
|
view: "list",
|
|
2742
2798
|
fullWidth: !0
|
|
2743
2799
|
},
|
|
2744
|
-
rows:
|
|
2800
|
+
rows: A
|
|
2745
2801
|
}
|
|
2746
2802
|
];
|
|
2747
|
-
},
|
|
2748
|
-
if (!
|
|
2749
|
-
if (!
|
|
2803
|
+
}, F = () => {
|
|
2804
|
+
if (!v.value) return [];
|
|
2805
|
+
if (!a.value) return [];
|
|
2750
2806
|
try {
|
|
2751
|
-
const l =
|
|
2807
|
+
const l = a.value?.registry?.registry[v.value];
|
|
2752
2808
|
return l?.schema ? "toArray" in l.schema ? l.schema.toArray() : l.schema : [];
|
|
2753
2809
|
} catch {
|
|
2754
2810
|
return [];
|
|
2755
2811
|
}
|
|
2756
|
-
},
|
|
2757
|
-
if (!
|
|
2812
|
+
}, N = () => {
|
|
2813
|
+
if (!a.value || !v.value)
|
|
2758
2814
|
return [];
|
|
2759
|
-
const l =
|
|
2815
|
+
const l = a.value.records(v.value)?.get("");
|
|
2760
2816
|
return l && typeof l == "object" && !Array.isArray(l) ? Object.values(l) : [];
|
|
2761
|
-
},
|
|
2762
|
-
if (!
|
|
2817
|
+
}, V = () => {
|
|
2818
|
+
if (!a.value || !v.value) return [];
|
|
2763
2819
|
try {
|
|
2764
|
-
const l =
|
|
2820
|
+
const l = a.value.registry.registry[v.value];
|
|
2765
2821
|
if (l?.schema)
|
|
2766
|
-
return ("toArray" in l.schema ? l.schema.toArray() : l.schema).map((
|
|
2767
|
-
fieldname:
|
|
2768
|
-
label: "label" in
|
|
2769
|
-
fieldtype: "fieldtype" in
|
|
2822
|
+
return ("toArray" in l.schema ? l.schema.toArray() : l.schema).map((O) => ({
|
|
2823
|
+
fieldname: O.fieldname,
|
|
2824
|
+
label: "label" in O && O.label || O.fieldname,
|
|
2825
|
+
fieldtype: "fieldtype" in O && O.fieldtype || "Data"
|
|
2770
2826
|
}));
|
|
2771
2827
|
} catch {
|
|
2772
2828
|
}
|
|
2773
2829
|
return [];
|
|
2774
|
-
}, M =
|
|
2775
|
-
switch (
|
|
2830
|
+
}, M = R(() => {
|
|
2831
|
+
switch (k.value) {
|
|
2776
2832
|
case "doctypes":
|
|
2777
|
-
return
|
|
2833
|
+
return y();
|
|
2778
2834
|
case "records":
|
|
2779
|
-
return
|
|
2835
|
+
return D();
|
|
2780
2836
|
case "record":
|
|
2781
|
-
return
|
|
2837
|
+
return F();
|
|
2782
2838
|
default:
|
|
2783
2839
|
return [];
|
|
2784
2840
|
}
|
|
2785
|
-
}),
|
|
2786
|
-
if (e.value) {
|
|
2787
|
-
n.value = !0;
|
|
2788
|
-
try {
|
|
2789
|
-
const s = i.value || {};
|
|
2790
|
-
if (b.value) {
|
|
2791
|
-
const l = `record-${Date.now()}`, y = { id: l, ...s };
|
|
2792
|
-
e.value.addRecord(c.value, l, y);
|
|
2793
|
-
const N = e.value.getRecordById(c.value, l);
|
|
2794
|
-
N && await N.triggerTransition("SAVE", {
|
|
2795
|
-
currentState: "creating",
|
|
2796
|
-
targetState: "saved",
|
|
2797
|
-
fsmContext: y
|
|
2798
|
-
}), await u.value?.replace(`/${f.value}/${l}`);
|
|
2799
|
-
} else {
|
|
2800
|
-
const l = { id: p.value, ...s };
|
|
2801
|
-
e.value.addRecord(c.value, p.value, l);
|
|
2802
|
-
const y = e.value.getRecordById(c.value, p.value);
|
|
2803
|
-
y && await y.triggerTransition("SAVE", {
|
|
2804
|
-
currentState: "editing",
|
|
2805
|
-
targetState: "saved",
|
|
2806
|
-
fsmContext: l
|
|
2807
|
-
});
|
|
2808
|
-
}
|
|
2809
|
-
} catch {
|
|
2810
|
-
} finally {
|
|
2811
|
-
n.value = !1;
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
|
-
}, T = async () => {
|
|
2815
|
-
if (b.value)
|
|
2816
|
-
await u.value?.push(`/${f.value}`);
|
|
2817
|
-
else {
|
|
2818
|
-
if (e.value) {
|
|
2819
|
-
const s = e.value.getRecordById(c.value, p.value);
|
|
2820
|
-
s && await s.triggerTransition("CANCEL", {
|
|
2821
|
-
currentState: "editing",
|
|
2822
|
-
targetState: "cancelled"
|
|
2823
|
-
});
|
|
2824
|
-
}
|
|
2825
|
-
S();
|
|
2826
|
-
}
|
|
2827
|
-
}, F = (s, l) => {
|
|
2841
|
+
}), _ = (i, l) => {
|
|
2828
2842
|
l && l();
|
|
2829
|
-
},
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
case "cancel":
|
|
2850
|
-
await T();
|
|
2851
|
-
break;
|
|
2852
|
-
case "delete":
|
|
2853
|
-
await w();
|
|
2854
|
-
break;
|
|
2855
|
-
}
|
|
2856
|
-
const N = l.closest("td, th");
|
|
2857
|
-
if (N) {
|
|
2858
|
-
const j = N.textContent?.trim(), J = N.closest("tr");
|
|
2859
|
-
if (j === "View Records" && J) {
|
|
2860
|
-
const W = J.querySelectorAll("td");
|
|
2861
|
-
if (W.length > 0) {
|
|
2862
|
-
const q = W[1].textContent?.trim();
|
|
2863
|
-
q && await K(q);
|
|
2843
|
+
}, C = async (i) => {
|
|
2844
|
+
const l = i || b.value;
|
|
2845
|
+
if (!l) return;
|
|
2846
|
+
(t.confirmFn ? await t.confirmFn("Are you sure you want to delete this record?") : confirm("Are you sure you want to delete this record?")) && o("action", {
|
|
2847
|
+
name: "DELETE",
|
|
2848
|
+
doctype: v.value,
|
|
2849
|
+
recordId: l,
|
|
2850
|
+
data: d.value || {}
|
|
2851
|
+
});
|
|
2852
|
+
}, S = async (i) => {
|
|
2853
|
+
const l = i.target;
|
|
2854
|
+
l.getAttribute("data-action") === "create" && await g();
|
|
2855
|
+
const O = l.closest("td, th");
|
|
2856
|
+
if (O) {
|
|
2857
|
+
const W = O.textContent?.trim(), J = O.closest("tr");
|
|
2858
|
+
if (W === "View Records" && J) {
|
|
2859
|
+
const Q = J.querySelectorAll("td");
|
|
2860
|
+
if (Q.length > 0) {
|
|
2861
|
+
const ee = Q[1].textContent?.trim();
|
|
2862
|
+
ee && await Y(ee);
|
|
2864
2863
|
}
|
|
2865
|
-
} else if (
|
|
2866
|
-
const
|
|
2867
|
-
if (
|
|
2868
|
-
const
|
|
2869
|
-
|
|
2864
|
+
} else if (W?.includes("Edit") && J) {
|
|
2865
|
+
const Q = J.querySelectorAll("td");
|
|
2866
|
+
if (Q.length > 0) {
|
|
2867
|
+
const ee = Q[0].textContent?.trim();
|
|
2868
|
+
ee && await B(ee);
|
|
2870
2869
|
}
|
|
2871
|
-
} else if (
|
|
2872
|
-
const
|
|
2873
|
-
if (
|
|
2874
|
-
const
|
|
2875
|
-
|
|
2870
|
+
} else if (W?.includes("Delete") && J) {
|
|
2871
|
+
const Q = J.querySelectorAll("td");
|
|
2872
|
+
if (Q.length > 0) {
|
|
2873
|
+
const ee = Q[0].textContent?.trim();
|
|
2874
|
+
ee && await C(ee);
|
|
2876
2875
|
}
|
|
2877
2876
|
}
|
|
2878
2877
|
}
|
|
2879
|
-
}
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
() => {
|
|
2883
|
-
h.value === "record" && S();
|
|
2884
|
-
},
|
|
2885
|
-
{ immediate: !0 }
|
|
2886
|
-
), L(
|
|
2887
|
-
e,
|
|
2888
|
-
(s) => {
|
|
2889
|
-
},
|
|
2890
|
-
{ immediate: !0 }
|
|
2891
|
-
), L(
|
|
2892
|
-
[h, c, e],
|
|
2893
|
-
([s, l, y]) => {
|
|
2894
|
-
s === "records" && l && y && E(l);
|
|
2895
|
-
},
|
|
2896
|
-
{ immediate: !0 }
|
|
2897
|
-
);
|
|
2898
|
-
const S = () => {
|
|
2899
|
-
if (!(!e.value || !c.value)) {
|
|
2900
|
-
o.value = !0;
|
|
2878
|
+
}, p = () => {
|
|
2879
|
+
if (!(!a.value || !v.value)) {
|
|
2880
|
+
s.value = !0;
|
|
2901
2881
|
try {
|
|
2902
|
-
|
|
2903
|
-
} catch (
|
|
2904
|
-
console.warn("Error loading record data:",
|
|
2882
|
+
m.value || a.value.getRecordById(v.value, b.value);
|
|
2883
|
+
} catch (i) {
|
|
2884
|
+
console.warn("Error loading record data:", i);
|
|
2905
2885
|
} finally {
|
|
2906
|
-
|
|
2886
|
+
s.value = !1;
|
|
2907
2887
|
}
|
|
2908
2888
|
}
|
|
2909
2889
|
};
|
|
2910
|
-
return
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2890
|
+
return H(
|
|
2891
|
+
[k, v, b],
|
|
2892
|
+
() => {
|
|
2893
|
+
k.value === "record" && p();
|
|
2894
|
+
},
|
|
2895
|
+
{ immediate: !0 }
|
|
2896
|
+
), Ge("desktopMethods", {
|
|
2897
|
+
navigateToDoctype: Y,
|
|
2898
|
+
openRecord: B,
|
|
2899
|
+
createNewRecord: g,
|
|
2900
|
+
handleDelete: C,
|
|
2901
|
+
/**
|
|
2902
|
+
* Convenience wrapper so child components (e.g. slot content) can emit
|
|
2903
|
+
* an action event without needing a direct reference to the emit function.
|
|
2904
|
+
*/
|
|
2905
|
+
emitAction: (i, l) => {
|
|
2906
|
+
o("action", {
|
|
2907
|
+
name: i,
|
|
2908
|
+
doctype: v.value,
|
|
2909
|
+
recordId: b.value,
|
|
2910
|
+
data: l ?? d.value ?? {}
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2913
|
+
}), xe(() => {
|
|
2914
|
+
const i = (l) => {
|
|
2915
|
+
(l.ctrlKey || l.metaKey) && l.key === "k" && (l.preventDefault(), c.value = !0), l.key === "Escape" && c.value && (c.value = !1);
|
|
2923
2916
|
};
|
|
2924
|
-
return document.addEventListener("keydown",
|
|
2925
|
-
document.removeEventListener("keydown",
|
|
2917
|
+
return document.addEventListener("keydown", i), () => {
|
|
2918
|
+
document.removeEventListener("keydown", i);
|
|
2926
2919
|
};
|
|
2927
|
-
}), (
|
|
2920
|
+
}), (i, l) => (P(), j("div", {
|
|
2928
2921
|
class: "desktop",
|
|
2929
|
-
onClick:
|
|
2922
|
+
onClick: S
|
|
2930
2923
|
}, [
|
|
2931
|
-
ne(
|
|
2932
|
-
elements:
|
|
2933
|
-
onActionClick:
|
|
2924
|
+
ne(bt, {
|
|
2925
|
+
elements: T.value,
|
|
2926
|
+
onActionClick: _
|
|
2934
2927
|
}, null, 8, ["elements"]),
|
|
2935
|
-
M.value.length > 0 ? (P(),
|
|
2928
|
+
M.value.length > 0 ? (P(), Qe(Ne(Uo), {
|
|
2936
2929
|
key: 0,
|
|
2937
|
-
data:
|
|
2938
|
-
"onUpdate:data": l[0] || (l[0] = (
|
|
2930
|
+
data: d.value,
|
|
2931
|
+
"onUpdate:data": l[0] || (l[0] = (A) => d.value = A),
|
|
2939
2932
|
schema: M.value
|
|
2940
|
-
}, null, 8, ["data", "schema"])) :
|
|
2941
|
-
|
|
2942
|
-
])) : (P(),
|
|
2943
|
-
|
|
2933
|
+
}, null, 8, ["data", "schema"])) : Ne(a) ? (P(), j("div", Zo, [
|
|
2934
|
+
x("p", null, "Loading " + X(k.value) + " data...", 1)
|
|
2935
|
+
])) : (P(), j("div", Ko, [...l[2] || (l[2] = [
|
|
2936
|
+
x("p", null, "Initializing Stonecrop...", -1)
|
|
2944
2937
|
])])),
|
|
2945
|
-
ne(
|
|
2938
|
+
ne(Dt, { breadcrumbs: Z.value }, null, 8, ["breadcrumbs"]),
|
|
2946
2939
|
ne(St, {
|
|
2947
|
-
"is-open":
|
|
2948
|
-
search:
|
|
2940
|
+
"is-open": c.value,
|
|
2941
|
+
search: U,
|
|
2949
2942
|
placeholder: "Type a command or search...",
|
|
2950
|
-
onSelect:
|
|
2951
|
-
onClose: l[1] || (l[1] = (
|
|
2943
|
+
onSelect: z,
|
|
2944
|
+
onClose: l[1] || (l[1] = (A) => c.value = !1)
|
|
2952
2945
|
}, {
|
|
2953
|
-
title:
|
|
2954
|
-
|
|
2946
|
+
title: me(({ result: A }) => [
|
|
2947
|
+
Ae(X(A.title), 1)
|
|
2955
2948
|
]),
|
|
2956
|
-
content:
|
|
2957
|
-
|
|
2949
|
+
content: me(({ result: A }) => [
|
|
2950
|
+
Ae(X(A.description), 1)
|
|
2958
2951
|
]),
|
|
2959
2952
|
_: 1
|
|
2960
2953
|
}, 8, ["is-open"])
|
|
2961
2954
|
]));
|
|
2962
2955
|
}
|
|
2963
|
-
}),
|
|
2964
|
-
install: (
|
|
2965
|
-
|
|
2956
|
+
}), Yo = {
|
|
2957
|
+
install: (n) => {
|
|
2958
|
+
n.component("ActionSet", bt), n.component("CommandPalette", St), n.component("Desktop", Qo), n.component("SheetNav", Dt);
|
|
2966
2959
|
}
|
|
2967
2960
|
};
|
|
2968
2961
|
export {
|
|
2969
|
-
|
|
2962
|
+
bt as ActionSet,
|
|
2970
2963
|
St as CommandPalette,
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2964
|
+
Qo as Desktop,
|
|
2965
|
+
Dt as SheetNav,
|
|
2966
|
+
Yo as StonecropDesktop
|
|
2974
2967
|
};
|
|
2975
2968
|
//# sourceMappingURL=desktop.js.map
|