@wssto2/vue-core 0.4.14 → 0.4.16

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 (98) hide show
  1. package/dist/{ActionRow.vue_vue_type_script_setup_true_lang-LlfIPWsJ.js → ActionRow.vue_vue_type_script_setup_true_lang-DOjn7fqy.js} +1 -1
  2. package/dist/{Activity-BdSvn0GP.js → Activity-CVO3sJwy.js} +6 -6
  3. package/dist/{Changes-BQO--N9F.js → Changes-Bzvl3cEx.js} +5 -5
  4. package/dist/{CollectionPage.vue_vue_type_script_setup_true_lang-DkpFEHUw.js → CollectionPage.vue_vue_type_script_setup_true_lang-CD5zZ29o.js} +2 -2
  5. package/dist/DateField.vue_vue_type_script_setup_true_lang-BufoFwVQ.js +278 -0
  6. package/dist/{DeadLetters-OmeiADEi.js → DeadLetters-DmwUtgf9.js} +4 -4
  7. package/dist/FormErrors.vue_vue_type_script_setup_true_lang-DWcVKZM3.js +285 -0
  8. package/dist/{FormGroup.vue_vue_type_script_setup_true_lang-DG2zdG_a.js → FormGroup.vue_vue_type_script_setup_true_lang-BokxZ7LU.js} +1 -1
  9. package/dist/{FormView.vue_vue_type_script_setup_true_lang-cr0xNDXP.js → FormView.vue_vue_type_script_setup_true_lang-Dz5TZt92.js} +2 -2
  10. package/dist/{General-CBwFLiKQ.js → General-CUEjJBD4.js} +10 -10
  11. package/dist/{NewRolePage-CblUW2gA.js → NewRolePage-Cyn-oV6r.js} +3 -3
  12. package/dist/NumberField.vue_vue_type_script_setup_true_lang-a8kN3A7k.js +150 -0
  13. package/dist/{ProfilePage-BOoDDbmB.js → ProfilePage-I74SQBFO.js} +41 -41
  14. package/dist/{RoleEditor.vue_vue_type_script_setup_true_lang-BCE5yrwy.js → RoleEditor.vue_vue_type_script_setup_true_lang-Ce6wjptT.js} +44 -44
  15. package/dist/{RolePage-xDsFL_eC.js → RolePage-DWQP3qQl.js} +8 -8
  16. package/dist/{RolesPage-C39wsF6X.js → RolesPage-BeEsHIQ2.js} +5 -5
  17. package/dist/SegmentedField.vue_vue_type_script_setup_true_lang-BMBkEmxr.js +81 -0
  18. package/dist/SelectField.vue_vue_type_script_setup_true_lang-C1Flb1hA.js +465 -0
  19. package/dist/{SessionList.vue_vue_type_script_setup_true_lang-D4k5QeWS.js → SessionList.vue_vue_type_script_setup_true_lang-DoUo68xE.js} +2 -2
  20. package/dist/{Sessions-m_i4aTfw.js → Sessions-D8IXcb5M.js} +4 -4
  21. package/dist/{SettingsPage-ktKvQQnE.js → SettingsPage-DRQP2nrH.js} +9 -9
  22. package/dist/{SignIn-CkoEixY4.js → SignIn-CAZkovhb.js} +6 -6
  23. package/dist/{SignInPage-DVcpFz3G.js → SignInPage-D-49oLY3.js} +3 -3
  24. package/dist/{SignIns-BnVAtncZ.js → SignIns-BtNfgMLc.js} +3 -3
  25. package/dist/SwitchField.vue_vue_type_script_setup_true_lang-0weBvsJf.js +87 -0
  26. package/dist/TextField.vue_vue_type_script_setup_true_lang-D3-R5XXG.js +292 -0
  27. package/dist/TextareaField.vue_vue_type_script_setup_true_lang-4wC3c0BM.js +91 -0
  28. package/dist/TimeField.vue_vue_type_script_setup_true_lang-pAdLPYXA.js +187 -0
  29. package/dist/{UserRecord-Cg69_mbU.js → UserRecord-BSbNuRFi.js} +10 -10
  30. package/dist/{UsersList-BFmBDGs7.js → UsersList-DPHxcaDm.js} +8 -8
  31. package/dist/access/index.js +1 -1
  32. package/dist/app/application.d.ts +8 -2
  33. package/dist/app/index.js +93 -93
  34. package/dist/collection/index.js +1 -1
  35. package/dist/control-B_Nwtmag.js +334 -0
  36. package/dist/{describeError-CvGmajU0.js → describeError-B-NMa--w.js} +12 -7
  37. package/dist/fieldMessages-DV6sESpn.js +25 -0
  38. package/dist/form/CardSelectField.vue.d.ts +2 -2
  39. package/dist/form/ChoiceChips.vue.d.ts +2 -2
  40. package/dist/form/ComboField.vue.d.ts +2 -2
  41. package/dist/form/DateField.vue.d.ts +10 -2
  42. package/dist/form/DateTimeField.vue.d.ts +10 -2
  43. package/dist/form/Field.vue.d.ts +2 -1
  44. package/dist/form/FileField.vue.d.ts +10 -2
  45. package/dist/form/FormErrors.vue.d.ts +1 -1
  46. package/dist/form/FormRow.vue.d.ts +3 -0
  47. package/dist/form/I18nField.vue.d.ts +10 -2
  48. package/dist/form/MoneyField.vue.d.ts +10 -2
  49. package/dist/form/MonthYearField.vue.d.ts +10 -2
  50. package/dist/form/MultiSelectField.vue.d.ts +2 -2
  51. package/dist/form/NumberField.vue.d.ts +25 -2
  52. package/dist/form/PhotoField.vue.d.ts +10 -2
  53. package/dist/form/SegmentedField.vue.d.ts +2 -2
  54. package/dist/form/SelectField.vue.d.ts +7 -8
  55. package/dist/form/SwitchField.vue.d.ts +3 -2
  56. package/dist/form/TextField.vue.d.ts +10 -2
  57. package/dist/form/TextareaField.vue.d.ts +10 -2
  58. package/dist/form/TimeField.vue.d.ts +10 -2
  59. package/dist/form/field.d.ts +12 -0
  60. package/dist/form/index.d.ts +3 -1
  61. package/dist/form/index.js +1167 -956
  62. package/dist/form/useForm.d.ts +2 -2
  63. package/dist/form/useHiddenFieldErrors.d.ts +23 -0
  64. package/dist/form/useSaveChrome.d.ts +8 -3
  65. package/dist/i18n/describeError.d.ts +8 -0
  66. package/dist/i18n/index.d.ts +3 -2
  67. package/dist/i18n/index.js +32 -28
  68. package/dist/identity/fieldMessages.d.ts +1 -1
  69. package/dist/identity/index.js +1 -1
  70. package/dist/{index-RNF5-9uf.js → index-Bq96L43f.js} +15 -15
  71. package/dist/{index-B416VXmR.js → index-CWeNiBX6.js} +2 -2
  72. package/dist/{index-KcCoCfr-.js → index-yKIOaisE.js} +10 -10
  73. package/dist/index.d.ts +1 -1
  74. package/dist/index.js +1 -1
  75. package/dist/notifications/index.js +1 -1
  76. package/dist/phone/PhoneField.vue.d.ts +1 -0
  77. package/dist/phone/index.js +66 -65
  78. package/dist/resource/index.js +1 -1
  79. package/dist/{routeResource-BwEFXzIX.js → routeResource-DlTsGTg_.js} +1 -1
  80. package/dist/state/index.js +1 -1
  81. package/dist/{status-OZUHZpWl.js → status-DzmySsWw.js} +1 -1
  82. package/dist/{useCommand-BkONMn3X.js → useCommand-B-N6HJOz.js} +1 -1
  83. package/dist/{useLoad-DuEsLECT.js → useLoad-M7V-AVwR.js} +1 -1
  84. package/dist/{useResourceForm-D1hIpwW5.js → useResourceForm-CP2lCwmD.js} +1 -1
  85. package/dist/useSaveChrome-7huA3FzR.js +26 -0
  86. package/package.json +1 -1
  87. package/dist/DateField.vue_vue_type_script_setup_true_lang-GVasv8ao.js +0 -255
  88. package/dist/FormErrors.vue_vue_type_script_setup_true_lang-BQb7wLT0.js +0 -276
  89. package/dist/NumberField.vue_vue_type_script_setup_true_lang-C7N5nq0P.js +0 -113
  90. package/dist/SegmentedField.vue_vue_type_script_setup_true_lang-BMqWlpsL.js +0 -58
  91. package/dist/SelectField.vue_vue_type_script_setup_true_lang-BJoAkBo2.js +0 -437
  92. package/dist/SwitchField.vue_vue_type_script_setup_true_lang-CM8yp9JQ.js +0 -64
  93. package/dist/TextField.vue_vue_type_script_setup_true_lang-B9dwVASU.js +0 -269
  94. package/dist/TextareaField.vue_vue_type_script_setup_true_lang-CqAWfABZ.js +0 -68
  95. package/dist/TimeField.vue_vue_type_script_setup_true_lang-DWfAUlnz.js +0 -164
  96. package/dist/control-7EP4tjYy.js +0 -313
  97. package/dist/fieldMessages-D_dpSe19.js +0 -25
  98. package/dist/useSaveChrome-DuWm0Czf.js +0 -25
@@ -1,255 +0,0 @@
1
- import { computed as f, defineComponent as X, useModel as Z, useTemplateRef as $, openBlock as y, createBlock as A, mergeProps as V, unref as l, withCtx as N, createElementBlock as C, Fragment as I, createVNode as w, createTextVNode as ee, toDisplayString as Q, createCommentVNode as E, createElementVNode as O, normalizeClass as te, mergeModels as re, mergeDefaults as oe, nextTick as Y } from "vue";
2
- import { useI18n as j } from "vue-i18n";
3
- import { _ as ae } from "./DateButton.vue_vue_type_script_setup_true_lang-EcqrfWKz.js";
4
- import { u as K } from "./format-B8mJm946.js";
5
- import { _ as ne } from "./Icon.vue_vue_type_script_lang-D7oC-d-S.js";
6
- import { u as le } from "./mediaQuery-CygcXmFW.js";
7
- import { _ as se } from "./Popover.vue_vue_type_script_setup_true_lang-Dx-tDhNE.js";
8
- import { c as ie, _ as de, f as ue, b as ce } from "./control-7EP4tjYy.js";
9
- import { e as T, f as B, m as G, g as H, h as me, j as fe, u as pe, k as be, _ as ve, l as ye, c as xe } from "./useTypedEntry-aTfPBAhw.js";
10
- const ke = ["d", "m", "y"];
11
- function he(o) {
12
- const r = o("2033-11-22"), e = { y: r.indexOf("2033") >= 0 ? r.indexOf("2033") : r.indexOf("33"), m: r.indexOf("11"), d: r.indexOf("22") };
13
- return e.y < 0 || e.m < 0 || e.d < 0 ? ke : ["d", "m", "y"].sort((t, a) => e[t] - e[a]);
14
- }
15
- const ge = (o) => o.trim().toLowerCase().replace(/\.+$/, "");
16
- function _e(o, r) {
17
- if (o.length === 4) return Number(o);
18
- if (o.length > 2) return null;
19
- const e = 2e3 + Number(o);
20
- return e > Number(r.slice(0, 4)) + 30 ? e - 100 : e;
21
- }
22
- function x(o, r) {
23
- const e = o.y === void 0 ? Number(r.slice(0, 4)) : _e(o.y, r), t = o.m === void 0 ? Number(r.slice(5, 7)) : Number(o.m);
24
- return e === null || o.d === void 0 ? null : G(e, t, Number(o.d));
25
- }
26
- function we(o, r) {
27
- const e = r.today ?? T(), t = ge(o);
28
- if (t === "") return null;
29
- const { words: a } = r;
30
- if (a.today.includes(t)) return e;
31
- if (a.tomorrow.includes(t)) return B(e, 1);
32
- if (a.yesterday.includes(t)) return B(e, -1);
33
- const d = /^([+-])\s*(\d{1,4})$/.exec(t);
34
- if (d) return B(e, Number(d[2]) * (d[1] === "-" ? -1 : 1));
35
- const i = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(t);
36
- if (i) return G(Number(i[1]), Number(i[2]), Number(i[3]));
37
- if (!/^[\d\s./-]+$/.test(t)) return null;
38
- const n = r.order, p = n.filter((v) => v !== "y");
39
- if (/^\d+$/.test(t)) {
40
- if (t.length <= 2) return x({ d: t }, e);
41
- if (t.length === 4) return x(M(p, [t.slice(0, 2), t.slice(2)]), e);
42
- if (t.length === 6 || t.length === 8) {
43
- const v = n.map((u) => u === "y" ? t.length - 4 : 2);
44
- let k = 0;
45
- const b = n.map((u, h) => [u, t.slice(k, k += v[h])]);
46
- return x(Object.fromEntries(b), e);
47
- }
48
- return null;
49
- }
50
- const m = t.split(/[^\d]+/).filter(Boolean);
51
- return m.length === 3 ? x(M(n, m), e) : m.length === 2 ? x(M(p, m), e) : m.length === 1 ? x({ d: m[0] }, e) : null;
52
- }
53
- function M(o, r) {
54
- return Object.fromEntries(o.map((e, t) => [e, r[t]]));
55
- }
56
- function Ue(o) {
57
- const r = o.trim().replace(/^(\d{4}-\d{2}-\d{2})T/, "$1 ").split(/\s+/).filter(Boolean), e = r[r.length - 1];
58
- if (e === void 0) return { date: null, time: null };
59
- if (!(e.includes(":") || r.length > 1 && /^\d{1,2}\.\d{2}$/.test(e))) return { date: r.join(" "), time: null };
60
- const a = r.slice(0, -1).join(" ");
61
- return { date: a === "" ? null : a, time: e };
62
- }
63
- function De(o, r, e) {
64
- const t = o(e), a = /\D+/.exec(t)?.[0].trim() ?? ".", d = /\D+$/.test(t) ? a : "", i = { d: String(Number(e.slice(8))), m: String(Number(e.slice(5, 7))), y: "" };
65
- return r.filter((n) => n !== "y").map((n) => i[n]).join(a) + d;
66
- }
67
- function $e(o) {
68
- const { t: r } = j(), e = K(), t = (n) => e.date(n), a = f(() => he(t)), d = f(() => ({
69
- today: [r("core.form.date.words.today").toLowerCase(), "today"],
70
- tomorrow: [r("core.form.date.words.tomorrow").toLowerCase(), "tomorrow"],
71
- yesterday: [r("core.form.date.words.yesterday").toLowerCase(), "yesterday"]
72
- }));
73
- return {
74
- placeholder: f(() => r("core.form.date.placeholder", { example: De(t, a.value, T()) })),
75
- /** The day a text means, or null. */
76
- parse: (n) => we(n, { order: a.value, words: d.value }),
77
- available: (n) => !H(n, o()),
78
- invalidMessage: () => r("core.form.date.invalid", { example: t(T()) }),
79
- unavailableMessage: () => r("core.form.date.unavailable")
80
- };
81
- }
82
- function Ne(o, r, e) {
83
- const { t } = j();
84
- return f(() => {
85
- const a = T();
86
- return (o() ?? me(r())).map((d) => {
87
- const i = fe(d, (n) => t(`core.form.date.${n.replace(/-/g, "_")}`), a);
88
- return { ...i, disabled: H(i.value, e()) };
89
- });
90
- });
91
- }
92
- const Ce = ["id", "name", "value", "placeholder", "disabled", "required", "aria-required", "aria-invalid", "aria-describedby"], Oe = ["aria-label", "onClick"], Te = { class: "flex flex-col gap-2.5" }, qe = {
93
- key: 0,
94
- class: "border-t border-border-separator pt-2.5"
95
- }, Pe = { class: "text-footnote text-content-muted" }, Re = /* @__PURE__ */ X({
96
- __name: "DateField",
97
- props: /* @__PURE__ */ re(/* @__PURE__ */ oe({
98
- label: {},
99
- hint: {},
100
- error: {},
101
- required: { type: Boolean },
102
- editable: { type: Boolean },
103
- disabled: { type: Boolean },
104
- lockedReason: {},
105
- presentation: {},
106
- name: {},
107
- min: {},
108
- max: {},
109
- disabledDates: { type: [Array, Function] },
110
- openOn: {},
111
- quickPicks: {}
112
- }, { ...ce, min: void 0, max: void 0, disabledDates: void 0, openOn: void 0, quickPicks: void 0 }), {
113
- modelValue: { default: null },
114
- modelModifiers: {}
115
- }),
116
- emits: ["update:modelValue"],
117
- setup(o, { expose: r }) {
118
- const e = o, t = Z(o, "modelValue"), { t: a } = j(), d = K(), i = le(), n = $("input"), p = $("popover"), m = $("calendar"), v = $("sheet"), k = f(() => ({ min: e.min, max: e.max, disabled: e.disabledDates })), b = $e(() => k.value), u = pe({
119
- model: t,
120
- display: (c) => d.date(c),
121
- parse: (c) => {
122
- const s = b.parse(c);
123
- return s ? b.available(s) ? { value: s } : { error: b.unavailableMessage() } : { error: b.invalidMessage() };
124
- }
125
- }), h = Ne(() => e.quickPicks, () => i.value, () => k.value), L = f(() => e.error || u.message.value), q = f(() => t.value ? d.date(t.value) : null), J = ie("date", () => L.value ? "error" : e.disabled ? "locked" : "rest"), z = f(() => u.typed.value ?? (be(t.value) ? t.value : null));
126
- async function P(c) {
127
- e.disabled || (p.value?.present(), c && (await Y(), await Y(), m.value?.focus()));
128
- }
129
- function W(c) {
130
- c.key === "Enter" ? (u.commit(), p.value?.dismiss()) : c.key === "ArrowDown" && (c.preventDefault(), P(!0));
131
- }
132
- function F(c, s) {
133
- u.set(c), s();
134
- }
135
- return r({ focus: () => n.value?.focus() }), (c, s) => (y(), A(de, V({ ...l(ue)(e), error: L.value }, {
136
- value: q.value,
137
- "value-style": "numeric"
138
- }), {
139
- default: N(({ id: S, describedby: U, invalid: R }) => [
140
- l(i) ? (y(), C(I, { key: 0 }, [
141
- w(ae, V({ id: S, "aria-describedby": U }, {
142
- disabled: e.disabled,
143
- invalid: R,
144
- placeholder: l(a)("core.form.select.choose"),
145
- onClick: s[0] || (s[0] = (g) => v.value?.present())
146
- }), {
147
- default: N(() => [
148
- q.value ? (y(), C(I, { key: 0 }, [
149
- ee(Q(q.value), 1)
150
- ], 64)) : E("", !0)
151
- ]),
152
- _: 1
153
- }, 16, ["disabled", "invalid", "placeholder"]),
154
- w(ve, {
155
- ref_key: "sheet",
156
- ref: v,
157
- title: e.label ?? l(a)("core.form.date.calendar"),
158
- mode: "date",
159
- "model-value": t.value,
160
- min: e.min,
161
- max: e.max,
162
- "disabled-dates": e.disabledDates,
163
- "open-on": e.openOn,
164
- shortcuts: l(h),
165
- clearable: !e.required,
166
- "onUpdate:modelValue": l(u).set
167
- }, null, 8, ["title", "model-value", "min", "max", "disabled-dates", "open-on", "shortcuts", "clearable", "onUpdate:modelValue"])
168
- ], 64)) : (y(), A(se, {
169
- key: 1,
170
- ref_key: "popover",
171
- ref: p,
172
- label: e.label ?? l(a)("core.form.date.calendar"),
173
- width: "lg",
174
- placement: "bottom-start",
175
- arrow: !1,
176
- autofocus: !1
177
- }, {
178
- trigger: N(({ attrs: g, presented: _ }) => [
179
- O("div", {
180
- class: te(["inline-flex max-w-full items-center gap-2", l(J)])
181
- }, [
182
- O("input", V({
183
- id: S,
184
- ref_key: "input",
185
- ref: n
186
- }, g, {
187
- type: "text",
188
- role: "combobox",
189
- autocomplete: "off",
190
- size: "16",
191
- name: e.name,
192
- value: l(u).text.value,
193
- placeholder: l(b).placeholder.value,
194
- disabled: e.disabled,
195
- required: e.required,
196
- "aria-required": e.required || void 0,
197
- "aria-invalid": R || void 0,
198
- "aria-describedby": U,
199
- class: "block min-h-7 min-w-0 border-0 bg-transparent py-1 pl-2.5 text-body tabular-nums text-content-strong placeholder:text-content-disabled focus:outline-none focus:ring-0 disabled:cursor-not-allowed",
200
- onInput: s[1] || (s[1] = (D) => l(u).input(D.target.value)),
201
- onBlur: s[2] || (s[2] = (D) => l(u).commit()),
202
- onKeydown: W,
203
- onClick: s[3] || (s[3] = (D) => P(!1))
204
- }), null, 16, Ce),
205
- e.disabled ? E("", !0) : (y(), C("button", {
206
- key: 0,
207
- type: "button",
208
- tabindex: "-1",
209
- "aria-label": l(a)("core.form.date.open"),
210
- class: "mr-2 flex shrink-0 cursor-pointer items-center text-content-link",
211
- onClick: (D) => _ ? p.value?.dismiss() : P(!0)
212
- }, [
213
- w(l(ne), {
214
- name: "calendarLine",
215
- size: 18
216
- })
217
- ], 8, Oe))
218
- ], 2)
219
- ]),
220
- default: N(({ dismiss: g }) => [
221
- O("div", Te, [
222
- w(ye, {
223
- ref_key: "calendar",
224
- ref: m,
225
- "model-value": z.value,
226
- min: e.min,
227
- max: e.max,
228
- "disabled-dates": e.disabledDates,
229
- "open-on": e.openOn,
230
- "month-picker": "",
231
- "onUpdate:modelValue": (_) => F(_, g)
232
- }, null, 8, ["model-value", "min", "max", "disabled-dates", "open-on", "onUpdate:modelValue"]),
233
- l(h).length > 0 ? (y(), C("div", qe, [
234
- w(xe, {
235
- items: l(h),
236
- selected: z.value,
237
- onPick: (_) => F(_, g)
238
- }, null, 8, ["items", "selected", "onPick"])
239
- ])) : E("", !0),
240
- O("p", Pe, Q(l(a)("core.form.date.keys")), 1)
241
- ])
242
- ]),
243
- _: 2
244
- }, 1032, ["label"]))
245
- ]),
246
- _: 1
247
- }, 16, ["value"]));
248
- }
249
- });
250
- export {
251
- Re as _,
252
- Ne as a,
253
- Ue as s,
254
- $e as u
255
- };
@@ -1,276 +0,0 @@
1
- var J = Object.defineProperty;
2
- var Q = (a, e, s) => e in a ? J(a, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[e] = s;
3
- var I = (a, e, s) => Q(a, typeof e != "symbol" ? e + "" : e, s);
4
- import { shallowRef as M, computed as x, toRaw as X, reactive as Z, ref as Y, defineComponent as K, watch as ee, nextTick as te, openBlock as b, createBlock as re, withCtx as se, createElementBlock as O, toDisplayString as A, createCommentVNode as E, Fragment as U, createElementVNode as P, normalizeClass as ae, unref as R, renderList as ne, createTextVNode as V } from "vue";
5
- import { useI18n as G } from "vue-i18n";
6
- import { i as le, a as q } from "./error-CD7x0Jrz.js";
7
- import { _ as ie } from "./Banner.vue_vue_type_script_setup_true_lang-DSStj_5z.js";
8
- class ue {
9
- constructor() {
10
- I(this, "messages", M({}));
11
- /** How many fields have a message. */
12
- I(this, "count", x(() => Object.keys(this.messages.value).length));
13
- }
14
- /** Replaces everything. Empty lists are dropped. */
15
- set(e) {
16
- this.messages.value = Object.fromEntries(Object.entries(e).filter(([, s]) => s.length > 0).map(([s, t]) => [s, [...t]]));
17
- }
18
- add(e, s) {
19
- this.messages.value = { ...this.messages.value, [e]: [...this.messages.value[e] ?? [], s] };
20
- }
21
- /** Clears one field (and its nested paths), or everything. */
22
- clear(e) {
23
- if (e === void 0) {
24
- this.count.value > 0 && (this.messages.value = {});
25
- return;
26
- }
27
- const s = Object.fromEntries(Object.entries(this.messages.value).filter(([t]) => t !== e && !t.startsWith(`${e}.`)));
28
- Object.keys(s).length !== this.count.value && (this.messages.value = s);
29
- }
30
- /** Whether the field, or a value inside it (`items.0.quantity` for `items`), has a message. */
31
- has(e) {
32
- return this.first(e) !== void 0 || Object.keys(this.messages.value).some((s) => s.startsWith(`${e}.`));
33
- }
34
- first(e) {
35
- return this.messages.value[e]?.[0];
36
- }
37
- all() {
38
- return this.messages.value;
39
- }
40
- }
41
- function f(a) {
42
- const e = X(a);
43
- 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(f) : Object.fromEntries(Object.entries(e).map(([s, t]) => [s, f(t)]));
44
- }
45
- function S(a, e) {
46
- const s = a, t = e;
47
- if (Object.is(s, t)) return !0;
48
- if (s === null || t === null || typeof s != "object" || typeof t != "object") return !1;
49
- if (s instanceof Date || t instanceof Date) return s instanceof Date && t instanceof Date && s.getTime() === t.getTime();
50
- if (Array.isArray(s) || Array.isArray(t))
51
- return Array.isArray(s) && Array.isArray(t) && s.length === t.length && s.every((c, d) => S(c, t[d]));
52
- if (typeof Blob < "u" && (s instanceof Blob || t instanceof Blob)) return !1;
53
- const l = (c) => Object.keys(c).filter((d) => c[d] !== void 0), o = l(s);
54
- return o.length === l(t).length && o.every((c) => S(s[c], t[c]));
55
- }
56
- function W(a) {
57
- const e = {};
58
- for (const s of a) {
59
- const t = s.path.map(String).join(".");
60
- (e[t] ?? (e[t] = [])).push(s.message);
61
- }
62
- return e;
63
- }
64
- const oe = (a) => a.split(".")[0] ?? a, L = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
65
- function ye(a) {
66
- const { t: e } = G(), t = Z(f(typeof a.defaults == "function" ? a.defaults() : a.defaults)), l = M(f(t)), o = new ue(), c = Y(!1), d = M(null), v = x(() => !S(t, l.value));
67
- let j = null, h = L();
68
- function y(r) {
69
- const n = t;
70
- for (const i of Object.keys(n)) i in r || delete n[i];
71
- Object.assign(n, f(r));
72
- }
73
- function D() {
74
- o.clear(), d.value = null;
75
- }
76
- function _(r, n) {
77
- const i = q(n) ? n.requestId : null, u = a.failureMessage?.(r, n) ?? e(`core.form.failure.${r}`);
78
- return d.value = { kind: r, message: u, requestId: i, error: n };
79
- }
80
- function B(r, n = !1) {
81
- const { translate: i, serverField: u } = a, w = n && u ? Object.entries(r).map(([m, g]) => [u(m), g]) : Object.entries(r);
82
- o.set(Object.fromEntries(i ? w.map(([m, g]) => [m, g.map((F) => i(F, m))]) : w));
83
- }
84
- function T() {
85
- if (o.clear(), !a.validator) return f(t);
86
- const r = a.validator.safeParse(f(t));
87
- return r.success ? r.data : (B(W(r.error.issues)), null);
88
- }
89
- function C(r) {
90
- if (o.clear(), !a.validator) return !0;
91
- const n = a.validator.safeParse(f(t));
92
- if (n.success) return !0;
93
- const i = Object.fromEntries(Object.entries(W(n.error.issues)).filter(([u]) => r.includes(oe(u))));
94
- return B(i), Object.keys(i).length === 0;
95
- }
96
- function H(r) {
97
- if (!q(r)) return "failed";
98
- switch (r.kind) {
99
- case "validation":
100
- return "invalid";
101
- case "conflict":
102
- return "conflict";
103
- case "forbidden":
104
- return "forbidden";
105
- case "unauthorized":
106
- return "unauthorized";
107
- case "network":
108
- return "offline";
109
- default:
110
- return "failed";
111
- }
112
- }
113
- async function z(r, n, i, u) {
114
- if (j) return j;
115
- const m = (async () => {
116
- d.value = null;
117
- const g = r();
118
- if (g === null) return { status: "failed", failure: _("invalid", null) };
119
- const F = f(t);
120
- let k;
121
- c.value = !0;
122
- try {
123
- k = await n(g, { idempotencyKey: h });
124
- } catch (p) {
125
- if (c.value = !1, le(p)) return { status: "aborted" };
126
- const N = H(p);
127
- return N === "invalid" && q(p) && B(p.fields, !0), { status: "failed", failure: _(N, p) };
128
- }
129
- const $ = u?.hydrateFrom?.(k) ?? null;
130
- $ ? (y($), l.value = f($), o.clear()) : i(k, F);
131
- try {
132
- await u?.refresh?.(k);
133
- } catch (p) {
134
- return _("refresh", p), { status: "saved-refresh-failed", value: k, error: p };
135
- } finally {
136
- c.value = !1;
137
- }
138
- return { status: "saved", value: k };
139
- })().finally(() => {
140
- j = null, h = L();
141
- });
142
- return j = m, m;
143
- }
144
- return {
145
- values: t,
146
- errors: o,
147
- dirty: v,
148
- submitting: c,
149
- failure: d,
150
- bind(r) {
151
- return {
152
- get modelValue() {
153
- return t[r];
154
- },
155
- "onUpdate:modelValue"(n) {
156
- t[r] = n, o.clear(r);
157
- },
158
- get error() {
159
- return o.first(r);
160
- },
161
- "data-field-key": r
162
- };
163
- },
164
- bindMonthYear(r, n) {
165
- const i = t;
166
- return {
167
- get month() {
168
- return i[r] ?? null;
169
- },
170
- get year() {
171
- return i[n] ?? null;
172
- },
173
- "onUpdate:month"(u) {
174
- i[r] = u, o.clear(r);
175
- },
176
- "onUpdate:year"(u) {
177
- i[n] = u, o.clear(n);
178
- },
179
- get error() {
180
- return o.first(r) ?? o.first(n);
181
- },
182
- "data-field-key": `${r} ${n}`
183
- };
184
- },
185
- hydrate(r) {
186
- y(r), l.value = f(r), D();
187
- },
188
- reset() {
189
- y(l.value), D();
190
- },
191
- markClean() {
192
- l.value = f(t);
193
- },
194
- validate: T,
195
- check: C,
196
- submit: (r, n) => z(T, r, (i, u) => l.value = u, n),
197
- submitFields: (r, n, i) => z(
198
- () => C(r) ? Object.fromEntries(r.map((u) => [u, f(t[u])])) : null,
199
- n,
200
- (u, w) => {
201
- const m = f(l.value);
202
- for (const g of r) m[g] = f(w[g]);
203
- l.value = m;
204
- },
205
- i
206
- ),
207
- dismissFailure() {
208
- d.value = null;
209
- }
210
- };
211
- }
212
- const ce = {
213
- key: 0,
214
- class: "text-footnote font-medium"
215
- }, fe = {
216
- class: "mt-1 list-inside list-disc text-footnote",
217
- "data-test": "form-errors-hidden"
218
- }, de = {
219
- key: 2,
220
- class: "mt-1 text-caption text-content-muted"
221
- }, be = /* @__PURE__ */ K({
222
- __name: "FormErrors",
223
- props: {
224
- form: {},
225
- label: { type: Function, default: (a) => a },
226
- scope: { default: null }
227
- },
228
- setup(a) {
229
- const e = a, { t: s } = G(), t = Y([]);
230
- ee(
231
- () => e.form.errors.all(),
232
- async (c) => {
233
- await te();
234
- const d = e.scope ?? document, v = new Set([...d.querySelectorAll("[data-field-key]")].flatMap((h) => (h.getAttribute("data-field-key") ?? "").split(/\s+/))), j = (h) => h.split(".").some((y, D, _) => v.has(_.slice(0, D + 1).join(".")));
235
- t.value = Object.entries(c).flatMap(([h, y]) => y[0] && !j(h) ? [{ field: h, message: y[0] }] : []);
236
- },
237
- { immediate: !0 }
238
- );
239
- const l = x(() => e.form.failure.value), o = x(() => l.value?.kind === "conflict" || l.value?.kind === "refresh" ? "warning" : "critical");
240
- return (c, d) => l.value || t.value.length ? (b(), re(ie, {
241
- key: 0,
242
- tone: l.value ? o.value : "warning",
243
- "data-test": "form-errors"
244
- }, {
245
- default: se(() => [
246
- l.value ? (b(), O("p", ce, A(l.value.message), 1)) : E("", !0),
247
- t.value.length ? (b(), O(U, { key: 1 }, [
248
- P("p", {
249
- class: ae(["text-footnote", l.value ? "mt-1" : "font-medium"])
250
- }, A(R(s)("core.form.errors.hidden_title")), 3),
251
- P("ul", fe, [
252
- (b(!0), O(U, null, ne(t.value, (v) => (b(), O("li", {
253
- key: v.field
254
- }, [
255
- V(A(v.field ? e.label(v.field) : ""), 1),
256
- v.field ? (b(), O(U, { key: 0 }, [
257
- V(": ")
258
- ], 64)) : E("", !0),
259
- V(A(v.message), 1)
260
- ]))), 128))
261
- ])
262
- ], 64)) : E("", !0),
263
- l.value?.requestId ? (b(), O("p", de, A(R(s)("core.form.errors.request", { id: l.value.requestId })), 1)) : E("", !0)
264
- ]),
265
- _: 1
266
- }, 8, ["tone"])) : E("", !0);
267
- }
268
- });
269
- export {
270
- ue as E,
271
- be as _,
272
- f as c,
273
- oe as f,
274
- S as s,
275
- ye as u
276
- };
@@ -1,113 +0,0 @@
1
- import { defineComponent as G, useModel as I, useTemplateRef as R, computed as _, ref as w, watch as F, openBlock as y, createBlock as S, mergeProps as W, unref as B, withCtx as $, createElementVNode as D, normalizeClass as A, createElementBlock as q, toDisplayString as N, createCommentVNode as M, mergeModels as E, mergeDefaults as O } from "vue";
2
- import { b as P } from "./controlSurface-t7OEFESJ.js";
3
- import { u as z } from "./format-B8mJm946.js";
4
- import { a as T, c as j, _ as H, f as J, b as K } from "./control-7EP4tjYy.js";
5
- function L(n) {
6
- const r = n.number(1234.5, { minimumFractionDigits: 1, maximumFractionDigits: 1, useGrouping: !0 }), e = /^\d(\D)\d/.exec(r)?.[1] ?? "";
7
- return { decimal: r.charAt(r.length - 2) || ".", group: e === "." || e === "," ? e : "" };
8
- }
9
- function Q(n, r) {
10
- const e = n.trim().startsWith("-"), t = n.replace(/[^\d.,]/g, "");
11
- if (t === "") return e ? void 0 : null;
12
- const c = [...t].filter((a) => a === "." || a === ",");
13
- let d = t, p = "";
14
- if (r.decimals > 0 && c.length > 0) {
15
- const a = Math.max(t.lastIndexOf("."), t.lastIndexOf(",")), m = t.charAt(a), f = t.slice(a + 1), s = t.includes(".") && t.includes(","), l = c.filter((k) => k === m).length > 1, h = !s && m === r.group && f.length === 3;
16
- (s || !l && !h) && (d = t.slice(0, a), p = f);
17
- }
18
- const g = (a) => a.replace(/\D/g, ""), v = +`${g(d) || "0"}.${g(p) || "0"}`;
19
- if (!Number.isFinite(v)) return;
20
- const u = Number(v.toFixed(r.decimals));
21
- return e ? -u || 0 : u;
22
- }
23
- const U = {
24
- key: 0,
25
- class: "shrink-0 text-footnote text-content-muted"
26
- }, X = ["id", "value", "name", "placeholder", "disabled", "required", "aria-required", "aria-invalid", "aria-describedby"], Y = {
27
- key: 1,
28
- class: "shrink-0 text-footnote text-content-muted"
29
- }, ie = /* @__PURE__ */ G({
30
- __name: "NumberField",
31
- props: /* @__PURE__ */ E(/* @__PURE__ */ O({
32
- label: {},
33
- hint: {},
34
- error: {},
35
- required: { type: Boolean },
36
- editable: { type: Boolean },
37
- disabled: { type: Boolean },
38
- lockedReason: {},
39
- presentation: {},
40
- name: {},
41
- decimals: {},
42
- negative: { type: Boolean },
43
- grouping: { type: Boolean },
44
- placeholder: {},
45
- prefix: {},
46
- suffix: {},
47
- width: {}
48
- }, { ...K, decimals: 0, negative: !1, grouping: !0, placeholder: void 0, prefix: void 0, suffix: void 0, width: "sm" }), {
49
- modelValue: { default: null },
50
- modelModifiers: {}
51
- }),
52
- emits: ["update:modelValue"],
53
- setup(n, { expose: r }) {
54
- const e = n, t = I(n, "modelValue"), c = z(), d = R("input"), p = !!T(), g = j("text", () => e.error ? "error" : e.disabled ? "locked" : "rest"), v = _(() => p ? P(e.width) : "w-full"), u = _(() => L(c)), a = (i) => i === null ? "" : c.number(i, { minimumFractionDigits: e.decimals, maximumFractionDigits: e.decimals, useGrouping: e.grouping }), m = (i) => i === null ? "" : String(i).replace(".", u.value.decimal), f = (i) => Q(i, { decimals: e.decimals, group: e.grouping ? u.value.group : "" }), s = w(!1), l = w(a(t.value));
55
- F(t, (i) => {
56
- s.value ? f(l.value) !== i && (l.value = m(i)) : l.value = a(i);
57
- }), F(() => [e.decimals, e.grouping, u.value.decimal], () => {
58
- s.value || (l.value = a(t.value));
59
- });
60
- function h(i) {
61
- const x = i.target;
62
- let o = x.value.replace(/[^\d.,\-\s]/g, "");
63
- e.negative ? o = o.replace(/(?!^)-/g, "") : o = o.replace(/-/g, ""), o !== x.value && (x.value = o), l.value = o;
64
- const b = f(o);
65
- b !== void 0 ? t.value = b : t.value = null;
66
- }
67
- function k() {
68
- s.value = !0, l.value = m(t.value);
69
- }
70
- function C() {
71
- s.value = !1, l.value = a(t.value);
72
- }
73
- return r({ focus: () => d.value?.focus() }), (i, x) => (y(), S(H, W(B(J)(e), {
74
- value: t.value === null ? null : a(t.value),
75
- prefix: e.prefix,
76
- suffix: e.suffix,
77
- "value-style": "numeric"
78
- }), {
79
- default: $(({ id: o, describedby: b, invalid: V }) => [
80
- D("div", {
81
- class: A(["flex items-center gap-1.5", [B(g), v.value]])
82
- }, [
83
- e.prefix ? (y(), q("span", U, N(e.prefix), 1)) : M("", !0),
84
- D("input", {
85
- id: o,
86
- ref_key: "input",
87
- ref: d,
88
- value: l.value,
89
- type: "text",
90
- inputmode: "decimal",
91
- autocomplete: "off",
92
- name: e.name,
93
- placeholder: e.placeholder,
94
- disabled: e.disabled,
95
- required: e.required,
96
- "aria-required": e.required || void 0,
97
- "aria-invalid": V || void 0,
98
- "aria-describedby": b,
99
- class: "block w-full min-w-0 border-0 bg-transparent px-0 py-1 text-right text-body tabular-nums text-content-strong placeholder:text-content-disabled focus:outline-none focus:ring-0 disabled:cursor-not-allowed",
100
- onInput: h,
101
- onFocus: k,
102
- onBlur: C
103
- }, null, 40, X),
104
- e.suffix ? (y(), q("span", Y, N(e.suffix), 1)) : M("", !0)
105
- ], 2)
106
- ]),
107
- _: 1
108
- }, 16, ["value", "prefix", "suffix"]));
109
- }
110
- });
111
- export {
112
- ie as _
113
- };