@stonecrop/desktop 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/desktop.js CHANGED
@@ -1,98 +1,98 @@
1
- import { defineComponent as Y, ref as T, onMounted as fe, openBlock as p, createElementBlock as g, normalizeClass as B, createElementVNode as i, Fragment as G, renderList as J, toDisplayString as N, createCommentVNode as K, withDirectives as Q, vShow as ne, useTemplateRef as me, computed as R, watch as z, nextTick as ye, createBlock as he, Teleport as Oe, createVNode as j, Transition as Be, withCtx as U, withModifiers as ge, vModelText as we, renderSlot as ee, createTextVNode as X, resolveComponent as Ke, withKeys as H, normalizeStyle as te, unref as ae, provide as oe, onUnmounted as je } from "vue";
2
- import { useStonecrop as Pe, useValidationStore as He, isDraftRecordId as ze, DRAFT_RECORD_ID as Ue } from "@stonecrop/stonecrop";
3
- import { AForm as We } from "@stonecrop/aform";
4
- import { flattenFields as qe, linkDisplayFieldname as pe, componentLinkExpansion as Ge } from "@stonecrop/schema";
5
- const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header" }, Xe = ["disabled", "onClick"], Ye = { key: 0 }, Ze = { class: "dropdown-header" }, et = ["onClick"], tt = ["onClick"], at = { class: "dropdown-container" }, ot = { class: "dropdown" }, nt = ["onClick"], rt = ["href"], lt = { class: "dropdown-item" }, st = /* @__PURE__ */ Y({
1
+ import { defineComponent as Q, ref as M, onMounted as de, openBlock as m, createElementBlock as g, normalizeClass as F, createElementVNode as c, Fragment as W, renderList as q, toDisplayString as V, createCommentVNode as L, withDirectives as G, vShow as ae, useTemplateRef as ve, computed as S, watch as H, nextTick as pe, createBlock as fe, Teleport as Ee, createVNode as j, Transition as Oe, withCtx as z, withModifiers as me, vModelText as he, renderSlot as Y, createTextVNode as J, resolveComponent as Be, withKeys as K, normalizeStyle as Z, unref as ee, provide as te, onUnmounted as Fe } from "vue";
2
+ import { useStonecrop as Le, useValidationStore as je, isDraftRecordId as Pe, DRAFT_RECORD_ID as Ke } from "@stonecrop/stonecrop";
3
+ import { AForm as He } from "@stonecrop/aform";
4
+ import { flattenFields as ze, componentLinkExpansion as Ue } from "@stonecrop/schema";
5
+ const We = { class: "action-menu-icon" }, qe = { class: "action-element-header" }, Ge = ["disabled", "onClick"], Je = { key: 0 }, Qe = { class: "dropdown-header" }, Xe = ["onClick"], Ye = ["onClick"], Ze = { class: "dropdown-container" }, et = { class: "dropdown" }, tt = ["onClick"], at = ["href"], ot = { class: "dropdown-item" }, rt = /* @__PURE__ */ Q({
6
6
  __name: "ActionSet",
7
7
  props: {
8
8
  elements: { default: () => [] }
9
9
  },
10
10
  emits: ["actionClick"],
11
- setup(s, { emit: $ }) {
12
- const C = $, b = T({}), m = T(!0), D = T([]);
13
- fe(() => {
14
- a();
11
+ setup(l, { emit: $ }) {
12
+ const D = $, w = M({}), d = M(!0), a = M([]);
13
+ de(() => {
14
+ v();
15
15
  });
16
- const a = () => {
17
- b.value = {}, D.value = [];
18
- }, k = () => {
19
- m.value = !m.value;
20
- }, M = (c) => {
21
- const d = !b.value[c];
22
- a(), d && (b.value[c] = !0, D.value[c] = !0);
23
- }, I = (c, d) => {
24
- C("actionClick", d, c);
16
+ const v = () => {
17
+ w.value = {}, a.value = [];
18
+ }, x = () => {
19
+ d.value = !d.value;
20
+ }, N = (i) => {
21
+ const p = !w.value[i];
22
+ v(), p && (w.value[i] = !0, a.value[i] = !0);
23
+ }, C = (i, p) => {
24
+ D("actionClick", p, i);
25
25
  };
26
- return (c, d) => (p(), g("div", {
27
- class: B([{ collapsed: !m.value }, "action-set"])
26
+ return (i, p) => (m(), g("div", {
27
+ class: F([{ collapsed: !d.value }, "action-set"])
28
28
  }, [
29
- i("div", Je, [
30
- i("div", {
29
+ c("div", We, [
30
+ c("div", {
31
31
  id: "cross",
32
- class: B({ rotated: m.value }),
33
- onClick: k
32
+ class: F({ rotated: d.value }),
33
+ onClick: x
34
34
  }, "×", 2)
35
35
  ]),
36
- d[0] || (d[0] = i("div", { style: { "margin-right": "30px" } }, null, -1)),
37
- (p(!0), g(G, null, J(s.elements, (l, _) => (p(), g("div", {
38
- key: l.label,
36
+ p[0] || (p[0] = c("div", { style: { "margin-right": "30px" } }, null, -1)),
37
+ (m(!0), g(W, null, q(l.elements, (s, n) => (m(), g("div", {
38
+ key: s.label,
39
39
  class: "action-element"
40
40
  }, [
41
- i("div", Qe, [
42
- l.type == "button" ? (p(), g("button", {
41
+ c("div", qe, [
42
+ s.type == "button" ? (m(), g("button", {
43
43
  key: 0,
44
- disabled: l.disabled,
44
+ disabled: s.disabled,
45
45
  class: "button-default",
46
- onClick: (o) => I(l.action, l.label)
47
- }, N(l.label), 9, Xe)) : K("", !0)
46
+ onClick: (u) => C(s.action, s.label)
47
+ }, V(s.label), 9, Ge)) : L("", !0)
48
48
  ]),
49
- l.type == "dropdown" ? (p(), g("div", Ye, [
50
- i("div", Ze, [
51
- i("div", {
52
- class: B(["cross", { rotated: D.value[_] }]),
53
- onClick: (o) => M(_)
54
- }, "×", 10, et),
55
- i("button", {
49
+ s.type == "dropdown" ? (m(), g("div", Je, [
50
+ c("div", Qe, [
51
+ c("div", {
52
+ class: F(["cross", { rotated: a.value[n] }]),
53
+ onClick: (u) => N(n)
54
+ }, "×", 10, Xe),
55
+ c("button", {
56
56
  class: "button-default dropdown-title",
57
- onClick: (o) => M(_)
58
- }, N(l.label), 9, tt)
57
+ onClick: (u) => N(n)
58
+ }, V(s.label), 9, Ye)
59
59
  ]),
60
- Q(i("div", at, [
61
- i("div", ot, [
62
- (p(!0), g(G, null, J(l.actions, (o) => (p(), g("div", {
63
- key: o.label
60
+ G(c("div", Ze, [
61
+ c("div", et, [
62
+ (m(!0), g(W, null, q(s.actions, (u) => (m(), g("div", {
63
+ key: u.label
64
64
  }, [
65
- o.action != null ? (p(), g("button", {
65
+ u.action != null ? (m(), g("button", {
66
66
  key: 0,
67
67
  class: "dropdown-item",
68
- onClick: (W) => I(o.action, o.label)
69
- }, N(o.label), 9, nt)) : o.link != null ? (p(), g("a", {
68
+ onClick: (r) => C(u.action, u.label)
69
+ }, V(u.label), 9, tt)) : u.link != null ? (m(), g("a", {
70
70
  key: 1,
71
- href: o.link
71
+ href: u.link
72
72
  }, [
73
- i("button", lt, N(o.label), 1)
74
- ], 8, rt)) : K("", !0)
73
+ c("button", ot, V(u.label), 1)
74
+ ], 8, at)) : L("", !0)
75
75
  ]))), 128))
76
76
  ])
77
77
  ], 512), [
78
- [ne, b.value[_]]
78
+ [ae, w.value[n]]
79
79
  ])
80
- ])) : K("", !0)
80
+ ])) : L("", !0)
81
81
  ]))), 128))
82
82
  ], 2));
83
83
  }
84
- }), be = (s, $) => {
85
- const C = s.__vccOpts || s;
86
- for (const [b, m] of $)
87
- C[b] = m;
88
- return C;
89
- }, ke = /* @__PURE__ */ be(st, [["__scopeId", "data-v-54797d4b"]]), ct = { class: "command-palette-header" }, it = ["placeholder"], ut = {
84
+ }), ye = (l, $) => {
85
+ const D = l.__vccOpts || l;
86
+ for (const [w, d] of $)
87
+ D[w] = d;
88
+ return D;
89
+ }, ge = /* @__PURE__ */ ye(rt, [["__scopeId", "data-v-54797d4b"]]), nt = { class: "command-palette-header" }, lt = ["placeholder"], st = {
90
90
  key: 0,
91
91
  class: "command-palette-results"
92
- }, dt = ["onClick", "onMouseover"], vt = { class: "result-title" }, pt = { class: "result-content" }, ft = {
92
+ }, ct = ["onClick", "onMouseover"], it = { class: "result-title" }, ut = { class: "result-content" }, dt = {
93
93
  key: 1,
94
94
  class: "command-palette-no-results"
95
- }, Ce = /* @__PURE__ */ Y({
95
+ }, we = /* @__PURE__ */ Q({
96
96
  __name: "CommandPalette",
97
97
  props: {
98
98
  search: { type: Function },
@@ -101,133 +101,133 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
101
101
  maxResults: { default: 10 }
102
102
  },
103
103
  emits: ["select", "close"],
104
- setup(s, { emit: $ }) {
105
- const C = $, b = T(""), m = T(0), D = me("input"), a = R(() => b.value ? s.search(b.value).slice(0, s.maxResults) : []);
106
- z(
107
- () => s.isOpen,
108
- async (c) => {
109
- c && (b.value = "", m.value = 0, await ye(), D.value?.focus());
104
+ setup(l, { emit: $ }) {
105
+ const D = $, w = M(""), d = M(0), a = ve("input"), v = S(() => w.value ? l.search(w.value).slice(0, l.maxResults) : []);
106
+ H(
107
+ () => l.isOpen,
108
+ async (i) => {
109
+ i && (w.value = "", d.value = 0, await pe(), a.value?.focus());
110
110
  }
111
- ), z(a, () => {
112
- m.value = 0;
111
+ ), H(v, () => {
112
+ d.value = 0;
113
113
  });
114
- const k = () => {
115
- C("close");
116
- }, M = (c) => {
117
- switch (c.key) {
114
+ const x = () => {
115
+ D("close");
116
+ }, N = (i) => {
117
+ switch (i.key) {
118
118
  case "Escape":
119
- k();
119
+ x();
120
120
  break;
121
121
  case "ArrowDown":
122
- c.preventDefault(), a.value.length && (m.value = (m.value + 1) % a.value.length);
122
+ i.preventDefault(), v.value.length && (d.value = (d.value + 1) % v.value.length);
123
123
  break;
124
124
  case "ArrowUp":
125
- c.preventDefault(), a.value.length && (m.value = (m.value - 1 + a.value.length) % a.value.length);
125
+ i.preventDefault(), v.value.length && (d.value = (d.value - 1 + v.value.length) % v.value.length);
126
126
  break;
127
127
  case "Enter":
128
- a.value.length && m.value >= 0 && I(a.value[m.value]);
128
+ v.value.length && d.value >= 0 && C(v.value[d.value]);
129
129
  break;
130
130
  }
131
- }, I = (c) => {
132
- C("select", c), k();
131
+ }, C = (i) => {
132
+ D("select", i), x();
133
133
  };
134
- return (c, d) => (p(), he(Oe, { to: "body" }, [
135
- j(Be, { name: "fade" }, {
136
- default: U(() => [
137
- s.isOpen ? (p(), g("div", {
134
+ return (i, p) => (m(), fe(Ee, { to: "body" }, [
135
+ j(Oe, { name: "fade" }, {
136
+ default: z(() => [
137
+ l.isOpen ? (m(), g("div", {
138
138
  key: 0,
139
139
  class: "command-palette-overlay",
140
- onClick: k
140
+ onClick: x
141
141
  }, [
142
- i("div", {
142
+ c("div", {
143
143
  class: "command-palette",
144
- onClick: d[1] || (d[1] = ge(() => {
144
+ onClick: p[1] || (p[1] = me(() => {
145
145
  }, ["stop"]))
146
146
  }, [
147
- i("div", ct, [
148
- Q(i("input", {
147
+ c("div", nt, [
148
+ G(c("input", {
149
149
  ref: "input",
150
- "onUpdate:modelValue": d[0] || (d[0] = (l) => b.value = l),
150
+ "onUpdate:modelValue": p[0] || (p[0] = (s) => w.value = s),
151
151
  type: "text",
152
152
  class: "command-palette-input",
153
- placeholder: s.placeholder,
153
+ placeholder: l.placeholder,
154
154
  autofocus: "",
155
- onKeydown: M
156
- }, null, 40, it), [
157
- [we, b.value]
155
+ onKeydown: N
156
+ }, null, 40, lt), [
157
+ [he, w.value]
158
158
  ])
159
159
  ]),
160
- a.value.length ? (p(), g("div", ut, [
161
- (p(!0), g(G, null, J(a.value, (l, _) => (p(), g("div", {
162
- key: _,
163
- class: B(["command-palette-result", { selected: _ === m.value }]),
164
- onClick: (o) => I(l),
165
- onMouseover: (o) => m.value = _
160
+ v.value.length ? (m(), g("div", st, [
161
+ (m(!0), g(W, null, q(v.value, (s, n) => (m(), g("div", {
162
+ key: n,
163
+ class: F(["command-palette-result", { selected: n === d.value }]),
164
+ onClick: (u) => C(s),
165
+ onMouseover: (u) => d.value = n
166
166
  }, [
167
- i("div", vt, [
168
- ee(c.$slots, "title", { result: l })
167
+ c("div", it, [
168
+ Y(i.$slots, "title", { result: s })
169
169
  ]),
170
- i("div", pt, [
171
- ee(c.$slots, "content", { result: l })
170
+ c("div", ut, [
171
+ Y(i.$slots, "content", { result: s })
172
172
  ])
173
- ], 42, dt))), 128))
174
- ])) : b.value && !a.value.length ? (p(), g("div", ft, [
175
- ee(c.$slots, "empty", {}, () => [
176
- X(' No results found for "' + N(b.value) + '" ', 1)
173
+ ], 42, ct))), 128))
174
+ ])) : w.value && !v.value.length ? (m(), g("div", dt, [
175
+ Y(i.$slots, "empty", {}, () => [
176
+ J(' No results found for "' + V(w.value) + '" ', 1)
177
177
  ])
178
- ])) : K("", !0)
178
+ ])) : L("", !0)
179
179
  ])
180
- ])) : K("", !0)
180
+ ])) : L("", !0)
181
181
  ]),
182
182
  _: 3
183
183
  })
184
184
  ]));
185
185
  }
186
- }), mt = { class: "tabs" }, yt = { tabindex: "0" }, ht = { tabindex: "0" }, gt = /* @__PURE__ */ Y({
186
+ }), vt = { class: "tabs" }, pt = { tabindex: "0" }, ft = { tabindex: "0" }, mt = /* @__PURE__ */ Q({
187
187
  __name: "SheetNav",
188
188
  props: {
189
189
  breadcrumbs: { default: () => [] }
190
190
  },
191
- setup(s) {
192
- const $ = T(!0), C = T(!1), b = T(""), m = me("searchinput"), D = R(() => $.value ? "unrotated" : "rotated"), a = () => {
191
+ setup(l) {
192
+ const $ = M(!0), D = M(!1), w = M(""), d = ve("searchinput"), a = S(() => $.value ? "unrotated" : "rotated"), v = () => {
193
193
  $.value = !$.value;
194
- }, k = async () => {
195
- C.value = !C.value, await ye(() => {
196
- m.value?.focus();
194
+ }, x = async () => {
195
+ D.value = !D.value, await pe(() => {
196
+ d.value?.focus();
197
197
  });
198
- }, M = (d) => {
199
- d.preventDefault(), d.stopPropagation();
200
- }, I = async (d) => {
201
- d.preventDefault(), d.stopPropagation(), await k();
202
- }, c = () => {
198
+ }, N = (p) => {
199
+ p.preventDefault(), p.stopPropagation();
200
+ }, C = async (p) => {
201
+ p.preventDefault(), p.stopPropagation(), await x();
202
+ }, i = () => {
203
203
  };
204
- return (d, l) => {
205
- const _ = Ke("router-link");
206
- return p(), g("footer", null, [
207
- i("ul", mt, [
208
- i("li", {
204
+ return (p, s) => {
205
+ const n = Be("router-link");
206
+ return m(), g("footer", null, [
207
+ c("ul", vt, [
208
+ c("li", {
209
209
  class: "hidebreadcrumbs",
210
- onClick: a,
211
- onKeydown: H(a, ["enter"])
210
+ onClick: v,
211
+ onKeydown: K(v, ["enter"])
212
212
  }, [
213
- i("a", yt, [
214
- i("div", {
215
- class: B(D.value)
213
+ c("a", pt, [
214
+ c("div", {
215
+ class: F(a.value)
216
216
  }, "×", 2)
217
217
  ])
218
218
  ], 32),
219
- i("li", {
219
+ c("li", {
220
220
  class: "hometab",
221
- style: te({ display: $.value ? "block" : "none" }),
222
- onClick: c,
223
- onKeydown: H(c, ["enter"])
221
+ style: Z({ display: $.value ? "block" : "none" }),
222
+ onClick: i,
223
+ onKeydown: K(i, ["enter"])
224
224
  }, [
225
- j(_, {
225
+ j(n, {
226
226
  to: "/",
227
227
  tabindex: "0"
228
228
  }, {
229
- default: U(() => [...l[5] || (l[5] = [
230
- i("svg", {
229
+ default: z(() => [...s[5] || (s[5] = [
230
+ c("svg", {
231
231
  class: "icon",
232
232
  "aria-label": "Home",
233
233
  viewBox: "0 0 24 24",
@@ -235,19 +235,19 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
235
235
  stroke: "currentColor",
236
236
  "stroke-width": "2"
237
237
  }, [
238
- i("path", { d: "M3 12l9-9 9 9" }),
239
- i("path", { d: "M9 21V12h6v9" })
238
+ c("path", { d: "M3 12l9-9 9 9" }),
239
+ c("path", { d: "M9 21V12h6v9" })
240
240
  ], -1)
241
241
  ])]),
242
242
  _: 1
243
243
  })
244
244
  ], 36),
245
- i("li", {
246
- class: B(["searchtab", { "search-active": C.value }]),
247
- style: te({ display: $.value ? "block" : "none" })
245
+ c("li", {
246
+ class: F(["searchtab", { "search-active": D.value }]),
247
+ style: Z({ display: $.value ? "block" : "none" })
248
248
  }, [
249
- i("a", ht, [
250
- Q((p(), g("svg", {
249
+ c("a", ft, [
250
+ G((m(), g("svg", {
251
251
  class: "icon search-icon",
252
252
  role: "button",
253
253
  "aria-label": "Search",
@@ -255,47 +255,47 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
255
255
  fill: "none",
256
256
  stroke: "currentColor",
257
257
  "stroke-width": "2",
258
- onClick: k,
259
- onKeydown: H(k, ["enter"])
260
- }, [...l[6] || (l[6] = [
261
- i("circle", {
258
+ onClick: x,
259
+ onKeydown: K(x, ["enter"])
260
+ }, [...s[6] || (s[6] = [
261
+ c("circle", {
262
262
  cx: "11",
263
263
  cy: "11",
264
264
  r: "7"
265
265
  }, null, -1),
266
- i("path", { d: "M21 21l-4.35-4.35" }, null, -1)
266
+ c("path", { d: "M21 21l-4.35-4.35" }, null, -1)
267
267
  ])], 544)), [
268
- [ne, !C.value]
268
+ [ae, !D.value]
269
269
  ]),
270
- Q(i("input", {
270
+ G(c("input", {
271
271
  ref: "searchinput",
272
- "onUpdate:modelValue": l[0] || (l[0] = (o) => b.value = o),
272
+ "onUpdate:modelValue": s[0] || (s[0] = (u) => w.value = u),
273
273
  type: "text",
274
274
  placeholder: "Search...",
275
- onClick: l[1] || (l[1] = ge(() => {
275
+ onClick: s[1] || (s[1] = me(() => {
276
276
  }, ["stop"])),
277
- onInput: l[2] || (l[2] = (o) => M(o)),
278
- onBlur: l[3] || (l[3] = (o) => I(o)),
277
+ onInput: s[2] || (s[2] = (u) => N(u)),
278
+ onBlur: s[3] || (s[3] = (u) => C(u)),
279
279
  onKeydown: [
280
- l[4] || (l[4] = H((o) => I(o), ["enter"])),
281
- H(k, ["escape"])
280
+ s[4] || (s[4] = K((u) => C(u), ["enter"])),
281
+ K(x, ["escape"])
282
282
  ]
283
283
  }, null, 544), [
284
- [ne, C.value],
285
- [we, b.value]
284
+ [ae, D.value],
285
+ [he, w.value]
286
286
  ])
287
287
  ])
288
288
  ], 6),
289
- (p(!0), g(G, null, J(s.breadcrumbs, (o) => (p(), g("li", {
290
- key: o.title,
291
- style: te({ display: $.value ? "block" : "none" })
289
+ (m(!0), g(W, null, q(l.breadcrumbs, (u) => (m(), g("li", {
290
+ key: u.title,
291
+ style: Z({ display: $.value ? "block" : "none" })
292
292
  }, [
293
- j(_, {
293
+ j(n, {
294
294
  tabindex: "0",
295
- to: o.to
295
+ to: u.to
296
296
  }, {
297
- default: U(() => [
298
- X(N(o.title), 1)
297
+ default: z(() => [
298
+ J(V(u.title), 1)
299
299
  ]),
300
300
  _: 2
301
301
  }, 1032, ["to"])
@@ -304,68 +304,57 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
304
304
  ]);
305
305
  };
306
306
  }
307
- }), Ae = /* @__PURE__ */ be(gt, [["__scopeId", "data-v-0072260b"]]), wt = {
307
+ }), be = /* @__PURE__ */ ye(mt, [["__scopeId", "data-v-0072260b"]]), ht = {
308
308
  key: 1,
309
309
  class: "loading"
310
- }, bt = {
310
+ }, yt = {
311
311
  key: 2,
312
312
  class: "loading"
313
- }, kt = {
313
+ }, gt = {
314
314
  key: 3,
315
315
  class: "truncation-note"
316
- }, Ct = /* @__PURE__ */ Y({
316
+ }, wt = /* @__PURE__ */ Q({
317
317
  __name: "Desktop",
318
318
  props: {
319
319
  availableDoctypes: { default: () => [] },
320
320
  routeAdapter: {}
321
321
  },
322
322
  emits: ["action", "navigate", "record:open", "load-records", "load-record"],
323
- setup(s, { emit: $ }) {
324
- function C(e) {
325
- const t = qe(e).filter((n) => n.kind === "field" && !!n.doctype);
326
- return {
327
- inlineLinks: new Set(
328
- t.filter((n) => Ge(n.component) === "inline").map((n) => n.fieldname)
329
- ),
330
- displayKeys: new Set(t.map((n) => pe(n.fieldname)))
331
- };
332
- }
333
- function b(e, t) {
334
- const { inlineLinks: n, displayKeys: v } = C(t);
335
- for (const u of n) {
336
- const f = e[u], A = e[pe(u)];
337
- f != null && (typeof f == "string" || typeof f == "number") && A != null && (typeof A == "string" || typeof A == "number") && (e[u] = { id: f, displayText: String(A) });
338
- }
339
- for (const u of v) delete e[u];
323
+ setup(l, { emit: $ }) {
324
+ function D(e) {
325
+ const t = ze(e).filter((o) => o.kind === "field" && !!o.doctype);
326
+ return new Set(
327
+ t.filter((o) => Ue(o.component) === "inline").map((o) => o.fieldname)
328
+ );
340
329
  }
341
- function m(e) {
330
+ function w(e) {
342
331
  return e !== null && typeof e == "object" && !Array.isArray(e) && "id" in e ? e.id : e;
343
332
  }
344
- const D = $, { stonecrop: a } = Pe();
345
- let k = null;
333
+ const d = $, { stonecrop: a } = Le();
334
+ let v = null;
346
335
  try {
347
- k = He();
336
+ v = je();
348
337
  } catch {
349
- k = null;
338
+ v = null;
350
339
  }
351
- const M = R(
352
- () => x.value === "record" ? k?.errorsByField ?? {} : {}
353
- ), I = T(!1), c = T(!1), d = T({}), l = R({
340
+ const x = S(
341
+ () => I.value === "record" ? v?.errorsByField ?? {} : {}
342
+ ), N = M(!1), C = M(!1), i = M({}), p = S({
354
343
  get() {
355
- if (x.value === "doctypes")
344
+ if (I.value === "doctypes")
356
345
  return {
357
- doctypes_table: s.availableDoctypes?.map((e) => ({
346
+ doctypes_table: l.availableDoctypes?.map((e) => ({
358
347
  id: e,
359
348
  doctype: e,
360
- display_name: O(e),
349
+ display_name: B(e),
361
350
  actions: "View Records"
362
351
  })) ?? []
363
352
  };
364
- if (x.value === "records")
353
+ if (I.value === "records")
365
354
  return {
366
- records_table: ie().map(
355
+ records_table: se().map(
367
356
  (e) => Object.assign({}, e, {
368
- id: de(e) ?? "",
357
+ id: ie(e) ?? "",
369
358
  // A list row is navigation. Actions live on the record view, where the Actions
370
359
  // dropdown is built from what the doctype declares and what the record's
371
360
  // current state allows. This cell used to also offer Delete, which dispatched
@@ -376,18 +365,17 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
376
365
  })
377
366
  )
378
367
  };
379
- if (!a.value || !r.value || !y.value)
368
+ if (!a.value || !r.value || !h.value)
380
369
  return {};
381
370
  try {
382
- const t = { ...L.value ? d.value : a.value.getRecordById(r.value, y.value)?.get("") }, n = a.value.registry.registry[r.value];
383
- if (n) {
384
- b(t, n.getSchemaArray());
385
- for (const v of n.getSchemaArray())
386
- if (v.kind === "fieldset") {
387
- const u = {};
388
- for (const f of v.schema)
389
- f.fieldname && (u[f.fieldname] = t[f.fieldname]);
390
- t[v.fieldname] = u;
371
+ const t = { ...O.value ? i.value : a.value.getRecordById(r.value, h.value)?.get("") }, o = a.value.registry.registry[r.value];
372
+ if (o) {
373
+ for (const y of o.getSchemaArray())
374
+ if (y.kind === "fieldset") {
375
+ const f = {};
376
+ for (const A of y.schema)
377
+ A.fieldname && (f[A.fieldname] = t[A.fieldname]);
378
+ t[y.fieldname] = f;
391
379
  }
392
380
  }
393
381
  return t;
@@ -396,146 +384,146 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
396
384
  }
397
385
  },
398
386
  set(e) {
399
- if (x.value === "record" && !(!a.value || !r.value || !y.value))
387
+ if (I.value === "record" && !(!a.value || !r.value || !h.value))
400
388
  try {
401
- const t = a.value.registry.registry[r.value], n = /* @__PURE__ */ new Set();
389
+ const t = a.value.registry.registry[r.value], o = /* @__PURE__ */ new Set();
402
390
  if (t)
403
- for (const h of t.getSchemaArray())
404
- h.kind === "fieldset" && n.add(h.fieldname);
405
- const { inlineLinks: v, displayKeys: u } = C(t ? t.getSchemaArray() : []), f = {}, A = [];
406
- for (const [h, w] of Object.entries(e))
407
- u.has(h) || (n.has(h) && w && typeof w == "object" && !Array.isArray(w) ? A.push(w) : f[h] = w);
408
- for (const h of A)
409
- Object.assign(f, h);
410
- const E = [];
411
- if (L.value) {
412
- const h = { ...d.value };
413
- for (const [w, F] of Object.entries(f)) {
414
- if (F === void 0 || u.has(w)) continue;
415
- const P = v.has(w) ? m(F) : F;
416
- h[w] !== P && (h[w] = P, E.push(w));
391
+ for (const k of t.getSchemaArray())
392
+ k.kind === "fieldset" && o.add(k.fieldname);
393
+ const y = D(t ? t.getSchemaArray() : []), f = {}, A = [];
394
+ for (const [k, b] of Object.entries(e))
395
+ o.has(k) && b && typeof b == "object" && !Array.isArray(b) ? A.push(b) : f[k] = b;
396
+ for (const k of A)
397
+ Object.assign(f, k);
398
+ const _ = [];
399
+ if (O.value) {
400
+ const k = { ...i.value };
401
+ for (const [b, T] of Object.entries(f)) {
402
+ if (T === void 0) continue;
403
+ const P = y.has(b) ? w(T) : T;
404
+ k[b] !== P && (k[b] = P, _.push(b));
417
405
  }
418
- d.value = h;
406
+ i.value = k;
419
407
  } else {
420
- const h = a.value.getStore();
421
- for (const [w, F] of Object.entries(f)) {
422
- if (F === void 0 || u.has(w)) continue;
423
- const P = v.has(w) ? m(F) : F, Z = `${r.value}.${y.value}.${w}`;
424
- (h.has(Z) ? h.get(Z) : void 0) !== P && (h.set(Z, P), E.push(w));
408
+ const k = a.value.getStore();
409
+ for (const [b, T] of Object.entries(f)) {
410
+ if (T === void 0) continue;
411
+ const P = y.has(b) ? w(T) : T, X = `${r.value}.${h.value}.${b}`;
412
+ (k.has(X) ? k.get(X) : void 0) !== P && (k.set(X, P), _.push(b));
425
413
  }
426
414
  }
427
- E.length > 0 && _(E);
415
+ _.length > 0 && s(_);
428
416
  } catch (t) {
429
417
  console.warn("HST update failed:", t);
430
418
  }
431
419
  }
432
420
  });
433
- function _(e) {
434
- if (!k || !a.value || !r.value || !y.value) return;
435
- const n = a.value.registry.getDoctype(r.value)?.getTriggers();
436
- if (!n || Object.keys(n).length === 0) return;
437
- const v = L.value ? { ...d.value } : {
438
- ...a.value.getRecordById(r.value, y.value)?.get("")
421
+ function s(e) {
422
+ if (!v || !a.value || !r.value || !h.value) return;
423
+ const o = a.value.registry.getDoctype(r.value)?.getTriggers();
424
+ if (!o || Object.keys(o).length === 0) return;
425
+ const y = O.value ? { ...i.value } : {
426
+ ...a.value.getRecordById(r.value, h.value)?.get("")
439
427
  };
440
- for (const u of e)
441
- k.validateField(n, u, v);
428
+ for (const f of e)
429
+ v.validateField(o, f, y);
442
430
  }
443
- const o = R(() => s.routeAdapter ? null : ae(a.value?.registry.router?.currentRoute)), W = R(() => s.routeAdapter ? null : a.value?.registry.router), r = R(() => {
444
- if (s.routeAdapter) return s.routeAdapter.getCurrentDoctype();
445
- if (!o.value) return "";
446
- if (o.value.meta?.actualDoctype)
447
- return o.value.meta.actualDoctype;
448
- if (o.value.params.doctype)
449
- return o.value.params.doctype.toString();
450
- const e = o.value.params.pathMatch;
431
+ const n = S(() => l.routeAdapter ? null : ee(a.value?.registry.router?.currentRoute)), u = S(() => l.routeAdapter ? null : a.value?.registry.router), r = S(() => {
432
+ if (l.routeAdapter) return l.routeAdapter.getCurrentDoctype();
433
+ if (!n.value) return "";
434
+ if (n.value.meta?.actualDoctype)
435
+ return n.value.meta.actualDoctype;
436
+ if (n.value.params.doctype)
437
+ return n.value.params.doctype.toString();
438
+ const e = n.value.params.pathMatch;
451
439
  return e && e.length > 0 ? e[0] : "";
452
- }), S = R(() => {
453
- if (s.routeAdapter) return s.routeAdapter.getCurrentDoctype();
454
- if (!o.value) return "";
455
- if (o.value.meta?.doctype)
456
- return o.value.meta.doctype;
457
- if (o.value.params.doctype)
458
- return o.value.params.doctype.toString();
459
- const e = o.value.params.pathMatch;
440
+ }), R = S(() => {
441
+ if (l.routeAdapter) return l.routeAdapter.getCurrentDoctype();
442
+ if (!n.value) return "";
443
+ if (n.value.meta?.doctype)
444
+ return n.value.meta.doctype;
445
+ if (n.value.params.doctype)
446
+ return n.value.params.doctype.toString();
447
+ const e = n.value.params.pathMatch;
460
448
  return e && e.length > 0 ? e[0] : "";
461
- }), y = R(() => {
462
- if (s.routeAdapter) return s.routeAdapter.getCurrentRecordId();
463
- if (!o.value) return "";
464
- if (o.value.params.recordId)
465
- return o.value.params.recordId.toString();
466
- const e = o.value.params.pathMatch;
449
+ }), h = S(() => {
450
+ if (l.routeAdapter) return l.routeAdapter.getCurrentRecordId();
451
+ if (!n.value) return "";
452
+ if (n.value.params.recordId)
453
+ return n.value.params.recordId.toString();
454
+ const e = n.value.params.pathMatch;
467
455
  return e && e.length > 1 ? e[1] : "";
468
- }), L = R(() => ze(y.value)), x = R(() => {
469
- if (s.routeAdapter) return s.routeAdapter.getCurrentView();
470
- if (!o.value || o.value.name === "home" || o.value.path === "/")
456
+ }), O = S(() => Pe(h.value)), I = S(() => {
457
+ if (l.routeAdapter) return l.routeAdapter.getCurrentView();
458
+ if (!n.value || n.value.name === "home" || n.value.path === "/")
471
459
  return "doctypes";
472
- if (o.value.name && o.value.name !== "catch-all") {
473
- const t = o.value.name;
474
- if (t.includes("form") || o.value.params.recordId)
460
+ if (n.value.name && n.value.name !== "catch-all") {
461
+ const t = n.value.name;
462
+ if (t.includes("form") || n.value.params.recordId)
475
463
  return "record";
476
- if (t.includes("list") || o.value.params.doctype)
464
+ if (t.includes("list") || n.value.params.doctype)
477
465
  return "records";
478
466
  }
479
- const e = o.value.params.pathMatch;
467
+ const e = n.value.params.pathMatch;
480
468
  return e && e.length > 0 ? e.length === 1 ? "records" : "record" : "doctypes";
481
- }), De = () => {
482
- if (!a.value || !r.value || !y.value)
469
+ }), ke = () => {
470
+ if (!a.value || !r.value || !h.value)
483
471
  return [];
484
472
  try {
485
473
  const e = a.value.registry.getDoctype(r.value);
486
474
  if (!e?.workflow) return [];
487
- const t = a.value.getRecordState(r.value, y.value), n = e.getAvailableTransitions(t), v = l.value || {};
488
- return n.map(({ name: u }) => ({
475
+ const t = a.value.getRecordState(r.value, h.value), o = e.getAvailableTransitions(t), y = p.value || {};
476
+ return o.map(({ name: f }) => ({
489
477
  // Prefer the workflow action's human-readable label (WorkflowMeta format);
490
478
  // fall back to the raw transition name for XState workflows with no action meta.
491
- label: e.getActionMeta(u)?.label ?? u,
479
+ label: e.getActionMeta(f)?.label ?? f,
492
480
  action: () => {
493
- D("action", {
494
- name: u,
481
+ d("action", {
482
+ name: f,
495
483
  doctype: r.value,
496
- recordId: y.value,
497
- data: v
484
+ recordId: h.value,
485
+ data: y
498
486
  });
499
487
  }
500
488
  }));
501
489
  } catch (e) {
502
490
  return console.warn("Error getting available transitions:", e), [];
503
491
  }
504
- }, Se = () => {
505
- if (!a.value || !r.value || !y.value)
492
+ }, Ce = () => {
493
+ if (!a.value || !r.value || !h.value)
506
494
  return [];
507
495
  try {
508
496
  const e = a.value.registry.getDoctype(r.value);
509
497
  if (!e?.workflow) return [];
510
- const t = a.value.getRecordState(r.value, y.value), n = e.getAvailableCommands(t), v = l.value || {};
511
- return n.map(({ name: u }) => ({
512
- label: e.getActionMeta(u)?.label ?? u,
498
+ const t = a.value.getRecordState(r.value, h.value), o = e.getAvailableCommands(t), y = p.value || {};
499
+ return o.map(({ name: f }) => ({
500
+ label: e.getActionMeta(f)?.label ?? f,
513
501
  action: () => {
514
- D("action", {
515
- name: u,
502
+ d("action", {
503
+ name: f,
516
504
  doctype: r.value,
517
- recordId: y.value,
518
- data: v
505
+ recordId: h.value,
506
+ data: y
519
507
  });
520
508
  }
521
509
  }));
522
510
  } catch (e) {
523
511
  return console.warn("Error getting available commands:", e), [];
524
512
  }
525
- }, Re = R(() => {
513
+ }, Ae = S(() => {
526
514
  const e = [];
527
- switch (x.value) {
515
+ switch (I.value) {
528
516
  case "records":
529
517
  e.push({
530
518
  type: "button",
531
519
  label: "New Record",
532
520
  action: () => {
533
- q();
521
+ U();
534
522
  }
535
523
  });
536
524
  break;
537
525
  case "record": {
538
- const t = [...De(), ...Se()];
526
+ const t = [...ke(), ...Ce()];
539
527
  t.length > 0 && e.push({
540
528
  type: "dropdown",
541
529
  label: "Actions",
@@ -545,77 +533,77 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
545
533
  }
546
534
  }
547
535
  return e;
548
- }), $e = R(() => {
536
+ }), De = S(() => {
549
537
  const e = [];
550
- if (x.value === "records" && S.value)
538
+ if (I.value === "records" && R.value)
551
539
  e.push(
552
540
  { title: "Home", to: "/" },
553
- { title: O(S.value), to: `/${S.value}` }
541
+ { title: B(R.value), to: `/${R.value}` }
554
542
  );
555
- else if (x.value === "record" && S.value) {
556
- const t = y.value ? `/${S.value}/${y.value}` : o.value?.fullPath ?? "";
543
+ else if (I.value === "record" && R.value) {
544
+ const t = h.value ? `/${R.value}/${h.value}` : n.value?.fullPath ?? "";
557
545
  e.push(
558
546
  { title: "Home", to: "/" },
559
- { title: O(S.value), to: `/${S.value}` },
560
- { title: L.value ? "New Record" : "Edit Record", to: t }
547
+ { title: B(R.value), to: `/${R.value}` },
548
+ { title: O.value ? "New Record" : "Edit Record", to: t }
561
549
  );
562
550
  }
563
551
  return e;
564
- }), Ie = (e) => {
552
+ }), Re = (e) => {
565
553
  const t = [
566
554
  {
567
555
  title: "Go Home",
568
556
  description: "Navigate to the home page",
569
557
  action: () => {
570
- V({ view: "doctypes" });
558
+ E({ view: "doctypes" });
571
559
  }
572
560
  },
573
561
  {
574
562
  title: "Toggle Command Palette",
575
563
  description: "Open/close the command palette",
576
- action: () => c.value = !c.value
564
+ action: () => C.value = !C.value
577
565
  }
578
566
  ];
579
- return S.value && (t.push({
580
- title: `View ${O(S.value)} Records`,
581
- description: `Navigate to ${S.value} list`,
567
+ return R.value && (t.push({
568
+ title: `View ${B(R.value)} Records`,
569
+ description: `Navigate to ${R.value} list`,
582
570
  action: () => {
583
- V({ view: "records", doctype: S.value });
571
+ E({ view: "records", doctype: R.value });
584
572
  }
585
573
  }), t.push({
586
- title: `Create New ${O(S.value)}`,
587
- description: `Create a new ${S.value} record`,
574
+ title: `Create New ${B(R.value)}`,
575
+ description: `Create a new ${R.value} record`,
588
576
  action: () => {
589
- q();
577
+ U();
590
578
  }
591
- })), s.availableDoctypes.forEach((n) => {
579
+ })), l.availableDoctypes.forEach((o) => {
592
580
  t.push({
593
- title: `View ${O(n)}`,
594
- description: `Navigate to ${n} list`,
581
+ title: `View ${B(o)}`,
582
+ description: `Navigate to ${o} list`,
595
583
  action: () => {
596
- V({ view: "records", doctype: n });
584
+ E({ view: "records", doctype: o });
597
585
  }
598
586
  });
599
587
  }), e ? t.filter(
600
- (n) => n.title.toLowerCase().includes(e.toLowerCase()) || n.description.toLowerCase().includes(e.toLowerCase())
588
+ (o) => o.title.toLowerCase().includes(e.toLowerCase()) || o.description.toLowerCase().includes(e.toLowerCase())
601
589
  ) : t;
602
- }, _e = (e) => {
603
- e.action(), c.value = !1;
604
- }, O = (e) => e.split("-").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" "), xe = R(() => x.value !== "records" || !r.value ? !1 : a.value?.getPageInfo(r.value)?.hasMore === !0), V = async (e) => {
605
- D("navigate", e), s.routeAdapter ? await s.routeAdapter.navigate(e) : e.view === "doctypes" ? await W.value?.push("/") : e.view === "records" && e.doctype ? await W.value?.push(`/${e.doctype}`) : e.view === "record" && e.doctype && e.recordId && await W.value?.push(`/${e.doctype}/${e.recordId}`);
590
+ }, Se = (e) => {
591
+ e.action(), C.value = !1;
592
+ }, B = (e) => e.split("-").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" "), $e = S(() => I.value !== "records" || !r.value ? !1 : a.value?.getPageInfo(r.value)?.hasMore === !0), E = async (e) => {
593
+ d("navigate", e), l.routeAdapter ? await l.routeAdapter.navigate(e) : e.view === "doctypes" ? await u.value?.push("/") : e.view === "records" && e.doctype ? await u.value?.push(`/${e.doctype}`) : e.view === "record" && e.doctype && e.recordId && await u.value?.push(`/${e.doctype}/${e.recordId}`);
594
+ }, oe = async (e) => {
595
+ await E({ view: "records", doctype: e });
606
596
  }, re = async (e) => {
607
- await V({ view: "records", doctype: e });
608
- }, le = async (e) => {
609
- const t = S.value;
610
- D("record:open", { doctype: t, recordId: e }), await V({ view: "record", doctype: t, recordId: e });
611
- }, q = async () => {
612
- await V({ view: "record", doctype: S.value, recordId: Ue });
613
- }, se = (e) => {
597
+ const t = R.value;
598
+ d("record:open", { doctype: t, recordId: e }), await E({ view: "record", doctype: t, recordId: e });
599
+ }, U = async () => {
600
+ await E({ view: "record", doctype: R.value, recordId: Ke });
601
+ }, ne = (e) => {
614
602
  const t = [];
615
- for (const n of e)
616
- n.kind === "fieldset" ? t.push(...se(n.schema)) : t.push(n);
603
+ for (const o of e)
604
+ o.kind === "fieldset" ? t.push(...ne(o.schema)) : t.push(o);
617
605
  return t;
618
- }, Te = () => s.availableDoctypes?.length ? [
606
+ }, Ie = () => l.availableDoctypes?.length ? [
619
607
  {
620
608
  kind: "table",
621
609
  fieldname: "doctypes_table",
@@ -653,25 +641,25 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
653
641
  ],
654
642
  config: { view: "list", fullWidth: !0 }
655
643
  }
656
- ] : [], Ne = () => {
644
+ ] : [], _e = () => {
657
645
  if (!r.value) return [];
658
646
  if (!a.value) return [];
659
647
  const e = a.value.registry, t = e.registry[r.value];
660
648
  if (!t) return [];
661
- const n = e.resolveSchema(t);
662
- return n.length === 0 ? [] : [
649
+ const o = e.resolveSchema(t);
650
+ return o.length === 0 ? [] : [
663
651
  {
664
652
  kind: "table",
665
653
  fieldname: "records_table",
666
654
  component: "ATable",
667
655
  schema: [
668
- ...se(n),
656
+ ...ne(o),
669
657
  { fieldname: "actions", label: "Actions", component: "ATextInput" }
670
658
  ],
671
659
  config: { view: "list", fullWidth: !0 }
672
660
  }
673
661
  ];
674
- }, ce = () => {
662
+ }, le = () => {
675
663
  if (!r.value) return [];
676
664
  if (!a.value) return [];
677
665
  try {
@@ -680,195 +668,195 @@ const Je = { class: "action-menu-icon" }, Qe = { class: "action-element-header"
680
668
  } catch {
681
669
  return [];
682
670
  }
683
- }, ie = () => {
671
+ }, se = () => {
684
672
  if (!a.value || !r.value)
685
673
  return [];
686
674
  const t = a.value.records(r.value)?.get("");
687
675
  return t && typeof t == "object" && !Array.isArray(t) ? Object.values(t) : [];
688
- }, ue = R(() => {
689
- switch (x.value) {
676
+ }, ce = S(() => {
677
+ switch (I.value) {
690
678
  case "doctypes":
691
- return Te();
679
+ return Ie();
692
680
  case "records":
693
- return Ne();
681
+ return _e();
694
682
  case "record":
695
- return ce();
683
+ return le();
696
684
  default:
697
685
  return [];
698
686
  }
699
- }), Me = (e, t) => {
687
+ }), xe = (e, t) => {
700
688
  t && t();
701
- }, de = (e) => {
689
+ }, ie = (e) => {
702
690
  if (!(!a.value || !r.value))
703
691
  return a.value.registry.registry[r.value]?.getRecordId(e);
704
- }, Ve = (e) => {
692
+ }, Ne = (e) => {
705
693
  const t = e.querySelector("td[data-rowindex]");
706
694
  if (!t) return null;
707
- const n = t.getAttribute("data-rowindex");
708
- if (n === null) return null;
709
- const v = parseInt(n, 10);
710
- if (isNaN(v)) return null;
711
- const f = ie()[v];
712
- return f ? de(f) ?? null : null;
713
- }, Ee = async (e) => {
695
+ const o = t.getAttribute("data-rowindex");
696
+ if (o === null) return null;
697
+ const y = parseInt(o, 10);
698
+ if (isNaN(y)) return null;
699
+ const A = se()[y];
700
+ return A ? ie(A) ?? null : null;
701
+ }, Te = async (e) => {
714
702
  const t = e.target;
715
- t.getAttribute("data-action") === "create" && await q();
716
- const v = t.closest("td, th");
717
- if (v) {
718
- const u = v.textContent?.trim(), f = v.closest("tr");
719
- if (u === "View Records" && f) {
720
- const A = f.querySelectorAll("td");
721
- if (A.length > 0) {
722
- const h = A[1].textContent?.trim();
723
- h && await re(h);
703
+ t.getAttribute("data-action") === "create" && await U();
704
+ const y = t.closest("td, th");
705
+ if (y) {
706
+ const f = y.textContent?.trim(), A = y.closest("tr");
707
+ if (f === "View Records" && A) {
708
+ const _ = A.querySelectorAll("td");
709
+ if (_.length > 0) {
710
+ const b = _[1].textContent?.trim();
711
+ b && await oe(b);
724
712
  }
725
- } else if (u === "Edit" && f) {
726
- const A = Ve(f);
727
- A && await le(A);
713
+ } else if (f === "Edit" && A) {
714
+ const _ = Ne(A);
715
+ _ && await re(_);
728
716
  }
729
717
  }
730
- }, Fe = async () => {
718
+ }, Me = async () => {
731
719
  if (!(!a.value || !r.value || !a.value.getClient())) {
732
- I.value = !0;
720
+ N.value = !0;
733
721
  try {
734
- await a.value.getRecord(r.value, y.value);
722
+ await a.value.getRecord(r.value, h.value);
735
723
  } catch (e) {
736
724
  console.warn("Error fetching record:", e);
737
725
  } finally {
738
- I.value = !1;
726
+ N.value = !1;
739
727
  }
740
728
  }
741
- }, Le = async () => {
729
+ }, Ve = async () => {
742
730
  if (!a.value || !r.value || !a.value.getClient()) return;
743
731
  const e = a.value.registry.getDoctype(r.value);
744
732
  if (e) {
745
- I.value = !0;
733
+ N.value = !0;
746
734
  try {
747
735
  await a.value.getRecords(e);
748
736
  } catch (t) {
749
737
  console.warn("Error fetching records:", t);
750
738
  } finally {
751
- I.value = !1;
739
+ N.value = !1;
752
740
  }
753
741
  }
754
742
  };
755
- z(
756
- [x, r, y],
743
+ H(
744
+ [I, r, h],
757
745
  () => {
758
- if (x.value === "records" && r.value)
759
- D("load-records", { doctype: r.value }), Le();
760
- else if (x.value === "record" && r.value && y.value) {
761
- if (L.value) return;
762
- D("load-record", { doctype: r.value, recordId: y.value }), Fe();
746
+ if (I.value === "records" && r.value)
747
+ d("load-records", { doctype: r.value }), Ve();
748
+ else if (I.value === "record" && r.value && h.value) {
749
+ if (O.value) return;
750
+ d("load-record", { doctype: r.value, recordId: h.value }), Me();
763
751
  }
764
752
  },
765
753
  { immediate: !0 }
766
- ), z([r, y], () => {
767
- k?.clearAll();
768
- }), z(
769
- [r, y],
754
+ ), H([r, h], () => {
755
+ v?.clearAll();
756
+ }), H(
757
+ [r, h],
770
758
  () => {
771
- if (!L.value) {
772
- d.value = {};
759
+ if (!O.value) {
760
+ i.value = {};
773
761
  return;
774
762
  }
775
763
  const e = a.value?.registry;
776
- d.value = e ? e.initializeRecord(ce()) : {};
764
+ i.value = e ? e.initializeRecord(le()) : {};
777
765
  },
778
766
  { immediate: !0 }
779
- ), oe("desktopMethods", {
780
- navigateToDoctype: re,
781
- openRecord: le,
782
- createNewRecord: q,
767
+ ), te("desktopMethods", {
768
+ navigateToDoctype: oe,
769
+ openRecord: re,
770
+ createNewRecord: U,
783
771
  /**
784
772
  * Convenience wrapper so child components (e.g. slot content) can emit
785
773
  * an action event without needing a direct reference to the emit function.
786
774
  */
787
775
  emitAction: (e, t) => {
788
- D("action", {
776
+ d("action", {
789
777
  name: e,
790
778
  doctype: r.value,
791
- recordId: y.value,
792
- data: t ?? l.value ?? {}
779
+ recordId: h.value,
780
+ data: t ?? p.value ?? {}
793
781
  });
794
782
  }
795
- }), oe("aformLinkNavigator", {
783
+ }), te("aformLinkNavigator", {
796
784
  navigate: (e, t) => {
797
- V({ view: "record", doctype: e, recordId: String(t) });
785
+ E({ view: "record", doctype: e, recordId: String(t) });
798
786
  }
799
- }), oe("aformLinkResolver", async (e, t) => {
787
+ }), te("aformLinkResolver", async (e, t) => {
800
788
  if (a.value)
801
789
  try {
802
- const v = (await a.value.getMeta({ path: `/${e}`, segments: [e] }))?.displayField;
803
- if (!v) return;
804
- const u = (h) => {
805
- if (!h) return;
806
- const w = h[v];
807
- return typeof w == "string" || typeof w == "number" ? String(w) : void 0;
808
- }, f = a.value.getRecordById(e, t)?.get(""), A = u(f);
809
- if (A != null) return A;
790
+ const y = (await a.value.getMeta({ path: `/${e}`, segments: [e] }))?.displayField;
791
+ if (!y) return;
792
+ const f = (b) => {
793
+ if (!b) return;
794
+ const T = b[y];
795
+ return typeof T == "string" || typeof T == "number" ? String(T) : void 0;
796
+ }, A = a.value.getRecordById(e, t)?.get(""), _ = f(A);
797
+ if (_ != null) return _;
810
798
  await a.value.getRecord(e, t);
811
- const E = a.value.getRecordById(e, t)?.get("");
812
- return u(E);
799
+ const k = a.value.getRecordById(e, t)?.get("");
800
+ return f(k);
813
801
  } catch {
814
802
  return;
815
803
  }
816
804
  });
817
- const ve = (e) => {
818
- (e.ctrlKey || e.metaKey) && e.key === "k" && (e.preventDefault(), c.value = !0), e.key === "Escape" && c.value && (c.value = !1);
805
+ const ue = (e) => {
806
+ (e.ctrlKey || e.metaKey) && e.key === "k" && (e.preventDefault(), C.value = !0), e.key === "Escape" && C.value && (C.value = !1);
819
807
  };
820
- return fe(() => {
821
- document.addEventListener("keydown", ve);
822
- }), je(() => {
823
- document.removeEventListener("keydown", ve);
824
- }), (e, t) => (p(), g("div", {
808
+ return de(() => {
809
+ document.addEventListener("keydown", ue);
810
+ }), Fe(() => {
811
+ document.removeEventListener("keydown", ue);
812
+ }), (e, t) => (m(), g("div", {
825
813
  class: "desktop",
826
- onClick: Ee
814
+ onClick: Te
827
815
  }, [
828
- j(ke, {
829
- elements: Re.value,
830
- onActionClick: Me
816
+ j(ge, {
817
+ elements: Ae.value,
818
+ onActionClick: xe
831
819
  }, null, 8, ["elements"]),
832
- ue.value.length > 0 ? (p(), he(ae(We), {
820
+ ce.value.length > 0 ? (m(), fe(ee(He), {
833
821
  key: 0,
834
- data: l.value,
835
- "onUpdate:data": t[0] || (t[0] = (n) => l.value = n),
836
- schema: ue.value,
837
- errors: M.value
838
- }, null, 8, ["data", "schema", "errors"])) : ae(a) ? (p(), g("div", bt, [
839
- i("p", null, "Loading " + N(x.value) + " data...", 1)
840
- ])) : (p(), g("div", wt, [...t[2] || (t[2] = [
841
- i("p", null, "Initializing Stonecrop...", -1)
822
+ data: p.value,
823
+ "onUpdate:data": t[0] || (t[0] = (o) => p.value = o),
824
+ schema: ce.value,
825
+ errors: x.value
826
+ }, null, 8, ["data", "schema", "errors"])) : ee(a) ? (m(), g("div", yt, [
827
+ c("p", null, "Loading " + V(I.value) + " data...", 1)
828
+ ])) : (m(), g("div", ht, [...t[2] || (t[2] = [
829
+ c("p", null, "Initializing Stonecrop...", -1)
842
830
  ])])),
843
- xe.value ? (p(), g("p", kt, "This is a partial list — more records exist on the server.")) : K("", !0),
844
- j(Ae, { breadcrumbs: $e.value }, null, 8, ["breadcrumbs"]),
845
- j(Ce, {
846
- "is-open": c.value,
847
- search: Ie,
831
+ $e.value ? (m(), g("p", gt, "This is a partial list — more records exist on the server.")) : L("", !0),
832
+ j(be, { breadcrumbs: De.value }, null, 8, ["breadcrumbs"]),
833
+ j(we, {
834
+ "is-open": C.value,
835
+ search: Re,
848
836
  placeholder: "Type a command or search...",
849
- onSelect: _e,
850
- onClose: t[1] || (t[1] = (n) => c.value = !1)
837
+ onSelect: Se,
838
+ onClose: t[1] || (t[1] = (o) => C.value = !1)
851
839
  }, {
852
- title: U(({ result: n }) => [
853
- X(N(n.title), 1)
840
+ title: z(({ result: o }) => [
841
+ J(V(o.title), 1)
854
842
  ]),
855
- content: U(({ result: n }) => [
856
- X(N(n.description), 1)
843
+ content: z(({ result: o }) => [
844
+ J(V(o.description), 1)
857
845
  ]),
858
846
  _: 1
859
847
  }, 8, ["is-open"])
860
848
  ]));
861
849
  }
862
- }), _t = {
863
- install: (s) => {
864
- s.component("ActionSet", ke), s.component("CommandPalette", Ce), s.component("Desktop", Ct), s.component("SheetNav", Ae);
850
+ }), St = {
851
+ install: (l) => {
852
+ l.component("ActionSet", ge), l.component("CommandPalette", we), l.component("Desktop", wt), l.component("SheetNav", be);
865
853
  }
866
854
  };
867
855
  export {
868
- ke as ActionSet,
869
- Ce as CommandPalette,
870
- Ct as Desktop,
871
- Ae as SheetNav,
872
- _t as StonecropDesktop
856
+ ge as ActionSet,
857
+ we as CommandPalette,
858
+ wt as Desktop,
859
+ be as SheetNav,
860
+ St as StonecropDesktop
873
861
  };
874
862
  //# sourceMappingURL=desktop.js.map