@stonecrop/desktop 0.16.3 → 0.16.5

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,22 +1,22 @@
1
- import { defineComponent as U, ref as R, onMounted as ce, openBlock as d, createElementBlock as h, normalizeClass as _, createElementVNode as s, Fragment as L, renderList as K, toDisplayString as N, createCommentVNode as F, withDirectives as P, vShow as X, useTemplateRef as se, computed as C, watch as j, nextTick as ie, createBlock as ue, Teleport as Ne, createVNode as M, Transition as Te, withCtx as B, withModifiers as de, vModelText as ve, renderSlot as q, createTextVNode as H, resolveComponent as Ve, withKeys as E, normalizeStyle as G, unref as J, provide as Q, onUnmounted as _e } from "vue";
2
- import { useStonecrop as Me, useValidationStore as Ee } from "@stonecrop/stonecrop";
3
- import { AForm as Fe } from "@stonecrop/aform";
4
- const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header" }, Le = ["disabled", "onClick"], Ke = { key: 0 }, Pe = { class: "dropdown-header" }, je = ["onClick"], He = ["onClick"], Ue = { class: "dropdown-container" }, ze = { class: "dropdown" }, We = ["onClick"], qe = ["href"], Ge = { class: "dropdown-item" }, Je = /* @__PURE__ */ U({
1
+ import { defineComponent as U, ref as R, onMounted as ce, openBlock as d, createElementBlock as h, normalizeClass as _, createElementVNode as c, Fragment as L, renderList as K, toDisplayString as N, createCommentVNode as F, withDirectives as P, vShow as X, useTemplateRef as ie, computed as k, watch as j, nextTick as ue, createBlock as de, Teleport as Te, createVNode as M, Transition as Ve, withCtx as B, withModifiers as ve, vModelText as fe, renderSlot as q, createTextVNode as H, resolveComponent as _e, withKeys as E, normalizeStyle as G, unref as J, provide as Q, onUnmounted as Me } from "vue";
2
+ import { useStonecrop as Ee, useValidationStore as Fe } from "@stonecrop/stonecrop";
3
+ import { AForm as Be } from "@stonecrop/aform";
4
+ const Oe = { class: "action-menu-icon" }, Le = { class: "action-element-header" }, Ke = ["disabled", "onClick"], Pe = { key: 0 }, je = { class: "dropdown-header" }, He = ["onClick"], Ue = ["onClick"], ze = { class: "dropdown-container" }, We = { class: "dropdown" }, qe = ["onClick"], Ge = ["href"], Je = { class: "dropdown-item" }, Qe = /* @__PURE__ */ U({
5
5
  __name: "ActionSet",
6
6
  props: {
7
7
  elements: { default: () => [] }
8
8
  },
9
9
  emits: ["actionClick"],
10
- setup(c, { emit: b }) {
10
+ setup(s, { emit: b }) {
11
11
  const v = b, a = R({}), u = R(!0), x = R([]);
12
12
  ce(() => {
13
13
  y();
14
14
  });
15
15
  const y = () => {
16
16
  a.value = {}, x.value = [];
17
- }, w = () => {
17
+ }, g = () => {
18
18
  u.value = !u.value;
19
- }, A = (n) => {
19
+ }, C = (n) => {
20
20
  const f = !a.value[n];
21
21
  y(), f && (a.value[n] = !0, x.value[n] = !0);
22
22
  }, $ = (n, f) => {
@@ -25,39 +25,39 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
25
25
  return (n, f) => (d(), h("div", {
26
26
  class: _([{ collapsed: !u.value }, "action-set"])
27
27
  }, [
28
- s("div", Be, [
29
- s("div", {
28
+ c("div", Oe, [
29
+ c("div", {
30
30
  id: "cross",
31
31
  class: _({ rotated: u.value }),
32
- onClick: w
32
+ onClick: g
33
33
  }, "×", 2)
34
34
  ]),
35
- f[0] || (f[0] = s("div", { style: { "margin-right": "30px" } }, null, -1)),
36
- (d(!0), h(L, null, K(c.elements, (o, i) => (d(), h("div", {
35
+ f[0] || (f[0] = c("div", { style: { "margin-right": "30px" } }, null, -1)),
36
+ (d(!0), h(L, null, K(s.elements, (o, i) => (d(), h("div", {
37
37
  key: o.label,
38
38
  class: "action-element"
39
39
  }, [
40
- s("div", Oe, [
40
+ c("div", Le, [
41
41
  o.type == "button" ? (d(), h("button", {
42
42
  key: 0,
43
43
  disabled: o.disabled,
44
44
  class: "button-default",
45
45
  onClick: (r) => $(o.action, o.label)
46
- }, N(o.label), 9, Le)) : F("", !0)
46
+ }, N(o.label), 9, Ke)) : F("", !0)
47
47
  ]),
48
- o.type == "dropdown" ? (d(), h("div", Ke, [
49
- s("div", Pe, [
50
- s("div", {
48
+ o.type == "dropdown" ? (d(), h("div", Pe, [
49
+ c("div", je, [
50
+ c("div", {
51
51
  class: _(["cross", { rotated: x.value[i] }]),
52
- onClick: (r) => A(i)
53
- }, "×", 10, je),
54
- s("button", {
52
+ onClick: (r) => C(i)
53
+ }, "×", 10, He),
54
+ c("button", {
55
55
  class: "button-default dropdown-title",
56
- onClick: (r) => A(i)
57
- }, N(o.label), 9, He)
56
+ onClick: (r) => C(i)
57
+ }, N(o.label), 9, Ue)
58
58
  ]),
59
- P(s("div", Ue, [
60
- s("div", ze, [
59
+ P(c("div", ze, [
60
+ c("div", We, [
61
61
  (d(!0), h(L, null, K(o.actions, (r) => (d(), h("div", {
62
62
  key: r.label
63
63
  }, [
@@ -65,12 +65,12 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
65
65
  key: 0,
66
66
  class: "dropdown-item",
67
67
  onClick: (z) => $(r.action, r.label)
68
- }, N(r.label), 9, We)) : r.link != null ? (d(), h("a", {
68
+ }, N(r.label), 9, qe)) : r.link != null ? (d(), h("a", {
69
69
  key: 1,
70
70
  href: r.link
71
71
  }, [
72
- s("button", Ge, N(r.label), 1)
73
- ], 8, qe)) : F("", !0)
72
+ c("button", Je, N(r.label), 1)
73
+ ], 8, Ge)) : F("", !0)
74
74
  ]))), 128))
75
75
  ])
76
76
  ], 512), [
@@ -80,18 +80,18 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
80
80
  ]))), 128))
81
81
  ], 2));
82
82
  }
83
- }), fe = (c, b) => {
84
- const v = c.__vccOpts || c;
83
+ }), pe = (s, b) => {
84
+ const v = s.__vccOpts || s;
85
85
  for (const [a, u] of b)
86
86
  v[a] = u;
87
87
  return v;
88
- }, pe = /* @__PURE__ */ fe(Je, [["__scopeId", "data-v-54797d4b"]]), Qe = { class: "command-palette-header" }, Xe = ["placeholder"], Ye = {
88
+ }, me = /* @__PURE__ */ pe(Qe, [["__scopeId", "data-v-54797d4b"]]), Xe = { class: "command-palette-header" }, Ye = ["placeholder"], Ze = {
89
89
  key: 0,
90
90
  class: "command-palette-results"
91
- }, Ze = ["onClick", "onMouseover"], et = { class: "result-title" }, tt = { class: "result-content" }, ot = {
91
+ }, et = ["onClick", "onMouseover"], tt = { class: "result-title" }, ot = { class: "result-content" }, at = {
92
92
  key: 1,
93
93
  class: "command-palette-no-results"
94
- }, me = /* @__PURE__ */ U({
94
+ }, he = /* @__PURE__ */ U({
95
95
  __name: "CommandPalette",
96
96
  props: {
97
97
  search: { type: Function },
@@ -100,22 +100,22 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
100
100
  maxResults: { default: 10 }
101
101
  },
102
102
  emits: ["select", "close"],
103
- setup(c, { emit: b }) {
104
- const v = b, a = R(""), u = R(0), x = se("input"), y = C(() => a.value ? c.search(a.value).slice(0, c.maxResults) : []);
103
+ setup(s, { emit: b }) {
104
+ const v = b, a = R(""), u = R(0), x = ie("input"), y = k(() => a.value ? s.search(a.value).slice(0, s.maxResults) : []);
105
105
  j(
106
- () => c.isOpen,
106
+ () => s.isOpen,
107
107
  async (n) => {
108
- n && (a.value = "", u.value = 0, await ie(), x.value?.focus());
108
+ n && (a.value = "", u.value = 0, await ue(), x.value?.focus());
109
109
  }
110
110
  ), j(y, () => {
111
111
  u.value = 0;
112
112
  });
113
- const w = () => {
113
+ const g = () => {
114
114
  v("close");
115
- }, A = (n) => {
115
+ }, C = (n) => {
116
116
  switch (n.key) {
117
117
  case "Escape":
118
- w();
118
+ g();
119
119
  break;
120
120
  case "ArrowDown":
121
121
  n.preventDefault(), y.value.length && (u.value = (u.value + 1) % y.value.length);
@@ -128,49 +128,49 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
128
128
  break;
129
129
  }
130
130
  }, $ = (n) => {
131
- v("select", n), w();
131
+ v("select", n), g();
132
132
  };
133
- return (n, f) => (d(), ue(Ne, { to: "body" }, [
134
- M(Te, { name: "fade" }, {
133
+ return (n, f) => (d(), de(Te, { to: "body" }, [
134
+ M(Ve, { name: "fade" }, {
135
135
  default: B(() => [
136
- c.isOpen ? (d(), h("div", {
136
+ s.isOpen ? (d(), h("div", {
137
137
  key: 0,
138
138
  class: "command-palette-overlay",
139
- onClick: w
139
+ onClick: g
140
140
  }, [
141
- s("div", {
141
+ c("div", {
142
142
  class: "command-palette",
143
- onClick: f[1] || (f[1] = de(() => {
143
+ onClick: f[1] || (f[1] = ve(() => {
144
144
  }, ["stop"]))
145
145
  }, [
146
- s("div", Qe, [
147
- P(s("input", {
146
+ c("div", Xe, [
147
+ P(c("input", {
148
148
  ref: "input",
149
149
  "onUpdate:modelValue": f[0] || (f[0] = (o) => a.value = o),
150
150
  type: "text",
151
151
  class: "command-palette-input",
152
- placeholder: c.placeholder,
152
+ placeholder: s.placeholder,
153
153
  autofocus: "",
154
- onKeydown: A
155
- }, null, 40, Xe), [
156
- [ve, a.value]
154
+ onKeydown: C
155
+ }, null, 40, Ye), [
156
+ [fe, a.value]
157
157
  ])
158
158
  ]),
159
- y.value.length ? (d(), h("div", Ye, [
159
+ y.value.length ? (d(), h("div", Ze, [
160
160
  (d(!0), h(L, null, K(y.value, (o, i) => (d(), h("div", {
161
161
  key: i,
162
162
  class: _(["command-palette-result", { selected: i === u.value }]),
163
163
  onClick: (r) => $(o),
164
164
  onMouseover: (r) => u.value = i
165
165
  }, [
166
- s("div", et, [
166
+ c("div", tt, [
167
167
  q(n.$slots, "title", { result: o })
168
168
  ]),
169
- s("div", tt, [
169
+ c("div", ot, [
170
170
  q(n.$slots, "content", { result: o })
171
171
  ])
172
- ], 42, Ze))), 128))
173
- ])) : a.value && !y.value.length ? (d(), h("div", ot, [
172
+ ], 42, et))), 128))
173
+ ])) : a.value && !y.value.length ? (d(), h("div", at, [
174
174
  q(n.$slots, "empty", {}, () => [
175
175
  H(' No results found for "' + N(a.value) + '" ', 1)
176
176
  ])
@@ -182,40 +182,40 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
182
182
  })
183
183
  ]));
184
184
  }
185
- }), at = { class: "tabs" }, nt = { tabindex: "0" }, rt = { tabindex: "0" }, lt = /* @__PURE__ */ U({
185
+ }), nt = { class: "tabs" }, rt = { tabindex: "0" }, lt = { tabindex: "0" }, st = /* @__PURE__ */ U({
186
186
  __name: "SheetNav",
187
187
  props: {
188
188
  breadcrumbs: { default: () => [] }
189
189
  },
190
- setup(c) {
191
- const b = R(!0), v = R(!1), a = R(""), u = se("searchinput"), x = C(() => b.value ? "unrotated" : "rotated"), y = () => {
190
+ setup(s) {
191
+ const b = R(!0), v = R(!1), a = R(""), u = ie("searchinput"), x = k(() => b.value ? "unrotated" : "rotated"), y = () => {
192
192
  b.value = !b.value;
193
- }, w = async () => {
194
- v.value = !v.value, await ie(() => {
193
+ }, g = async () => {
194
+ v.value = !v.value, await ue(() => {
195
195
  u.value?.focus();
196
196
  });
197
- }, A = (f) => {
197
+ }, C = (f) => {
198
198
  f.preventDefault(), f.stopPropagation();
199
199
  }, $ = async (f) => {
200
- f.preventDefault(), f.stopPropagation(), await w();
200
+ f.preventDefault(), f.stopPropagation(), await g();
201
201
  }, n = () => {
202
202
  };
203
203
  return (f, o) => {
204
- const i = Ve("router-link");
204
+ const i = _e("router-link");
205
205
  return d(), h("footer", null, [
206
- s("ul", at, [
207
- s("li", {
206
+ c("ul", nt, [
207
+ c("li", {
208
208
  class: "hidebreadcrumbs",
209
209
  onClick: y,
210
210
  onKeydown: E(y, ["enter"])
211
211
  }, [
212
- s("a", nt, [
213
- s("div", {
212
+ c("a", rt, [
213
+ c("div", {
214
214
  class: _(x.value)
215
215
  }, "×", 2)
216
216
  ])
217
217
  ], 32),
218
- s("li", {
218
+ c("li", {
219
219
  class: "hometab",
220
220
  style: G({ display: b.value ? "block" : "none" }),
221
221
  onClick: n,
@@ -226,7 +226,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
226
226
  tabindex: "0"
227
227
  }, {
228
228
  default: B(() => [...o[5] || (o[5] = [
229
- s("svg", {
229
+ c("svg", {
230
230
  class: "icon",
231
231
  "aria-label": "Home",
232
232
  viewBox: "0 0 24 24",
@@ -234,18 +234,18 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
234
234
  stroke: "currentColor",
235
235
  "stroke-width": "2"
236
236
  }, [
237
- s("path", { d: "M3 12l9-9 9 9" }),
238
- s("path", { d: "M9 21V12h6v9" })
237
+ c("path", { d: "M3 12l9-9 9 9" }),
238
+ c("path", { d: "M9 21V12h6v9" })
239
239
  ], -1)
240
240
  ])]),
241
241
  _: 1
242
242
  })
243
243
  ], 36),
244
- s("li", {
244
+ c("li", {
245
245
  class: _(["searchtab", { "search-active": v.value }]),
246
246
  style: G({ display: b.value ? "block" : "none" })
247
247
  }, [
248
- s("a", rt, [
248
+ c("a", lt, [
249
249
  P((d(), h("svg", {
250
250
  class: "icon search-icon",
251
251
  role: "button",
@@ -254,38 +254,38 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
254
254
  fill: "none",
255
255
  stroke: "currentColor",
256
256
  "stroke-width": "2",
257
- onClick: w,
258
- onKeydown: E(w, ["enter"])
257
+ onClick: g,
258
+ onKeydown: E(g, ["enter"])
259
259
  }, [...o[6] || (o[6] = [
260
- s("circle", {
260
+ c("circle", {
261
261
  cx: "11",
262
262
  cy: "11",
263
263
  r: "7"
264
264
  }, null, -1),
265
- s("path", { d: "M21 21l-4.35-4.35" }, null, -1)
265
+ c("path", { d: "M21 21l-4.35-4.35" }, null, -1)
266
266
  ])], 544)), [
267
267
  [X, !v.value]
268
268
  ]),
269
- P(s("input", {
269
+ P(c("input", {
270
270
  ref: "searchinput",
271
271
  "onUpdate:modelValue": o[0] || (o[0] = (r) => a.value = r),
272
272
  type: "text",
273
273
  placeholder: "Search...",
274
- onClick: o[1] || (o[1] = de(() => {
274
+ onClick: o[1] || (o[1] = ve(() => {
275
275
  }, ["stop"])),
276
- onInput: o[2] || (o[2] = (r) => A(r)),
276
+ onInput: o[2] || (o[2] = (r) => C(r)),
277
277
  onBlur: o[3] || (o[3] = (r) => $(r)),
278
278
  onKeydown: [
279
279
  o[4] || (o[4] = E((r) => $(r), ["enter"])),
280
- E(w, ["escape"])
280
+ E(g, ["escape"])
281
281
  ]
282
282
  }, null, 544), [
283
283
  [X, v.value],
284
- [ve, a.value]
284
+ [fe, a.value]
285
285
  ])
286
286
  ])
287
287
  ], 6),
288
- (d(!0), h(L, null, K(c.breadcrumbs, (r) => (d(), h("li", {
288
+ (d(!0), h(L, null, K(s.breadcrumbs, (r) => (d(), h("li", {
289
289
  key: r.title,
290
290
  style: G({ display: b.value ? "block" : "none" })
291
291
  }, [
@@ -303,13 +303,13 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
303
303
  ]);
304
304
  };
305
305
  }
306
- }), he = /* @__PURE__ */ fe(lt, [["__scopeId", "data-v-0072260b"]]), ct = {
306
+ }), ye = /* @__PURE__ */ pe(st, [["__scopeId", "data-v-0072260b"]]), ct = {
307
307
  key: 1,
308
308
  class: "loading"
309
- }, st = {
309
+ }, it = {
310
310
  key: 2,
311
311
  class: "loading"
312
- }, it = /* @__PURE__ */ U({
312
+ }, ut = /* @__PURE__ */ U({
313
313
  __name: "Desktop",
314
314
  props: {
315
315
  availableDoctypes: { default: () => [] },
@@ -318,39 +318,37 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
318
318
  recordIdField: {}
319
319
  },
320
320
  emits: ["action", "navigate", "record:open", "load-records", "load-record"],
321
- setup(c, { emit: b }) {
322
- const v = b, { stonecrop: a } = Me();
321
+ setup(s, { emit: b }) {
322
+ const v = b, { stonecrop: a } = Ee();
323
323
  let u = null;
324
324
  try {
325
- u = Ee();
325
+ u = Fe();
326
326
  } catch {
327
327
  u = null;
328
328
  }
329
- const x = C(
330
- () => D.value === "record" ? u?.errorsByField ?? {} : {}
331
- ), y = R(!1), w = R(!1), A = C({
329
+ const x = k(
330
+ () => A.value === "record" ? u?.errorsByField ?? {} : {}
331
+ ), y = R(!1), g = R(!1), C = k({
332
332
  get() {
333
- if (D.value === "doctypes")
333
+ if (A.value === "doctypes")
334
334
  return {
335
- doctypes_table: c.availableDoctypes?.map((e) => ({
335
+ doctypes_table: s.availableDoctypes?.map((e) => ({
336
336
  id: e,
337
337
  doctype: e,
338
338
  display_name: V(e),
339
- record_count: Ae(e),
339
+ record_count: De(e),
340
340
  actions: "View Records"
341
341
  })) ?? []
342
342
  };
343
- if (D.value === "records") {
344
- const e = c.recordIdField || "id";
343
+ if (A.value === "records")
345
344
  return {
346
345
  records_table: te().map(
347
- (t) => Object.assign({}, t, {
348
- id: t[e] || t.id || "",
346
+ (e) => Object.assign({}, e, {
347
+ id: ne(e) ?? "",
349
348
  actions: "Edit | Delete"
350
349
  })
351
350
  )
352
351
  };
353
- }
354
352
  if (!a.value || !o.value || !r.value)
355
353
  return {};
356
354
  try {
@@ -359,8 +357,8 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
359
357
  for (const p of l.getSchemaArray())
360
358
  if (p.kind === "fieldset") {
361
359
  const m = {};
362
- for (const g of p.schema)
363
- g.fieldname && (m[g.fieldname] = t[g.fieldname]);
360
+ for (const w of p.schema)
361
+ w.fieldname && (m[w.fieldname] = t[w.fieldname]);
364
362
  t[p.fieldname] = m;
365
363
  }
366
364
  }
@@ -370,7 +368,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
370
368
  }
371
369
  },
372
370
  set(e) {
373
- if (D.value === "record" && !(!a.value || !o.value || !r.value))
371
+ if (A.value === "record" && !(!a.value || !o.value || !r.value))
374
372
  try {
375
373
  const t = a.value.registry.registry[o.value], l = /* @__PURE__ */ new Set();
376
374
  if (t)
@@ -381,13 +379,13 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
381
379
  l.has(S) && I && typeof I == "object" && !Array.isArray(I) ? m.push(I) : p[S] = I;
382
380
  for (const S of m)
383
381
  Object.assign(p, S);
384
- const g = a.value.getStore(), k = [];
382
+ const w = a.value.getStore(), D = [];
385
383
  for (const [S, I] of Object.entries(p)) {
386
384
  if (I === void 0) continue;
387
385
  const W = `${o.value}.${r.value}.${S}`;
388
- (g.has(W) ? g.get(W) : void 0) !== I && (g.set(W, I), k.push(S));
386
+ (w.has(W) ? w.get(W) : void 0) !== I && (w.set(W, I), D.push(S));
389
387
  }
390
- k.length > 0 && $(k);
388
+ D.length > 0 && $(D);
391
389
  } catch (t) {
392
390
  console.warn("HST update failed:", t);
393
391
  }
@@ -398,11 +396,11 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
398
396
  const l = a.value.registry.getDoctype(o.value)?.getTriggers();
399
397
  if (!l || Object.keys(l).length === 0) return;
400
398
  const m = { ...a.value.getRecordById(o.value, r.value)?.get("") };
401
- for (const g of e)
402
- u.validateField(l, g, m);
399
+ for (const w of e)
400
+ u.validateField(l, w, m);
403
401
  }
404
- const n = C(() => c.routeAdapter ? null : J(a.value?.registry.router?.currentRoute)), f = C(() => c.routeAdapter ? null : a.value?.registry.router), o = C(() => {
405
- if (c.routeAdapter) return c.routeAdapter.getCurrentDoctype();
402
+ const n = k(() => s.routeAdapter ? null : J(a.value?.registry.router?.currentRoute)), f = k(() => s.routeAdapter ? null : a.value?.registry.router), o = k(() => {
403
+ if (s.routeAdapter) return s.routeAdapter.getCurrentDoctype();
406
404
  if (!n.value) return "";
407
405
  if (n.value.meta?.actualDoctype)
408
406
  return n.value.meta.actualDoctype;
@@ -410,8 +408,8 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
410
408
  return n.value.params.doctype.toString();
411
409
  const e = n.value.params.pathMatch;
412
410
  return e && e.length > 0 ? e[0] : "";
413
- }), i = C(() => {
414
- if (c.routeAdapter) return c.routeAdapter.getCurrentDoctype();
411
+ }), i = k(() => {
412
+ if (s.routeAdapter) return s.routeAdapter.getCurrentDoctype();
415
413
  if (!n.value) return "";
416
414
  if (n.value.meta?.doctype)
417
415
  return n.value.meta.doctype;
@@ -419,15 +417,15 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
419
417
  return n.value.params.doctype.toString();
420
418
  const e = n.value.params.pathMatch;
421
419
  return e && e.length > 0 ? e[0] : "";
422
- }), r = C(() => {
423
- if (c.routeAdapter) return c.routeAdapter.getCurrentRecordId();
420
+ }), r = k(() => {
421
+ if (s.routeAdapter) return s.routeAdapter.getCurrentRecordId();
424
422
  if (!n.value) return "";
425
423
  if (n.value.params.recordId)
426
424
  return n.value.params.recordId.toString();
427
425
  const e = n.value.params.pathMatch;
428
426
  return e && e.length > 1 ? e[1] : "";
429
- }), z = C(() => r.value?.startsWith("new-")), D = C(() => {
430
- if (c.routeAdapter) return c.routeAdapter.getCurrentView();
427
+ }), z = k(() => r.value?.startsWith("new-")), A = k(() => {
428
+ if (s.routeAdapter) return s.routeAdapter.getCurrentView();
431
429
  if (!n.value || n.value.name === "home" || n.value.path === "/")
432
430
  return "doctypes";
433
431
  if (n.value.name && n.value.name !== "catch-all") {
@@ -439,13 +437,13 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
439
437
  }
440
438
  const e = n.value.params.pathMatch;
441
439
  return e && e.length > 0 ? e.length === 1 ? "records" : "record" : "doctypes";
442
- }), ye = () => {
440
+ }), ge = () => {
443
441
  if (!a.value || !o.value || !r.value)
444
442
  return [];
445
443
  try {
446
444
  const e = a.value.registry.getDoctype(o.value);
447
445
  if (!e?.workflow) return [];
448
- const t = a.value.getRecordState(o.value, r.value), l = e.getAvailableTransitions(t), p = A.value || {};
446
+ const t = a.value.getRecordState(o.value, r.value), l = e.getAvailableTransitions(t), p = C.value || {};
449
447
  return l.map(({ name: m }) => ({
450
448
  // Prefer the workflow action's human-readable label (WorkflowMeta format);
451
449
  // fall back to the raw transition name for XState workflows with no action meta.
@@ -462,13 +460,13 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
462
460
  } catch (e) {
463
461
  return console.warn("Error getting available transitions:", e), [];
464
462
  }
465
- }, ge = () => {
463
+ }, we = () => {
466
464
  if (!a.value || !o.value || !r.value)
467
465
  return [];
468
466
  try {
469
467
  const e = a.value.registry.getDoctype(o.value);
470
468
  if (!e?.workflow) return [];
471
- const t = a.value.getRecordState(o.value, r.value), l = e.getAvailableCommands(t), p = A.value || {};
469
+ const t = a.value.getRecordState(o.value, r.value), l = e.getAvailableCommands(t), p = C.value || {};
472
470
  return l.map(({ name: m }) => ({
473
471
  label: e.getActionMeta(m)?.label ?? m,
474
472
  action: () => {
@@ -483,9 +481,9 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
483
481
  } catch (e) {
484
482
  return console.warn("Error getting available commands:", e), [];
485
483
  }
486
- }, we = C(() => {
484
+ }, be = k(() => {
487
485
  const e = [];
488
- switch (D.value) {
486
+ switch (A.value) {
489
487
  case "records":
490
488
  e.push({
491
489
  type: "button",
@@ -496,7 +494,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
496
494
  });
497
495
  break;
498
496
  case "record": {
499
- const t = [...ye(), ...ge()];
497
+ const t = [...ge(), ...we()];
500
498
  t.length > 0 && e.push({
501
499
  type: "dropdown",
502
500
  label: "Actions",
@@ -506,14 +504,14 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
506
504
  }
507
505
  }
508
506
  return e;
509
- }), be = C(() => {
507
+ }), ke = k(() => {
510
508
  const e = [];
511
- if (D.value === "records" && i.value)
509
+ if (A.value === "records" && i.value)
512
510
  e.push(
513
511
  { title: "Home", to: "/" },
514
512
  { title: V(i.value), to: `/${i.value}` }
515
513
  );
516
- else if (D.value === "record" && i.value) {
514
+ else if (A.value === "record" && i.value) {
517
515
  const t = r.value ? `/${i.value}/${r.value}` : n.value?.fullPath ?? "";
518
516
  e.push(
519
517
  { title: "Home", to: "/" },
@@ -522,7 +520,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
522
520
  );
523
521
  }
524
522
  return e;
525
- }), ke = (e) => {
523
+ }), Ce = (e) => {
526
524
  const t = [
527
525
  {
528
526
  title: "Go Home",
@@ -534,7 +532,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
534
532
  {
535
533
  title: "Toggle Command Palette",
536
534
  description: "Open/close the command palette",
537
- action: () => w.value = !w.value
535
+ action: () => g.value = !g.value
538
536
  }
539
537
  ];
540
538
  return i.value && (t.push({
@@ -549,7 +547,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
549
547
  action: () => {
550
548
  O();
551
549
  }
552
- })), c.availableDoctypes.forEach((l) => {
550
+ })), s.availableDoctypes.forEach((l) => {
553
551
  t.push({
554
552
  title: `View ${V(l)}`,
555
553
  description: `Navigate to ${l} list`,
@@ -560,10 +558,10 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
560
558
  }), e ? t.filter(
561
559
  (l) => l.title.toLowerCase().includes(e.toLowerCase()) || l.description.toLowerCase().includes(e.toLowerCase())
562
560
  ) : t;
563
- }, Ce = (e) => {
564
- e.action(), w.value = !1;
565
- }, V = (e) => e.split("-").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" "), Ae = (e) => a.value ? a.value.getRecordIds(e).length : 0, T = async (e) => {
566
- v("navigate", e), c.routeAdapter ? await c.routeAdapter.navigate(e) : e.view === "doctypes" ? await f.value?.push("/") : e.view === "records" && e.doctype ? await f.value?.push(`/${e.doctype}`) : e.view === "record" && e.doctype && e.recordId && await f.value?.push(`/${e.doctype}/${e.recordId}`);
561
+ }, Ae = (e) => {
562
+ e.action(), g.value = !1;
563
+ }, V = (e) => e.split("-").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" "), De = (e) => a.value ? a.value.getRecordIds(e).length : 0, T = async (e) => {
564
+ v("navigate", e), s.routeAdapter ? await s.routeAdapter.navigate(e) : e.view === "doctypes" ? await f.value?.push("/") : e.view === "records" && e.doctype ? await f.value?.push(`/${e.doctype}`) : e.view === "record" && e.doctype && e.recordId && await f.value?.push(`/${e.doctype}/${e.recordId}`);
567
565
  }, Y = async (e) => {
568
566
  await T({ view: "records", doctype: e });
569
567
  }, Z = async (e) => {
@@ -577,7 +575,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
577
575
  for (const l of e)
578
576
  l.kind === "fieldset" ? t.push(...ee(l.schema)) : t.push(l);
579
577
  return t;
580
- }, De = () => c.availableDoctypes?.length ? [
578
+ }, Ie = () => s.availableDoctypes?.length ? [
581
579
  {
582
580
  kind: "table",
583
581
  fieldname: "doctypes_table",
@@ -619,7 +617,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
619
617
  ],
620
618
  config: { view: "list", fullWidth: !0 }
621
619
  }
622
- ] : [], Ie = () => {
620
+ ] : [], Se = () => {
623
621
  if (!o.value) return [];
624
622
  if (!a.value) return [];
625
623
  const e = a.value.registry, t = e.registry[o.value];
@@ -637,7 +635,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
637
635
  config: { view: "list", fullWidth: !0 }
638
636
  }
639
637
  ];
640
- }, Se = () => {
638
+ }, $e = () => {
641
639
  if (!o.value) return [];
642
640
  if (!a.value) return [];
643
641
  try {
@@ -651,60 +649,66 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
651
649
  return [];
652
650
  const t = a.value.records(o.value)?.get("");
653
651
  return t && typeof t == "object" && !Array.isArray(t) ? Object.values(t) : [];
654
- }, oe = C(() => {
655
- switch (D.value) {
652
+ }, oe = k(() => {
653
+ switch (A.value) {
656
654
  case "doctypes":
657
- return De();
658
- case "records":
659
655
  return Ie();
660
- case "record":
656
+ case "records":
661
657
  return Se();
658
+ case "record":
659
+ return $e();
662
660
  default:
663
661
  return [];
664
662
  }
665
- }), $e = (e, t) => {
663
+ }), Re = (e, t) => {
666
664
  t && t();
667
665
  }, ae = async (e) => {
668
666
  const t = e || r.value;
669
667
  if (!t) return;
670
- (c.confirmFn ? await c.confirmFn("Are you sure you want to delete this record?") : confirm("Are you sure you want to delete this record?")) && v("action", {
668
+ (s.confirmFn ? await s.confirmFn("Are you sure you want to delete this record?") : confirm("Are you sure you want to delete this record?")) && v("action", {
671
669
  name: "DELETE",
672
670
  doctype: o.value,
673
671
  recordId: t,
674
- data: A.value || {}
672
+ data: C.value || {}
675
673
  });
676
674
  }, ne = (e) => {
675
+ if (s.recordIdField) {
676
+ const t = e[s.recordIdField];
677
+ if (typeof t == "number") return String(t);
678
+ if (typeof t == "string" && t !== "") return t;
679
+ }
680
+ if (!(!a.value || !o.value))
681
+ return a.value.registry.registry[o.value]?.getRecordId(e);
682
+ }, re = (e) => {
677
683
  const t = e.querySelector("td[data-rowindex]");
678
684
  if (!t) return null;
679
685
  const l = t.getAttribute("data-rowindex");
680
686
  if (l === null) return null;
681
687
  const p = parseInt(l, 10);
682
688
  if (isNaN(p)) return null;
683
- const g = te()[p];
684
- if (!g) return null;
685
- const k = c.recordIdField || "id";
686
- return g[k] || g.id || null;
687
- }, Re = async (e) => {
689
+ const w = te()[p];
690
+ return w ? ne(w) ?? null : null;
691
+ }, xe = async (e) => {
688
692
  const t = e.target;
689
693
  t.getAttribute("data-action") === "create" && await O();
690
694
  const p = t.closest("td, th");
691
695
  if (p) {
692
- const m = p.textContent?.trim(), g = p.closest("tr");
693
- if (m === "View Records" && g) {
694
- const k = g.querySelectorAll("td");
695
- if (k.length > 0) {
696
- const I = k[1].textContent?.trim();
696
+ const m = p.textContent?.trim(), w = p.closest("tr");
697
+ if (m === "View Records" && w) {
698
+ const D = w.querySelectorAll("td");
699
+ if (D.length > 0) {
700
+ const I = D[1].textContent?.trim();
697
701
  I && await Y(I);
698
702
  }
699
- } else if (m?.includes("Edit") && g) {
700
- const k = ne(g);
701
- k && await Z(k);
702
- } else if (m?.includes("Delete") && g) {
703
- const k = ne(g);
704
- k && await ae(k);
703
+ } else if (m?.includes("Edit") && w) {
704
+ const D = re(w);
705
+ D && await Z(D);
706
+ } else if (m?.includes("Delete") && w) {
707
+ const D = re(w);
708
+ D && await ae(D);
705
709
  }
706
710
  }
707
- }, xe = async () => {
711
+ }, Ne = async () => {
708
712
  if (!(!a.value || !o.value || z.value) && !a.value.getRecordById(o.value, r.value) && a.value.getClient()) {
709
713
  y.value = !0;
710
714
  try {
@@ -717,9 +721,9 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
717
721
  }
718
722
  };
719
723
  j(
720
- [D, o, r],
724
+ [A, o, r],
721
725
  () => {
722
- D.value === "records" && o.value ? v("load-records", { doctype: o.value }) : D.value === "record" && o.value && r.value && (v("load-record", { doctype: o.value, recordId: r.value }), xe());
726
+ A.value === "records" && o.value ? v("load-records", { doctype: o.value }) : A.value === "record" && o.value && r.value && (v("load-record", { doctype: o.value, recordId: r.value }), Ne());
723
727
  },
724
728
  { immediate: !0 }
725
729
  ), j([o, r], () => {
@@ -738,7 +742,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
738
742
  name: e,
739
743
  doctype: o.value,
740
744
  recordId: r.value,
741
- data: t ?? A.value ?? {}
745
+ data: t ?? C.value ?? {}
742
746
  });
743
747
  }
744
748
  }), Q("aformLinkNavigator", {
@@ -746,7 +750,7 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
746
750
  T({ view: "record", doctype: e, recordId: String(t) });
747
751
  }
748
752
  });
749
- function re(e) {
753
+ function le(e) {
750
754
  if (!e) return;
751
755
  const t = e.name ?? e.title ?? e.displayText;
752
756
  return typeof t == "string" || typeof t == "number" ? String(t) : void 0;
@@ -754,48 +758,48 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
754
758
  Q("aformLinkResolver", async (e, t) => {
755
759
  if (a.value)
756
760
  try {
757
- const l = a.value.getRecordById(e, t)?.get(""), p = re(l);
761
+ const l = a.value.getRecordById(e, t)?.get(""), p = le(l);
758
762
  if (p != null) return p;
759
763
  await a.value.getRecord(e, t);
760
764
  const m = a.value.getRecordById(e, t)?.get("");
761
- return re(m);
765
+ return le(m);
762
766
  } catch {
763
767
  return;
764
768
  }
765
769
  });
766
- const le = (e) => {
767
- (e.ctrlKey || e.metaKey) && e.key === "k" && (e.preventDefault(), w.value = !0), e.key === "Escape" && w.value && (w.value = !1);
770
+ const se = (e) => {
771
+ (e.ctrlKey || e.metaKey) && e.key === "k" && (e.preventDefault(), g.value = !0), e.key === "Escape" && g.value && (g.value = !1);
768
772
  };
769
773
  return ce(() => {
770
- document.addEventListener("keydown", le);
771
- }), _e(() => {
772
- document.removeEventListener("keydown", le);
774
+ document.addEventListener("keydown", se);
775
+ }), Me(() => {
776
+ document.removeEventListener("keydown", se);
773
777
  }), (e, t) => (d(), h("div", {
774
778
  class: "desktop",
775
- onClick: Re
779
+ onClick: xe
776
780
  }, [
777
- M(pe, {
778
- elements: we.value,
779
- onActionClick: $e
781
+ M(me, {
782
+ elements: be.value,
783
+ onActionClick: Re
780
784
  }, null, 8, ["elements"]),
781
- oe.value.length > 0 ? (d(), ue(J(Fe), {
785
+ oe.value.length > 0 ? (d(), de(J(Be), {
782
786
  key: 0,
783
- data: A.value,
784
- "onUpdate:data": t[0] || (t[0] = (l) => A.value = l),
787
+ data: C.value,
788
+ "onUpdate:data": t[0] || (t[0] = (l) => C.value = l),
785
789
  schema: oe.value,
786
790
  errors: x.value
787
- }, null, 8, ["data", "schema", "errors"])) : J(a) ? (d(), h("div", st, [
788
- s("p", null, "Loading " + N(D.value) + " data...", 1)
791
+ }, null, 8, ["data", "schema", "errors"])) : J(a) ? (d(), h("div", it, [
792
+ c("p", null, "Loading " + N(A.value) + " data...", 1)
789
793
  ])) : (d(), h("div", ct, [...t[2] || (t[2] = [
790
- s("p", null, "Initializing Stonecrop...", -1)
794
+ c("p", null, "Initializing Stonecrop...", -1)
791
795
  ])])),
792
- M(he, { breadcrumbs: be.value }, null, 8, ["breadcrumbs"]),
793
- M(me, {
794
- "is-open": w.value,
795
- search: ke,
796
+ M(ye, { breadcrumbs: ke.value }, null, 8, ["breadcrumbs"]),
797
+ M(he, {
798
+ "is-open": g.value,
799
+ search: Ce,
796
800
  placeholder: "Type a command or search...",
797
- onSelect: Ce,
798
- onClose: t[1] || (t[1] = (l) => w.value = !1)
801
+ onSelect: Ae,
802
+ onClose: t[1] || (t[1] = (l) => g.value = !1)
799
803
  }, {
800
804
  title: B(({ result: l }) => [
801
805
  H(N(l.title), 1)
@@ -807,16 +811,16 @@ const Be = { class: "action-menu-icon" }, Oe = { class: "action-element-header"
807
811
  }, 8, ["is-open"])
808
812
  ]));
809
813
  }
810
- }), mt = {
811
- install: (c) => {
812
- c.component("ActionSet", pe), c.component("CommandPalette", me), c.component("Desktop", it), c.component("SheetNav", he);
814
+ }), ht = {
815
+ install: (s) => {
816
+ s.component("ActionSet", me), s.component("CommandPalette", he), s.component("Desktop", ut), s.component("SheetNav", ye);
813
817
  }
814
818
  };
815
819
  export {
816
- pe as ActionSet,
817
- me as CommandPalette,
818
- it as Desktop,
819
- he as SheetNav,
820
- mt as StonecropDesktop
820
+ me as ActionSet,
821
+ he as CommandPalette,
822
+ ut as Desktop,
823
+ ye as SheetNav,
824
+ ht as StonecropDesktop
821
825
  };
822
826
  //# sourceMappingURL=desktop.js.map