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