@inpageedit/core 0.11.0 → 0.12.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/LICENSE +20 -20
- package/dist/{ActionButton-BgbTKTg7.js → ActionButton-CRjo_l3y.js} +2 -2
- package/dist/{ActionButton-BgbTKTg7.js.map → ActionButton-CRjo_l3y.js.map} +1 -1
- package/dist/{CheckBox-D3rHnX7I.js → CheckBox-Bc79KBEB.js} +2 -2
- package/dist/{CheckBox-D3rHnX7I.js.map → CheckBox-Bc79KBEB.js.map} +1 -1
- package/dist/{IconQuickEdit-CAL1HXIb.js → IconQuickEdit-CMCQncyj.js} +2 -2
- package/dist/IconQuickEdit-CMCQncyj.js.map +1 -0
- package/dist/InPageEdit.d.ts +5 -1
- package/dist/{InputBox-BV4m05Xs.js → InputBox-DZAdyZ4B.js} +2 -2
- package/dist/InputBox-DZAdyZ4B.js.map +1 -0
- package/dist/PluginPrefSync-BPQkNtX8.js +292 -0
- package/dist/PluginPrefSync-BPQkNtX8.js.map +1 -0
- package/dist/PluginStoreApp-Cxspe6t8.js +158 -0
- package/dist/PluginStoreApp-Cxspe6t8.js.map +1 -0
- package/dist/Preferences-DS4-CFWe.js.map +1 -1
- package/dist/{RadioBox-nJqWsxW2.js → RadioBox-0UuxlcWZ.js} +2 -2
- package/dist/{RadioBox-nJqWsxW2.js.map → RadioBox-0UuxlcWZ.js.map} +1 -1
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +10 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js.map +1 -0
- package/dist/components/index.js +8 -8
- package/dist/components/index.js.map +1 -1
- package/dist/constants/endpoints.d.ts +2 -1
- package/dist/index-B5DtUqkK.js +180 -0
- package/dist/index-B5DtUqkK.js.map +1 -0
- package/dist/{index-DFPN4uYd.js → index-BXaiDKnr.js} +2316 -2314
- package/dist/index-BXaiDKnr.js.map +1 -0
- package/dist/{index-B5vDBMEh.js → index-Bv7Dw5eO.js} +10 -9
- package/dist/index-Bv7Dw5eO.js.map +1 -0
- package/dist/{index-BVkdBJNf.js → index-CB7TltEb.js} +25 -30
- package/dist/index-CB7TltEb.js.map +1 -0
- package/dist/{index-lZkYoUca.js → index-CG38LlAh.js} +2 -2
- package/dist/index-CG38LlAh.js.map +1 -0
- package/dist/{index-BP-e8PeH.js → index-CJFePavo.js} +4 -4
- package/dist/index-CJFePavo.js.map +1 -0
- package/dist/{index-CvhkVj_L.js → index-CM_6yF2v.js} +3 -3
- package/dist/{index-CvhkVj_L.js.map → index-CM_6yF2v.js.map} +1 -1
- package/dist/{index-D7NpqwUe.js → index-CPoUaSMw.js} +8 -8
- package/dist/index-CPoUaSMw.js.map +1 -0
- package/dist/{index-CFb1PSJg.js → index-CYc6LH26.js} +53 -43
- package/dist/index-CYc6LH26.js.map +1 -0
- package/dist/index-CZXxH2-9.js +173 -0
- package/dist/index-CZXxH2-9.js.map +1 -0
- package/dist/{index-DkQLtTG0.js → index-Ckozkp6W.js} +5 -7
- package/dist/index-Ckozkp6W.js.map +1 -0
- package/dist/{index-BjwVNZ_h.js → index-D4uwfUZL.js} +6 -6
- package/dist/index-D4uwfUZL.js.map +1 -0
- package/dist/{index-Bh70Udzi.js → index-DD5CVCfD.js} +2 -2
- package/dist/index-DD5CVCfD.js.map +1 -0
- package/dist/index-DEav9Ptt.js +365 -0
- package/dist/index-DEav9Ptt.js.map +1 -0
- package/dist/index-hSl8LzNb.js +1169 -0
- package/dist/index-hSl8LzNb.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
- package/dist/models/MemoryStorage.d.ts +10 -0
- package/dist/models/WikiPage/index.d.ts +14 -0
- package/dist/noop-ClDc6zv4.js.map +1 -1
- package/dist/plugins/in-article-links/index.d.ts +5 -0
- package/dist/plugins/plugin-store/index.d.ts +59 -0
- package/dist/plugins/plugin-store/schema.d.ts +41 -0
- package/dist/plugins/preferences-ui/PluginPrefSync.d.ts +1 -0
- package/dist/plugins/preferences-ui/index.d.ts +34 -5
- package/dist/plugins/quick-delete/index.d.ts +3 -0
- package/dist/plugins/quick-diff/index.d.ts +3 -0
- package/dist/plugins/quick-edit/index.d.ts +8 -0
- package/dist/plugins/quick-move/index.d.ts +5 -3
- package/dist/plugins/quick-preview/index.d.ts +4 -0
- package/dist/plugins/quick-redirect/index.d.ts +11 -4
- package/dist/plugins/toolbox/index.d.ts +3 -0
- package/dist/services/PreferencesService.d.ts +53 -11
- package/dist/services/ResourceLoaderService.d.ts +3 -0
- package/dist/services/WikiMetadataService.d.ts +1 -1
- package/dist/services/storage/index.d.ts +18 -8
- package/dist/services/storage/{IPEStorageManager.d.ts → managers/IDBStorageManager.d.ts} +9 -6
- package/dist/services/storage/managers/LocalStorageManager.d.ts +27 -0
- package/dist/style.css +1 -1
- package/dist/vueHooks-D0uVqbO-.js +4032 -0
- package/dist/vueHooks-D0uVqbO-.js.map +1 -0
- package/lib/index.umd.js +11 -115
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +14 -14
- package/dist/IconQuickEdit-CAL1HXIb.js.map +0 -1
- package/dist/InputBox-BV4m05Xs.js.map +0 -1
- package/dist/PluginPrefSync-PIoKRRu2.js +0 -254
- package/dist/PluginPrefSync-PIoKRRu2.js.map +0 -1
- package/dist/index-B5vDBMEh.js.map +0 -1
- package/dist/index-BP-e8PeH.js.map +0 -1
- package/dist/index-BVkdBJNf.js.map +0 -1
- package/dist/index-Bh70Udzi.js.map +0 -1
- package/dist/index-BjwVNZ_h.js.map +0 -1
- package/dist/index-BzCqww16.js +0 -159
- package/dist/index-BzCqww16.js.map +0 -1
- package/dist/index-CFb1PSJg.js.map +0 -1
- package/dist/index-D7NpqwUe.js.map +0 -1
- package/dist/index-DFPN4uYd.js.map +0 -1
- package/dist/index-DGOY4X1J.js +0 -4912
- package/dist/index-DGOY4X1J.js.map +0 -1
- package/dist/index-DKDtc9IF.js +0 -167
- package/dist/index-DKDtc9IF.js.map +0 -1
- package/dist/index-DkQLtTG0.js.map +0 -1
- package/dist/index-lZkYoUca.js.map +0 -1
|
@@ -0,0 +1,1169 @@
|
|
|
1
|
+
import { j as _, P as Ae, F as Le } from "./index-CM_6yF2v.js";
|
|
2
|
+
import { S as Ie, B as Me, I as Pe } from "./index-BXaiDKnr.js";
|
|
3
|
+
import { a as re, m as te, u as ae, b as oe, e as D, o as Fe, f as le, g as je, w as J, n as U, h as M, i as De, j as Te, t as Re, k as He, s as Oe, r as H, l as z, p as qe, q as O, v as G, F as Ue, x as Be, y as Ve, z as ne, A as ze, B as se, c as Ge } from "./vueHooks-D0uVqbO-.js";
|
|
4
|
+
import { n as Je } from "./noop-ClDc6zv4.js";
|
|
5
|
+
import { _ as We } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
6
|
+
const k = '@charset "UTF-8";:host{display:block;font-family:var(--schema-font-family, ui-sans-serif, system-ui, -apple-system);color:var(--schema-color-fg, #111827)}*,*:before,*:after{box-sizing:border-box}.wrapper{display:block;background:var(--schema-color-bg, #ffffff)}.form{display:grid;gap:12px}.field{display:grid;gap:6px;padding:8px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);border-radius:var(--schema-radius, 10px);background:var(--schema-surface, #fff)}.label{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.input,select,textarea{width:100%;padding:8px 10px;border-radius:8px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-input-bg, #fff);color:inherit}.checkbox{display:inline-flex;align-items:center;gap:8px}.helper{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.row{display:grid;gap:8px}.actions{display:flex;gap:8px}.btn{padding:6px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-btn-bg, #f8fafc);border-radius:8px;cursor:pointer}.btn.primary{background:var(--schema-color-primary, #2563eb);color:#fff;border-color:transparent}.btn:disabled{opacity:.5;cursor:not-allowed}.btn.danger{background:var(--schema-color-danger, #dc2626);color:#fff;border-color:transparent}.group{display:grid;gap:10px}.kv{display:grid;grid-template-columns:1fr 1fr auto;gap:8px;align-items:center}.badge{display:inline-flex;padding:2px 6px;border-radius:999px;font-size:11px;background:var(--schema-badge-bg, #eef2ff);color:var(--schema-badge-fg, #4f46e5)}.hidden{display:none!important}.toolbar{display:flex;gap:6px}.schema-collection-row{position:relative;transition:transform var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease),opacity var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease)}.schema-collection-row.enter{opacity:0}.schema-collection-row.enter.enter-active{opacity:1}.schema-collection-row.leaving{opacity:0}.field.schema-type-array .group,.field.schema-type-array .group .row{position:relative}';
|
|
7
|
+
const ce = {
|
|
8
|
+
arrayAdd: "+",
|
|
9
|
+
arrayMoveUp: "↑",
|
|
10
|
+
arrayMoveDown: "↓",
|
|
11
|
+
arrayRemove: "×",
|
|
12
|
+
dictAdd: "+",
|
|
13
|
+
dictRemove: "×",
|
|
14
|
+
rootLabel: "root"
|
|
15
|
+
}, b = (n, e) => {
|
|
16
|
+
customElements.get(n) || customElements.define(n, e);
|
|
17
|
+
}, Qe = (n, e, s) => {
|
|
18
|
+
if (!e.length) return;
|
|
19
|
+
let a = n, t = null, r = null;
|
|
20
|
+
for (let o = 0; o < e.length - 1; o++) {
|
|
21
|
+
const c = e[o];
|
|
22
|
+
let h = a?.[c];
|
|
23
|
+
h == null ? (h = typeof e[o + 1] == "number" ? [] : {}, a[c] = h) : typeof h != "object" && (h = typeof e[o + 1] == "number" ? [] : {}, a[c] = h), t = a, r = c, a = h;
|
|
24
|
+
}
|
|
25
|
+
const i = e[e.length - 1];
|
|
26
|
+
if (a == null || typeof a != "object") {
|
|
27
|
+
const o = typeof i == "number" ? [] : {};
|
|
28
|
+
if (t)
|
|
29
|
+
t[r] = o, a = o;
|
|
30
|
+
else
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
a[i] = s;
|
|
35
|
+
} catch {
|
|
36
|
+
try {
|
|
37
|
+
const o = Array.isArray(a) ? a.slice() : { ...a };
|
|
38
|
+
o[i] = s, t && (t[r] = o);
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, R = (n) => n.map(String).join("."), Xe = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), L = (n) => `schema_${Xe(R(n) || "root")}`, F = (n) => R(n), p = (n, ...e) => {
|
|
43
|
+
const s = new Set(e);
|
|
44
|
+
s.size && n.setAttribute("part", Array.from(s).join(" "));
|
|
45
|
+
}, Ye = [
|
|
46
|
+
"wrapper",
|
|
47
|
+
"form",
|
|
48
|
+
"field",
|
|
49
|
+
"field-intersect",
|
|
50
|
+
"field-string",
|
|
51
|
+
"field-number",
|
|
52
|
+
"field-boolean",
|
|
53
|
+
"field-date",
|
|
54
|
+
"field-const",
|
|
55
|
+
"field-array",
|
|
56
|
+
"field-object",
|
|
57
|
+
"field-tuple",
|
|
58
|
+
"field-union",
|
|
59
|
+
"field-dict",
|
|
60
|
+
"field-label",
|
|
61
|
+
"field-helper",
|
|
62
|
+
"field-group",
|
|
63
|
+
"field-row",
|
|
64
|
+
"field-actions",
|
|
65
|
+
"field-button",
|
|
66
|
+
"field-button-primary",
|
|
67
|
+
"field-button-danger",
|
|
68
|
+
"field-button-secondary",
|
|
69
|
+
"field-toolbar",
|
|
70
|
+
"field-badge",
|
|
71
|
+
"field-input",
|
|
72
|
+
"field-input-text",
|
|
73
|
+
"field-input-number",
|
|
74
|
+
"field-input-date",
|
|
75
|
+
"field-input-select",
|
|
76
|
+
"field-input-textarea",
|
|
77
|
+
"field-input-checkbox",
|
|
78
|
+
"field-const-value",
|
|
79
|
+
"collection-row",
|
|
80
|
+
"field-checkbox",
|
|
81
|
+
"field-checkbox-text",
|
|
82
|
+
"field-toolbar-select"
|
|
83
|
+
].join(" ");
|
|
84
|
+
function X(n, e) {
|
|
85
|
+
if (e == null) return e;
|
|
86
|
+
switch (n) {
|
|
87
|
+
case "number":
|
|
88
|
+
case "natural":
|
|
89
|
+
case "percent": {
|
|
90
|
+
if (e === "") return;
|
|
91
|
+
const s = Number(e);
|
|
92
|
+
return Number.isNaN(s) ? void 0 : s;
|
|
93
|
+
}
|
|
94
|
+
case "boolean":
|
|
95
|
+
return !!e;
|
|
96
|
+
case "date": {
|
|
97
|
+
if (!e) return;
|
|
98
|
+
const s = new Date(e);
|
|
99
|
+
return Number.isNaN(+s) ? void 0 : s;
|
|
100
|
+
}
|
|
101
|
+
case "const":
|
|
102
|
+
case "string":
|
|
103
|
+
default:
|
|
104
|
+
return e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function ie(n) {
|
|
108
|
+
return typeof n == "function" && !!n?.type;
|
|
109
|
+
}
|
|
110
|
+
function de(n) {
|
|
111
|
+
if (!n) throw new Error("schema is required");
|
|
112
|
+
if (ie(n)) return n;
|
|
113
|
+
try {
|
|
114
|
+
const e = Schema.from(n);
|
|
115
|
+
if (ie(e)) return e;
|
|
116
|
+
} catch {
|
|
117
|
+
}
|
|
118
|
+
if (n?.type) {
|
|
119
|
+
const e = n.type;
|
|
120
|
+
if (Schema[e]) return Schema[e](n.inner ?? n.list ?? n.dict);
|
|
121
|
+
}
|
|
122
|
+
throw new Error("无法从传入对象生成 Schemastery 实例,请传入 schema 或 schema.toJSON() 的结果。");
|
|
123
|
+
}
|
|
124
|
+
function N(n) {
|
|
125
|
+
return n?.meta ?? {};
|
|
126
|
+
}
|
|
127
|
+
function Ze(n) {
|
|
128
|
+
return n.length > 0 && n.every((e) => e?.type === "const");
|
|
129
|
+
}
|
|
130
|
+
function j(n) {
|
|
131
|
+
if (!n) return;
|
|
132
|
+
const e = n, s = e.meta || {};
|
|
133
|
+
if (Object.prototype.hasOwnProperty.call(s, "default")) return s.default;
|
|
134
|
+
const a = e.type;
|
|
135
|
+
try {
|
|
136
|
+
const t = n();
|
|
137
|
+
if (t !== void 0) return t;
|
|
138
|
+
} catch {
|
|
139
|
+
}
|
|
140
|
+
switch (a) {
|
|
141
|
+
case "string":
|
|
142
|
+
return "";
|
|
143
|
+
case "number":
|
|
144
|
+
case "natural":
|
|
145
|
+
case "percent":
|
|
146
|
+
return 0;
|
|
147
|
+
case "boolean":
|
|
148
|
+
return !1;
|
|
149
|
+
case "array":
|
|
150
|
+
return [];
|
|
151
|
+
case "tuple":
|
|
152
|
+
return [];
|
|
153
|
+
case "object":
|
|
154
|
+
return {};
|
|
155
|
+
case "dict":
|
|
156
|
+
return {};
|
|
157
|
+
case "union": {
|
|
158
|
+
const t = e.list || [];
|
|
159
|
+
return t.length ? j(t[0]) : void 0;
|
|
160
|
+
}
|
|
161
|
+
case "const":
|
|
162
|
+
return e.value;
|
|
163
|
+
case "date":
|
|
164
|
+
return;
|
|
165
|
+
case "intersect": {
|
|
166
|
+
const t = e.list || [], r = (o, c) => {
|
|
167
|
+
if (Array.isArray(o) && Array.isArray(c)) return c.slice();
|
|
168
|
+
if (o && c && typeof o == "object" && typeof c == "object") {
|
|
169
|
+
const h = { ...o };
|
|
170
|
+
for (const l of Object.keys(c))
|
|
171
|
+
h[l] = l in h ? r(h[l], c[l]) : c[l];
|
|
172
|
+
return h;
|
|
173
|
+
}
|
|
174
|
+
return c ?? o;
|
|
175
|
+
};
|
|
176
|
+
let i = {};
|
|
177
|
+
for (const o of t) i = r(i, j(o));
|
|
178
|
+
return i;
|
|
179
|
+
}
|
|
180
|
+
default:
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
class S extends HTMLElement {
|
|
185
|
+
constructor() {
|
|
186
|
+
super(), this._path = [], this._i18n = ce, this.$root = this.attachShadow({ mode: "open" });
|
|
187
|
+
const e = document.createElement("style");
|
|
188
|
+
e.textContent = k, this.$root.appendChild(e);
|
|
189
|
+
}
|
|
190
|
+
/** 初始化公共容器(带类名与 data-path) */
|
|
191
|
+
makeFieldContainer(e, s) {
|
|
192
|
+
const a = document.createElement("div");
|
|
193
|
+
if (a.className = `field schema-form-item schema-type-${e}`, a.setAttribute("data-path", R(this._path)), p(a, "field", `field-${e}`), this._label) {
|
|
194
|
+
const t = document.createElement("label");
|
|
195
|
+
t.className = "label", t.textContent = this._label, p(t, "field-label"), a.appendChild(t);
|
|
196
|
+
}
|
|
197
|
+
if (s && s !== this._label) {
|
|
198
|
+
const t = document.createElement("div");
|
|
199
|
+
t.className = "helper", t.textContent = s, p(t, "field-helper"), a.appendChild(t);
|
|
200
|
+
}
|
|
201
|
+
return a;
|
|
202
|
+
}
|
|
203
|
+
/** 外部设置 schema/path/label/value */
|
|
204
|
+
set schema(e) {
|
|
205
|
+
this._schema = de(e), this.render();
|
|
206
|
+
}
|
|
207
|
+
get schema() {
|
|
208
|
+
return this._schema;
|
|
209
|
+
}
|
|
210
|
+
set path(e) {
|
|
211
|
+
this._path = e ?? [], this.render();
|
|
212
|
+
}
|
|
213
|
+
get path() {
|
|
214
|
+
return this._path;
|
|
215
|
+
}
|
|
216
|
+
set label(e) {
|
|
217
|
+
this._label = e, this.render();
|
|
218
|
+
}
|
|
219
|
+
get label() {
|
|
220
|
+
return this._label;
|
|
221
|
+
}
|
|
222
|
+
set i18n(e) {
|
|
223
|
+
e && (this._i18n = { ...this._i18n, ...e }), this.render();
|
|
224
|
+
}
|
|
225
|
+
get i18n() {
|
|
226
|
+
return this._i18n;
|
|
227
|
+
}
|
|
228
|
+
setValue(e) {
|
|
229
|
+
this._value = e, this.render();
|
|
230
|
+
}
|
|
231
|
+
getValue() {
|
|
232
|
+
return this._value;
|
|
233
|
+
}
|
|
234
|
+
/** 触发变更事件(冒泡) */
|
|
235
|
+
emitChange(e) {
|
|
236
|
+
this._value = e, this.dispatchEvent(
|
|
237
|
+
new CustomEvent("change", {
|
|
238
|
+
bubbles: !0,
|
|
239
|
+
composed: !0,
|
|
240
|
+
detail: { path: this._path, value: e }
|
|
241
|
+
})
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
class ue extends S {
|
|
246
|
+
render() {
|
|
247
|
+
if (this.$input && this.$root.contains(this.$input)) {
|
|
248
|
+
const r = !!this.$root.querySelector("label.label");
|
|
249
|
+
if (!(this._label && !r)) {
|
|
250
|
+
const i = this._value ?? "";
|
|
251
|
+
this.$input.value !== i && document.activeElement !== this.$input && (this.$input.value = i);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
256
|
+
const e = N(this._schema), s = this.makeFieldContainer("string", e.description), a = document.createElement("input");
|
|
257
|
+
this.$input = a, a.className = "input", p(a, "field-input", "field-input-text"), a.type = "text", a.name = F(this._path), a.id = L(this._path), e?.pattern?.source && (a.pattern = e.pattern.source), e?.max != null && (a.maxLength = e.max), a.value = this._value ?? "", a.oninput = () => this.emitChange(X("string", a.value));
|
|
258
|
+
const t = s.querySelector("label.label");
|
|
259
|
+
t && (t.htmlFor = a.id), s.appendChild(a), this.$root.appendChild(s);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
b("schema-form-string", ue);
|
|
263
|
+
class he extends S {
|
|
264
|
+
render() {
|
|
265
|
+
if (this.$input && this.$root.contains(this.$input)) {
|
|
266
|
+
const i = !!this.$root.querySelector("label.label");
|
|
267
|
+
if (!(this._label && !i)) {
|
|
268
|
+
const o = this._value ?? "";
|
|
269
|
+
this.$input.value !== String(o) && document.activeElement !== this.$input && (this.$input.value = o);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
274
|
+
const e = this._schema?.type ?? "number", s = N(this._schema), a = this.makeFieldContainer("number", s.description), t = document.createElement("input");
|
|
275
|
+
this.$input = t, t.className = "input", p(t, "field-input", "field-input-number"), t.name = F(this._path), t.id = L(this._path), s?.min != null && (t.min = String(s.min)), s?.max != null && (t.max = String(s.max)), s?.step != null && (t.step = String(s.step)), e === "percent" && !t.step && (t.step = "0.01"), t.value = this._value ?? "", t.oninput = () => this.emitChange(X(e, t.value));
|
|
276
|
+
const r = a.querySelector("label.label");
|
|
277
|
+
r && (r.htmlFor = t.id), s.role === "slider" ? t.type = "range" : t.type = "number", a.appendChild(t), this.$root.appendChild(a);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
b("schema-form-number", he);
|
|
281
|
+
class me extends S {
|
|
282
|
+
render() {
|
|
283
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
284
|
+
const e = N(this._schema), s = this.makeFieldContainer("boolean", e.description), a = document.createElement("label");
|
|
285
|
+
a.className = "checkbox", p(a, "field-checkbox");
|
|
286
|
+
const t = document.createElement("input");
|
|
287
|
+
t.type = "checkbox", t.checked = !!this._value, t.name = F(this._path), t.id = L(this._path), p(t, "field-input", "field-input-checkbox");
|
|
288
|
+
const r = document.createElement("span");
|
|
289
|
+
r.textContent = e.description ?? this._label ?? "", p(r, "field-checkbox-text"), t.onchange = () => this.emitChange(t.checked);
|
|
290
|
+
const i = s.querySelector("label.label");
|
|
291
|
+
i && (i.htmlFor = t.id), a.append(t, r), s.appendChild(a), this.$root.appendChild(s);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
b("schema-form-boolean", me);
|
|
295
|
+
function B(n) {
|
|
296
|
+
return String(n).padStart(2, "0");
|
|
297
|
+
}
|
|
298
|
+
function T(n) {
|
|
299
|
+
return `${n.getFullYear()}-${B(n.getMonth() + 1)}-${B(n.getDate())}`;
|
|
300
|
+
}
|
|
301
|
+
function W(n) {
|
|
302
|
+
return `${B(n.getHours())}:${B(n.getMinutes())}`;
|
|
303
|
+
}
|
|
304
|
+
function q(n) {
|
|
305
|
+
return `${T(n)}T${W(n)}`;
|
|
306
|
+
}
|
|
307
|
+
class pe extends S {
|
|
308
|
+
render() {
|
|
309
|
+
if (this.$input && this.$root.contains(this.$input)) {
|
|
310
|
+
const i = !!this.$root.querySelector("label.label");
|
|
311
|
+
if (!(this._label && !i)) {
|
|
312
|
+
const o = N(this._schema).role || "date";
|
|
313
|
+
if (document.activeElement !== this.$input)
|
|
314
|
+
if (this._value instanceof Date)
|
|
315
|
+
o === "date" ? this.$input.value = T(this._value) : o === "time" ? this.$input.value = W(this._value) : o === "datetime" && (this.$input.value = q(this._value));
|
|
316
|
+
else if (typeof this._value == "string" && o !== "time") {
|
|
317
|
+
const c = new Date(this._value);
|
|
318
|
+
isNaN(+c) || (o === "date" ? this.$input.value = T(c) : o === "datetime" && (this.$input.value = q(c)));
|
|
319
|
+
} else this._value || (this.$input.value = "");
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
324
|
+
const e = N(this._schema), s = this.makeFieldContainer("date", e.description), a = document.createElement("input");
|
|
325
|
+
this.$input = a, a.className = "input", p(a, "field-input", "field-input-date");
|
|
326
|
+
const t = e.role || "date";
|
|
327
|
+
if (t === "datetime" ? a.type = "datetime-local" : t === "time" ? a.type = "time" : a.type = "date", a.name = F(this._path), a.id = L(this._path), this._value instanceof Date)
|
|
328
|
+
t === "date" ? a.value = T(this._value) : t === "time" ? a.value = W(this._value) : t === "datetime" && (a.value = q(this._value));
|
|
329
|
+
else if (typeof this._value == "string" && t !== "time") {
|
|
330
|
+
const i = new Date(this._value);
|
|
331
|
+
isNaN(+i) || (t === "date" ? a.value = T(i) : t === "datetime" && (a.value = q(i)));
|
|
332
|
+
}
|
|
333
|
+
a.oninput = () => {
|
|
334
|
+
e.role;
|
|
335
|
+
let i;
|
|
336
|
+
if (!a.value)
|
|
337
|
+
i = void 0;
|
|
338
|
+
else {
|
|
339
|
+
const o = new Date(a.value);
|
|
340
|
+
i = Number.isNaN(+o) ? void 0 : o;
|
|
341
|
+
}
|
|
342
|
+
this.emitChange(i);
|
|
343
|
+
};
|
|
344
|
+
const r = s.querySelector("label.label");
|
|
345
|
+
r && (r.htmlFor = a.id), s.appendChild(a), this.$root.appendChild(s);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
b("schema-form-date", pe);
|
|
349
|
+
class Y extends S {
|
|
350
|
+
render() {
|
|
351
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
352
|
+
const e = N(this._schema), s = this._schema.value;
|
|
353
|
+
if (e.role === "raw-html") {
|
|
354
|
+
if (s instanceof Node) {
|
|
355
|
+
this.$root.append(s);
|
|
356
|
+
return;
|
|
357
|
+
} else if (typeof s == "function") {
|
|
358
|
+
this.$root.append(s());
|
|
359
|
+
return;
|
|
360
|
+
} else if (typeof s == "string") {
|
|
361
|
+
const i = document.createElement("div");
|
|
362
|
+
i.innerHTML = String(s), p(i, "field-const-value"), this.$root.appendChild(i);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const a = this.makeFieldContainer("const", e.description), t = document.createElement("section");
|
|
367
|
+
t.className = "const content", t.textContent = String(s), t.id = L(this._path), p(t, "field-const-value");
|
|
368
|
+
const r = a.querySelector("label.label");
|
|
369
|
+
r && (r.htmlFor = t.id), a.appendChild(t), this.$root.appendChild(a);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
b("schema-form-const", Y);
|
|
373
|
+
class fe extends S {
|
|
374
|
+
render() {
|
|
375
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
376
|
+
const e = N(this._schema), s = this.makeFieldContainer("intersect", e.description);
|
|
377
|
+
s.classList.remove("field");
|
|
378
|
+
const a = document.createElement("div");
|
|
379
|
+
a.classList.add("group"), p(a, "field-group");
|
|
380
|
+
const t = this._schema.list || [], r = t.length > 0 && t.every((o) => o?.type === "object"), i = (o, c) => {
|
|
381
|
+
if (Array.isArray(o) && Array.isArray(c)) return c.slice();
|
|
382
|
+
if (o && c && typeof o == "object" && typeof c == "object") {
|
|
383
|
+
const h = { ...o };
|
|
384
|
+
for (const l of Object.keys(c))
|
|
385
|
+
h[l] = l in h ? i(h[l], c[l]) : c[l];
|
|
386
|
+
return h;
|
|
387
|
+
}
|
|
388
|
+
return c ?? o;
|
|
389
|
+
};
|
|
390
|
+
if (r) {
|
|
391
|
+
const o = this._value && typeof this._value == "object" ? this._value : {};
|
|
392
|
+
t.forEach((c, h) => {
|
|
393
|
+
const l = c?.meta?.description ?? "", m = I(c, this._path, o, l, this._i18n);
|
|
394
|
+
m.addEventListener("change", (u) => {
|
|
395
|
+
u.stopPropagation();
|
|
396
|
+
const f = i(this._value ?? {}, u.detail.value);
|
|
397
|
+
this.emitChange(f);
|
|
398
|
+
}), a.appendChild(m);
|
|
399
|
+
});
|
|
400
|
+
} else {
|
|
401
|
+
const o = t[t.length - 1], c = I(o, this._path, this._value, this._label, this._i18n);
|
|
402
|
+
c.addEventListener("change", (h) => {
|
|
403
|
+
h.stopPropagation(), this.emitChange(h.detail.value);
|
|
404
|
+
}), a.appendChild(c);
|
|
405
|
+
}
|
|
406
|
+
s.appendChild(a), this.$root.appendChild(s);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
b("schema-form-intersect", fe);
|
|
410
|
+
function Ke(n) {
|
|
411
|
+
switch (n.type) {
|
|
412
|
+
case "intersect":
|
|
413
|
+
return "schema-form-intersect";
|
|
414
|
+
case "string":
|
|
415
|
+
return "schema-form-string";
|
|
416
|
+
case "number":
|
|
417
|
+
case "natural":
|
|
418
|
+
case "percent":
|
|
419
|
+
return "schema-form-number";
|
|
420
|
+
case "boolean":
|
|
421
|
+
return "schema-form-boolean";
|
|
422
|
+
case "date":
|
|
423
|
+
return "schema-form-date";
|
|
424
|
+
case "const":
|
|
425
|
+
return "schema-form-const";
|
|
426
|
+
case "array":
|
|
427
|
+
return "schema-form-array";
|
|
428
|
+
case "object":
|
|
429
|
+
return "schema-form-object";
|
|
430
|
+
case "tuple":
|
|
431
|
+
return "schema-form-tuple";
|
|
432
|
+
case "dict":
|
|
433
|
+
return "schema-form-dict";
|
|
434
|
+
case "union": {
|
|
435
|
+
const e = n.list || [];
|
|
436
|
+
return e.length === 2 && e[0]?.type === "is" && e[0]?.constructor === Date && e[1]?.type === "transform" && (e[1]?.inner?.meta?.role === "datetime" || e[1]?.inner?.meta?.role === "date" || e[1]?.inner?.meta?.role === "time") ? "schema-form-date" : "schema-form-union";
|
|
437
|
+
}
|
|
438
|
+
default:
|
|
439
|
+
return "schema-form-string";
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function I(n, e, s, a, t) {
|
|
443
|
+
const r = Ke(n), i = document.createElement(r);
|
|
444
|
+
return i.schema = n, i.path = e, i.label = a, t && (i.i18n = t), i.setValue?.(s), i.setAttribute("exportparts", Ye), i;
|
|
445
|
+
}
|
|
446
|
+
class ve extends S {
|
|
447
|
+
render() {
|
|
448
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
449
|
+
const e = N(this._schema), s = this.makeFieldContainer("union", e.description), a = this._schema.list || [];
|
|
450
|
+
if (Ze(a)) {
|
|
451
|
+
const t = document.createElement("select");
|
|
452
|
+
t.className = "input", p(t, "field-input", "field-input-select"), t.name = F(this._path), t.id = L(this._path), a.forEach((i) => {
|
|
453
|
+
const o = document.createElement("option");
|
|
454
|
+
o.value = String(i.value), o.textContent = String(i.meta?.description || i.value || i.type), this._value === i.value && (o.selected = !0), t.appendChild(o);
|
|
455
|
+
}), t.onchange = () => this.emitChange(X("string", t.value));
|
|
456
|
+
const r = s.querySelector("label.label");
|
|
457
|
+
r && (r.htmlFor = t.id), s.appendChild(t);
|
|
458
|
+
} else {
|
|
459
|
+
const t = document.createElement("div");
|
|
460
|
+
t.className = "toolbar", p(t, "field-toolbar");
|
|
461
|
+
const r = document.createElement("select");
|
|
462
|
+
r.className = "input", p(r, "field-input", "field-input-select", "field-toolbar-select"), r.name = F(this._path) + ".__type", r.id = L(this._path) + "__type";
|
|
463
|
+
let i = 0;
|
|
464
|
+
a.forEach((l, m) => {
|
|
465
|
+
const u = document.createElement("option");
|
|
466
|
+
u.value = String(m), u.textContent = String(l.meta?.description || l.value || l.type), r.appendChild(u);
|
|
467
|
+
}), r.onchange = () => {
|
|
468
|
+
i = Number(r.value);
|
|
469
|
+
const l = a[i], m = j(l);
|
|
470
|
+
this.emitChange(m), h();
|
|
471
|
+
};
|
|
472
|
+
const o = s.querySelector("label.label");
|
|
473
|
+
o && (o.htmlFor = r.id), t.appendChild(r), s.appendChild(t);
|
|
474
|
+
const c = document.createElement("div");
|
|
475
|
+
c.className = "group", p(c, "field-group");
|
|
476
|
+
const h = () => {
|
|
477
|
+
c.innerHTML = "";
|
|
478
|
+
const l = a[i], m = I(l, this._path, this._value, this._label);
|
|
479
|
+
m instanceof Y || (m.addEventListener("change", (u) => {
|
|
480
|
+
u.stopPropagation(), this.emitChange(u.detail.value);
|
|
481
|
+
}), c.appendChild(m));
|
|
482
|
+
};
|
|
483
|
+
h(), s.appendChild(c);
|
|
484
|
+
}
|
|
485
|
+
this.$root.appendChild(s);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
b("schema-form-union", ve);
|
|
489
|
+
class ge extends S {
|
|
490
|
+
render() {
|
|
491
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
492
|
+
const e = N(this._schema), s = this.makeFieldContainer("tuple", e.description), a = document.createElement("div");
|
|
493
|
+
a.className = "group", p(a, "field-group");
|
|
494
|
+
const t = Array.isArray(this._value) ? this._value : [];
|
|
495
|
+
(this._schema.list || []).forEach((r, i) => {
|
|
496
|
+
const o = I(
|
|
497
|
+
r,
|
|
498
|
+
[...this._path, i],
|
|
499
|
+
t[i],
|
|
500
|
+
`${this._label ?? ""}[${i}]`
|
|
501
|
+
);
|
|
502
|
+
o.addEventListener("change", (c) => {
|
|
503
|
+
c.stopPropagation();
|
|
504
|
+
const h = Array.isArray(this._value) ? this._value.slice() : [];
|
|
505
|
+
h[i] = c.detail.value, this.emitChange(h);
|
|
506
|
+
}), a.appendChild(o);
|
|
507
|
+
}), s.appendChild(a), this.$root.appendChild(s);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
b("schema-form-tuple", ge);
|
|
511
|
+
class _e extends S {
|
|
512
|
+
render() {
|
|
513
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
514
|
+
const e = N(this._schema), s = this.makeFieldContainer("object", e.description), a = document.createElement("div");
|
|
515
|
+
a.className = "group", p(a, "field-group");
|
|
516
|
+
const t = this._schema.dict || {};
|
|
517
|
+
Object.keys(t).forEach((r) => {
|
|
518
|
+
if (t[r]?.meta?.hidden) return;
|
|
519
|
+
const i = (this._value ?? {})[r], o = I(t[r], [...this._path, r], i, r);
|
|
520
|
+
o.addEventListener("change", (c) => {
|
|
521
|
+
c.stopPropagation();
|
|
522
|
+
const h = { ...this._value ?? {} };
|
|
523
|
+
h[r] = c.detail.value, this.emitChange(h);
|
|
524
|
+
}), a.appendChild(o);
|
|
525
|
+
}), s.appendChild(a), this.$root.appendChild(s);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
b("schema-form-object", _e);
|
|
529
|
+
class V extends S {
|
|
530
|
+
constructor() {
|
|
531
|
+
super(...arguments), this._itemIds = [];
|
|
532
|
+
}
|
|
533
|
+
static {
|
|
534
|
+
this._idCounter = 0;
|
|
535
|
+
}
|
|
536
|
+
generateItemId() {
|
|
537
|
+
try {
|
|
538
|
+
if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
|
|
539
|
+
return crypto.randomUUID();
|
|
540
|
+
} catch {
|
|
541
|
+
}
|
|
542
|
+
return "i" + V._idCounter++;
|
|
543
|
+
}
|
|
544
|
+
ensureItemIds(e) {
|
|
545
|
+
for (; this._itemIds.length < e; ) this._itemIds.push(this.generateItemId());
|
|
546
|
+
this._itemIds.length > e && (this._itemIds.length = e);
|
|
547
|
+
}
|
|
548
|
+
// 采集当前行位置信息(用于 FLIP)
|
|
549
|
+
capturePositions(e) {
|
|
550
|
+
const s = {};
|
|
551
|
+
return e.querySelectorAll(".row").forEach((a) => {
|
|
552
|
+
const t = a.dataset.uid;
|
|
553
|
+
t && (s[t] = a.getBoundingClientRect());
|
|
554
|
+
}), s;
|
|
555
|
+
}
|
|
556
|
+
playFLIP(e, s) {
|
|
557
|
+
Array.from(e.querySelectorAll(".row")).forEach((a) => {
|
|
558
|
+
const t = a.dataset.uid;
|
|
559
|
+
if (!t) return;
|
|
560
|
+
const r = s[t];
|
|
561
|
+
if (!r) return;
|
|
562
|
+
const i = a.getBoundingClientRect(), o = r.left - i.left, c = r.top - i.top;
|
|
563
|
+
(o || c) && (a.style.transition = "none", a.style.transform = `translate(${o}px, ${c}px)`, requestAnimationFrame(() => {
|
|
564
|
+
a.style.transition = "transform .25s ease", a.style.transform = "";
|
|
565
|
+
}));
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
render() {
|
|
569
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
570
|
+
const e = N(this._schema), s = this.makeFieldContainer("array", e.description), a = document.createElement("div");
|
|
571
|
+
a.className = "group", p(a, "field-group");
|
|
572
|
+
const t = this._schema.inner, r = () => Array.isArray(this._value) ? this._value : [];
|
|
573
|
+
this.ensureItemIds(r().length);
|
|
574
|
+
const i = (h, l) => {
|
|
575
|
+
a.innerHTML = "", r().forEach((m, u) => {
|
|
576
|
+
const f = [...this._path, u], d = document.createElement("div");
|
|
577
|
+
d.className = "row schema-collection-row", p(d, "field-row", "collection-row");
|
|
578
|
+
const g = this._itemIds[u];
|
|
579
|
+
d.dataset.uid = g, d.setAttribute("data-path", R(f));
|
|
580
|
+
const v = I(
|
|
581
|
+
t,
|
|
582
|
+
f,
|
|
583
|
+
m,
|
|
584
|
+
`${this._label ?? ""}[${u}]`
|
|
585
|
+
);
|
|
586
|
+
v.addEventListener("change", (E) => {
|
|
587
|
+
E.stopPropagation();
|
|
588
|
+
const x = r().slice();
|
|
589
|
+
x[u] = E.detail.value, this._value = x, this.emitChange(x);
|
|
590
|
+
});
|
|
591
|
+
const C = document.createElement("div");
|
|
592
|
+
C.className = "actions", p(C, "field-actions");
|
|
593
|
+
const w = document.createElement("button");
|
|
594
|
+
w.type = "button", w.className = "btn", p(w, "field-button", "field-button-secondary"), w.textContent = this._i18n.arrayMoveUp ?? "↑", w.onclick = () => {
|
|
595
|
+
if (u <= 0) return;
|
|
596
|
+
const E = this.capturePositions(a), x = r().slice();
|
|
597
|
+
[x[u - 1], x[u]] = [x[u], x[u - 1]], [this._itemIds[u - 1], this._itemIds[u]] = [
|
|
598
|
+
this._itemIds[u],
|
|
599
|
+
this._itemIds[u - 1]
|
|
600
|
+
], this._value = x, i(E), this.emitChange(x);
|
|
601
|
+
};
|
|
602
|
+
const $ = document.createElement("button");
|
|
603
|
+
$.type = "button", $.className = "btn", p($, "field-button", "field-button-secondary"), $.textContent = this._i18n.arrayMoveDown ?? "↓", $.onclick = () => {
|
|
604
|
+
const E = r();
|
|
605
|
+
if (u >= E.length - 1) return;
|
|
606
|
+
const x = this.capturePositions(a), A = E.slice();
|
|
607
|
+
[A[u + 1], A[u]] = [A[u], A[u + 1]], [this._itemIds[u + 1], this._itemIds[u]] = [
|
|
608
|
+
this._itemIds[u],
|
|
609
|
+
this._itemIds[u + 1]
|
|
610
|
+
], this._value = A, i(x), this.emitChange(A);
|
|
611
|
+
};
|
|
612
|
+
const y = document.createElement("button");
|
|
613
|
+
y.type = "button", y.className = "btn danger", p(y, "field-button", "field-button-danger"), y.textContent = this._i18n.arrayRemove ?? "×", y.onclick = () => {
|
|
614
|
+
d.classList.add("leaving");
|
|
615
|
+
const E = 250;
|
|
616
|
+
let x = !1;
|
|
617
|
+
const A = () => {
|
|
618
|
+
if (x) return;
|
|
619
|
+
x = !0, clearTimeout(ke);
|
|
620
|
+
const ee = r().filter((xt, Se) => Se !== u);
|
|
621
|
+
this._itemIds.splice(u, 1);
|
|
622
|
+
const Ne = this.capturePositions(a);
|
|
623
|
+
this._value = ee, i(Ne), this.emitChange(ee);
|
|
624
|
+
};
|
|
625
|
+
d.addEventListener("transitionend", A, { once: !0 });
|
|
626
|
+
const ke = setTimeout(A, E + 80);
|
|
627
|
+
}, C.append(w, $, y), d.appendChild(v), d.appendChild(C), a.appendChild(d), l && l === g && (d.classList.add("enter"), requestAnimationFrame(() => {
|
|
628
|
+
d.classList.add("enter-active");
|
|
629
|
+
}), requestAnimationFrame(() => {
|
|
630
|
+
d.classList.remove("enter");
|
|
631
|
+
}));
|
|
632
|
+
}), h && this.playFLIP(a, h);
|
|
633
|
+
};
|
|
634
|
+
i();
|
|
635
|
+
const o = document.createElement("button");
|
|
636
|
+
o.type = "button", o.className = "btn primary", p(o, "field-button", "field-button-primary"), o.textContent = this._i18n.arrayAdd ?? "+", o.onclick = () => {
|
|
637
|
+
const h = this.capturePositions(a), l = r().slice(), m = j(t);
|
|
638
|
+
l.push(m);
|
|
639
|
+
const u = this.generateItemId();
|
|
640
|
+
this._itemIds.push(u), this._value = l, i(h, u), this.emitChange(l);
|
|
641
|
+
};
|
|
642
|
+
const c = document.createElement("div");
|
|
643
|
+
c.className = "actions", p(c, "field-actions"), c.appendChild(o), s.appendChild(a), s.appendChild(c), this.$root.appendChild(s);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
b("schema-form-array", V);
|
|
647
|
+
class be extends S {
|
|
648
|
+
render() {
|
|
649
|
+
this.$root.innerHTML = `<style>${k}</style>`;
|
|
650
|
+
const e = N(this._schema), s = this.makeFieldContainer("dict", e.description), a = document.createElement("div");
|
|
651
|
+
a.className = "group", p(a, "field-group");
|
|
652
|
+
const t = this._schema.inner, r = this._value ?? {}, i = (u) => `d_${u}`, o = () => {
|
|
653
|
+
const u = {};
|
|
654
|
+
return a.querySelectorAll(".kv").forEach((f) => {
|
|
655
|
+
const d = f.dataset.uid;
|
|
656
|
+
d && (u[d] = f.getBoundingClientRect());
|
|
657
|
+
}), u;
|
|
658
|
+
}, c = (u) => {
|
|
659
|
+
a.querySelectorAll(".kv").forEach((f) => {
|
|
660
|
+
const d = f.dataset.uid;
|
|
661
|
+
if (!d) return;
|
|
662
|
+
const g = u[d];
|
|
663
|
+
if (!g) return;
|
|
664
|
+
const v = f.getBoundingClientRect(), C = g.left - v.left, w = g.top - v.top;
|
|
665
|
+
(C || w) && (f.style.transition = "none", f.style.transform = `translate(${C}px, ${w}px)`, requestAnimationFrame(() => {
|
|
666
|
+
f.style.transition = "transform .25s ease", f.style.transform = "";
|
|
667
|
+
}));
|
|
668
|
+
});
|
|
669
|
+
}, h = (u, f) => {
|
|
670
|
+
a.innerHTML = "", Object.keys(r).forEach((d) => {
|
|
671
|
+
const g = [...this._path, d], v = document.createElement("div");
|
|
672
|
+
v.className = "kv schema-collection-row", p(v, "field-row", "collection-row"), v.dataset.uid = i(d), v.setAttribute("data-path", R(g));
|
|
673
|
+
const C = document.createElement("input");
|
|
674
|
+
C.className = "input", p(C, "field-input", "field-input-text"), C.value = d, C.name = F(g) + ".__key", C.id = L(g) + "__key";
|
|
675
|
+
const w = I(t, g, r[d], `${this._label ?? ""}[${d}]`), $ = document.createElement("button");
|
|
676
|
+
$.type = "button", $.className = "btn danger", p($, "field-button", "field-button-danger"), $.textContent = this._i18n.dictRemove ?? "×", $.onclick = () => {
|
|
677
|
+
const y = o();
|
|
678
|
+
delete r[d];
|
|
679
|
+
const E = { ...this._value ?? {} };
|
|
680
|
+
delete E[d], this._value = E, h(y), this.emitChange(E);
|
|
681
|
+
}, C.onchange = () => {
|
|
682
|
+
const y = C.value.trim();
|
|
683
|
+
if (!y || y === d || r[y] !== void 0) return;
|
|
684
|
+
const E = o();
|
|
685
|
+
r[y] = r[d], delete r[d];
|
|
686
|
+
const x = { ...this._value ?? {} };
|
|
687
|
+
x[y] = x[d], delete x[d], this._value = x, h(E), this.emitChange(x);
|
|
688
|
+
}, w.addEventListener("change", (y) => {
|
|
689
|
+
y.stopPropagation();
|
|
690
|
+
const E = { ...this._value ?? {} };
|
|
691
|
+
E[d] = y.detail.value, this._value = E, this.emitChange(E);
|
|
692
|
+
}), v.append(C, w, $), a.appendChild(v), f === d && (v.classList.add("enter"), requestAnimationFrame(() => v.classList.add("enter-active")), requestAnimationFrame(() => v.classList.remove("enter")));
|
|
693
|
+
}), u && c(u);
|
|
694
|
+
};
|
|
695
|
+
h();
|
|
696
|
+
const l = document.createElement("button");
|
|
697
|
+
l.type = "button", l.className = "btn primary", p(l, "field-button", "field-button-primary"), l.textContent = this._i18n.dictAdd ?? "+", l.onclick = () => {
|
|
698
|
+
let u = Object.keys(r).length + 1, f = `k${u}`;
|
|
699
|
+
for (; r[f] !== void 0; ) f = `k${++u}`;
|
|
700
|
+
const d = o();
|
|
701
|
+
r[f] = j(t);
|
|
702
|
+
const g = { ...this._value ?? {}, [f]: r[f] };
|
|
703
|
+
this._value = g, h(d, f), this.emitChange(g);
|
|
704
|
+
};
|
|
705
|
+
const m = document.createElement("div");
|
|
706
|
+
m.className = "actions", p(m, "field-actions"), m.appendChild(l), s.appendChild(a), s.appendChild(m), this.$root.appendChild(s);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
b("schema-form-dict", be);
|
|
710
|
+
class ye extends HTMLElement {
|
|
711
|
+
constructor() {
|
|
712
|
+
super(), this._i18n = { ...ce }, this._i18nCommitted = !1, this.$root = this.attachShadow({ mode: "open" });
|
|
713
|
+
const e = document.createElement("style");
|
|
714
|
+
e.textContent = k, this.$root.appendChild(e);
|
|
715
|
+
const s = document.createElement("div");
|
|
716
|
+
s.className = "wrapper", p(s, "wrapper");
|
|
717
|
+
const a = document.createElement("form");
|
|
718
|
+
a.className = "form", p(a, "form"), s.appendChild(a), this.$root.appendChild(s), this.addEventListener("change", (t) => {
|
|
719
|
+
if (!t?.detail) return;
|
|
720
|
+
const { path: r, value: i } = t.detail;
|
|
721
|
+
Array.isArray(r) && r.length === 0 ? this._state = i : Qe(this._state ?? (this._state = {}), r, i), this.dispatchEvent(
|
|
722
|
+
new CustomEvent("form-change", { detail: { path: r, value: i, state: this._state } })
|
|
723
|
+
);
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
// --- 对外 API ---
|
|
727
|
+
set schema(e) {
|
|
728
|
+
this._schema = de(e);
|
|
729
|
+
try {
|
|
730
|
+
this._state = this._schema(null, { autofix: !0 });
|
|
731
|
+
} catch {
|
|
732
|
+
this._state = j(this._schema);
|
|
733
|
+
}
|
|
734
|
+
this.render();
|
|
735
|
+
}
|
|
736
|
+
get schema() {
|
|
737
|
+
return this._schema;
|
|
738
|
+
}
|
|
739
|
+
set schemaJSON(e) {
|
|
740
|
+
this.schema = e;
|
|
741
|
+
}
|
|
742
|
+
get schemaJSON() {
|
|
743
|
+
return this._schema?.toJSON?.();
|
|
744
|
+
}
|
|
745
|
+
setData(e, s = { validate: !0, autofix: !0 }) {
|
|
746
|
+
if (!this._schema) throw new Error("请先设置 schema");
|
|
747
|
+
const a = s.validate ? this._schema(e ?? null, { autofix: s.autofix }) : e;
|
|
748
|
+
this._state = a, this.render();
|
|
749
|
+
}
|
|
750
|
+
getData(e = { validate: !0, autofix: !0 }) {
|
|
751
|
+
if (!this._schema) throw new Error("请先设置 schema");
|
|
752
|
+
const s = this._state;
|
|
753
|
+
return e.validate ? this._schema(s ?? null, { autofix: e.autofix }) : s;
|
|
754
|
+
}
|
|
755
|
+
reset() {
|
|
756
|
+
try {
|
|
757
|
+
this._state = this._schema(null, { autofix: !0 });
|
|
758
|
+
} catch {
|
|
759
|
+
this._state = j(this._schema);
|
|
760
|
+
}
|
|
761
|
+
this.render();
|
|
762
|
+
}
|
|
763
|
+
refresh() {
|
|
764
|
+
this.render();
|
|
765
|
+
}
|
|
766
|
+
// i18n 相关
|
|
767
|
+
set i18n(e) {
|
|
768
|
+
this._i18nCommitted || (this._i18n = { ...this._i18n, ...e }, this._i18nCommitted = !0, this.render());
|
|
769
|
+
}
|
|
770
|
+
get i18n() {
|
|
771
|
+
return this._i18n;
|
|
772
|
+
}
|
|
773
|
+
render() {
|
|
774
|
+
if (!this._schema) return;
|
|
775
|
+
const e = this.$root.querySelector("form");
|
|
776
|
+
e.innerHTML = "";
|
|
777
|
+
const s = I(
|
|
778
|
+
this._schema,
|
|
779
|
+
[],
|
|
780
|
+
this._state,
|
|
781
|
+
this._i18n.rootLabel,
|
|
782
|
+
this._i18n
|
|
783
|
+
);
|
|
784
|
+
e.appendChild(s);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
b("schema-form", ye);
|
|
788
|
+
function et() {
|
|
789
|
+
b("schema-form", ye), b("schema-form-string", ue), b("schema-form-number", he), b("schema-form-boolean", me), b("schema-form-date", pe), b("schema-form-const", Y), b("schema-form-union", ve), b("schema-form-tuple", ge), b("schema-form-object", _e), b("schema-form-array", V), b("schema-form-dict", be), b("schema-form-intersect", fe);
|
|
790
|
+
}
|
|
791
|
+
const tt = /* @__PURE__ */ re({
|
|
792
|
+
__name: "SchemasteryFormVue",
|
|
793
|
+
props: /* @__PURE__ */ te({
|
|
794
|
+
schema: {},
|
|
795
|
+
value: {},
|
|
796
|
+
validateOnChange: { type: Boolean, default: !1 }
|
|
797
|
+
}, {
|
|
798
|
+
schema: { required: !0 },
|
|
799
|
+
schemaModifiers: {},
|
|
800
|
+
value: { required: !1, default: {} },
|
|
801
|
+
valueModifiers: {}
|
|
802
|
+
}),
|
|
803
|
+
emits: /* @__PURE__ */ te(["change"], ["update:schema", "update:value"]),
|
|
804
|
+
setup(n, { expose: e, emit: s }) {
|
|
805
|
+
const a = ae(n, "schema"), t = ae(n, "value"), r = s, i = oe("elRef");
|
|
806
|
+
let o = !1, c = !1;
|
|
807
|
+
const h = (l) => {
|
|
808
|
+
if (c)
|
|
809
|
+
return;
|
|
810
|
+
const m = i.value, u = n.validateOnChange ? m.getData({ validate: !0 }) : l.detail.state;
|
|
811
|
+
o = !0, t.value = u, U(() => {
|
|
812
|
+
o = !1;
|
|
813
|
+
}), r("change", l.detail);
|
|
814
|
+
};
|
|
815
|
+
return Fe(() => {
|
|
816
|
+
et();
|
|
817
|
+
}), le(() => {
|
|
818
|
+
const l = i.value;
|
|
819
|
+
a.value && (l.schema = a.value), t.value !== void 0 && l.setData(t.value, { validate: !1, autofix: !0 }), l.addEventListener("form-change", h);
|
|
820
|
+
}), je(() => {
|
|
821
|
+
i.value?.removeEventListener("form-change", h);
|
|
822
|
+
}), J(
|
|
823
|
+
a,
|
|
824
|
+
(l) => {
|
|
825
|
+
o || i.value && l && i.value.schema !== l && (c = !0, i.value.schema = l, U(() => {
|
|
826
|
+
c = !1;
|
|
827
|
+
}));
|
|
828
|
+
},
|
|
829
|
+
{ deep: !0, immediate: !0 }
|
|
830
|
+
), J(
|
|
831
|
+
t,
|
|
832
|
+
(l) => {
|
|
833
|
+
if (o || !i.value || l === void 0) return;
|
|
834
|
+
const m = i.value.getData({ validate: !1 });
|
|
835
|
+
JSON.stringify(m) !== JSON.stringify(l) && (c = !0, i.value.setData(l, { validate: !1 }), U(() => {
|
|
836
|
+
c = !1;
|
|
837
|
+
}));
|
|
838
|
+
},
|
|
839
|
+
{ deep: !0, immediate: !0 }
|
|
840
|
+
), e({
|
|
841
|
+
/** 手动设置数据并可选择是否触发 v-model:data */
|
|
842
|
+
setData(l, m) {
|
|
843
|
+
const u = i.value;
|
|
844
|
+
u.setData(l, { validate: !!m?.validate }), m?.emit && (t.value = u.getData({ validate: !!m?.validate }));
|
|
845
|
+
},
|
|
846
|
+
/** 获取数据 */
|
|
847
|
+
getData(l) {
|
|
848
|
+
return i.value.getData(l);
|
|
849
|
+
},
|
|
850
|
+
/** 设置 schema,并同步到 v-model:schema */
|
|
851
|
+
setSchema(l, m = !0) {
|
|
852
|
+
i.value.schema = l, m && (a.value = l);
|
|
853
|
+
},
|
|
854
|
+
refresh() {
|
|
855
|
+
i.value.refresh();
|
|
856
|
+
},
|
|
857
|
+
reset() {
|
|
858
|
+
i.value.reset();
|
|
859
|
+
},
|
|
860
|
+
/** 原生元素 */
|
|
861
|
+
el: i
|
|
862
|
+
}), (l, m) => (M(), D("schema-form", De({
|
|
863
|
+
ref_key: "elRef",
|
|
864
|
+
ref: i
|
|
865
|
+
}, l.$attrs), null, 16));
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
function P(n, e = /* @__PURE__ */ new WeakMap()) {
|
|
869
|
+
if (Te(n))
|
|
870
|
+
return P(n.value, e);
|
|
871
|
+
if (n === null || typeof n != "object")
|
|
872
|
+
return n;
|
|
873
|
+
if (e.has(n))
|
|
874
|
+
return e.get(n);
|
|
875
|
+
if (n instanceof Date)
|
|
876
|
+
return new Date(n);
|
|
877
|
+
if (n instanceof RegExp)
|
|
878
|
+
return new RegExp(n);
|
|
879
|
+
if (n instanceof Map) {
|
|
880
|
+
const t = /* @__PURE__ */ new Map();
|
|
881
|
+
return e.set(n, t), Array.from(n.entries()).forEach(([r, i]) => {
|
|
882
|
+
t.set(r, P(i, e));
|
|
883
|
+
}), t;
|
|
884
|
+
}
|
|
885
|
+
if (n instanceof Set) {
|
|
886
|
+
const t = /* @__PURE__ */ new Set();
|
|
887
|
+
return e.set(n, t), Array.from(n).forEach((r) => {
|
|
888
|
+
t.add(P(r, e));
|
|
889
|
+
}), t;
|
|
890
|
+
}
|
|
891
|
+
if (Array.isArray(n)) {
|
|
892
|
+
const t = [];
|
|
893
|
+
e.set(n, t);
|
|
894
|
+
for (const r of n)
|
|
895
|
+
t.push(P(r, e));
|
|
896
|
+
return t;
|
|
897
|
+
}
|
|
898
|
+
const s = Re(n), a = {};
|
|
899
|
+
e.set(n, a);
|
|
900
|
+
for (const t of Object.keys(s))
|
|
901
|
+
a[t] = P(s[t], e);
|
|
902
|
+
for (const t of Object.getOwnPropertySymbols(s))
|
|
903
|
+
a[t] = P(s[t], e);
|
|
904
|
+
return a;
|
|
905
|
+
}
|
|
906
|
+
const at = { id: "preferences-ui-app" }, nt = { class: "tabbar" }, st = { class: "tabbar-tabs" }, it = ["onClick", "data-value"], rt = { class: "tabbar-content" }, ot = { key: 0 }, lt = { style: { "max-height": "20em", overflow: "auto" } }, ct = /* @__PURE__ */ re({
|
|
907
|
+
__name: "PreferencesApp",
|
|
908
|
+
setup(n, { expose: e }) {
|
|
909
|
+
const s = He(), a = !1, t = Oe([]), r = H([]), i = H(""), o = z(() => r.value.find((d) => d.name === i.value) || null), c = z(() => {
|
|
910
|
+
const d = t.value.filter((g) => g.category === i.value).map((g) => g.schema);
|
|
911
|
+
return d.length === 0 ? null : Ie.intersect(d);
|
|
912
|
+
}), h = z(() => o.value && typeof o.value.autoGenerateForm == "boolean" ? o.value.autoGenerateForm : !0), l = H({});
|
|
913
|
+
e({
|
|
914
|
+
getValue() {
|
|
915
|
+
return P(l);
|
|
916
|
+
},
|
|
917
|
+
mergeValue(d) {
|
|
918
|
+
l.value = {
|
|
919
|
+
...l.value,
|
|
920
|
+
...d
|
|
921
|
+
};
|
|
922
|
+
},
|
|
923
|
+
selectTab(d) {
|
|
924
|
+
i.value = d;
|
|
925
|
+
}
|
|
926
|
+
}), le(async () => {
|
|
927
|
+
s.inject(["preferences"], async (d) => {
|
|
928
|
+
const g = await d.preferences.getAll();
|
|
929
|
+
l.value = g, r.value = d.preferences.getConfigCategories(), t.value = d.preferences.getConfigRegistries(), i.value = r.value[0].name;
|
|
930
|
+
});
|
|
931
|
+
});
|
|
932
|
+
const m = (d, g) => {
|
|
933
|
+
d.preventDefault(), i.value = g;
|
|
934
|
+
const v = d.currentTarget;
|
|
935
|
+
v && v.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center" });
|
|
936
|
+
}, u = oe("customRenderContainerRef"), f = H([]);
|
|
937
|
+
return qe(() => {
|
|
938
|
+
f.value.forEach((d) => d()), f.value = [];
|
|
939
|
+
}), J(
|
|
940
|
+
o,
|
|
941
|
+
async (d) => {
|
|
942
|
+
f.value.forEach((v) => v()), f.value = [], await U();
|
|
943
|
+
const g = u.value;
|
|
944
|
+
if (g && (g.innerText = "", d && typeof d.customRenderer == "function")) {
|
|
945
|
+
let v = Je;
|
|
946
|
+
const C = (y) => {
|
|
947
|
+
v = y;
|
|
948
|
+
}, w = (y) => {
|
|
949
|
+
f.value.push(y);
|
|
950
|
+
}, $ = await d.customRenderer({ ctx: s, onMounted: C, onUnmount: w });
|
|
951
|
+
$ && (g.appendChild($), v?.(g));
|
|
952
|
+
}
|
|
953
|
+
},
|
|
954
|
+
{ immediate: !0, deep: !1 }
|
|
955
|
+
), (d, g) => (M(), D("div", at, [
|
|
956
|
+
O("div", nt, [
|
|
957
|
+
O("div", st, [
|
|
958
|
+
(M(!0), D(Ue, null, Be(r.value, (v) => (M(), D("a", {
|
|
959
|
+
class: Ve(["tab", { active: i.value === v.name }]),
|
|
960
|
+
key: v.name,
|
|
961
|
+
onClick: (C) => m(C, v.name),
|
|
962
|
+
"data-value": v.name
|
|
963
|
+
}, ne(v.label), 11, it))), 128))
|
|
964
|
+
]),
|
|
965
|
+
O("div", rt, [
|
|
966
|
+
o.value && o.value.customRenderer ? (M(), D("div", {
|
|
967
|
+
class: "custom-render-container",
|
|
968
|
+
ref_key: "customRenderContainerRef",
|
|
969
|
+
ref: u,
|
|
970
|
+
key: i.value
|
|
971
|
+
})) : G("", !0),
|
|
972
|
+
h.value && c.value ? (M(), ze(se(tt), {
|
|
973
|
+
class: "auto-schema-form",
|
|
974
|
+
key: i.value,
|
|
975
|
+
"data-category": i.value,
|
|
976
|
+
schema: c.value,
|
|
977
|
+
value: l.value,
|
|
978
|
+
"onUpdate:value": g[0] || (g[0] = (v) => l.value = { ...l.value, ...v }),
|
|
979
|
+
"validate-on-change": !1,
|
|
980
|
+
i18n: { rootLabel: "" }
|
|
981
|
+
}, null, 8, ["data-category", "schema", "value"])) : G("", !0)
|
|
982
|
+
])
|
|
983
|
+
]),
|
|
984
|
+
se(a) ? (M(), D("details", ot, [
|
|
985
|
+
O("pre", lt, ne(l.value), 1)
|
|
986
|
+
])) : G("", !0)
|
|
987
|
+
]));
|
|
988
|
+
}
|
|
989
|
+
}), dt = /* @__PURE__ */ We(ct, [["__scopeId", "data-v-7f07706b"]]);
|
|
990
|
+
var ut = Object.create, Z = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, xe = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), Ce = (n) => {
|
|
991
|
+
throw TypeError(n);
|
|
992
|
+
}, mt = (n, e, s) => e in n ? Z(n, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[e] = s, pt = (n, e) => Z(n, "name", { value: e, configurable: !0 }), ft = (n) => [, , , ut(n?.[xe("metadata")] ?? null)], vt = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Ee = (n) => n !== void 0 && typeof n != "function" ? Ce("Function expected") : n, gt = (n, e, s, a, t) => ({ kind: vt[n], name: e, metadata: a, addInitializer: (r) => s._ ? Ce("Already initialized") : t.push(Ee(r || null)) }), _t = (n, e) => mt(e, xe("metadata"), n[3]), bt = (n, e, s, a) => {
|
|
993
|
+
for (var t = 0, r = n[e >> 1], i = r && r.length; t < i; t++) r[t].call(s);
|
|
994
|
+
return a;
|
|
995
|
+
}, yt = (n, e, s, a, t, r) => {
|
|
996
|
+
var i, o, c, h = e & 7, l = !1, m = 0, u = n[m] || (n[m] = []), f = h && (t = t.prototype, h < 5 && (h > 3 || !l) && ht(t, s));
|
|
997
|
+
pt(t, s);
|
|
998
|
+
for (var d = a.length - 1; d >= 0; d--)
|
|
999
|
+
c = gt(h, s, o = {}, n[3], u), i = (0, a[d])(t, c), o._ = 1, Ee(i) && (t = i);
|
|
1000
|
+
return _t(n, t), f && Z(t, s, f), l ? h ^ 4 ? r : f : t;
|
|
1001
|
+
}, $e, K, we;
|
|
1002
|
+
$e = [Pe(["preferences", "modal"])];
|
|
1003
|
+
class Q extends (we = Me) {
|
|
1004
|
+
constructor(e) {
|
|
1005
|
+
super(e, {}, "preferences-ui"), this.ctx = e, this._modal = null, this._form = null, e.set("preferencesUI", this), e.preferences.defineCategory({
|
|
1006
|
+
name: "about",
|
|
1007
|
+
label: "About",
|
|
1008
|
+
description: "About InPageEdit",
|
|
1009
|
+
index: 99,
|
|
1010
|
+
customRenderer: () => /* @__PURE__ */ _("section", { className: "theme-ipe-prose", children: [
|
|
1011
|
+
/* @__PURE__ */ _("h2", { children: "✏️ InPageEdit NEXT" }),
|
|
1012
|
+
/* @__PURE__ */ _("p", { children: "🚀 Modular, Extensible Supercharged Plugin for MediaWiki." }),
|
|
1013
|
+
/* @__PURE__ */ _("h3", { children: "Portals" }),
|
|
1014
|
+
/* @__PURE__ */ _("ul", { children: [
|
|
1015
|
+
/* @__PURE__ */ _("li", { children: /* @__PURE__ */ _("a", { href: this.ctx.Endpoints.HOME_URL, target: "_blank", children: "Official Website & Help Center" }) }),
|
|
1016
|
+
/* @__PURE__ */ _("li", { children: /* @__PURE__ */ _(
|
|
1017
|
+
"a",
|
|
1018
|
+
{
|
|
1019
|
+
href: `${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,
|
|
1020
|
+
target: "_blank",
|
|
1021
|
+
children: "Update Logs"
|
|
1022
|
+
}
|
|
1023
|
+
) })
|
|
1024
|
+
] }),
|
|
1025
|
+
/* @__PURE__ */ _("h3", { children: "Join us" }),
|
|
1026
|
+
/* @__PURE__ */ _("ul", { children: [
|
|
1027
|
+
/* @__PURE__ */ _("li", { children: [
|
|
1028
|
+
/* @__PURE__ */ _("strong", { children: "GitHub" }),
|
|
1029
|
+
":",
|
|
1030
|
+
" ",
|
|
1031
|
+
/* @__PURE__ */ _("a", { href: this.ctx.Endpoints.GITHUB_URL, target: "_blank", children: "inpageedit/inpageedit-next" })
|
|
1032
|
+
] }),
|
|
1033
|
+
/* @__PURE__ */ _("li", { children: [
|
|
1034
|
+
/* @__PURE__ */ _("strong", { children: "QQ Group" }),
|
|
1035
|
+
": 1026023666"
|
|
1036
|
+
] })
|
|
1037
|
+
] }),
|
|
1038
|
+
/* @__PURE__ */ _("hr", {}),
|
|
1039
|
+
/* @__PURE__ */ _("p", { style: { textAlign: "center" }, children: [
|
|
1040
|
+
"InPageEdit-NEXT Copyright © 2025-",
|
|
1041
|
+
(/* @__PURE__ */ new Date()).getFullYear(),
|
|
1042
|
+
" dragon-fish"
|
|
1043
|
+
] }),
|
|
1044
|
+
/* @__PURE__ */ _("hr", {})
|
|
1045
|
+
] })
|
|
1046
|
+
}), e.inject(["toolbox"], (s) => {
|
|
1047
|
+
s.toolbox.addButton({
|
|
1048
|
+
id: "preferences",
|
|
1049
|
+
icon: /* @__PURE__ */ _(
|
|
1050
|
+
"svg",
|
|
1051
|
+
{
|
|
1052
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1053
|
+
width: "24",
|
|
1054
|
+
height: "24",
|
|
1055
|
+
viewBox: "0 0 24 24",
|
|
1056
|
+
fill: "currentColor",
|
|
1057
|
+
class: "icon icon-tabler icons-tabler-filled icon-tabler-settings",
|
|
1058
|
+
children: [
|
|
1059
|
+
/* @__PURE__ */ _("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
1060
|
+
/* @__PURE__ */ _("path", { d: "M14.647 4.081a.724 .724 0 0 0 1.08 .448c2.439 -1.485 5.23 1.305 3.745 3.744a.724 .724 0 0 0 .447 1.08c2.775 .673 2.775 4.62 0 5.294a.724 .724 0 0 0 -.448 1.08c1.485 2.439 -1.305 5.23 -3.744 3.745a.724 .724 0 0 0 -1.08 .447c-.673 2.775 -4.62 2.775 -5.294 0a.724 .724 0 0 0 -1.08 -.448c-2.439 1.485 -5.23 -1.305 -3.745 -3.744a.724 .724 0 0 0 -.447 -1.08c-2.775 -.673 -2.775 -4.62 0 -5.294a.724 .724 0 0 0 .448 -1.08c-1.485 -2.439 1.305 -5.23 3.744 -3.745a.722 .722 0 0 0 1.08 -.447c.673 -2.775 4.62 -2.775 5.294 0zm-2.647 4.919a3 3 0 1 0 0 6a3 3 0 0 0 0 -6z" })
|
|
1061
|
+
]
|
|
1062
|
+
}
|
|
1063
|
+
),
|
|
1064
|
+
tooltip: "Configure Preferences",
|
|
1065
|
+
group: "group2",
|
|
1066
|
+
index: 99,
|
|
1067
|
+
onClick: () => this.showModal()
|
|
1068
|
+
}), this.addDisposeHandler((a) => {
|
|
1069
|
+
a.toolbox.removeButton("preferences");
|
|
1070
|
+
});
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
async start() {
|
|
1074
|
+
import("./PluginPrefSync-BPQkNtX8.js").then(({ PluginPrefSync: e }) => {
|
|
1075
|
+
this.ctx.plugin(e);
|
|
1076
|
+
}).catch(this.ctx.logger.warn), this.ctx.on("preferences/changed", (e) => {
|
|
1077
|
+
this._form?.mergeValue?.(e.input);
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
stop() {
|
|
1081
|
+
}
|
|
1082
|
+
showModal() {
|
|
1083
|
+
if (this._modal && !this._modal.isDestroyed)
|
|
1084
|
+
return this._modal;
|
|
1085
|
+
const e = this.ctx.modal.show({
|
|
1086
|
+
className: "ipe-preference compact-buttons",
|
|
1087
|
+
sizeClass: "small",
|
|
1088
|
+
outSideClose: !1,
|
|
1089
|
+
center: !0,
|
|
1090
|
+
title: `InPageEdit Preferences (${this.ctx.version})`,
|
|
1091
|
+
content: /* @__PURE__ */ _(Le, { children: /* @__PURE__ */ _(Ae, {}) })
|
|
1092
|
+
});
|
|
1093
|
+
e.get$window().classList.add("dialog");
|
|
1094
|
+
const s = /* @__PURE__ */ _(
|
|
1095
|
+
"div",
|
|
1096
|
+
{
|
|
1097
|
+
id: "ipe-preferences-app",
|
|
1098
|
+
style: { minHeight: "calc(85dvh - var(--ipe-modal-spacing) * 2)" }
|
|
1099
|
+
}
|
|
1100
|
+
);
|
|
1101
|
+
e.setContent(s), this.ctx.emit("preferences-ui/modal-shown", {
|
|
1102
|
+
ctx: this.ctx,
|
|
1103
|
+
modal: e
|
|
1104
|
+
});
|
|
1105
|
+
const a = this.createPreferencesUIApp(), t = a.mount(s);
|
|
1106
|
+
return this._form = t, this.ctx.emit("preferences-ui/vue-app-mounted", {
|
|
1107
|
+
ctx: this.ctx,
|
|
1108
|
+
app: a,
|
|
1109
|
+
form: t
|
|
1110
|
+
}), e.setButtons([
|
|
1111
|
+
{
|
|
1112
|
+
label: "Close",
|
|
1113
|
+
className: "is-ghost",
|
|
1114
|
+
method: () => {
|
|
1115
|
+
e.close();
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
label: "Save",
|
|
1120
|
+
className: "is-primary is-ghost",
|
|
1121
|
+
method: async () => {
|
|
1122
|
+
const r = t.getValue();
|
|
1123
|
+
try {
|
|
1124
|
+
const i = await this.ctx.preferences.setMany(r);
|
|
1125
|
+
this.logger.info("preferences saved", r, i);
|
|
1126
|
+
} catch (i) {
|
|
1127
|
+
this.logger.error("failed to save preferences", i);
|
|
1128
|
+
}
|
|
1129
|
+
e.close(), this.ctx.modal.notify("success", {
|
|
1130
|
+
title: "Preferences Saved",
|
|
1131
|
+
content: /* @__PURE__ */ _("p", { children: "Some settings may take effect after reloading the page." })
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
]), this._modal = e, e.on(e.Event.Close, () => {
|
|
1136
|
+
this.logger.debug("preferences modal closed, vue app unmounting"), a.unmount(), this._modal = null, this._form = null, this.ctx.emit("preferences-ui/modal-closed", {
|
|
1137
|
+
ctx: this.ctx,
|
|
1138
|
+
modal: e
|
|
1139
|
+
});
|
|
1140
|
+
}), e;
|
|
1141
|
+
}
|
|
1142
|
+
getCurrentModal() {
|
|
1143
|
+
return this._modal;
|
|
1144
|
+
}
|
|
1145
|
+
closeCurrentModal() {
|
|
1146
|
+
return this._modal?.close();
|
|
1147
|
+
}
|
|
1148
|
+
async dispatchFormSave(e) {
|
|
1149
|
+
e = e || this._form || void 0;
|
|
1150
|
+
const s = e?.getValue();
|
|
1151
|
+
return s ? (this.ctx.preferences.setMany(s), !0) : !1;
|
|
1152
|
+
}
|
|
1153
|
+
getCurrentFormValue() {
|
|
1154
|
+
return this._form?.getValue();
|
|
1155
|
+
}
|
|
1156
|
+
mergeFormValue(e) {
|
|
1157
|
+
return this._form?.mergeValue?.(e), !!this._form?.mergeValue;
|
|
1158
|
+
}
|
|
1159
|
+
createPreferencesUIApp() {
|
|
1160
|
+
return Ge(this.ctx, dt);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
K = ft(we);
|
|
1164
|
+
Q = yt(K, 0, "PluginPreferencesUI", $e, Q);
|
|
1165
|
+
bt(K, 1, Q);
|
|
1166
|
+
export {
|
|
1167
|
+
Q as PluginPreferencesUI
|
|
1168
|
+
};
|
|
1169
|
+
//# sourceMappingURL=index-hSl8LzNb.js.map
|