rowvia 0.3.2 → 0.3.3
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 +201 -0
- package/dist/fields.css +1 -1
- package/dist/fields.es.js +1086 -974
- package/dist/fields.umd.cjs +1 -1
- package/dist/rowvia.css +1 -1
- package/dist/rowvia.es.js +3289 -3168
- package/dist/rowvia.umd.cjs +45 -45
- package/dist/types/contracts/work-item.d.ts +1 -0
- package/dist/types/fields/field-types.d.ts +2 -0
- package/dist/types/fields/radio-control.d.ts +3 -0
- package/dist/types/fields/types.d.ts +3 -0
- package/package.json +2 -2
package/dist/fields.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var Ge = Object.defineProperty;
|
|
2
|
+
var Je = (t, e, n) => e in t ? Ge(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var _ = (t, e, n) => Je(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
class he {
|
|
5
5
|
constructor() {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
_(this, "cleanups", /* @__PURE__ */ new Set());
|
|
7
|
+
_(this, "stopped", !1);
|
|
8
8
|
}
|
|
9
9
|
get destroyed() {
|
|
10
10
|
return this.stopped;
|
|
@@ -14,22 +14,22 @@ class pe {
|
|
|
14
14
|
this.cleanups.delete(e) && e();
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
listen(e, n,
|
|
18
|
-
return e.addEventListener(n,
|
|
17
|
+
listen(e, n, i, o) {
|
|
18
|
+
return e.addEventListener(n, i, o), this.add(() => e.removeEventListener(n, i, o));
|
|
19
19
|
}
|
|
20
20
|
timeout(e, n) {
|
|
21
21
|
if (this.stopped) return 0;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
}, n),
|
|
25
|
-
return
|
|
22
|
+
const i = window.setTimeout(() => {
|
|
23
|
+
o(), this.stopped || e();
|
|
24
|
+
}, n), o = this.add(() => window.clearTimeout(i));
|
|
25
|
+
return i;
|
|
26
26
|
}
|
|
27
27
|
interval(e, n) {
|
|
28
28
|
if (this.stopped) return 0;
|
|
29
|
-
const
|
|
29
|
+
const i = window.setInterval(() => {
|
|
30
30
|
this.stopped || e();
|
|
31
31
|
}, n);
|
|
32
|
-
return this.add(() => window.clearInterval(
|
|
32
|
+
return this.add(() => window.clearInterval(i)), i;
|
|
33
33
|
}
|
|
34
34
|
destroy() {
|
|
35
35
|
if (this.stopped) return;
|
|
@@ -37,151 +37,151 @@ class pe {
|
|
|
37
37
|
const e = [...this.cleanups].reverse();
|
|
38
38
|
this.cleanups.clear();
|
|
39
39
|
let n;
|
|
40
|
-
for (const
|
|
40
|
+
for (const i of e)
|
|
41
41
|
try {
|
|
42
|
-
|
|
43
|
-
} catch (
|
|
44
|
-
n ?? (n =
|
|
42
|
+
i();
|
|
43
|
+
} catch (o) {
|
|
44
|
+
n ?? (n = o);
|
|
45
45
|
}
|
|
46
46
|
if (n !== void 0) throw n;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
if (!(
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
49
|
+
function Qe(t, e, n = {}, i = []) {
|
|
50
|
+
const o = new he(), r = /* @__PURE__ */ new Set(), s = (p) => [...r].some((b) => b.contains(p)), c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new WeakMap(), f = (p) => {
|
|
51
|
+
const b = p.target;
|
|
52
|
+
if (!(b != null && b.closest)) return;
|
|
53
|
+
const h = b.closest('button,input,select,textarea,a,[data-action],[contenteditable],[role="button"],[role="tab"],[data-node-id],[data-rowid],[data-viewport],canvas');
|
|
54
|
+
if (!h || !s(h)) return;
|
|
55
55
|
const E = {};
|
|
56
|
-
for (let
|
|
57
|
-
for (const [L,
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
56
|
+
for (let m = h; m && s(m); m = m.parentElement)
|
|
57
|
+
for (const [L, V] of Object.entries(m.dataset))
|
|
58
|
+
V !== void 0 && !(L in E) && (E[L] = V);
|
|
59
|
+
const M = h;
|
|
60
|
+
u.has(p) || (u.set(p, {
|
|
61
61
|
component: e,
|
|
62
|
-
type:
|
|
62
|
+
type: p.type,
|
|
63
63
|
action: E.action ?? E.control,
|
|
64
|
-
value: "value" in
|
|
65
|
-
checked:
|
|
64
|
+
value: "value" in h ? M.value : void 0,
|
|
65
|
+
checked: M.type === "checkbox" || M.type === "radio" ? M.checked : void 0,
|
|
66
66
|
data: E,
|
|
67
|
-
originalEvent:
|
|
68
|
-
}), queueMicrotask(() =>
|
|
69
|
-
},
|
|
67
|
+
originalEvent: p
|
|
68
|
+
}), queueMicrotask(() => y(p)));
|
|
69
|
+
}, y = (p) => {
|
|
70
70
|
var E;
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
73
|
-
|
|
74
|
-
for (const
|
|
75
|
-
const
|
|
76
|
-
t.dispatchEvent(new
|
|
77
|
-
}, T = (
|
|
78
|
-
if (
|
|
71
|
+
const b = u.get(p);
|
|
72
|
+
if (!b || o.destroyed) return;
|
|
73
|
+
u.delete(p), (E = n.onInteraction) == null || E.call(n, b);
|
|
74
|
+
for (const M of [...c]) M(b);
|
|
75
|
+
const h = t.ownerDocument.defaultView.CustomEvent;
|
|
76
|
+
t.dispatchEvent(new h("rowvia:interaction", { detail: b, bubbles: !0 }));
|
|
77
|
+
}, T = (p) => {
|
|
78
|
+
if (o.destroyed || r.has(p)) return () => {
|
|
79
79
|
};
|
|
80
|
-
r.add(
|
|
81
|
-
const
|
|
82
|
-
for (const
|
|
83
|
-
|
|
80
|
+
r.add(p);
|
|
81
|
+
const b = [];
|
|
82
|
+
for (const h of ["click", "dblclick", "contextmenu", "input", "change", "submit", "keydown", "pointerdown", "pointerup", "wheel"])
|
|
83
|
+
b.push(o.listen(p, h, f, { capture: !0, passive: !0 }));
|
|
84
84
|
return () => {
|
|
85
|
-
r.delete(
|
|
85
|
+
r.delete(p), b.forEach((h) => h());
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
|
-
for (const
|
|
88
|
+
for (const p of [t, ...i]) T(p);
|
|
89
89
|
return {
|
|
90
90
|
addRoot: T,
|
|
91
|
-
onInteraction(
|
|
92
|
-
return
|
|
93
|
-
} : (c.add(
|
|
94
|
-
c.delete(
|
|
91
|
+
onInteraction(p) {
|
|
92
|
+
return o.destroyed ? () => {
|
|
93
|
+
} : (c.add(p), () => {
|
|
94
|
+
c.delete(p);
|
|
95
95
|
});
|
|
96
96
|
},
|
|
97
97
|
destroy() {
|
|
98
|
-
|
|
98
|
+
o.destroy(), c.clear(), r.clear();
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
102
|
+
const ae = /* @__PURE__ */ new Map();
|
|
103
|
+
function be(t, e) {
|
|
104
104
|
if (!t) return !1;
|
|
105
|
-
const n = e ? [e] : [],
|
|
106
|
-
for (let
|
|
107
|
-
for (const [r,
|
|
108
|
-
if (!(
|
|
105
|
+
const n = e ? [e] : [], i = /* @__PURE__ */ new Set();
|
|
106
|
+
for (let o = 0; o < Math.max(1, n.length); o++)
|
|
107
|
+
for (const [r, s] of ae)
|
|
108
|
+
if (!(i.has(r) || e && !n[o].contains(s))) {
|
|
109
109
|
if (r.element.contains(t)) return !0;
|
|
110
|
-
|
|
110
|
+
i.add(r), n.push(r.element);
|
|
111
111
|
}
|
|
112
112
|
return !1;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
for (const [e, n] of [...
|
|
114
|
+
function Ze(t) {
|
|
115
|
+
for (const [e, n] of [...ae])
|
|
116
116
|
(!t || t.contains(n)) && e.close();
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
const { anchor: e, content: n, width:
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
118
|
+
function ce(t) {
|
|
119
|
+
const { anchor: e, content: n, width: i = "anchor", gap: o = 4, onDismiss: r } = t, s = e.ownerDocument, c = s.defaultView || window, u = t.anchorMode === "element" ? e : e.closest(".fc-focus-body") || e, f = s.createElement("div");
|
|
120
|
+
f.className = "rowvia-field-scope rowvia-field-popup-layer";
|
|
121
|
+
const y = s.createElement("div");
|
|
122
|
+
y.className = "rowvia-field-popup", y.append(n), f.append(y), (e.closest("dialog[open]") || s.body || s.documentElement).append(f);
|
|
123
123
|
let T = !1;
|
|
124
|
-
const
|
|
125
|
-
if (T || !
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
let
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
T || (T = !0,
|
|
136
|
-
},
|
|
137
|
-
const L =
|
|
138
|
-
L && (
|
|
139
|
-
}, E = (
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
124
|
+
const p = () => {
|
|
125
|
+
if (T || !f.isConnected) return;
|
|
126
|
+
const m = u.getBoundingClientRect(), L = s.documentElement.clientWidth || c.innerWidth, V = s.documentElement.clientHeight || c.innerHeight, N = i === "anchor" ? m.width + 2 : i === "auto" ? y.getBoundingClientRect().width : i;
|
|
127
|
+
y.style.width = i === "auto" ? "max-content" : N + "px";
|
|
128
|
+
const x = y.getBoundingClientRect().height;
|
|
129
|
+
let A = m.bottom + o;
|
|
130
|
+
const R = m.top - o - x;
|
|
131
|
+
A + x > V - 8 && R >= 8 && (A = R), A = Math.max(8, Math.min(A, Math.max(8, V - x - 8)));
|
|
132
|
+
const C = Math.max(8, Math.min(t.align === "end" ? m.right - N : m.left, Math.max(8, L - N - 8)));
|
|
133
|
+
f.style.top = Math.round(A) + "px", f.style.left = Math.round(C) + "px";
|
|
134
|
+
}, b = () => {
|
|
135
|
+
T || (T = !0, Ze(f), ae.delete(M), s.removeEventListener("pointerdown", h, !0), s.removeEventListener("keydown", E, !0), c.removeEventListener("resize", p), c.removeEventListener("scroll", p, !0), f.remove(), r == null || r());
|
|
136
|
+
}, h = (m) => {
|
|
137
|
+
const L = m.target;
|
|
138
|
+
L && (f.contains(L) || u.contains(L) || e.contains(L) || be(L, f)) || b();
|
|
139
|
+
}, E = (m) => {
|
|
140
|
+
if (m.key !== "Escape" || [...ae.keys()][ae.size - 1] !== M) return;
|
|
141
|
+
if (m.preventDefault(), m.stopPropagation(), b(), t.onEscape) {
|
|
142
142
|
t.onEscape();
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
|
-
const L =
|
|
145
|
+
const L = s.defaultView.CustomEvent;
|
|
146
146
|
e.dispatchEvent(new L("fc-collapse", { bubbles: !0, detail: { reason: "escape" } }));
|
|
147
|
-
},
|
|
148
|
-
return
|
|
147
|
+
}, M = { element: f, reposition: p, close: b };
|
|
148
|
+
return ae.set(M, e), s.addEventListener("pointerdown", h, !0), s.addEventListener("keydown", E, !0), c.addEventListener("resize", p), c.addEventListener("scroll", p, !0), p(), M;
|
|
149
149
|
}
|
|
150
150
|
const ye = /* @__PURE__ */ new WeakMap();
|
|
151
|
-
function
|
|
151
|
+
function Xe(t, e) {
|
|
152
152
|
let n = ye.get(t);
|
|
153
153
|
if (!n) {
|
|
154
|
-
const
|
|
155
|
-
for (const c of [...
|
|
156
|
-
|
|
154
|
+
const o = /* @__PURE__ */ new Set(), r = (s) => {
|
|
155
|
+
for (const c of [...o])
|
|
156
|
+
o.has(c) && !c.contains(s.target, s) && c.leave(s);
|
|
157
157
|
};
|
|
158
|
-
t.addEventListener("pointerdown", r, !0), t.addEventListener("focusin", r, !0), n = { boundaries:
|
|
158
|
+
t.addEventListener("pointerdown", r, !0), t.addEventListener("focusin", r, !0), n = { boundaries: o, stop: () => {
|
|
159
159
|
t.removeEventListener("pointerdown", r, !0), t.removeEventListener("focusin", r, !0);
|
|
160
160
|
} }, ye.set(t, n);
|
|
161
161
|
}
|
|
162
162
|
n.boundaries.add(e);
|
|
163
|
-
const
|
|
163
|
+
const i = n;
|
|
164
164
|
return () => {
|
|
165
|
-
!
|
|
165
|
+
!i.boundaries.delete(e) || i.boundaries.size || (i.stop(), ye.delete(t));
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
class K {
|
|
169
169
|
constructor(e) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
170
|
+
_(this, "root");
|
|
171
|
+
_(this, "destroying", !1);
|
|
172
|
+
_(this, "feedback");
|
|
173
|
+
_(this, "options");
|
|
174
|
+
_(this, "value");
|
|
175
|
+
_(this, "committedValue");
|
|
176
|
+
_(this, "state");
|
|
177
|
+
_(this, "view");
|
|
178
|
+
_(this, "viewLife", new he());
|
|
179
|
+
_(this, "life", new he());
|
|
180
|
+
_(this, "listeners", /* @__PURE__ */ new Set());
|
|
181
|
+
_(this, "interactions");
|
|
182
|
+
_(this, "interactionListeners", /* @__PURE__ */ new Set());
|
|
183
|
+
_(this, "mounted", !1);
|
|
184
|
+
_(this, "handled", /* @__PURE__ */ new WeakSet());
|
|
185
185
|
this.options = { ...e }, this.value = e.value, this.committedValue = e.value, this.state = e.readonly || e.canEdit === !1 ? "display" : e.state ?? "display";
|
|
186
186
|
}
|
|
187
187
|
get element() {
|
|
@@ -204,10 +204,10 @@ class K {
|
|
|
204
204
|
((n = e.detail) == null ? void 0 : n.reason) === "escape" ? this.cancel("user") : this.commit("user");
|
|
205
205
|
}), this.life.listen(this.element, "focusout", () => {
|
|
206
206
|
queueMicrotask(() => {
|
|
207
|
-
var n,
|
|
207
|
+
var n, i;
|
|
208
208
|
if (this.life.destroyed || !this.element.isConnected || this.state !== "editing") return;
|
|
209
209
|
const e = this.element.ownerDocument.activeElement;
|
|
210
|
-
this.element.contains(e) || (
|
|
210
|
+
this.element.contains(e) || (i = (n = this.view) == null ? void 0 : n.content) != null && i.contains(e) || be(e, this.element) || this.commit("user");
|
|
211
211
|
});
|
|
212
212
|
});
|
|
213
213
|
}
|
|
@@ -256,11 +256,11 @@ class K {
|
|
|
256
256
|
this.interactionListeners.delete(e);
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
|
-
input(e, n = "api",
|
|
259
|
+
input(e, n = "api", i) {
|
|
260
260
|
var c;
|
|
261
261
|
if (this.life.destroyed || this.snapshot.readonly) return;
|
|
262
|
-
const
|
|
263
|
-
this.value = (c = this.options.hooks) != null && c.beforeInput ? this.options.hooks.beforeInput(
|
|
262
|
+
const o = this.value, r = this.snapshot, s = this.beforeInput(e);
|
|
263
|
+
this.value = (c = this.options.hooks) != null && c.beforeInput ? this.options.hooks.beforeInput(s, r) : s, (n === "api" || !Object.is(e, this.value)) && this.draw(), this.emit("input", n, { previousValue: o, originalEvent: i });
|
|
264
264
|
}
|
|
265
265
|
/** External synchronization is distinct from user input; it resets the draft. */
|
|
266
266
|
setValue(e) {
|
|
@@ -272,44 +272,44 @@ class K {
|
|
|
272
272
|
this.life.destroyed || (this.value = this.read(), this.options = { ...this.options, ...e }, "value" in e && (this.value = this.committedValue = e.value), e.state && (this.state = e.state), this.isReadonly() && (this.state = "display"), this.draw());
|
|
273
273
|
}
|
|
274
274
|
validate() {
|
|
275
|
-
var
|
|
275
|
+
var i, o, r, s;
|
|
276
276
|
const e = this.read(), n = e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
277
|
-
return (this.options.field.required && n ? "此项必填" : void 0) || this.validateValue(e) || ((
|
|
277
|
+
return (this.options.field.required && n ? "此项必填" : void 0) || this.validateValue(e) || ((o = (i = this.view) == null ? void 0 : i.validate) == null ? void 0 : o.call(i)) || ((s = (r = this.options.hooks) == null ? void 0 : r.validate) == null ? void 0 : s.call(r, e));
|
|
278
278
|
}
|
|
279
279
|
commit(e = "api") {
|
|
280
|
-
var
|
|
280
|
+
var o, r;
|
|
281
281
|
if (this.life.destroyed || this.snapshot.readonly) return !1;
|
|
282
282
|
const n = this.validate();
|
|
283
283
|
if (this.showValidation(n), n)
|
|
284
284
|
return this.emit("invalid", e, { message: n }), !1;
|
|
285
|
-
const
|
|
286
|
-
return !this.beforeCommit(
|
|
285
|
+
const i = this.event("commit", e, { previousValue: this.committedValue });
|
|
286
|
+
return !this.beforeCommit(i) || ((r = (o = this.options.hooks) == null ? void 0 : o.beforeCommit) == null ? void 0 : r.call(o, i)) === !1 ? !1 : (this.value = this.read(), this.committedValue = this.value, this.element.removeAttribute("aria-invalid"), this.emit("commit", e, { previousValue: i.previousValue }), this.setState("display", e), !0);
|
|
287
287
|
}
|
|
288
288
|
cancel(e = "api") {
|
|
289
|
-
var
|
|
289
|
+
var o, r, s, c;
|
|
290
290
|
if (this.life.destroyed) return;
|
|
291
291
|
const n = this.event("cancel", e);
|
|
292
|
-
if (!this.beforeCancel(n) || ((r = (
|
|
293
|
-
const
|
|
294
|
-
this.state !== "display" && (!this.beforeStateChange(
|
|
292
|
+
if (!this.beforeCancel(n) || ((r = (o = this.options.hooks) == null ? void 0 : o.beforeCancel) == null ? void 0 : r.call(o, n)) === !1) return;
|
|
293
|
+
const i = this.event("state", e, { previousState: this.state, state: "display", value: this.committedValue });
|
|
294
|
+
this.state !== "display" && (!this.beforeStateChange(i) || ((c = (s = this.options.hooks) == null ? void 0 : s.beforeStateChange) == null ? void 0 : c.call(s, i)) === !1) || (this.value = this.committedValue, this.disposeView(), this.state = "display", this.draw(), this.emit("cancel", e), i.previousState !== "display" && this.publish(i));
|
|
295
295
|
}
|
|
296
296
|
edit(e = "api") {
|
|
297
|
-
var n,
|
|
298
|
-
this.life.destroyed || (this.setState("editing", e), this.state === "editing" && ((
|
|
297
|
+
var n, i;
|
|
298
|
+
this.life.destroyed || (this.setState("editing", e), this.state === "editing" && ((i = (n = this.view) == null ? void 0 : n.focus) == null || i.call(n)));
|
|
299
299
|
}
|
|
300
300
|
setState(e, n = "api") {
|
|
301
|
-
var r,
|
|
301
|
+
var r, s, c, u;
|
|
302
302
|
if (this.life.destroyed || e === this.state || e === "editing" && this.snapshot.readonly) return;
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
this.value = this.read(), this.state = e,
|
|
303
|
+
const i = this.event("state", n, { previousState: this.state });
|
|
304
|
+
if (i.state = e, !this.beforeStateChange(i) || ((s = (r = this.options.hooks) == null ? void 0 : r.beforeStateChange) == null ? void 0 : s.call(r, i)) === !1) return;
|
|
305
|
+
const o = this.state !== "editing" && e !== "editing" && !((c = this.options.renderers) != null && c.display) && !((u = this.options.renderers) != null && u.hover) && this.renderHover === K.prototype.renderHover;
|
|
306
|
+
this.value = this.read(), this.state = e, o && this.view ? this.element.dataset.state = e : this.draw(), this.publish(i);
|
|
307
307
|
}
|
|
308
308
|
action(e, n) {
|
|
309
|
-
var
|
|
309
|
+
var o, r;
|
|
310
310
|
if (this.life.destroyed) return;
|
|
311
|
-
const
|
|
312
|
-
(r = (
|
|
311
|
+
const i = { type: e, value: n };
|
|
312
|
+
(r = (o = this.options).onAction) == null || r.call(o, i), this.emit("action", "api", { action: i });
|
|
313
313
|
}
|
|
314
314
|
destroy() {
|
|
315
315
|
var e, n;
|
|
@@ -358,281 +358,281 @@ class K {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
draw() {
|
|
361
|
-
var
|
|
361
|
+
var y, T, p, b, h, E, M;
|
|
362
362
|
if (!this.mounted || this.life.destroyed) return;
|
|
363
|
-
const e = this.element.ownerDocument.activeElement, n = this.state === "editing" && !!e && (!!((
|
|
363
|
+
const e = this.element.ownerDocument.activeElement, n = this.state === "editing" && !!e && (!!((y = this.view) != null && y.element.contains(e)) || !!((p = (T = this.view) == null ? void 0 : T.content) != null && p.contains(e))), i = e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement ? { start: e.selectionStart, end: e.selectionEnd } : void 0;
|
|
364
364
|
this.disposeView(), this.isReadonly() && (this.state = "display");
|
|
365
|
-
const
|
|
366
|
-
...
|
|
365
|
+
const o = this.snapshot, r = this.options.content, s = typeof r == "function" ? r(o) : r ?? { kind: "text", text: this.value == null ? "" : String(this.value) }, c = this.context(), u = () => this.state === "editing" ? this.renderEditing(c) : r ? Re(s) : this.state === "hover" ? this.renderHover(c) : this.renderDisplay(c), f = {
|
|
366
|
+
...o,
|
|
367
367
|
element: this.element,
|
|
368
368
|
field: this.options.field,
|
|
369
|
-
content:
|
|
370
|
-
renderDefault:
|
|
371
|
-
input: (
|
|
369
|
+
content: s,
|
|
370
|
+
renderDefault: u,
|
|
371
|
+
input: (m) => this.input(m),
|
|
372
372
|
commit: () => this.commit(),
|
|
373
373
|
cancel: () => this.cancel(),
|
|
374
374
|
edit: () => this.edit(),
|
|
375
|
-
action: (
|
|
375
|
+
action: (m, L) => this.action(m, L)
|
|
376
376
|
};
|
|
377
|
-
if (this.view = ((
|
|
378
|
-
(
|
|
379
|
-
const
|
|
380
|
-
if ((
|
|
377
|
+
if (this.view = ((h = (b = this.options.renderers) == null ? void 0 : b[this.state]) == null ? void 0 : h.call(b, f)) ?? u(), this.element.setAttribute("aria-label", this.options.field.label), this.element.dataset.state = this.state, this.element.dataset.readonly = String(o.readonly), this.element.replaceChildren(this.view.element), this.element.removeAttribute("aria-invalid"), this.watch(this.view), n) {
|
|
378
|
+
(M = (E = this.view).focus) == null || M.call(E);
|
|
379
|
+
const m = this.element.ownerDocument.activeElement;
|
|
380
|
+
if ((i == null ? void 0 : i.start) != null && i.end != null && (m instanceof HTMLInputElement || m instanceof HTMLTextAreaElement))
|
|
381
381
|
try {
|
|
382
|
-
|
|
382
|
+
m.setSelectionRange(i.start, i.end);
|
|
383
383
|
} catch {
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
watch(e) {
|
|
388
388
|
if (this.mounted && this.state === "editing") {
|
|
389
|
-
const
|
|
390
|
-
this.viewLife.add(
|
|
391
|
-
contains: (
|
|
389
|
+
const i = () => [this.element, e.content, this.options.focusBoundary].filter((o) => !!o);
|
|
390
|
+
this.viewLife.add(Xe(this.element.ownerDocument, {
|
|
391
|
+
contains: (o, r) => i().some((s) => r.composedPath().includes(s) || !!o && s.contains(o) || be(o, s)),
|
|
392
392
|
leave: () => {
|
|
393
393
|
this.element.isConnected && this.commit("user");
|
|
394
394
|
}
|
|
395
395
|
}));
|
|
396
396
|
}
|
|
397
|
-
this.interactions ?? (this.interactions =
|
|
398
|
-
onInteraction: (
|
|
399
|
-
var
|
|
400
|
-
(r = (
|
|
401
|
-
for (const
|
|
397
|
+
this.interactions ?? (this.interactions = Qe(this.mounted ? this.element : e.element, `field:${this.options.field.key}`, {
|
|
398
|
+
onInteraction: (i) => {
|
|
399
|
+
var o, r;
|
|
400
|
+
(r = (o = this.options).onInteraction) == null || r.call(o, i);
|
|
401
|
+
for (const s of this.interactionListeners) s(i);
|
|
402
402
|
}
|
|
403
403
|
}));
|
|
404
|
-
const n = [...new Set([e.element, e.content].filter((
|
|
405
|
-
for (const
|
|
406
|
-
for (const
|
|
407
|
-
for (const
|
|
408
|
-
var
|
|
409
|
-
this.handled.has(r) || (this.handled.add(r), this.input(((
|
|
404
|
+
const n = [...new Set([e.element, e.content].filter((i) => !!i))];
|
|
405
|
+
for (const i of n) this.viewLife.add(this.interactions.addRoot(i));
|
|
406
|
+
for (const i of e.inputRoot ? [e.inputRoot] : n)
|
|
407
|
+
for (const o of ["input", "change"]) this.viewLife.listen(i, o, (r) => {
|
|
408
|
+
var s;
|
|
409
|
+
this.handled.has(r) || (this.handled.add(r), this.input(((s = e.read) == null ? void 0 : s.call(e)) ?? this.value, "user", r), o === "change" && this.emit("change", "user", { originalEvent: r }));
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
412
|
disposeView() {
|
|
413
413
|
var n;
|
|
414
|
-
this.viewLife.destroy(), this.viewLife = new
|
|
414
|
+
this.viewLife.destroy(), this.viewLife = new he();
|
|
415
415
|
const e = this.view;
|
|
416
416
|
this.view = void 0, (n = e == null ? void 0 : e.destroy) == null || n.call(e);
|
|
417
417
|
}
|
|
418
|
-
event(e, n,
|
|
419
|
-
return { ...this.snapshot, type: e, source: n, ...
|
|
418
|
+
event(e, n, i = {}) {
|
|
419
|
+
return { ...this.snapshot, type: e, source: n, ...i };
|
|
420
420
|
}
|
|
421
|
-
emit(e, n,
|
|
422
|
-
this.publish(this.event(e, n,
|
|
421
|
+
emit(e, n, i = {}) {
|
|
422
|
+
this.publish(this.event(e, n, i));
|
|
423
423
|
}
|
|
424
424
|
publish(e) {
|
|
425
|
-
var
|
|
426
|
-
this.onOutput(e), (r = (
|
|
425
|
+
var o, r, s;
|
|
426
|
+
this.onOutput(e), (r = (o = this.options).onEvent) == null || r.call(o, e);
|
|
427
427
|
for (const c of [...this.listeners]) c(e);
|
|
428
|
-
const n = this.mounted ? this.element : (
|
|
428
|
+
const n = this.mounted ? this.element : (s = this.view) == null ? void 0 : s.element;
|
|
429
429
|
if (!n) return;
|
|
430
|
-
const
|
|
431
|
-
n.dispatchEvent(new
|
|
430
|
+
const i = n.ownerDocument.defaultView.CustomEvent;
|
|
431
|
+
n.dispatchEvent(new i(`field:${e.type}`, { detail: e, bubbles: !0 }));
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
function
|
|
434
|
+
function Re(t) {
|
|
435
435
|
if (t.kind === "node") return { element: t.node, destroy: t.destroy };
|
|
436
436
|
const e = document.createElement("div");
|
|
437
437
|
if (e.className = t.className ?? "", t.kind === "text")
|
|
438
438
|
return e.textContent = t.text, { element: e };
|
|
439
|
-
const n = t.children.map(
|
|
440
|
-
return e.append(...n.map((
|
|
441
|
-
var
|
|
442
|
-
return (
|
|
439
|
+
const n = t.children.map(Re);
|
|
440
|
+
return e.append(...n.map((i) => i.element)), { element: e, destroy: () => n.forEach((i) => {
|
|
441
|
+
var o;
|
|
442
|
+
return (o = i.destroy) == null ? void 0 : o.call(i);
|
|
443
443
|
}) };
|
|
444
444
|
}
|
|
445
445
|
function a(t, e = "", n) {
|
|
446
|
-
const
|
|
447
|
-
return
|
|
446
|
+
const i = document.createElement(t);
|
|
447
|
+
return i.className = e, n !== void 0 && (i.textContent = n), i;
|
|
448
448
|
}
|
|
449
|
-
function
|
|
449
|
+
function Fe(t, e = 312) {
|
|
450
450
|
t.rows = 1, t.style.resize = "none";
|
|
451
451
|
const n = () => {
|
|
452
452
|
t.style.height = "auto";
|
|
453
|
-
const
|
|
454
|
-
|
|
453
|
+
const i = t.scrollHeight;
|
|
454
|
+
i > 0 && (t.style.height = Math.min(i, e) + "px"), t.style.overflowY = i > e ? "auto" : "hidden";
|
|
455
455
|
};
|
|
456
456
|
return t.addEventListener("input", n), t.addEventListener("focus", n), queueMicrotask(n), n;
|
|
457
457
|
}
|
|
458
|
-
const Q = (t) => t.choices ?? (t.options || []).map((e) => ({ id: e, label: e })),
|
|
459
|
-
var n,
|
|
460
|
-
return ((n = Q(t).find((
|
|
461
|
-
},
|
|
462
|
-
function
|
|
458
|
+
const Q = (t) => t.choices ?? (t.options || []).map((e) => ({ id: e, label: e })), Se = ["rgba(61, 188, 47, 0.2)", "rgba(0, 184, 159, 0.2)", "rgba(244, 118, 189, 0.2)", "rgba(149, 155, 238, 0.2)", "rgba(184, 143, 255, 0.2)"], Ee = (t, e) => {
|
|
459
|
+
var n, i;
|
|
460
|
+
return ((n = Q(t).find((o) => o.id === e)) == null ? void 0 : n.color) || ((i = t.colors) == null ? void 0 : i[e]) || Se[Math.max(0, Q(t).findIndex((o) => o.id === e)) % Se.length];
|
|
461
|
+
}, He = (t) => (Array.isArray(t) ? t : t == null || t === "" ? [] : [t]).map(String);
|
|
462
|
+
function et(t, e) {
|
|
463
463
|
var n;
|
|
464
|
-
return ((n = Q(t).find((
|
|
464
|
+
return ((n = Q(t).find((i) => i.id === e)) == null ? void 0 : n.label) || e;
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function Ie(t, e = "choice") {
|
|
467
467
|
const n = a("div", "fc-tags");
|
|
468
|
-
for (const
|
|
469
|
-
const
|
|
470
|
-
e === "choice" && (r.style.backgroundColor =
|
|
468
|
+
for (const i of He(t.value)) {
|
|
469
|
+
const o = et(t.field, i), r = a(e === "relation" ? "button" : "span", "fc-tag fc-tag--" + e);
|
|
470
|
+
e === "choice" && (r.style.backgroundColor = Ee(t.field, i)), e === "person" && r.append(a("span", "fc-avatar", o.slice(0, 1))), r.append(a("span", "fc-tag-label", o)), r.tagName === "BUTTON" && (r.type = "button", r.onclick = (s) => {
|
|
471
471
|
var c;
|
|
472
|
-
|
|
472
|
+
s.stopPropagation(), (c = t.onAction) == null || c.call(t, { type: "open", value: i });
|
|
473
473
|
}), n.append(r);
|
|
474
474
|
}
|
|
475
475
|
return n.children.length || n.append(a("span", "fc-empty", "待填")), n;
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function xe(t, e, n = "choice") {
|
|
478
478
|
var l;
|
|
479
|
-
const
|
|
480
|
-
let
|
|
479
|
+
const i = a("div", "fc-choice fc-choice--" + n);
|
|
480
|
+
let o = He(e.value).slice(0, t ? void 0 : 1);
|
|
481
481
|
const r = new Map(Q(e.field).map((d) => [d.id, d]));
|
|
482
|
-
let
|
|
483
|
-
const c = t && (e.field.maxSelections ?? 0) > 0 ? e.field.maxSelections : 1 / 0,
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
|
|
482
|
+
let s = Q(e.field);
|
|
483
|
+
const c = t && (e.field.maxSelections ?? 0) > 0 ? e.field.maxSelections : 1 / 0, u = a("select", "fc-select");
|
|
484
|
+
u.hidden = !0, u.multiple = t, u.disabled = e.readonly, u.required = !!e.field.required, u.ariaLabel = e.field.label;
|
|
485
|
+
const f = a("div", "fc-choice-head"), y = a("div", "fc-choice-selection"), T = a("span", "fc-empty fc-choice-placeholder", "待填"), p = a("input", "fc-choice-search");
|
|
486
|
+
p.placeholder = "", p.autocomplete = "off", p.ariaLabel = "输入以搜索" + e.field.label, p.disabled = e.readonly;
|
|
487
|
+
const b = () => {
|
|
488
|
+
p.size = Math.max(1, [...p.value].length + 1);
|
|
489
489
|
};
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
490
|
+
b();
|
|
491
|
+
const h = a("div", "fc-option-list");
|
|
492
|
+
h.setAttribute("role", n === "radio" ? "radiogroup" : "group"), h.ariaLabel = e.field.label;
|
|
493
493
|
const E = a("div", "fc-error fc-choice-feedback");
|
|
494
494
|
E.setAttribute("role", "status");
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
let L,
|
|
500
|
-
const
|
|
501
|
-
let
|
|
495
|
+
const M = a("div", "fc-picker-status");
|
|
496
|
+
M.setAttribute("role", "status");
|
|
497
|
+
const m = a("button", "fc-retry", "重试");
|
|
498
|
+
m.type = "button", m.hidden = !0;
|
|
499
|
+
let L, V = 0, N = !1, x = !1;
|
|
500
|
+
const A = n !== "radio" && !!((l = e.services) != null && l.searchOptions), R = n !== "radio" && e.layout !== "compact" && !e.readonly;
|
|
501
|
+
let C;
|
|
502
502
|
const j = () => {
|
|
503
|
-
const d =
|
|
504
|
-
|
|
505
|
-
},
|
|
506
|
-
!
|
|
507
|
-
|
|
503
|
+
const d = C;
|
|
504
|
+
C = void 0, d == null || d.close();
|
|
505
|
+
}, P = () => {
|
|
506
|
+
!R || N || C || e.readonly || (C = ce({ anchor: f, content: h, width: "anchor", onDismiss: () => {
|
|
507
|
+
C = void 0;
|
|
508
508
|
} }));
|
|
509
|
+
}, B = () => {
|
|
510
|
+
!R || !C || (j(), i.dispatchEvent(new Event("fc-collapse", { bubbles: !0 })));
|
|
509
511
|
}, q = () => {
|
|
510
|
-
!V || !S || (j(), s.dispatchEvent(new Event("fc-collapse", { bubbles: !0 })));
|
|
511
|
-
}, O = () => {
|
|
512
512
|
var d;
|
|
513
|
-
(d = e.onSelectedOptions) == null || d.call(e,
|
|
514
|
-
},
|
|
513
|
+
(d = e.onSelectedOptions) == null || d.call(e, o.map((w) => r.get(w)).filter((w) => !!w)), i.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
514
|
+
}, O = () => {
|
|
515
515
|
var d;
|
|
516
|
-
if (
|
|
516
|
+
if (u.replaceChildren(), !t) {
|
|
517
517
|
const w = a("option");
|
|
518
|
-
w.value = "",
|
|
518
|
+
w.value = "", u.append(w);
|
|
519
519
|
}
|
|
520
|
-
for (const w of /* @__PURE__ */ new Set([...
|
|
520
|
+
for (const w of /* @__PURE__ */ new Set([...s.map((v) => v.id), ...o])) {
|
|
521
521
|
const v = a("option", "", ((d = r.get(w)) == null ? void 0 : d.label) || w);
|
|
522
|
-
v.value = w, v.selected =
|
|
522
|
+
v.value = w, v.selected = o.includes(w), u.append(v);
|
|
523
523
|
}
|
|
524
|
-
t || (
|
|
525
|
-
},
|
|
526
|
-
|
|
527
|
-
for (const v of
|
|
524
|
+
t || (u.value = o[0] || "");
|
|
525
|
+
}, F = () => {
|
|
526
|
+
y.replaceChildren(), h.replaceChildren(), O(), !o.length && !p.value && y.append(T);
|
|
527
|
+
for (const v of o) {
|
|
528
528
|
const k = r.get(v), I = a("span", "fc-tag fc-tag--" + n);
|
|
529
|
-
(n === "choice" || n === "radio") && (I.style.backgroundColor =
|
|
530
|
-
const W = a("span", "fc-tag-slot"),
|
|
531
|
-
|
|
532
|
-
G.stopPropagation(),
|
|
533
|
-
}, W.append(
|
|
529
|
+
(n === "choice" || n === "radio") && (I.style.backgroundColor = Ee(e.field, v)), n === "person" && I.append(a("span", "fc-avatar", ((k == null ? void 0 : k.label) || v).slice(0, 1))), I.append(a("span", "fc-tag-label", ((k == null ? void 0 : k.label) || v) + (k != null && k.disabled ? "(已停用)" : "")));
|
|
530
|
+
const W = a("span", "fc-tag-slot"), U = a("button", "fc-choice-remove", "×");
|
|
531
|
+
U.type = "button", U.disabled = e.readonly, U.ariaLabel = "移除" + ((k == null ? void 0 : k.label) || v), U.onclick = (G) => {
|
|
532
|
+
G.stopPropagation(), o = o.filter((z) => z !== v), E.textContent = "", F(), p.focus(), q();
|
|
533
|
+
}, W.append(U), I.append(W), y.append(I);
|
|
534
534
|
}
|
|
535
|
-
const d =
|
|
535
|
+
const d = p.value.trim().toLocaleLowerCase(), w = s.filter((v) => !v.disabled && (A || (v.label + " " + v.id + " " + (v.description || "")).toLocaleLowerCase().includes(d)));
|
|
536
536
|
for (const v of w) {
|
|
537
537
|
const k = a("button", "fc-option");
|
|
538
|
-
k.type = "button", k.dataset.value = v.id, k.disabled = e.readonly ||
|
|
539
|
-
const I =
|
|
538
|
+
k.type = "button", k.dataset.value = v.id, k.disabled = e.readonly || x;
|
|
539
|
+
const I = o.includes(v.id);
|
|
540
540
|
k.classList.toggle("selected", I), k.setAttribute(n === "radio" ? "aria-checked" : "aria-pressed", String(I)), n === "radio" && k.setAttribute("role", "radio");
|
|
541
541
|
const W = a("span", "fc-option-label" + (n === "choice" ? " fc-tag" : ""), v.label);
|
|
542
|
-
n === "choice" && (W.style.backgroundColor =
|
|
543
|
-
const
|
|
544
|
-
|
|
542
|
+
n === "choice" && (W.style.backgroundColor = Ee(e.field, v.id)), n === "person" && k.append(a("span", "fc-avatar", v.label.slice(0, 1))), n === "relation" && k.append(a("span", "fc-relation-icon", "↗"));
|
|
543
|
+
const U = a("span", "fc-option-copy");
|
|
544
|
+
U.append(W), v.description && U.append(a("small", "fc-option-description", v.description)), k.append(U, a("span", "fc-option-mark", I ? "✓" : "")), k.onclick = (G) => {
|
|
545
545
|
if (G.stopPropagation(), !e.readonly) {
|
|
546
|
-
if (!t)
|
|
547
|
-
else if (I)
|
|
546
|
+
if (!t) o = [v.id];
|
|
547
|
+
else if (I) o = o.filter((z) => z !== v.id);
|
|
548
548
|
else {
|
|
549
|
-
const
|
|
549
|
+
const z = v.exclusive ? [] : o.filter((J) => {
|
|
550
550
|
var ee;
|
|
551
551
|
return !((ee = r.get(J)) != null && ee.exclusive);
|
|
552
552
|
});
|
|
553
|
-
if (
|
|
553
|
+
if (z.length >= c) {
|
|
554
554
|
E.textContent = "最多可选择 " + c + " 项";
|
|
555
555
|
return;
|
|
556
556
|
}
|
|
557
|
-
|
|
557
|
+
o = [...z, v.id];
|
|
558
558
|
}
|
|
559
|
-
E.textContent = "", t || (
|
|
560
|
-
|
|
561
|
-
}),
|
|
559
|
+
E.textContent = "", t || (p.value = "", b()), F(), h.querySelectorAll("button").forEach((z) => {
|
|
560
|
+
z.dataset.value === v.id && z.focus();
|
|
561
|
+
}), q(), !t && R && B();
|
|
562
562
|
}
|
|
563
|
-
},
|
|
563
|
+
}, h.append(k);
|
|
564
564
|
}
|
|
565
|
-
!w.length && !
|
|
566
|
-
},
|
|
565
|
+
!w.length && !x && h.append(a("p", "fc-empty fc-choice-empty", "暂无匹配选项"));
|
|
566
|
+
}, $ = async () => {
|
|
567
567
|
L == null || L.abort();
|
|
568
|
-
const d = ++
|
|
569
|
-
L = new AbortController(),
|
|
568
|
+
const d = ++V;
|
|
569
|
+
L = new AbortController(), x = !0, m.hidden = !0, M.textContent = "加载中…", i.setAttribute("aria-busy", "true"), F();
|
|
570
570
|
try {
|
|
571
|
-
const w = await e.services.searchOptions(e.field,
|
|
572
|
-
if (N || d !==
|
|
573
|
-
|
|
571
|
+
const w = await e.services.searchOptions(e.field, p.value.trim(), L.signal);
|
|
572
|
+
if (N || d !== V) return;
|
|
573
|
+
s = w, w.forEach((v) => r.set(v.id, v)), M.textContent = "";
|
|
574
574
|
} catch {
|
|
575
|
-
if (N || d !==
|
|
576
|
-
|
|
575
|
+
if (N || d !== V) return;
|
|
576
|
+
s = [], M.textContent = "加载失败,请重试", m.hidden = !1;
|
|
577
577
|
} finally {
|
|
578
|
-
!N && d ===
|
|
578
|
+
!N && d === V && (x = !1, i.setAttribute("aria-busy", "false"), F());
|
|
579
579
|
}
|
|
580
580
|
};
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
},
|
|
584
|
-
d.target.closest("button") ||
|
|
585
|
-
},
|
|
586
|
-
const
|
|
581
|
+
p.oninput = () => {
|
|
582
|
+
b(), A ? $() : F();
|
|
583
|
+
}, p.onfocus = () => P(), f.onclick = (d) => {
|
|
584
|
+
d.target.closest("button") || p.focus();
|
|
585
|
+
}, m.onclick = () => void $();
|
|
586
|
+
const Y = (d) => {
|
|
587
587
|
if (!["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Home", "End"].includes(d.key)) return;
|
|
588
|
-
const w = [...
|
|
588
|
+
const w = [...h.querySelectorAll("button:not(:disabled)")];
|
|
589
589
|
if (!w.length) return;
|
|
590
590
|
d.preventDefault();
|
|
591
591
|
const v = w.indexOf(document.activeElement), k = d.key === "Home" ? 0 : d.key === "End" ? w.length - 1 : (v + (d.key === "ArrowUp" || d.key === "ArrowLeft" ? -1 : 1) + w.length) % w.length;
|
|
592
592
|
w[k].focus();
|
|
593
593
|
};
|
|
594
|
-
if (
|
|
595
|
-
d.key === "ArrowDown" && (
|
|
596
|
-
},
|
|
597
|
-
|
|
598
|
-
},
|
|
594
|
+
if (h.onkeydown = Y, p.onkeydown = (d) => {
|
|
595
|
+
d.key === "ArrowDown" && (P(), Y(d));
|
|
596
|
+
}, u.onchange = () => {
|
|
597
|
+
o = [...u.selectedOptions].map((d) => d.value).filter(Boolean), F();
|
|
598
|
+
}, f.append(y), n !== "radio" && f.append(p), R) {
|
|
599
599
|
const d = a("span", "fc-field-chevron");
|
|
600
|
-
d.setAttribute("aria-hidden", "true"),
|
|
601
|
-
} else
|
|
602
|
-
return
|
|
603
|
-
element:
|
|
604
|
-
content:
|
|
605
|
-
read: () => t ? [...
|
|
606
|
-
validate: () => e.field.required && !
|
|
600
|
+
d.setAttribute("aria-hidden", "true"), f.append(d), i.append(u, f, M, m, E);
|
|
601
|
+
} else i.append(u, f, M, h, m, E);
|
|
602
|
+
return F(), A && !e.readonly && $(), {
|
|
603
|
+
element: i,
|
|
604
|
+
content: R ? h : void 0,
|
|
605
|
+
read: () => t ? [...o] : o[0] || "",
|
|
606
|
+
validate: () => e.field.required && !o.length ? "请选择一个选项" : o.length > c ? "最多可选择 " + c + " 项" : void 0,
|
|
607
607
|
focus: () => {
|
|
608
608
|
var d;
|
|
609
609
|
if (n === "radio") {
|
|
610
|
-
(d =
|
|
610
|
+
(d = h.querySelector("button")) == null || d.focus();
|
|
611
611
|
return;
|
|
612
612
|
}
|
|
613
|
-
|
|
613
|
+
p.focus(), P();
|
|
614
614
|
},
|
|
615
615
|
deactivate: () => {
|
|
616
|
-
|
|
616
|
+
p.value = "", b(), j();
|
|
617
617
|
},
|
|
618
618
|
destroy: () => {
|
|
619
|
-
N = !0, ++
|
|
619
|
+
N = !0, ++V, L == null || L.abort(), j();
|
|
620
620
|
}
|
|
621
621
|
};
|
|
622
622
|
}
|
|
623
|
-
const
|
|
624
|
-
function
|
|
623
|
+
const tt = new Set("P DIV BR STRONG B EM I U S STRIKE UL OL LI BLOCKQUOTE H1 H2 H3 H4 H5 SPAN FONT A IMG PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")), $e = (t) => /^(https?:\/\/|mailto:)/i.test(t.trim());
|
|
624
|
+
function me(t) {
|
|
625
625
|
const e = document.createElement("template");
|
|
626
626
|
e.innerHTML = String(t ?? "");
|
|
627
|
-
const n = (
|
|
628
|
-
for (const
|
|
629
|
-
if (
|
|
630
|
-
const r =
|
|
627
|
+
const n = (i) => {
|
|
628
|
+
for (const o of [...i.childNodes]) {
|
|
629
|
+
if (o.nodeType !== 1) continue;
|
|
630
|
+
const r = o;
|
|
631
631
|
if (["SCRIPT", "STYLE", "IFRAME", "OBJECT", "SVG", "MATH"].includes(r.tagName)) {
|
|
632
632
|
r.remove();
|
|
633
633
|
continue;
|
|
634
634
|
}
|
|
635
|
-
if (n(r), !
|
|
635
|
+
if (n(r), !tt.has(r.tagName)) {
|
|
636
636
|
r.replaceWith(...r.childNodes);
|
|
637
637
|
continue;
|
|
638
638
|
}
|
|
@@ -640,18 +640,18 @@ function he(t) {
|
|
|
640
640
|
r.remove();
|
|
641
641
|
continue;
|
|
642
642
|
}
|
|
643
|
-
const
|
|
644
|
-
for (const
|
|
645
|
-
for (const [
|
|
646
|
-
(
|
|
647
|
-
if (
|
|
643
|
+
const s = r.getAttribute("href") || "", c = r.getAttribute("src") || "", u = r.getAttribute("alt") || "", f = r.getAttribute("data-person-id"), y = r.hasAttribute("checked"), T = r.getAttribute("data-task") === "true", p = ["color", "background-color", "text-align", "margin-left", "font-weight", "font-style", "text-decoration-line"].map((h) => [h, r.style.getPropertyValue(h)]), b = r.tagName === "FONT" ? r.getAttribute("color") : null;
|
|
644
|
+
for (const h of [...r.attributes]) r.removeAttribute(h.name);
|
|
645
|
+
for (const [h, E] of p)
|
|
646
|
+
(h === "color" || h === "background-color" ? /^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(E) : h === "text-align" ? /^(left|center|right|justify)$/.test(E) : h === "margin-left" ? /^\d{1,3}px$/.test(E) : /^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(E)) && r.style.setProperty(h, E);
|
|
647
|
+
if (b && /^(#[a-f\d]{3,8}|[a-z]+)$/i.test(b) && (r.style.color = b), r.tagName === "A" && $e(s) && (r.setAttribute("href", s.trim()), r.setAttribute("target", "_blank"), r.setAttribute("rel", "noopener noreferrer")), r.tagName === "IMG") {
|
|
648
648
|
if (!/^https?:\/\//i.test(c.trim())) {
|
|
649
649
|
r.remove();
|
|
650
650
|
continue;
|
|
651
651
|
}
|
|
652
|
-
r.setAttribute("src", c.trim()), r.setAttribute("alt",
|
|
652
|
+
r.setAttribute("src", c.trim()), r.setAttribute("alt", u), r.setAttribute("loading", "lazy"), r.setAttribute("referrerpolicy", "no-referrer");
|
|
653
653
|
}
|
|
654
|
-
r.tagName === "SPAN" &&
|
|
654
|
+
r.tagName === "SPAN" && f && (r.setAttribute("data-person-id", f), r.setAttribute("contenteditable", "false")), r.tagName === "INPUT" && (r.setAttribute("type", "checkbox"), r.setAttribute("contenteditable", "false"), y && r.setAttribute("checked", "")), T && r.tagName === "LI" && r.setAttribute("data-task", "true");
|
|
655
655
|
}
|
|
656
656
|
};
|
|
657
657
|
return n(e.content), e.innerHTML;
|
|
@@ -669,102 +669,102 @@ const we = {
|
|
|
669
669
|
indent: '<path d="M10 5h11M10 12h11M10 19h11M2 8l4 4-4 4"/>',
|
|
670
670
|
line: '<path d="M3 12h18M3 5h3m3 0h3m3 0h3M3 19h3m3 0h3m3 0h3"/>'
|
|
671
671
|
};
|
|
672
|
-
function
|
|
672
|
+
function nt(t) {
|
|
673
673
|
const e = a("div", `fc-rich${t.layout === "compact" ? " fc-rich-compact" : ""}`), n = a("div", "fc-rich-toolbar");
|
|
674
674
|
n.setAttribute("role", "toolbar"), n.ariaLabel = "文本格式";
|
|
675
|
-
const
|
|
676
|
-
n.append(
|
|
677
|
-
const
|
|
678
|
-
|
|
675
|
+
const i = a("div", "fc-rich-tools");
|
|
676
|
+
n.append(i);
|
|
677
|
+
const o = a("div", "fc-rich-content");
|
|
678
|
+
o.contentEditable = String(!t.readonly), o.setAttribute("role", "textbox"), o.setAttribute("aria-multiline", "true"), o.ariaLabel = t.field.label, o.tabIndex = t.readonly ? -1 : 0, o.innerHTML = me(t.value);
|
|
679
679
|
const r = a("div", "fc-rich-menu");
|
|
680
680
|
r.hidden = !0;
|
|
681
|
-
let
|
|
682
|
-
const
|
|
681
|
+
let s = null, c = !1, u = [o.innerHTML], f = 0, y = !1, T = null, p, b;
|
|
682
|
+
const h = () => {
|
|
683
683
|
const l = window.getSelection();
|
|
684
|
-
l != null && l.rangeCount &&
|
|
684
|
+
l != null && l.rangeCount && o.contains(l.anchorNode) && o.contains(l.focusNode) && (s = l.getRangeAt(0).cloneRange());
|
|
685
685
|
}, E = () => {
|
|
686
|
-
|
|
686
|
+
o.focus();
|
|
687
687
|
const l = window.getSelection();
|
|
688
688
|
if (!l) return;
|
|
689
|
-
const d =
|
|
690
|
-
d !==
|
|
691
|
-
},
|
|
689
|
+
const d = s && o.contains(s.commonAncestorContainer) ? s : document.createRange();
|
|
690
|
+
d !== s && (d.selectNodeContents(o), d.collapse(!1)), l.removeAllRanges(), l.addRange(d), s = d;
|
|
691
|
+
}, M = () => {
|
|
692
692
|
var d;
|
|
693
|
-
const l =
|
|
694
|
-
|
|
695
|
-
},
|
|
693
|
+
const l = b;
|
|
694
|
+
b = void 0, l == null || l.close(), (d = p == null ? void 0 : p.destroy) == null || d.call(p), p = void 0, r.hidden = !0, r.replaceChildren();
|
|
695
|
+
}, m = /* @__PURE__ */ new Map(), L = () => {
|
|
696
696
|
var l;
|
|
697
|
-
|
|
697
|
+
m.get("撤销").disabled = t.readonly || f === 0, m.get("重做").disabled = t.readonly || f === u.length - 1;
|
|
698
698
|
for (const [d, w] of [["加粗", "bold"], ["斜体", "italic"], ["下划线", "underline"], ["删除线", "strikeThrough"], ["有序列表", "insertOrderedList"], ["无序列表", "insertUnorderedList"]]) {
|
|
699
|
-
const v =
|
|
699
|
+
const v = m.get(d);
|
|
700
700
|
if (!v) continue;
|
|
701
701
|
const k = !!((l = document.queryCommandState) != null && l.call(document, w));
|
|
702
702
|
v.classList.toggle("active", k), v.setAttribute("aria-pressed", String(k));
|
|
703
703
|
}
|
|
704
|
-
},
|
|
705
|
-
|
|
704
|
+
}, V = () => {
|
|
705
|
+
y || (o.innerHTML !== u[f] && (u = u.slice(0, f + 1), u.push(o.innerHTML), u.length > 100 && u.shift(), f = u.length - 1), h(), L());
|
|
706
706
|
}, N = () => {
|
|
707
|
-
|
|
708
|
-
},
|
|
709
|
-
const d =
|
|
710
|
-
d < 0 || d >=
|
|
711
|
-
},
|
|
712
|
-
t.readonly || (E(), document.execCommand(l, !1, d),
|
|
713
|
-
},
|
|
707
|
+
V(), o.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
708
|
+
}, x = (l) => {
|
|
709
|
+
const d = f + l;
|
|
710
|
+
d < 0 || d >= u.length || (f = d, y = !0, o.innerHTML = u[f], s = null, E(), y = !1, L(), o.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
711
|
+
}, A = (l, d) => {
|
|
712
|
+
t.readonly || (E(), document.execCommand(l, !1, d), h(), M(), N());
|
|
713
|
+
}, R = (l) => {
|
|
714
714
|
if (t.readonly) return;
|
|
715
715
|
E();
|
|
716
716
|
const d = window.getSelection().getRangeAt(0);
|
|
717
|
-
d.deleteContents(), d.insertNode(l), d.setStartAfter(l), d.collapse(!0),
|
|
718
|
-
},
|
|
717
|
+
d.deleteContents(), d.insertNode(l), d.setStartAfter(l), d.collapse(!0), s = d.cloneRange(), M(), N();
|
|
718
|
+
}, C = (l, d, w, v = !0) => {
|
|
719
719
|
const k = a("button", v ? "fc-rich-tool fc-rich-advanced" : "fc-rich-tool");
|
|
720
720
|
return k.type = "button", k.ariaLabel = l, k.title = l, k.disabled = t.readonly, we[d] ? k.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${we[d]}</svg>` : k.textContent = d, k.onmousedown = (I) => {
|
|
721
|
-
I.preventDefault(),
|
|
721
|
+
I.preventDefault(), h();
|
|
722
722
|
}, k.onclick = (I) => {
|
|
723
723
|
I.stopPropagation(), w();
|
|
724
|
-
},
|
|
724
|
+
}, i.append(k), m.set(l, k), k;
|
|
725
725
|
}, j = (l, d) => {
|
|
726
726
|
if (!t.readonly) {
|
|
727
|
-
if (
|
|
728
|
-
|
|
727
|
+
if (h(), !r.hidden && r.ariaLabel === l) {
|
|
728
|
+
M();
|
|
729
729
|
return;
|
|
730
730
|
}
|
|
731
|
-
|
|
731
|
+
M(), r.className = "fc-rich-menu", r.ariaLabel = l, r.hidden = !1, b = ce({ anchor: m.get(l), anchorMode: "element", content: r, width: "auto", onDismiss: M, onEscape: E }), d(), b == null || b.reposition();
|
|
732
732
|
}
|
|
733
|
-
},
|
|
733
|
+
}, P = (l, d) => {
|
|
734
734
|
const w = a("button", "fc-rich-menu-option", l);
|
|
735
735
|
return w.type = "button", w.onmousedown = (v) => v.preventDefault(), w.onclick = (v) => {
|
|
736
736
|
v.stopPropagation(), d();
|
|
737
737
|
}, r.append(w), w;
|
|
738
738
|
};
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
const l =
|
|
742
|
-
!d || !
|
|
743
|
-
}),
|
|
744
|
-
for (const [l, d] of [["正文", "p"], ["标题 1", "h1"], ["标题 2", "h2"], ["标题 3", "h3"], ["标题 4", "h4"], ["标题 5", "h5"]])
|
|
739
|
+
C("撤销", "undo", () => x(-1), !1), C("重做", "redo", () => x(1), !1), C("格式刷", "paint", () => {
|
|
740
|
+
h();
|
|
741
|
+
const l = s == null ? void 0 : s.startContainer, d = (l == null ? void 0 : l.nodeType) === 1 ? l : l == null ? void 0 : l.parentElement;
|
|
742
|
+
!d || !o.contains(d) || (T = { tag: /^(B|STRONG|I|EM|U|S)$/.test(d.tagName) ? d.tagName.toLowerCase() : "span", css: d.getAttribute("style") || "" }, m.get("格式刷").classList.add("active"));
|
|
743
|
+
}), C("正文样式", "Aa⌄", () => j("正文样式", () => {
|
|
744
|
+
for (const [l, d] of [["正文", "p"], ["标题 1", "h1"], ["标题 2", "h2"], ["标题 3", "h3"], ["标题 4", "h4"], ["标题 5", "h5"]]) P(l, () => A("formatBlock", d));
|
|
745
745
|
}));
|
|
746
|
-
const
|
|
746
|
+
const B = ["#1f2329", "#8f959e", "#ffffff", "#f54a45", "#ff8800", "#ffc60a", "#34c724", "#14b8a6", "#3370ff", "#7f3bf5", "#f7cdd9", "#fce2cf", "#fff3b8", "#d9f5d6", "#d6e8ff", "#e9ddfa"];
|
|
747
747
|
for (const [l, d, w] of [["文字颜色", "A⌄", "foreColor"], ["背景高亮", "▰⌄", "hiliteColor"]])
|
|
748
|
-
|
|
748
|
+
C(l, d, () => j(l, () => {
|
|
749
749
|
r.classList.add("fc-rich-colors");
|
|
750
|
-
for (const v of
|
|
751
|
-
const k =
|
|
750
|
+
for (const v of B) {
|
|
751
|
+
const k = P(v, () => A(w, v));
|
|
752
752
|
k.textContent = "", k.style.backgroundColor = v, k.ariaLabel = `${l} ${v}`;
|
|
753
753
|
}
|
|
754
|
-
|
|
754
|
+
P("清除", () => A(w, w === "foreColor" ? "#1f2329" : "transparent"));
|
|
755
755
|
}));
|
|
756
|
-
for (const [l, d, w] of [["加粗", "B", "bold"], ["斜体", "I", "italic"], ["下划线", "U", "underline"], ["删除线", "S", "strikeThrough"]])
|
|
757
|
-
|
|
758
|
-
for (const [l, d] of [["左对齐", "justifyLeft"], ["居中对齐", "justifyCenter"], ["右对齐", "justifyRight"], ["两端对齐", "justifyFull"]])
|
|
759
|
-
})),
|
|
756
|
+
for (const [l, d, w] of [["加粗", "B", "bold"], ["斜体", "I", "italic"], ["下划线", "U", "underline"], ["删除线", "S", "strikeThrough"]]) C(l, d, () => A(w));
|
|
757
|
+
C("对齐", "☰⌄", () => j("对齐", () => {
|
|
758
|
+
for (const [l, d] of [["左对齐", "justifyLeft"], ["居中对齐", "justifyCenter"], ["右对齐", "justifyRight"], ["两端对齐", "justifyFull"]]) P(l, () => A(d));
|
|
759
|
+
})), C("有序列表", "1≡", () => A("insertOrderedList")), C("无序列表", "•≡", () => A("insertUnorderedList")), C("任务列表", "task", () => {
|
|
760
760
|
E();
|
|
761
761
|
const l = window.getSelection().getRangeAt(0), d = a("ul"), w = a("li");
|
|
762
762
|
w.dataset.task = "true";
|
|
763
763
|
const v = a("input");
|
|
764
|
-
v.type = "checkbox", v.contentEditable = "false", w.append(v, l.extractContents()), w.textContent || w.append(document.createTextNode("待办事项")), d.append(w),
|
|
765
|
-
}),
|
|
766
|
-
|
|
767
|
-
})),
|
|
764
|
+
v.type = "checkbox", v.contentEditable = "false", w.append(v, l.extractContents()), w.textContent || w.append(document.createTextNode("待办事项")), d.append(w), R(d);
|
|
765
|
+
}), C("引用", "quote", () => A("formatBlock", "blockquote")), C("缩进", "indent", () => j("缩进", () => {
|
|
766
|
+
P("增加缩进", () => A("indent")), P("减少缩进", () => A("outdent"));
|
|
767
|
+
})), C("分隔线", "line", () => R(a("hr"))), C("表格", "table", () => j("表格", () => {
|
|
768
768
|
const l = a("p", "", "选择行列"), d = a("div", "fc-rich-table-grid");
|
|
769
769
|
r.append(l, d);
|
|
770
770
|
for (let w = 1; w <= 6; w++) for (let v = 1; v <= 6; v++) {
|
|
@@ -774,36 +774,36 @@ function tt(t) {
|
|
|
774
774
|
}, k.onclick = () => {
|
|
775
775
|
const I = a("table"), W = a("tbody");
|
|
776
776
|
for (let G = 0; G < w; G++) {
|
|
777
|
-
const
|
|
777
|
+
const z = a("tr");
|
|
778
778
|
for (let J = 0; J < v; J++) {
|
|
779
779
|
const ee = a("td");
|
|
780
|
-
ee.append(a("br")),
|
|
780
|
+
ee.append(a("br")), z.append(ee);
|
|
781
781
|
}
|
|
782
|
-
W.append(
|
|
782
|
+
W.append(z);
|
|
783
783
|
}
|
|
784
|
-
I.append(W),
|
|
785
|
-
const
|
|
786
|
-
|
|
784
|
+
I.append(W), R(I);
|
|
785
|
+
const U = document.createRange();
|
|
786
|
+
U.selectNodeContents(I.querySelector("td")), U.collapse(!0), s = U, E();
|
|
787
787
|
}, d.append(k);
|
|
788
788
|
}
|
|
789
789
|
}));
|
|
790
|
-
const
|
|
790
|
+
const q = () => j("链接", () => {
|
|
791
791
|
const l = a("input", "fc-input");
|
|
792
|
-
l.ariaLabel = "链接文本", l.placeholder = "输入文本", l.value = (
|
|
792
|
+
l.ariaLabel = "链接文本", l.placeholder = "输入文本", l.value = (s == null ? void 0 : s.toString()) || "";
|
|
793
793
|
const d = a("input", "fc-input");
|
|
794
794
|
d.ariaLabel = "链接地址", d.placeholder = "粘贴或输入超链接";
|
|
795
795
|
const w = a("div", "fc-error"), v = a("button", "primary", "确定");
|
|
796
796
|
v.type = "button", v.onclick = () => {
|
|
797
797
|
const k = d.value.trim();
|
|
798
|
-
if (
|
|
798
|
+
if (!$e(k)) {
|
|
799
799
|
w.textContent = "请输入 http、https 或 mailto 链接";
|
|
800
800
|
return;
|
|
801
801
|
}
|
|
802
802
|
const I = a("a", "", l.value || k);
|
|
803
|
-
I.href = k, I.target = "_blank", I.rel = "noopener noreferrer",
|
|
803
|
+
I.href = k, I.target = "_blank", I.rel = "noopener noreferrer", R(I);
|
|
804
804
|
}, r.append(a("span", "", "文本"), l, a("span", "", "链接"), d, w, v), l.focus();
|
|
805
805
|
});
|
|
806
|
-
|
|
806
|
+
C("链接", "link", q), C("插入图片", "▧", () => j("插入图片", () => {
|
|
807
807
|
const l = a("input", "fc-input");
|
|
808
808
|
l.type = "url", l.ariaLabel = "图片地址", l.placeholder = "https:// 图片地址";
|
|
809
809
|
const d = a("input", "fc-input");
|
|
@@ -815,43 +815,43 @@ function tt(t) {
|
|
|
815
815
|
return;
|
|
816
816
|
}
|
|
817
817
|
const k = a("img");
|
|
818
|
-
k.src = l.value.trim(), k.alt = d.value, k.referrerPolicy = "no-referrer",
|
|
818
|
+
k.src = l.value.trim(), k.alt = d.value, k.referrerPolicy = "no-referrer", R(k);
|
|
819
819
|
}, r.append(l, d, w, v), l.focus();
|
|
820
|
-
})),
|
|
820
|
+
})), C("提及人员", "@", () => j("提及人员", () => {
|
|
821
821
|
var d;
|
|
822
|
-
const l =
|
|
823
|
-
|
|
822
|
+
const l = xe(!1, { ...t, value: "", field: { ...t.field, label: "人员" } }, "person");
|
|
823
|
+
p = l, r.append(l.element), l.element.addEventListener("change", (w) => {
|
|
824
824
|
var I, W;
|
|
825
825
|
w.stopPropagation();
|
|
826
826
|
const v = String(l.read());
|
|
827
827
|
if (!v) return;
|
|
828
|
-
const k = a("span", "", "@" + (((I = Q(t.field).find((
|
|
829
|
-
k.dataset.personId = v, k.contentEditable = "false",
|
|
828
|
+
const k = a("span", "", "@" + (((I = Q(t.field).find((U) => U.id === v)) == null ? void 0 : I.label) || ((W = l.element.querySelector("option:checked")) == null ? void 0 : W.textContent) || v));
|
|
829
|
+
k.dataset.personId = v, k.contentEditable = "false", R(k);
|
|
830
830
|
}), (d = l.focus) == null || d.call(l);
|
|
831
|
-
})),
|
|
831
|
+
})), C("代码块", "{ }", () => A("formatBlock", "pre")), C("表情", "☺", () => j("表情", () => {
|
|
832
832
|
r.classList.add("fc-rich-emojis");
|
|
833
|
-
for (const l of ["😀", "😊", "😂", "👍", "👏", "🎉", "❤️", "🔥", "✅", "💡", "🚀", "👀", "🤔", "🙏", "💪", "⭐"])
|
|
833
|
+
for (const l of ["😀", "😊", "😂", "👍", "👏", "🎉", "❤️", "🔥", "✅", "💡", "🚀", "👀", "🤔", "🙏", "💪", "⭐"]) P(l, () => R(document.createTextNode(l)));
|
|
834
834
|
}));
|
|
835
|
-
const
|
|
836
|
-
|
|
835
|
+
const O = C("全屏编辑", "expand", () => {
|
|
836
|
+
h(), c = !c, e.classList.toggle("is-fullscreen", c), M(), O.ariaLabel = O.title = c ? "收起全屏" : "全屏编辑", O.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${we[c ? "collapse" : "expand"]}</svg>`, E();
|
|
837
837
|
}, !1);
|
|
838
|
-
|
|
839
|
-
const
|
|
840
|
-
for (const l of
|
|
841
|
-
},
|
|
842
|
-
|
|
843
|
-
const
|
|
838
|
+
O.disabled = !1, O.classList.add("fc-rich-expand"), n.append(O);
|
|
839
|
+
const F = () => {
|
|
840
|
+
for (const l of i.children) l.inert = l.offsetTop >= i.clientHeight;
|
|
841
|
+
}, $ = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(F);
|
|
842
|
+
$ == null || $.observe(i);
|
|
843
|
+
const Y = (l) => {
|
|
844
844
|
const d = l.target;
|
|
845
|
-
|
|
845
|
+
o.contains(d) || d.closest("input,textarea,select,[contenteditable=true]") || (l.preventDefault(), !e.contains(document.activeElement) && !r.contains(document.activeElement) && E());
|
|
846
846
|
};
|
|
847
|
-
return e.addEventListener("mousedown",
|
|
848
|
-
if (
|
|
849
|
-
const l =
|
|
850
|
-
d.style.cssText = T.css, d.append(l.extractContents()), l.insertNode(d), T = null,
|
|
847
|
+
return e.addEventListener("mousedown", Y), r.addEventListener("mousedown", Y), o.addEventListener("input", V), o.addEventListener("mouseup", () => {
|
|
848
|
+
if (h(), L(), T && s && !s.collapsed) {
|
|
849
|
+
const l = s, d = a(T.tag);
|
|
850
|
+
d.style.cssText = T.css, d.append(l.extractContents()), l.insertNode(d), T = null, m.get("格式刷").classList.remove("active"), N();
|
|
851
851
|
}
|
|
852
|
-
}),
|
|
853
|
-
|
|
854
|
-
}),
|
|
852
|
+
}), o.addEventListener("keyup", () => {
|
|
853
|
+
h(), L();
|
|
854
|
+
}), o.addEventListener("click", (l) => {
|
|
855
855
|
const d = l.target;
|
|
856
856
|
if (d.tagName === "A" && l.preventDefault(), d instanceof HTMLInputElement && d.type === "checkbox") {
|
|
857
857
|
if (t.readonly) {
|
|
@@ -860,817 +860,929 @@ function tt(t) {
|
|
|
860
860
|
}
|
|
861
861
|
d.toggleAttribute("checked", d.checked), N();
|
|
862
862
|
}
|
|
863
|
-
|
|
864
|
-
}),
|
|
863
|
+
M();
|
|
864
|
+
}), o.addEventListener("drop", (l) => l.preventDefault()), o.addEventListener("paste", (l) => {
|
|
865
865
|
var w, v;
|
|
866
866
|
if (t.readonly) {
|
|
867
867
|
l.preventDefault();
|
|
868
868
|
return;
|
|
869
869
|
}
|
|
870
|
-
l.preventDefault(),
|
|
870
|
+
l.preventDefault(), h();
|
|
871
871
|
const d = (w = l.clipboardData) == null ? void 0 : w.getData("text/html");
|
|
872
872
|
if (d) {
|
|
873
873
|
const k = document.createElement("template");
|
|
874
|
-
k.innerHTML =
|
|
874
|
+
k.innerHTML = me(d);
|
|
875
875
|
const I = k.content, W = document.createTextNode("");
|
|
876
876
|
I.append(W), E();
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
} else
|
|
877
|
+
const U = window.getSelection().getRangeAt(0);
|
|
878
|
+
U.deleteContents(), U.insertNode(I), U.setStartAfter(W), U.collapse(!0), s = U.cloneRange(), N();
|
|
879
|
+
} else R(document.createTextNode(((v = l.clipboardData) == null ? void 0 : v.getData("text/plain")) || ""));
|
|
880
880
|
}), e.addEventListener("keydown", (l) => {
|
|
881
|
-
l.key === "Escape" && !r.hidden ? (l.preventDefault(), l.stopPropagation(),
|
|
882
|
-
}), e.append(n,
|
|
881
|
+
l.key === "Escape" && !r.hidden ? (l.preventDefault(), l.stopPropagation(), M(), E()) : l.key === "Escape" && c ? (l.preventDefault(), l.stopPropagation(), O.click()) : !t.readonly && (l.metaKey || l.ctrlKey) && l.key.toLowerCase() === "z" ? (l.preventDefault(), x(l.shiftKey ? 1 : -1)) : (l.metaKey || l.ctrlKey) && l.key.toLowerCase() === "k" && (l.preventDefault(), h(), q());
|
|
882
|
+
}), e.append(n, o), L(), { element: e, content: r, inputRoot: e, read: () => me(o.innerHTML), validate: () => {
|
|
883
883
|
var l;
|
|
884
|
-
return t.field.required && !((l =
|
|
885
|
-
}, focus: () =>
|
|
886
|
-
|
|
884
|
+
return t.field.required && !((l = o.textContent) != null && l.trim()) && !o.querySelector("img") ? "请填写内容" : void 0;
|
|
885
|
+
}, focus: () => o.focus(), deactivate: () => {
|
|
886
|
+
M(), c = !1, e.classList.remove("is-fullscreen"), O.ariaLabel = O.title = "全屏编辑";
|
|
887
887
|
}, destroy: () => {
|
|
888
|
-
|
|
888
|
+
$ == null || $.disconnect(), M();
|
|
889
889
|
} };
|
|
890
890
|
}
|
|
891
|
-
const
|
|
892
|
-
function
|
|
891
|
+
const Oe = (t) => t == null ? "" : String(t);
|
|
892
|
+
function it(t) {
|
|
893
893
|
var n;
|
|
894
894
|
const e = a("div", `fc-value fc-${t.className || ""}`);
|
|
895
|
-
if (t.field.kind === "richText" || t.field.kind === "richtext" || t.field.kind === "longText" || t.field.control === "richText") e.innerHTML =
|
|
895
|
+
if (t.field.kind === "richText" || t.field.kind === "richtext" || t.field.kind === "longText" || t.field.control === "richText") e.innerHTML = me(t.value);
|
|
896
896
|
else if (t.field.kind === "number" && typeof t.value == "number") {
|
|
897
|
-
const
|
|
898
|
-
e.textContent = t.value.toLocaleString("zh-CN", { useGrouping: (
|
|
897
|
+
const i = t.field.numberOptions;
|
|
898
|
+
e.textContent = t.value.toLocaleString("zh-CN", { useGrouping: (i == null ? void 0 : i.thousandsSeparator) ?? !1, maximumFractionDigits: (i == null ? void 0 : i.decimals) ?? 10 }) + ((i == null ? void 0 : i.suffix) || ""), e.classList.add("fc-plain");
|
|
899
899
|
} else
|
|
900
|
-
e.textContent =
|
|
900
|
+
e.textContent = Oe(t.value), e.classList.add("fc-plain");
|
|
901
901
|
return (n = e.textContent) != null && n.trim() || (e.textContent = "待填", e.classList.add("fc-empty")), e;
|
|
902
902
|
}
|
|
903
|
-
function
|
|
904
|
-
const
|
|
905
|
-
if (
|
|
906
|
-
const
|
|
907
|
-
|
|
903
|
+
function Pe(t, e) {
|
|
904
|
+
const i = t === "text" && e.layout !== "compact" ? a("textarea", "fc-input fc-textarea") : a("input", "fc-input");
|
|
905
|
+
if (i instanceof HTMLInputElement && (i.type = t), i.value = Oe(e.value), i.disabled = e.readonly, i.required = !!e.field.required, i.ariaLabel = e.field.label, i.placeholder = e.field.placeholder || (e.layout !== "compact" ? "待填" : `请输入${e.field.label}`), e.field.maxLength !== void 0 && (i.maxLength = e.field.maxLength), t === "number" && i instanceof HTMLInputElement) {
|
|
906
|
+
const o = e.field.numberOptions;
|
|
907
|
+
i.step = String((o == null ? void 0 : o.step) ?? "any"), (o == null ? void 0 : o.min) !== void 0 && (i.min = String(o.min)), (o == null ? void 0 : o.max) !== void 0 && (i.max = String(o.max));
|
|
908
908
|
}
|
|
909
|
-
return
|
|
910
|
-
|
|
909
|
+
return i instanceof HTMLTextAreaElement && Fe(i), t === "text" && e.layout !== "compact" && i.addEventListener("keydown", (o) => {
|
|
910
|
+
o.key === "Enter" && (o.preventDefault(), i.dispatchEvent(new Event("fc-collapse", { bubbles: !0 })));
|
|
911
911
|
}), {
|
|
912
|
-
element:
|
|
913
|
-
read: () => t === "number" ?
|
|
914
|
-
validate: () => e.field.required && !
|
|
915
|
-
focus: () =>
|
|
912
|
+
element: i,
|
|
913
|
+
read: () => t === "number" ? i.value === "" ? null : Number(i.value) : i.value,
|
|
914
|
+
validate: () => e.field.required && !i.value.trim() ? "此项必填" : i.checkValidity() ? void 0 : i.validationMessage || "请填写有效值",
|
|
915
|
+
focus: () => i.focus()
|
|
916
916
|
};
|
|
917
917
|
}
|
|
918
|
-
const
|
|
918
|
+
const oe = (t) => t == null ? "" : String(t), ie = (t) => t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
919
|
+
function Ae(t) {
|
|
920
|
+
try {
|
|
921
|
+
const e = new URL(oe(t));
|
|
922
|
+
return ["http:", "https:"].includes(e.protocol) ? e.href : void 0;
|
|
923
|
+
} catch {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
function ue(t) {
|
|
928
|
+
return a("div", "fc-value fc-plain fc-" + (t.className || "") + (t.value == null || t.value === "" ? " fc-empty" : ""), oe(t.value) || "待填");
|
|
929
|
+
}
|
|
930
|
+
function ve(t, e) {
|
|
931
|
+
const n = e === "textarea" ? a("textarea", "fc-input fc-textarea") : a("input", "fc-input");
|
|
932
|
+
return n instanceof HTMLInputElement && (n.type = e), n instanceof HTMLTextAreaElement && Fe(n), n.value = oe(t.value), n.disabled = t.readonly, n.required = !!t.field.required, n.ariaLabel = t.field.label, n.placeholder = t.field.placeholder || "请输入" + t.field.label, t.field.maxLength !== void 0 && (n.maxLength = t.field.maxLength), {
|
|
933
|
+
element: n,
|
|
934
|
+
read: () => n.value,
|
|
935
|
+
focus: () => n.focus(),
|
|
936
|
+
validate: () => e === "url" && n.value && !Ae(n.value) ? "请输入 http 或 https 链接" : n.checkValidity() ? void 0 : "请填写有效的" + t.field.label
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
function ot(t) {
|
|
940
|
+
const e = a("div", "fc-link-value"), n = Ae(t.value);
|
|
941
|
+
if (!n) return ue(t);
|
|
942
|
+
const i = a("a", "fc-link", oe(t.value));
|
|
943
|
+
return i.href = n, i.target = "_blank", i.rel = "noopener noreferrer", i.onclick = (o) => o.stopPropagation(), e.append(a("span", "fc-link-icon", "↗"), i), e;
|
|
944
|
+
}
|
|
945
|
+
function qe(t) {
|
|
946
|
+
let e = t.value == null || t.value === "" ? null : t.value === !0;
|
|
947
|
+
const n = a("div", "fc-switch-field"), i = a("button", "fc-switch");
|
|
948
|
+
i.type = "button", i.setAttribute("role", "switch"), i.ariaLabel = t.field.label, i.disabled = t.readonly;
|
|
949
|
+
const o = a("span"), r = () => {
|
|
950
|
+
i.setAttribute("aria-checked", String(e === !0)), n.dataset.empty = String(e === null), o.textContent = e === null ? "待填" : e ? "是" : "否";
|
|
951
|
+
};
|
|
952
|
+
return i.onclick = () => {
|
|
953
|
+
t.readonly || (e = !e, r(), ie(n));
|
|
954
|
+
}, n.append(i, o), r(), { element: n, read: () => e, focus: () => i.focus() };
|
|
955
|
+
}
|
|
956
|
+
function st(t) {
|
|
957
|
+
return qe({ ...t, readonly: !0 }).element;
|
|
958
|
+
}
|
|
959
|
+
function rt(t) {
|
|
960
|
+
const e = a("div", "fc-signals"), n = Array.isArray(t.value) ? t.value : [t.value];
|
|
961
|
+
for (const i of n.filter((o) => o != null && o !== "")) {
|
|
962
|
+
const o = typeof i == "object" ? i : { status: i }, r = o.status ?? o.value, s = r === !0 || r === "passed" || r === "success", c = a("span", "fc-signal " + (s ? "is-success" : "is-pending"), (s ? "● " : "○ ") + oe(o.label || o.name || (s ? "已满足" : r === !1 ? "未满足" : r || "等待信号")));
|
|
963
|
+
e.append(c);
|
|
964
|
+
}
|
|
965
|
+
return e.children.length || e.append(a("span", "fc-empty", "等待外部信号")), e;
|
|
966
|
+
}
|
|
967
|
+
function at(t) {
|
|
968
|
+
const e = t.value && typeof t.value == "object" ? t.value.display ?? t.value.value : t.value;
|
|
969
|
+
return ue({ ...t, value: e != null && typeof e != "object" ? e : "" });
|
|
970
|
+
}
|
|
971
|
+
function lt(t, e) {
|
|
972
|
+
const n = a("div", "fc-readonly");
|
|
973
|
+
return n.append(e(t), a("small", "fc-service-note", "由系统更新 · 只读")), { element: n, read: () => t.value };
|
|
974
|
+
}
|
|
975
|
+
function Me(t) {
|
|
976
|
+
const e = t.field.radioValueType === "boolean";
|
|
977
|
+
let n = t.value == null ? "" : String(t.value);
|
|
978
|
+
const i = a("div", "fc-radio-group fc-choice--radio");
|
|
979
|
+
i.setAttribute("role", "radiogroup"), i.ariaLabel = t.field.label;
|
|
980
|
+
const o = [], r = () => {
|
|
981
|
+
const s = o.find((c) => c.dataset.value === n && !c.disabled) ?? o.find((c) => !c.disabled);
|
|
982
|
+
for (const c of o) {
|
|
983
|
+
const u = c.dataset.value === n;
|
|
984
|
+
c.setAttribute("aria-checked", String(u)), c.classList.toggle("selected", u), c.tabIndex = c === s ? 0 : -1;
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
for (const s of Q(t.field)) {
|
|
988
|
+
const c = a("button", "fc-option fc-radio-option");
|
|
989
|
+
c.type = "button", c.dataset.value = s.id, c.setAttribute("role", "radio"), c.disabled = t.readonly || !!s.disabled;
|
|
990
|
+
const u = a("span", "fc-radio-dot");
|
|
991
|
+
u.ariaHidden = "true", c.append(u, a("span", "fc-option-label", s.label)), c.onclick = (f) => {
|
|
992
|
+
f.stopPropagation(), !(c.disabled || n === s.id) && (n = s.id, r(), ie(i));
|
|
993
|
+
}, c.onkeydown = (f) => {
|
|
994
|
+
var h, E;
|
|
995
|
+
if (!["ArrowRight", "ArrowDown", "ArrowLeft", "ArrowUp", "Home", "End"].includes(f.key) || t.readonly) return;
|
|
996
|
+
f.preventDefault(), f.stopPropagation();
|
|
997
|
+
const T = o.filter((M) => !M.disabled), p = T.indexOf(c), b = f.key === "Home" ? 0 : f.key === "End" ? T.length - 1 : (p + (["ArrowLeft", "ArrowUp"].includes(f.key) ? -1 : 1) + T.length) % T.length;
|
|
998
|
+
(h = T[b]) == null || h.focus(), (E = T[b]) == null || E.click();
|
|
999
|
+
}, o.push(c), i.append(c);
|
|
1000
|
+
}
|
|
1001
|
+
return o.length ? n && !o.some((s) => s.dataset.value === n) && i.append(a("span", "fc-empty", "已选选项不可用")) : i.append(a("span", "fc-empty", "暂无选项")), r(), {
|
|
1002
|
+
element: i,
|
|
1003
|
+
read: () => e ? n === "" ? null : n === "true" : n,
|
|
1004
|
+
focus: () => {
|
|
1005
|
+
var s;
|
|
1006
|
+
return (s = o.find((c) => c.tabIndex === 0)) == null ? void 0 : s.focus();
|
|
1007
|
+
},
|
|
1008
|
+
validate: () => t.field.required && !n ? "请选择一个选项" : void 0
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
const Be = (t) => !Array.isArray(t) || !t.length ? [] : Array.isArray(t[0]) ? t.map((e) => e.map(String)) : [t.map(String)];
|
|
919
1012
|
function le(t, e) {
|
|
920
1013
|
const n = [];
|
|
921
|
-
for (const
|
|
922
|
-
const
|
|
923
|
-
n.push((
|
|
1014
|
+
for (const i of e) {
|
|
1015
|
+
const o = t.find((r) => r.id === i);
|
|
1016
|
+
n.push((o == null ? void 0 : o.label) || i), t = (o == null ? void 0 : o.children) || [];
|
|
924
1017
|
}
|
|
925
1018
|
return n.join(" / ");
|
|
926
1019
|
}
|
|
927
|
-
function
|
|
1020
|
+
function dt(t) {
|
|
928
1021
|
const e = a("div", "fc-tags");
|
|
929
|
-
for (const n of
|
|
930
|
-
const
|
|
931
|
-
|
|
1022
|
+
for (const n of Be(t.value)) {
|
|
1023
|
+
const i = a("span", "fc-tag");
|
|
1024
|
+
i.append(a("span", "fc-tag-label", le(Q(t.field), n))), e.append(i);
|
|
932
1025
|
}
|
|
933
1026
|
return e.children.length || e.append(a("span", "fc-empty", "待填")), e;
|
|
934
1027
|
}
|
|
935
|
-
function
|
|
936
|
-
const n = a("div", "fc-cascade"),
|
|
937
|
-
|
|
1028
|
+
function ct(t, e) {
|
|
1029
|
+
const n = a("div", "fc-cascade"), i = a("div", "fc-choice-selection"), o = a("input", "fc-choice-search");
|
|
1030
|
+
o.placeholder = "", o.autocomplete = "off", o.ariaLabel = "输入以搜索" + e.field.label, o.disabled = e.readonly;
|
|
938
1031
|
const r = () => {
|
|
939
|
-
|
|
1032
|
+
o.size = Math.max(1, [...o.value].length + 1);
|
|
940
1033
|
};
|
|
941
1034
|
r();
|
|
942
|
-
const
|
|
1035
|
+
const s = a("div", "fc-cascade-columns"), c = a("div", "fc-error");
|
|
943
1036
|
c.setAttribute("role", "status");
|
|
944
|
-
const
|
|
945
|
-
let
|
|
946
|
-
const T = [],
|
|
1037
|
+
const u = Q(e.field);
|
|
1038
|
+
let f = Be(e.value), y = [];
|
|
1039
|
+
const T = [], p = (x, A, R = !1) => x.forEach((C) => {
|
|
947
1040
|
var j;
|
|
948
|
-
(j =
|
|
1041
|
+
(j = C.children) != null && j.length ? p(C.children, [...A, C.id], R || !!C.disabled) : T.push({ path: [...A, C.id], disabled: R || !!C.disabled });
|
|
949
1042
|
});
|
|
950
|
-
|
|
951
|
-
const
|
|
1043
|
+
p(u, []);
|
|
1044
|
+
const b = (x, A) => JSON.stringify(x) === JSON.stringify(A), h = e.layout !== "compact" && !e.readonly;
|
|
952
1045
|
let E;
|
|
953
|
-
const
|
|
954
|
-
const
|
|
955
|
-
E = void 0,
|
|
956
|
-
},
|
|
957
|
-
!
|
|
1046
|
+
const M = () => {
|
|
1047
|
+
const x = E;
|
|
1048
|
+
E = void 0, x == null || x.close();
|
|
1049
|
+
}, m = () => {
|
|
1050
|
+
!h || E || e.readonly || (E = ce({ anchor: o.parentElement || n, content: s, width: "anchor", gap: 4, onDismiss: () => {
|
|
958
1051
|
E = void 0;
|
|
959
1052
|
} }));
|
|
960
1053
|
}, L = () => {
|
|
961
|
-
!
|
|
962
|
-
},
|
|
1054
|
+
!h || !E || (M(), n.dispatchEvent(new Event("fc-collapse", { bubbles: !0 })));
|
|
1055
|
+
}, V = (x) => {
|
|
963
1056
|
if (e.readonly) return;
|
|
964
|
-
const
|
|
965
|
-
if (t &&
|
|
1057
|
+
const A = f.findIndex((R) => b(R, x));
|
|
1058
|
+
if (t && A >= 0) f.splice(A, 1);
|
|
966
1059
|
else {
|
|
967
|
-
if (t && e.field.maxSelections &&
|
|
1060
|
+
if (t && e.field.maxSelections && f.length >= e.field.maxSelections) {
|
|
968
1061
|
c.textContent = "最多可选择 " + e.field.maxSelections + " 项";
|
|
969
1062
|
return;
|
|
970
1063
|
}
|
|
971
|
-
|
|
1064
|
+
f = t ? [...f, x] : [x];
|
|
972
1065
|
}
|
|
973
1066
|
c.textContent = "", N(), n.dispatchEvent(new Event("change", { bubbles: !0 })), t || L();
|
|
974
1067
|
}, N = () => {
|
|
975
|
-
var
|
|
976
|
-
if (
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
},
|
|
983
|
-
}),
|
|
984
|
-
const
|
|
985
|
-
for (const { path:
|
|
986
|
-
const
|
|
987
|
-
|
|
1068
|
+
var C, j;
|
|
1069
|
+
if (i.replaceChildren(), s.replaceChildren(), f.forEach((P) => {
|
|
1070
|
+
const B = a("span", "fc-tag");
|
|
1071
|
+
B.append(a("span", "fc-tag-label", le(u, P)));
|
|
1072
|
+
const q = a("span", "fc-tag-slot"), O = a("button", "fc-choice-remove", "×");
|
|
1073
|
+
O.type = "button", O.disabled = e.readonly, O.ariaLabel = "移除" + le(u, P), O.onclick = () => {
|
|
1074
|
+
f = f.filter((F) => !b(P, F)), N(), n.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1075
|
+
}, q.append(O), B.append(q), i.append(B);
|
|
1076
|
+
}), o.value.trim()) {
|
|
1077
|
+
const P = T.filter((B) => !B.disabled && le(u, B.path).toLocaleLowerCase().includes(o.value.trim().toLocaleLowerCase()));
|
|
1078
|
+
for (const { path: B } of P) {
|
|
1079
|
+
const q = a("button", "fc-option", le(u, B));
|
|
1080
|
+
q.type = "button", q.disabled = e.readonly, q.setAttribute("aria-pressed", String(f.some((O) => b(O, B)))), q.onclick = () => V(B), s.append(q);
|
|
988
1081
|
}
|
|
989
|
-
|
|
1082
|
+
s.classList.add("is-search"), P.length || s.append(a("p", "fc-empty", "暂无匹配路径"));
|
|
990
1083
|
return;
|
|
991
1084
|
}
|
|
992
|
-
|
|
993
|
-
let
|
|
994
|
-
for (;
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
for (const
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
var
|
|
1001
|
-
|
|
1002
|
-
},
|
|
1085
|
+
s.classList.remove("is-search");
|
|
1086
|
+
let x = u, A = [], R = 0;
|
|
1087
|
+
for (; x.length; ) {
|
|
1088
|
+
const P = a("div", "fc-cascade-column");
|
|
1089
|
+
P.setAttribute("role", "group"), P.ariaLabel = "第" + (R + 1) + "级";
|
|
1090
|
+
for (const q of x.filter((O) => !O.disabled)) {
|
|
1091
|
+
const O = [...A, q.id], F = !!((C = q.children) != null && C.length), $ = a("button", "fc-option", q.label + (F ? " ›" : ""));
|
|
1092
|
+
$.type = "button", $.disabled = e.readonly, $.classList.toggle("selected", F ? y[R] === q.id : f.some((Y) => b(Y, O))), $.setAttribute(F ? "aria-expanded" : "aria-pressed", String(F ? y[R] === q.id : f.some((Y) => b(Y, O)))), $.onclick = () => {
|
|
1093
|
+
var Y, l;
|
|
1094
|
+
F ? (y = O, N(), (l = (Y = s.lastElementChild) == null ? void 0 : Y.querySelector("button")) == null || l.focus()) : V(O);
|
|
1095
|
+
}, P.append($);
|
|
1003
1096
|
}
|
|
1004
|
-
|
|
1005
|
-
const
|
|
1006
|
-
if (!((j =
|
|
1007
|
-
|
|
1097
|
+
s.append(P);
|
|
1098
|
+
const B = x.find((q) => q.id === y[R] && !q.disabled);
|
|
1099
|
+
if (!((j = B == null ? void 0 : B.children) != null && j.length)) break;
|
|
1100
|
+
A = [...A, B.id], x = B.children, R++;
|
|
1008
1101
|
}
|
|
1009
|
-
|
|
1102
|
+
u.length || s.append(a("p", "fc-empty", "暂无可选分类"));
|
|
1010
1103
|
};
|
|
1011
|
-
if (
|
|
1104
|
+
if (o.oninput = () => {
|
|
1012
1105
|
r(), N();
|
|
1013
|
-
},
|
|
1014
|
-
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(
|
|
1015
|
-
const
|
|
1016
|
-
if (!
|
|
1017
|
-
|
|
1018
|
-
const j =
|
|
1019
|
-
|
|
1020
|
-
}, n.append(
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
} else n.append(
|
|
1106
|
+
}, o.onfocus = m, s.onkeydown = (x) => {
|
|
1107
|
+
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(x.key)) return;
|
|
1108
|
+
const A = x.target, C = [...(A.closest(".fc-cascade-column") || s).querySelectorAll("button:not(:disabled)")];
|
|
1109
|
+
if (!C.length) return;
|
|
1110
|
+
x.preventDefault();
|
|
1111
|
+
const j = C.indexOf(A);
|
|
1112
|
+
C[x.key === "Home" ? 0 : x.key === "End" ? C.length - 1 : (j + (x.key === "ArrowDown" ? 1 : -1) + C.length) % C.length].focus();
|
|
1113
|
+
}, n.append(i, o, c), h) {
|
|
1114
|
+
const x = a("span", "fc-field-chevron");
|
|
1115
|
+
x.setAttribute("aria-hidden", "true"), n.append(x), n.addEventListener("click", () => m());
|
|
1116
|
+
} else n.append(s);
|
|
1024
1117
|
return N(), {
|
|
1025
1118
|
element: n,
|
|
1026
|
-
content:
|
|
1027
|
-
read: () => t ?
|
|
1119
|
+
content: h ? s : void 0,
|
|
1120
|
+
read: () => t ? f.map((x) => [...x]) : [...f[0] || []],
|
|
1028
1121
|
focus: () => {
|
|
1029
|
-
|
|
1122
|
+
o.focus(), m();
|
|
1030
1123
|
},
|
|
1031
1124
|
deactivate: () => {
|
|
1032
|
-
|
|
1125
|
+
o.value = "", r(), M();
|
|
1033
1126
|
},
|
|
1034
|
-
destroy: () =>
|
|
1035
|
-
validate: () => e.field.required && !
|
|
1127
|
+
destroy: () => M(),
|
|
1128
|
+
validate: () => e.field.required && !f.length ? "请选择分类" : void 0
|
|
1036
1129
|
};
|
|
1037
1130
|
}
|
|
1038
|
-
const te = (t) => String(t).padStart(2, "0"),
|
|
1039
|
-
function
|
|
1131
|
+
const te = (t) => String(t).padStart(2, "0"), Le = (t) => `${t.getFullYear()}-${te(t.getMonth() + 1)}-${te(t.getDate())}`;
|
|
1132
|
+
function pe(t) {
|
|
1040
1133
|
if (!/^(\d{4})-(\d{2})-(\d{2})$/.exec(t)) return !1;
|
|
1041
1134
|
const n = /* @__PURE__ */ new Date(`${t}T12:00:00`);
|
|
1042
|
-
return !Number.isNaN(n.getTime()) &&
|
|
1135
|
+
return !Number.isNaN(n.getTime()) && Le(n) === t;
|
|
1043
1136
|
}
|
|
1044
|
-
const
|
|
1045
|
-
var e, n,
|
|
1137
|
+
const _e = (t) => {
|
|
1138
|
+
var e, n, i;
|
|
1046
1139
|
return {
|
|
1047
1140
|
time: ((e = t.field.dateOptions) == null ? void 0 : e.showTime) ?? t.field.kind !== "date",
|
|
1048
1141
|
range: ((n = t.field.dateOptions) == null ? void 0 : n.showRange) ?? !1,
|
|
1049
|
-
seconds: ((
|
|
1142
|
+
seconds: ((i = t.field.dateOptions) == null ? void 0 : i.showSeconds) ?? t.field.kind === "datetime"
|
|
1050
1143
|
};
|
|
1051
1144
|
};
|
|
1052
|
-
function
|
|
1053
|
-
const { time: e, range: n, seconds:
|
|
1145
|
+
function je(t) {
|
|
1146
|
+
const { time: e, range: n, seconds: i } = _e(t), r = (Array.isArray(t.value) ? t.value : [t.value]).slice(0, n ? 2 : 1).filter(Boolean).map((s) => e ? String(s).slice(0, i ? 19 : 16).replace("T", " ") : String(s).slice(0, 10)).join(" 至 ");
|
|
1054
1147
|
return a("div", `fc-value fc-${t.className || ""}${r ? "" : " fc-empty"}`, r || "待填");
|
|
1055
1148
|
}
|
|
1056
|
-
function
|
|
1057
|
-
const { time: e, range: n, seconds:
|
|
1058
|
-
let
|
|
1059
|
-
|
|
1060
|
-
const T = a("div", "fc-calendar-panel"),
|
|
1149
|
+
function ut(t) {
|
|
1150
|
+
const { time: e, range: n, seconds: i } = _e(t), o = a("div", "fc-calendar"), r = Array.isArray(t.value) ? t.value : [t.value], s = [0, 1].map((g) => String(r[g] || "").slice(0, 10)), c = [0, 1].map((g) => (String(r[g] || "").slice(11, 16) || "00:00") + (i ? ":" + (String(r[g] || "").slice(17, 19) || "00") : ""));
|
|
1151
|
+
let u = 0, f = !1, y = pe(s[0]) ? /* @__PURE__ */ new Date(`${s[0]}T12:00:00`) : /* @__PURE__ */ new Date();
|
|
1152
|
+
y = new Date(y.getFullYear(), y.getMonth(), 1);
|
|
1153
|
+
const T = a("div", "fc-calendar-panel"), p = a("div", "fc-calendar-inputs"), b = [], h = () => o.dispatchEvent(new Event("change", { bubbles: !0 })), E = a("div", "fc-error");
|
|
1061
1154
|
E.setAttribute("role", "status");
|
|
1062
|
-
const
|
|
1063
|
-
if (
|
|
1064
|
-
if (t.field.required && !
|
|
1065
|
-
if (n && !!
|
|
1066
|
-
if (e && c.slice(0, n ? 2 : 1).some((g) => !(
|
|
1067
|
-
if (n &&
|
|
1068
|
-
},
|
|
1069
|
-
E.textContent =
|
|
1155
|
+
const M = () => {
|
|
1156
|
+
if (s.some((g) => g && !pe(g))) return "请输入有效日期,格式为 YYYY-MM-DD";
|
|
1157
|
+
if (t.field.required && !s[0]) return "请选择日期";
|
|
1158
|
+
if (n && !!s[0] != !!s[1]) return "请选择完整的日期范围";
|
|
1159
|
+
if (e && c.slice(0, n ? 2 : 1).some((g) => !(i ? /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/ : /^([01]\d|2[0-3]):[0-5]\d$/).test(g))) return "请输入有效时间";
|
|
1160
|
+
if (n && s[0] && `${s[0]}T${e ? c[0] : ""}` > `${s[1]}T${e ? c[1] : ""}`) return "结束日期时间不能早于开始日期时间";
|
|
1161
|
+
}, m = () => {
|
|
1162
|
+
E.textContent = M() || "", E.textContent || h();
|
|
1070
1163
|
};
|
|
1071
1164
|
for (let g = 0; g < (n ? 2 : 1); g++) {
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
if (
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1165
|
+
const D = a("input", "fc-input fc-calendar-date");
|
|
1166
|
+
D.type = "text", D.value = s[g], D.placeholder = n ? g ? "结束日期" : "开始日期" : "YYYY-MM-DD", D.ariaLabel = n ? D.placeholder : t.field.label, D.disabled = t.readonly, D.onfocus = () => {
|
|
1167
|
+
if (u = g, f = g === 1, pe(s[g])) {
|
|
1168
|
+
const S = /* @__PURE__ */ new Date(`${s[g]}T12:00:00`);
|
|
1169
|
+
y = new Date(S.getFullYear(), S.getMonth(), 1);
|
|
1077
1170
|
}
|
|
1078
1171
|
w();
|
|
1079
|
-
},
|
|
1080
|
-
if (
|
|
1081
|
-
const
|
|
1082
|
-
|
|
1172
|
+
}, D.addEventListener("change", (S) => {
|
|
1173
|
+
if (S.stopPropagation(), s[g] = D.value.trim(), pe(s[g])) {
|
|
1174
|
+
const H = /* @__PURE__ */ new Date(`${s[g]}T12:00:00`);
|
|
1175
|
+
y = new Date(H.getFullYear(), H.getMonth(), 1);
|
|
1083
1176
|
}
|
|
1084
|
-
w(),
|
|
1085
|
-
}),
|
|
1086
|
-
}
|
|
1087
|
-
const L = a("div", "fc-calendar-header"),
|
|
1088
|
-
|
|
1089
|
-
const N = (g,
|
|
1090
|
-
const
|
|
1091
|
-
return
|
|
1092
|
-
|
|
1093
|
-
},
|
|
1177
|
+
w(), m();
|
|
1178
|
+
}), p.append(D), b.push(D);
|
|
1179
|
+
}
|
|
1180
|
+
const L = a("div", "fc-calendar-header"), V = a("button", "fc-calendar-month");
|
|
1181
|
+
V.type = "button", V.ariaLabel = "选择年份和月份", V.setAttribute("aria-expanded", "false"), V.setAttribute("aria-live", "polite");
|
|
1182
|
+
const N = (g, D, S) => {
|
|
1183
|
+
const H = a("button", "fc-calendar-nav");
|
|
1184
|
+
return H.type = "button", H.ariaLabel = g, H.innerHTML = `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${S ? "M10 6l-6 6 6 6M19 6l-6 6 6 6" : "M15 6l-6 6 6 6"}"/></svg>`, D > 0 && H.classList.add("next"), H.onclick = () => {
|
|
1185
|
+
y = new Date(y.getFullYear(), y.getMonth() + D, 1), w();
|
|
1186
|
+
}, H;
|
|
1094
1187
|
};
|
|
1095
|
-
L.append(N("上一年", -12, !0), N("上个月", -1, !1),
|
|
1096
|
-
const
|
|
1097
|
-
for (const g of ["日", "一", "二", "三", "四", "五", "六"])
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
const
|
|
1103
|
-
|
|
1104
|
-
const j = a("div", "fc-calendar-period-columns"),
|
|
1105
|
-
|
|
1188
|
+
L.append(N("上一年", -12, !0), N("上个月", -1, !1), V, N("下个月", 1, !1), N("下一年", 12, !0));
|
|
1189
|
+
const x = a("div", "fc-calendar-weekdays");
|
|
1190
|
+
for (const g of ["日", "一", "二", "三", "四", "五", "六"]) x.append(a("span", "", g));
|
|
1191
|
+
const A = a("div", "fc-calendar-days");
|
|
1192
|
+
A.setAttribute("role", "group"), A.ariaLabel = "选择日期";
|
|
1193
|
+
const R = a("div", "fc-calendar-period");
|
|
1194
|
+
R.hidden = !0;
|
|
1195
|
+
const C = a("button", "fc-calendar-back", "‹ 返回选择日期");
|
|
1196
|
+
C.type = "button";
|
|
1197
|
+
const j = a("div", "fc-calendar-period-columns"), P = a("div", "fc-calendar-period-list");
|
|
1198
|
+
P.setAttribute("role", "group"), P.ariaLabel = "年份";
|
|
1199
|
+
const B = a("div", "fc-calendar-period-list");
|
|
1200
|
+
B.setAttribute("role", "group"), B.ariaLabel = "月份";
|
|
1106
1201
|
const q = a("div", "fc-calendar-period-list");
|
|
1107
|
-
q.
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
const oe = Number(X.dataset.value) === Z;
|
|
1116
|
-
X.classList.toggle("selected", oe), X.setAttribute("aria-pressed", String(oe)), X.textContent = `${H === "time" ? te(Number(X.dataset.value)) : X.dataset.value}${oe ? se : ""}`, oe && g && (R.scrollTop = Math.max(0, X.offsetTop - 108));
|
|
1202
|
+
q.ariaLabel = "秒", q.hidden = !0, j.append(P, B, q), R.append(C, j);
|
|
1203
|
+
let O = "period", F = 0;
|
|
1204
|
+
const $ = [], Y = (g = !1) => {
|
|
1205
|
+
const D = c[F].split(":").map(Number), S = O === "period" ? [[P, y.getFullYear(), "年"], [B, y.getMonth() + 1, "月"]] : [[P, D[0], "时"], [B, D[1], "分"], [q, D[2], "秒"]];
|
|
1206
|
+
for (const [H, Z, se] of S)
|
|
1207
|
+
for (const X of H.querySelectorAll("button")) {
|
|
1208
|
+
const re = Number(X.dataset.value) === Z;
|
|
1209
|
+
X.classList.toggle("selected", re), X.setAttribute("aria-pressed", String(re)), X.textContent = `${O === "time" ? te(Number(X.dataset.value)) : X.dataset.value}${re ? se : ""}`, re && g && (H.scrollTop = Math.max(0, X.offsetTop - 108));
|
|
1117
1210
|
}
|
|
1118
|
-
}, l = (g,
|
|
1119
|
-
const
|
|
1120
|
-
return
|
|
1121
|
-
if (
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1211
|
+
}, l = (g, D) => {
|
|
1212
|
+
const S = a("button", "fc-calendar-period-option", String(g));
|
|
1213
|
+
return S.type = "button", S.dataset.value = String(g), S.ariaLabel = `${O === "time" ? te(g) : g}${O === "time" ? D ? "时" : "分" : D ? "年" : "月"}`, S.disabled = O === "time" && t.readonly, S.onclick = () => {
|
|
1214
|
+
if (O === "time") {
|
|
1215
|
+
const H = c[F].split(":");
|
|
1216
|
+
H[D ? 0 : 1] = te(g), c[F] = H.join(":"), $[F].textContent = c[F], Y(), m();
|
|
1124
1217
|
return;
|
|
1125
1218
|
}
|
|
1126
|
-
|
|
1127
|
-
},
|
|
1128
|
-
}, d = (g,
|
|
1129
|
-
if (
|
|
1130
|
-
for (let
|
|
1131
|
-
for (let
|
|
1219
|
+
y.setFullYear(D ? g : y.getFullYear(), D ? y.getMonth() : g - 1, 1), Y(), w();
|
|
1220
|
+
}, S;
|
|
1221
|
+
}, d = (g, D = 0) => {
|
|
1222
|
+
if (O = g, F = D, P.replaceChildren(), B.replaceChildren(), q.replaceChildren(), q.hidden = g !== "time" || !i, P.ariaLabel = g === "period" ? "年份" : "小时", B.ariaLabel = g === "period" ? "月份" : "分钟", g === "period") {
|
|
1223
|
+
for (let S = Math.max(1, y.getFullYear() - 100); S <= Math.min(9999, y.getFullYear() + 100); S++) P.append(l(S, !0));
|
|
1224
|
+
for (let S = 1; S <= 12; S++) B.append(l(S, !1));
|
|
1132
1225
|
} else {
|
|
1133
|
-
for (let
|
|
1134
|
-
for (let
|
|
1135
|
-
if (
|
|
1136
|
-
const
|
|
1137
|
-
|
|
1138
|
-
const Z = c[
|
|
1139
|
-
Z[2] = te(
|
|
1140
|
-
},
|
|
1226
|
+
for (let S = 0; S < 24; S++) P.append(l(S, !0));
|
|
1227
|
+
for (let S = 0; S < 60; S++) B.append(l(S, !1));
|
|
1228
|
+
if (i) for (let S = 0; S < 60; S++) {
|
|
1229
|
+
const H = a("button", "fc-calendar-period-option", te(S));
|
|
1230
|
+
H.type = "button", H.dataset.value = String(S), H.ariaLabel = te(S) + "秒", H.disabled = t.readonly, H.onclick = () => {
|
|
1231
|
+
const Z = c[F].split(":");
|
|
1232
|
+
Z[2] = te(S), c[F] = Z.join(":"), $[F].textContent = c[F], Y(), m();
|
|
1233
|
+
}, q.append(H);
|
|
1141
1234
|
}
|
|
1142
1235
|
}
|
|
1143
|
-
|
|
1236
|
+
o.classList.add("choosing-period"), R.hidden = !1, (g === "period" ? V : $[D]).setAttribute("aria-expanded", "true"), Y(!0), C.focus();
|
|
1144
1237
|
};
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
const g =
|
|
1238
|
+
V.onclick = () => d("period"), C.onclick = () => {
|
|
1239
|
+
o.classList.remove("choosing-period"), R.hidden = !0;
|
|
1240
|
+
const g = O === "period" ? V : $[F];
|
|
1148
1241
|
g.setAttribute("aria-expanded", "false"), w(), g.focus();
|
|
1149
|
-
},
|
|
1150
|
-
if (g.key === "Escape" && (g.preventDefault(), g.stopPropagation(),
|
|
1151
|
-
const
|
|
1152
|
-
if (!
|
|
1153
|
-
const
|
|
1154
|
-
g.preventDefault(),
|
|
1242
|
+
}, R.addEventListener("keydown", (g) => {
|
|
1243
|
+
if (g.key === "Escape" && (g.preventDefault(), g.stopPropagation(), C.click()), !["ArrowUp", "ArrowDown", "Home", "End"].includes(g.key)) return;
|
|
1244
|
+
const D = g.target, S = D.closest(".fc-calendar-period-list");
|
|
1245
|
+
if (!S) return;
|
|
1246
|
+
const H = [...S.querySelectorAll("button")], Z = H.indexOf(D), se = g.key === "Home" ? 0 : g.key === "End" ? H.length - 1 : Math.max(0, Math.min(H.length - 1, Z + (g.key === "ArrowDown" ? 1 : -1)));
|
|
1247
|
+
g.preventDefault(), H[se].focus();
|
|
1155
1248
|
});
|
|
1156
1249
|
function w() {
|
|
1157
|
-
|
|
1158
|
-
for (let
|
|
1159
|
-
const g = new Date(
|
|
1160
|
-
for (let
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1163
|
-
const Z =
|
|
1164
|
-
|
|
1250
|
+
V.textContent = `${y.getFullYear()}年 ${y.getMonth() + 1}月`, b.forEach((D, S) => D.classList.toggle("active", S === u)), A.replaceChildren();
|
|
1251
|
+
for (let D = 0; D < y.getDay(); D++) A.append(a("span", "fc-calendar-blank"));
|
|
1252
|
+
const g = new Date(y.getFullYear(), y.getMonth() + 1, 0).getDate();
|
|
1253
|
+
for (let D = 1; D <= g; D++) {
|
|
1254
|
+
const S = Le(new Date(y.getFullYear(), y.getMonth(), D)), H = a("button", "fc-calendar-day", String(D));
|
|
1255
|
+
H.type = "button", H.ariaLabel = S, H.disabled = t.readonly;
|
|
1256
|
+
const Z = s[0] === S || n && s[1] === S;
|
|
1257
|
+
H.classList.toggle("selected", Z), H.setAttribute("aria-pressed", String(Z)), H.classList.toggle("in-range", n && !!s[0] && !!s[1] && S > s[0] && S < s[1]), S === Le(/* @__PURE__ */ new Date()) && (H.classList.add("today"), H.setAttribute("aria-current", "date")), H.onclick = () => {
|
|
1165
1258
|
var se;
|
|
1166
|
-
n ?
|
|
1167
|
-
},
|
|
1259
|
+
n ? f ? (s[1] = S, s[0] && s[1] < s[0] && ([s[0], s[1]] = [s[1], s[0]]), u = 0, f = !1) : (s[0] = S, s[1] = "", u = 1, f = !0) : s[0] = S, b.forEach((X, re) => X.value = s[re]), w(), !n || s[1] ? m() : E.textContent = "", (se = A.querySelector(`[aria-label="${S}"]`)) == null || se.focus(), (!n || s[1]) && o.dispatchEvent(new Event("fc-collapse", { bubbles: !0 }));
|
|
1260
|
+
}, A.append(H);
|
|
1168
1261
|
}
|
|
1169
1262
|
}
|
|
1170
|
-
T.append(L,
|
|
1263
|
+
T.append(L, x, A, R);
|
|
1171
1264
|
const v = a("div", "fc-calendar-time");
|
|
1172
1265
|
if (e) {
|
|
1173
1266
|
for (let g = 0; g < (n ? 2 : 1); g++) {
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1267
|
+
const D = a("div", "fc-calendar-time-field"), S = n ? g ? "结束时间" : "开始时间" : "时间", H = a("button", "fc-input fc-calendar-time-trigger", c[g]);
|
|
1268
|
+
H.type = "button", H.disabled = t.readonly, H.ariaLabel = S, H.setAttribute("aria-expanded", "false"), H.onclick = () => d("time", g), $.push(H), D.append(a("span", "", S), H), v.append(D);
|
|
1176
1269
|
}
|
|
1177
1270
|
T.append(v);
|
|
1178
1271
|
}
|
|
1179
1272
|
const k = a("button", "fc-calendar-clear", "清空");
|
|
1180
1273
|
k.type = "button", k.disabled = t.readonly, k.onclick = () => {
|
|
1181
|
-
|
|
1182
|
-
},
|
|
1274
|
+
s.fill(""), b.forEach((g) => g.value = ""), u = 0, f = !1, w(), m();
|
|
1275
|
+
}, o.append(p, T, k, E);
|
|
1183
1276
|
const I = () => {
|
|
1184
|
-
const g =
|
|
1277
|
+
const g = s.slice(0, n ? 2 : 1).map((D, S) => D ? D + (e ? `T${c[S]}` : "") : "");
|
|
1185
1278
|
return n ? g.some(Boolean) ? g : [] : g[0];
|
|
1186
1279
|
};
|
|
1187
1280
|
if (t.layout === "compact" || t.readonly)
|
|
1188
1281
|
return w(), {
|
|
1189
|
-
element:
|
|
1282
|
+
element: o,
|
|
1190
1283
|
read: I,
|
|
1191
|
-
validate:
|
|
1284
|
+
validate: M,
|
|
1192
1285
|
focus: () => {
|
|
1193
|
-
|
|
1286
|
+
b[0].focus();
|
|
1194
1287
|
},
|
|
1195
1288
|
deactivate: () => {
|
|
1196
|
-
|
|
1289
|
+
o.classList.remove("choosing-period"), R.hidden = !0;
|
|
1197
1290
|
}
|
|
1198
1291
|
};
|
|
1199
|
-
const W = a("div", "fc-date-mirror"),
|
|
1292
|
+
const W = a("div", "fc-date-mirror"), U = () => W.replaceChildren(je({ ...t, value: I() })), G = a("span", "fc-field-chevron");
|
|
1200
1293
|
G.setAttribute("aria-hidden", "true");
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1294
|
+
const z = a("div", "fc-date-trigger");
|
|
1295
|
+
z.tabIndex = 0, z.setAttribute("role", "button"), z.ariaLabel = `编辑${t.field.label}`, z.append(W, G);
|
|
1203
1296
|
let J;
|
|
1204
1297
|
const ee = () => {
|
|
1205
1298
|
const g = J;
|
|
1206
1299
|
J = void 0;
|
|
1207
|
-
const
|
|
1208
|
-
g == null || g.close(), G.classList.remove("is-open"),
|
|
1209
|
-
J || !
|
|
1300
|
+
const D = !!g && g.element.contains(document.activeElement);
|
|
1301
|
+
g == null || g.close(), G.classList.remove("is-open"), D && queueMicrotask(() => {
|
|
1302
|
+
J || !z.isConnected || z.dispatchEvent(new Event("fc-collapse", { bubbles: !0 }));
|
|
1210
1303
|
});
|
|
1211
1304
|
}, ge = () => {
|
|
1212
|
-
J || t.readonly || (
|
|
1305
|
+
J || t.readonly || (U(), J = ce({ anchor: z, content: o, width: 320, gap: 4, onDismiss: () => {
|
|
1213
1306
|
J = void 0, G.classList.remove("is-open");
|
|
1214
1307
|
} }), G.classList.add("is-open"));
|
|
1215
1308
|
};
|
|
1216
|
-
return
|
|
1309
|
+
return z.onclick = () => ge(), z.onkeydown = (g) => {
|
|
1217
1310
|
(g.key === "Enter" || g.key === " ") && (g.preventDefault(), ge());
|
|
1218
|
-
},
|
|
1219
|
-
const
|
|
1220
|
-
if (
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
}),
|
|
1224
|
-
element:
|
|
1225
|
-
content:
|
|
1226
|
-
inputRoot:
|
|
1311
|
+
}, o.addEventListener("focusout", (g) => {
|
|
1312
|
+
const D = g.relatedTarget;
|
|
1313
|
+
if (D && (o.contains(D) || z.contains(D) || be(D))) return;
|
|
1314
|
+
const S = new Event("focusout", { bubbles: !0 });
|
|
1315
|
+
D && Object.defineProperty(S, "relatedTarget", { value: D }), z.dispatchEvent(S);
|
|
1316
|
+
}), o.addEventListener("change", () => z.dispatchEvent(new Event("change", { bubbles: !0 }))), w(), U(), {
|
|
1317
|
+
element: z,
|
|
1318
|
+
content: o,
|
|
1319
|
+
inputRoot: z,
|
|
1227
1320
|
read: I,
|
|
1228
|
-
validate:
|
|
1321
|
+
validate: M,
|
|
1229
1322
|
focus: () => {
|
|
1230
|
-
ge(),
|
|
1323
|
+
ge(), b[0].focus();
|
|
1231
1324
|
},
|
|
1232
1325
|
deactivate: ee,
|
|
1233
1326
|
destroy: ee
|
|
1234
1327
|
};
|
|
1235
1328
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
try {
|
|
1239
|
-
const e = new URL(ie(t));
|
|
1240
|
-
return ["http:", "https:"].includes(e.protocol) ? e.href : void 0;
|
|
1241
|
-
} catch {
|
|
1242
|
-
return;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
function ce(t) {
|
|
1246
|
-
return a("div", "fc-value fc-plain fc-" + (t.className || "") + (t.value == null || t.value === "" ? " fc-empty" : ""), ie(t.value) || "待填");
|
|
1247
|
-
}
|
|
1248
|
-
function ve(t, e) {
|
|
1249
|
-
const n = e === "textarea" ? a("textarea", "fc-input fc-textarea") : a("input", "fc-input");
|
|
1250
|
-
return n instanceof HTMLInputElement && (n.type = e), n instanceof HTMLTextAreaElement && Re(n), n.value = ie(t.value), n.disabled = t.readonly, n.required = !!t.field.required, n.ariaLabel = t.field.label, n.placeholder = t.field.placeholder || "请输入" + t.field.label, t.field.maxLength !== void 0 && (n.maxLength = t.field.maxLength), {
|
|
1251
|
-
element: n,
|
|
1252
|
-
read: () => n.value,
|
|
1253
|
-
focus: () => n.focus(),
|
|
1254
|
-
validate: () => e === "url" && n.value && !Le(n.value) ? "请输入 http 或 https 链接" : n.checkValidity() ? void 0 : "请填写有效的" + t.field.label
|
|
1255
|
-
};
|
|
1256
|
-
}
|
|
1257
|
-
function rt(t) {
|
|
1258
|
-
const e = a("div", "fc-link-value"), n = Le(t.value);
|
|
1259
|
-
if (!n) return ce(t);
|
|
1260
|
-
const s = a("a", "fc-link", ie(t.value));
|
|
1261
|
-
return s.href = n, s.target = "_blank", s.rel = "noopener noreferrer", s.onclick = (i) => i.stopPropagation(), e.append(a("span", "fc-link-icon", "↗"), s), e;
|
|
1262
|
-
}
|
|
1263
|
-
function Be(t) {
|
|
1264
|
-
let e = t.value === !0;
|
|
1265
|
-
const n = a("div", "fc-switch-field"), s = a("button", "fc-switch");
|
|
1266
|
-
s.type = "button", s.setAttribute("role", "switch"), s.ariaLabel = t.field.label, s.disabled = t.readonly;
|
|
1267
|
-
const i = a("span"), r = () => {
|
|
1268
|
-
s.setAttribute("aria-checked", String(e)), i.textContent = e ? "是" : "否";
|
|
1269
|
-
};
|
|
1270
|
-
return s.onclick = () => {
|
|
1271
|
-
t.readonly || (e = !e, r(), ae(n));
|
|
1272
|
-
}, n.append(s, i), r(), { element: n, read: () => e, focus: () => s.focus() };
|
|
1273
|
-
}
|
|
1274
|
-
function at(t) {
|
|
1275
|
-
return Be({ ...t, readonly: !0 }).element;
|
|
1276
|
-
}
|
|
1277
|
-
function lt(t) {
|
|
1278
|
-
const e = a("div", "fc-signals"), n = Array.isArray(t.value) ? t.value : [t.value];
|
|
1279
|
-
for (const s of n.filter((i) => i != null && i !== "")) {
|
|
1280
|
-
const i = typeof s == "object" ? s : { status: s }, r = i.status ?? i.value, o = r === !0 || r === "passed" || r === "success", c = a("span", "fc-signal " + (o ? "is-success" : "is-pending"), (o ? "● " : "○ ") + ie(i.label || i.name || (o ? "已满足" : r === !1 ? "未满足" : r || "等待信号")));
|
|
1281
|
-
e.append(c);
|
|
1282
|
-
}
|
|
1283
|
-
return e.children.length || e.append(a("span", "fc-empty", "等待外部信号")), e;
|
|
1284
|
-
}
|
|
1285
|
-
function dt(t) {
|
|
1286
|
-
const e = t.value && typeof t.value == "object" ? t.value.display ?? t.value.value : t.value;
|
|
1287
|
-
return ce({ ...t, value: e != null && typeof e != "object" ? e : "" });
|
|
1288
|
-
}
|
|
1289
|
-
function ct(t, e) {
|
|
1290
|
-
const n = a("div", "fc-readonly");
|
|
1291
|
-
return n.append(e(t), a("small", "fc-service-note", "由系统更新 · 只读")), { element: n, read: () => t.value };
|
|
1292
|
-
}
|
|
1293
|
-
function Ce(t) {
|
|
1294
|
-
var p, E, D;
|
|
1329
|
+
function De(t) {
|
|
1330
|
+
var h, E, M;
|
|
1295
1331
|
let e = Array.isArray(t.value) ? structuredClone(t.value) : [];
|
|
1296
|
-
const n = a("div", "fc-attachments"),
|
|
1297
|
-
r.type = "file", r.multiple = !0, r.ariaLabel = "上传" + t.field.label, r.accept = ((
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1332
|
+
const n = a("div", "fc-attachments"), i = a("div", "fc-file-list"), o = a("label", "fc-upload-zone", "+ 上传附件"), r = a("input");
|
|
1333
|
+
r.type = "file", r.multiple = !0, r.ariaLabel = "上传" + t.field.label, r.accept = ((h = t.field.attachmentOptions) == null ? void 0 : h.accept) || "", r.disabled = t.readonly || !((E = t.services) != null && E.upload);
|
|
1334
|
+
const s = a("p", "fc-error");
|
|
1335
|
+
s.setAttribute("role", "status");
|
|
1300
1336
|
const c = a("button", "fc-retry", "重试上传");
|
|
1301
1337
|
c.type = "button", c.hidden = !0;
|
|
1302
|
-
let
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1305
|
-
const
|
|
1306
|
-
if (
|
|
1307
|
-
const
|
|
1308
|
-
|
|
1338
|
+
let u = [], f = !1, y = !1, T;
|
|
1339
|
+
const p = () => {
|
|
1340
|
+
i.replaceChildren(), e.forEach((m, L) => {
|
|
1341
|
+
const V = a("div", "fc-file-row"), N = Ae(m.url), x = N ? a("a", "fc-link", m.name) : a("span", "", m.name);
|
|
1342
|
+
if (x.tagName === "A") {
|
|
1343
|
+
const A = x;
|
|
1344
|
+
A.href = N, A.target = "_blank", A.rel = "noopener noreferrer";
|
|
1309
1345
|
}
|
|
1310
|
-
if (
|
|
1311
|
-
const
|
|
1312
|
-
|
|
1313
|
-
e.splice(L, 1),
|
|
1314
|
-
},
|
|
1346
|
+
if (V.append(a("span", "fc-file-icon", "▤"), x), m.size != null && V.append(a("small", "fc-file-size", Math.ceil(m.size / 1024) + " KB")), !t.readonly) {
|
|
1347
|
+
const A = a("button", "fc-file-remove", "×");
|
|
1348
|
+
A.type = "button", A.disabled = f, A.ariaLabel = "移除" + m.name, A.onclick = () => {
|
|
1349
|
+
e.splice(L, 1), p(), ie(n);
|
|
1350
|
+
}, V.append(A);
|
|
1315
1351
|
}
|
|
1316
|
-
|
|
1317
|
-
}), e.length ||
|
|
1318
|
-
},
|
|
1319
|
-
var
|
|
1320
|
-
if (!((
|
|
1321
|
-
const
|
|
1322
|
-
if (
|
|
1323
|
-
|
|
1352
|
+
i.append(V);
|
|
1353
|
+
}), e.length || i.append(a("span", "fc-empty", "暂无附件"));
|
|
1354
|
+
}, b = async () => {
|
|
1355
|
+
var V;
|
|
1356
|
+
if (!((V = t.services) != null && V.upload) || t.readonly || f || !u.length) return;
|
|
1357
|
+
const m = t.field.attachmentOptions;
|
|
1358
|
+
if (m != null && m.maxFiles && e.length + u.length > m.maxFiles) {
|
|
1359
|
+
s.textContent = "最多上传 " + m.maxFiles + " 个文件";
|
|
1324
1360
|
return;
|
|
1325
1361
|
}
|
|
1326
|
-
if (
|
|
1327
|
-
|
|
1362
|
+
if (m != null && m.maxBytes && u.some((N) => N.size > m.maxBytes)) {
|
|
1363
|
+
s.textContent = "文件大小超过限制";
|
|
1328
1364
|
return;
|
|
1329
1365
|
}
|
|
1330
|
-
const L = ((
|
|
1331
|
-
if (L.length &&
|
|
1332
|
-
|
|
1366
|
+
const L = ((m == null ? void 0 : m.accept) || "").split(",").map((N) => N.trim().toLowerCase()).filter(Boolean);
|
|
1367
|
+
if (L.length && u.some((N) => !L.some((x) => x.startsWith(".") ? N.name.toLowerCase().endsWith(x) : x.endsWith("/*") ? N.type.toLowerCase().startsWith(x.slice(0, -1)) : N.type.toLowerCase() === x))) {
|
|
1368
|
+
s.textContent = "文件类型不符合要求";
|
|
1333
1369
|
return;
|
|
1334
1370
|
}
|
|
1335
|
-
T = new AbortController(),
|
|
1371
|
+
T = new AbortController(), f = !0, r.disabled = !0, c.hidden = !0, s.textContent = "上传中…", n.setAttribute("aria-busy", "true"), p();
|
|
1336
1372
|
try {
|
|
1337
|
-
const N = await t.services.upload(t.field,
|
|
1338
|
-
if (
|
|
1339
|
-
if (N.length !==
|
|
1340
|
-
e = [...e, ...N],
|
|
1373
|
+
const N = await t.services.upload(t.field, u, T.signal);
|
|
1374
|
+
if (y) return;
|
|
1375
|
+
if (N.length !== u.length || N.some((x) => !x.id || !x.name)) throw new Error("Invalid file references");
|
|
1376
|
+
e = [...e, ...N], u = [], s.textContent = "", r.value = "";
|
|
1341
1377
|
} catch {
|
|
1342
|
-
|
|
1378
|
+
y || (s.textContent = "上传失败,已保留原有附件", c.hidden = !1);
|
|
1343
1379
|
} finally {
|
|
1344
|
-
|
|
1380
|
+
y || (f = !1, r.disabled = !1, n.setAttribute("aria-busy", "false"), p(), u.length || ie(n));
|
|
1345
1381
|
}
|
|
1346
1382
|
};
|
|
1347
|
-
return r.onchange = (
|
|
1348
|
-
|
|
1349
|
-
}, c.onclick = () => void
|
|
1383
|
+
return r.onchange = (m) => {
|
|
1384
|
+
m.stopPropagation(), u = Array.from(r.files || []), b();
|
|
1385
|
+
}, c.onclick = () => void b(), o.append(r), n.append(i), t.readonly || (n.append(o), (M = t.services) != null && M.upload || n.append(a("p", "fc-service-note", "上传服务未接入"))), n.append(s, c), p(), {
|
|
1350
1386
|
element: n,
|
|
1351
1387
|
read: () => structuredClone(e),
|
|
1352
1388
|
focus: () => r.focus(),
|
|
1353
|
-
validate: () =>
|
|
1389
|
+
validate: () => f ? "请等待上传完成" : u.length ? "请完成或重新选择上传文件" : t.field.required && !e.length ? "请上传附件" : void 0,
|
|
1354
1390
|
destroy: () => {
|
|
1355
|
-
|
|
1391
|
+
y = !0, T == null || T.abort();
|
|
1356
1392
|
}
|
|
1357
1393
|
};
|
|
1358
1394
|
}
|
|
1359
|
-
function
|
|
1395
|
+
function ke(t) {
|
|
1360
1396
|
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
1361
1397
|
const e = t;
|
|
1362
1398
|
return { selected: Array.isArray(e.selected) ? [...e.selected] : [], counts: { ...e.counts }, total: e.total };
|
|
1363
1399
|
}
|
|
1364
1400
|
return { selected: [], counts: {} };
|
|
1365
1401
|
}
|
|
1366
|
-
function
|
|
1367
|
-
var
|
|
1368
|
-
let n =
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1402
|
+
function Te(t, e) {
|
|
1403
|
+
var q, O;
|
|
1404
|
+
let n = ke(t.value), i = [...n.selected];
|
|
1405
|
+
const o = e === "attitude" ? [{ id: "like", label: "赞同" }] : Q(t.field), r = a("div", "fc-vote"), s = a("button", "fc-vote-trigger");
|
|
1406
|
+
s.type = "button", s.setAttribute("aria-haspopup", "dialog"), s.setAttribute("aria-expanded", "false");
|
|
1407
|
+
const c = a("span", "fc-vote-icon", "+");
|
|
1408
|
+
c.ariaHidden = "true";
|
|
1409
|
+
const u = a("span");
|
|
1410
|
+
s.append(c, u);
|
|
1411
|
+
const f = a("section", "fc-vote-panel");
|
|
1412
|
+
f.setAttribute("role", "dialog"), f.ariaLabel = t.field.label;
|
|
1413
|
+
const y = a("div", "fc-vote-header"), T = a("span", "fc-vote-total");
|
|
1414
|
+
y.append(a("strong", "", e === "attitude" ? "表态投票" : e === "multi" ? "投票-多选" : "投票-单选"), T);
|
|
1415
|
+
const p = a("div", "fc-vote-list");
|
|
1416
|
+
p.setAttribute("role", e === "multi" ? "group" : "radiogroup"), p.ariaLabel = t.field.label;
|
|
1417
|
+
const b = a("p", "fc-error");
|
|
1418
|
+
b.setAttribute("role", "status");
|
|
1419
|
+
const h = a("button", "fc-vote-submit", "确认投票");
|
|
1420
|
+
h.type = "button";
|
|
1421
|
+
const E = a("button", "fc-vote-withdraw", "撤回投票");
|
|
1422
|
+
E.type = "button";
|
|
1423
|
+
const M = a("button", "fc-vote-withdraw", "重新加载");
|
|
1424
|
+
M.type = "button", M.hidden = !0;
|
|
1425
|
+
const m = a("div", "fc-vote-actions");
|
|
1426
|
+
m.append(h, E);
|
|
1427
|
+
let L = !1, V = !1, N = !1, x = !((q = t.services) != null && q.loadVote), A, R;
|
|
1428
|
+
const C = () => {
|
|
1429
|
+
var F, $, Y;
|
|
1430
|
+
u.textContent = n.selected.length ? "已投票" : "投票", s.classList.toggle("is-voted", !!n.selected.length), s.ariaLabel = `${t.field.label},${u.textContent}`, T.textContent = V ? "加载中…" : x ? `${n.total ?? Object.values(n.counts).reduce((l, d) => l + d, 0)}人已投` : "待加载", f.setAttribute("aria-busy", String(L || V)), p.replaceChildren();
|
|
1431
|
+
for (const l of o) {
|
|
1432
|
+
const d = a("button", "fc-vote-option");
|
|
1433
|
+
d.type = "button", d.dataset.value = l.id, d.disabled = t.readonly || L || V || !x || !((F = t.services) != null && F.vote) || !!l.disabled;
|
|
1434
|
+
const w = i.includes(l.id);
|
|
1435
|
+
d.classList.toggle("selected", w), d.setAttribute("role", e === "multi" ? "checkbox" : "radio"), d.setAttribute("aria-checked", String(w));
|
|
1436
|
+
const v = a("span", e === "multi" ? "fc-vote-check" : "fc-radio-dot");
|
|
1437
|
+
v.ariaHidden = "true", d.append(v, a("span", "fc-vote-label", l.label)), x && Object.keys(n.counts).length && d.append(a("span", "fc-vote-count", `${n.counts[l.id] ?? 0} 票`)), d.onclick = () => {
|
|
1438
|
+
var k;
|
|
1439
|
+
d.disabled || (i = e === "multi" ? w ? i.filter((I) => I !== l.id) : [...i, l.id] : [l.id], C(), (k = p.querySelector(`[data-index="${o.indexOf(l)}"]`)) == null || k.focus());
|
|
1440
|
+
}, d.dataset.index = String(o.indexOf(l)), p.append(d);
|
|
1385
1441
|
}
|
|
1386
|
-
|
|
1442
|
+
o.length || p.append(a("p", "fc-empty", "暂无投票选项")), h.disabled = L || V || !x || !(($ = t.services) != null && $.vote) || !i.length, h.textContent = L ? "提交中…" : n.selected.length ? "确认改票" : "确认投票", E.hidden = !n.selected.length, E.disabled = L || V || !x, m.hidden = t.readonly || !((Y = t.services) != null && Y.vote), R == null || R.reposition();
|
|
1443
|
+
};
|
|
1444
|
+
p.onkeydown = (F) => {
|
|
1445
|
+
if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End"].includes(F.key)) return;
|
|
1446
|
+
const $ = [...p.querySelectorAll("button:not(:disabled)")];
|
|
1447
|
+
if (!$.length) return;
|
|
1448
|
+
F.preventDefault(), F.stopPropagation();
|
|
1449
|
+
const Y = $.indexOf(document.activeElement), l = F.key === "Home" ? 0 : F.key === "End" ? $.length - 1 : (Y + (["ArrowUp", "ArrowLeft"].includes(F.key) ? -1 : 1) + $.length) % $.length;
|
|
1450
|
+
$[l].focus(), e !== "multi" && $[l].click();
|
|
1387
1451
|
};
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1452
|
+
const j = () => {
|
|
1453
|
+
R == null || R.close(), R = void 0;
|
|
1454
|
+
}, P = async () => {
|
|
1455
|
+
var F;
|
|
1456
|
+
if (!(!((F = t.services) != null && F.loadVote) || V || L)) {
|
|
1457
|
+
V = !0, b.textContent = "", M.hidden = !0, A = new AbortController(), C();
|
|
1458
|
+
try {
|
|
1459
|
+
const $ = await t.services.loadVote(t.field, A.signal);
|
|
1460
|
+
if (N || A.signal.aborted) return;
|
|
1461
|
+
n = ke($), i = [...n.selected], x = !0;
|
|
1462
|
+
} catch {
|
|
1463
|
+
N || (x = !1, b.textContent = "加载失败,请重试", M.hidden = !1);
|
|
1464
|
+
} finally {
|
|
1465
|
+
N || (V = !1, C());
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}, B = async (F) => {
|
|
1469
|
+
var $;
|
|
1470
|
+
if (!(L || V || !x || t.readonly || !(($ = t.services) != null && $.vote))) {
|
|
1471
|
+
L = !0, b.textContent = "", A = new AbortController(), C();
|
|
1392
1472
|
try {
|
|
1393
|
-
const
|
|
1394
|
-
if (
|
|
1395
|
-
n =
|
|
1473
|
+
const Y = await t.services.vote(t.field, [...F], A.signal);
|
|
1474
|
+
if (N || A.signal.aborted) return;
|
|
1475
|
+
n = ke(Y), i = [...n.selected], L = !1, ie(r), j(), s.focus();
|
|
1396
1476
|
} catch {
|
|
1397
|
-
|
|
1477
|
+
N || (b.textContent = "投票失败,请重试");
|
|
1398
1478
|
} finally {
|
|
1399
|
-
|
|
1479
|
+
N || (L = !1, C());
|
|
1400
1480
|
}
|
|
1401
1481
|
}
|
|
1402
|
-
}
|
|
1482
|
+
};
|
|
1483
|
+
return s.onclick = (F) => {
|
|
1484
|
+
if (F.stopPropagation(), R) {
|
|
1485
|
+
j();
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
i = [...n.selected], b.textContent = "", C(), R = ce({
|
|
1489
|
+
anchor: s,
|
|
1490
|
+
anchorMode: "element",
|
|
1491
|
+
content: f,
|
|
1492
|
+
width: 360,
|
|
1493
|
+
onDismiss: () => {
|
|
1494
|
+
R = void 0, s.setAttribute("aria-expanded", "false"), L || (i = [...n.selected]);
|
|
1495
|
+
},
|
|
1496
|
+
onEscape: () => s.focus()
|
|
1497
|
+
}), s.setAttribute("aria-expanded", "true"), f.tabIndex = -1, f.focus(), P();
|
|
1498
|
+
}, h.onclick = () => {
|
|
1499
|
+
i.length && B(i);
|
|
1500
|
+
}, E.onclick = () => void B([]), M.onclick = () => void P(), f.append(y, p, b, M, m), !t.readonly && !((O = t.services) != null && O.vote) && f.append(a("p", "fc-service-note", "创建工作项后可投票")), r.append(s), C(), {
|
|
1403
1501
|
element: r,
|
|
1502
|
+
content: f,
|
|
1404
1503
|
read: () => structuredClone(n),
|
|
1405
|
-
|
|
1504
|
+
focus: () => s.focus(),
|
|
1505
|
+
validate: () => L ? "请等待投票完成" : void 0,
|
|
1506
|
+
deactivate: j,
|
|
1406
1507
|
destroy: () => {
|
|
1407
|
-
|
|
1508
|
+
N = !0, A == null || A.abort(), j();
|
|
1408
1509
|
}
|
|
1409
1510
|
};
|
|
1410
1511
|
}
|
|
1411
|
-
function
|
|
1412
|
-
const e = t.value && typeof t.value == "object" ? t.value : {}, n = a("div", "fc-location"),
|
|
1413
|
-
const
|
|
1414
|
-
return
|
|
1415
|
-
}), r = () =>
|
|
1416
|
-
return { element: n, read: r, focus: () =>
|
|
1512
|
+
function ft(t) {
|
|
1513
|
+
const e = t.value && typeof t.value == "object" ? t.value : {}, n = a("div", "fc-location"), o = [["address", "地址", "text"], ["longitude", "经度", "number"], ["latitude", "纬度", "number"]].map(([s, c, u]) => {
|
|
1514
|
+
const f = a("label", "fc-location-part", c), y = a("input", "fc-input");
|
|
1515
|
+
return y.type = u, y.value = oe(e[s]), y.disabled = t.readonly, y.ariaLabel = c, y.placeholder = c, u === "number" && (y.step = "any", y.min = s === "longitude" ? "-180" : "-90", y.max = s === "longitude" ? "180" : "90"), f.append(y), n.append(f), y;
|
|
1516
|
+
}), r = () => o.every((s) => !s.value) ? null : { address: o[0].value, longitude: o[1].value ? Number(o[1].value) : null, latitude: o[2].value ? Number(o[2].value) : null };
|
|
1517
|
+
return { element: n, read: r, focus: () => o[0].focus(), validate: () => {
|
|
1417
1518
|
if (!r()) return t.field.required ? "请填写位置" : void 0;
|
|
1418
|
-
if (
|
|
1519
|
+
if (o.slice(1).some((s) => s.value === "" || !s.checkValidity())) return "请填写有效的经纬度";
|
|
1419
1520
|
} };
|
|
1420
1521
|
}
|
|
1421
|
-
function
|
|
1522
|
+
function pt(t) {
|
|
1422
1523
|
const e = t.value;
|
|
1423
|
-
return
|
|
1524
|
+
return ue({ ...t, value: e && typeof e == "object" ? oe(e.address) || [e.longitude, e.latitude].filter((n) => n != null).join(", ") : "" });
|
|
1424
1525
|
}
|
|
1425
|
-
function
|
|
1426
|
-
const n = a("div", "fc-composite"),
|
|
1427
|
-
|
|
1428
|
-
const r = t.field.compositeFields || [],
|
|
1526
|
+
function ht(t, e) {
|
|
1527
|
+
const n = a("div", "fc-composite"), i = a("div", "fc-composite-rows"), o = a("button", "fc-composite-add", "+ 添加一组");
|
|
1528
|
+
o.type = "button";
|
|
1529
|
+
const r = t.field.compositeFields || [], s = [];
|
|
1429
1530
|
let c = !1;
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1531
|
+
const u = (b) => ({ ...b.value, ...Object.fromEntries(b.editors.map(({ field: h, editor: E }) => [h.key, E.read()])) }), f = (b) => {
|
|
1532
|
+
b.editors.forEach(({ editor: h }) => {
|
|
1432
1533
|
var E;
|
|
1433
|
-
return (E =
|
|
1434
|
-
}),
|
|
1435
|
-
},
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
}),
|
|
1439
|
-
},
|
|
1440
|
-
const
|
|
1441
|
-
|
|
1442
|
-
const
|
|
1443
|
-
const
|
|
1534
|
+
return (E = h.destroy) == null ? void 0 : E.call(h);
|
|
1535
|
+
}), b.remove && (b.remove.onclick = null), b.element.remove();
|
|
1536
|
+
}, y = a("p", "fc-empty", "暂无记录"), T = () => {
|
|
1537
|
+
s.forEach((b, h) => {
|
|
1538
|
+
b.legend.textContent = "第 " + (h + 1) + " 组";
|
|
1539
|
+
}), o.disabled = t.readonly || !r.length || s.length >= (t.field.maxRows || 100), s.length ? y.remove() : i.append(y);
|
|
1540
|
+
}, p = (b) => {
|
|
1541
|
+
const h = a("fieldset", "fc-composite-row"), E = a("legend");
|
|
1542
|
+
h.append(E);
|
|
1543
|
+
const M = r.map((L) => {
|
|
1544
|
+
const V = e(L), N = V.createEditor({
|
|
1444
1545
|
...t,
|
|
1445
1546
|
field: L,
|
|
1446
|
-
value:
|
|
1447
|
-
readonly: t.readonly || L.editable === !1 || !!
|
|
1547
|
+
value: b[L.key],
|
|
1548
|
+
readonly: t.readonly || L.editable === !1 || !!V.readonly,
|
|
1448
1549
|
focusBoundary: void 0,
|
|
1449
|
-
onSelectedOptions: (
|
|
1450
|
-
var
|
|
1451
|
-
(
|
|
1550
|
+
onSelectedOptions: (A) => {
|
|
1551
|
+
var R;
|
|
1552
|
+
(R = t.services) != null && R.searchOptions && (L.choices = [...new Map([...Q(L), ...A].map((C) => [C.id, C])).values()]);
|
|
1452
1553
|
}
|
|
1453
|
-
}),
|
|
1454
|
-
return
|
|
1455
|
-
}),
|
|
1554
|
+
}), x = a("div", "fc-composite-field");
|
|
1555
|
+
return x.append(a("label", "", L.label + (L.required ? " *" : "")), N.element), h.append(x), { field: L, editor: N };
|
|
1556
|
+
}), m = { value: b, element: h, legend: E, editors: M };
|
|
1456
1557
|
if (!t.readonly) {
|
|
1457
1558
|
const L = a("button", "fc-composite-remove", "删除此组");
|
|
1458
1559
|
L.type = "button", L.onclick = () => {
|
|
1459
1560
|
if (c) return;
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
},
|
|
1561
|
+
const V = s.indexOf(m);
|
|
1562
|
+
V < 0 || (f(m), s.splice(V, 1), T(), ie(n));
|
|
1563
|
+
}, m.remove = L, h.append(L);
|
|
1463
1564
|
}
|
|
1464
|
-
|
|
1565
|
+
s.push(m), i.append(h), T();
|
|
1465
1566
|
};
|
|
1466
|
-
for (const
|
|
1467
|
-
return
|
|
1468
|
-
c ||
|
|
1469
|
-
}, n.append(
|
|
1567
|
+
for (const b of Array.isArray(t.value) ? t.value : []) p(structuredClone(b));
|
|
1568
|
+
return o.onclick = () => {
|
|
1569
|
+
c || o.disabled || (p({}), ie(n));
|
|
1570
|
+
}, n.append(i), t.readonly || n.append(o), r.length || n.append(a("p", "fc-service-note", "请配置复合子字段")), T(), {
|
|
1470
1571
|
element: n,
|
|
1471
|
-
read: () =>
|
|
1572
|
+
read: () => s.map(u),
|
|
1472
1573
|
validate: () => {
|
|
1473
|
-
var
|
|
1474
|
-
if (t.field.required && !
|
|
1475
|
-
for (const [
|
|
1476
|
-
const L = (
|
|
1477
|
-
if (L) return "第 " + (
|
|
1574
|
+
var b;
|
|
1575
|
+
if (t.field.required && !s.length) return "请至少添加一组";
|
|
1576
|
+
for (const [h, E] of s.entries()) for (const { field: M, editor: m } of E.editors) {
|
|
1577
|
+
const L = (b = m.validate) == null ? void 0 : b.call(m);
|
|
1578
|
+
if (L) return "第 " + (h + 1) + " 组 · " + M.label + ":" + L;
|
|
1478
1579
|
}
|
|
1479
1580
|
},
|
|
1480
1581
|
destroy: () => {
|
|
1481
|
-
c || (c = !0,
|
|
1582
|
+
c || (c = !0, o.onclick = null, s.forEach(f));
|
|
1482
1583
|
}
|
|
1483
1584
|
};
|
|
1484
1585
|
}
|
|
1485
1586
|
class ne extends K {
|
|
1486
1587
|
renderDisplay(e) {
|
|
1487
|
-
return { element:
|
|
1588
|
+
return { element: it(e) };
|
|
1488
1589
|
}
|
|
1489
1590
|
renderEditing(e) {
|
|
1490
|
-
return
|
|
1591
|
+
return Pe("text", e);
|
|
1491
1592
|
}
|
|
1492
1593
|
}
|
|
1493
|
-
class
|
|
1594
|
+
class mt extends ne {
|
|
1494
1595
|
renderDisplay(e) {
|
|
1495
1596
|
return super.renderDisplay({ ...e, field: { ...e.field, kind: "number" } });
|
|
1496
1597
|
}
|
|
1497
1598
|
renderEditing(e) {
|
|
1498
|
-
return
|
|
1599
|
+
return Pe("number", e);
|
|
1499
1600
|
}
|
|
1500
1601
|
}
|
|
1501
|
-
class
|
|
1602
|
+
class bt extends ne {
|
|
1502
1603
|
renderDisplay(e) {
|
|
1503
1604
|
return super.renderDisplay({ ...e, field: { ...e.field, control: "richText" } });
|
|
1504
1605
|
}
|
|
1505
1606
|
renderEditing(e) {
|
|
1506
|
-
return
|
|
1607
|
+
return nt(e);
|
|
1507
1608
|
}
|
|
1508
1609
|
}
|
|
1509
|
-
class
|
|
1610
|
+
class vt extends ne {
|
|
1510
1611
|
renderDisplay(e) {
|
|
1511
|
-
return { element:
|
|
1612
|
+
return { element: ue(e) };
|
|
1512
1613
|
}
|
|
1513
1614
|
renderEditing(e) {
|
|
1514
1615
|
return ve(e, "textarea");
|
|
1515
1616
|
}
|
|
1516
1617
|
}
|
|
1517
|
-
class
|
|
1618
|
+
class Ne extends ne {
|
|
1518
1619
|
renderDisplay(e) {
|
|
1519
|
-
return { element:
|
|
1620
|
+
return { element: ot(e) };
|
|
1520
1621
|
}
|
|
1521
1622
|
renderEditing(e) {
|
|
1522
1623
|
return ve(e, "url");
|
|
1523
1624
|
}
|
|
1524
1625
|
}
|
|
1525
|
-
class
|
|
1626
|
+
class gt extends ne {
|
|
1526
1627
|
renderEditing(e) {
|
|
1527
1628
|
return ve(e, "email");
|
|
1528
1629
|
}
|
|
1529
1630
|
}
|
|
1530
|
-
class
|
|
1631
|
+
class yt extends ne {
|
|
1531
1632
|
renderEditing(e) {
|
|
1532
1633
|
return ve(e, "tel");
|
|
1533
1634
|
}
|
|
1534
1635
|
}
|
|
1535
|
-
class
|
|
1636
|
+
class fe extends K {
|
|
1536
1637
|
constructor() {
|
|
1537
1638
|
super(...arguments);
|
|
1538
|
-
|
|
1539
|
-
|
|
1639
|
+
_(this, "multiple", !1);
|
|
1640
|
+
_(this, "variant", "choice");
|
|
1540
1641
|
}
|
|
1541
1642
|
renderDisplay(n) {
|
|
1542
|
-
return { element:
|
|
1643
|
+
return { element: Ie(n, this.variant === "radio" ? "choice" : this.variant) };
|
|
1543
1644
|
}
|
|
1544
1645
|
renderEditing(n) {
|
|
1545
|
-
return
|
|
1646
|
+
return xe(this.multiple, n, this.variant);
|
|
1546
1647
|
}
|
|
1547
1648
|
}
|
|
1548
|
-
class
|
|
1649
|
+
class wt extends fe {
|
|
1549
1650
|
constructor() {
|
|
1550
1651
|
super(...arguments);
|
|
1551
|
-
|
|
1652
|
+
_(this, "multiple", !0);
|
|
1552
1653
|
}
|
|
1553
1654
|
}
|
|
1554
|
-
class
|
|
1655
|
+
class kt extends fe {
|
|
1555
1656
|
constructor() {
|
|
1556
1657
|
super(...arguments);
|
|
1557
|
-
|
|
1658
|
+
_(this, "variant", "radio");
|
|
1659
|
+
}
|
|
1660
|
+
renderDisplay(n) {
|
|
1661
|
+
return n.layout === "compact" ? { element: Ie(n) } : Me({ ...n, readonly: !0 });
|
|
1662
|
+
}
|
|
1663
|
+
renderEditing(n) {
|
|
1664
|
+
if (n.layout !== "compact") return Me(n);
|
|
1665
|
+
const i = xe(!1, n, "choice");
|
|
1666
|
+
return n.field.radioValueType !== "boolean" ? i : { ...i, read: () => {
|
|
1667
|
+
const o = i.read();
|
|
1668
|
+
return o === "" ? null : o === "true";
|
|
1669
|
+
} };
|
|
1558
1670
|
}
|
|
1559
1671
|
}
|
|
1560
|
-
class
|
|
1672
|
+
class ze extends fe {
|
|
1561
1673
|
constructor() {
|
|
1562
1674
|
super(...arguments);
|
|
1563
|
-
|
|
1675
|
+
_(this, "variant", "person");
|
|
1564
1676
|
}
|
|
1565
1677
|
}
|
|
1566
|
-
class
|
|
1678
|
+
class Et extends ze {
|
|
1567
1679
|
constructor() {
|
|
1568
1680
|
super(...arguments);
|
|
1569
|
-
|
|
1681
|
+
_(this, "multiple", !0);
|
|
1570
1682
|
}
|
|
1571
1683
|
}
|
|
1572
|
-
class
|
|
1684
|
+
class Ye extends fe {
|
|
1573
1685
|
constructor() {
|
|
1574
1686
|
super(...arguments);
|
|
1575
|
-
|
|
1687
|
+
_(this, "variant", "relation");
|
|
1576
1688
|
}
|
|
1577
1689
|
}
|
|
1578
|
-
class
|
|
1690
|
+
class Lt extends Ye {
|
|
1579
1691
|
constructor() {
|
|
1580
1692
|
super(...arguments);
|
|
1581
|
-
|
|
1693
|
+
_(this, "multiple", !0);
|
|
1582
1694
|
}
|
|
1583
1695
|
}
|
|
1584
|
-
class
|
|
1696
|
+
class Ue extends K {
|
|
1585
1697
|
constructor() {
|
|
1586
1698
|
super(...arguments);
|
|
1587
|
-
|
|
1699
|
+
_(this, "multiple", !1);
|
|
1588
1700
|
}
|
|
1589
1701
|
renderDisplay(n) {
|
|
1590
|
-
return { element:
|
|
1702
|
+
return { element: dt(n) };
|
|
1591
1703
|
}
|
|
1592
1704
|
renderEditing(n) {
|
|
1593
|
-
return
|
|
1705
|
+
return ct(this.multiple, n);
|
|
1594
1706
|
}
|
|
1595
1707
|
}
|
|
1596
|
-
class
|
|
1708
|
+
class xt extends Ue {
|
|
1597
1709
|
constructor() {
|
|
1598
1710
|
super(...arguments);
|
|
1599
|
-
|
|
1711
|
+
_(this, "multiple", !0);
|
|
1600
1712
|
}
|
|
1601
1713
|
}
|
|
1602
|
-
class
|
|
1714
|
+
class We extends K {
|
|
1603
1715
|
normalize(e) {
|
|
1604
1716
|
return e;
|
|
1605
1717
|
}
|
|
1606
1718
|
renderDisplay(e) {
|
|
1607
|
-
return { element:
|
|
1719
|
+
return { element: je(this.normalize(e)) };
|
|
1608
1720
|
}
|
|
1609
1721
|
renderEditing(e) {
|
|
1610
|
-
return
|
|
1722
|
+
return ut(this.normalize(e));
|
|
1611
1723
|
}
|
|
1612
1724
|
}
|
|
1613
|
-
class
|
|
1725
|
+
class Ke extends We {
|
|
1614
1726
|
constructor() {
|
|
1615
1727
|
super(...arguments);
|
|
1616
|
-
|
|
1728
|
+
_(this, "range", !1);
|
|
1617
1729
|
}
|
|
1618
1730
|
normalize(n) {
|
|
1619
1731
|
return { ...n, field: { ...n.field, dateOptions: { showTime: !1, showRange: this.range, ...n.field.dateOptions } } };
|
|
1620
1732
|
}
|
|
1621
1733
|
}
|
|
1622
|
-
class
|
|
1734
|
+
class At extends Ke {
|
|
1623
1735
|
constructor() {
|
|
1624
1736
|
super(...arguments);
|
|
1625
|
-
|
|
1737
|
+
_(this, "range", !0);
|
|
1626
1738
|
}
|
|
1627
1739
|
}
|
|
1628
|
-
class
|
|
1740
|
+
class Ct extends K {
|
|
1629
1741
|
renderDisplay(e) {
|
|
1630
|
-
return { element:
|
|
1742
|
+
return { element: st(e) };
|
|
1631
1743
|
}
|
|
1632
1744
|
renderEditing(e) {
|
|
1633
|
-
return
|
|
1745
|
+
return qe(e);
|
|
1634
1746
|
}
|
|
1635
1747
|
}
|
|
1636
|
-
class
|
|
1748
|
+
class St extends K {
|
|
1637
1749
|
renderDisplay(e) {
|
|
1638
|
-
return
|
|
1750
|
+
return De({ ...e, readonly: !0 });
|
|
1639
1751
|
}
|
|
1640
1752
|
renderEditing(e) {
|
|
1641
|
-
return
|
|
1753
|
+
return De(e);
|
|
1642
1754
|
}
|
|
1643
1755
|
}
|
|
1644
|
-
class
|
|
1756
|
+
class Mt extends K {
|
|
1645
1757
|
renderDisplay(e) {
|
|
1646
|
-
return { element:
|
|
1758
|
+
return { element: pt(e) };
|
|
1647
1759
|
}
|
|
1648
1760
|
renderEditing(e) {
|
|
1649
|
-
return
|
|
1761
|
+
return ft(e);
|
|
1650
1762
|
}
|
|
1651
1763
|
}
|
|
1652
|
-
class
|
|
1764
|
+
class Ce extends K {
|
|
1653
1765
|
constructor() {
|
|
1654
1766
|
super(...arguments);
|
|
1655
|
-
|
|
1767
|
+
_(this, "mode", "attitude");
|
|
1656
1768
|
}
|
|
1657
1769
|
renderDisplay(n) {
|
|
1658
|
-
return
|
|
1770
|
+
return Te({ ...n, readonly: !0 }, this.mode);
|
|
1659
1771
|
}
|
|
1660
1772
|
renderEditing(n) {
|
|
1661
|
-
return
|
|
1773
|
+
return Te(n, this.mode);
|
|
1662
1774
|
}
|
|
1663
1775
|
}
|
|
1664
|
-
class
|
|
1776
|
+
class Dt extends Ce {
|
|
1665
1777
|
constructor() {
|
|
1666
1778
|
super(...arguments);
|
|
1667
|
-
|
|
1779
|
+
_(this, "mode", "single");
|
|
1668
1780
|
}
|
|
1669
1781
|
}
|
|
1670
|
-
class
|
|
1782
|
+
class Tt extends Ce {
|
|
1671
1783
|
constructor() {
|
|
1672
1784
|
super(...arguments);
|
|
1673
|
-
|
|
1785
|
+
_(this, "mode", "multi");
|
|
1674
1786
|
}
|
|
1675
1787
|
}
|
|
1676
1788
|
class de extends K {
|
|
@@ -1681,56 +1793,56 @@ class de extends K {
|
|
|
1681
1793
|
super({ ...e, readonly: !0 });
|
|
1682
1794
|
}
|
|
1683
1795
|
renderDisplay(e) {
|
|
1684
|
-
return { element:
|
|
1796
|
+
return { element: at(e) };
|
|
1685
1797
|
}
|
|
1686
1798
|
renderEditing(e) {
|
|
1687
|
-
return
|
|
1799
|
+
return lt(e, (n) => this.renderDisplay(n).element);
|
|
1688
1800
|
}
|
|
1689
1801
|
}
|
|
1690
|
-
class
|
|
1802
|
+
class Ve extends de {
|
|
1691
1803
|
renderDisplay(e) {
|
|
1692
|
-
return { element:
|
|
1804
|
+
return { element: rt(e) };
|
|
1693
1805
|
}
|
|
1694
1806
|
}
|
|
1695
|
-
class
|
|
1807
|
+
class Nt extends ne {
|
|
1696
1808
|
renderDisplay(e) {
|
|
1697
1809
|
const n = document.createElement("button");
|
|
1698
|
-
return n.type = "button", n.className = "fc-detail-link", n.textContent = e.field.label, n.onclick = (
|
|
1699
|
-
var
|
|
1700
|
-
|
|
1810
|
+
return n.type = "button", n.className = "fc-detail-link", n.textContent = e.field.label, n.onclick = (i) => {
|
|
1811
|
+
var o;
|
|
1812
|
+
i.stopPropagation(), (o = e.onAction) == null || o.call(e, { type: "open", value: e.value });
|
|
1701
1813
|
}, { element: n, destroy: () => {
|
|
1702
1814
|
n.onclick = null;
|
|
1703
1815
|
} };
|
|
1704
1816
|
}
|
|
1705
1817
|
}
|
|
1706
|
-
class
|
|
1818
|
+
class Vt extends K {
|
|
1707
1819
|
constructor(e, n) {
|
|
1708
1820
|
super(e), this.resolve = n;
|
|
1709
1821
|
}
|
|
1710
1822
|
renderDisplay(e) {
|
|
1711
|
-
var
|
|
1712
|
-
if (e.layout === "compact") return { element:
|
|
1823
|
+
var o;
|
|
1824
|
+
if (e.layout === "compact") return { element: ue({ ...e, value: Array.isArray(e.value) && e.value.length ? e.value.length + " 组记录" : "" }) };
|
|
1713
1825
|
const n = document.createElement("div");
|
|
1714
1826
|
n.className = "fc-composite";
|
|
1715
|
-
const
|
|
1827
|
+
const i = [];
|
|
1716
1828
|
for (const r of Array.isArray(e.value) ? e.value : []) {
|
|
1717
|
-
const
|
|
1718
|
-
|
|
1829
|
+
const s = document.createElement("fieldset");
|
|
1830
|
+
s.className = "fc-composite-row";
|
|
1719
1831
|
for (const c of e.field.compositeFields ?? []) {
|
|
1720
|
-
const
|
|
1721
|
-
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1832
|
+
const u = document.createElement("label");
|
|
1833
|
+
u.textContent = c.label;
|
|
1834
|
+
const f = { ...e, field: c, value: r[c.key], readonly: !0 }, y = this.resolve(c), T = ((o = y.renderView) == null ? void 0 : o.call(y, f)) ?? { element: y.render(f) };
|
|
1835
|
+
i.push(T), s.append(u, T.element);
|
|
1724
1836
|
}
|
|
1725
|
-
n.append(
|
|
1837
|
+
n.append(s);
|
|
1726
1838
|
}
|
|
1727
|
-
return { element: n, destroy: () =>
|
|
1728
|
-
var
|
|
1729
|
-
return (
|
|
1839
|
+
return { element: n, destroy: () => i.forEach((r) => {
|
|
1840
|
+
var s;
|
|
1841
|
+
return (s = r.destroy) == null ? void 0 : s.call(r);
|
|
1730
1842
|
}) };
|
|
1731
1843
|
}
|
|
1732
1844
|
renderEditing(e) {
|
|
1733
|
-
return
|
|
1845
|
+
return ht(e, this.resolve);
|
|
1734
1846
|
}
|
|
1735
1847
|
}
|
|
1736
1848
|
const Rt = {
|
|
@@ -1794,75 +1906,75 @@ const Rt = {
|
|
|
1794
1906
|
external_multi_signal: "externalMultiSignal",
|
|
1795
1907
|
multi_person_composite: "multiPersonComposite",
|
|
1796
1908
|
cloud_document: "cloudDocument"
|
|
1797
|
-
},
|
|
1909
|
+
}, Ht = [
|
|
1798
1910
|
["text", "单行文本", ne, "文本", "T"],
|
|
1799
|
-
["richText", "富文本",
|
|
1800
|
-
["select", "单选",
|
|
1801
|
-
["multiSelect", "多选",
|
|
1802
|
-
["number", "数字",
|
|
1803
|
-
["dateTime", "日期时间",
|
|
1804
|
-
["detail", "详情页查看",
|
|
1805
|
-
["textarea", "多行文本",
|
|
1806
|
-
["radio", "单选按钮",
|
|
1807
|
-
["cascadeSingle", "级联单选",
|
|
1808
|
-
["cascadeMulti", "级联多选",
|
|
1809
|
-
["person", "单选人员",
|
|
1810
|
-
["multiPerson", "多选人员",
|
|
1811
|
-
["date", "日期",
|
|
1812
|
-
["dateRange", "日期区间",
|
|
1813
|
-
["url", "URL 链接",
|
|
1814
|
-
["cloudDocument", "关联云文档",
|
|
1815
|
-
["email", "邮箱",
|
|
1816
|
-
["phone", "电话",
|
|
1817
|
-
["switch", "开关",
|
|
1818
|
-
["attachment", "附件",
|
|
1819
|
-
["location", "地理位置",
|
|
1820
|
-
["relation", "单选关联工作项",
|
|
1821
|
-
["multiRelation", "多选关联工作项",
|
|
1822
|
-
["attitudeVote", "表态投票",
|
|
1823
|
-
["singleVote", "单选投票",
|
|
1824
|
-
["multiVote", "多选投票",
|
|
1825
|
-
["externalSignal", "系统外信号",
|
|
1826
|
-
["externalMultiSignal", "多值系统外信号",
|
|
1911
|
+
["richText", "富文本", bt, "文本", "¶"],
|
|
1912
|
+
["select", "单选", fe, "选择", "◉"],
|
|
1913
|
+
["multiSelect", "多选", wt, "选择", "☑"],
|
|
1914
|
+
["number", "数字", mt, "其他", "#"],
|
|
1915
|
+
["dateTime", "日期时间", We, "日期", "◷"],
|
|
1916
|
+
["detail", "详情页查看", Nt, "关联工作项", "↗"],
|
|
1917
|
+
["textarea", "多行文本", vt, "文本", "≡"],
|
|
1918
|
+
["radio", "单选按钮", kt, "选择", "◉"],
|
|
1919
|
+
["cascadeSingle", "级联单选", Ue, "选择", "⑂"],
|
|
1920
|
+
["cascadeMulti", "级联多选", xt, "选择", "⑂"],
|
|
1921
|
+
["person", "单选人员", ze, "人员", "♙"],
|
|
1922
|
+
["multiPerson", "多选人员", Et, "人员", "♙"],
|
|
1923
|
+
["date", "日期", Ke, "日期", "▦"],
|
|
1924
|
+
["dateRange", "日期区间", At, "日期", "▦"],
|
|
1925
|
+
["url", "URL 链接", Ne, "其他", "↗"],
|
|
1926
|
+
["cloudDocument", "关联云文档", Ne, "其他", "▤"],
|
|
1927
|
+
["email", "邮箱", gt, "其他", "@"],
|
|
1928
|
+
["phone", "电话", yt, "其他", "☎"],
|
|
1929
|
+
["switch", "开关", Ct, "其他", "◐"],
|
|
1930
|
+
["attachment", "附件", St, "其他", "⌑"],
|
|
1931
|
+
["location", "地理位置", Mt, "其他", "⌖"],
|
|
1932
|
+
["relation", "单选关联工作项", Ye, "关联工作项", "↗"],
|
|
1933
|
+
["multiRelation", "多选关联工作项", Lt, "关联工作项", "↗"],
|
|
1934
|
+
["attitudeVote", "表态投票", Ce, "投票", "♡"],
|
|
1935
|
+
["singleVote", "单选投票", Dt, "投票", "♡"],
|
|
1936
|
+
["multiVote", "多选投票", Tt, "投票", "♡"],
|
|
1937
|
+
["externalSignal", "系统外信号", Ve, "系统", "◌", !0],
|
|
1938
|
+
["externalMultiSignal", "多值系统外信号", Ve, "系统", "◌", !0],
|
|
1827
1939
|
["formula", "公式计算", de, "系统", "ƒ", !0],
|
|
1828
1940
|
["aggregate", "聚合计算", de, "系统", "ƒ", !0],
|
|
1829
1941
|
["ai", "AI 字段", de, "系统", "ƒ", !0],
|
|
1830
1942
|
["system", "系统字段", de, "系统", "ƒ", !0]
|
|
1831
1943
|
];
|
|
1832
|
-
function
|
|
1833
|
-
const e = /* @__PURE__ */ new Map(), n = (
|
|
1834
|
-
if (!/^[A-Za-z][\w-]*$/.test(
|
|
1835
|
-
if (e.has(
|
|
1836
|
-
e.set(
|
|
1837
|
-
},
|
|
1838
|
-
const c =
|
|
1839
|
-
if (!
|
|
1840
|
-
return
|
|
1841
|
-
},
|
|
1842
|
-
const c = s
|
|
1944
|
+
function $t(t = []) {
|
|
1945
|
+
const e = /* @__PURE__ */ new Map(), n = (s) => {
|
|
1946
|
+
if (!/^[A-Za-z][\w-]*$/.test(s.id)) throw new Error("Invalid control id");
|
|
1947
|
+
if (e.has(s.id)) throw new Error(`Control already registered: ${s.id}`);
|
|
1948
|
+
e.set(s.id, s);
|
|
1949
|
+
}, i = (s) => {
|
|
1950
|
+
const c = s.control || Ft[s.kind || "text"] || s.kind || "text", u = e.get(c);
|
|
1951
|
+
if (!u) throw new Error(`Unknown control: ${c}`);
|
|
1952
|
+
return u;
|
|
1953
|
+
}, o = (s) => i(s.field).create(s), r = (s) => {
|
|
1954
|
+
const c = i(s);
|
|
1843
1955
|
return {
|
|
1844
1956
|
...c,
|
|
1845
|
-
render: (
|
|
1846
|
-
renderView: (
|
|
1847
|
-
createEditor: (
|
|
1957
|
+
render: (u) => c.create(u).render().element,
|
|
1958
|
+
renderView: (u) => c.create(u).render(),
|
|
1959
|
+
createEditor: (u) => c.create(u).createEditor()
|
|
1848
1960
|
};
|
|
1849
1961
|
};
|
|
1850
|
-
for (const [
|
|
1962
|
+
for (const [s, c, u, f, y, T] of Ht)
|
|
1851
1963
|
n({
|
|
1852
|
-
id:
|
|
1964
|
+
id: s,
|
|
1853
1965
|
label: c,
|
|
1854
|
-
description: Rt[
|
|
1855
|
-
glyph:
|
|
1856
|
-
group:
|
|
1966
|
+
description: Rt[s] || c,
|
|
1967
|
+
glyph: y,
|
|
1968
|
+
group: f,
|
|
1857
1969
|
readonly: T,
|
|
1858
|
-
action:
|
|
1859
|
-
create: (
|
|
1970
|
+
action: s === "detail" ? "view" : s === "select" || s === "multiSelect" ? "select" : void 0,
|
|
1971
|
+
create: (p) => new u({ ...p, readonly: T || p.readonly })
|
|
1860
1972
|
});
|
|
1861
|
-
for (const [
|
|
1862
|
-
n({ id:
|
|
1863
|
-
return t.forEach(n), { register: n, resolve:
|
|
1973
|
+
for (const [s, c] of [["composite", "复合字段"], ["multiPersonComposite", "多人复合字段"]])
|
|
1974
|
+
n({ id: s, label: c, description: "组合多个已注册字段", glyph: "▦", group: "其他", create: (u) => new Vt(u, r) });
|
|
1975
|
+
return t.forEach(n), { register: n, resolve: i, create: o, list: () => [...e.values()] };
|
|
1864
1976
|
}
|
|
1865
|
-
class
|
|
1977
|
+
class Ot extends K {
|
|
1866
1978
|
constructor(e, n) {
|
|
1867
1979
|
super(e), this.control = n;
|
|
1868
1980
|
}
|
|
@@ -1874,40 +1986,40 @@ class $t extends K {
|
|
|
1874
1986
|
}
|
|
1875
1987
|
}
|
|
1876
1988
|
export {
|
|
1877
|
-
|
|
1878
|
-
|
|
1989
|
+
Nt as ActionField,
|
|
1990
|
+
St as AttachmentField,
|
|
1879
1991
|
K as BaseField,
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1992
|
+
Ue as CascadeField,
|
|
1993
|
+
fe as ChoiceField,
|
|
1994
|
+
Vt as CompositeField,
|
|
1883
1995
|
de as ComputedField,
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1996
|
+
Ot as CustomField,
|
|
1997
|
+
Ke as DateField,
|
|
1998
|
+
At as DateRangeField,
|
|
1999
|
+
We as DateTimeField,
|
|
2000
|
+
gt as EmailField,
|
|
2001
|
+
Ne as LinkField,
|
|
2002
|
+
Mt as LocationField,
|
|
2003
|
+
xt as MultiCascadeField,
|
|
2004
|
+
wt as MultiChoiceField,
|
|
2005
|
+
Et as MultiPersonField,
|
|
2006
|
+
Lt as MultiRelationField,
|
|
2007
|
+
Tt as MultiVoteField,
|
|
2008
|
+
mt as NumberField,
|
|
2009
|
+
ze as PersonField,
|
|
2010
|
+
yt as PhoneField,
|
|
2011
|
+
kt as RadioField,
|
|
2012
|
+
Ye as RelationField,
|
|
2013
|
+
bt as RichTextField,
|
|
2014
|
+
Ve as SignalField,
|
|
2015
|
+
Dt as SingleVoteField,
|
|
2016
|
+
Ct as SwitchField,
|
|
1905
2017
|
ne as TextField,
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
2018
|
+
vt as TextareaField,
|
|
2019
|
+
Ce as VoteField,
|
|
2020
|
+
Ze as closeAllFieldPopups,
|
|
2021
|
+
$t as createFieldRegistry,
|
|
2022
|
+
ce as openFieldPopup,
|
|
2023
|
+
Re as renderContent,
|
|
2024
|
+
me as sanitizeRichText
|
|
1913
2025
|
};
|