@webx-ui/module-pages 0.1.0 → 0.3.0

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/index.js CHANGED
@@ -1,38 +1,38 @@
1
- import { inject as je, provide as Ge, defineComponent as H, ref as P, computed as V, openBlock as d, createBlock as x, unref as e, withCtx as n, createElementVNode as N, createElementBlock as M, createVNode as f, createTextVNode as h, toDisplayString as g, createCommentVNode as D, useTemplateRef as Pe, watch as ae, onMounted as ye, onBeforeUnmount as Je, Fragment as F, renderList as ie, normalizeClass as Qe, useModel as Xe, mergeModels as Ye, withModifiers as xe, nextTick as Ze, isRef as Re, withKeys as De } from "vue";
2
- import { useRouter as Ce, useRoute as qe, onBeforeRouteLeave as et } from "vue-router";
3
- import { useAdmin as X, useTranslate as j, WxScreen as tt } from "@webx-ui/module-admin";
4
- import { WxCard as Oe, WxText as O, WxButton as R, confirm as le, toast as z, useLocales as Ue, useElementWidth as Ie, localizedValue as at, WxSkeleton as ke, WxBreadcrumb as lt, WxBreadcrumbItem as we, WxBadge as We, WxDropdown as Le, WxDropdownItem as re, WxAction as $e, WxAlert as Ve, WxEmpty as nt, WxTreeSelect as st, WxFormItem as ue, WxActions as ot, useModal as Fe, WxDialog as Ke, WxInput as Me, WxSpace as Te, createModal as Ae, WxHeading as it, WxTable as rt, WxSegmented as ut } from "@webx-ui/core";
5
- import { provideBlocksPreview as dt } from "@webx-ui/module-blocks";
6
- function Z(v) {
7
- const u = `${v.apiPath}/pages`, p = (l) => l.data;
1
+ import { inject as Le, provide as Oe, defineComponent as K, ref as k, computed as W, openBlock as m, createBlock as V, unref as e, withCtx as n, createElementVNode as E, createElementBlock as A, createVNode as g, createTextVNode as y, toDisplayString as b, createCommentVNode as N, useTemplateRef as Be, watch as ae, onMounted as pe, onBeforeUnmount as Ke, Fragment as j, renderList as Me, normalizeClass as Fe, useModel as He, mergeModels as je, nextTick as Ge, isRef as De, withKeys as Pe, createSlots as Je, withModifiers as Qe } from "vue";
2
+ import { useRouter as ye, useRoute as Xe, onBeforeRouteLeave as Ye } from "vue-router";
3
+ import { useAdmin as G, useTranslate as F, useErrorText as ie, WxBackButton as Ze, WxScreen as qe, WxDate as me, WxRowMenu as et, WxListScreen as tt } from "@webx-ui/module-admin";
4
+ import { WxCard as at, WxText as R, WxButton as I, confirm as O, toast as z, useLocales as Se, useElementWidth as lt, localizedValue as nt, WxSkeleton as be, WxBreadcrumb as st, WxBreadcrumbItem as fe, WxBadge as we, WxDropdown as ot, WxDropdownItem as We, WxAction as it, WxAlert as xe, WxActionBar as rt, WxEmpty as ut, WxTreeSelect as dt, WxFormItem as oe, useModal as Ne, WxDialog as Ae, WxInput as Ve, WxSpace as _e, createModal as ze, WxTable as ct } from "@webx-ui/core";
5
+ import { provideBlocksPreview as pt } from "@webx-ui/module-blocks";
6
+ function Z(u) {
7
+ const r = `${u.apiPath}/pages`, h = (l) => l.data;
8
8
  return {
9
9
  list: (l = {}) => {
10
- const i = new URLSearchParams();
11
- l.parent != null && i.set("parent", String(l.parent)), l.search && i.set("search", l.search), l.status && i.set("status", l.status), l.trashed && i.set("trashed", "1"), l.flat && i.set("flat", "1");
12
- const t = i.size > 0 ? `?${i}` : "";
13
- return v.http.get(`${u}${t}`).then(p);
10
+ const s = new URLSearchParams();
11
+ l.parent != null && s.set("parent", String(l.parent)), l.search && s.set("search", l.search), l.status && s.set("status", l.status), l.trashed && s.set("trashed", "1"), l.flat && s.set("flat", "1");
12
+ const t = s.size > 0 ? `?${s}` : "";
13
+ return u.http.get(`${r}${t}`).then(h);
14
14
  },
15
- get: (l) => v.http.get(`${u}/${l}`).then(p),
16
- create: (l) => v.http.post(u, l).then(p),
17
- save: (l, i) => v.http.put(`${u}/${l}`, i).then(p),
18
- move: (l, i, t) => v.http.post(`${u}/${l}/move`, { target: i, zone: t }).then(p),
19
- duplicate: (l) => v.http.post(`${u}/${l}/duplicate`, {}).then(p),
20
- publish: (l) => v.http.post(`${u}/${l}/publish`, {}).then(p),
21
- unpublish: (l) => v.http.post(`${u}/${l}/unpublish`, {}).then(p),
22
- remove: (l) => v.http.delete(`${u}/${l}`).then((i) => i.data.trashed),
23
- restore: (l) => v.http.post(`${u}/${l}/restore`, {}).then((i) => i.data.restored),
24
- versions: (l) => v.http.get(`${u}/${l}/versions`).then(p),
25
- restoreVersion: (l, i) => v.http.post(`${u}/${l}/versions/${i}/restore`, {}).then(p)
15
+ get: (l) => u.http.get(`${r}/${l}`).then(h),
16
+ create: (l) => u.http.post(r, l).then(h),
17
+ save: (l, s) => u.http.put(`${r}/${l}`, s).then(h),
18
+ move: (l, s, t) => u.http.post(`${r}/${l}/move`, { target: s, zone: t }).then(h),
19
+ duplicate: (l) => u.http.post(`${r}/${l}/duplicate`, {}).then(h),
20
+ publish: (l) => u.http.post(`${r}/${l}/publish`, {}).then(h),
21
+ unpublish: (l) => u.http.post(`${r}/${l}/unpublish`, {}).then(h),
22
+ remove: (l) => u.http.delete(`${r}/${l}`).then((s) => s.data.trashed),
23
+ restore: (l) => u.http.post(`${r}/${l}/restore`, {}).then((s) => s.data.restored),
24
+ versions: (l) => u.http.get(`${r}/${l}/versions`).then(h),
25
+ restoreVersion: (l, s) => u.http.post(`${r}/${l}/versions/${s}/restore`, {}).then(h)
26
26
  };
27
27
  }
28
- const He = /* @__PURE__ */ Symbol("wx-page-editor");
29
- function ct(v) {
30
- Ge(He, v);
28
+ const Ee = /* @__PURE__ */ Symbol("wx-page-editor");
29
+ function gt(u) {
30
+ Oe(Ee, u);
31
31
  }
32
- function ze() {
33
- return je(He, null);
32
+ function ke() {
33
+ return Le(Ee, null);
34
34
  }
35
- const pt = {
35
+ const vt = {
36
36
  module: {
37
37
  title: "Pages"
38
38
  },
@@ -78,6 +78,7 @@ const pt = {
78
78
  "move-title": "Move “:title”",
79
79
  "move-help": "Pick the page it goes inside. Everything under it moves too, and their addresses change with it.",
80
80
  "move-confirm": "Move",
81
+ "move-branch": ":count addresses change — the page and everything inside it. The old ones will redirect to the new ones.",
81
82
  moved: "Moved. :count addresses changed; the old ones now redirect to the new ones.",
82
83
  "moved-one": "Moved. The address changed; the old one now redirects to it.",
83
84
  "delete-title": "Delete “:title”?",
@@ -85,6 +86,10 @@ const pt = {
85
86
  "delete-branch": "The :count pages inside it go with it.",
86
87
  deleted: "The page is in the bin.",
87
88
  restored: "The page is back.",
89
+ "restore-page-title": "Bring “:title” back?",
90
+ "restore-page-text": "The page leaves the bin and takes its address back. One that was on the site answers again.",
91
+ "restore-branch": "The :count pages that went in with it come back too.",
92
+ "restored-branch": ":count pages are back.",
88
93
  "copy-of": ":title (copy)",
89
94
  duplicated: "The copy is ready, and it is not on the site.",
90
95
  "address-copied": "The address is on the clipboard.",
@@ -97,6 +102,9 @@ const pt = {
97
102
  save: "Save",
98
103
  "save-failed": "The page was not saved.",
99
104
  publish: "Publish",
105
+ "publish-title": "Put “:title” on the site?",
106
+ "publish-text": "It answers at :address from the moment you do, for everyone.",
107
+ "publish-text-nowhere": "It starts answering on the site from the moment you do, for everyone.",
100
108
  published: "The page is on the site.",
101
109
  preview: "Preview",
102
110
  more: "More",
@@ -129,129 +137,126 @@ const pt = {
129
137
  "restore-text": "It becomes the draft. The site keeps showing what is published until you publish this.",
130
138
  "restored-version": "Version :number is now the draft."
131
139
  }
132
- }, Be = /* @__PURE__ */ new WeakSet();
133
- function G() {
140
+ }, Ce = /* @__PURE__ */ new WeakSet();
141
+ function H() {
134
142
  try {
135
- const { i18n: v } = X();
136
- Be.has(v) || (v.defaults("webx-pages", pt), Be.add(v));
143
+ const { i18n: u } = G();
144
+ Ce.has(u) || (u.defaults("webx-pages", vt), Ce.add(u));
137
145
  } catch {
138
146
  }
139
147
  }
140
- const gt = { class: "wx-page-danger" }, vt = {
148
+ const ht = { class: "wx-page-danger" }, ft = {
141
149
  key: 0,
142
150
  class: "wx-page-danger__row"
143
- }, ft = { class: "wx-page-danger__what" }, ht = { class: "wx-page-danger__row" }, mt = { class: "wx-page-danger__what" }, yt = /* @__PURE__ */ H({
151
+ }, mt = { class: "wx-page-danger__what" }, bt = { class: "wx-page-danger__row" }, _t = { class: "wx-page-danger__what" }, yt = /* @__PURE__ */ K({
144
152
  name: "WxPageDanger",
145
153
  __name: "PageDanger",
146
- setup(v) {
147
- const u = X(), p = Z(u), l = Ce(), i = ze();
148
- G();
149
- const t = j("webx-pages"), c = P(!1), a = V(() => i?.page.value ?? null), o = V(() => u.can("pages.manage"));
150
- async function s() {
151
- const $ = a.value;
152
- if (!(!$ || !await le({
153
- title: t("page.unpublish-title", { title: $.title }),
154
+ setup(u) {
155
+ const r = G(), h = Z(r), l = ye(), s = ke();
156
+ H();
157
+ const t = F("webx-pages"), d = ie(), a = k(!1), c = W(() => s?.page.value ?? null), f = W(() => r.can("pages.manage"));
158
+ async function i() {
159
+ const x = c.value;
160
+ if (!(!x || !await O({
161
+ title: t("page.unpublish-title", { title: x.title }),
154
162
  message: t("page.unpublish-text"),
155
163
  confirmText: t("page.unpublish"),
156
164
  cancelText: t("page.cancel"),
157
165
  tone: "danger"
158
166
  }))) {
159
- c.value = !0;
167
+ a.value = !0;
160
168
  try {
161
- await p.unpublish($.id), await i?.reload(), z.success(t("page.unpublished"));
162
- } catch (y) {
163
- z.danger(k(y));
169
+ await h.unpublish(x.id), await s?.reload(), z.success(t("page.unpublished"));
170
+ } catch (_) {
171
+ z.danger(d(_));
164
172
  } finally {
165
- c.value = !1;
173
+ a.value = !1;
166
174
  }
167
175
  }
168
176
  }
169
- async function C() {
170
- const $ = a.value;
171
- if (!(!$ || !await le({
172
- title: t("page.delete-title", { title: $.title }),
177
+ async function T() {
178
+ const x = c.value;
179
+ if (!(!x || !await O({
180
+ title: t("page.delete-title", { title: x.title }),
173
181
  // The whole branch, not the level under it (§7): a catalogue with two sections and forty
174
182
  // products is forty-two pages leaving the site at once.
175
- message: $.descendants_count > 0 ? `${t("page.delete-text")} ${t("page.delete-branch", { count: $.descendants_count })}` : t("page.delete-text"),
183
+ message: x.descendants_count > 0 ? `${t("page.delete-text")} ${t("page.delete-branch", { count: x.descendants_count })}` : t("page.delete-text"),
176
184
  confirmText: t("page.delete"),
177
185
  cancelText: t("page.cancel"),
178
186
  tone: "danger"
179
187
  }))) {
180
- c.value = !0;
188
+ a.value = !0;
181
189
  try {
182
- await p.remove($.id), z.success(t("page.deleted")), l.push(i?.base ?? "/pages");
183
- } catch (y) {
184
- z.danger(k(y));
190
+ await h.remove(x.id), z.success(t("page.deleted")), l.push(s?.base ?? "/pages");
191
+ } catch (_) {
192
+ z.danger(d(_));
185
193
  } finally {
186
- c.value = !1;
194
+ a.value = !1;
187
195
  }
188
196
  }
189
197
  }
190
- function k($) {
191
- return $.body?.message ?? String($);
192
- }
193
- return ($, T) => a.value && o.value ? (d(), x(e(Oe), {
198
+ return (x, C) => c.value && f.value ? (m(), V(e(at), {
194
199
  key: 0,
195
200
  title: e(t)("page.danger")
196
201
  }, {
197
202
  default: n(() => [
198
- N("div", gt, [
199
- a.value.status !== "draft" ? (d(), M("div", vt, [
200
- N("div", ft, [
201
- f(e(O), { weight: "medium" }, {
203
+ E("div", ht, [
204
+ c.value.status !== "draft" ? (m(), A("div", ft, [
205
+ E("div", mt, [
206
+ g(e(R), { weight: "medium" }, {
202
207
  default: n(() => [
203
- h(g(e(t)("page.unpublish")), 1)
208
+ y(b(e(t)("page.unpublish")), 1)
204
209
  ]),
205
210
  _: 1
206
211
  }),
207
- f(e(O), {
212
+ g(e(R), {
208
213
  size: "sm",
209
214
  tone: "muted"
210
215
  }, {
211
216
  default: n(() => [
212
- h(g(e(t)("page.unpublish-help")), 1)
217
+ y(b(e(t)("page.unpublish-help")), 1)
213
218
  ]),
214
219
  _: 1
215
220
  })
216
221
  ]),
217
- f(e(R), {
222
+ g(e(I), {
218
223
  variant: "outline",
219
- loading: c.value,
220
- onClick: s
224
+ loading: a.value,
225
+ onClick: i
221
226
  }, {
222
227
  default: n(() => [
223
- h(g(e(t)("page.unpublish")), 1)
228
+ y(b(e(t)("page.unpublish")), 1)
224
229
  ]),
225
230
  _: 1
226
231
  }, 8, ["loading"])
227
- ])) : D("", !0),
228
- N("div", ht, [
229
- N("div", mt, [
230
- f(e(O), { weight: "medium" }, {
232
+ ])) : N("", !0),
233
+ E("div", bt, [
234
+ E("div", _t, [
235
+ g(e(R), { weight: "medium" }, {
231
236
  default: n(() => [
232
- h(g(e(t)("page.delete")), 1)
237
+ y(b(e(t)("page.delete")), 1)
233
238
  ]),
234
239
  _: 1
235
240
  }),
236
- f(e(O), {
241
+ g(e(R), {
237
242
  size: "sm",
238
243
  tone: "muted"
239
244
  }, {
240
245
  default: n(() => [
241
- h(g(a.value.can.delete ? e(t)("page.delete-help") : e(t)("page.delete-home")), 1)
246
+ y(b(c.value.can.delete ? e(t)("page.delete-help") : e(t)("page.delete-home")), 1)
242
247
  ]),
243
248
  _: 1
244
249
  })
245
250
  ]),
246
- f(e(R), {
251
+ g(e(I), {
247
252
  type: "danger",
248
253
  variant: "outline",
249
- disabled: !a.value.can.delete,
250
- loading: c.value,
251
- onClick: C
254
+ disabled: !c.value.can.delete,
255
+ loading: a.value,
256
+ onClick: T
252
257
  }, {
253
258
  default: n(() => [
254
- h(g(e(t)("page.delete")), 1)
259
+ y(b(e(t)("page.delete")), 1)
255
260
  ]),
256
261
  _: 1
257
262
  }, 8, ["disabled", "loading"])
@@ -259,79 +264,79 @@ const gt = { class: "wx-page-danger" }, vt = {
259
264
  ])
260
265
  ]),
261
266
  _: 1
262
- }, 8, ["title"])) : D("", !0);
267
+ }, 8, ["title"])) : N("", !0);
263
268
  }
264
- }), de = (v, u) => {
265
- const p = v.__vccOpts || v;
266
- for (const [l, i] of u)
267
- p[l] = i;
268
- return p;
269
- }, bt = /* @__PURE__ */ de(yt, [["__scopeId", "data-v-94c0abe4"]]), _t = { class: "wx-page-editor__head" }, wt = { class: "wx-page-editor__id" }, xt = { class: "wx-page-editor__name" }, kt = { class: "wx-page-editor__title" }, $t = { class: "wx-page-editor__actions" }, Tt = { class: "wx-page-editor__screen" }, Pt = 1200, Ct = 720, Wt = /* @__PURE__ */ H({
269
+ }), re = (u, r) => {
270
+ const h = u.__vccOpts || u;
271
+ for (const [l, s] of r)
272
+ h[l] = s;
273
+ return h;
274
+ }, wt = /* @__PURE__ */ re(yt, [["__scopeId", "data-v-d4a9083f"]]), xt = { class: "wx-page-editor__head" }, kt = { class: "wx-page-editor__id" }, Tt = { class: "wx-page-editor__name" }, $t = { class: "wx-page-editor__title" }, Pt = { class: "wx-page-editor__actions" }, Wt = { class: "wx-page-editor__screen" }, Vt = 1200, zt = 720, Ct = /* @__PURE__ */ K({
270
275
  __name: "PageEditorPage",
271
276
  props: {
272
277
  base: { default: "/pages" }
273
278
  },
274
- setup(v) {
275
- const u = v, p = X(), l = Z(p), i = qe(), t = Ce(), c = Ue();
276
- G();
277
- const a = j("webx-pages"), o = V(() => Number(i.params.id)), s = P(null), C = P([]), k = P({}), $ = P(""), T = P(null), y = P({}), S = P(!0), W = P(!1), _ = P(!1), A = P({}), U = P(null), q = P(""), ce = P(0), I = V(() => p.can("pages.manage")), pe = Pe("root"), ge = Ie(pe), L = V(() => ge.value > 0 && ge.value < Ct), ee = V(() => JSON.stringify(k.value)), B = V(() => q.value !== "" && ee.value !== q.value), ne = V(() => W.value ? "saving" : B.value ? "unsaved" : "saved"), se = V(() => {
278
- const m = k.value.title;
279
- return at(m, c.active.value, s.value?.title ?? "");
280
- }), ve = V(
281
- () => C.value.map((m) => ({
282
- id: m.id,
283
- label: m.is_home ? a("pages.home") : m.title
279
+ setup(u) {
280
+ const r = u, h = G(), l = Z(h), s = Xe(), t = ye(), d = Se();
281
+ H();
282
+ const a = F("webx-pages"), c = ie(), f = W(() => Number(s.params.id)), i = k(null), T = k([]), x = k({}), C = k(""), _ = k(null), p = k({}), B = k(!0), $ = k(!1), D = k(!1), le = k({}), U = k(null), q = k(""), ue = k(0), M = W(() => h.can("pages.manage")), de = Be("root"), ee = lt(de), ce = W(() => ee.value > 0 && ee.value < zt), te = W(() => JSON.stringify(x.value)), L = W(() => q.value !== "" && te.value !== q.value), ge = W(() => $.value ? "saving" : L.value ? "unsaved" : "saved"), ne = W(() => {
283
+ const P = x.value.title;
284
+ return nt(P, d.active.value, i.value?.title ?? "");
285
+ }), ve = W(
286
+ () => T.value.map((P) => ({
287
+ id: P.id,
288
+ label: P.is_home ? a("pages.home") : P.title
284
289
  }))
285
290
  );
286
- dt({ url: V(() => T.value), reload: ce }), ct({
287
- page: s,
288
- ancestors: C,
289
- values: k,
290
- prefixes: y,
291
- base: u.base,
292
- canManage: I.value,
291
+ pt({ url: W(() => _.value), reload: ue }), gt({
292
+ page: i,
293
+ ancestors: T,
294
+ values: x,
295
+ prefixes: p,
296
+ base: r.base,
297
+ canManage: M.value,
293
298
  reload: () => J(!0),
294
- save: () => K()
299
+ save: () => v()
295
300
  });
296
- function be(m) {
297
- s.value = m.page, C.value = m.ancestors, k.value = m.values, $.value = m.revision, T.value = m.preview_url, y.value = m.address_prefix, q.value = JSON.stringify(m.values), U.value = null;
301
+ function he(P) {
302
+ i.value = P.page, T.value = P.ancestors, x.value = P.values, C.value = P.revision, _.value = P.preview_url, p.value = P.address_prefix, q.value = JSON.stringify(P.values), U.value = null;
298
303
  }
299
- async function J(m = !1) {
300
- m || (S.value = !0);
304
+ async function J(P = !1) {
305
+ P || (B.value = !0);
301
306
  try {
302
- be(await l.get(o.value));
303
- } catch (te) {
304
- z.danger(r(te)), t.push(u.base);
307
+ he(await l.get(f.value));
308
+ } catch (Y) {
309
+ z.danger(c(Y)), t.push(r.base);
305
310
  } finally {
306
- S.value = !1;
311
+ B.value = !1;
307
312
  }
308
313
  }
309
314
  let Q;
310
- function fe() {
311
- !I.value || U.value || !B.value || (clearTimeout(Q), Q = setTimeout(() => {
312
- K();
313
- }, Pt));
315
+ function o() {
316
+ !M.value || U.value || !L.value || (clearTimeout(Q), Q = setTimeout(() => {
317
+ v();
318
+ }, Vt));
314
319
  }
315
- function he() {
316
- !I.value || U.value || !B.value || W.value || (clearTimeout(Q), K());
320
+ function w() {
321
+ !M.value || U.value || !L.value || $.value || (clearTimeout(Q), v());
317
322
  }
318
- async function K() {
319
- if (!s.value || W.value || !I.value) return;
323
+ async function v() {
324
+ if (!i.value || $.value || !M.value) return;
320
325
  clearTimeout(Q);
321
- const m = ee.value, te = k.value;
322
- W.value = !0, A.value = {};
326
+ const P = te.value, Y = x.value;
327
+ $.value = !0, le.value = {};
323
328
  try {
324
- const E = await l.save(s.value.id, { values: te, revision: $.value });
325
- s.value = E.page, C.value = E.ancestors, $.value = E.revision, T.value = E.preview_url, y.value = E.address_prefix, U.value = null, ee.value === m && (q.value = m), ce.value += 1;
326
- } catch (E) {
327
- const oe = E;
328
- oe.status === 409 && oe.body?.data ? U.value = oe.body : oe.body?.errors ? (A.value = oe.body.errors, z.danger(a("page.save-failed"))) : z.danger(r(E));
329
+ const S = await l.save(i.value.id, { values: Y, revision: C.value });
330
+ i.value = S.page, T.value = S.ancestors, C.value = S.revision, _.value = S.preview_url, p.value = S.address_prefix, U.value = null, te.value === P && (q.value = P), ue.value += 1;
331
+ } catch (S) {
332
+ const se = S;
333
+ se.status === 409 && se.body?.data ? U.value = se.body : se.body?.errors ? (le.value = se.body.errors, z.danger(a("page.save-failed"))) : z.danger(c(S));
329
334
  } finally {
330
- W.value = !1;
335
+ $.value = !1;
331
336
  }
332
337
  }
333
- async function me() {
334
- await le({
338
+ async function X() {
339
+ await O({
335
340
  title: a("page.conflict-theirs-title"),
336
341
  message: a("page.conflict-theirs-text"),
337
342
  confirmText: a("page.conflict-theirs"),
@@ -339,371 +344,367 @@ const gt = { class: "wx-page-danger" }, vt = {
339
344
  tone: "danger"
340
345
  }) && await J(!0);
341
346
  }
342
- async function Y() {
343
- const m = U.value;
344
- m && ($.value = m.data.revision, U.value = null, await K());
347
+ async function Ie() {
348
+ const P = U.value;
349
+ P && (C.value = P.data.revision, U.value = null, await v());
345
350
  }
346
- async function _e() {
347
- if (s.value && (B.value && await K(), !U.value)) {
348
- _.value = !0;
351
+ async function Ue() {
352
+ if (!i.value) return;
353
+ const P = i.value.path === null ? null : `/${i.value.path}`;
354
+ if (await O({
355
+ title: a("page.publish-title", { title: i.value.title }),
356
+ message: P === null ? a("page.publish-text-nowhere") : a("page.publish-text", { address: P }),
357
+ confirmText: a("page.publish"),
358
+ cancelText: a("page.cancel")
359
+ }) && (L.value && await v(), !U.value)) {
360
+ D.value = !0;
349
361
  try {
350
- await l.publish(s.value.id), await J(!0), z.success(a("page.published"));
351
- } catch (m) {
352
- z.danger(r(m));
362
+ await l.publish(i.value.id), await J(!0), z.success(a("page.published"));
363
+ } catch (S) {
364
+ z.danger(c(S));
353
365
  } finally {
354
- _.value = !1;
366
+ D.value = !1;
355
367
  }
356
368
  }
357
369
  }
358
- function r(m) {
359
- return m.body?.message ?? String(m);
360
- }
361
- function b() {
362
- return s.value?.status === "published" ? "success" : s.value?.status === "modified" ? "warning" : "default";
370
+ function Re() {
371
+ return i.value?.status === "published" ? "success" : i.value?.status === "modified" ? "warning" : "default";
363
372
  }
364
- function w(m) {
365
- B.value && m.preventDefault();
373
+ function $e(P) {
374
+ L.value && P.preventDefault();
366
375
  }
367
- return ae(ee, fe), ae(o, () => {
376
+ return ae(te, o), ae(f, () => {
368
377
  J();
369
- }), ye(() => {
370
- J(), window.addEventListener("beforeunload", w);
371
- }), Je(() => {
372
- clearTimeout(Q), window.removeEventListener("beforeunload", w);
373
- }), et(async () => !B.value || !I.value || (await K(), !B.value) ? !0 : await le({
378
+ }), pe(() => {
379
+ J(), window.addEventListener("beforeunload", $e);
380
+ }), Ke(() => {
381
+ clearTimeout(Q), window.removeEventListener("beforeunload", $e);
382
+ }), Ye(async () => !L.value || !M.value || (await v(), !L.value) ? !0 : await O({
374
383
  title: a("page.leave-title"),
375
384
  message: a("page.leave-text"),
376
385
  confirmText: a("page.leave"),
377
386
  cancelText: a("page.cancel"),
378
387
  tone: "danger"
379
- })), (m, te) => (d(), M("div", {
388
+ })), (P, Y) => (m(), A("div", {
380
389
  ref_key: "root",
381
- ref: pe,
390
+ ref: de,
382
391
  class: "wx-page-editor",
383
- "data-wx-fill": "",
384
- onFocusout: he
392
+ onFocusout: w
385
393
  }, [
386
- S.value || !s.value ? (d(), M(F, { key: 0 }, [
387
- f(e(ke), {
394
+ B.value || !i.value ? (m(), A(j, { key: 0 }, [
395
+ g(e(be), {
388
396
  class: "wx-page-editor__ghost",
389
397
  title: "",
390
398
  rows: 1
391
399
  }),
392
- f(e(ke), { rows: 8 })
393
- ], 64)) : (d(), M(F, { key: 1 }, [
394
- N("div", _t, [
395
- N("div", wt, [
396
- f(e(lt), {
400
+ g(e(be), { rows: 8 })
401
+ ], 64)) : (m(), A(j, { key: 1 }, [
402
+ E("div", xt, [
403
+ g(e(Ze), {
404
+ class: "wx-page-editor__back",
405
+ to: u.base,
406
+ label: e(a)("module.title")
407
+ }, null, 8, ["to", "label"]),
408
+ E("div", kt, [
409
+ g(e(st), {
397
410
  size: "sm",
398
411
  label: e(a)("page.trail")
399
412
  }, {
400
413
  default: n(() => [
401
- f(e(we), {
414
+ g(e(fe), {
402
415
  as: "router-link",
403
- to: v.base
416
+ to: u.base
404
417
  }, {
405
418
  default: n(() => [
406
- h(g(e(a)("module.title")), 1)
419
+ y(b(e(a)("module.title")), 1)
407
420
  ]),
408
421
  _: 1
409
422
  }, 8, ["to"]),
410
- (d(!0), M(F, null, ie(ve.value, (E) => (d(), x(e(we), {
411
- key: E.id,
423
+ (m(!0), A(j, null, Me(ve.value, (S) => (m(), V(e(fe), {
424
+ key: S.id,
412
425
  as: "router-link",
413
- to: `${v.base}/${E.id}`
426
+ to: `${u.base}/${S.id}`
414
427
  }, {
415
428
  default: n(() => [
416
- h(g(E.label), 1)
429
+ y(b(S.label), 1)
417
430
  ]),
418
431
  _: 2
419
432
  }, 1032, ["to"]))), 128)),
420
- f(e(we), { current: "" }, {
433
+ g(e(fe), { current: "" }, {
421
434
  default: n(() => [
422
- h(g(s.value.is_home ? e(a)("pages.home") : se.value), 1)
435
+ y(b(i.value.is_home ? e(a)("pages.home") : ne.value), 1)
423
436
  ]),
424
437
  _: 1
425
438
  })
426
439
  ]),
427
440
  _: 1
428
441
  }, 8, ["label"]),
429
- N("div", xt, [
430
- N("span", kt, g(s.value.is_home ? e(a)("pages.home") : se.value || e(a)("page.untitled")), 1),
431
- f(e(We), {
432
- type: b(),
442
+ E("div", Tt, [
443
+ E("span", $t, b(i.value.is_home ? e(a)("pages.home") : ne.value || e(a)("page.untitled")), 1),
444
+ g(e(we), {
445
+ type: Re(),
433
446
  dot: ""
434
447
  }, {
435
448
  default: n(() => [
436
- h(g(e(a)(`page.status-${s.value.status}`)), 1)
449
+ y(b(e(a)(`page.status-${i.value.status}`)), 1)
437
450
  ]),
438
451
  _: 1
439
- }, 8, ["type"]),
440
- f(e(O), {
441
- size: "sm",
442
- tone: "muted",
443
- class: "wx-page-editor__state"
444
- }, {
445
- default: n(() => [
446
- h(g(e(a)(`page.state-${ne.value}`)), 1)
447
- ]),
448
- _: 1
449
- })
452
+ }, 8, ["type"])
450
453
  ])
451
454
  ]),
452
- N("div", $t, [
453
- L.value ? (d(), x(e(Le), {
455
+ E("div", Pt, [
456
+ ce.value ? (m(), V(e(ot), {
454
457
  key: 0,
455
458
  align: "end"
456
459
  }, {
457
460
  trigger: n(() => [
458
- f(e($e), {
461
+ g(e(it), {
459
462
  type: "more",
460
463
  title: e(a)("page.more")
461
464
  }, null, 8, ["title"])
462
465
  ]),
463
466
  default: n(() => [
464
- T.value ? (d(), x(e(re), {
467
+ _.value ? (m(), V(e(We), {
465
468
  key: 0,
466
469
  icon: "eye",
467
- href: T.value,
470
+ href: _.value,
468
471
  target: "_blank",
469
472
  rel: "noopener"
470
473
  }, {
471
474
  default: n(() => [
472
- h(g(e(a)("page.preview")), 1)
475
+ y(b(e(a)("page.preview")), 1)
473
476
  ]),
474
477
  _: 1
475
- }, 8, ["href"])) : D("", !0),
476
- s.value.url && s.value.status !== "draft" ? (d(), x(e(re), {
478
+ }, 8, ["href"])) : N("", !0),
479
+ i.value.url && i.value.status !== "draft" ? (m(), V(e(We), {
477
480
  key: 1,
478
481
  icon: "link",
479
- href: s.value.url,
482
+ href: i.value.url,
480
483
  target: "_blank",
481
484
  rel: "noopener"
482
485
  }, {
483
486
  default: n(() => [
484
- h(g(e(a)("page.open-on-site")), 1)
485
- ]),
486
- _: 1
487
- }, 8, ["href"])) : D("", !0),
488
- I.value ? (d(), x(e(re), {
489
- key: 2,
490
- icon: "check",
491
- disabled: !B.value,
492
- onClick: K
493
- }, {
494
- default: n(() => [
495
- h(g(e(a)("page.save")), 1)
487
+ y(b(e(a)("page.open-on-site")), 1)
496
488
  ]),
497
489
  _: 1
498
- }, 8, ["disabled"])) : D("", !0)
490
+ }, 8, ["href"])) : N("", !0)
499
491
  ]),
500
492
  _: 1
501
- })) : (d(), M(F, { key: 1 }, [
502
- T.value ? (d(), x(e(R), {
493
+ })) : (m(), A(j, { key: 1 }, [
494
+ _.value ? (m(), V(e(I), {
503
495
  key: 0,
504
- variant: "text",
496
+ variant: "outline",
505
497
  icon: "eye",
506
- href: T.value,
498
+ href: _.value,
507
499
  target: "_blank",
508
500
  rel: "noopener"
509
501
  }, {
510
502
  default: n(() => [
511
- h(g(e(a)("page.preview")), 1)
503
+ y(b(e(a)("page.preview")), 1)
512
504
  ]),
513
505
  _: 1
514
- }, 8, ["href"])) : D("", !0),
515
- s.value.url && s.value.status !== "draft" ? (d(), x(e(R), {
506
+ }, 8, ["href"])) : N("", !0),
507
+ i.value.url && i.value.status !== "draft" ? (m(), V(e(I), {
516
508
  key: 1,
517
- variant: "text",
509
+ variant: "outline",
518
510
  icon: "link",
519
- href: s.value.url,
511
+ href: i.value.url,
520
512
  target: "_blank",
521
513
  rel: "noopener"
522
514
  }, {
523
515
  default: n(() => [
524
- h(g(e(a)("page.open-on-site")), 1)
516
+ y(b(e(a)("page.open-on-site")), 1)
525
517
  ]),
526
518
  _: 1
527
- }, 8, ["href"])) : D("", !0),
528
- I.value ? (d(), x(e(R), {
529
- key: 2,
530
- variant: "outline",
531
- loading: W.value,
532
- disabled: !B.value,
533
- onClick: K
534
- }, {
535
- default: n(() => [
536
- h(g(e(a)("page.save")), 1)
537
- ]),
538
- _: 1
539
- }, 8, ["loading", "disabled"])) : D("", !0)
540
- ], 64)),
541
- I.value ? (d(), x(e(R), {
542
- key: 2,
543
- type: "primary",
544
- loading: _.value,
545
- disabled: s.value.status === "published" && !B.value,
546
- onClick: _e
547
- }, {
548
- default: n(() => [
549
- h(g(e(a)("page.publish")), 1)
550
- ]),
551
- _: 1
552
- }, 8, ["loading", "disabled"])) : D("", !0)
519
+ }, 8, ["href"])) : N("", !0)
520
+ ], 64))
553
521
  ])
554
522
  ]),
555
- U.value ? (d(), x(e(Ve), {
523
+ U.value ? (m(), V(e(xe), {
556
524
  key: 0,
557
525
  type: "warning",
558
526
  title: e(a)("page.conflict-title"),
559
527
  description: U.value.message
560
528
  }, {
561
529
  actions: n(() => [
562
- f(e(R), {
530
+ g(e(I), {
563
531
  size: "sm",
564
532
  variant: "outline",
565
- onClick: me
533
+ onClick: X
566
534
  }, {
567
535
  default: n(() => [
568
- h(g(e(a)("page.conflict-theirs")), 1)
536
+ y(b(e(a)("page.conflict-theirs")), 1)
569
537
  ]),
570
538
  _: 1
571
539
  }),
572
- f(e(R), {
540
+ g(e(I), {
573
541
  size: "sm",
574
542
  type: "primary",
575
- onClick: Y
543
+ onClick: Ie
576
544
  }, {
577
545
  default: n(() => [
578
- h(g(e(a)("page.conflict-mine")), 1)
546
+ y(b(e(a)("page.conflict-mine")), 1)
579
547
  ]),
580
548
  _: 1
581
549
  })
582
550
  ]),
583
551
  _: 1
584
- }, 8, ["title", "description"])) : D("", !0),
585
- N("div", Tt, [
586
- f(e(tt), {
587
- modelValue: k.value,
588
- "onUpdate:modelValue": te[0] || (te[0] = (E) => k.value = E),
552
+ }, 8, ["title", "description"])) : N("", !0),
553
+ E("div", Wt, [
554
+ g(e(qe), {
555
+ modelValue: x.value,
556
+ "onUpdate:modelValue": Y[0] || (Y[0] = (S) => x.value = S),
589
557
  name: "pages.form",
590
- errors: A.value,
591
- disabled: !I.value || _.value
558
+ errors: le.value,
559
+ disabled: !M.value || D.value
592
560
  }, null, 8, ["modelValue", "errors", "disabled"])
593
- ])
561
+ ]),
562
+ M.value ? (m(), V(e(rt), { key: 1 }, {
563
+ state: n(() => [
564
+ g(e(R), {
565
+ size: "sm",
566
+ tone: "muted"
567
+ }, {
568
+ default: n(() => [
569
+ y(b(e(a)(`page.state-${ge.value}`)), 1)
570
+ ]),
571
+ _: 1
572
+ })
573
+ ]),
574
+ default: n(() => [
575
+ g(e(I), {
576
+ variant: "outline",
577
+ loading: $.value,
578
+ disabled: !L.value,
579
+ onClick: v
580
+ }, {
581
+ default: n(() => [
582
+ y(b(e(a)("page.save")), 1)
583
+ ]),
584
+ _: 1
585
+ }, 8, ["loading", "disabled"]),
586
+ g(e(I), {
587
+ type: "primary",
588
+ loading: D.value,
589
+ disabled: i.value.status === "published" && !L.value,
590
+ onClick: Ue
591
+ }, {
592
+ default: n(() => [
593
+ y(b(e(a)("page.publish")), 1)
594
+ ]),
595
+ _: 1
596
+ }, 8, ["loading", "disabled"])
597
+ ]),
598
+ _: 1
599
+ })) : N("", !0)
594
600
  ], 64))
595
601
  ], 544));
596
602
  }
597
- }), Vt = /* @__PURE__ */ de(Wt, [["__scopeId", "data-v-861519ac"]]), zt = { class: "wx-page-history" }, St = { class: "wx-page-history__number" }, Dt = { class: "wx-page-history__who" }, Mt = /* @__PURE__ */ H({
603
+ }), Bt = /* @__PURE__ */ re(Ct, [["__scopeId", "data-v-268d0501"]]), Mt = { class: "wx-page-history" }, Dt = { class: "wx-page-history__number" }, St = { class: "wx-page-history__who" }, Nt = /* @__PURE__ */ K({
598
604
  name: "WxPageHistory",
599
605
  __name: "PageHistory",
600
- setup(v) {
601
- const u = X(), p = Z(u), l = ze();
602
- G();
603
- const i = j("webx-pages"), t = P(null), c = P(!1), a = V(() => l?.page.value ?? null), o = V(() => u.can("pages.manage")), s = V(
604
- () => a.value?.published_at ? t.value?.[0]?.number ?? null : null
606
+ setup(u) {
607
+ const r = G(), h = Z(r), l = ke();
608
+ H();
609
+ const s = F("webx-pages"), t = ie(), d = k(null), a = k(!1), c = W(() => l?.page.value ?? null), f = W(() => r.can("pages.manage")), i = W(
610
+ () => c.value?.published_at ? d.value?.[0]?.number ?? null : null
605
611
  );
606
- async function C() {
607
- const y = a.value;
608
- if (y)
612
+ async function T() {
613
+ const C = c.value;
614
+ if (C)
609
615
  try {
610
- t.value = await p.versions(y.id);
611
- } catch (S) {
612
- t.value = [], z.danger(T(S));
616
+ d.value = await h.versions(C.id);
617
+ } catch (_) {
618
+ d.value = [], z.danger(t(_));
613
619
  }
614
620
  }
615
- async function k(y) {
616
- const S = a.value;
617
- if (!(!S || !await le({
618
- title: i("page.restore-title", { number: y.number }),
619
- message: i("page.restore-text"),
620
- confirmText: i("page.restore"),
621
- cancelText: i("page.cancel")
621
+ async function x(C) {
622
+ const _ = c.value;
623
+ if (!(!_ || !await O({
624
+ title: s("page.restore-title", { number: C.number }),
625
+ message: s("page.restore-text"),
626
+ confirmText: s("page.restore"),
627
+ cancelText: s("page.cancel")
622
628
  }))) {
623
- c.value = !0;
629
+ a.value = !0;
624
630
  try {
625
- await p.restoreVersion(S.id, y.number), await l?.reload(), z.success(i("page.restored-version", { number: y.number }));
626
- } catch (_) {
627
- z.danger(T(_));
631
+ await h.restoreVersion(_.id, C.number), await l?.reload(), z.success(s("page.restored-version", { number: C.number }));
632
+ } catch (B) {
633
+ z.danger(t(B));
628
634
  } finally {
629
- c.value = !1;
635
+ a.value = !1;
630
636
  }
631
637
  }
632
638
  }
633
- function $(y) {
634
- return y.created_at ? new Date(y.created_at).toLocaleString(u.i18n.state.locale) : "";
635
- }
636
- function T(y) {
637
- return y.body?.message ?? String(y);
638
- }
639
639
  return ae(
640
- () => [a.value?.id, a.value?.published_at, a.value?.updated_at],
640
+ () => [c.value?.id, c.value?.published_at, c.value?.updated_at],
641
641
  () => {
642
- C();
642
+ T();
643
643
  },
644
644
  {
645
645
  immediate: !0
646
646
  }
647
- ), (y, S) => (d(), M("div", zt, [
648
- t.value === null ? (d(), x(e(ke), {
647
+ ), (C, _) => (m(), A("div", Mt, [
648
+ d.value === null ? (m(), V(e(be), {
649
649
  key: 0,
650
+ class: "wx-page-history__ghost",
650
651
  rows: 3
651
- })) : t.value.length === 0 ? (d(), x(e(nt), {
652
+ })) : d.value.length === 0 ? (m(), V(e(ut), {
652
653
  key: 1,
653
- description: e(i)("page.history-empty")
654
- }, null, 8, ["description"])) : (d(!0), M(F, { key: 2 }, ie(t.value, (W) => (d(), M("div", {
655
- key: W.number,
656
- class: Qe(["wx-page-history__row", { "is-live": W.number === s.value }])
654
+ description: e(s)("page.history-empty")
655
+ }, null, 8, ["description"])) : (m(!0), A(j, { key: 2 }, Me(d.value, (p) => (m(), A("div", {
656
+ key: p.number,
657
+ class: Fe(["wx-page-history__row", { "is-live": p.number === i.value }])
657
658
  }, [
658
- N("code", St, g(e(i)("page.version", { number: W.number })), 1),
659
- N("div", Dt, [
660
- f(e(O), null, {
661
- default: n(() => [
662
- h(g($(W)), 1)
663
- ]),
664
- _: 2
665
- }, 1024),
666
- f(e(O), {
659
+ E("code", Dt, b(e(s)("page.version", { number: p.number })), 1),
660
+ E("div", St, [
661
+ p.created_at ? (m(), V(e(me), {
662
+ key: 0,
663
+ value: p.created_at,
664
+ size: "md",
665
+ tone: "default"
666
+ }, null, 8, ["value"])) : N("", !0),
667
+ g(e(R), {
667
668
  size: "sm",
668
669
  tone: "muted"
669
670
  }, {
670
671
  default: n(() => [
671
- h(g(W.author ?? e(i)(`page.source-${W.source}`)) + " ", 1),
672
- W.comment ? (d(), M(F, { key: 0 }, [
673
- h(" · " + g(W.comment), 1)
674
- ], 64)) : D("", !0)
672
+ y(b(p.author ?? e(s)(`page.source-${p.source}`)) + " ", 1),
673
+ p.comment ? (m(), A(j, { key: 0 }, [
674
+ y(" · " + b(p.comment), 1)
675
+ ], 64)) : N("", !0)
675
676
  ]),
676
677
  _: 2
677
678
  }, 1024)
678
679
  ]),
679
- W.number === s.value ? (d(), x(e(We), {
680
+ p.number === i.value ? (m(), V(e(we), {
680
681
  key: 0,
681
682
  type: "success",
682
683
  dot: ""
683
684
  }, {
684
685
  default: n(() => [
685
- h(g(e(i)("page.version-live")), 1)
686
+ y(b(e(s)("page.version-live")), 1)
686
687
  ]),
687
688
  _: 1
688
- })) : D("", !0),
689
- o.value && W.number !== s.value ? (d(), x(e(R), {
689
+ })) : N("", !0),
690
+ f.value && p.number !== i.value ? (m(), V(e(I), {
690
691
  key: 1,
691
692
  size: "sm",
692
693
  variant: "outline",
693
- loading: c.value,
694
- onClick: (_) => k(W)
694
+ loading: a.value,
695
+ onClick: (B) => x(p)
695
696
  }, {
696
697
  default: n(() => [
697
- h(g(e(i)("page.restore")), 1)
698
+ y(b(e(s)("page.restore")), 1)
698
699
  ]),
699
700
  _: 1
700
- }, 8, ["loading", "onClick"])) : D("", !0)
701
+ }, 8, ["loading", "onClick"])) : N("", !0)
701
702
  ], 2))), 128))
702
703
  ]));
703
704
  }
704
- }), At = /* @__PURE__ */ de(Mt, [["__scopeId", "data-v-d24bb671"]]), Se = /* @__PURE__ */ H({
705
+ }), At = /* @__PURE__ */ re(Nt, [["__scopeId", "data-v-41bcd106"]]), Te = /* @__PURE__ */ K({
705
706
  __name: "PagePicker",
706
- props: /* @__PURE__ */ Ye({
707
+ props: /* @__PURE__ */ je({
707
708
  exclude: { default: () => [] },
708
709
  placeholder: { default: void 0 },
709
710
  selected: { default: () => [] }
@@ -712,284 +713,205 @@ const gt = { class: "wx-page-danger" }, vt = {
712
713
  modelModifiers: {}
713
714
  }),
714
715
  emits: ["update:modelValue"],
715
- setup(v) {
716
- const u = v, p = Xe(v, "modelValue"), l = X(), i = Z(l);
717
- G();
718
- const t = j("webx-pages"), c = P([]);
719
- ye(async () => {
720
- const s = await i.list();
721
- s.home && (c.value = [
716
+ setup(u) {
717
+ const r = u, h = He(u, "modelValue"), l = G(), s = Z(l);
718
+ H();
719
+ const t = F("webx-pages"), d = k([]);
720
+ pe(async () => {
721
+ const f = await s.list();
722
+ f.home && (d.value = [
722
723
  a(
723
- s.home,
724
- s.items.map((C) => a(C))
724
+ f.home,
725
+ f.items.map((i) => a(i))
725
726
  )
726
727
  ]);
727
728
  });
728
- function a(s, C) {
729
+ function a(f, i) {
729
730
  return {
730
- id: s.id,
731
- label: s.is_home ? t("pages.home") : s.title,
732
- disabled: u.exclude.includes(s.id),
733
- leaf: s.children_count === 0,
734
- ...C ? { children: C } : {}
731
+ id: f.id,
732
+ label: f.is_home ? t("pages.home") : f.title,
733
+ disabled: r.exclude.includes(f.id),
734
+ leaf: f.children_count === 0,
735
+ ...i ? { children: i } : {}
735
736
  };
736
737
  }
737
- async function o(s) {
738
- return (await i.list({ parent: Number(s.id) })).items.map((k) => a(k));
738
+ async function c(f) {
739
+ return (await s.list({ parent: Number(f.id) })).items.map((T) => a(T));
739
740
  }
740
- return (s, C) => (d(), x(e(st), {
741
- modelValue: p.value,
742
- "onUpdate:modelValue": C[0] || (C[0] = (k) => p.value = k),
743
- nodes: c.value,
741
+ return (f, i) => (m(), V(e(dt), {
742
+ modelValue: h.value,
743
+ "onUpdate:modelValue": i[0] || (i[0] = (T) => h.value = T),
744
+ nodes: d.value,
744
745
  lazy: "",
745
- load: o,
746
+ load: c,
746
747
  "show-path": "",
747
748
  clearable: "",
748
- "selected-path": u.selected.map((k) => ({
749
- id: k.id,
750
- label: k.is_home ? e(t)("pages.home") : k.title
749
+ "selected-path": r.selected.map((T) => ({
750
+ id: T.id,
751
+ label: T.is_home ? e(t)("pages.home") : T.title
751
752
  })),
752
- placeholder: u.placeholder ?? e(t)("page.field-parent"),
753
+ placeholder: r.placeholder ?? e(t)("page.field-parent"),
753
754
  "aria-label": e(t)("page.field-parent"),
754
755
  teleport: ""
755
756
  }, null, 8, ["modelValue", "nodes", "selected-path", "placeholder", "aria-label"]));
756
757
  }
757
- }), Bt = {
758
+ }), Et = {
758
759
  key: 0,
759
760
  class: "wx-page-place"
760
- }, Nt = /* @__PURE__ */ H({
761
+ }, It = /* @__PURE__ */ K({
761
762
  name: "WxPagePlace",
762
763
  __name: "PagePlace",
763
- setup(v) {
764
- const u = X(), p = Z(u), l = ze(), i = Ue();
765
- G();
766
- const t = j("webx-pages"), c = P(!1), a = P(null), o = V(() => l?.page.value ?? null), s = V(() => l?.ancestors.value.length === 0 ? null : l?.prefixes.value[i.active.value] ?? null), C = V(() => {
767
- const T = l?.values.value.slug;
768
- return typeof T == "string" ? T : T?.[i.active.value] ?? "";
769
- }), k = V(() => o.value?.is_home ? "/" : s.value === null || C.value === "" ? null : `/${[s.value, C.value].filter(Boolean).join("/")}`);
764
+ setup(u) {
765
+ const r = G(), h = Z(r), l = ke(), s = Se();
766
+ H();
767
+ const t = F("webx-pages"), d = ie(), a = k(!1), c = k(null), f = W(() => l?.page.value ?? null), i = W(() => l?.ancestors.value.length === 0 ? null : l?.prefixes.value[s.active.value] ?? null), T = W(() => {
768
+ const _ = l?.values.value.slug;
769
+ return typeof _ == "string" ? _ : _?.[s.active.value] ?? "";
770
+ }), x = W(() => f.value?.is_home ? "/" : i.value === null || T.value === "" ? null : `/${[i.value, T.value].filter(Boolean).join("/")}`);
770
771
  ae(
771
- o,
772
- (T) => {
773
- a.value = T?.parent_id ?? null;
772
+ f,
773
+ (_) => {
774
+ c.value = _?.parent_id ?? null;
774
775
  },
775
776
  { immediate: !0 }
776
777
  );
777
- async function $(T) {
778
- const y = o.value;
779
- if (!(!y || T === null || T === y.parent_id || c.value)) {
780
- c.value = !0;
781
- try {
782
- const S = await p.move(y.id, T, "inside");
783
- z.success(
784
- S.addresses_changed > 1 ? t("page.moved", { count: S.addresses_changed }) : t("page.moved-one")
785
- ), await l?.reload();
786
- } catch (S) {
787
- z.danger(S.body?.message ?? String(S)), a.value = y.parent_id;
788
- } finally {
789
- c.value = !1;
790
- }
778
+ async function C(_) {
779
+ const p = f.value;
780
+ if (!p || _ === null || _ === p.parent_id || a.value) return;
781
+ const B = p.descendants_count + 1;
782
+ if (B > 1 && !await O({
783
+ title: t("page.move-title", { title: p.title }),
784
+ message: t("page.move-branch", { count: B }),
785
+ confirmText: t("page.move-confirm"),
786
+ cancelText: t("page.cancel")
787
+ })) {
788
+ c.value = p.parent_id;
789
+ return;
790
+ }
791
+ a.value = !0;
792
+ try {
793
+ const $ = await h.move(p.id, _, "inside");
794
+ z.success(
795
+ $.addresses_changed > 1 ? t("page.moved", { count: $.addresses_changed }) : t("page.moved-one")
796
+ ), await l?.reload();
797
+ } catch ($) {
798
+ z.danger(d($)), c.value = p.parent_id;
799
+ } finally {
800
+ a.value = !1;
791
801
  }
792
802
  }
793
- return (T, y) => o.value ? (d(), M("div", Bt, [
794
- f(e(ue), {
803
+ return (_, p) => f.value ? (m(), A("div", Et, [
804
+ g(e(oe), {
795
805
  label: e(t)("page.address")
796
806
  }, {
797
807
  default: n(() => [
798
- k.value ? (d(), x(e(O), {
808
+ x.value ? (m(), V(e(R), {
799
809
  key: 0,
800
810
  mono: "",
801
811
  class: "wx-page-place__address"
802
812
  }, {
803
813
  default: n(() => [
804
- h(g(k.value), 1)
814
+ y(b(x.value), 1)
805
815
  ]),
806
816
  _: 1
807
- })) : (d(), x(e(O), {
817
+ })) : (m(), V(e(R), {
808
818
  key: 1,
809
819
  size: "sm",
810
820
  tone: "muted"
811
821
  }, {
812
822
  default: n(() => [
813
- h(g(e(t)("page.no-address")), 1)
823
+ y(b(e(t)("page.no-address")), 1)
814
824
  ]),
815
825
  _: 1
816
826
  }))
817
827
  ]),
818
828
  _: 1
819
829
  }, 8, ["label"]),
820
- o.value.can.move ? (d(), M(F, { key: 0 }, [
821
- f(e(ue), {
830
+ f.value.can.move ? (m(), A(j, { key: 0 }, [
831
+ g(e(oe), {
822
832
  label: e(t)("page.field-parent"),
823
833
  help: e(t)("page.parent-help")
824
834
  }, {
825
835
  default: n(() => [
826
- f(Se, {
827
- modelValue: a.value,
836
+ g(Te, {
837
+ modelValue: c.value,
828
838
  "onUpdate:modelValue": [
829
- y[0] || (y[0] = (S) => a.value = S),
830
- $
839
+ p[0] || (p[0] = (B) => c.value = B),
840
+ C
831
841
  ],
832
- exclude: [o.value.id],
842
+ exclude: [f.value.id],
833
843
  selected: e(l)?.ancestors.value ?? []
834
844
  }, null, 8, ["modelValue", "exclude", "selected"])
835
845
  ]),
836
846
  _: 1
837
847
  }, 8, ["label", "help"]),
838
- f(e(Ve), {
848
+ g(e(xe), {
839
849
  type: "info",
840
850
  variant: "soft",
841
851
  description: e(t)("page.parent-warning")
842
852
  }, null, 8, ["description"])
843
- ], 64)) : D("", !0)
844
- ])) : D("", !0);
853
+ ], 64)) : N("", !0)
854
+ ])) : N("", !0);
845
855
  }
846
- }), Et = /* @__PURE__ */ de(Nt, [["__scopeId", "data-v-1adcb4ab"]]), Ne = /* @__PURE__ */ H({
856
+ }), Ut = /* @__PURE__ */ re(It, [["__scopeId", "data-v-bf094be2"]]), Rt = /* @__PURE__ */ K({
847
857
  __name: "PageActions",
848
858
  props: {
849
859
  page: {},
850
- inBin: { type: Boolean, default: !1 },
851
- menuOnly: { type: Boolean, default: !1 }
860
+ inBin: { type: Boolean, default: !1 }
852
861
  },
853
862
  emits: ["open", "add", "duplicate", "move", "copy", "remove", "restore"],
854
- setup(v, { emit: u }) {
855
- const p = v, l = u;
856
- G();
857
- const i = j("webx-pages"), t = V(() => {
858
- const c = p.page;
859
- if (p.inBin)
863
+ setup(u, { emit: r }) {
864
+ const h = u, l = r;
865
+ H();
866
+ const s = F("webx-pages"), t = W(() => {
867
+ const d = h.page;
868
+ if (h.inBin)
860
869
  return [
861
870
  {
862
871
  key: "restore",
863
- type: "restore",
864
872
  icon: "refresh",
865
- label: i("page.restore"),
866
- run: () => l("restore", c)
873
+ label: s("page.restore"),
874
+ run: () => l("restore", d)
867
875
  }
868
876
  ];
869
877
  const a = [
870
- {
871
- key: "open",
872
- type: "edit",
873
- icon: "edit",
874
- label: i("page.open"),
875
- run: () => l("open", c)
876
- },
877
- {
878
- key: "add",
879
- type: "add",
880
- icon: "plus",
881
- label: i("page.add-child"),
882
- run: () => l("add", c)
883
- }
878
+ { key: "open", icon: "edit", label: s("page.open"), run: () => l("open", d) },
879
+ { key: "add", icon: "plus", label: s("page.add-child"), run: () => l("add", d) }
884
880
  ];
885
- return c.is_home || a.push({
881
+ return d.is_home || a.push({
886
882
  key: "duplicate",
887
- type: "copy",
888
883
  icon: "copy",
889
- label: i("page.duplicate"),
890
- run: () => l("duplicate", c)
891
- }), c.can.move && a.push({
892
- key: "move",
893
- type: "sort",
894
- icon: "drag",
895
- label: i("page.move"),
896
- run: () => l("move", c)
897
- }), a.push(
884
+ label: s("page.duplicate"),
885
+ run: () => l("duplicate", d)
886
+ }), d.can.move && a.push({ key: "move", icon: "drag", label: s("page.move"), run: () => l("move", d) }), a.push(
898
887
  {
899
888
  key: "copy-address",
900
- type: "link",
901
889
  icon: "link",
902
- label: i("page.copy-address"),
903
- disabled: !c.url,
904
- run: () => l("copy", c)
890
+ label: s("page.copy-address"),
891
+ disabled: !d.url,
892
+ run: () => l("copy", d)
905
893
  },
906
894
  {
907
895
  key: "on-site",
908
- type: "goto",
909
896
  icon: "external-link",
910
- label: i("page.open-on-site"),
911
- disabled: !c.url,
912
- href: c.url ?? void 0
897
+ label: s("page.open-on-site"),
898
+ disabled: !d.url,
899
+ href: d.url ?? void 0
913
900
  }
914
- ), c.can.delete && a.push({
901
+ ), d.can.delete && a.push({
915
902
  key: "delete",
916
- type: "remove",
917
903
  icon: "trash",
918
- label: i("page.delete"),
904
+ label: s("page.delete"),
919
905
  danger: !0,
920
- run: () => l("remove", c)
906
+ run: () => l("remove", d)
921
907
  }), a;
922
908
  });
923
- return (c, a) => p.menuOnly ? (d(), x(e(Le), {
924
- key: 0,
925
- align: "end",
926
- onClick: a[0] || (a[0] = xe(() => {
927
- }, ["stop"]))
928
- }, {
929
- trigger: n(() => [
930
- f(e($e), {
931
- type: "more",
932
- size: "sm",
933
- title: p.page.title
934
- }, null, 8, ["title"])
935
- ]),
936
- default: n(() => [
937
- (d(!0), M(F, null, ie(t.value, (o) => (d(), x(e(re), {
938
- key: o.key,
939
- icon: o.icon,
940
- tone: o.danger ? "danger" : "default",
941
- href: o.href,
942
- target: o.href ? "_blank" : void 0,
943
- disabled: o.disabled,
944
- onClick: (s) => o.run?.()
945
- }, {
946
- default: n(() => [
947
- h(g(o.label), 1)
948
- ]),
949
- _: 2
950
- }, 1032, ["icon", "tone", "href", "target", "disabled", "onClick"]))), 128))
951
- ]),
952
- _: 1
953
- })) : (d(), x(e(ot), {
954
- key: 1,
955
- size: "sm",
956
- align: "end",
957
- collapse: "",
958
- "aria-label": p.page.title,
959
- onClick: a[1] || (a[1] = xe(() => {
960
- }, ["stop"]))
961
- }, {
962
- collapsed: n(() => [
963
- (d(!0), M(F, null, ie(t.value, (o) => (d(), x(e(re), {
964
- key: o.key,
965
- icon: o.icon,
966
- tone: o.danger ? "danger" : "default",
967
- href: o.href,
968
- target: o.href ? "_blank" : void 0,
969
- disabled: o.disabled,
970
- onClick: (s) => o.run?.()
971
- }, {
972
- default: n(() => [
973
- h(g(o.label), 1)
974
- ]),
975
- _: 2
976
- }, 1032, ["icon", "tone", "href", "target", "disabled", "onClick"]))), 128))
977
- ]),
978
- default: n(() => [
979
- (d(!0), M(F, null, ie(t.value, (o) => (d(), x(e($e), {
980
- key: o.key,
981
- type: o.type,
982
- title: o.label,
983
- href: o.href,
984
- target: o.href ? "_blank" : void 0,
985
- disabled: o.disabled,
986
- onClick: (s) => o.run?.()
987
- }, null, 8, ["type", "title", "href", "target", "disabled", "onClick"]))), 128))
988
- ]),
989
- _: 1
990
- }, 8, ["aria-label"]));
909
+ return (d, a) => (m(), V(e(et), {
910
+ actions: t.value,
911
+ label: h.page.title
912
+ }, null, 8, ["actions", "label"]));
991
913
  }
992
- }), Rt = {
914
+ }), Lt = {
993
915
  а: "a",
994
916
  б: "b",
995
917
  в: "v",
@@ -1048,67 +970,67 @@ const gt = { class: "wx-page-danger" }, vt = {
1048
970
  ź: "z",
1049
971
  ż: "z"
1050
972
  };
1051
- function Ot(v) {
1052
- return v.toLowerCase().split("").map((u) => Rt[u] ?? u).join("").normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
973
+ function Ot(u) {
974
+ return u.toLowerCase().split("").map((r) => Lt[r] ?? r).join("").normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
1053
975
  }
1054
- const Ut = /* @__PURE__ */ H({
976
+ const Kt = /* @__PURE__ */ K({
1055
977
  __name: "PageCreateDialog",
1056
978
  props: {
1057
979
  parent: { default: null }
1058
980
  },
1059
- setup(v) {
1060
- const u = v, { open: p, resolve: l, dismiss: i } = Fe(), t = X(), c = Z(t);
1061
- G();
1062
- const a = j("webx-pages"), o = P(""), s = P(""), C = P(u.parent?.id ?? null), k = P(!1), $ = P({}), T = Pe("field"), y = P(!1);
1063
- ae(o, (W) => {
1064
- y.value || (s.value = Ot(W));
1065
- }), ye(async () => {
1066
- await Ze(), T.value?.querySelector("input")?.focus();
981
+ setup(u) {
982
+ const r = u, { open: h, resolve: l, dismiss: s } = Ne(), t = G(), d = Z(t);
983
+ H();
984
+ const a = F("webx-pages"), c = k(""), f = k(""), i = k(r.parent?.id ?? null), T = k(!1), x = k({}), C = Be("field"), _ = k(!1);
985
+ ae(c, (B) => {
986
+ _.value || (f.value = Ot(B));
987
+ }), pe(async () => {
988
+ await Ge(), C.value?.querySelector("input")?.focus();
1067
989
  });
1068
- async function S() {
1069
- if (!(o.value.trim() === "" || k.value)) {
1070
- k.value = !0, $.value = {};
990
+ async function p() {
991
+ if (!(c.value.trim() === "" || T.value)) {
992
+ T.value = !0, x.value = {};
1071
993
  try {
1072
994
  l(
1073
- await c.create({
1074
- title: o.value.trim(),
1075
- slug: s.value.trim(),
1076
- parent_id: C.value
995
+ await d.create({
996
+ title: c.value.trim(),
997
+ slug: f.value.trim(),
998
+ parent_id: i.value
1077
999
  })
1078
1000
  );
1079
- } catch (W) {
1080
- $.value = W.body?.errors ?? {};
1001
+ } catch (B) {
1002
+ x.value = B.body?.errors ?? {};
1081
1003
  } finally {
1082
- k.value = !1;
1004
+ T.value = !1;
1083
1005
  }
1084
1006
  }
1085
1007
  }
1086
- return (W, _) => (d(), x(e(Ke), {
1087
- open: e(p),
1088
- "onUpdate:open": _[5] || (_[5] = (A) => Re(p) ? p.value = A : null),
1008
+ return (B, $) => (m(), V(e(Ae), {
1009
+ open: e(h),
1010
+ "onUpdate:open": $[5] || ($[5] = (D) => De(h) ? h.value = D : null),
1089
1011
  title: e(a)("page.new-title"),
1090
1012
  width: 460
1091
1013
  }, {
1092
1014
  footer: n(() => [
1093
- f(e(Te), { size: "sm" }, {
1015
+ g(e(_e), { size: "sm" }, {
1094
1016
  default: n(() => [
1095
- f(e(R), {
1017
+ g(e(I), {
1096
1018
  variant: "outline",
1097
- onClick: _[4] || (_[4] = (A) => e(i)())
1019
+ onClick: $[4] || ($[4] = (D) => e(s)())
1098
1020
  }, {
1099
1021
  default: n(() => [
1100
- h(g(e(a)("page.cancel")), 1)
1022
+ y(b(e(a)("page.cancel")), 1)
1101
1023
  ]),
1102
1024
  _: 1
1103
1025
  }),
1104
- f(e(R), {
1026
+ g(e(I), {
1105
1027
  type: "primary",
1106
- loading: k.value,
1107
- disabled: o.value.trim() === "",
1108
- onClick: S
1028
+ loading: T.value,
1029
+ disabled: c.value.trim() === "",
1030
+ onClick: p
1109
1031
  }, {
1110
1032
  default: n(() => [
1111
- h(g(e(a)("page.create")), 1)
1033
+ y(b(e(a)("page.create")), 1)
1112
1034
  ]),
1113
1035
  _: 1
1114
1036
  }, 8, ["loading", "disabled"])
@@ -1117,51 +1039,51 @@ const Ut = /* @__PURE__ */ H({
1117
1039
  })
1118
1040
  ]),
1119
1041
  default: n(() => [
1120
- f(e(ue), {
1042
+ g(e(oe), {
1121
1043
  label: e(a)("page.field-title"),
1122
- error: $.value.title?.[0],
1044
+ error: x.value.title?.[0],
1123
1045
  required: ""
1124
1046
  }, {
1125
1047
  default: n(() => [
1126
- N("div", {
1048
+ E("div", {
1127
1049
  ref_key: "field",
1128
- ref: T
1050
+ ref: C
1129
1051
  }, [
1130
- f(e(Me), {
1131
- modelValue: o.value,
1132
- "onUpdate:modelValue": _[0] || (_[0] = (A) => o.value = A),
1052
+ g(e(Ve), {
1053
+ modelValue: c.value,
1054
+ "onUpdate:modelValue": $[0] || ($[0] = (D) => c.value = D),
1133
1055
  "aria-label": e(a)("page.field-title"),
1134
- onKeyup: De(S, ["enter"])
1056
+ onKeyup: Pe(p, ["enter"])
1135
1057
  }, null, 8, ["modelValue", "aria-label"])
1136
1058
  ], 512)
1137
1059
  ]),
1138
1060
  _: 1
1139
1061
  }, 8, ["label", "error"]),
1140
- f(e(ue), {
1062
+ g(e(oe), {
1141
1063
  label: e(a)("page.field-slug"),
1142
- error: $.value.slug?.[0],
1064
+ error: x.value.slug?.[0],
1143
1065
  help: e(a)("page.slug-help")
1144
1066
  }, {
1145
1067
  default: n(() => [
1146
- f(e(Me), {
1147
- modelValue: s.value,
1148
- "onUpdate:modelValue": _[1] || (_[1] = (A) => s.value = A),
1068
+ g(e(Ve), {
1069
+ modelValue: f.value,
1070
+ "onUpdate:modelValue": $[1] || ($[1] = (D) => f.value = D),
1149
1071
  "aria-label": e(a)("page.field-slug"),
1150
- onInput: _[2] || (_[2] = (A) => y.value = !0),
1151
- onKeyup: De(S, ["enter"])
1072
+ onInput: $[2] || ($[2] = (D) => _.value = !0),
1073
+ onKeyup: Pe(p, ["enter"])
1152
1074
  }, null, 8, ["modelValue", "aria-label"])
1153
1075
  ]),
1154
1076
  _: 1
1155
1077
  }, 8, ["label", "error", "help"]),
1156
- f(e(ue), {
1078
+ g(e(oe), {
1157
1079
  label: e(a)("page.field-parent"),
1158
- error: $.value.parent_id?.[0]
1080
+ error: x.value.parent_id?.[0]
1159
1081
  }, {
1160
1082
  default: n(() => [
1161
- f(Se, {
1162
- modelValue: C.value,
1163
- "onUpdate:modelValue": _[3] || (_[3] = (A) => C.value = A),
1164
- selected: u.parent ? [u.parent] : []
1083
+ g(Te, {
1084
+ modelValue: i.value,
1085
+ "onUpdate:modelValue": $[3] || ($[3] = (D) => i.value = D),
1086
+ selected: r.parent ? [r.parent] : []
1165
1087
  }, null, 8, ["modelValue", "selected"])
1166
1088
  ]),
1167
1089
  _: 1
@@ -1170,40 +1092,40 @@ const Ut = /* @__PURE__ */ H({
1170
1092
  _: 1
1171
1093
  }, 8, ["open", "title"]));
1172
1094
  }
1173
- }), It = /* @__PURE__ */ H({
1095
+ }), Ft = /* @__PURE__ */ K({
1174
1096
  __name: "PageMoveDialog",
1175
1097
  props: {
1176
1098
  page: {}
1177
1099
  },
1178
- setup(v) {
1179
- const u = v, { open: p, resolve: l, dismiss: i } = Fe();
1180
- G();
1181
- const t = j("webx-pages"), c = P(u.page.parent_id);
1182
- return (a, o) => (d(), x(e(Ke), {
1183
- open: e(p),
1184
- "onUpdate:open": o[3] || (o[3] = (s) => Re(p) ? p.value = s : null),
1185
- title: e(t)("page.move-title", { title: u.page.title }),
1100
+ setup(u) {
1101
+ const r = u, { open: h, resolve: l, dismiss: s } = Ne();
1102
+ H();
1103
+ const t = F("webx-pages"), d = k(r.page.parent_id);
1104
+ return (a, c) => (m(), V(e(Ae), {
1105
+ open: e(h),
1106
+ "onUpdate:open": c[3] || (c[3] = (f) => De(h) ? h.value = f : null),
1107
+ title: e(t)("page.move-title", { title: r.page.title }),
1186
1108
  width: 460
1187
1109
  }, {
1188
1110
  footer: n(() => [
1189
- f(e(Te), { size: "sm" }, {
1111
+ g(e(_e), { size: "sm" }, {
1190
1112
  default: n(() => [
1191
- f(e(R), {
1113
+ g(e(I), {
1192
1114
  variant: "outline",
1193
- onClick: o[1] || (o[1] = (s) => e(i)())
1115
+ onClick: c[1] || (c[1] = (f) => e(s)())
1194
1116
  }, {
1195
1117
  default: n(() => [
1196
- h(g(e(t)("page.cancel")), 1)
1118
+ y(b(e(t)("page.cancel")), 1)
1197
1119
  ]),
1198
1120
  _: 1
1199
1121
  }),
1200
- f(e(R), {
1122
+ g(e(I), {
1201
1123
  type: "primary",
1202
- disabled: c.value === null || c.value === u.page.parent_id,
1203
- onClick: o[2] || (o[2] = (s) => e(l)(c.value))
1124
+ disabled: d.value === null || d.value === r.page.parent_id,
1125
+ onClick: c[2] || (c[2] = (f) => e(l)(d.value))
1204
1126
  }, {
1205
1127
  default: n(() => [
1206
- h(g(e(t)("page.move-confirm")), 1)
1128
+ y(b(e(t)("page.move-confirm")), 1)
1207
1129
  ]),
1208
1130
  _: 1
1209
1131
  }, 8, ["disabled"])
@@ -1212,21 +1134,21 @@ const Ut = /* @__PURE__ */ H({
1212
1134
  })
1213
1135
  ]),
1214
1136
  default: n(() => [
1215
- f(e(Te), {
1137
+ g(e(_e), {
1216
1138
  direction: "vertical",
1217
1139
  size: "md",
1218
1140
  fill: ""
1219
1141
  }, {
1220
1142
  default: n(() => [
1221
- f(e(Ve), {
1143
+ g(e(xe), {
1222
1144
  type: "info",
1223
1145
  variant: "soft",
1224
1146
  description: e(t)("page.move-help")
1225
1147
  }, null, 8, ["description"]),
1226
- f(Se, {
1227
- modelValue: c.value,
1228
- "onUpdate:modelValue": o[0] || (o[0] = (s) => c.value = s),
1229
- exclude: [u.page.id]
1148
+ g(Te, {
1149
+ modelValue: d.value,
1150
+ "onUpdate:modelValue": c[0] || (c[0] = (f) => d.value = f),
1151
+ exclude: [r.page.id]
1230
1152
  }, null, 8, ["modelValue", "exclude"])
1231
1153
  ]),
1232
1154
  _: 1
@@ -1235,32 +1157,32 @@ const Ut = /* @__PURE__ */ H({
1235
1157
  _: 1
1236
1158
  }, 8, ["open", "title"]));
1237
1159
  }
1238
- }), Lt = { class: "wx-pages__head" }, Ft = { class: "wx-pages__title" }, Kt = ["href"], Ee = 640, Ht = /* @__PURE__ */ H({
1160
+ }), Ht = { class: "wx-pages" }, jt = { class: "wx-pages__title" }, Gt = ["href"], Jt = /* @__PURE__ */ K({
1239
1161
  __name: "PagesPage",
1240
1162
  props: {
1241
1163
  base: { default: "/pages" }
1242
1164
  },
1243
- setup(v) {
1244
- const u = v, p = X(), l = Z(p), i = Ce();
1245
- G();
1246
- const t = j("webx-pages"), c = P(null), a = P([]), o = P(!0), s = P(""), C = P(""), k = Pe("root"), $ = Ie(k), T = V(() => $.value > 0 && $.value < Ee), y = Ae(Ut), S = Ae(It), W = V(() => p.can("pages.manage")), _ = V(() => C.value === "trashed"), A = V(() => !_.value && !T.value && s.value.trim() === ""), U = V(
1247
- () => p.state.manifest?.modules.find((r) => r.id === "pages")?.title ?? t("module.title")
1248
- ), q = V(() => [
1165
+ setup(u) {
1166
+ const r = u, h = G(), l = Z(h), s = ye();
1167
+ H();
1168
+ const t = F("webx-pages"), d = ie(), a = k(null), c = k([]), f = k(!0), i = k(""), T = k(""), x = ze(Kt), C = ze(Ft), _ = W(() => h.can("pages.manage")), p = W(() => T.value === "trashed"), B = W(() => !p.value && i.value.trim() === ""), $ = W(
1169
+ () => h.state.manifest?.modules.find((o) => o.id === "pages")?.title ?? t("module.title")
1170
+ ), D = W(() => [
1249
1171
  { value: "", label: t("page.filter-all") },
1250
1172
  { value: "draft", label: t("page.filter-draft") },
1251
1173
  { value: "published", label: t("page.filter-published") },
1252
1174
  { value: "modified", label: t("page.filter-modified") },
1253
1175
  { value: "trashed", label: t("page.bin"), icon: "trash" }
1254
- ]), ce = V(
1255
- () => A.value && c.value ? [{ ...c.value, children_count: 0 }, ...a.value] : a.value
1256
- ), I = V(() => [
1176
+ ]), le = W(
1177
+ () => B.value && a.value ? [{ ...a.value, children_count: 0 }, ...c.value] : c.value
1178
+ ), U = W(() => [
1257
1179
  { key: "title", label: t("page.column-title"), minWidth: 200 },
1258
- { key: "path", label: t("page.column-address"), width: 200 },
1180
+ { key: "path", label: t("page.column-address"), width: 200, hideBelow: 560 },
1259
1181
  // In the bin the state of a page is not what it was published as — it is off the site either
1260
1182
  // way — so the column says when it went in, which is what decides whether to bring it back.
1261
1183
  {
1262
1184
  key: "status",
1263
- label: _.value ? t("page.column-deleted") : t("page.column-status"),
1185
+ label: p.value ? t("page.column-deleted") : t("page.column-status"),
1264
1186
  align: "center",
1265
1187
  width: 130,
1266
1188
  hideBelow: 620
@@ -1270,304 +1192,282 @@ const Ut = /* @__PURE__ */ H({
1270
1192
  label: t("page.column-updated"),
1271
1193
  width: 180,
1272
1194
  hideBelow: 900,
1273
- hideOnCards: !0,
1274
- hidden: _.value
1195
+ hidden: p.value
1275
1196
  },
1276
- { key: "actions", label: "", width: 48, align: "right", hideOnCards: !0 }
1277
- ]), pe = V(
1278
- () => A.value ? {
1197
+ { key: "actions", label: "", width: 56, align: "right" }
1198
+ ]), q = W(
1199
+ () => B.value ? {
1279
1200
  childrenKey: "children",
1280
1201
  hasChildrenKey: "children_count",
1281
1202
  lazy: !0,
1282
- load: (r) => l.list({ parent: r.id }).then((b) => b.items),
1283
- draggable: W.value,
1284
- allowDrag: (r) => r.can.move,
1285
- allowDrop: ge
1203
+ load: (o) => l.list({ parent: o.id }).then((w) => w.items),
1204
+ draggable: _.value,
1205
+ allowDrag: (o) => o.can.move,
1206
+ allowDrop: ue
1286
1207
  } : void 0
1287
1208
  );
1288
- function ge(r, b, w) {
1289
- return b.is_home ? w === "inside" : r.id !== b.id;
1209
+ function ue(o, w, v) {
1210
+ return w.is_home ? v === "inside" : o.id !== w.id;
1290
1211
  }
1291
- async function L() {
1292
- o.value = !0;
1212
+ async function M() {
1213
+ f.value = !0;
1293
1214
  try {
1294
- const r = await l.list({
1295
- search: s.value.trim(),
1296
- status: _.value ? "" : C.value,
1297
- trashed: _.value,
1298
- flat: T.value
1215
+ const o = await l.list({
1216
+ search: i.value.trim(),
1217
+ status: p.value ? "" : T.value,
1218
+ trashed: p.value
1299
1219
  });
1300
- c.value = r.home, a.value = r.items;
1301
- } catch (r) {
1302
- z.danger(Y(r));
1220
+ a.value = o.home, c.value = o.items;
1221
+ } catch (o) {
1222
+ z.danger(d(o));
1303
1223
  } finally {
1304
- o.value = !1;
1224
+ f.value = !1;
1305
1225
  }
1306
1226
  }
1307
- function ee(r) {
1308
- r.search !== s.value && (s.value = r.search, L());
1227
+ function de(o) {
1228
+ o.search !== i.value && (i.value = o.search, M());
1309
1229
  }
1310
- function B(r) {
1311
- const b = `${u.base}/${r.id}`;
1312
- i.resolve(b).matched.length > 0 && i.push(b);
1230
+ function ee(o) {
1231
+ const w = `${r.base}/${o.id}`;
1232
+ s.resolve(w).matched.length > 0 && s.push(w);
1313
1233
  }
1314
- async function ne(r) {
1315
- const b = await y({ parent: r });
1316
- b && (await L(), B(b));
1234
+ async function ce(o) {
1235
+ const w = await x({ parent: o });
1236
+ w && (await M(), ee(w));
1317
1237
  }
1318
- async function se(r) {
1238
+ async function te(o) {
1319
1239
  try {
1320
- await l.duplicate(r.id), z.success(t("page.duplicated")), await L();
1321
- } catch (b) {
1322
- z.danger(Y(b));
1240
+ await l.duplicate(o.id), z.success(t("page.duplicated")), await M();
1241
+ } catch (w) {
1242
+ z.danger(d(w));
1323
1243
  }
1324
1244
  }
1325
- async function ve(r) {
1326
- const b = await S({ page: r });
1327
- b != null && await J(r, b, "inside");
1245
+ async function L(o) {
1246
+ const w = await C({ page: o });
1247
+ w != null && await ne(o, w, "inside");
1328
1248
  }
1329
- async function be(r) {
1330
- await J(r.row, r.target.id, r.zone);
1249
+ async function ge(o) {
1250
+ const w = o.zone === "inside" ? o.target.id : o.target.parent_id, v = o.row.descendants_count + 1;
1251
+ if (w !== o.row.parent_id && v > 1 && !await O({
1252
+ title: t("page.move-title", { title: o.row.title }),
1253
+ message: t("page.move-branch", { count: v }),
1254
+ confirmText: t("page.move-confirm"),
1255
+ cancelText: t("page.cancel")
1256
+ })) {
1257
+ await M();
1258
+ return;
1259
+ }
1260
+ await ne(o.row, o.target.id, o.zone);
1331
1261
  }
1332
- async function J(r, b, w) {
1262
+ async function ne(o, w, v) {
1333
1263
  try {
1334
- const m = await l.move(r.id, b, w);
1264
+ const X = await l.move(o.id, w, v);
1335
1265
  z.success(
1336
- m.addresses_changed > 1 ? t("page.moved", { count: m.addresses_changed }) : t("page.moved-one")
1266
+ X.addresses_changed > 1 ? t("page.moved", { count: X.addresses_changed }) : t("page.moved-one")
1337
1267
  );
1338
- } catch (m) {
1339
- z.danger(Y(m));
1268
+ } catch (X) {
1269
+ z.danger(d(X));
1340
1270
  } finally {
1341
- await L();
1271
+ await M();
1342
1272
  }
1343
1273
  }
1344
- async function Q(r) {
1345
- if (await le({
1346
- title: t("page.delete-title", { title: r.title }),
1274
+ async function ve(o) {
1275
+ if (await O({
1276
+ title: t("page.delete-title", { title: o.title }),
1347
1277
  message: (
1348
1278
  // The whole branch, not the level under it: a catalogue with two sections and forty
1349
1279
  // products is forty-two pages leaving the site, and "2" would be a comforting lie.
1350
- r.descendants_count > 0 ? `${t("page.delete-text")} ${t("page.delete-branch", { count: r.descendants_count })}` : t("page.delete-text")
1280
+ o.descendants_count > 0 ? `${t("page.delete-text")} ${t("page.delete-branch", { count: o.descendants_count })}` : t("page.delete-text")
1351
1281
  ),
1352
1282
  confirmText: t("page.delete"),
1353
1283
  cancelText: t("page.cancel"),
1354
1284
  tone: "danger"
1355
1285
  }))
1356
1286
  try {
1357
- await l.remove(r.id), z.success(t("page.deleted")), await L();
1358
- } catch (w) {
1359
- z.danger(Y(w));
1287
+ await l.remove(o.id), z.success(t("page.deleted")), await M();
1288
+ } catch (v) {
1289
+ z.danger(d(v));
1360
1290
  }
1361
1291
  }
1362
- async function fe(r) {
1363
- try {
1364
- await l.restore(r.id), z.success(t("page.restored")), await L();
1365
- } catch (b) {
1366
- z.danger(Y(b));
1367
- }
1292
+ async function he(o) {
1293
+ if (await O({
1294
+ title: t("page.restore-page-title", { title: o.title }),
1295
+ message: o.descendants_count > 0 ? `${t("page.restore-page-text")} ${t("page.restore-branch", { count: o.descendants_count })}` : t("page.restore-page-text"),
1296
+ confirmText: t("page.restore"),
1297
+ cancelText: t("page.cancel")
1298
+ }))
1299
+ try {
1300
+ const v = await l.restore(o.id);
1301
+ z.success(
1302
+ v > 1 ? t("page.restored-branch", { count: v }) : t("page.restored")
1303
+ ), await M();
1304
+ } catch (v) {
1305
+ z.danger(d(v));
1306
+ }
1368
1307
  }
1369
- async function he(r) {
1370
- if (r.url)
1308
+ async function J(o) {
1309
+ if (o.url)
1371
1310
  try {
1372
- await navigator.clipboard.writeText(r.url), z.success(t("page.address-copied"));
1311
+ await navigator.clipboard.writeText(o.url), z.success(t("page.address-copied"));
1373
1312
  } catch {
1374
1313
  }
1375
1314
  }
1376
- function K(r) {
1377
- return r === "published" ? "success" : r === "modified" ? "warning" : "default";
1378
- }
1379
- function me(r) {
1380
- const b = _.value ? r.deleted_at : r.updated_at;
1381
- return b ? new Date(b).toLocaleDateString() : "";
1382
- }
1383
- function Y(r) {
1384
- return r.body?.message ?? String(r);
1385
- }
1386
- function _e() {
1387
- L();
1315
+ function Q(o) {
1316
+ return o === "published" ? "success" : o === "modified" ? "warning" : "default";
1388
1317
  }
1389
1318
  return ae(T, () => {
1390
- L();
1391
- }), ye(L), (r, b) => (d(), M("div", {
1392
- ref_key: "root",
1393
- ref: k,
1394
- class: "wx-pages"
1395
- }, [
1396
- N("div", Lt, [
1397
- f(e(it), { level: 2 }, {
1398
- default: n(() => [
1399
- h(g(U.value), 1)
1400
- ]),
1401
- _: 1
1402
- }),
1403
- W.value ? (d(), x(e(R), {
1404
- key: 0,
1405
- type: "primary",
1406
- icon: "plus",
1407
- onClick: b[0] || (b[0] = (w) => ne(null))
1408
- }, {
1409
- default: n(() => [
1410
- h(g(e(t)("page.new")), 1)
1411
- ]),
1412
- _: 1
1413
- })) : D("", !0)
1414
- ]),
1415
- f(e(Oe), null, {
1416
- header: n(() => [
1417
- f(e(ut), {
1418
- modelValue: C.value,
1419
- "onUpdate:modelValue": b[1] || (b[1] = (w) => C.value = w),
1420
- options: q.value,
1421
- size: "sm",
1422
- "aria-label": e(t)("page.column-status"),
1423
- onChange: _e
1424
- }, null, 8, ["modelValue", "options", "aria-label"])
1425
- ]),
1319
+ M();
1320
+ }), pe(M), (o, w) => (m(), A("div", Ht, [
1321
+ g(e(tt), {
1322
+ view: T.value,
1323
+ "onUpdate:view": w[2] || (w[2] = (v) => T.value = v),
1324
+ title: $.value,
1325
+ views: D.value
1326
+ }, Je({
1426
1327
  default: n(() => [
1427
- f(e(rt), {
1428
- data: ce.value,
1429
- columns: I.value,
1328
+ g(e(ct), {
1329
+ data: le.value,
1330
+ columns: U.value,
1430
1331
  "row-key": "id",
1431
- tree: pe.value,
1332
+ tree: q.value,
1432
1333
  searchable: "",
1433
- hover: "",
1334
+ clickable: !p.value,
1335
+ hover: !p.value,
1434
1336
  flush: "",
1435
1337
  layout: "fixed",
1436
- loading: o.value,
1437
- "cards-below": Ee,
1338
+ loading: f.value,
1339
+ "cards-below": 0,
1438
1340
  "search-placeholder": e(t)("page.search"),
1439
- "empty-text": _.value ? e(t)("page.empty-bin") : s.value ? e(t)("page.empty-search") : e(t)("page.empty"),
1440
- "aria-label": U.value,
1441
- onStateChange: ee,
1442
- onNodeDrop: be,
1443
- onRowClick: B
1341
+ "empty-text": p.value ? e(t)("page.empty-bin") : i.value ? e(t)("page.empty-search") : e(t)("page.empty"),
1342
+ "aria-label": $.value,
1343
+ onRowClick: ee,
1344
+ onStateChange: de,
1345
+ onNodeDrop: ge
1444
1346
  }, {
1445
- "cell-title": n(({ row: w }) => [
1446
- N("span", Ft, g(w.is_home ? e(t)("pages.home") : w.title), 1)
1347
+ "cell-title": n(({ row: v }) => [
1348
+ E("span", jt, b(v.is_home ? e(t)("pages.home") : v.title), 1)
1447
1349
  ]),
1448
- "cell-path": n(({ row: w }) => [
1449
- _.value ? (d(), x(e(O), {
1350
+ "cell-path": n(({ row: v }) => [
1351
+ p.value ? (m(), V(e(R), {
1450
1352
  key: 0,
1451
1353
  size: "sm",
1452
1354
  tone: "muted"
1453
1355
  }, {
1454
- default: n(() => [...b[3] || (b[3] = [
1455
- h("—", -1)
1356
+ default: n(() => [...w[3] || (w[3] = [
1357
+ y("—", -1)
1456
1358
  ])]),
1457
1359
  _: 1
1458
- })) : w.url && w.status !== "draft" ? (d(), M("a", {
1360
+ })) : v.url && v.status !== "draft" ? (m(), A("a", {
1459
1361
  key: 1,
1460
1362
  class: "wx-pages__address",
1461
- href: w.url,
1363
+ href: v.url,
1462
1364
  target: "_blank",
1463
1365
  rel: "noopener",
1464
- onClick: b[2] || (b[2] = xe(() => {
1366
+ onClick: w[1] || (w[1] = Qe(() => {
1465
1367
  }, ["stop"]))
1466
- }, " /" + g(w.path), 9, Kt)) : w.path !== null ? (d(), x(e(O), {
1368
+ }, " /" + b(v.path), 9, Gt)) : v.path !== null ? (m(), V(e(R), {
1467
1369
  key: 2,
1468
1370
  mono: "",
1469
1371
  size: "sm",
1470
1372
  tone: "muted"
1471
1373
  }, {
1472
1374
  default: n(() => [
1473
- h("/" + g(w.path), 1)
1375
+ y("/" + b(v.path), 1)
1474
1376
  ]),
1475
1377
  _: 2
1476
- }, 1024)) : (d(), x(e(O), {
1378
+ }, 1024)) : (m(), V(e(R), {
1477
1379
  key: 3,
1478
1380
  size: "sm",
1479
1381
  tone: "muted"
1480
1382
  }, {
1481
1383
  default: n(() => [
1482
- h(g(e(t)("page.no-address")), 1)
1384
+ y(b(e(t)("page.no-address")), 1)
1483
1385
  ]),
1484
1386
  _: 1
1485
1387
  }))
1486
1388
  ]),
1487
- "cell-status": n(({ row: w }) => [
1488
- _.value ? (d(), x(e(O), {
1389
+ "cell-status": n(({ row: v }) => [
1390
+ p.value ? (m(), V(e(me), {
1489
1391
  key: 0,
1490
- size: "sm",
1491
- tone: "muted"
1492
- }, {
1493
- default: n(() => [
1494
- h(g(me(w)), 1)
1495
- ]),
1496
- _: 2
1497
- }, 1024)) : (d(), x(e(We), {
1392
+ value: v.deleted_at
1393
+ }, null, 8, ["value"])) : (m(), V(e(we), {
1498
1394
  key: 1,
1499
- type: K(w.status),
1395
+ type: Q(v.status),
1500
1396
  dot: ""
1501
1397
  }, {
1502
1398
  default: n(() => [
1503
- h(g(e(t)(`page.status-${w.status}`)), 1)
1399
+ y(b(e(t)(`page.status-${v.status}`)), 1)
1504
1400
  ]),
1505
1401
  _: 2
1506
1402
  }, 1032, ["type"]))
1507
1403
  ]),
1508
- "cell-updated_at": n(({ row: w }) => [
1509
- f(e(O), {
1404
+ "cell-updated_at": n(({ row: v }) => [
1405
+ g(e(R), {
1510
1406
  size: "sm",
1511
1407
  tone: "muted"
1512
1408
  }, {
1513
1409
  default: n(() => [
1514
- h(g(me(w)), 1),
1515
- w.edited_by && !_.value ? (d(), M(F, { key: 0 }, [
1516
- h(", " + g(w.edited_by), 1)
1517
- ], 64)) : D("", !0)
1410
+ g(e(me), {
1411
+ value: v.updated_at
1412
+ }, null, 8, ["value"]),
1413
+ v.edited_by && !p.value ? (m(), A(j, { key: 0 }, [
1414
+ y(", " + b(v.edited_by), 1)
1415
+ ], 64)) : N("", !0)
1518
1416
  ]),
1519
1417
  _: 2
1520
1418
  }, 1024)
1521
1419
  ]),
1522
- "cell-actions": n(({ row: w }) => [
1523
- W.value ? (d(), x(Ne, {
1420
+ "cell-actions": n(({ row: v }) => [
1421
+ _.value ? (m(), V(Rt, {
1524
1422
  key: 0,
1525
- page: w,
1526
- "in-bin": _.value,
1527
- onOpen: B,
1528
- onAdd: ne,
1529
- onDuplicate: se,
1530
- onMove: ve,
1531
- onCopy: he,
1532
- onRemove: Q,
1533
- onRestore: fe
1534
- }, null, 8, ["page", "in-bin"])) : D("", !0)
1535
- ]),
1536
- "card-actions": n(({ row: w }) => [
1537
- W.value ? (d(), x(Ne, {
1538
- key: 0,
1539
- "menu-only": "",
1540
- page: w,
1541
- "in-bin": _.value,
1542
- onOpen: B,
1543
- onAdd: ne,
1544
- onDuplicate: se,
1545
- onMove: ve,
1546
- onCopy: he,
1547
- onRemove: Q,
1548
- onRestore: fe
1549
- }, null, 8, ["page", "in-bin"])) : D("", !0)
1423
+ page: v,
1424
+ "in-bin": p.value,
1425
+ onOpen: ee,
1426
+ onAdd: ce,
1427
+ onDuplicate: te,
1428
+ onMove: L,
1429
+ onCopy: J,
1430
+ onRemove: ve,
1431
+ onRestore: he
1432
+ }, null, 8, ["page", "in-bin"])) : N("", !0)
1550
1433
  ]),
1551
1434
  _: 1
1552
- }, 8, ["data", "columns", "tree", "loading", "search-placeholder", "empty-text", "aria-label"])
1435
+ }, 8, ["data", "columns", "tree", "clickable", "hover", "loading", "search-placeholder", "empty-text", "aria-label"])
1553
1436
  ]),
1554
- _: 1
1555
- })
1556
- ], 512));
1437
+ _: 2
1438
+ }, [
1439
+ _.value ? {
1440
+ name: "actions",
1441
+ fn: n(() => [
1442
+ g(e(I), {
1443
+ type: "primary",
1444
+ icon: "plus",
1445
+ onClick: w[0] || (w[0] = (v) => ce(null))
1446
+ }, {
1447
+ default: n(() => [
1448
+ y(b(e(t)("page.new")), 1)
1449
+ ]),
1450
+ _: 1
1451
+ })
1452
+ ]),
1453
+ key: "0"
1454
+ } : void 0
1455
+ ]), 1032, ["view", "title", "views"])
1456
+ ]));
1557
1457
  }
1558
- }), jt = /* @__PURE__ */ de(Ht, [["__scopeId", "data-v-681ec89c"]]);
1559
- function Zt(v = {}) {
1560
- const u = v.path ?? "/pages";
1458
+ }), Qt = /* @__PURE__ */ re(Jt, [["__scopeId", "data-v-6c1123b3"]]);
1459
+ function ta(u = {}) {
1460
+ const r = u.path ?? "/pages";
1561
1461
  return {
1562
1462
  id: "pages",
1563
- path: u,
1463
+ path: r,
1564
1464
  routes: [
1565
- { path: u, name: "webx.pages", component: jt, props: { base: u } },
1465
+ { path: r, name: "webx.pages", component: Qt, props: { base: r } },
1566
1466
  {
1567
- path: `${u}/:id(\\d+)`,
1467
+ path: `${r}/:id(\\d+)`,
1568
1468
  name: "webx.pages.edit",
1569
- component: Vt,
1570
- props: { base: u }
1469
+ component: Bt,
1470
+ props: { base: r }
1571
1471
  }
1572
1472
  ],
1573
1473
  /*
@@ -1579,25 +1479,25 @@ function Zt(v = {}) {
1579
1479
  * page from the editor above it rather than from the description.
1580
1480
  */
1581
1481
  types: {
1582
- "wx-page-place": { component: Et, kind: "display" },
1583
- "wx-page-danger": { component: bt, kind: "display" },
1482
+ "wx-page-place": { component: Ut, kind: "display" },
1483
+ "wx-page-danger": { component: wt, kind: "display" },
1584
1484
  "wx-page-history": { component: At, kind: "display" }
1585
1485
  }
1586
1486
  };
1587
1487
  }
1588
1488
  export {
1589
- bt as WxPageDanger,
1590
- Vt as WxPageEditorPage,
1489
+ wt as WxPageDanger,
1490
+ Bt as WxPageEditorPage,
1591
1491
  At as WxPageHistory,
1592
- Se as WxPagePicker,
1593
- Et as WxPagePlace,
1594
- jt as WxPagesPage,
1492
+ Te as WxPagePicker,
1493
+ Ut as WxPagePlace,
1494
+ Qt as WxPagesPage,
1595
1495
  Z as createPagesApi,
1596
- He as pageEditorKey,
1597
- Zt as pages,
1598
- pt as pagesMessages,
1599
- ct as providePageEditor,
1496
+ Ee as pageEditorKey,
1497
+ ta as pages,
1498
+ vt as pagesMessages,
1499
+ gt as providePageEditor,
1600
1500
  Ot as slugify,
1601
- ze as usePageEditor
1501
+ ke as usePageEditor
1602
1502
  };
1603
1503
  //# sourceMappingURL=index.js.map