@wssto2/vue-core 0.4.20 → 0.4.23

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 (37) hide show
  1. package/CHANGELOG.md +460 -0
  2. package/dist/{Activity-C0NvjIi5.js → Activity-Cu_mAn_m.js} +1 -1
  3. package/dist/{Changes-hoMHeAZt.js → Changes-DW_3-MwX.js} +1 -1
  4. package/dist/{DeadLetters-O6QReswO.js → DeadLetters-CpcMccCc.js} +1 -1
  5. package/dist/{FormErrors.vue_vue_type_script_setup_true_lang-DWcVKZM3.js → FormErrors.vue_vue_type_script_setup_true_lang-4WQz-TYS.js} +75 -74
  6. package/dist/{FormView.vue_vue_type_script_setup_true_lang-Dbfg_jGh.js → FormView.vue_vue_type_script_setup_true_lang-CbvMRBOc.js} +1 -1
  7. package/dist/{General-9Sgxb74n.js → General-Dbc3qDRz.js} +3 -3
  8. package/dist/{NewRolePage-D-LunWMH.js → NewRolePage-DPHFJ0I8.js} +2 -2
  9. package/dist/{ProfilePage-DJUDCyEr.js → ProfilePage-Cc7eiyV2.js} +3 -3
  10. package/dist/{RoleEditor.vue_vue_type_script_setup_true_lang-D-b-O6SG.js → RoleEditor.vue_vue_type_script_setup_true_lang-2fpYYCXj.js} +3 -3
  11. package/dist/{RolePage-Ha-EgoEJ.js → RolePage-C0jmkQkO.js} +3 -3
  12. package/dist/{RolesPage-8uWWCClN.js → RolesPage-eb4gqxdW.js} +1 -1
  13. package/dist/{Sessions-Dz4KYMu9.js → Sessions-DSDcj8Yd.js} +1 -1
  14. package/dist/{SettingsPage-D47NSOYW.js → SettingsPage-BF7MW1GH.js} +3 -3
  15. package/dist/{SignIn-CNv68Tba.js → SignIn-BR8-RVIk.js} +1 -1
  16. package/dist/{SignInPage-CsjC4aiV.js → SignInPage-Dcws582A.js} +2 -2
  17. package/dist/{SignIns-CgsNf8uf.js → SignIns-3u7YgKqh.js} +1 -1
  18. package/dist/{UserRecord-B9r_9U1z.js → UserRecord-AtZIwCO9.js} +3 -3
  19. package/dist/{UsersList-BBLa3OCv.js → UsersList-1IeQnvOL.js} +3 -3
  20. package/dist/access/index.js +1 -1
  21. package/dist/form/CommandDialog.vue.d.ts +4 -1
  22. package/dist/form/MonthYearField.vue.d.ts +3 -1
  23. package/dist/form/index.js +728 -717
  24. package/dist/form/useCommand.d.ts +21 -0
  25. package/dist/form/useForm.d.ts +1 -1
  26. package/dist/identity/index.js +1 -1
  27. package/dist/{index-Dxu7ZfCC.js → index--CxZ33h0.js} +12 -12
  28. package/dist/{index-D-0JNiFF.js → index-DBTK_iMB.js} +2 -2
  29. package/dist/{index-D6BjUQJT.js → index-Du3Ti2Zp.js} +4 -4
  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/{status-BLTC7wi1.js → status-QOGPjIHu.js} +1 -1
  34. package/dist/useCommand-CT1RF_IB.js +169 -0
  35. package/dist/{useResourceForm-CP2lCwmD.js → useResourceForm-CQuniKhd.js} +1 -1
  36. package/package.json +3 -2
  37. package/dist/useCommand-YN9EMb7s.js +0 -138
@@ -1,10 +1,26 @@
1
1
  import { type Ref } from "vue";
2
+ import type { IconName } from "../icon";
2
3
  import { type Form, type FormOptions, type SubmitContext, type SubmitResult } from "./useForm";
4
+ /** The question a command asks before it runs: it names the consequence ("Archive the vehicle?"), and `confirmLabel` says exactly what yes does. */
5
+ export interface CommandQuestion {
6
+ readonly title: string;
7
+ readonly message?: string;
8
+ readonly confirmLabel?: string;
9
+ /** The alert's icon, as on `AlertDialog` (an app-registered or core icon name); by default the tone's. */
10
+ readonly icon?: IconName;
11
+ readonly tone?: "neutral" | "warning" | "critical";
12
+ }
3
13
  export interface CommandOptions<Values extends object, Output = Values, Done = unknown> extends FormOptions<Values, Output> {
4
14
  /** The call: one purpose-specific endpoint (advance a status, assign, approve, change a price). Its payload is the validator's output. */
5
15
  readonly run: (input: Output, context: SubmitContext) => Promise<Done>;
6
16
  /** After the call went through: the page updates itself (reloads the record, toasts). */
7
17
  readonly done?: (result: Done) => Promise<unknown> | unknown;
18
+ /**
19
+ * A question to put after the inputs check out and before anything is sent (an irreversible step): its answer, not the primary action,
20
+ * runs the command. It reads the validated input and whatever the caller holds (what is still unpaid); `null` asks nothing this time.
21
+ * `CommandDialog` presents it; No returns to the filled form, Yes calls with the usual idempotency key.
22
+ */
23
+ readonly ask?: (input: Output) => CommandQuestion | null;
8
24
  }
9
25
  export interface Command<Values extends object, Output = Values, Done = unknown> {
10
26
  /** The command's inputs: a small form (`command.form.bind('assignee')`). */
@@ -16,6 +32,10 @@ export interface Command<Values extends object, Output = Values, Done = unknown>
16
32
  dismiss(): void;
17
33
  /** Validates and calls. One call at a time; a failure keeps the inputs and says why (`form.failure`, field errors on the fields). */
18
34
  run(): Promise<SubmitResult<Done>>;
35
+ /** The question waiting for an answer (set by `run()` when `ask` returned one, instead of calling). */
36
+ readonly question: Readonly<Ref<CommandQuestion | null>>;
37
+ /** Answers it: Yes calls (the result is `run()`'s), No sends nothing and keeps the inputs (`aborted`). */
38
+ answer(yes: boolean): Promise<SubmitResult<Done>>;
19
39
  /** For `AlertDialog`'s `action`: resolves when the call went through, throws when it did not, so the dialog stays open and `@failed` fires. */
20
40
  confirm(): Promise<void>;
21
41
  }
@@ -32,6 +52,7 @@ export interface Command<Values extends object, Output = Values, Done = unknown>
32
52
  * <CommandDialog :command="assign" :title="t('assign')" :confirm-label="t('assign')"><SelectField v-bind="assign.form.bind('assignee')" … /></CommandDialog>
33
53
  * <Button @click="assign.present()">Assign</Button>
34
54
  *
55
+ * `ask: (input) => ({ title, message, confirmLabel, icon, tone }) | null` puts a question before the call (a delivery that archives the vehicle).
35
56
  * A command with nothing to enter is an `AlertDialog` with `:action="command.confirm"`.
36
57
  */
37
58
  export declare function useCommand<Values extends object, Output = Values, Done = unknown>(options: CommandOptions<Values, Output, Done>): Command<Values, Output, Done>;
@@ -107,7 +107,7 @@ export interface Form<Values extends object, Output = Values> {
107
107
  reset(): void;
108
108
  /** Takes the draft as the baseline (defaults applied right after loading are not the user's edits). */
109
109
  markClean(): void;
110
- /** Runs the validator on a copy of the draft: the errors are set and null returned, or the parsed output. */
110
+ /** Runs the validator on a copy of the draft: the errors are set and null returned, or the parsed output and the failure of an earlier attempt is cleared (it complained about inputs that have since been fixed). */
111
111
  validate(): Output | null;
112
112
  /** Like `validate` for the given fields only: the validator's issues elsewhere are ignored (a group saving to its own endpoint). True when they are fine. */
113
113
  check(fields: Fields<Values>): boolean;
@@ -1,4 +1,4 @@
1
- import { _ as t, h as n, j as a, i, k as o, d as r, l as d, m as u, n as y, r as l, o as I, s as f, q as p, t as A, f as c } from "../index-Dxu7ZfCC.js";
1
+ import { _ as t, h as n, j as a, i, k as o, d as r, l as d, m as u, n as y, r as l, o as I, s as f, q as p, t as A, f as c } from "../index--CxZ33h0.js";
2
2
  export {
3
3
  t as SignInAsButton,
4
4
  n as identityFeature,
@@ -14,12 +14,12 @@ import { useRouter as J, useRoute as de } from "vue-router";
14
14
  import { _ as Q } from "./Icon.vue_vue_type_script_lang-D7oC-d-S.js";
15
15
  import { _ as L } from "./Button.vue_vue_type_script_setup_true_lang-CL9Qh5yq.js";
16
16
  import { u as fe } from "./leaveGuard-Cc8yeLxM.js";
17
- import { _ as he } from "./FormView.vue_vue_type_script_setup_true_lang-Dbfg_jGh.js";
17
+ import { _ as he } from "./FormView.vue_vue_type_script_setup_true_lang-CbvMRBOc.js";
18
18
  import { _ as ye } from "./TextField.vue_vue_type_script_setup_true_lang-CP2WeU36.js";
19
19
  import { u as ge } from "./mediaQuery-CygcXmFW.js";
20
20
  import { u as ve } from "./useDialog-CXR3hN0G.js";
21
21
  import { c as _e } from "./closeOverlays-CjVsIrpL.js";
22
- import { u as be } from "./FormErrors.vue_vue_type_script_setup_true_lang-DWcVKZM3.js";
22
+ import { u as be } from "./FormErrors.vue_vue_type_script_setup_true_lang-4WQz-TYS.js";
23
23
  import { u as we } from "./format-D8X4zsx6.js";
24
24
  import { _ as xe } from "./AccountMenuItem.vue_vue_type_script_setup_true_lang-CPeNxh5K.js";
25
25
  import { b as Ee } from "./routeResource-DlTsGTg_.js";
@@ -315,7 +315,7 @@ function Cs(e) {
315
315
  const Ye = async (e) => {
316
316
  await B(e.http);
317
317
  }, Je = z({
318
- login: { name: "login", path: "/login", component: () => import("./SignInPage-CsjC4aiV.js"), meta: { public: !0, titleKey: "core.identity.signin.title" } }
318
+ login: { name: "login", path: "/login", component: () => import("./SignInPage-Dcws582A.js"), meta: { public: !0, titleKey: "core.identity.signin.title" } }
319
319
  });
320
320
  function Os(e = {}) {
321
321
  return H({
@@ -334,7 +334,7 @@ function Os(e = {}) {
334
334
  });
335
335
  }
336
336
  const Z = z({
337
- index: { name: "profile", path: "/profile", component: () => import("./ProfilePage-DJUDCyEr.js"), meta: { titleKey: "core.profile.title" } }
337
+ index: { name: "profile", path: "/profile", component: () => import("./ProfilePage-Cc7eiyV2.js"), meta: { titleKey: "core.profile.title" } }
338
338
  }), Qe = /* @__PURE__ */ E({
339
339
  __name: "ProfileMenuItem",
340
340
  setup(e) {
@@ -358,19 +358,19 @@ function es(e) {
358
358
  return { name: `users.record.${e.path}`, path: e.path, component: s, meta: { ...e.meta } };
359
359
  }
360
360
  const W = "iam.user:view", qs = "iam.user:manage", ss = "iam.user.activity:view", ee = z({
361
- index: { name: "users.index", path: "/users", component: () => import("./UsersList-BBLa3OCv.js"), meta: { access: W, titleKey: "core.users.title" } },
361
+ index: { name: "users.index", path: "/users", component: () => import("./UsersList-1IeQnvOL.js"), meta: { access: W, titleKey: "core.users.title" } },
362
362
  record: {
363
363
  name: "users.record",
364
364
  path: "/users/:id",
365
- component: () => import("./UserRecord-B9r_9U1z.js"),
365
+ component: () => import("./UserRecord-AtZIwCO9.js"),
366
366
  meta: { access: W, titleKey: "core.users.title", remountOnParam: "id" },
367
367
  children: [
368
- { name: "users.record.general", path: "general", component: () => import("./General-9Sgxb74n.js"), meta: { section: { labelKey: "core.users.sections.general", icon: "user3Line", groupKey: "core.users.section_groups.person" } } },
369
- { name: "users.record.signin", path: "signin", component: () => import("./SignIn-CNv68Tba.js"), meta: { section: { labelKey: "core.users.sections.signin", icon: "key2Line", groupKey: "core.users.section_groups.access" } } },
370
- { name: "users.record.sessions", path: "sessions", component: () => import("./Sessions-Dz4KYMu9.js"), meta: { section: { labelKey: "core.users.sections.sessions", icon: "deviceLine", groupKey: "core.users.section_groups.access" } } },
371
- { name: "users.record.signins", path: "signins", component: () => import("./SignIns-CgsNf8uf.js"), meta: { section: { labelKey: "core.users.sections.signins", icon: "timeFill", groupKey: "core.users.section_groups.activity" } } },
372
- { name: "users.record.changes", path: "changes", component: () => import("./Changes-hoMHeAZt.js"), meta: { section: { labelKey: "core.users.sections.changes", icon: "edit", groupKey: "core.users.section_groups.activity" } } },
373
- { name: "users.record.activity", path: "activity", component: () => import("./Activity-C0NvjIi5.js"), meta: { access: ss, section: { labelKey: "core.users.sections.activity", icon: "listCheck", groupKey: "core.users.section_groups.activity" } } }
368
+ { name: "users.record.general", path: "general", component: () => import("./General-Dbc3qDRz.js"), meta: { section: { labelKey: "core.users.sections.general", icon: "user3Line", groupKey: "core.users.section_groups.person" } } },
369
+ { name: "users.record.signin", path: "signin", component: () => import("./SignIn-BR8-RVIk.js"), meta: { section: { labelKey: "core.users.sections.signin", icon: "key2Line", groupKey: "core.users.section_groups.access" } } },
370
+ { name: "users.record.sessions", path: "sessions", component: () => import("./Sessions-DSDcj8Yd.js"), meta: { section: { labelKey: "core.users.sections.sessions", icon: "deviceLine", groupKey: "core.users.section_groups.access" } } },
371
+ { name: "users.record.signins", path: "signins", component: () => import("./SignIns-3u7YgKqh.js"), meta: { section: { labelKey: "core.users.sections.signins", icon: "timeFill", groupKey: "core.users.section_groups.activity" } } },
372
+ { name: "users.record.changes", path: "changes", component: () => import("./Changes-DW_3-MwX.js"), meta: { section: { labelKey: "core.users.sections.changes", icon: "edit", groupKey: "core.users.section_groups.activity" } } },
373
+ { name: "users.record.activity", path: "activity", component: () => import("./Activity-Cu_mAn_m.js"), meta: { access: ss, section: { labelKey: "core.users.sections.activity", icon: "listCheck", groupKey: "core.users.section_groups.activity" } } }
374
374
  ]
375
375
  }
376
376
  });
@@ -31,9 +31,9 @@ const M = {
31
31
  deadLettersRetryAll: y("POST", "/v1/events/dead-letters/retry", { permission: "events.deadletter:retry" }),
32
32
  consumers: y("GET", "/v1/events/consumers", { permission: "events.deadletter:view" })
33
33
  }, [ke, ee] = fe("vue-core.notifications"), we = "events.deadletter:view", bt = "events.deadletter:retry", J = Z({
34
- index: { name: "events.deadletters", path: "/events/dead-letters", component: () => import("./DeadLetters-O6QReswO.js"), meta: { access: we, titleKey: "core.notifications.dead_letters.title" } }
34
+ index: { name: "events.deadletters", path: "/events/dead-letters", component: () => import("./DeadLetters-CpcMccCc.js"), meta: { access: we, titleKey: "core.notifications.dead_letters.title" } }
35
35
  }), j = Z({
36
- index: { name: "notifications.settings", path: "/profile/notifications", component: () => import("./SettingsPage-D47NSOYW.js"), meta: { titleKey: "core.notifications.settings.title" } }
36
+ index: { name: "notifications.settings", path: "/profile/notifications", component: () => import("./SettingsPage-BF7MW1GH.js"), meta: { titleKey: "core.notifications.settings.title" } }
37
37
  }), Te = /* @__PURE__ */ z({
38
38
  __name: "SettingsMenuItem",
39
39
  setup(o) {
@@ -16,7 +16,7 @@ import { _ as Oe } from "./AsyncSection.vue_vue_type_script_setup_true_lang-Blj6
16
16
  import { u as Ae } from "./useLoad-M7V-AVwR.js";
17
17
  import { _ as De, a as Ke } from "./SelectField.vue_vue_type_script_setup_true_lang-C3FbRQW7.js";
18
18
  import { _ as Be } from "./SegmentedField.vue_vue_type_script_setup_true_lang-Dg-_ZjgR.js";
19
- import { u as Pe, _ as Ue } from "./useCommand-YN9EMb7s.js";
19
+ import { u as Pe, _ as Ue } from "./useCommand-CT1RF_IB.js";
20
20
  import { u as Fe } from "./platform-q3cjODLx.js";
21
21
  import { _ as Ge } from "./IconTile.vue_vue_type_script_setup_true_lang-_FXvaj93.js";
22
22
  import { u as Me } from "./mediaQuery-CygcXmFW.js";
@@ -43,12 +43,12 @@ const C = {
43
43
  viewAccess: "iam.user:view",
44
44
  manageBindings: "iam.user:manage"
45
45
  }, re = Ee({
46
- roles: { name: "access.roles", path: "/iam/roles", component: () => import("./RolesPage-8uWWCClN.js"), meta: { access: F.viewRoles, titleKey: "core.access.title" } },
47
- newRole: { name: "access.roles.new", path: "/iam/roles/new", component: () => import("./NewRolePage-D-LunWMH.js"), meta: { access: F.manageRoles, titleKey: "core.access.new_title" } },
46
+ roles: { name: "access.roles", path: "/iam/roles", component: () => import("./RolesPage-eb4gqxdW.js"), meta: { access: F.viewRoles, titleKey: "core.access.title" } },
47
+ newRole: { name: "access.roles.new", path: "/iam/roles/new", component: () => import("./NewRolePage-DPHFJ0I8.js"), meta: { access: F.manageRoles, titleKey: "core.access.new_title" } },
48
48
  role: {
49
49
  name: "access.role",
50
50
  path: "/iam/roles/:ref",
51
- component: () => import("./RolePage-Ha-EgoEJ.js"),
51
+ component: () => import("./RolePage-C0jmkQkO.js"),
52
52
  // A role's ref (its key, or the id of a custom one) swaps in place when a link leads to another role.
53
53
  meta: { access: F.viewRoles, titleKey: "core.access.title", remountOnParam: "ref" }
54
54
  }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The version of @wssto2/vue-core (kept equal to package.json by index.test.ts). */
2
- export declare const version = "0.4.20";
2
+ export declare const version = "0.4.23";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const o = "0.4.20";
1
+ const o = "0.4.23";
2
2
  export {
3
3
  o as version
4
4
  };
@@ -1,4 +1,4 @@
1
- import { d as s, e as o, n as a, a as i, b as n } from "../index-D-0JNiFF.js";
1
+ import { d as s, e as o, n as a, a as i, b as n } from "../index-DBTK_iMB.js";
2
2
  export {
3
3
  s as deadLettersRoutes,
4
4
  o as eventsRoutes,
@@ -1,5 +1,5 @@
1
1
  import { a, r as o } from "./http-D_D9YbLH.js";
2
- import { i as r } from "./index-Dxu7ZfCC.js";
2
+ import { i as r } from "./index--CxZ33h0.js";
3
3
  const n = ["active", "locked", "inactive", "all"];
4
4
  function l(i) {
5
5
  return a({
@@ -0,0 +1,169 @@
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";
3
+ import { f as R } from "./useDialog-CXR3hN0G.js";
4
+ import { _ as U } from "./Modal.vue_vue_type_script_setup_true_lang-DpBb8ans.js";
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";
9
+ 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));
14
+ 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;
17
+ }
18
+ const se = (t) => ({ "data-field-key": t }), j = {
19
+ key: 0,
20
+ class: "text-body text-content-muted"
21
+ }, ne = /* @__PURE__ */ C({
22
+ __name: "CommandDialog",
23
+ props: {
24
+ command: {},
25
+ title: {},
26
+ subtitle: { default: void 0 },
27
+ confirmLabel: {},
28
+ confirmDisabled: { type: Boolean, default: !1 },
29
+ doneLabel: { default: void 0 },
30
+ busyLabel: { default: void 0 },
31
+ message: { default: void 0 },
32
+ size: { default: "sm" },
33
+ fieldLabel: { type: Function, default: void 0 }
34
+ },
35
+ emits: ["done"],
36
+ setup(t, { emit: r }) {
37
+ const e = t, n = r, { t: i } = I(), l = v("modal"), o = v("body"), a = b(!1);
38
+ 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
+ s ? (a.value = !1, l.value?.present()) : l.value?.dismiss();
42
+ });
43
+ async function w(s = {}) {
44
+ e.confirmDisabled || await g(await e.command.run(), s);
45
+ }
46
+ async function g(s, d = {}) {
47
+ if (s.status === "failed") {
48
+ s.failure.kind === "invalid" && await f().then(() => Y(o.value ?? document));
49
+ return;
50
+ }
51
+ if (s.status !== "aborted") {
52
+ if (n("done"), d.addAnother) {
53
+ e.command.present(), await f(), R(o.value)[0]?.focus();
54
+ return;
55
+ }
56
+ a.value = !0, u = setTimeout(() => e.command.dismiss(), K);
57
+ }
58
+ }
59
+ const k = v("ask"), m = b(null);
60
+ L(() => e.command.question?.value, (s) => {
61
+ s && (m.value = s, f(() => k.value?.present()));
62
+ });
63
+ const T = async () => {
64
+ e.command.answer && await g(await e.command.answer(!0));
65
+ };
66
+ N(() => {
67
+ u && clearTimeout(u);
68
+ });
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
+ ref_key: "modal",
73
+ ref: l,
74
+ size: e.size,
75
+ grouped: "",
76
+ title: e.title,
77
+ subtitle: e.subtitle,
78
+ "before-dismiss": y(E),
79
+ "primary-label": e.confirmLabel,
80
+ "primary-disabled": e.confirmDisabled,
81
+ status: B.value,
82
+ "processing-label": e.busyLabel ?? y(i)("core.actions.saving"),
83
+ "done-label": e.doneLabel ?? y(i)("core.actions.saved"),
84
+ onPrimary: d[0] || (d[0] = (_) => w()),
85
+ onDismissed: d[1] || (d[1] = (_) => e.command.dismiss())
86
+ }, F({
87
+ default: $(() => [
88
+ V("div", {
89
+ ref_key: "body",
90
+ ref: o,
91
+ class: "flex min-w-0 flex-col gap-group-gap",
92
+ "data-test": "command-dialog"
93
+ }, [
94
+ e.message ? (p(), D("p", j, A(e.message), 1)) : h("", !0),
95
+ S(M, {
96
+ form: e.command.form,
97
+ label: e.fieldLabel,
98
+ scope: o.value
99
+ }, null, 8, ["form", "label", "scope"]),
100
+ x(s.$slots, "default")
101
+ ], 512)
102
+ ]),
103
+ _: 2
104
+ }, [
105
+ s.$slots.actions ? {
106
+ name: "actions",
107
+ fn: $(() => [
108
+ x(s.$slots, "actions", {
109
+ run: w,
110
+ busy: e.command.form.submitting.value
111
+ })
112
+ ]),
113
+ key: "0"
114
+ } : void 0
115
+ ]), 1032, ["size", "title", "subtitle", "before-dismiss", "primary-label", "primary-disabled", "status", "processing-label", "done-label"]),
116
+ m.value ? (p(), O(G, {
117
+ key: 0,
118
+ ref_key: "ask",
119
+ ref: k,
120
+ title: m.value.title,
121
+ message: m.value.message,
122
+ "confirm-label": m.value.confirmLabel,
123
+ tone: m.value.tone,
124
+ icon: m.value.icon,
125
+ action: T,
126
+ onDismissed: d[2] || (d[2] = (_) => void e.command.answer?.(!1))
127
+ }, null, 8, ["title", "message", "confirm-label", "tone", "icon"])) : h("", !0)
128
+ ], 64));
129
+ }
130
+ });
131
+ function oe(t) {
132
+ const r = P(t), e = b(!1), n = () => typeof t.defaults == "function" ? t.defaults() : t.defaults, i = b(null);
133
+ async function l() {
134
+ return await r.submit(t.run, {
135
+ // The page updating itself after the call is the refresh: its failure is "saved, but could not be read back".
136
+ refresh: t.done ? (u) => t.done?.(u) : void 0
137
+ });
138
+ }
139
+ async function o() {
140
+ const a = t.ask ? r.validate() : null, u = a === null ? null : t.ask?.(a) ?? null;
141
+ return u ? (i.value = u, { status: "aborted" }) : l();
142
+ }
143
+ return {
144
+ form: r,
145
+ open: e,
146
+ present(a) {
147
+ r.hydrate({ ...n(), ...a }), e.value = !0;
148
+ },
149
+ dismiss() {
150
+ e.value = !1;
151
+ },
152
+ run: o,
153
+ question: i,
154
+ async answer(a) {
155
+ return i.value = null, a ? l() : { status: "aborted" };
156
+ },
157
+ async confirm() {
158
+ const a = await l();
159
+ if (a.status === "failed") throw new Error(a.failure.message);
160
+ if (a.status === "aborted") throw new Error("aborted");
161
+ }
162
+ };
163
+ }
164
+ export {
165
+ ne as _,
166
+ se as a,
167
+ Y as f,
168
+ oe as u
169
+ };
@@ -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-DWcVKZM3.js";
2
+ import { u as i, c as h } from "./FormErrors.vue_vue_type_script_setup_true_lang-4WQz-TYS.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.20",
3
+ "version": "0.4.23",
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": [
@@ -25,7 +25,8 @@
25
25
  ],
26
26
  "files": [
27
27
  "dist",
28
- "src/styles"
28
+ "src/styles",
29
+ "CHANGELOG.md"
29
30
  ],
30
31
  "exports": {
31
32
  ".": {
@@ -1,138 +0,0 @@
1
- import { nextTick as f, defineComponent as L, useTemplateRef as p, ref as w, watch as D, onBeforeUnmount as S, computed as x, openBlock as v, createBlock as E, unref as c, createSlots as T, withCtx as y, createElementVNode as $, createElementBlock as B, toDisplayString as C, createCommentVNode as N, createVNode as z, renderSlot as g } from "vue";
2
- import { useI18n as V } from "vue-i18n";
3
- import { f as q } from "./useDialog-CXR3hN0G.js";
4
- import { _ as A } from "./Modal.vue_vue_type_script_setup_true_lang-DpBb8ans.js";
5
- import { D as F } from "./useWaitStatus-fsacMl4W.js";
6
- import { _ as O, u as I } from "./FormErrors.vue_vue_type_script_setup_true_lang-DWcVKZM3.js";
7
- import { a as R } from "./leaveGuard-Cc8yeLxM.js";
8
- const d = "input:not([type=hidden]):not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex='-1'])";
9
- async function U(t = document, n) {
10
- const e = [...t.querySelectorAll("[data-field-error]")], o = e.find((s) => s.matches(d) || s.querySelector(d)) ?? e[0];
11
- if (!o) return !1;
12
- const r = n?.sections.value.find((s) => s.element.contains(o));
13
- r && (await n?.scrollTo(r.id, { updateUrl: !1 }), await f());
14
- const a = o.matches(d) ? o : o.querySelector(d);
15
- return (a ?? o).scrollIntoView?.({ block: "center" }), (a ?? o).focus({ preventScroll: !0 }), !0;
16
- }
17
- const Q = (t) => ({ "data-field-key": t }), G = {
18
- key: 0,
19
- class: "text-body text-content-muted"
20
- }, X = /* @__PURE__ */ L({
21
- __name: "CommandDialog",
22
- props: {
23
- command: {},
24
- title: {},
25
- subtitle: { default: void 0 },
26
- confirmLabel: {},
27
- confirmDisabled: { type: Boolean, default: !1 },
28
- doneLabel: { default: void 0 },
29
- busyLabel: { default: void 0 },
30
- message: { default: void 0 },
31
- size: { default: "sm" },
32
- fieldLabel: { type: Function, default: void 0 }
33
- },
34
- emits: ["done"],
35
- setup(t, { emit: n }) {
36
- const e = t, o = n, { t: r } = V(), a = p("modal"), s = p("body"), u = w(!1);
37
- let m = null;
38
- const { confirmDiscard: _ } = R(() => e.command.open.value && e.command.form.dirty.value);
39
- D(() => e.command.open.value, (l) => {
40
- l ? (u.value = !1, a.value?.present()) : a.value?.dismiss();
41
- });
42
- async function b(l = {}) {
43
- if (e.confirmDisabled) return;
44
- const i = await e.command.run();
45
- if (i.status === "failed") {
46
- i.failure.kind === "invalid" && await f().then(() => U(s.value ?? document));
47
- return;
48
- }
49
- if (i.status !== "aborted") {
50
- if (o("done"), l.addAnother) {
51
- e.command.present(), await f(), q(s.value)[0]?.focus();
52
- return;
53
- }
54
- u.value = !0, m = setTimeout(() => e.command.dismiss(), F);
55
- }
56
- }
57
- S(() => {
58
- m && clearTimeout(m);
59
- });
60
- const k = x(() => e.command.form.submitting.value ? "processing" : u.value ? "done" : "idle");
61
- return (l, i) => (v(), E(A, {
62
- ref_key: "modal",
63
- ref: a,
64
- size: e.size,
65
- grouped: "",
66
- title: e.title,
67
- subtitle: e.subtitle,
68
- "before-dismiss": c(_),
69
- "primary-label": e.confirmLabel,
70
- "primary-disabled": e.confirmDisabled,
71
- status: k.value,
72
- "processing-label": e.busyLabel ?? c(r)("core.actions.saving"),
73
- "done-label": e.doneLabel ?? c(r)("core.actions.saved"),
74
- onPrimary: i[0] || (i[0] = (h) => b()),
75
- onDismissed: i[1] || (i[1] = (h) => e.command.dismiss())
76
- }, T({
77
- default: y(() => [
78
- $("div", {
79
- ref_key: "body",
80
- ref: s,
81
- class: "flex min-w-0 flex-col gap-group-gap",
82
- "data-test": "command-dialog"
83
- }, [
84
- e.message ? (v(), B("p", G, C(e.message), 1)) : N("", !0),
85
- z(O, {
86
- form: e.command.form,
87
- label: e.fieldLabel,
88
- scope: s.value
89
- }, null, 8, ["form", "label", "scope"]),
90
- g(l.$slots, "default")
91
- ], 512)
92
- ]),
93
- _: 2
94
- }, [
95
- l.$slots.actions ? {
96
- name: "actions",
97
- fn: y(() => [
98
- g(l.$slots, "actions", {
99
- run: b,
100
- busy: e.command.form.submitting.value
101
- })
102
- ]),
103
- key: "0"
104
- } : void 0
105
- ]), 1032, ["size", "title", "subtitle", "before-dismiss", "primary-label", "primary-disabled", "status", "processing-label", "done-label"]));
106
- }
107
- });
108
- function Y(t) {
109
- const n = I(t), e = w(!1), o = () => typeof t.defaults == "function" ? t.defaults() : t.defaults;
110
- async function r() {
111
- return await n.submit(t.run, {
112
- // The page updating itself after the call is the refresh: its failure is "saved, but could not be read back".
113
- refresh: t.done ? (s) => t.done?.(s) : void 0
114
- });
115
- }
116
- return {
117
- form: n,
118
- open: e,
119
- present(a) {
120
- n.hydrate({ ...o(), ...a }), e.value = !0;
121
- },
122
- dismiss() {
123
- e.value = !1;
124
- },
125
- run: r,
126
- async confirm() {
127
- const a = await r();
128
- if (a.status === "failed") throw new Error(a.failure.message);
129
- if (a.status === "aborted") throw new Error("aborted");
130
- }
131
- };
132
- }
133
- export {
134
- X as _,
135
- Q as a,
136
- U as f,
137
- Y as u
138
- };