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