@wssto2/vue-core 0.4.23 → 0.4.25

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/{Activity-Cu_mAn_m.js → Activity-CI-l_OFl.js} +1 -1
  3. package/dist/{Changes-DW_3-MwX.js → Changes-BdR0R20V.js} +1 -1
  4. package/dist/{DeadLetters-CpcMccCc.js → DeadLetters-CRTeoZS1.js} +1 -1
  5. package/dist/FormErrors.vue_vue_type_script_setup_true_lang-DGOSc-PS.js +295 -0
  6. package/dist/{FormView.vue_vue_type_script_setup_true_lang-CbvMRBOc.js → FormView.vue_vue_type_script_setup_true_lang-BUrYkjmF.js} +1 -1
  7. package/dist/{General-Dbc3qDRz.js → General-hdmVP72B.js} +3 -3
  8. package/dist/{NewRolePage-DPHFJ0I8.js → NewRolePage-BPeKasOp.js} +2 -2
  9. package/dist/PhotoViewer.vue_vue_type_script_setup_true_lang-CY5EZiyK.js +433 -0
  10. package/dist/{ProfilePage-Cc7eiyV2.js → ProfilePage-Dq9lcO5O.js} +3 -3
  11. package/dist/{RoleEditor.vue_vue_type_script_setup_true_lang-2fpYYCXj.js → RoleEditor.vue_vue_type_script_setup_true_lang-B6g2760V.js} +3 -3
  12. package/dist/{RolePage-C0jmkQkO.js → RolePage-BYH-0fVI.js} +3 -3
  13. package/dist/{RolesPage-eb4gqxdW.js → RolesPage-BRm5xDw7.js} +1 -1
  14. package/dist/{Sessions-DSDcj8Yd.js → Sessions-B1eKG_I2.js} +1 -1
  15. package/dist/{SettingsPage-BF7MW1GH.js → SettingsPage-0P38Ty4w.js} +3 -3
  16. package/dist/{SignIn-BR8-RVIk.js → SignIn-Dp8Ji0_r.js} +1 -1
  17. package/dist/{SignInPage-Dcws582A.js → SignInPage-CiStJboK.js} +2 -2
  18. package/dist/{SignIns-3u7YgKqh.js → SignIns-Bo7R2Coi.js} +1 -1
  19. package/dist/{UserRecord-AtZIwCO9.js → UserRecord-DGq_PPy1.js} +3 -3
  20. package/dist/{UsersList-1IeQnvOL.js → UsersList-BulNu4aE.js} +3 -3
  21. package/dist/access/index.js +1 -1
  22. package/dist/form/CommandDialog.vue.d.ts +6 -0
  23. package/dist/form/index.js +9 -9
  24. package/dist/form/useForm.d.ts +5 -1
  25. package/dist/form/useRecordDialog.d.ts +2 -2
  26. package/dist/identity/index.js +1 -1
  27. package/dist/{index--CxZ33h0.js → index-BmowiT1y.js} +12 -12
  28. package/dist/{index-Du3Ti2Zp.js → index-Yy28omu6.js} +4 -4
  29. package/dist/{index-DBTK_iMB.js → index-tnSTp0cM.js} +2 -2
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.js +1 -1
  32. package/dist/notifications/index.js +1 -1
  33. package/dist/overlay/PhotoViewer.vue.d.ts +4 -3
  34. package/dist/overlay/PhotoViewerAction.vue.d.ts +22 -0
  35. package/dist/overlay/index.d.ts +1 -0
  36. package/dist/overlay/index.js +47 -23
  37. package/dist/{status-QOGPjIHu.js → status-Bh3-Cg7o.js} +1 -1
  38. package/dist/styles.css +1 -1
  39. package/dist/{useCommand-CT1RF_IB.js → useCommand-Cj-APj-P.js} +53 -50
  40. package/dist/{useResourceForm-CQuniKhd.js → useResourceForm-tGYTfKhH.js} +1 -1
  41. package/package.json +1 -1
  42. package/dist/FormErrors.vue_vue_type_script_setup_true_lang-4WQz-TYS.js +0 -286
  43. package/dist/PhotoViewer.vue_vue_type_script_setup_true_lang-QPCW3Xi6.js +0 -411
@@ -1,30 +1,32 @@
1
- import { nextTick as f, defineComponent as C, useTemplateRef as v, ref as b, watch as L, onBeforeUnmount as N, computed as q, openBlock as p, createElementBlock as D, Fragment as z, createVNode as S, unref as y, createSlots as F, withCtx as $, createElementVNode as V, toDisplayString as A, createCommentVNode as h, renderSlot as x, createBlock as O } from "vue";
2
- import { useI18n as I } from "vue-i18n";
1
+ import { nextTick as f, defineComponent as N, useTemplateRef as v, ref as b, provide as q, computed as L, watch as D, onBeforeUnmount as z, openBlock as p, createElementBlock as S, Fragment as F, createVNode as $, unref as y, createSlots as V, withCtx as h, createElementVNode as A, toDisplayString as O, createCommentVNode as x, renderSlot as E, createBlock as I } from "vue";
2
+ import { useI18n as K } from "vue-i18n";
3
3
  import { f as R } from "./useDialog-CXR3hN0G.js";
4
4
  import { _ as U } from "./Modal.vue_vue_type_script_setup_true_lang-DpBb8ans.js";
5
5
  import { _ as G } from "./AlertDialog.vue_vue_type_script_setup_true_lang-whA4WLdl.js";
6
- import { D as K } from "./useWaitStatus-fsacMl4W.js";
7
- import { _ as M, u as P } from "./FormErrors.vue_vue_type_script_setup_true_lang-4WQz-TYS.js";
8
- import { a as W } from "./leaveGuard-Cc8yeLxM.js";
6
+ import { D as M } from "./useWaitStatus-fsacMl4W.js";
7
+ import { d as P } from "./control-B4SdblL6.js";
8
+ import { _ as W, u as Y } from "./FormErrors.vue_vue_type_script_setup_true_lang-DGOSc-PS.js";
9
+ import { a as j } from "./leaveGuard-Cc8yeLxM.js";
9
10
  const c = "input:not([type=hidden]):not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex='-1'])";
10
- async function Y(t = document, r) {
11
- const e = [...t.querySelectorAll("[data-field-error]")], n = e.find((o) => o.matches(c) || o.querySelector(c)) ?? e[0];
12
- if (!n) return !1;
13
- const i = r?.sections.value.find((o) => o.element.contains(n));
11
+ async function H(t = document, r) {
12
+ const e = [...t.querySelectorAll("[data-field-error]")], o = e.find((n) => n.matches(c) || n.querySelector(c)) ?? e[0];
13
+ if (!o) return !1;
14
+ const i = r?.sections.value.find((n) => n.element.contains(o));
14
15
  i && (await r?.scrollTo(i.id, { updateUrl: !1 }), await f());
15
- const l = n.matches(c) ? n : n.querySelector(c);
16
- return (l ?? n).scrollIntoView?.({ block: "center" }), (l ?? n).focus({ preventScroll: !0 }), !0;
16
+ const l = o.matches(c) ? o : o.querySelector(c);
17
+ return (l ?? o).scrollIntoView?.({ block: "center" }), (l ?? o).focus({ preventScroll: !0 }), !0;
17
18
  }
18
- const se = (t) => ({ "data-field-key": t }), j = {
19
+ const le = (t) => ({ "data-field-key": t }), J = {
19
20
  key: 0,
20
21
  class: "text-body text-content-muted"
21
- }, ne = /* @__PURE__ */ C({
22
+ }, re = /* @__PURE__ */ N({
22
23
  __name: "CommandDialog",
23
24
  props: {
24
25
  command: {},
25
26
  title: {},
26
27
  subtitle: { default: void 0 },
27
28
  confirmLabel: {},
29
+ editable: { type: Boolean, default: !0 },
28
30
  confirmDisabled: { type: Boolean, default: !1 },
29
31
  doneLabel: { default: void 0 },
30
32
  busyLabel: { default: void 0 },
@@ -34,10 +36,11 @@ const se = (t) => ({ "data-field-key": t }), j = {
34
36
  },
35
37
  emits: ["done"],
36
38
  setup(t, { emit: r }) {
37
- const e = t, n = r, { t: i } = I(), l = v("modal"), o = v("body"), a = b(!1);
39
+ const e = t, o = r, { t: i } = K(), l = v("modal"), n = v("body"), a = b(!1);
38
40
  let u = null;
39
- const { confirmDiscard: E } = W(() => e.command.open.value && e.command.form.dirty.value);
40
- L(() => e.command.open.value, (s) => {
41
+ q(P, L(() => e.editable));
42
+ const { confirmDiscard: B } = j(() => e.editable && e.command.open.value && e.command.form.dirty.value);
43
+ D(() => e.command.open.value, (s) => {
41
44
  s ? (a.value = !1, l.value?.present()) : l.value?.dismiss();
42
45
  });
43
46
  async function w(s = {}) {
@@ -45,67 +48,67 @@ const se = (t) => ({ "data-field-key": t }), j = {
45
48
  }
46
49
  async function g(s, d = {}) {
47
50
  if (s.status === "failed") {
48
- s.failure.kind === "invalid" && await f().then(() => Y(o.value ?? document));
51
+ s.failure.kind === "invalid" && await f().then(() => H(n.value ?? document));
49
52
  return;
50
53
  }
51
54
  if (s.status !== "aborted") {
52
- if (n("done"), d.addAnother) {
53
- e.command.present(), await f(), R(o.value)[0]?.focus();
55
+ if (o("done"), d.addAnother) {
56
+ e.command.present(), await f(), R(n.value)[0]?.focus();
54
57
  return;
55
58
  }
56
- a.value = !0, u = setTimeout(() => e.command.dismiss(), K);
59
+ a.value = !0, u = setTimeout(() => e.command.dismiss(), M);
57
60
  }
58
61
  }
59
62
  const k = v("ask"), m = b(null);
60
- L(() => e.command.question?.value, (s) => {
63
+ D(() => e.command.question?.value, (s) => {
61
64
  s && (m.value = s, f(() => k.value?.present()));
62
65
  });
63
66
  const T = async () => {
64
67
  e.command.answer && await g(await e.command.answer(!0));
65
68
  };
66
- N(() => {
69
+ z(() => {
67
70
  u && clearTimeout(u);
68
71
  });
69
- const B = q(() => e.command.form.submitting.value ? "processing" : a.value ? "done" : "idle");
70
- return (s, d) => (p(), D(z, null, [
71
- S(U, {
72
+ const C = L(() => e.command.form.submitting.value ? "processing" : a.value ? "done" : "idle");
73
+ return (s, d) => (p(), S(F, null, [
74
+ $(U, {
72
75
  ref_key: "modal",
73
76
  ref: l,
74
77
  size: e.size,
75
78
  grouped: "",
76
79
  title: e.title,
77
80
  subtitle: e.subtitle,
78
- "before-dismiss": y(E),
79
- "primary-label": e.confirmLabel,
81
+ "before-dismiss": y(B),
82
+ "primary-label": e.editable ? e.confirmLabel : void 0,
80
83
  "primary-disabled": e.confirmDisabled,
81
- status: B.value,
84
+ status: C.value,
82
85
  "processing-label": e.busyLabel ?? y(i)("core.actions.saving"),
83
86
  "done-label": e.doneLabel ?? y(i)("core.actions.saved"),
84
87
  onPrimary: d[0] || (d[0] = (_) => w()),
85
88
  onDismissed: d[1] || (d[1] = (_) => e.command.dismiss())
86
- }, F({
87
- default: $(() => [
88
- V("div", {
89
+ }, V({
90
+ default: h(() => [
91
+ A("div", {
89
92
  ref_key: "body",
90
- ref: o,
93
+ ref: n,
91
94
  class: "flex min-w-0 flex-col gap-group-gap",
92
95
  "data-test": "command-dialog"
93
96
  }, [
94
- e.message ? (p(), D("p", j, A(e.message), 1)) : h("", !0),
95
- S(M, {
97
+ e.message ? (p(), S("p", J, O(e.message), 1)) : x("", !0),
98
+ $(W, {
96
99
  form: e.command.form,
97
100
  label: e.fieldLabel,
98
- scope: o.value
101
+ scope: n.value
99
102
  }, null, 8, ["form", "label", "scope"]),
100
- x(s.$slots, "default")
103
+ E(s.$slots, "default")
101
104
  ], 512)
102
105
  ]),
103
106
  _: 2
104
107
  }, [
105
- s.$slots.actions ? {
108
+ e.editable && s.$slots.actions ? {
106
109
  name: "actions",
107
- fn: $(() => [
108
- x(s.$slots, "actions", {
110
+ fn: h(() => [
111
+ E(s.$slots, "actions", {
109
112
  run: w,
110
113
  busy: e.command.form.submitting.value
111
114
  })
@@ -113,7 +116,7 @@ const se = (t) => ({ "data-field-key": t }), j = {
113
116
  key: "0"
114
117
  } : void 0
115
118
  ]), 1032, ["size", "title", "subtitle", "before-dismiss", "primary-label", "primary-disabled", "status", "processing-label", "done-label"]),
116
- m.value ? (p(), O(G, {
119
+ m.value ? (p(), I(G, {
117
120
  key: 0,
118
121
  ref_key: "ask",
119
122
  ref: k,
@@ -124,19 +127,19 @@ const se = (t) => ({ "data-field-key": t }), j = {
124
127
  icon: m.value.icon,
125
128
  action: T,
126
129
  onDismissed: d[2] || (d[2] = (_) => void e.command.answer?.(!1))
127
- }, null, 8, ["title", "message", "confirm-label", "tone", "icon"])) : h("", !0)
130
+ }, null, 8, ["title", "message", "confirm-label", "tone", "icon"])) : x("", !0)
128
131
  ], 64));
129
132
  }
130
133
  });
131
- function oe(t) {
132
- const r = P(t), e = b(!1), n = () => typeof t.defaults == "function" ? t.defaults() : t.defaults, i = b(null);
134
+ function ie(t) {
135
+ const r = Y(t), e = b(!1), o = () => typeof t.defaults == "function" ? t.defaults() : t.defaults, i = b(null);
133
136
  async function l() {
134
137
  return await r.submit(t.run, {
135
138
  // The page updating itself after the call is the refresh: its failure is "saved, but could not be read back".
136
139
  refresh: t.done ? (u) => t.done?.(u) : void 0
137
140
  });
138
141
  }
139
- async function o() {
142
+ async function n() {
140
143
  const a = t.ask ? r.validate() : null, u = a === null ? null : t.ask?.(a) ?? null;
141
144
  return u ? (i.value = u, { status: "aborted" }) : l();
142
145
  }
@@ -144,12 +147,12 @@ function oe(t) {
144
147
  form: r,
145
148
  open: e,
146
149
  present(a) {
147
- r.hydrate({ ...n(), ...a }), e.value = !0;
150
+ r.hydrate({ ...o(), ...a }), e.value = !0;
148
151
  },
149
152
  dismiss() {
150
153
  e.value = !1;
151
154
  },
152
- run: o,
155
+ run: n,
153
156
  question: i,
154
157
  async answer(a) {
155
158
  return i.value = null, a ? l() : { status: "aborted" };
@@ -162,8 +165,8 @@ function oe(t) {
162
165
  };
163
166
  }
164
167
  export {
165
- ne as _,
166
- se as a,
167
- Y as f,
168
- oe as u
168
+ re as _,
169
+ le as a,
170
+ H as f,
171
+ ie as u
169
172
  };
@@ -1,5 +1,5 @@
1
1
  import { shallowRef as v, watch as m, computed as f } from "vue";
2
- import { u as i, c as h } from "./FormErrors.vue_vue_type_script_setup_true_lang-4WQz-TYS.js";
2
+ import { u as i, c as h } from "./FormErrors.vue_vue_type_script_setup_true_lang-DGOSc-PS.js";
3
3
  function b(u) {
4
4
  const t = i(u), r = v(null), s = v(!1);
5
5
  let n = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wssto2/vue-core",
3
- "version": "0.4.23",
3
+ "version": "0.4.25",
4
4
  "goCore": "v1.7.0",
5
5
  "description": "Shared Vue 3 library for go-core applications: app shell, list / record / form pages and their controls.",
6
6
  "keywords": [
@@ -1,286 +0,0 @@
1
- var Q = Object.defineProperty;
2
- var X = (s, e, t) => e in s ? Q(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var $ = (s, e, t) => X(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { shallowRef as M, computed as w, toRaw as Z, reactive as K, ref as Y, watch as ee, nextTick as te, toValue as re, defineComponent as se, unref as k, openBlock as b, createBlock as ne, withCtx as ae, createElementBlock as y, toDisplayString as O, createCommentVNode as _, Fragment as I, createElementVNode as W, normalizeClass as le, renderList as ie, createTextVNode as U } from "vue";
5
- import { useI18n as G } from "vue-i18n";
6
- import { i as ue, a as q } from "./error-CD7x0Jrz.js";
7
- import { d as oe } from "./describeError-B-NMa--w.js";
8
- import { _ as ce } from "./Banner.vue_vue_type_script_setup_true_lang-DSStj_5z.js";
9
- class fe {
10
- constructor() {
11
- $(this, "messages", M({}));
12
- /** How many fields have a message. */
13
- $(this, "count", w(() => Object.keys(this.messages.value).length));
14
- }
15
- /** Replaces everything. Empty lists are dropped. */
16
- set(e) {
17
- this.messages.value = Object.fromEntries(Object.entries(e).filter(([, t]) => t.length > 0).map(([t, n]) => [t, [...n]]));
18
- }
19
- add(e, t) {
20
- this.messages.value = { ...this.messages.value, [e]: [...this.messages.value[e] ?? [], t] };
21
- }
22
- /** Clears one field (and its nested paths), or everything. */
23
- clear(e) {
24
- if (e === void 0) {
25
- this.count.value > 0 && (this.messages.value = {});
26
- return;
27
- }
28
- const t = Object.fromEntries(Object.entries(this.messages.value).filter(([n]) => n !== e && !n.startsWith(`${e}.`)));
29
- Object.keys(t).length !== this.count.value && (this.messages.value = t);
30
- }
31
- /** Whether the field, or a value inside it (`items.0.quantity` for `items`), has a message. */
32
- has(e) {
33
- return this.first(e) !== void 0 || Object.keys(this.messages.value).some((t) => t.startsWith(`${e}.`));
34
- }
35
- first(e) {
36
- return this.messages.value[e]?.[0];
37
- }
38
- all() {
39
- return this.messages.value;
40
- }
41
- }
42
- function d(s) {
43
- const e = Z(s);
44
- return e === null || typeof e != "object" ? e : e instanceof Date ? new Date(e.getTime()) : typeof Blob < "u" && e instanceof Blob ? e : Array.isArray(e) ? e.map(d) : Object.fromEntries(Object.entries(e).map(([t, n]) => [t, d(n)]));
45
- }
46
- function S(s, e) {
47
- const t = s, n = e;
48
- if (Object.is(t, n)) return !0;
49
- if (t === null || n === null || typeof t != "object" || typeof n != "object") return !1;
50
- if (t instanceof Date || n instanceof Date) return t instanceof Date && n instanceof Date && t.getTime() === n.getTime();
51
- if (Array.isArray(t) || Array.isArray(n))
52
- return Array.isArray(t) && Array.isArray(n) && t.length === n.length && t.every((l, m) => S(l, n[m]));
53
- if (typeof Blob < "u" && (t instanceof Blob || n instanceof Blob)) return !1;
54
- const a = (l) => Object.keys(l).filter((m) => l[m] !== void 0), c = a(t);
55
- return c.length === a(n).length && c.every((l) => S(t[l], n[l]));
56
- }
57
- function H(s) {
58
- const e = {};
59
- for (const t of s) {
60
- const n = t.path.map(String).join(".");
61
- (e[n] ?? (e[n] = [])).push(t.message);
62
- }
63
- return e;
64
- }
65
- const de = (s) => s.split(".")[0] ?? s, L = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
66
- function _e(s) {
67
- const { t: e } = G(), t = s.describeFieldError ?? oe(), a = K(d(typeof s.defaults == "function" ? s.defaults() : s.defaults)), c = M(d(a)), l = new fe(), m = Y(!1), f = M(null), A = w(() => !S(a, c.value));
68
- let E = null, T = L();
69
- function F(r) {
70
- const i = a;
71
- for (const u of Object.keys(i)) u in r || delete i[u];
72
- Object.assign(i, d(r));
73
- }
74
- function C() {
75
- l.clear(), f.value = null;
76
- }
77
- function D(r, i) {
78
- const u = q(i) ? i.requestId : null, o = s.failureMessage?.(r, i) ?? e(`core.form.failure.${r}`);
79
- return f.value = { kind: r, message: o, requestId: u, error: i };
80
- }
81
- function x(r, i = !1) {
82
- const { serverField: u } = s, o = t, j = i && u ? Object.entries(r).map(([v, h]) => [u(v), h]) : Object.entries(r);
83
- l.set(Object.fromEntries(o ? j.map(([v, h]) => [v, h.map((B) => o(B, v))]) : j));
84
- }
85
- function z() {
86
- if (l.clear(), !s.validator)
87
- return f.value = null, d(a);
88
- const r = s.validator.safeParse(d(a));
89
- return r.success ? (f.value = null, r.data) : (x(H(r.error.issues)), null);
90
- }
91
- function N(r) {
92
- if (l.clear(), !s.validator) return !0;
93
- const i = s.validator.safeParse(d(a));
94
- if (i.success) return !0;
95
- const u = Object.fromEntries(Object.entries(H(i.error.issues)).filter(([o]) => r.includes(de(o))));
96
- return x(u), Object.keys(u).length === 0;
97
- }
98
- function J(r) {
99
- if (!q(r)) return "failed";
100
- switch (r.kind) {
101
- case "validation":
102
- return "invalid";
103
- case "conflict":
104
- return "conflict";
105
- case "forbidden":
106
- return "forbidden";
107
- case "unauthorized":
108
- return "unauthorized";
109
- case "network":
110
- return "offline";
111
- default:
112
- return "failed";
113
- }
114
- }
115
- async function P(r, i, u, o) {
116
- if (E) return E;
117
- const v = (async () => {
118
- f.value = null;
119
- const h = r();
120
- if (h === null) return { status: "failed", failure: D("invalid", null) };
121
- const B = d(a);
122
- let p;
123
- m.value = !0;
124
- try {
125
- p = await i(h, { idempotencyKey: T });
126
- } catch (g) {
127
- if (m.value = !1, ue(g)) return { status: "aborted" };
128
- const R = J(g);
129
- return R === "invalid" && q(g) && x(g.fields, !0), { status: "failed", failure: D(R, g) };
130
- }
131
- const V = o?.hydrateFrom?.(p) ?? null;
132
- V ? (F(V), c.value = d(V), l.clear()) : u(p, B);
133
- try {
134
- await o?.refresh?.(p);
135
- } catch (g) {
136
- return D("refresh", g), { status: "saved-refresh-failed", value: p, error: g };
137
- } finally {
138
- m.value = !1;
139
- }
140
- return { status: "saved", value: p };
141
- })().finally(() => {
142
- E = null, T = L();
143
- });
144
- return E = v, v;
145
- }
146
- return {
147
- values: a,
148
- errors: l,
149
- dirty: A,
150
- submitting: m,
151
- failure: f,
152
- bind(r) {
153
- return {
154
- get modelValue() {
155
- return a[r];
156
- },
157
- "onUpdate:modelValue"(i) {
158
- a[r] = i, l.clear(r);
159
- },
160
- get error() {
161
- return l.first(r);
162
- },
163
- "data-field-key": r
164
- };
165
- },
166
- bindMonthYear(r, i) {
167
- const u = a;
168
- return {
169
- get month() {
170
- return u[r] ?? null;
171
- },
172
- get year() {
173
- return u[i] ?? null;
174
- },
175
- "onUpdate:month"(o) {
176
- u[r] = o, l.clear(r);
177
- },
178
- "onUpdate:year"(o) {
179
- u[i] = o, l.clear(i);
180
- },
181
- get error() {
182
- return l.first(r) ?? l.first(i);
183
- },
184
- "data-field-key": `${r} ${i}`
185
- };
186
- },
187
- hydrate(r) {
188
- F(r), c.value = d(r), C();
189
- },
190
- reset() {
191
- F(c.value), C();
192
- },
193
- markClean() {
194
- c.value = d(a);
195
- },
196
- validate: z,
197
- check: N,
198
- submit: (r, i) => P(z, r, (u, o) => c.value = o, i),
199
- submitFields: (r, i, u) => P(
200
- () => N(r) ? Object.fromEntries(r.map((o) => [o, d(a[o])])) : null,
201
- i,
202
- (o, j) => {
203
- const v = d(c.value);
204
- for (const h of r) v[h] = d(j[h]);
205
- c.value = v;
206
- },
207
- u
208
- ),
209
- dismissFailure() {
210
- f.value = null;
211
- }
212
- };
213
- }
214
- function me(s) {
215
- const e = Y([]);
216
- return ee(
217
- () => s.form.errors.all(),
218
- async (t) => {
219
- await te();
220
- const n = re(s.root) ?? document, a = new Set([...n.querySelectorAll("[data-field-key]")].flatMap((l) => (l.getAttribute("data-field-key") ?? "").split(/\s+/))), c = (l) => l.split(".").some((m, f, A) => a.has(A.slice(0, f + 1).join(".")));
221
- e.value = Object.entries(t).flatMap(([l, m]) => m[0] && !c(l) ? [{ field: l, message: m[0] }] : []);
222
- },
223
- { immediate: !0 }
224
- ), w(() => e.value);
225
- }
226
- const ve = {
227
- key: 0,
228
- class: "text-footnote font-medium"
229
- }, he = {
230
- class: "mt-1 list-inside list-disc text-footnote",
231
- "data-test": "form-errors-hidden"
232
- }, ge = {
233
- key: 2,
234
- class: "mt-1 text-caption text-content-muted"
235
- }, we = /* @__PURE__ */ se({
236
- __name: "FormErrors",
237
- props: {
238
- form: {},
239
- label: { type: Function, default: (s) => s },
240
- scope: { default: null }
241
- },
242
- setup(s) {
243
- const e = s, { t } = G(), n = me({
244
- get form() {
245
- return e.form;
246
- },
247
- root: () => e.scope
248
- }), a = w(() => e.form.failure.value), c = w(() => a.value?.kind === "conflict" || a.value?.kind === "refresh" ? "warning" : "critical");
249
- return (l, m) => a.value || k(n).length ? (b(), ne(ce, {
250
- key: 0,
251
- tone: a.value ? c.value : "warning",
252
- "data-test": "form-errors"
253
- }, {
254
- default: ae(() => [
255
- a.value ? (b(), y("p", ve, O(a.value.message), 1)) : _("", !0),
256
- k(n).length ? (b(), y(I, { key: 1 }, [
257
- W("p", {
258
- class: le(["text-footnote", a.value ? "mt-1" : "font-medium"])
259
- }, O(k(t)("core.form.errors.hidden_title")), 3),
260
- W("ul", he, [
261
- (b(!0), y(I, null, ie(k(n), (f) => (b(), y("li", {
262
- key: f.field
263
- }, [
264
- U(O(f.field ? e.label(f.field) : ""), 1),
265
- f.field ? (b(), y(I, { key: 0 }, [
266
- U(": ")
267
- ], 64)) : _("", !0),
268
- U(O(f.message), 1)
269
- ]))), 128))
270
- ])
271
- ], 64)) : _("", !0),
272
- a.value?.requestId ? (b(), y("p", ge, O(k(t)("core.form.errors.request", { id: a.value.requestId })), 1)) : _("", !0)
273
- ]),
274
- _: 1
275
- }, 8, ["tone"])) : _("", !0);
276
- }
277
- });
278
- export {
279
- fe as E,
280
- we as _,
281
- me as a,
282
- d as c,
283
- de as f,
284
- S as s,
285
- _e as u
286
- };