@wssto2/vue-core 0.4.20 → 0.4.21
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/{Activity-C0NvjIi5.js → Activity-DX-RK9xj.js} +1 -1
- package/dist/{Changes-hoMHeAZt.js → Changes-_nARQ9IC.js} +1 -1
- package/dist/{General-9Sgxb74n.js → General-CkZoXu29.js} +1 -1
- package/dist/{NewRolePage-D-LunWMH.js → NewRolePage-OosTaMfZ.js} +2 -2
- package/dist/{ProfilePage-DJUDCyEr.js → ProfilePage-Dn8fQ3ff.js} +1 -1
- package/dist/{RoleEditor.vue_vue_type_script_setup_true_lang-D-b-O6SG.js → RoleEditor.vue_vue_type_script_setup_true_lang-2IOio1Sa.js} +1 -1
- package/dist/{RolePage-Ha-EgoEJ.js → RolePage-33RUvHYD.js} +3 -3
- package/dist/{RolesPage-8uWWCClN.js → RolesPage-BGPoUCMP.js} +1 -1
- package/dist/{Sessions-Dz4KYMu9.js → Sessions-BbAdbjmG.js} +1 -1
- package/dist/{SignIn-CNv68Tba.js → SignIn-DDCRzlUq.js} +1 -1
- package/dist/{SignInPage-CsjC4aiV.js → SignInPage-D9jryXA7.js} +1 -1
- package/dist/{SignIns-CgsNf8uf.js → SignIns-C_5sRrB4.js} +1 -1
- package/dist/{UserRecord-B9r_9U1z.js → UserRecord-CUhbz62x.js} +3 -3
- package/dist/{UsersList-BBLa3OCv.js → UsersList-BE8fnICz.js} +3 -3
- package/dist/access/index.js +1 -1
- package/dist/form/CommandDialog.vue.d.ts +4 -1
- package/dist/form/index.js +721 -712
- package/dist/form/useCommand.d.ts +18 -0
- package/dist/identity/index.js +1 -1
- package/dist/{index-D6BjUQJT.js → index-C3HWRCEe.js} +4 -4
- package/dist/{index-Dxu7ZfCC.js → index-DiEoRV9D.js} +10 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{status-BLTC7wi1.js → status-UWWFHi9t.js} +1 -1
- package/dist/useCommand-VIZE7xG-.js +168 -0
- package/package.json +1 -1
- package/dist/useCommand-YN9EMb7s.js +0 -138
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { type Ref } from "vue";
|
|
2
2
|
import { type Form, type FormOptions, type SubmitContext, type SubmitResult } from "./useForm";
|
|
3
|
+
/** The question a command asks before it runs: it names the consequence ("Archive the vehicle?"), and `confirmLabel` says exactly what yes does. */
|
|
4
|
+
export interface CommandQuestion {
|
|
5
|
+
readonly title: string;
|
|
6
|
+
readonly message?: string;
|
|
7
|
+
readonly confirmLabel?: string;
|
|
8
|
+
readonly tone?: "neutral" | "warning" | "critical";
|
|
9
|
+
}
|
|
3
10
|
export interface CommandOptions<Values extends object, Output = Values, Done = unknown> extends FormOptions<Values, Output> {
|
|
4
11
|
/** The call: one purpose-specific endpoint (advance a status, assign, approve, change a price). Its payload is the validator's output. */
|
|
5
12
|
readonly run: (input: Output, context: SubmitContext) => Promise<Done>;
|
|
6
13
|
/** After the call went through: the page updates itself (reloads the record, toasts). */
|
|
7
14
|
readonly done?: (result: Done) => Promise<unknown> | unknown;
|
|
15
|
+
/**
|
|
16
|
+
* A question to put after the inputs check out and before anything is sent (an irreversible step): its answer, not the primary action,
|
|
17
|
+
* runs the command. It reads the validated input and whatever the caller holds (what is still unpaid); `null` asks nothing this time.
|
|
18
|
+
* `CommandDialog` presents it; No returns to the filled form, Yes calls with the usual idempotency key.
|
|
19
|
+
*/
|
|
20
|
+
readonly ask?: (input: Output) => CommandQuestion | null;
|
|
8
21
|
}
|
|
9
22
|
export interface Command<Values extends object, Output = Values, Done = unknown> {
|
|
10
23
|
/** The command's inputs: a small form (`command.form.bind('assignee')`). */
|
|
@@ -16,6 +29,10 @@ export interface Command<Values extends object, Output = Values, Done = unknown>
|
|
|
16
29
|
dismiss(): void;
|
|
17
30
|
/** Validates and calls. One call at a time; a failure keeps the inputs and says why (`form.failure`, field errors on the fields). */
|
|
18
31
|
run(): Promise<SubmitResult<Done>>;
|
|
32
|
+
/** The question waiting for an answer (set by `run()` when `ask` returned one, instead of calling). */
|
|
33
|
+
readonly question: Readonly<Ref<CommandQuestion | null>>;
|
|
34
|
+
/** Answers it: Yes calls (the result is `run()`'s), No sends nothing and keeps the inputs (`aborted`). */
|
|
35
|
+
answer(yes: boolean): Promise<SubmitResult<Done>>;
|
|
19
36
|
/** For `AlertDialog`'s `action`: resolves when the call went through, throws when it did not, so the dialog stays open and `@failed` fires. */
|
|
20
37
|
confirm(): Promise<void>;
|
|
21
38
|
}
|
|
@@ -32,6 +49,7 @@ export interface Command<Values extends object, Output = Values, Done = unknown>
|
|
|
32
49
|
* <CommandDialog :command="assign" :title="t('assign')" :confirm-label="t('assign')"><SelectField v-bind="assign.form.bind('assignee')" … /></CommandDialog>
|
|
33
50
|
* <Button @click="assign.present()">Assign</Button>
|
|
34
51
|
*
|
|
52
|
+
* `ask: (input) => ({ title, message, confirmLabel, tone }) | null` puts a question before the call (a delivery that archives the vehicle).
|
|
35
53
|
* A command with nothing to enter is an `AlertDialog` with `:action="command.confirm"`.
|
|
36
54
|
*/
|
|
37
55
|
export declare function useCommand<Values extends object, Output = Values, Done = unknown>(options: CommandOptions<Values, Output, Done>): Command<Values, Output, Done>;
|
package/dist/identity/index.js
CHANGED
|
@@ -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-
|
|
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-DiEoRV9D.js";
|
|
2
2
|
export {
|
|
3
3
|
t as SignInAsButton,
|
|
4
4
|
n as identityFeature,
|
|
@@ -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-
|
|
19
|
+
import { u as Pe, _ as Ue } from "./useCommand-VIZE7xG-.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-
|
|
47
|
-
newRole: { name: "access.roles.new", path: "/iam/roles/new", component: () => import("./NewRolePage-
|
|
46
|
+
roles: { name: "access.roles", path: "/iam/roles", component: () => import("./RolesPage-BGPoUCMP.js"), meta: { access: F.viewRoles, titleKey: "core.access.title" } },
|
|
47
|
+
newRole: { name: "access.roles.new", path: "/iam/roles/new", component: () => import("./NewRolePage-OosTaMfZ.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-
|
|
51
|
+
component: () => import("./RolePage-33RUvHYD.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
|
}
|
|
@@ -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-
|
|
318
|
+
login: { name: "login", path: "/login", component: () => import("./SignInPage-D9jryXA7.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-
|
|
337
|
+
index: { name: "profile", path: "/profile", component: () => import("./ProfilePage-Dn8fQ3ff.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-
|
|
361
|
+
index: { name: "users.index", path: "/users", component: () => import("./UsersList-BE8fnICz.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-
|
|
365
|
+
component: () => import("./UserRecord-CUhbz62x.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-
|
|
369
|
-
{ name: "users.record.signin", path: "signin", component: () => import("./SignIn-
|
|
370
|
-
{ name: "users.record.sessions", path: "sessions", component: () => import("./Sessions-
|
|
371
|
-
{ name: "users.record.signins", path: "signins", component: () => import("./SignIns-
|
|
372
|
-
{ name: "users.record.changes", path: "changes", component: () => import("./Changes-
|
|
373
|
-
{ name: "users.record.activity", path: "activity", component: () => import("./Activity-
|
|
368
|
+
{ name: "users.record.general", path: "general", component: () => import("./General-CkZoXu29.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-DDCRzlUq.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-BbAdbjmG.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-C_5sRrB4.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-_nARQ9IC.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-DX-RK9xj.js"), meta: { access: ss, section: { labelKey: "core.users.sections.activity", icon: "listCheck", groupKey: "core.users.section_groups.activity" } } }
|
|
374
374
|
]
|
|
375
375
|
}
|
|
376
376
|
});
|
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.
|
|
2
|
+
export declare const version = "0.4.21";
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,168 @@
|
|
|
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-DWcVKZM3.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
|
+
action: T,
|
|
125
|
+
onDismissed: d[2] || (d[2] = (_) => void e.command.answer?.(!1))
|
|
126
|
+
}, null, 8, ["title", "message", "confirm-label", "tone"])) : h("", !0)
|
|
127
|
+
], 64));
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
function oe(t) {
|
|
131
|
+
const r = P(t), e = b(!1), n = () => typeof t.defaults == "function" ? t.defaults() : t.defaults, i = b(null);
|
|
132
|
+
async function l() {
|
|
133
|
+
return await r.submit(t.run, {
|
|
134
|
+
// The page updating itself after the call is the refresh: its failure is "saved, but could not be read back".
|
|
135
|
+
refresh: t.done ? (u) => t.done?.(u) : void 0
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
async function o() {
|
|
139
|
+
const a = t.ask ? r.validate() : null, u = a === null ? null : t.ask?.(a) ?? null;
|
|
140
|
+
return u ? (i.value = u, { status: "aborted" }) : l();
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
form: r,
|
|
144
|
+
open: e,
|
|
145
|
+
present(a) {
|
|
146
|
+
r.hydrate({ ...n(), ...a }), e.value = !0;
|
|
147
|
+
},
|
|
148
|
+
dismiss() {
|
|
149
|
+
e.value = !1;
|
|
150
|
+
},
|
|
151
|
+
run: o,
|
|
152
|
+
question: i,
|
|
153
|
+
async answer(a) {
|
|
154
|
+
return i.value = null, a ? l() : { status: "aborted" };
|
|
155
|
+
},
|
|
156
|
+
async confirm() {
|
|
157
|
+
const a = await l();
|
|
158
|
+
if (a.status === "failed") throw new Error(a.failure.message);
|
|
159
|
+
if (a.status === "aborted") throw new Error("aborted");
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
ne as _,
|
|
165
|
+
se as a,
|
|
166
|
+
Y as f,
|
|
167
|
+
oe as u
|
|
168
|
+
};
|
package/package.json
CHANGED
|
@@ -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
|
-
};
|