@stonecrop/desktop 0.6.2 → 0.6.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/dist/actions-Bg0Mh5s7.js +137 -0
- package/dist/actions-Bg0Mh5s7.js.map +1 -0
- package/dist/desktop.css +1 -1
- package/dist/desktop.js +1103 -1104
- package/dist/desktop.js.map +1 -1
- package/dist/desktop.umd.cjs +26 -30
- package/dist/desktop.umd.cjs.map +1 -1
- package/dist/index-C3nXTrEd.js +1895 -0
- package/dist/index-C3nXTrEd.js.map +1 -0
- package/dist/operation-log-DB-dGNT9-C9cIr4-e.js +592 -0
- package/dist/operation-log-DB-dGNT9-C9cIr4-e.js.map +1 -0
- package/dist/src/tsdoc-metadata.json +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,1895 @@
|
|
|
1
|
+
import { defineComponent as W, ref as k, onMounted as te, createElementBlock as b, openBlock as y, normalizeClass as oe, createElementVNode as g, Fragment as L, renderList as B, createCommentVNode as F, toDisplayString as C, withDirectives as ue, vShow as He, useTemplateRef as we, computed as D, watch as x, nextTick as de, createBlock as ae, Teleport as be, createVNode as I, Transition as Oe, withCtx as z, withModifiers as Fe, vModelText as $e, renderSlot as ne, createTextVNode as Z, inject as me, provide as ce, shallowRef as _e, toValue as M, toRef as Le, readonly as Be, customRef as ze, getCurrentScope as We, onScopeDispose as Ke, unref as Q, resolveDynamicComponent as Ue, mergeProps as qe, resolveComponent as Ge, withKeys as J, normalizeStyle as U, withAsyncContext as Ye, onUnmounted as Je, TransitionGroup as Xe } from "vue";
|
|
2
|
+
const Qe = { class: "action-menu-icon" }, Ze = ["onclick"], et = { key: 1 }, tt = ["onClick"], ot = { class: "dropdown-container" }, at = { class: "dropdown" }, nt = ["onclick"], st = ["href"], rt = { class: "dropdown-item" }, lt = /* @__PURE__ */ W({
|
|
3
|
+
__name: "ActionSet",
|
|
4
|
+
props: {
|
|
5
|
+
elements: { default: () => [] }
|
|
6
|
+
},
|
|
7
|
+
setup(s) {
|
|
8
|
+
const e = k(s.elements), t = k(!1), o = k(null), a = k(!1), l = k(!1);
|
|
9
|
+
te(() => {
|
|
10
|
+
r();
|
|
11
|
+
});
|
|
12
|
+
const r = () => {
|
|
13
|
+
for (const i of e.value)
|
|
14
|
+
i.type === "dropdown" && (i.show = !1);
|
|
15
|
+
}, c = () => {
|
|
16
|
+
a.value = !0, o.value = setTimeout(() => {
|
|
17
|
+
a.value && (t.value = !0);
|
|
18
|
+
}, 500);
|
|
19
|
+
}, n = () => {
|
|
20
|
+
a.value = !1, l.value = !1, o.value && clearTimeout(o.value), t.value = !1;
|
|
21
|
+
}, u = (i) => {
|
|
22
|
+
const h = !e.value[i].show;
|
|
23
|
+
r(), e.value[i].show = h;
|
|
24
|
+
};
|
|
25
|
+
return (i, h) => (y(), b("div", {
|
|
26
|
+
class: oe([{ "open-set": t.value, "hovered-and-closed": l.value }, "action-set collapse"]),
|
|
27
|
+
onMouseover: c,
|
|
28
|
+
onMouseleave: n
|
|
29
|
+
}, [
|
|
30
|
+
g("div", Qe, [
|
|
31
|
+
g("div", {
|
|
32
|
+
id: "chevron",
|
|
33
|
+
onClick: h[0] || (h[0] = (p) => l.value = !l.value)
|
|
34
|
+
}, h[1] || (h[1] = [
|
|
35
|
+
g("svg", {
|
|
36
|
+
class: "leftBar",
|
|
37
|
+
version: "1.1",
|
|
38
|
+
id: "Layer_1",
|
|
39
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
40
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
|
41
|
+
x: "0px",
|
|
42
|
+
y: "0px",
|
|
43
|
+
viewBox: "0 0 100 100",
|
|
44
|
+
"xml:space": "preserve",
|
|
45
|
+
width: "50",
|
|
46
|
+
height: "50"
|
|
47
|
+
}, [
|
|
48
|
+
g("polygon", { points: "54.2,33.4 29.2,58.8 25,54.6 50,29.2 " })
|
|
49
|
+
], -1),
|
|
50
|
+
g("svg", {
|
|
51
|
+
class: "rightBar",
|
|
52
|
+
version: "1.1",
|
|
53
|
+
id: "Layer_1",
|
|
54
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
55
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
|
56
|
+
x: "0px",
|
|
57
|
+
y: "0px",
|
|
58
|
+
viewBox: "0 0 100 100",
|
|
59
|
+
"xml:space": "preserve",
|
|
60
|
+
width: "50",
|
|
61
|
+
height: "50"
|
|
62
|
+
}, [
|
|
63
|
+
g("polygon", { points: "70.8,58.8 45.8,33.4 50,29.2 75,54.6 " })
|
|
64
|
+
], -1)
|
|
65
|
+
]))
|
|
66
|
+
]),
|
|
67
|
+
h[2] || (h[2] = g("div", { style: { "margin-right": "30px" } }, null, -1)),
|
|
68
|
+
(y(!0), b(L, null, B(e.value, (p, f) => (y(), b("div", {
|
|
69
|
+
class: "action-element",
|
|
70
|
+
key: p.label
|
|
71
|
+
}, [
|
|
72
|
+
p.type == "button" ? (y(), b("button", {
|
|
73
|
+
key: 0,
|
|
74
|
+
onclick: p.action,
|
|
75
|
+
class: "button-default"
|
|
76
|
+
}, C(p.label), 9, Ze)) : F("", !0),
|
|
77
|
+
p.type == "dropdown" ? (y(), b("div", et, [
|
|
78
|
+
g("button", {
|
|
79
|
+
class: "button-default",
|
|
80
|
+
onClick: (m) => u(f)
|
|
81
|
+
}, C(p.label), 9, tt),
|
|
82
|
+
ue(g("div", ot, [
|
|
83
|
+
g("div", at, [
|
|
84
|
+
(y(!0), b(L, null, B(p.actions, (m) => (y(), b("div", {
|
|
85
|
+
key: m.label
|
|
86
|
+
}, [
|
|
87
|
+
m.action != null ? (y(), b("button", {
|
|
88
|
+
key: 0,
|
|
89
|
+
onclick: m.action,
|
|
90
|
+
class: "dropdown-item"
|
|
91
|
+
}, C(m.label), 9, nt)) : m.link != null ? (y(), b("a", {
|
|
92
|
+
key: 1,
|
|
93
|
+
href: m.link
|
|
94
|
+
}, [
|
|
95
|
+
g("button", rt, C(m.label), 1)
|
|
96
|
+
], 8, st)) : F("", !0)
|
|
97
|
+
]))), 128))
|
|
98
|
+
])
|
|
99
|
+
], 512), [
|
|
100
|
+
[He, p.show]
|
|
101
|
+
])
|
|
102
|
+
])) : F("", !0)
|
|
103
|
+
]))), 128))
|
|
104
|
+
], 34));
|
|
105
|
+
}
|
|
106
|
+
}), ve = (s, e) => {
|
|
107
|
+
const t = s.__vccOpts || s;
|
|
108
|
+
for (const [o, a] of e)
|
|
109
|
+
t[o] = a;
|
|
110
|
+
return t;
|
|
111
|
+
}, ke = /* @__PURE__ */ ve(lt, [["__scopeId", "data-v-fd5c3ea8"]]), it = { class: "command-palette-header" }, ct = ["placeholder"], ut = {
|
|
112
|
+
key: 0,
|
|
113
|
+
class: "command-palette-results"
|
|
114
|
+
}, dt = ["onClick", "onMouseover"], vt = { class: "result-title" }, pt = { class: "result-content" }, ht = {
|
|
115
|
+
key: 1,
|
|
116
|
+
class: "command-palette-no-results"
|
|
117
|
+
}, Se = /* @__PURE__ */ W({
|
|
118
|
+
__name: "CommandPalette",
|
|
119
|
+
props: {
|
|
120
|
+
search: { type: Function },
|
|
121
|
+
isOpen: { type: Boolean, default: !1 },
|
|
122
|
+
placeholder: { default: "Type a command or search..." },
|
|
123
|
+
maxResults: { default: 10 }
|
|
124
|
+
},
|
|
125
|
+
emits: ["select", "close"],
|
|
126
|
+
setup(s, { emit: e }) {
|
|
127
|
+
const t = e, o = k(""), a = k(0), l = we("input"), r = D(() => o.value ? s.search(o.value).slice(0, s.maxResults) : []);
|
|
128
|
+
x(
|
|
129
|
+
() => s.isOpen,
|
|
130
|
+
async (i) => {
|
|
131
|
+
i && (o.value = "", a.value = 0, await de(), l.value?.focus());
|
|
132
|
+
}
|
|
133
|
+
), x(r, () => {
|
|
134
|
+
a.value = 0;
|
|
135
|
+
});
|
|
136
|
+
const c = () => {
|
|
137
|
+
t("close");
|
|
138
|
+
}, n = (i) => {
|
|
139
|
+
switch (i.key) {
|
|
140
|
+
case "Escape":
|
|
141
|
+
c();
|
|
142
|
+
break;
|
|
143
|
+
case "ArrowDown":
|
|
144
|
+
i.preventDefault(), r.value.length && (a.value = (a.value + 1) % r.value.length);
|
|
145
|
+
break;
|
|
146
|
+
case "ArrowUp":
|
|
147
|
+
i.preventDefault(), r.value.length && (a.value = (a.value - 1 + r.value.length) % r.value.length);
|
|
148
|
+
break;
|
|
149
|
+
case "Enter":
|
|
150
|
+
r.value.length && a.value >= 0 && u(r.value[a.value]);
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}, u = (i) => {
|
|
154
|
+
t("select", i), c();
|
|
155
|
+
};
|
|
156
|
+
return (i, h) => (y(), ae(be, { to: "body" }, [
|
|
157
|
+
I(Oe, { name: "fade" }, {
|
|
158
|
+
default: z(() => [
|
|
159
|
+
i.isOpen ? (y(), b("div", {
|
|
160
|
+
key: 0,
|
|
161
|
+
class: "command-palette-overlay",
|
|
162
|
+
onClick: c
|
|
163
|
+
}, [
|
|
164
|
+
g("div", {
|
|
165
|
+
class: "command-palette",
|
|
166
|
+
onClick: h[1] || (h[1] = Fe(() => {
|
|
167
|
+
}, ["stop"]))
|
|
168
|
+
}, [
|
|
169
|
+
g("div", it, [
|
|
170
|
+
ue(g("input", {
|
|
171
|
+
ref: "input",
|
|
172
|
+
"onUpdate:modelValue": h[0] || (h[0] = (p) => o.value = p),
|
|
173
|
+
type: "text",
|
|
174
|
+
class: "command-palette-input",
|
|
175
|
+
placeholder: i.placeholder,
|
|
176
|
+
autofocus: "",
|
|
177
|
+
onKeydown: n
|
|
178
|
+
}, null, 40, ct), [
|
|
179
|
+
[$e, o.value]
|
|
180
|
+
])
|
|
181
|
+
]),
|
|
182
|
+
r.value.length ? (y(), b("div", ut, [
|
|
183
|
+
(y(!0), b(L, null, B(r.value, (p, f) => (y(), b("div", {
|
|
184
|
+
key: f,
|
|
185
|
+
class: oe(["command-palette-result", { selected: f === a.value }]),
|
|
186
|
+
onClick: (m) => u(p),
|
|
187
|
+
onMouseover: (m) => a.value = f
|
|
188
|
+
}, [
|
|
189
|
+
g("div", vt, [
|
|
190
|
+
ne(i.$slots, "title", { result: p })
|
|
191
|
+
]),
|
|
192
|
+
g("div", pt, [
|
|
193
|
+
ne(i.$slots, "content", { result: p })
|
|
194
|
+
])
|
|
195
|
+
], 42, dt))), 128))
|
|
196
|
+
])) : o.value && !r.value.length ? (y(), b("div", ht, [
|
|
197
|
+
ne(i.$slots, "empty", {}, () => [
|
|
198
|
+
Z(' No results found for "' + C(o.value) + '" ', 1)
|
|
199
|
+
])
|
|
200
|
+
])) : F("", !0)
|
|
201
|
+
])
|
|
202
|
+
])) : F("", !0)
|
|
203
|
+
]),
|
|
204
|
+
_: 3
|
|
205
|
+
})
|
|
206
|
+
]));
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
let se;
|
|
210
|
+
function De(s) {
|
|
211
|
+
return se || (se = new ft(s)), se;
|
|
212
|
+
}
|
|
213
|
+
function so(s, e) {
|
|
214
|
+
De().registerAction(s, e);
|
|
215
|
+
}
|
|
216
|
+
class ft {
|
|
217
|
+
options;
|
|
218
|
+
doctypeActions = /* @__PURE__ */ new Map();
|
|
219
|
+
// doctype -> action/field -> functions
|
|
220
|
+
globalActions = /* @__PURE__ */ new Map();
|
|
221
|
+
// action name -> function
|
|
222
|
+
constructor(e = {}) {
|
|
223
|
+
this.options = {
|
|
224
|
+
defaultTimeout: e.defaultTimeout ?? 5e3,
|
|
225
|
+
debug: e.debug ?? !1,
|
|
226
|
+
errorHandler: e.errorHandler
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Register a global action function
|
|
231
|
+
*/
|
|
232
|
+
registerAction(e, t) {
|
|
233
|
+
this.globalActions.set(e, t);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Register actions from a doctype - both regular actions and field triggers
|
|
237
|
+
*/
|
|
238
|
+
registerDoctypeActions(e, t) {
|
|
239
|
+
if (!t) return;
|
|
240
|
+
const o = /* @__PURE__ */ new Map();
|
|
241
|
+
if (typeof t.entrySeq == "function")
|
|
242
|
+
t.entrySeq().forEach(([a, l]) => {
|
|
243
|
+
o.set(a, l);
|
|
244
|
+
});
|
|
245
|
+
else if (t instanceof Map)
|
|
246
|
+
for (const [a, l] of t)
|
|
247
|
+
o.set(a, l);
|
|
248
|
+
else t && typeof t == "object" && Object.entries(t).forEach(([a, l]) => {
|
|
249
|
+
o.set(a, l);
|
|
250
|
+
});
|
|
251
|
+
this.doctypeActions.set(e, o);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Execute field triggers for a changed field
|
|
255
|
+
*/
|
|
256
|
+
async executeFieldTriggers(e, t = {}) {
|
|
257
|
+
const { doctype: o, fieldname: a } = e, l = this.findFieldTriggers(o, a);
|
|
258
|
+
if (l.length === 0)
|
|
259
|
+
return {
|
|
260
|
+
path: e.path,
|
|
261
|
+
actionResults: [],
|
|
262
|
+
totalExecutionTime: 0,
|
|
263
|
+
allSucceeded: !0,
|
|
264
|
+
stoppedOnError: !1
|
|
265
|
+
};
|
|
266
|
+
const r = performance.now(), c = [];
|
|
267
|
+
let n = !1;
|
|
268
|
+
for (const h of l)
|
|
269
|
+
try {
|
|
270
|
+
const p = await this.executeAction(h, e, t.timeout);
|
|
271
|
+
if (c.push(p), !p.success) {
|
|
272
|
+
n = !0;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
} catch (p) {
|
|
276
|
+
const f = {
|
|
277
|
+
success: !1,
|
|
278
|
+
error: p instanceof Error ? p : new Error(String(p)),
|
|
279
|
+
executionTime: 0,
|
|
280
|
+
action: h
|
|
281
|
+
};
|
|
282
|
+
c.push(f), n = !0;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
const u = performance.now() - r, i = c.filter((h) => !h.success);
|
|
286
|
+
if (i.length > 0 && this.options.errorHandler)
|
|
287
|
+
for (const h of i)
|
|
288
|
+
try {
|
|
289
|
+
this.options.errorHandler(h.error, e, h.action);
|
|
290
|
+
} catch (p) {
|
|
291
|
+
console.error("[FieldTriggers] Error in global error handler:", p);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
path: e.path,
|
|
295
|
+
actionResults: c,
|
|
296
|
+
totalExecutionTime: u,
|
|
297
|
+
allSucceeded: c.every((h) => h.success),
|
|
298
|
+
stoppedOnError: n
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Find field triggers for a specific doctype and field
|
|
303
|
+
* Field triggers are identified by keys that look like field paths (contain dots or match field names)
|
|
304
|
+
*/
|
|
305
|
+
findFieldTriggers(e, t) {
|
|
306
|
+
const o = this.doctypeActions.get(e);
|
|
307
|
+
if (!o) return [];
|
|
308
|
+
const a = [];
|
|
309
|
+
for (const [l, r] of o)
|
|
310
|
+
this.isFieldTriggerKey(l, t) && a.push(...r);
|
|
311
|
+
return a;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Determine if an action key represents a field trigger
|
|
315
|
+
* Field triggers can be:
|
|
316
|
+
* - Exact field name match: "emailAddress"
|
|
317
|
+
* - Wildcard patterns: "emailAddress.*", "*.is_primary"
|
|
318
|
+
* - Nested field paths: "address.street", "contact.email"
|
|
319
|
+
*/
|
|
320
|
+
isFieldTriggerKey(e, t) {
|
|
321
|
+
return e === t ? !0 : e.includes(".") ? this.matchFieldPattern(e, t) : e.includes("*") ? this.matchFieldPattern(e, t) : !1;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Match a field pattern against a field name
|
|
325
|
+
* Supports wildcards (*) for dynamic segments
|
|
326
|
+
*/
|
|
327
|
+
matchFieldPattern(e, t) {
|
|
328
|
+
const o = e.split("."), a = t.split(".");
|
|
329
|
+
if (o.length !== a.length)
|
|
330
|
+
return !1;
|
|
331
|
+
for (let l = 0; l < o.length; l++) {
|
|
332
|
+
const r = o[l], c = a[l];
|
|
333
|
+
if (r !== "*" && r !== c)
|
|
334
|
+
return !1;
|
|
335
|
+
}
|
|
336
|
+
return !0;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Execute a single action by name
|
|
340
|
+
*/
|
|
341
|
+
async executeAction(e, t, o) {
|
|
342
|
+
const a = performance.now(), l = o ?? this.options.defaultTimeout;
|
|
343
|
+
try {
|
|
344
|
+
const r = this.globalActions.get(e);
|
|
345
|
+
if (!r)
|
|
346
|
+
throw new Error(`Action "${e}" not found in registry`);
|
|
347
|
+
return await this.executeWithTimeout(r, t, l), {
|
|
348
|
+
success: !0,
|
|
349
|
+
executionTime: performance.now() - a,
|
|
350
|
+
action: e
|
|
351
|
+
};
|
|
352
|
+
} catch (r) {
|
|
353
|
+
const c = performance.now() - a;
|
|
354
|
+
return {
|
|
355
|
+
success: !1,
|
|
356
|
+
error: r instanceof Error ? r : new Error(String(r)),
|
|
357
|
+
executionTime: c,
|
|
358
|
+
action: e
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Execute a function with timeout
|
|
364
|
+
*/
|
|
365
|
+
async executeWithTimeout(e, t, o) {
|
|
366
|
+
return new Promise((a, l) => {
|
|
367
|
+
const r = setTimeout(() => {
|
|
368
|
+
l(new Error(`Action timeout after ${o}ms`));
|
|
369
|
+
}, o);
|
|
370
|
+
Promise.resolve(e(t)).then((c) => {
|
|
371
|
+
clearTimeout(r), a(c);
|
|
372
|
+
}).catch((c) => {
|
|
373
|
+
clearTimeout(r), l(c);
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
class O {
|
|
379
|
+
static instance;
|
|
380
|
+
/**
|
|
381
|
+
* Gets the singleton instance of HST
|
|
382
|
+
* @returns The HST singleton instance
|
|
383
|
+
*/
|
|
384
|
+
static getInstance() {
|
|
385
|
+
return O.instance || (O.instance = new O()), O.instance;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Gets the global registry instance
|
|
389
|
+
* @returns The global registry object or undefined if not found
|
|
390
|
+
*/
|
|
391
|
+
getRegistry() {
|
|
392
|
+
if (typeof globalThis < "u") {
|
|
393
|
+
const e = globalThis.Registry?._root;
|
|
394
|
+
if (e)
|
|
395
|
+
return e;
|
|
396
|
+
}
|
|
397
|
+
if (typeof window < "u") {
|
|
398
|
+
const e = window.Registry?._root;
|
|
399
|
+
if (e)
|
|
400
|
+
return e;
|
|
401
|
+
}
|
|
402
|
+
if (typeof global < "u" && global) {
|
|
403
|
+
const e = global.Registry?._root;
|
|
404
|
+
if (e)
|
|
405
|
+
return e;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Helper method to get doctype metadata from the registry
|
|
410
|
+
* @param doctype - The name of the doctype to retrieve metadata for
|
|
411
|
+
* @returns The doctype metadata object or undefined if not found
|
|
412
|
+
*/
|
|
413
|
+
getDoctypeMeta(e) {
|
|
414
|
+
const t = this.getRegistry();
|
|
415
|
+
if (t && typeof t == "object" && "registry" in t)
|
|
416
|
+
return t.registry[e];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
class ee {
|
|
420
|
+
target;
|
|
421
|
+
parentPath;
|
|
422
|
+
rootNode;
|
|
423
|
+
doctype;
|
|
424
|
+
parentDoctype;
|
|
425
|
+
hst;
|
|
426
|
+
constructor(e, t, o = "", a = null, l) {
|
|
427
|
+
return this.target = e, this.parentPath = o, this.rootNode = a || this, this.doctype = t, this.parentDoctype = l, this.hst = O.getInstance(), new Proxy(this, {
|
|
428
|
+
get(r, c) {
|
|
429
|
+
if (c in r) return r[c];
|
|
430
|
+
const n = String(c);
|
|
431
|
+
return r.getNode(n);
|
|
432
|
+
},
|
|
433
|
+
set(r, c, n) {
|
|
434
|
+
const u = String(c);
|
|
435
|
+
return r.set(u, n), !0;
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
get(e) {
|
|
440
|
+
return this.resolveValue(e);
|
|
441
|
+
}
|
|
442
|
+
// Method to get a tree-wrapped node for navigation
|
|
443
|
+
getNode(e) {
|
|
444
|
+
const t = this.resolvePath(e), o = this.resolveValue(e);
|
|
445
|
+
return typeof o == "object" && o !== null && !this.isPrimitive(o) ? new ee(o, this.doctype, t, this.rootNode, this.parentDoctype) : new ee(o, this.doctype, t, this.rootNode, this.parentDoctype);
|
|
446
|
+
}
|
|
447
|
+
set(e, t) {
|
|
448
|
+
const o = this.resolvePath(e), a = this.has(e) ? this.get(e) : void 0;
|
|
449
|
+
this.updateValue(e, t), this.triggerFieldActions(o, a, t);
|
|
450
|
+
}
|
|
451
|
+
has(e) {
|
|
452
|
+
try {
|
|
453
|
+
if (e === "")
|
|
454
|
+
return !0;
|
|
455
|
+
const t = this.parsePath(e);
|
|
456
|
+
let o = this.target;
|
|
457
|
+
for (let a = 0; a < t.length; a++) {
|
|
458
|
+
const l = t[a];
|
|
459
|
+
if (o == null)
|
|
460
|
+
return !1;
|
|
461
|
+
if (a === t.length - 1)
|
|
462
|
+
return this.isImmutable(o) ? o.has(l) : this.isPiniaStore(o) && o.$state && l in o.$state || l in o;
|
|
463
|
+
o = this.getProperty(o, l);
|
|
464
|
+
}
|
|
465
|
+
return !1;
|
|
466
|
+
} catch {
|
|
467
|
+
return !1;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
// Tree navigation methods
|
|
471
|
+
getParent() {
|
|
472
|
+
if (!this.parentPath) return null;
|
|
473
|
+
const e = this.parentPath.split(".").slice(0, -1).join(".");
|
|
474
|
+
return e === "" ? this.rootNode : this.rootNode.getNode(e);
|
|
475
|
+
}
|
|
476
|
+
getRoot() {
|
|
477
|
+
return this.rootNode;
|
|
478
|
+
}
|
|
479
|
+
getPath() {
|
|
480
|
+
return this.parentPath;
|
|
481
|
+
}
|
|
482
|
+
getDepth() {
|
|
483
|
+
return this.parentPath ? this.parentPath.split(".").length : 0;
|
|
484
|
+
}
|
|
485
|
+
getBreadcrumbs() {
|
|
486
|
+
return this.parentPath ? this.parentPath.split(".") : [];
|
|
487
|
+
}
|
|
488
|
+
// Private helper methods
|
|
489
|
+
resolvePath(e) {
|
|
490
|
+
return e === "" ? this.parentPath : this.parentPath ? `${this.parentPath}.${e}` : e;
|
|
491
|
+
}
|
|
492
|
+
resolveValue(e) {
|
|
493
|
+
if (e === "")
|
|
494
|
+
return this.target;
|
|
495
|
+
const t = this.parsePath(e);
|
|
496
|
+
let o = this.target;
|
|
497
|
+
for (const a of t) {
|
|
498
|
+
if (o == null)
|
|
499
|
+
return;
|
|
500
|
+
o = this.getProperty(o, a);
|
|
501
|
+
}
|
|
502
|
+
return o;
|
|
503
|
+
}
|
|
504
|
+
updateValue(e, t) {
|
|
505
|
+
if (e === "")
|
|
506
|
+
throw new Error("Cannot set value on empty path");
|
|
507
|
+
const o = this.parsePath(e), a = o.pop();
|
|
508
|
+
let l = this.target;
|
|
509
|
+
for (const r of o)
|
|
510
|
+
if (l = this.getProperty(l, r), l == null)
|
|
511
|
+
throw new Error(`Cannot set property on null/undefined path: ${e}`);
|
|
512
|
+
this.setProperty(l, a, t);
|
|
513
|
+
}
|
|
514
|
+
getProperty(e, t) {
|
|
515
|
+
return this.isImmutable(e) ? e.get(t) : this.isVueReactive(e) ? e[t] : this.isPiniaStore(e) ? e.$state?.[t] ?? e[t] : e[t];
|
|
516
|
+
}
|
|
517
|
+
setProperty(e, t, o) {
|
|
518
|
+
if (this.isImmutable(e))
|
|
519
|
+
throw new Error("Cannot directly mutate immutable objects. Use immutable update methods instead.");
|
|
520
|
+
if (this.isPiniaStore(e)) {
|
|
521
|
+
e.$patch ? e.$patch({ [t]: o }) : e[t] = o;
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
e[t] = o;
|
|
525
|
+
}
|
|
526
|
+
async triggerFieldActions(e, t, o) {
|
|
527
|
+
try {
|
|
528
|
+
const a = De(), l = e.split("."), r = l.slice(2).join(".") || l[l.length - 1], c = this.doctype;
|
|
529
|
+
let n;
|
|
530
|
+
l.length >= 2 && (n = l[1]);
|
|
531
|
+
const u = {
|
|
532
|
+
path: e,
|
|
533
|
+
fieldname: r,
|
|
534
|
+
beforeValue: t,
|
|
535
|
+
afterValue: o,
|
|
536
|
+
operation: "set",
|
|
537
|
+
doctype: c,
|
|
538
|
+
recordId: n,
|
|
539
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
540
|
+
};
|
|
541
|
+
await a.executeFieldTriggers(u);
|
|
542
|
+
} catch (a) {
|
|
543
|
+
a instanceof Error && console.warn("Field trigger error:", a.message);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
isVueReactive(e) {
|
|
547
|
+
return e && typeof e == "object" && "__v_isReactive" in e && e.__v_isReactive === !0;
|
|
548
|
+
}
|
|
549
|
+
isPiniaStore(e) {
|
|
550
|
+
return e && typeof e == "object" && ("$state" in e || "$patch" in e || "$id" in e);
|
|
551
|
+
}
|
|
552
|
+
isImmutable(e) {
|
|
553
|
+
if (!e || typeof e != "object")
|
|
554
|
+
return !1;
|
|
555
|
+
const t = "get" in e && typeof e.get == "function", o = "set" in e && typeof e.set == "function", a = "has" in e && typeof e.has == "function", l = "__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;
|
|
556
|
+
let r;
|
|
557
|
+
try {
|
|
558
|
+
const n = e;
|
|
559
|
+
if ("constructor" in n && n.constructor && typeof n.constructor == "object" && "name" in n.constructor) {
|
|
560
|
+
const u = n.constructor.name;
|
|
561
|
+
r = typeof u == "string" ? u : void 0;
|
|
562
|
+
}
|
|
563
|
+
} catch {
|
|
564
|
+
r = void 0;
|
|
565
|
+
}
|
|
566
|
+
const c = r && (r.includes("Map") || r.includes("List") || r.includes("Set") || r.includes("Stack") || r.includes("Seq")) && (t || o);
|
|
567
|
+
return !!(t && o && a && l || t && o && c);
|
|
568
|
+
}
|
|
569
|
+
isPrimitive(e) {
|
|
570
|
+
return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "function" || typeof e == "symbol" || typeof e == "bigint";
|
|
571
|
+
}
|
|
572
|
+
parsePath(e) {
|
|
573
|
+
return e ? e.split(".").filter((t) => t.length > 0) : [];
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function mt(s, e, t) {
|
|
577
|
+
return new ee(s, e, "", null, t);
|
|
578
|
+
}
|
|
579
|
+
let gt = class {
|
|
580
|
+
hstStore;
|
|
581
|
+
registry;
|
|
582
|
+
constructor(e) {
|
|
583
|
+
this.registry = e, this.initializeHSTStore(), this.setupRegistrySync();
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Initialize the HST store structure
|
|
587
|
+
*/
|
|
588
|
+
initializeHSTStore() {
|
|
589
|
+
const e = {};
|
|
590
|
+
Object.keys(this.registry.registry).forEach((t) => {
|
|
591
|
+
e[t] = {};
|
|
592
|
+
}), this.hstStore = mt(e, "StonecropStore");
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Setup automatic sync with Registry when doctypes are added
|
|
596
|
+
*/
|
|
597
|
+
setupRegistrySync() {
|
|
598
|
+
const e = this.registry.addDoctype.bind(this.registry);
|
|
599
|
+
this.registry.addDoctype = (t) => {
|
|
600
|
+
e(t), this.hstStore.has(t.slug) || this.hstStore.set(t.slug, {});
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Get records hash for a doctype
|
|
605
|
+
* @param doctype - The doctype to get records for
|
|
606
|
+
* @returns HST node containing records hash
|
|
607
|
+
*/
|
|
608
|
+
records(e) {
|
|
609
|
+
const t = typeof e == "string" ? e : e.slug;
|
|
610
|
+
return this.ensureDoctypeExists(t), this.hstStore.getNode(t);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Add a record to the store
|
|
614
|
+
* @param doctype - The doctype
|
|
615
|
+
* @param recordId - The record ID
|
|
616
|
+
* @param recordData - The record data
|
|
617
|
+
*/
|
|
618
|
+
addRecord(e, t, o) {
|
|
619
|
+
const a = typeof e == "string" ? e : e.slug;
|
|
620
|
+
this.ensureDoctypeExists(a), this.hstStore.set(`${a}.${t}`, o);
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Get a specific record
|
|
624
|
+
* @param doctype - The doctype
|
|
625
|
+
* @param recordId - The record ID
|
|
626
|
+
* @returns HST node for the record or undefined
|
|
627
|
+
*/
|
|
628
|
+
getRecordById(e, t) {
|
|
629
|
+
const o = typeof e == "string" ? e : e.slug;
|
|
630
|
+
if (this.ensureDoctypeExists(o), !(!this.hstStore.has(`${o}.${t}`) || this.hstStore.get(`${o}.${t}`) === void 0))
|
|
631
|
+
return this.hstStore.getNode(`${o}.${t}`);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Remove a record from the store
|
|
635
|
+
* @param doctype - The doctype
|
|
636
|
+
* @param recordId - The record ID
|
|
637
|
+
*/
|
|
638
|
+
removeRecord(e, t) {
|
|
639
|
+
const o = typeof e == "string" ? e : e.slug;
|
|
640
|
+
this.ensureDoctypeExists(o), this.hstStore.has(`${o}.${t}`) && this.hstStore.set(`${o}.${t}`, void 0);
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Get all record IDs for a doctype
|
|
644
|
+
* @param doctype - The doctype
|
|
645
|
+
* @returns Array of record IDs
|
|
646
|
+
*/
|
|
647
|
+
getRecordIds(e) {
|
|
648
|
+
const t = typeof e == "string" ? e : e.slug;
|
|
649
|
+
this.ensureDoctypeExists(t);
|
|
650
|
+
const o = this.hstStore.get(t);
|
|
651
|
+
return !o || typeof o != "object" ? [] : Object.keys(o).filter((a) => o[a] !== void 0);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Clear all records for a doctype
|
|
655
|
+
* @param doctype - The doctype
|
|
656
|
+
*/
|
|
657
|
+
clearRecords(e) {
|
|
658
|
+
const t = typeof e == "string" ? e : e.slug;
|
|
659
|
+
this.ensureDoctypeExists(t), this.getRecordIds(t).forEach((o) => {
|
|
660
|
+
this.hstStore.set(`${t}.${o}`, void 0);
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Setup method for doctype initialization
|
|
665
|
+
* @param doctype - The doctype to setup
|
|
666
|
+
*/
|
|
667
|
+
setup(e) {
|
|
668
|
+
this.ensureDoctypeExists(e.slug);
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Run action on doctype (maintains compatibility)
|
|
672
|
+
* @param _doctype - The doctype
|
|
673
|
+
* @param _action - The action to run
|
|
674
|
+
* @param _args - Action arguments
|
|
675
|
+
*/
|
|
676
|
+
runAction(e, t, o) {
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Get records from server (maintains compatibility)
|
|
680
|
+
* @param doctype - The doctype
|
|
681
|
+
*/
|
|
682
|
+
async getRecords(e) {
|
|
683
|
+
(await (await fetch(`/${e.slug}`)).json()).forEach((t) => {
|
|
684
|
+
t.id && this.addRecord(e, t.id, t);
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Get single record from server (maintains compatibility)
|
|
689
|
+
* @param doctype - The doctype
|
|
690
|
+
* @param recordId - The record ID
|
|
691
|
+
*/
|
|
692
|
+
async getRecord(e, t) {
|
|
693
|
+
const o = await (await fetch(`/${e.slug}/${t}`)).json();
|
|
694
|
+
this.addRecord(e, t, o);
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Ensure doctype section exists in HST store
|
|
698
|
+
* @param slug - The doctype slug
|
|
699
|
+
*/
|
|
700
|
+
ensureDoctypeExists(e) {
|
|
701
|
+
this.hstStore.has(e) || this.hstStore.set(e, {});
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Get the root HST store node for advanced usage
|
|
705
|
+
* @returns Root HST node
|
|
706
|
+
*/
|
|
707
|
+
getStore() {
|
|
708
|
+
return this.hstStore;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
function yt(s) {
|
|
712
|
+
s || (s = {});
|
|
713
|
+
const e = s.registry || me("$registry"), t = me("$stonecrop"), o = k(), a = k(), l = k({}), r = k(), c = k();
|
|
714
|
+
te(async () => {
|
|
715
|
+
if (console.log("🚀 [useStonecrop] Initializing Stonecrop composable", { options: s, registry: e }), !!e) {
|
|
716
|
+
if (o.value = t || new gt(e), !s.doctype && e.router) {
|
|
717
|
+
console.log("🌍 [useStonecrop] Setting up router-based doctype loading");
|
|
718
|
+
const i = e.router.currentRoute.value;
|
|
719
|
+
if (!i.path) return;
|
|
720
|
+
console.log("🔍 [useStonecrop] Current route path:", i.path);
|
|
721
|
+
const h = i.path.split("/").filter((m) => m.length > 0), p = h[0]?.toLowerCase(), f = h[1]?.toLowerCase();
|
|
722
|
+
if (p) {
|
|
723
|
+
console.log("📄 [useStonecrop] Loading doctype from slug:", p, { recordId: f });
|
|
724
|
+
const m = f && f !== "new", A = m ? `${p}-form` : `${p}-list`;
|
|
725
|
+
console.log("🎯 [useStonecrop] Resolved doctype:", {
|
|
726
|
+
originalSlug: p,
|
|
727
|
+
actualSlug: A,
|
|
728
|
+
isFormView: m,
|
|
729
|
+
recordId: f
|
|
730
|
+
});
|
|
731
|
+
const S = await e.getMeta?.(A);
|
|
732
|
+
if (S) {
|
|
733
|
+
if (e.addDoctype(S), o.value.setup(S), r.value = S, c.value = f, a.value = o.value.getStore(), f && f !== "new") {
|
|
734
|
+
const $ = o.value.getRecordById(S, f);
|
|
735
|
+
if ($)
|
|
736
|
+
l.value = $.get("") || {};
|
|
737
|
+
else
|
|
738
|
+
try {
|
|
739
|
+
await o.value.getRecord(S, f);
|
|
740
|
+
const R = o.value.getRecordById(S, f);
|
|
741
|
+
R && (l.value = R.get("") || {});
|
|
742
|
+
} catch {
|
|
743
|
+
l.value = X(S);
|
|
744
|
+
}
|
|
745
|
+
} else
|
|
746
|
+
l.value = X(S);
|
|
747
|
+
if (console.log("🗄️ [useStonecrop] HST Store initialized:", a.value), a.value && (ge(S, f || "new", l, a.value), Object.keys(l.value).length > 0)) {
|
|
748
|
+
const $ = `${S.slug}.${f || "new"}`;
|
|
749
|
+
Object.keys(l.value).forEach((R) => {
|
|
750
|
+
const P = `${$}.${R}`;
|
|
751
|
+
try {
|
|
752
|
+
a.value.set(P, l.value[R]);
|
|
753
|
+
} catch {
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
o.value.runAction(S, "load", f ? [f] : void 0);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (s.doctype) {
|
|
762
|
+
a.value = o.value.getStore();
|
|
763
|
+
const i = s.doctype, h = s.recordId;
|
|
764
|
+
if (h && h !== "new") {
|
|
765
|
+
const p = o.value.getRecordById(i, h);
|
|
766
|
+
if (p)
|
|
767
|
+
l.value = p.get("") || {};
|
|
768
|
+
else
|
|
769
|
+
try {
|
|
770
|
+
await o.value.getRecord(i, h);
|
|
771
|
+
const f = o.value.getRecordById(i, h);
|
|
772
|
+
f && (l.value = f.get("") || {});
|
|
773
|
+
} catch {
|
|
774
|
+
l.value = X(i);
|
|
775
|
+
}
|
|
776
|
+
} else
|
|
777
|
+
l.value = X(i);
|
|
778
|
+
if (a.value && (ge(i, h || "new", l, a.value), Object.keys(l.value).length > 0)) {
|
|
779
|
+
const p = `${i.slug}.${h || "new"}`;
|
|
780
|
+
Object.keys(l.value).forEach((f) => {
|
|
781
|
+
const m = `${p}.${f}`;
|
|
782
|
+
try {
|
|
783
|
+
a.value.set(m, l.value[f]);
|
|
784
|
+
} catch {
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
const n = (i, h) => {
|
|
792
|
+
const p = s.doctype || r.value;
|
|
793
|
+
if (!p) return "";
|
|
794
|
+
const f = h || s.recordId || c.value || "new";
|
|
795
|
+
return `${p.slug}.${f}.${i}`;
|
|
796
|
+
}, u = (i) => {
|
|
797
|
+
const h = s.doctype || r.value;
|
|
798
|
+
if (!(!a.value || !o.value || !h))
|
|
799
|
+
try {
|
|
800
|
+
const p = i.path.split(".");
|
|
801
|
+
if (p.length >= 2) {
|
|
802
|
+
const A = p[0], S = p[1];
|
|
803
|
+
if (a.value.has(`${A}.${S}`) || o.value.addRecord(h, S, { ...l.value }), p.length > 3) {
|
|
804
|
+
const $ = `${A}.${S}`, R = p.slice(2);
|
|
805
|
+
let P = $;
|
|
806
|
+
for (let V = 0; V < R.length - 1; V++)
|
|
807
|
+
if (P += `.${R[V]}`, !a.value.has(P)) {
|
|
808
|
+
const j = R[V + 1], q = !isNaN(Number(j));
|
|
809
|
+
a.value.set(P, q ? [] : {});
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
a.value.set(i.path, i.value);
|
|
814
|
+
const f = i.fieldname.split("."), m = { ...l.value };
|
|
815
|
+
f.length === 1 ? m[f[0]] = i.value : wt(m, f, i.value), l.value = m;
|
|
816
|
+
} catch {
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
return (s.doctype || e?.router) && (ce("hstPathProvider", n), ce("hstChangeHandler", u)), s.doctype ? {
|
|
820
|
+
stonecrop: o,
|
|
821
|
+
provideHSTPath: n,
|
|
822
|
+
handleHSTChange: u,
|
|
823
|
+
hstStore: a,
|
|
824
|
+
formData: l
|
|
825
|
+
} : !s.doctype && e?.router ? {
|
|
826
|
+
stonecrop: o,
|
|
827
|
+
provideHSTPath: n,
|
|
828
|
+
handleHSTChange: u,
|
|
829
|
+
hstStore: a,
|
|
830
|
+
formData: l
|
|
831
|
+
} : { stonecrop: o };
|
|
832
|
+
}
|
|
833
|
+
function X(s) {
|
|
834
|
+
const e = {};
|
|
835
|
+
return s.schema && s.schema.forEach((t) => {
|
|
836
|
+
switch ("fieldtype" in t ? t.fieldtype : "Data") {
|
|
837
|
+
case "Data":
|
|
838
|
+
case "Text":
|
|
839
|
+
e[t.fieldname] = "";
|
|
840
|
+
break;
|
|
841
|
+
case "Check":
|
|
842
|
+
e[t.fieldname] = !1;
|
|
843
|
+
break;
|
|
844
|
+
case "Int":
|
|
845
|
+
case "Float":
|
|
846
|
+
e[t.fieldname] = 0;
|
|
847
|
+
break;
|
|
848
|
+
case "Table":
|
|
849
|
+
e[t.fieldname] = [];
|
|
850
|
+
break;
|
|
851
|
+
case "JSON":
|
|
852
|
+
e[t.fieldname] = {};
|
|
853
|
+
break;
|
|
854
|
+
default:
|
|
855
|
+
e[t.fieldname] = null;
|
|
856
|
+
}
|
|
857
|
+
}), e;
|
|
858
|
+
}
|
|
859
|
+
function ge(s, e, t, o) {
|
|
860
|
+
console.log("🔗 [useStonecrop] Setting up deep reactivity", { doctype: s.slug, recordId: e, formData: t }), x(
|
|
861
|
+
t,
|
|
862
|
+
(a) => {
|
|
863
|
+
console.log("🔄 [useStonecrop] formData changed:", a);
|
|
864
|
+
const l = `${s.slug}.${e}`;
|
|
865
|
+
Object.keys(a).forEach((r) => {
|
|
866
|
+
const c = `${l}.${r}`;
|
|
867
|
+
try {
|
|
868
|
+
o.set(c, a[r]);
|
|
869
|
+
} catch {
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
},
|
|
873
|
+
{ deep: !0 }
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
function wt(s, e, t) {
|
|
877
|
+
let o = s;
|
|
878
|
+
for (let l = 0; l < e.length - 1; l++) {
|
|
879
|
+
const r = e[l];
|
|
880
|
+
(!(r in o) || typeof o[r] != "object") && (o[r] = isNaN(Number(e[l + 1])) ? {} : []), o = o[r];
|
|
881
|
+
}
|
|
882
|
+
const a = e[e.length - 1];
|
|
883
|
+
o[a] = t;
|
|
884
|
+
}
|
|
885
|
+
const bt = (s, e) => {
|
|
886
|
+
const t = s.__vccOpts || s;
|
|
887
|
+
for (const [o, a] of e)
|
|
888
|
+
t[o] = a;
|
|
889
|
+
return t;
|
|
890
|
+
};
|
|
891
|
+
function Re(s) {
|
|
892
|
+
return We() ? (Ke(s), !0) : !1;
|
|
893
|
+
}
|
|
894
|
+
const xe = typeof window < "u" && typeof document < "u";
|
|
895
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
896
|
+
const $t = Object.prototype.toString, _t = (s) => $t.call(s) === "[object Object]", kt = () => {
|
|
897
|
+
}, ye = /* @__PURE__ */ St();
|
|
898
|
+
function St() {
|
|
899
|
+
var s, e;
|
|
900
|
+
return xe && ((s = window?.navigator) == null ? void 0 : s.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((e = window?.navigator) == null ? void 0 : e.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
|
|
901
|
+
}
|
|
902
|
+
function Dt(...s) {
|
|
903
|
+
if (s.length !== 1)
|
|
904
|
+
return Le(...s);
|
|
905
|
+
const e = s[0];
|
|
906
|
+
return typeof e == "function" ? Be(ze(() => ({ get: e, set: kt }))) : k(e);
|
|
907
|
+
}
|
|
908
|
+
function re(s) {
|
|
909
|
+
return Array.isArray(s) ? s : [s];
|
|
910
|
+
}
|
|
911
|
+
function Rt(s, e, t) {
|
|
912
|
+
return x(
|
|
913
|
+
s,
|
|
914
|
+
e,
|
|
915
|
+
{
|
|
916
|
+
...t,
|
|
917
|
+
immediate: !0
|
|
918
|
+
}
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
const xt = xe ? window : void 0;
|
|
922
|
+
function Ct(s) {
|
|
923
|
+
var e;
|
|
924
|
+
const t = M(s);
|
|
925
|
+
return (e = t?.$el) != null ? e : t;
|
|
926
|
+
}
|
|
927
|
+
function Tt(...s) {
|
|
928
|
+
const e = [], t = () => {
|
|
929
|
+
e.forEach((c) => c()), e.length = 0;
|
|
930
|
+
}, o = (c, n, u, i) => (c.addEventListener(n, u, i), () => c.removeEventListener(n, u, i)), a = D(() => {
|
|
931
|
+
const c = re(M(s[0])).filter((n) => n != null);
|
|
932
|
+
return c.every((n) => typeof n != "string") ? c : void 0;
|
|
933
|
+
}), l = Rt(
|
|
934
|
+
() => {
|
|
935
|
+
var c, n;
|
|
936
|
+
return [
|
|
937
|
+
(n = (c = a.value) == null ? void 0 : c.map((u) => Ct(u))) != null ? n : [xt].filter((u) => u != null),
|
|
938
|
+
re(M(a.value ? s[1] : s[0])),
|
|
939
|
+
re(Q(a.value ? s[2] : s[1])),
|
|
940
|
+
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
941
|
+
M(a.value ? s[3] : s[2])
|
|
942
|
+
];
|
|
943
|
+
},
|
|
944
|
+
([c, n, u, i]) => {
|
|
945
|
+
if (t(), !c?.length || !n?.length || !u?.length)
|
|
946
|
+
return;
|
|
947
|
+
const h = _t(i) ? { ...i } : i;
|
|
948
|
+
e.push(
|
|
949
|
+
...c.flatMap(
|
|
950
|
+
(p) => n.flatMap(
|
|
951
|
+
(f) => u.map((m) => o(p, f, m, h))
|
|
952
|
+
)
|
|
953
|
+
)
|
|
954
|
+
);
|
|
955
|
+
},
|
|
956
|
+
{ flush: "post" }
|
|
957
|
+
), r = () => {
|
|
958
|
+
l(), t();
|
|
959
|
+
};
|
|
960
|
+
return Re(t), r;
|
|
961
|
+
}
|
|
962
|
+
function le(s) {
|
|
963
|
+
return typeof Window < "u" && s instanceof Window ? s.document.documentElement : typeof Document < "u" && s instanceof Document ? s.documentElement : s;
|
|
964
|
+
}
|
|
965
|
+
function Ce(s) {
|
|
966
|
+
const e = window.getComputedStyle(s);
|
|
967
|
+
if (e.overflowX === "scroll" || e.overflowY === "scroll" || e.overflowX === "auto" && s.clientWidth < s.scrollWidth || e.overflowY === "auto" && s.clientHeight < s.scrollHeight)
|
|
968
|
+
return !0;
|
|
969
|
+
{
|
|
970
|
+
const t = s.parentNode;
|
|
971
|
+
return !t || t.tagName === "BODY" ? !1 : Ce(t);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
function Pt(s) {
|
|
975
|
+
const e = s || window.event, t = e.target;
|
|
976
|
+
return Ce(t) ? !1 : e.touches.length > 1 ? !0 : (e.preventDefault && e.preventDefault(), !1);
|
|
977
|
+
}
|
|
978
|
+
const ie = /* @__PURE__ */ new WeakMap();
|
|
979
|
+
function Et(s, e = !1) {
|
|
980
|
+
const t = _e(e);
|
|
981
|
+
let o = null, a = "";
|
|
982
|
+
x(Dt(s), (c) => {
|
|
983
|
+
const n = le(M(c));
|
|
984
|
+
if (n) {
|
|
985
|
+
const u = n;
|
|
986
|
+
if (ie.get(u) || ie.set(u, u.style.overflow), u.style.overflow !== "hidden" && (a = u.style.overflow), u.style.overflow === "hidden")
|
|
987
|
+
return t.value = !0;
|
|
988
|
+
if (t.value)
|
|
989
|
+
return u.style.overflow = "hidden";
|
|
990
|
+
}
|
|
991
|
+
}, {
|
|
992
|
+
immediate: !0
|
|
993
|
+
});
|
|
994
|
+
const l = () => {
|
|
995
|
+
const c = le(M(s));
|
|
996
|
+
!c || t.value || (ye && (o = Tt(
|
|
997
|
+
c,
|
|
998
|
+
"touchmove",
|
|
999
|
+
(n) => {
|
|
1000
|
+
Pt(n);
|
|
1001
|
+
},
|
|
1002
|
+
{ passive: !1 }
|
|
1003
|
+
)), c.style.overflow = "hidden", t.value = !0);
|
|
1004
|
+
}, r = () => {
|
|
1005
|
+
const c = le(M(s));
|
|
1006
|
+
!c || !t.value || (ye && o?.(), c.style.overflow = a, ie.delete(c), t.value = !1);
|
|
1007
|
+
};
|
|
1008
|
+
return Re(r), D({
|
|
1009
|
+
get() {
|
|
1010
|
+
return t.value;
|
|
1011
|
+
},
|
|
1012
|
+
set(c) {
|
|
1013
|
+
c ? l() : r();
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
function Nt() {
|
|
1018
|
+
let s = !1;
|
|
1019
|
+
const e = _e(!1);
|
|
1020
|
+
return (t, o) => {
|
|
1021
|
+
if (e.value = o.value, s)
|
|
1022
|
+
return;
|
|
1023
|
+
s = !0;
|
|
1024
|
+
const a = Et(t, o.value);
|
|
1025
|
+
x(e, (l) => a.value = l);
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
Nt();
|
|
1029
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
1030
|
+
const It = { class: "aform" }, At = /* @__PURE__ */ W({
|
|
1031
|
+
__name: "AForm",
|
|
1032
|
+
props: {
|
|
1033
|
+
modelValue: {},
|
|
1034
|
+
data: {},
|
|
1035
|
+
readonly: { type: Boolean }
|
|
1036
|
+
},
|
|
1037
|
+
emits: ["update:modelValue"],
|
|
1038
|
+
setup(s, { emit: e }) {
|
|
1039
|
+
const t = e, o = k(s.data || {}), a = (r) => {
|
|
1040
|
+
let c = {};
|
|
1041
|
+
for (const [n, u] of Object.entries(r))
|
|
1042
|
+
["component", "fieldtype"].includes(n) || (c[n] = u), n === "rows" && u && u.length === 0 && (c.rows = o.value[r.fieldname]);
|
|
1043
|
+
return c;
|
|
1044
|
+
}, l = D({
|
|
1045
|
+
get: () => s.modelValue.map((r, c) => D({
|
|
1046
|
+
get() {
|
|
1047
|
+
return r.value;
|
|
1048
|
+
},
|
|
1049
|
+
set: (n) => {
|
|
1050
|
+
s.modelValue[c].value = n, t("update:modelValue", s.modelValue);
|
|
1051
|
+
}
|
|
1052
|
+
})),
|
|
1053
|
+
set: () => {
|
|
1054
|
+
}
|
|
1055
|
+
});
|
|
1056
|
+
return (r, c) => (y(), b("form", It, [
|
|
1057
|
+
(y(!0), b(L, null, B(r.modelValue, (n, u) => (y(), ae(Ue(n.component), qe({
|
|
1058
|
+
key: u,
|
|
1059
|
+
schema: n,
|
|
1060
|
+
modelValue: l.value[u].value,
|
|
1061
|
+
"onUpdate:modelValue": (i) => l.value[u].value = i,
|
|
1062
|
+
data: o.value[n.fieldname],
|
|
1063
|
+
readonly: r.readonly
|
|
1064
|
+
}, { ref_for: !0 }, a(n)), null, 16, ["schema", "modelValue", "onUpdate:modelValue", "data", "readonly"]))), 128))
|
|
1065
|
+
]));
|
|
1066
|
+
}
|
|
1067
|
+
}), Vt = /* @__PURE__ */ bt(At, [["__scopeId", "data-v-68845234"]]), Mt = { class: "tabs" }, jt = { tabindex: "0" }, Ht = {
|
|
1068
|
+
version: "1.1",
|
|
1069
|
+
id: "Capa_1",
|
|
1070
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1071
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
|
1072
|
+
x: "0px",
|
|
1073
|
+
y: "0px",
|
|
1074
|
+
viewBox: "0 0 424.098 424.098",
|
|
1075
|
+
style: { "enable-background": "new 0 0 424.098 424.098" },
|
|
1076
|
+
"xml:space": "preserve"
|
|
1077
|
+
}, Ot = { tabindex: "0" }, Ft = { style: { width: "11pt" } }, Lt = /* @__PURE__ */ W({
|
|
1078
|
+
__name: "SheetNav",
|
|
1079
|
+
props: {
|
|
1080
|
+
breadcrumbs: { default: () => [] }
|
|
1081
|
+
},
|
|
1082
|
+
setup(s) {
|
|
1083
|
+
const e = k(!0), t = k(!1), o = k(""), a = we("searchinput"), l = D(() => e.value ? "unrotated" : "rotated"), r = () => {
|
|
1084
|
+
e.value = !e.value;
|
|
1085
|
+
}, c = async () => {
|
|
1086
|
+
t.value = !t.value, await de(() => {
|
|
1087
|
+
a.value.focus();
|
|
1088
|
+
});
|
|
1089
|
+
}, n = (h) => {
|
|
1090
|
+
h.preventDefault(), h.stopPropagation();
|
|
1091
|
+
}, u = async (h) => {
|
|
1092
|
+
h.preventDefault(), h.stopPropagation(), await c();
|
|
1093
|
+
}, i = () => {
|
|
1094
|
+
};
|
|
1095
|
+
return (h, p) => {
|
|
1096
|
+
const f = Ge("router-link");
|
|
1097
|
+
return y(), b("footer", null, [
|
|
1098
|
+
g("ul", Mt, [
|
|
1099
|
+
g("li", {
|
|
1100
|
+
class: "hidebreadcrumbs",
|
|
1101
|
+
onClick: r,
|
|
1102
|
+
onKeydown: J(r, ["enter"])
|
|
1103
|
+
}, [
|
|
1104
|
+
g("a", jt, [
|
|
1105
|
+
g("div", {
|
|
1106
|
+
class: oe(l.value)
|
|
1107
|
+
}, "×", 2)
|
|
1108
|
+
])
|
|
1109
|
+
], 32),
|
|
1110
|
+
g("li", {
|
|
1111
|
+
class: "hometab",
|
|
1112
|
+
onClick: i,
|
|
1113
|
+
onKeydown: J(i, ["enter"]),
|
|
1114
|
+
style: U({ display: e.value ? "block" : "none" })
|
|
1115
|
+
}, [
|
|
1116
|
+
I(f, {
|
|
1117
|
+
to: "/home",
|
|
1118
|
+
tabindex: "0"
|
|
1119
|
+
}, {
|
|
1120
|
+
default: z(() => [
|
|
1121
|
+
(y(), b("svg", Ht, p[5] || (p[5] = [
|
|
1122
|
+
g("g", null, [
|
|
1123
|
+
g("path", {
|
|
1124
|
+
style: { fill: "#010002" },
|
|
1125
|
+
d: `M351.191,401.923H72.901c-4.487,0-8.129-3.633-8.129-8.129V242.262l-56.664-0.114
|
|
1126
|
+
c-3.284-0.008-6.243-1.992-7.495-5.023c-1.252-3.04-0.553-6.527,1.764-8.852L206.104,24.546c1.853-1.845,4.503-2.666,7.047-2.276
|
|
1127
|
+
c2.414,0.39,4.511,1.845,5.731,3.942l47.43,47.43V58.499c0-4.487,3.633-8.129,8.129-8.129h47.755c4.495,0,8.129,3.642,8.129,8.129
|
|
1128
|
+
v79.156l91.39,91.398c2.325,2.325,3.024,5.828,1.764,8.868c-1.26,3.032-4.227,5.007-7.511,5.007c-0.008,0-0.008,0-0.016,0
|
|
1129
|
+
l-56.64-0.114v150.98C359.32,398.29,355.686,401.923,351.191,401.923z M81.03,385.666h262.033V234.67
|
|
1130
|
+
c0-2.162,0.854-4.235,2.39-5.755c1.528-1.52,3.585-2.374,5.739-2.374c0.008,0,0.008,0,0.016,0l45.105,0.089l-79.855-79.863
|
|
1131
|
+
c-1.528-1.528-2.382-3.593-2.382-5.747V66.628h-31.498v26.645c0,3.284-1.975,6.251-5.015,7.511
|
|
1132
|
+
c-3.032,1.268-6.527,0.569-8.86-1.764l-57.038-57.038l-183.95,183.95l45.203,0.089c4.487,0.008,8.112,3.642,8.112,8.129
|
|
1133
|
+
C81.03,234.149,81.03,385.666,81.03,385.666z`
|
|
1134
|
+
})
|
|
1135
|
+
], -1)
|
|
1136
|
+
])))
|
|
1137
|
+
]),
|
|
1138
|
+
_: 1
|
|
1139
|
+
})
|
|
1140
|
+
], 36),
|
|
1141
|
+
g("li", {
|
|
1142
|
+
class: "searchtab",
|
|
1143
|
+
onClick: c,
|
|
1144
|
+
onKeydown: J(c, ["enter"]),
|
|
1145
|
+
style: U({ display: e.value ? "block" : "none" })
|
|
1146
|
+
}, [
|
|
1147
|
+
g("a", Ot, [
|
|
1148
|
+
g("span", {
|
|
1149
|
+
style: U({ display: t.value ? "none" : "block" })
|
|
1150
|
+
}, [
|
|
1151
|
+
(y(), b("svg", Ft, p[6] || (p[6] = [
|
|
1152
|
+
g("g", { transform: "matrix(-0.08088215,0,0,0.08088215,9.8016177,3.1263021e-6)" }, [
|
|
1153
|
+
g("path", {
|
|
1154
|
+
d: "M 93.148438,80.832031 C 109.5,57.742188 104.03125,25.769531 80.941406,9.421875 57.851562,-6.925781 25.878906,-1.460938 9.53125,21.632812 -6.816406,44.722656 -1.351562,76.691406 21.742188,93.039062 38.222656,104.70703 60.011719,105.60547 77.394531,95.339844 l 37.769529,37.542966 c 4.07813,4.29297 10.86328,4.46485 15.15625,0.38672 4.29297,-4.07422 4.46485,-10.85937 0.39063,-15.15234 -0.12891,-0.13672 -0.25391,-0.26172 -0.39063,-0.39063 z m -41.839844,3.5 C 33.0625,84.335938 18.269531,69.554688 18.257812,51.308594 18.253906,33.0625 33.035156,18.269531 51.285156,18.261719 c 18.222656,-0.0078 33.007813,14.75 33.042969,32.972656 0.03125,18.25 -14.742187,33.066406 -32.996094,33.097656 -0.0078,0 -0.01172,0 -0.02344,0 z m 0,0",
|
|
1155
|
+
style: { fill: "#000000", "fill-opacity": "1", "fill-rule": "nonzero", stroke: "none" },
|
|
1156
|
+
id: "path2"
|
|
1157
|
+
})
|
|
1158
|
+
], -1)
|
|
1159
|
+
])))
|
|
1160
|
+
], 4),
|
|
1161
|
+
ue(g("input", {
|
|
1162
|
+
"onUpdate:modelValue": p[0] || (p[0] = (m) => o.value = m),
|
|
1163
|
+
ref: "searchinput",
|
|
1164
|
+
style: U({ display: t.value ? "block" : "none" }),
|
|
1165
|
+
onClick: p[1] || (p[1] = (m) => n(m)),
|
|
1166
|
+
onInput: p[2] || (p[2] = (m) => n(m)),
|
|
1167
|
+
onBlur: p[3] || (p[3] = (m) => u(m)),
|
|
1168
|
+
onKeydown: p[4] || (p[4] = J((m) => u(m), ["enter"])),
|
|
1169
|
+
type: "text"
|
|
1170
|
+
}, null, 36), [
|
|
1171
|
+
[$e, o.value]
|
|
1172
|
+
])
|
|
1173
|
+
])
|
|
1174
|
+
], 36),
|
|
1175
|
+
(y(!0), b(L, null, B(h.breadcrumbs, (m) => (y(), b("li", {
|
|
1176
|
+
key: m.title,
|
|
1177
|
+
style: U({ display: e.value ? "block" : "none" })
|
|
1178
|
+
}, [
|
|
1179
|
+
I(f, {
|
|
1180
|
+
tabindex: "0",
|
|
1181
|
+
to: m.to
|
|
1182
|
+
}, {
|
|
1183
|
+
default: z(() => [
|
|
1184
|
+
Z(C(m.title), 1)
|
|
1185
|
+
]),
|
|
1186
|
+
_: 2
|
|
1187
|
+
}, 1032, ["to"])
|
|
1188
|
+
], 4))), 128))
|
|
1189
|
+
])
|
|
1190
|
+
]);
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
}), Te = /* @__PURE__ */ ve(Lt, [["__scopeId", "data-v-a650f215"]]), Bt = {
|
|
1194
|
+
key: 0,
|
|
1195
|
+
class: "notification-container"
|
|
1196
|
+
}, zt = { class: "notification-icon" }, Wt = { key: 0 }, Kt = { key: 1 }, Ut = { key: 2 }, qt = { key: 3 }, Gt = { class: "notification-content" }, Yt = { class: "notification-message" }, Jt = { class: "notification-time" }, Xt = ["onClick"], Qt = /* @__PURE__ */ W({
|
|
1197
|
+
__name: "FieldTriggerNotifications",
|
|
1198
|
+
async setup(s) {
|
|
1199
|
+
let e, t;
|
|
1200
|
+
const o = k([]);
|
|
1201
|
+
let a = null;
|
|
1202
|
+
try {
|
|
1203
|
+
const n = ([e, t] = Ye(() => import("./actions-Bg0Mh5s7.js")), e = await e, t(), e);
|
|
1204
|
+
n && n.notifications && (a = n.notifications);
|
|
1205
|
+
} catch {
|
|
1206
|
+
console.log("Field trigger actions not available");
|
|
1207
|
+
}
|
|
1208
|
+
function l(n) {
|
|
1209
|
+
const u = o.value.findIndex((i) => i.id === n);
|
|
1210
|
+
if (u > -1 && o.value.splice(u, 1), a) {
|
|
1211
|
+
const i = a.findIndex((h) => h.id === n);
|
|
1212
|
+
i > -1 && a.splice(i, 1);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
function r(n) {
|
|
1216
|
+
return n.toLocaleTimeString();
|
|
1217
|
+
}
|
|
1218
|
+
let c;
|
|
1219
|
+
return te(() => {
|
|
1220
|
+
c = setInterval(() => {
|
|
1221
|
+
a && (o.value = [...a]);
|
|
1222
|
+
}, 100);
|
|
1223
|
+
}), Je(() => {
|
|
1224
|
+
c && clearInterval(c);
|
|
1225
|
+
}), (n, u) => (y(), ae(be, { to: "body" }, [
|
|
1226
|
+
o.value.length > 0 ? (y(), b("div", Bt, [
|
|
1227
|
+
I(Xe, {
|
|
1228
|
+
name: "notification",
|
|
1229
|
+
tag: "div"
|
|
1230
|
+
}, {
|
|
1231
|
+
default: z(() => [
|
|
1232
|
+
(y(!0), b(L, null, B(o.value, (i) => (y(), b("div", {
|
|
1233
|
+
key: i.id,
|
|
1234
|
+
class: oe(["notification", `notification-${i.type}`])
|
|
1235
|
+
}, [
|
|
1236
|
+
g("div", zt, [
|
|
1237
|
+
i.type === "success" ? (y(), b("span", Wt, "✅")) : i.type === "warning" ? (y(), b("span", Kt, "⚠️")) : i.type === "error" ? (y(), b("span", Ut, "❌")) : (y(), b("span", qt, "ℹ️"))
|
|
1238
|
+
]),
|
|
1239
|
+
g("div", Gt, [
|
|
1240
|
+
g("p", Yt, C(i.message), 1),
|
|
1241
|
+
g("p", Jt, C(r(i.timestamp)), 1)
|
|
1242
|
+
]),
|
|
1243
|
+
g("button", {
|
|
1244
|
+
class: "notification-close",
|
|
1245
|
+
onClick: (h) => l(i.id)
|
|
1246
|
+
}, "×", 8, Xt)
|
|
1247
|
+
], 2))), 128))
|
|
1248
|
+
]),
|
|
1249
|
+
_: 1
|
|
1250
|
+
})
|
|
1251
|
+
])) : F("", !0)
|
|
1252
|
+
]));
|
|
1253
|
+
}
|
|
1254
|
+
}), Zt = /* @__PURE__ */ ve(Qt, [["__scopeId", "data-v-25e44434"]]), eo = {
|
|
1255
|
+
key: 1,
|
|
1256
|
+
class: "loading"
|
|
1257
|
+
}, to = {
|
|
1258
|
+
key: 2,
|
|
1259
|
+
class: "loading"
|
|
1260
|
+
}, oo = /* @__PURE__ */ W({
|
|
1261
|
+
__name: "Desktop",
|
|
1262
|
+
props: {
|
|
1263
|
+
availableDoctypes: { default: () => [] }
|
|
1264
|
+
},
|
|
1265
|
+
setup(s) {
|
|
1266
|
+
const { stonecrop: e } = yt(), t = k(!1), o = k(!1), a = k(!1), l = D({
|
|
1267
|
+
get() {
|
|
1268
|
+
if (!e.value || !n.value || !i.value)
|
|
1269
|
+
return {};
|
|
1270
|
+
try {
|
|
1271
|
+
return e.value.getRecordById(n.value, i.value)?.get("") || {};
|
|
1272
|
+
} catch {
|
|
1273
|
+
return {};
|
|
1274
|
+
}
|
|
1275
|
+
},
|
|
1276
|
+
set(d) {
|
|
1277
|
+
if (!(!e.value || !n.value || !i.value))
|
|
1278
|
+
try {
|
|
1279
|
+
const v = e.value.getStore();
|
|
1280
|
+
for (const [w, _] of Object.entries(d)) {
|
|
1281
|
+
const T = `${n.value}.${i.value}.${w}`;
|
|
1282
|
+
v.set(T, _);
|
|
1283
|
+
}
|
|
1284
|
+
} catch (v) {
|
|
1285
|
+
console.warn("HST update failed:", v);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}), r = D(() => Q(e.value?.registry.router?.currentRoute)), c = D(() => e.value?.registry.router), n = D(() => {
|
|
1289
|
+
if (!r.value) return "";
|
|
1290
|
+
if (r.value.meta?.actualDoctype)
|
|
1291
|
+
return r.value.meta.actualDoctype;
|
|
1292
|
+
if (r.value.params.doctype)
|
|
1293
|
+
return r.value.params.doctype;
|
|
1294
|
+
const d = r.value.params.pathMatch;
|
|
1295
|
+
return d && d.length > 0 ? d[0] : "";
|
|
1296
|
+
}), u = D(() => {
|
|
1297
|
+
if (!r.value) return "";
|
|
1298
|
+
if (r.value.meta?.doctype)
|
|
1299
|
+
return r.value.meta.doctype;
|
|
1300
|
+
if (r.value.params.doctype)
|
|
1301
|
+
return r.value.params.doctype;
|
|
1302
|
+
const d = r.value.params.pathMatch;
|
|
1303
|
+
return d && d.length > 0 ? d[0] : "";
|
|
1304
|
+
}), i = D(() => {
|
|
1305
|
+
if (!r.value) return "";
|
|
1306
|
+
if (r.value.params.recordId)
|
|
1307
|
+
return r.value.params.recordId;
|
|
1308
|
+
const d = r.value.params.pathMatch;
|
|
1309
|
+
return d && d.length > 1 ? d[1] : "";
|
|
1310
|
+
}), h = D(() => i.value?.startsWith("new-")), p = D(() => {
|
|
1311
|
+
if (!r.value || r.value.name === "home" || r.value.path === "/")
|
|
1312
|
+
return "doctypes";
|
|
1313
|
+
if (r.value.name && r.value.name !== "catch-all") {
|
|
1314
|
+
const v = r.value.name;
|
|
1315
|
+
if (v.includes("form") || r.value.params.recordId)
|
|
1316
|
+
return "record";
|
|
1317
|
+
if (v.includes("list") || r.value.params.doctype)
|
|
1318
|
+
return "records";
|
|
1319
|
+
}
|
|
1320
|
+
const d = r.value.params.pathMatch;
|
|
1321
|
+
return d && d.length > 0 ? d.length === 1 ? "records" : "record" : "doctypes";
|
|
1322
|
+
}), f = D(() => {
|
|
1323
|
+
const d = [];
|
|
1324
|
+
switch (p.value) {
|
|
1325
|
+
case "doctypes":
|
|
1326
|
+
d.push({
|
|
1327
|
+
type: "button",
|
|
1328
|
+
label: "Refresh",
|
|
1329
|
+
action: () => {
|
|
1330
|
+
window.location.reload();
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
break;
|
|
1334
|
+
case "records":
|
|
1335
|
+
d.push(
|
|
1336
|
+
{
|
|
1337
|
+
type: "button",
|
|
1338
|
+
label: "New Record",
|
|
1339
|
+
action: () => void j()
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
type: "button",
|
|
1343
|
+
label: "Refresh",
|
|
1344
|
+
action: () => {
|
|
1345
|
+
window.location.reload();
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
);
|
|
1349
|
+
break;
|
|
1350
|
+
case "record":
|
|
1351
|
+
h.value ? d.push({
|
|
1352
|
+
type: "button",
|
|
1353
|
+
label: "Save",
|
|
1354
|
+
action: () => void G()
|
|
1355
|
+
}) : d.push(
|
|
1356
|
+
{
|
|
1357
|
+
type: "button",
|
|
1358
|
+
label: "Save",
|
|
1359
|
+
action: () => void G()
|
|
1360
|
+
},
|
|
1361
|
+
{
|
|
1362
|
+
type: "button",
|
|
1363
|
+
label: "Delete",
|
|
1364
|
+
action: () => void Y()
|
|
1365
|
+
}
|
|
1366
|
+
);
|
|
1367
|
+
break;
|
|
1368
|
+
}
|
|
1369
|
+
return d;
|
|
1370
|
+
}), m = D(() => {
|
|
1371
|
+
const d = [];
|
|
1372
|
+
return p.value === "records" && u.value ? d.push(
|
|
1373
|
+
{ title: "Home", to: "/" },
|
|
1374
|
+
{ title: $(u.value), to: `/${u.value}` }
|
|
1375
|
+
) : p.value === "record" && u.value && d.push(
|
|
1376
|
+
{ title: "Home", to: "/" },
|
|
1377
|
+
{ title: $(u.value), to: `/${u.value}` },
|
|
1378
|
+
{ title: h.value ? "New Record" : "Edit Record", to: r.value?.fullPath || "" }
|
|
1379
|
+
), d;
|
|
1380
|
+
}), A = (d) => {
|
|
1381
|
+
const v = [
|
|
1382
|
+
{
|
|
1383
|
+
title: "Go Home",
|
|
1384
|
+
description: "Navigate to the home page",
|
|
1385
|
+
action: () => void c.value?.push("/")
|
|
1386
|
+
},
|
|
1387
|
+
{
|
|
1388
|
+
title: "Toggle Command Palette",
|
|
1389
|
+
description: "Open/close the command palette",
|
|
1390
|
+
action: () => a.value = !a.value
|
|
1391
|
+
}
|
|
1392
|
+
];
|
|
1393
|
+
return u.value && (v.push({
|
|
1394
|
+
title: `View ${$(u.value)} Records`,
|
|
1395
|
+
description: `Navigate to ${u.value} list`,
|
|
1396
|
+
action: () => void c.value?.push(`/${u.value}`)
|
|
1397
|
+
}), v.push({
|
|
1398
|
+
title: `Create New ${$(u.value)}`,
|
|
1399
|
+
description: `Create a new ${u.value} record`,
|
|
1400
|
+
action: () => void j()
|
|
1401
|
+
})), s.availableDoctypes.forEach((w) => {
|
|
1402
|
+
v.push({
|
|
1403
|
+
title: `View ${$(w)}`,
|
|
1404
|
+
description: `Navigate to ${w} list`,
|
|
1405
|
+
action: () => void c.value?.push(`/${w}`)
|
|
1406
|
+
});
|
|
1407
|
+
}), d ? v.filter(
|
|
1408
|
+
(w) => w.title.toLowerCase().includes(d.toLowerCase()) || w.description.toLowerCase().includes(d.toLowerCase())
|
|
1409
|
+
) : v;
|
|
1410
|
+
}, S = (d) => {
|
|
1411
|
+
d.action(), a.value = !1;
|
|
1412
|
+
}, $ = (d) => d.split("-").map((v) => v.charAt(0).toUpperCase() + v.slice(1)).join(" "), R = (d) => e.value ? e.value.getRecordIds(d).length : 0, P = async (d) => {
|
|
1413
|
+
await c.value?.push(`/${d}`);
|
|
1414
|
+
}, V = async (d) => {
|
|
1415
|
+
await c.value?.push(`/${u.value}/${d}`);
|
|
1416
|
+
}, j = async () => {
|
|
1417
|
+
const d = `new-${Date.now()}`;
|
|
1418
|
+
await c.value?.push(`/${u.value}/${d}`);
|
|
1419
|
+
}, q = (d) => {
|
|
1420
|
+
if (e.value)
|
|
1421
|
+
try {
|
|
1422
|
+
e.value.records(d);
|
|
1423
|
+
} catch {
|
|
1424
|
+
}
|
|
1425
|
+
}, Pe = () => {
|
|
1426
|
+
if (!s.availableDoctypes.length) return [];
|
|
1427
|
+
const d = s.availableDoctypes.map((v) => ({
|
|
1428
|
+
id: v,
|
|
1429
|
+
doctype: v,
|
|
1430
|
+
display_name: $(v),
|
|
1431
|
+
record_count: R(v),
|
|
1432
|
+
actions: "View Records"
|
|
1433
|
+
}));
|
|
1434
|
+
return [
|
|
1435
|
+
{
|
|
1436
|
+
fieldname: "header",
|
|
1437
|
+
component: "div",
|
|
1438
|
+
value: `
|
|
1439
|
+
<div class="view-header">
|
|
1440
|
+
<h1>Available Doctypes</h1>
|
|
1441
|
+
</div>
|
|
1442
|
+
`
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
fieldname: "doctypes_table",
|
|
1446
|
+
component: "ATable",
|
|
1447
|
+
columns: [
|
|
1448
|
+
{
|
|
1449
|
+
label: "Doctype",
|
|
1450
|
+
name: "doctype",
|
|
1451
|
+
type: "Data",
|
|
1452
|
+
align: "left",
|
|
1453
|
+
edit: !1,
|
|
1454
|
+
width: "20ch"
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
label: "Name",
|
|
1458
|
+
name: "display_name",
|
|
1459
|
+
type: "Data",
|
|
1460
|
+
align: "left",
|
|
1461
|
+
edit: !1,
|
|
1462
|
+
width: "30ch"
|
|
1463
|
+
},
|
|
1464
|
+
{
|
|
1465
|
+
label: "Records",
|
|
1466
|
+
name: "record_count",
|
|
1467
|
+
type: "Data",
|
|
1468
|
+
align: "center",
|
|
1469
|
+
edit: !1,
|
|
1470
|
+
width: "15ch"
|
|
1471
|
+
},
|
|
1472
|
+
{
|
|
1473
|
+
label: "Actions",
|
|
1474
|
+
name: "actions",
|
|
1475
|
+
type: "Data",
|
|
1476
|
+
align: "center",
|
|
1477
|
+
edit: !1,
|
|
1478
|
+
width: "20ch"
|
|
1479
|
+
}
|
|
1480
|
+
],
|
|
1481
|
+
config: {
|
|
1482
|
+
view: "list",
|
|
1483
|
+
fullWidth: !0
|
|
1484
|
+
},
|
|
1485
|
+
rows: d
|
|
1486
|
+
}
|
|
1487
|
+
];
|
|
1488
|
+
}, Ee = () => {
|
|
1489
|
+
if (!n.value) return [];
|
|
1490
|
+
if (!e.value) return [];
|
|
1491
|
+
const d = Ie(), v = Ae();
|
|
1492
|
+
if (v.length === 0)
|
|
1493
|
+
return [
|
|
1494
|
+
{
|
|
1495
|
+
fieldname: "header",
|
|
1496
|
+
component: "div",
|
|
1497
|
+
value: `
|
|
1498
|
+
<div class="view-header">
|
|
1499
|
+
<nav class="breadcrumbs">
|
|
1500
|
+
<a href="/">Home</a>
|
|
1501
|
+
<span class="separator">/</span>
|
|
1502
|
+
<span class="current">${$(u.value || n.value)}</span>
|
|
1503
|
+
</nav>
|
|
1504
|
+
<h1>${$(u.value || n.value)} Records</h1>
|
|
1505
|
+
</div>
|
|
1506
|
+
`
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
fieldname: "loading",
|
|
1510
|
+
component: "div",
|
|
1511
|
+
value: `
|
|
1512
|
+
<div class="loading-state">
|
|
1513
|
+
<p>Loading ${$(u.value || n.value)} schema...</p>
|
|
1514
|
+
</div>
|
|
1515
|
+
`
|
|
1516
|
+
}
|
|
1517
|
+
];
|
|
1518
|
+
const w = d.map((_) => ({
|
|
1519
|
+
..._,
|
|
1520
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1521
|
+
id: _.id || "",
|
|
1522
|
+
actions: "Edit | Delete"
|
|
1523
|
+
}));
|
|
1524
|
+
return [
|
|
1525
|
+
{
|
|
1526
|
+
fieldname: "header",
|
|
1527
|
+
component: "div",
|
|
1528
|
+
value: `
|
|
1529
|
+
<div class="view-header">
|
|
1530
|
+
<nav class="breadcrumbs">
|
|
1531
|
+
<a href="/">Home</a>
|
|
1532
|
+
<span class="separator">/</span>
|
|
1533
|
+
<span class="current">${$(u.value || n.value)}</span>
|
|
1534
|
+
</nav>
|
|
1535
|
+
<h1>${$(u.value || n.value)} Records</h1>
|
|
1536
|
+
</div>
|
|
1537
|
+
`
|
|
1538
|
+
},
|
|
1539
|
+
{
|
|
1540
|
+
fieldname: "actions",
|
|
1541
|
+
component: "div",
|
|
1542
|
+
value: `
|
|
1543
|
+
<div class="view-actions">
|
|
1544
|
+
<button class="btn-primary" data-action="create">
|
|
1545
|
+
New ${$(u.value || n.value)}
|
|
1546
|
+
</button>
|
|
1547
|
+
</div>
|
|
1548
|
+
`
|
|
1549
|
+
},
|
|
1550
|
+
...d.length === 0 ? [
|
|
1551
|
+
{
|
|
1552
|
+
fieldname: "empty_state",
|
|
1553
|
+
component: "div",
|
|
1554
|
+
value: `
|
|
1555
|
+
<div class="empty-state">
|
|
1556
|
+
<p>No ${u.value || n.value} records found.</p>
|
|
1557
|
+
<button class="btn-primary" data-action="create">
|
|
1558
|
+
Create First Record
|
|
1559
|
+
</button>
|
|
1560
|
+
</div>
|
|
1561
|
+
`
|
|
1562
|
+
}
|
|
1563
|
+
] : [
|
|
1564
|
+
{
|
|
1565
|
+
fieldname: "records_table",
|
|
1566
|
+
component: "ATable",
|
|
1567
|
+
columns: [
|
|
1568
|
+
...v.map((_) => ({
|
|
1569
|
+
label: _.label,
|
|
1570
|
+
name: _.fieldname,
|
|
1571
|
+
type: _.fieldtype,
|
|
1572
|
+
align: "left",
|
|
1573
|
+
edit: !1,
|
|
1574
|
+
width: "20ch"
|
|
1575
|
+
})),
|
|
1576
|
+
{
|
|
1577
|
+
label: "Actions",
|
|
1578
|
+
name: "actions",
|
|
1579
|
+
type: "Data",
|
|
1580
|
+
align: "center",
|
|
1581
|
+
edit: !1,
|
|
1582
|
+
width: "20ch"
|
|
1583
|
+
}
|
|
1584
|
+
],
|
|
1585
|
+
config: {
|
|
1586
|
+
view: "list",
|
|
1587
|
+
fullWidth: !0
|
|
1588
|
+
},
|
|
1589
|
+
rows: w
|
|
1590
|
+
}
|
|
1591
|
+
]
|
|
1592
|
+
];
|
|
1593
|
+
}, Ne = () => {
|
|
1594
|
+
if (!n.value) return [];
|
|
1595
|
+
if (!e.value) return [];
|
|
1596
|
+
try {
|
|
1597
|
+
const v = e.value?.registry?.registry[n.value];
|
|
1598
|
+
if (!v?.schema)
|
|
1599
|
+
return [
|
|
1600
|
+
{
|
|
1601
|
+
fieldname: "header",
|
|
1602
|
+
component: "div",
|
|
1603
|
+
value: `
|
|
1604
|
+
<div class="view-header">
|
|
1605
|
+
<nav class="breadcrumbs">
|
|
1606
|
+
<a href="/">Home</a>
|
|
1607
|
+
<span class="separator">/</span>
|
|
1608
|
+
<a href="/${u.value || n.value}">${$(
|
|
1609
|
+
u.value || n.value
|
|
1610
|
+
)}</a>
|
|
1611
|
+
<span class="separator">/</span>
|
|
1612
|
+
<span class="current">${h.value ? "New Record" : i.value}</span>
|
|
1613
|
+
</nav>
|
|
1614
|
+
<h1>${h.value ? `New ${$(u.value || n.value)}` : `Edit ${$(u.value || n.value)}`}</h1>
|
|
1615
|
+
</div>
|
|
1616
|
+
`
|
|
1617
|
+
},
|
|
1618
|
+
{
|
|
1619
|
+
fieldname: "loading",
|
|
1620
|
+
component: "div",
|
|
1621
|
+
value: `
|
|
1622
|
+
<div class="loading-state">
|
|
1623
|
+
<p>Loading ${$(u.value || n.value)} form...</p>
|
|
1624
|
+
</div>
|
|
1625
|
+
`
|
|
1626
|
+
}
|
|
1627
|
+
];
|
|
1628
|
+
const w = "toArray" in v.schema ? v.schema.toArray() : v.schema, _ = Ve();
|
|
1629
|
+
return [
|
|
1630
|
+
{
|
|
1631
|
+
fieldname: "header",
|
|
1632
|
+
component: "div",
|
|
1633
|
+
value: `
|
|
1634
|
+
<div class="view-header">
|
|
1635
|
+
<nav class="breadcrumbs">
|
|
1636
|
+
<a href="/">Home</a>
|
|
1637
|
+
<span class="separator">/</span>
|
|
1638
|
+
<a href="/${u.value || n.value}">${$(
|
|
1639
|
+
u.value || n.value
|
|
1640
|
+
)}</a>
|
|
1641
|
+
<span class="separator">/</span>
|
|
1642
|
+
<span class="current">${h.value ? "New Record" : i.value}</span>
|
|
1643
|
+
</nav>
|
|
1644
|
+
<h1>
|
|
1645
|
+
${h.value ? `New ${$(u.value || n.value)}` : `Edit ${$(u.value || n.value)}`}
|
|
1646
|
+
</h1>
|
|
1647
|
+
</div>
|
|
1648
|
+
`
|
|
1649
|
+
},
|
|
1650
|
+
{
|
|
1651
|
+
fieldname: "actions",
|
|
1652
|
+
component: "div",
|
|
1653
|
+
value: `
|
|
1654
|
+
<div class="view-actions">
|
|
1655
|
+
<button class="btn-primary" data-action="save" ${o.value ? "disabled" : ""}>
|
|
1656
|
+
${o.value ? "Saving..." : "Save"}
|
|
1657
|
+
</button>
|
|
1658
|
+
<button class="btn-secondary" data-action="cancel">Cancel</button>
|
|
1659
|
+
${h.value ? "" : '<button class="btn-danger" data-action="delete">Delete</button>'}
|
|
1660
|
+
</div>
|
|
1661
|
+
`
|
|
1662
|
+
},
|
|
1663
|
+
...w.map((T) => ({
|
|
1664
|
+
...T,
|
|
1665
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1666
|
+
value: _[T.fieldname] || ""
|
|
1667
|
+
}))
|
|
1668
|
+
];
|
|
1669
|
+
} catch {
|
|
1670
|
+
return [
|
|
1671
|
+
{
|
|
1672
|
+
fieldname: "error",
|
|
1673
|
+
component: "div",
|
|
1674
|
+
value: `
|
|
1675
|
+
<div class="error-state">
|
|
1676
|
+
<p>Unable to load form schema for ${$(u.value || n.value)}</p>
|
|
1677
|
+
</div>
|
|
1678
|
+
`
|
|
1679
|
+
}
|
|
1680
|
+
];
|
|
1681
|
+
}
|
|
1682
|
+
}, Ie = () => {
|
|
1683
|
+
if (!e.value || !n.value)
|
|
1684
|
+
return [];
|
|
1685
|
+
const v = e.value.records(n.value)?.get("");
|
|
1686
|
+
return v && typeof v == "object" && !Array.isArray(v) ? Object.values(v) : [];
|
|
1687
|
+
}, Ae = () => {
|
|
1688
|
+
if (!e.value || !n.value) return [];
|
|
1689
|
+
try {
|
|
1690
|
+
const v = e.value.registry.registry[n.value];
|
|
1691
|
+
if (v?.schema)
|
|
1692
|
+
return ("toArray" in v.schema ? v.schema.toArray() : v.schema).map((_) => ({
|
|
1693
|
+
fieldname: _.fieldname,
|
|
1694
|
+
label: "label" in _ && _.label || _.fieldname,
|
|
1695
|
+
fieldtype: "fieldtype" in _ && _.fieldtype || "Data"
|
|
1696
|
+
}));
|
|
1697
|
+
} catch {
|
|
1698
|
+
}
|
|
1699
|
+
return [];
|
|
1700
|
+
}, Ve = () => !e.value || !n.value || h.value ? {} : e.value.getRecordById(n.value, i.value)?.get("") || {}, Me = D(() => {
|
|
1701
|
+
switch (p.value) {
|
|
1702
|
+
case "doctypes":
|
|
1703
|
+
return Pe();
|
|
1704
|
+
case "records":
|
|
1705
|
+
return Ee();
|
|
1706
|
+
case "record":
|
|
1707
|
+
return Ne();
|
|
1708
|
+
default:
|
|
1709
|
+
return [];
|
|
1710
|
+
}
|
|
1711
|
+
}), K = k([]);
|
|
1712
|
+
x(
|
|
1713
|
+
Me,
|
|
1714
|
+
(d) => {
|
|
1715
|
+
K.value = [...d];
|
|
1716
|
+
},
|
|
1717
|
+
{ immediate: !0, deep: !0 }
|
|
1718
|
+
), x(
|
|
1719
|
+
K,
|
|
1720
|
+
(d) => {
|
|
1721
|
+
if (!(!e.value || !n.value || !i.value || h.value))
|
|
1722
|
+
try {
|
|
1723
|
+
const v = e.value.getStore();
|
|
1724
|
+
d.forEach((w) => {
|
|
1725
|
+
if (w.fieldname && "value" in w && !["header", "actions", "loading", "error"].includes(w.fieldname)) {
|
|
1726
|
+
const _ = `${n.value}.${i.value}.${w.fieldname}`;
|
|
1727
|
+
(v.has(_) ? v.get(_) : void 0) !== w.value && v.set(_, w.value);
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
} catch (v) {
|
|
1731
|
+
console.warn("HST schema sync failed:", v);
|
|
1732
|
+
}
|
|
1733
|
+
},
|
|
1734
|
+
{ deep: !0 }
|
|
1735
|
+
);
|
|
1736
|
+
const G = async () => {
|
|
1737
|
+
if (e.value) {
|
|
1738
|
+
o.value = !0;
|
|
1739
|
+
try {
|
|
1740
|
+
const d = l.value || {};
|
|
1741
|
+
if (h.value) {
|
|
1742
|
+
const v = `record-${Date.now()}`, w = { id: v, ...d };
|
|
1743
|
+
e.value.addRecord(n.value, v, w), await c.value?.replace(`/${u.value}/${v}`);
|
|
1744
|
+
} else {
|
|
1745
|
+
const v = { id: i.value, ...d };
|
|
1746
|
+
e.value.addRecord(n.value, i.value, v);
|
|
1747
|
+
}
|
|
1748
|
+
} catch {
|
|
1749
|
+
} finally {
|
|
1750
|
+
o.value = !1;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
}, pe = async () => {
|
|
1754
|
+
h.value ? await c.value?.push(`/${u.value}`) : he();
|
|
1755
|
+
}, Y = async (d) => {
|
|
1756
|
+
if (!e.value) return;
|
|
1757
|
+
const v = d || i.value;
|
|
1758
|
+
v && confirm("Are you sure you want to delete this record?") && (e.value.removeRecord(n.value, v), p.value === "record" && await c.value?.push(`/${u.value}`));
|
|
1759
|
+
}, je = async (d) => {
|
|
1760
|
+
const v = d.target, w = v.getAttribute("data-action");
|
|
1761
|
+
if (w)
|
|
1762
|
+
switch (w) {
|
|
1763
|
+
case "create":
|
|
1764
|
+
await j();
|
|
1765
|
+
break;
|
|
1766
|
+
case "save":
|
|
1767
|
+
await G();
|
|
1768
|
+
break;
|
|
1769
|
+
case "cancel":
|
|
1770
|
+
await pe();
|
|
1771
|
+
break;
|
|
1772
|
+
case "delete":
|
|
1773
|
+
await Y();
|
|
1774
|
+
break;
|
|
1775
|
+
}
|
|
1776
|
+
const _ = v.closest("td, th");
|
|
1777
|
+
if (_) {
|
|
1778
|
+
const T = _.textContent?.trim(), H = _.closest("tr");
|
|
1779
|
+
if (T === "View Records" && H) {
|
|
1780
|
+
const E = H.querySelectorAll("td");
|
|
1781
|
+
if (E.length > 0) {
|
|
1782
|
+
const N = E[1].textContent?.trim();
|
|
1783
|
+
N && await P(N);
|
|
1784
|
+
}
|
|
1785
|
+
} else if (T?.includes("Edit") && H) {
|
|
1786
|
+
const E = H.querySelectorAll("td");
|
|
1787
|
+
if (E.length > 0) {
|
|
1788
|
+
const N = E[0].textContent?.trim();
|
|
1789
|
+
N && await V(N);
|
|
1790
|
+
}
|
|
1791
|
+
} else if (T?.includes("Delete") && H) {
|
|
1792
|
+
const E = H.querySelectorAll("td");
|
|
1793
|
+
if (E.length > 0) {
|
|
1794
|
+
const N = E[0].textContent?.trim();
|
|
1795
|
+
N && await Y(N);
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
x(
|
|
1801
|
+
[p, n, i],
|
|
1802
|
+
() => {
|
|
1803
|
+
p.value === "record" && he();
|
|
1804
|
+
},
|
|
1805
|
+
{ immediate: !0 }
|
|
1806
|
+
), x(
|
|
1807
|
+
e,
|
|
1808
|
+
(d) => {
|
|
1809
|
+
},
|
|
1810
|
+
{ immediate: !0 }
|
|
1811
|
+
), x(
|
|
1812
|
+
[p, n, e],
|
|
1813
|
+
([d, v, w]) => {
|
|
1814
|
+
d === "records" && v && w && q(v);
|
|
1815
|
+
},
|
|
1816
|
+
{ immediate: !0 }
|
|
1817
|
+
);
|
|
1818
|
+
const he = () => {
|
|
1819
|
+
if (!(!e.value || !n.value)) {
|
|
1820
|
+
t.value = !0;
|
|
1821
|
+
try {
|
|
1822
|
+
h.value || e.value.getRecordById(n.value, i.value) || console.log(`📝 [Desktop] Record ${i.value} not found in HST for ${n.value}`);
|
|
1823
|
+
} catch (d) {
|
|
1824
|
+
console.warn("Error loading record data:", d);
|
|
1825
|
+
} finally {
|
|
1826
|
+
t.value = !1;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
return ce("desktopMethods", {
|
|
1831
|
+
navigateToDoctype: P,
|
|
1832
|
+
openRecord: V,
|
|
1833
|
+
createNewRecord: j,
|
|
1834
|
+
handleSave: G,
|
|
1835
|
+
handleCancel: pe,
|
|
1836
|
+
handleDelete: Y
|
|
1837
|
+
}), te(() => {
|
|
1838
|
+
de(() => {
|
|
1839
|
+
p.value === "records" && n.value && e.value && q(n.value);
|
|
1840
|
+
});
|
|
1841
|
+
const d = (v) => {
|
|
1842
|
+
(v.ctrlKey || v.metaKey) && v.key === "k" && (v.preventDefault(), a.value = !0), v.key === "Escape" && a.value && (a.value = !1);
|
|
1843
|
+
};
|
|
1844
|
+
return document.addEventListener("keydown", d), () => {
|
|
1845
|
+
document.removeEventListener("keydown", d);
|
|
1846
|
+
};
|
|
1847
|
+
}), (d, v) => (y(), b("div", {
|
|
1848
|
+
class: "desktop",
|
|
1849
|
+
onClick: je
|
|
1850
|
+
}, [
|
|
1851
|
+
I(ke, { elements: f.value }, null, 8, ["elements"]),
|
|
1852
|
+
K.value.length > 0 ? (y(), ae(Q(Vt), {
|
|
1853
|
+
key: 0,
|
|
1854
|
+
modelValue: K.value,
|
|
1855
|
+
"onUpdate:modelValue": v[0] || (v[0] = (w) => K.value = w),
|
|
1856
|
+
data: l.value
|
|
1857
|
+
}, null, 8, ["modelValue", "data"])) : Q(e) ? (y(), b("div", to, [
|
|
1858
|
+
g("p", null, "Loading " + C(p.value) + " data...", 1)
|
|
1859
|
+
])) : (y(), b("div", eo, v[2] || (v[2] = [
|
|
1860
|
+
g("p", null, "Initializing Stonecrop...", -1)
|
|
1861
|
+
]))),
|
|
1862
|
+
I(Te, { breadcrumbs: m.value }, null, 8, ["breadcrumbs"]),
|
|
1863
|
+
I(Se, {
|
|
1864
|
+
"is-open": a.value,
|
|
1865
|
+
search: A,
|
|
1866
|
+
placeholder: "Type a command or search...",
|
|
1867
|
+
onSelect: S,
|
|
1868
|
+
onClose: v[1] || (v[1] = (w) => a.value = !1)
|
|
1869
|
+
}, {
|
|
1870
|
+
title: z(({ result: w }) => [
|
|
1871
|
+
Z(C(w.title), 1)
|
|
1872
|
+
]),
|
|
1873
|
+
content: z(({ result: w }) => [
|
|
1874
|
+
Z(C(w.description), 1)
|
|
1875
|
+
]),
|
|
1876
|
+
_: 1
|
|
1877
|
+
}, 8, ["is-open"]),
|
|
1878
|
+
I(Zt)
|
|
1879
|
+
]));
|
|
1880
|
+
}
|
|
1881
|
+
}), lo = {
|
|
1882
|
+
install: (s) => {
|
|
1883
|
+
s.component("ActionSet", ke), s.component("CommandPalette", Se), s.component("Desktop", oo), s.component("SheetNav", Te);
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
export {
|
|
1887
|
+
ke as A,
|
|
1888
|
+
De as I,
|
|
1889
|
+
so as L,
|
|
1890
|
+
Te as S,
|
|
1891
|
+
Se as _,
|
|
1892
|
+
oo as a,
|
|
1893
|
+
lo as p
|
|
1894
|
+
};
|
|
1895
|
+
//# sourceMappingURL=index-C3nXTrEd.js.map
|