@skopon-cool/form-sdk 0.1.0 → 0.1.1
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 +6 -2
- package/dist/adapter/a2uiAdapter.d.ts.map +1 -1
- package/dist/catalog/a2uiCustomCatalog.d.ts.map +1 -1
- package/dist/catalog/textFieldPreview.test.d.ts +2 -0
- package/dist/catalog/textFieldPreview.test.d.ts.map +1 -0
- package/dist/index.js +586 -490
- package/package.json +8 -2
- package/src/adapter/a2uiAdapter.test.ts +23 -0
- package/src/adapter/a2uiAdapter.ts +29 -4
- package/src/catalog/a2uiCustomCatalog.tsx +127 -1
- package/src/catalog/textFieldPreview.test.tsx +88 -0
package/dist/index.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import ne from "
|
|
10
|
-
import
|
|
11
|
-
|
|
1
|
+
import './form-sdk.css';
|
|
2
|
+
import { jsx as u, jsxs as b, Fragment as le } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as Fe, useContext as Oe, useCallback as $, useSyncExternalStore as De, forwardRef as je, useEffect as P, useRef as M, useMemo as A, useImperativeHandle as Ne, useState as j } from "react";
|
|
4
|
+
import { Catalog as Re, MessageProcessor as ce } from "@a2ui/web_core/v0_9";
|
|
5
|
+
import { injectBasicCatalogStyles as se } from "@a2ui/web_core/v0_9/basic_catalog";
|
|
6
|
+
import { basicCatalog as N, createBinderlessComponentImplementation as x, A2uiSurface as ue } from "@a2ui/react/v0_9";
|
|
7
|
+
import { injectStyles as pe } from "@a2ui/react/styles";
|
|
8
|
+
import { z as p } from "zod";
|
|
9
|
+
import { Typography as E, Select as G, Checkbox as Ve, Radio as ze, Switch as Le, TimePicker as Ue, DatePicker as Be, Upload as te, Input as H, InputNumber as $e, Tooltip as X, Tag as ne, Button as de, Spin as He } from "antd";
|
|
10
|
+
import re from "dayjs";
|
|
11
|
+
import { FileTextOutlined as Ye, FileExcelOutlined as Ge, FileOutlined as me, PictureOutlined as Xe, SoundOutlined as Ke, VideoCameraOutlined as qe } from "@ant-design/icons";
|
|
12
|
+
const Cn = "v0.9", Je = [
|
|
12
13
|
"huge",
|
|
13
14
|
"large",
|
|
14
15
|
"medium",
|
|
15
16
|
"small",
|
|
16
17
|
"icon"
|
|
17
18
|
];
|
|
18
|
-
function
|
|
19
|
+
function K(e) {
|
|
19
20
|
return e === "image" || e === "video" || e === "audio";
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
+
function We(e) {
|
|
22
23
|
return e === "heading" || e === "paragraph";
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
return !
|
|
25
|
+
function oe(e) {
|
|
26
|
+
return !We(e) && !K(e);
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function Ze() {
|
|
28
29
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
|
|
29
30
|
return crypto.randomUUID();
|
|
30
31
|
if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") {
|
|
@@ -38,30 +39,30 @@ function Je() {
|
|
|
38
39
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
const t =
|
|
42
|
+
function w(e) {
|
|
43
|
+
const t = Ze().replace(/-/g, "").slice(0, 8);
|
|
43
44
|
return `${e}${t}`;
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
-
return typeof e == "string" &&
|
|
46
|
+
function F(e) {
|
|
47
|
+
return typeof e == "string" && Je.includes(e) ? e : "medium";
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
+
function Qe(e, t) {
|
|
49
50
|
var o;
|
|
50
51
|
const n = Math.max(1, t);
|
|
51
52
|
let r = [];
|
|
52
|
-
return Array.isArray(e.mediaUrls) ? r = e.mediaUrls.map((
|
|
53
|
+
return Array.isArray(e.mediaUrls) ? r = e.mediaUrls.map((i) => String(i).trim()) : (o = e.mediaUrl) != null && o.trim() && (r = [e.mediaUrl.trim()]), r.length === 0 ? [""] : r.slice(0, n);
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function et(e) {
|
|
55
56
|
var t;
|
|
56
57
|
return Array.isArray(e.mediaUrls) ? e.mediaUrls.map((n) => n.trim()).filter(Boolean) : (t = e.mediaUrl) != null && t.trim() ? [e.mediaUrl.trim()] : [];
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
-
return `form-media-size-${
|
|
59
|
+
function tt(e) {
|
|
60
|
+
return `form-media-size-${F(e)}`;
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
-
return `form-media-preview form-media-list ${
|
|
62
|
+
function nt(e) {
|
|
63
|
+
return `form-media-preview form-media-list ${tt(e)}`;
|
|
63
64
|
}
|
|
64
|
-
const
|
|
65
|
+
const fe = [
|
|
65
66
|
{ value: "image/*", label: "图片" },
|
|
66
67
|
{ value: "video/*", label: "视频" },
|
|
67
68
|
{ value: "audio/*", label: "音频" },
|
|
@@ -72,7 +73,7 @@ const de = [
|
|
|
72
73
|
{ value: "text/plain", label: "纯文本" },
|
|
73
74
|
{ value: "application/zip", label: "ZIP 压缩包" },
|
|
74
75
|
{ value: "application/x-rar-compressed", label: "RAR 压缩包" }
|
|
75
|
-
],
|
|
76
|
+
], rt = {
|
|
76
77
|
"image/*": ["image/*"],
|
|
77
78
|
"video/*": ["video/*"],
|
|
78
79
|
"audio/*": ["audio/*"],
|
|
@@ -92,7 +93,7 @@ const de = [
|
|
|
92
93
|
"text/plain": ["text/plain"],
|
|
93
94
|
"application/zip": ["application/zip"],
|
|
94
95
|
"application/x-rar-compressed": ["application/x-rar-compressed"]
|
|
95
|
-
},
|
|
96
|
+
}, ot = {
|
|
96
97
|
"image/*": [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"],
|
|
97
98
|
"video/*": [".mp4", ".mov", ".avi", ".webm"],
|
|
98
99
|
"audio/*": [".mp3", ".wav", ".ogg", ".m4a"],
|
|
@@ -103,14 +104,14 @@ const de = [
|
|
|
103
104
|
"text/plain": [".txt"],
|
|
104
105
|
"application/zip": [".zip", ".7z"],
|
|
105
106
|
"application/x-rar-compressed": [".rar"]
|
|
106
|
-
},
|
|
107
|
+
}, at = {
|
|
107
108
|
"application/msword": "office/word",
|
|
108
109
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "office/word",
|
|
109
110
|
"application/vnd.ms-excel": "office/excel",
|
|
110
111
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "office/excel",
|
|
111
112
|
"application/vnd.ms-powerpoint": "office/ppt",
|
|
112
113
|
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "office/ppt"
|
|
113
|
-
},
|
|
114
|
+
}, he = [
|
|
114
115
|
{ value: ".jpg", label: ".jpg" },
|
|
115
116
|
{ value: ".jpeg", label: ".jpeg" },
|
|
116
117
|
{ value: ".png", label: ".png" },
|
|
@@ -136,16 +137,16 @@ const de = [
|
|
|
136
137
|
{ value: ".zip", label: ".zip" },
|
|
137
138
|
{ value: ".rar", label: ".rar" },
|
|
138
139
|
{ value: ".7z", label: ".7z" }
|
|
139
|
-
],
|
|
140
|
-
de.map((e) => [e.value, e.label])
|
|
141
|
-
), it = Object.fromEntries(
|
|
140
|
+
], it = Object.fromEntries(
|
|
142
141
|
fe.map((e) => [e.value, e.label])
|
|
143
|
-
),
|
|
144
|
-
|
|
142
|
+
), lt = Object.fromEntries(
|
|
143
|
+
he.map((e) => [e.value, e.label])
|
|
144
|
+
), ct = new Set(fe.map((e) => e.value));
|
|
145
|
+
function st(e) {
|
|
145
146
|
const t = e.trim();
|
|
146
|
-
return t ?
|
|
147
|
+
return t ? ct.has(t) ? t : at[t] ?? null : null;
|
|
147
148
|
}
|
|
148
|
-
function
|
|
149
|
+
function ut(e) {
|
|
149
150
|
return Array.isArray(e) ? e.map((t) => {
|
|
150
151
|
const n = t.trim().toLowerCase();
|
|
151
152
|
return n ? n.startsWith(".") ? n : `.${n}` : "";
|
|
@@ -155,98 +156,98 @@ function L(e) {
|
|
|
155
156
|
if (!Array.isArray(e)) return [];
|
|
156
157
|
const t = [], n = /* @__PURE__ */ new Set();
|
|
157
158
|
for (const r of e) {
|
|
158
|
-
const o =
|
|
159
|
+
const o = st(r);
|
|
159
160
|
o && !n.has(o) && (n.add(o), t.push(o));
|
|
160
161
|
}
|
|
161
162
|
return t;
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function pt(e) {
|
|
164
165
|
const t = L(e), n = [];
|
|
165
166
|
for (const r of t)
|
|
166
|
-
n.push(...
|
|
167
|
+
n.push(...rt[r] ?? [r]);
|
|
167
168
|
return n;
|
|
168
169
|
}
|
|
169
|
-
function
|
|
170
|
+
function dt(e) {
|
|
170
171
|
const t = L(e);
|
|
171
172
|
if (t.length === 0) return [];
|
|
172
173
|
const n = /* @__PURE__ */ new Set();
|
|
173
174
|
for (const r of t)
|
|
174
|
-
for (const o of
|
|
175
|
+
for (const o of ot[r] ?? [])
|
|
175
176
|
n.add(o);
|
|
176
|
-
return
|
|
177
|
+
return he.filter((r) => n.has(r.value));
|
|
177
178
|
}
|
|
178
|
-
function
|
|
179
|
+
function Z(e, t) {
|
|
179
180
|
const n = new Set(
|
|
180
|
-
|
|
181
|
+
dt(e).map((r) => r.value)
|
|
181
182
|
);
|
|
182
|
-
return
|
|
183
|
+
return ut(t).filter((r) => n.has(r));
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
-
const n =
|
|
185
|
+
function mt(e, t) {
|
|
186
|
+
const n = pt(e), r = Z(e, t), o = [...n, ...r];
|
|
186
187
|
return o.length > 0 ? o.join(",") : void 0;
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
-
const n = L(e), r =
|
|
189
|
+
function ft(e, t) {
|
|
190
|
+
const n = L(e), r = Z(
|
|
190
191
|
n,
|
|
191
192
|
t
|
|
192
193
|
), o = [
|
|
193
|
-
...n.map((
|
|
194
|
-
...r.map((
|
|
194
|
+
...n.map((i) => it[i] ?? i),
|
|
195
|
+
...r.map((i) => lt[i] ?? i)
|
|
195
196
|
];
|
|
196
197
|
return o.length === 0 ? null : o.join("、");
|
|
197
198
|
}
|
|
198
|
-
const
|
|
199
|
+
const ht = [
|
|
199
200
|
"video",
|
|
200
201
|
"audio",
|
|
201
202
|
"image",
|
|
202
203
|
"file",
|
|
203
204
|
"spreadsheet",
|
|
204
205
|
"document"
|
|
205
|
-
],
|
|
206
|
-
function
|
|
207
|
-
return e &&
|
|
206
|
+
], vt = new Set(ht);
|
|
207
|
+
function yt(e) {
|
|
208
|
+
return e && vt.has(e) ? e : "file";
|
|
208
209
|
}
|
|
209
|
-
const
|
|
210
|
-
function
|
|
210
|
+
const bt = 10;
|
|
211
|
+
function ae(e, t = 1) {
|
|
211
212
|
const n = typeof e == "number" ? e : Number(e);
|
|
212
213
|
return Number.isFinite(n) ? Math.max(0, Math.floor(n)) : t;
|
|
213
214
|
}
|
|
214
|
-
function
|
|
215
|
+
function gt(e, t) {
|
|
215
216
|
if (t !== void 0)
|
|
216
217
|
return e === "toggle" ? t === !0 : e === "multiselect" || e === "checkbox" ? Array.isArray(t) ? t.map(String) : typeof t == "string" && t ? [t] : [] : typeof t == "boolean" ? t ? "true" : "false" : Array.isArray(t) ? t.map(String) : String(t);
|
|
217
218
|
}
|
|
218
|
-
function
|
|
219
|
+
function xt(e) {
|
|
219
220
|
var r, o;
|
|
220
221
|
const t = L(e.fileAcceptTypes), n = e.type;
|
|
221
222
|
return {
|
|
222
|
-
id: ((r = e.id) == null ? void 0 : r.trim()) ||
|
|
223
|
+
id: ((r = e.id) == null ? void 0 : r.trim()) || w("block-"),
|
|
223
224
|
type: n,
|
|
224
225
|
name: ((o = e.name) == null ? void 0 : o.trim()) || void 0,
|
|
225
226
|
label: e.label ?? "",
|
|
226
227
|
placeholder: e.placeholder ?? "",
|
|
227
228
|
help: e.help ?? "",
|
|
228
229
|
required: e.required === !0,
|
|
229
|
-
mediaUrls:
|
|
230
|
-
mediaSize:
|
|
230
|
+
mediaUrls: K(n) ? Qe(e, bt) : void 0,
|
|
231
|
+
mediaSize: K(n) ? F(e.mediaSize) : void 0,
|
|
231
232
|
fileAcceptTypes: t,
|
|
232
|
-
fileAcceptExtensions:
|
|
233
|
+
fileAcceptExtensions: Z(
|
|
233
234
|
t,
|
|
234
235
|
e.fileAcceptExtensions
|
|
235
236
|
),
|
|
236
|
-
filePlaceholderIcon:
|
|
237
|
-
fileMinCount: n === "file" ?
|
|
238
|
-
fileMaxCount: n === "file" ?
|
|
239
|
-
defaultValue:
|
|
240
|
-
options: Array.isArray(e.options) ? e.options.map((
|
|
237
|
+
filePlaceholderIcon: yt(e.filePlaceholderIcon),
|
|
238
|
+
fileMinCount: n === "file" ? ae(e.fileMinCount, 1) : void 0,
|
|
239
|
+
fileMaxCount: n === "file" ? ae(e.fileMaxCount, 1) : void 0,
|
|
240
|
+
defaultValue: gt(n, e.defaultValue),
|
|
241
|
+
options: Array.isArray(e.options) ? e.options.map((i, a) => {
|
|
241
242
|
var l, c;
|
|
242
243
|
return {
|
|
243
|
-
value: ((l =
|
|
244
|
-
label: ((c =
|
|
244
|
+
value: ((l = i.value) == null ? void 0 : l.trim()) || `option_${a + 1}`,
|
|
245
|
+
label: ((c = i.label) == null ? void 0 : c.trim()) || `选项 ${a + 1}`
|
|
245
246
|
};
|
|
246
247
|
}) : void 0
|
|
247
248
|
};
|
|
248
249
|
}
|
|
249
|
-
function
|
|
250
|
+
function R(e) {
|
|
250
251
|
return {
|
|
251
252
|
title: e.title ?? "",
|
|
252
253
|
description: e.description ?? "",
|
|
@@ -254,59 +255,59 @@ function D(e) {
|
|
|
254
255
|
jsonSchema: e.jsonSchema ?? {}
|
|
255
256
|
};
|
|
256
257
|
}
|
|
257
|
-
function
|
|
258
|
+
function ve(e) {
|
|
258
259
|
if (!e || !Array.isArray(e.blocks))
|
|
259
|
-
return
|
|
260
|
-
const t = e.blocks.map(
|
|
261
|
-
return
|
|
260
|
+
return R({ title: "", description: "", blocks: [], jsonSchema: {} });
|
|
261
|
+
const t = e.blocks.map(xt);
|
|
262
|
+
return R({
|
|
262
263
|
title: typeof e.title == "string" ? e.title : "",
|
|
263
264
|
description: typeof e.description == "string" ? e.description : "",
|
|
264
265
|
blocks: t,
|
|
265
266
|
jsonSchema: {}
|
|
266
267
|
});
|
|
267
268
|
}
|
|
268
|
-
const
|
|
269
|
-
function
|
|
269
|
+
const V = "root", q = "__title__", J = "__desc__", ye = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
|
|
270
|
+
function St(e) {
|
|
270
271
|
return `/${e}`;
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
+
function Tt(e) {
|
|
273
274
|
return e && typeof e == "object" && "path" in e ? String(e.path ?? "").replace(/^\//, "") : "";
|
|
274
275
|
}
|
|
275
276
|
function y(e) {
|
|
276
277
|
if (typeof e == "string") return e;
|
|
277
278
|
}
|
|
278
|
-
function
|
|
279
|
-
const t = e.id ||
|
|
279
|
+
function At(e) {
|
|
280
|
+
const t = e.id || w("a2-"), n = e.type === "video" ? "video" : e.type === "audio" ? "audio" : "image";
|
|
280
281
|
return {
|
|
281
282
|
id: t,
|
|
282
283
|
component: "SkoponMedia",
|
|
283
284
|
mediaType: n,
|
|
284
|
-
urls:
|
|
285
|
-
mediaSize:
|
|
285
|
+
urls: et(e),
|
|
286
|
+
mediaSize: F(e.mediaSize),
|
|
286
287
|
label: e.label ?? "",
|
|
287
288
|
help: e.help ?? "",
|
|
288
289
|
placeholder: e.placeholder ?? ""
|
|
289
290
|
};
|
|
290
291
|
}
|
|
291
|
-
function
|
|
292
|
+
function kt(e) {
|
|
292
293
|
if (Array.isArray(e.urls))
|
|
293
294
|
return e.urls.map((n) => String(n).trim()).filter(Boolean);
|
|
294
295
|
const t = y(e.url);
|
|
295
296
|
return t != null && t.trim() ? [t.trim()] : [];
|
|
296
297
|
}
|
|
297
|
-
function
|
|
298
|
-
const r = typeof e.id == "string" ? e.id :
|
|
298
|
+
function D(e, t, n) {
|
|
299
|
+
const r = typeof e.id == "string" ? e.id : w("block-"), o = kt(e), i = y(e.label) ?? y(e.description) ?? n, a = y(e.help), l = y(e.placeholder), c = F(e.mediaSize);
|
|
299
300
|
return {
|
|
300
301
|
id: r,
|
|
301
302
|
type: t,
|
|
302
|
-
label:
|
|
303
|
-
...
|
|
303
|
+
label: i,
|
|
304
|
+
...a ? { help: a } : {},
|
|
304
305
|
...l ? { placeholder: l } : {},
|
|
305
306
|
mediaSize: c,
|
|
306
307
|
mediaUrls: o.length > 0 ? o : [""]
|
|
307
308
|
};
|
|
308
309
|
}
|
|
309
|
-
function
|
|
310
|
+
function Ct(e) {
|
|
310
311
|
switch (e.type) {
|
|
311
312
|
case "toggle":
|
|
312
313
|
return typeof e.defaultValue == "boolean" ? e.defaultValue : !1;
|
|
@@ -319,9 +320,9 @@ function kt(e) {
|
|
|
319
320
|
return typeof e.defaultValue == "string" ? e.defaultValue : "";
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
|
-
function
|
|
323
|
+
function It(e) {
|
|
323
324
|
var l;
|
|
324
|
-
const t = e.id ||
|
|
325
|
+
const t = e.id || w("a2-"), n = e.label ?? "", r = ((l = e.name) == null ? void 0 : l.trim()) || "", o = r ? St(r) : void 0, i = (e.options ?? []).map((c) => ({ label: c.label, value: c.value })), a = (c) => r ? { node: c, dataKey: r, dataValue: Ct(e) } : { node: c };
|
|
325
326
|
switch (e.type) {
|
|
326
327
|
case "heading":
|
|
327
328
|
return { node: { id: t, component: "Text", text: n, variant: "h3" } };
|
|
@@ -330,64 +331,86 @@ function Tt(e) {
|
|
|
330
331
|
case "text":
|
|
331
332
|
case "tel":
|
|
332
333
|
case "url":
|
|
333
|
-
return
|
|
334
|
+
return a({
|
|
335
|
+
id: t,
|
|
336
|
+
component: "TextField",
|
|
337
|
+
label: n,
|
|
338
|
+
variant: "shortText",
|
|
339
|
+
...e.placeholder ? { placeholder: e.placeholder } : {},
|
|
340
|
+
value: { path: o }
|
|
341
|
+
});
|
|
334
342
|
case "email":
|
|
335
|
-
return
|
|
343
|
+
return a({
|
|
336
344
|
id: t,
|
|
337
345
|
component: "TextField",
|
|
338
346
|
label: n,
|
|
339
347
|
variant: "shortText",
|
|
340
|
-
validationRegexp:
|
|
348
|
+
validationRegexp: ye,
|
|
349
|
+
...e.placeholder ? { placeholder: e.placeholder } : {},
|
|
341
350
|
value: { path: o }
|
|
342
351
|
});
|
|
343
352
|
case "textarea":
|
|
344
|
-
return
|
|
353
|
+
return a({
|
|
354
|
+
id: t,
|
|
355
|
+
component: "TextField",
|
|
356
|
+
label: n,
|
|
357
|
+
variant: "longText",
|
|
358
|
+
...e.placeholder ? { placeholder: e.placeholder } : {},
|
|
359
|
+
value: { path: o }
|
|
360
|
+
});
|
|
345
361
|
case "number":
|
|
346
|
-
return
|
|
362
|
+
return a({
|
|
363
|
+
id: t,
|
|
364
|
+
component: "TextField",
|
|
365
|
+
label: n,
|
|
366
|
+
variant: "number",
|
|
367
|
+
...e.placeholder ? { placeholder: e.placeholder } : {},
|
|
368
|
+
value: { path: o }
|
|
369
|
+
});
|
|
347
370
|
case "select":
|
|
348
|
-
return
|
|
371
|
+
return a({
|
|
349
372
|
id: t,
|
|
350
373
|
component: "SkoponSelect",
|
|
351
374
|
label: n,
|
|
352
375
|
mode: "single",
|
|
353
376
|
placeholder: e.placeholder ?? "",
|
|
354
|
-
options:
|
|
377
|
+
options: i,
|
|
355
378
|
value: { path: o }
|
|
356
379
|
});
|
|
357
380
|
case "radio":
|
|
358
|
-
return
|
|
381
|
+
return a({
|
|
359
382
|
id: t,
|
|
360
383
|
component: "ChoicePicker",
|
|
361
384
|
label: n,
|
|
362
385
|
variant: "mutuallyExclusive",
|
|
363
386
|
skoponPickerType: "radio",
|
|
364
|
-
options:
|
|
387
|
+
options: i,
|
|
365
388
|
value: { path: o }
|
|
366
389
|
});
|
|
367
390
|
case "multiselect":
|
|
368
|
-
return
|
|
391
|
+
return a({
|
|
369
392
|
id: t,
|
|
370
393
|
component: "SkoponSelect",
|
|
371
394
|
label: n,
|
|
372
395
|
mode: "multiple",
|
|
373
396
|
placeholder: e.placeholder ?? "",
|
|
374
|
-
options:
|
|
397
|
+
options: i,
|
|
375
398
|
value: { path: o }
|
|
376
399
|
});
|
|
377
400
|
case "checkbox":
|
|
378
|
-
return
|
|
401
|
+
return a({
|
|
379
402
|
id: t,
|
|
380
403
|
component: "ChoicePicker",
|
|
381
404
|
label: n,
|
|
382
405
|
variant: "multipleSelection",
|
|
383
406
|
skoponPickerType: "checkbox",
|
|
384
|
-
options:
|
|
407
|
+
options: i,
|
|
385
408
|
value: { path: o }
|
|
386
409
|
});
|
|
387
410
|
case "toggle":
|
|
388
|
-
return
|
|
411
|
+
return a({ id: t, component: "CheckBox", label: n, value: { path: o } });
|
|
389
412
|
case "datetime":
|
|
390
|
-
return
|
|
413
|
+
return a({
|
|
391
414
|
id: t,
|
|
392
415
|
component: "DateTimeInput",
|
|
393
416
|
label: n,
|
|
@@ -397,7 +420,7 @@ function Tt(e) {
|
|
|
397
420
|
value: { path: o }
|
|
398
421
|
});
|
|
399
422
|
case "time":
|
|
400
|
-
return
|
|
423
|
+
return a({
|
|
401
424
|
id: t,
|
|
402
425
|
component: "DateTimeInput",
|
|
403
426
|
label: n,
|
|
@@ -408,9 +431,9 @@ function Tt(e) {
|
|
|
408
431
|
case "image":
|
|
409
432
|
case "video":
|
|
410
433
|
case "audio":
|
|
411
|
-
return { node:
|
|
434
|
+
return { node: At(e) };
|
|
412
435
|
case "file":
|
|
413
|
-
return
|
|
436
|
+
return a({
|
|
414
437
|
id: t,
|
|
415
438
|
component: "FileUpload",
|
|
416
439
|
label: n,
|
|
@@ -425,31 +448,31 @@ function Tt(e) {
|
|
|
425
448
|
return { node: null };
|
|
426
449
|
}
|
|
427
450
|
}
|
|
428
|
-
function
|
|
451
|
+
function W(e) {
|
|
429
452
|
if (!e || !Array.isArray(e.components) || e.components.length === 0) return !0;
|
|
430
|
-
const t = e.components.find((r) => r.id ===
|
|
453
|
+
const t = e.components.find((r) => r.id === V);
|
|
431
454
|
if (!t) return e.components.length === 0;
|
|
432
455
|
const n = t.children;
|
|
433
456
|
return !Array.isArray(n) || n.length === 0;
|
|
434
457
|
}
|
|
435
|
-
function
|
|
436
|
-
const n = [], r = [], o = {},
|
|
437
|
-
|
|
438
|
-
for (const
|
|
439
|
-
const { node:
|
|
440
|
-
|
|
458
|
+
function be(e, t) {
|
|
459
|
+
const n = [], r = [], o = {}, i = (t == null ? void 0 : t.includeHeader) !== !1, a = (e.title ?? "").trim(), l = (e.description ?? "").trim();
|
|
460
|
+
i && a && (n.push({ id: q, component: "Text", text: a, variant: "h2" }), r.push(q)), i && l && (n.push({ id: J, component: "Text", text: l, variant: "body" }), r.push(J));
|
|
461
|
+
for (const d of e.blocks ?? []) {
|
|
462
|
+
const { node: m, dataKey: f, dataValue: v } = It(d);
|
|
463
|
+
m && (n.push(m), r.push(m.id), f && (o[f] = v));
|
|
441
464
|
}
|
|
442
|
-
n.unshift({ id:
|
|
443
|
-
const c = { root:
|
|
465
|
+
n.unshift({ id: V, component: "Column", children: r });
|
|
466
|
+
const c = { root: V, components: n, dataModel: o }, s = t == null ? void 0 : t.styleId;
|
|
444
467
|
return s !== void 0 && (c.surfaceProperties = { styleId: s ?? null }), c;
|
|
445
468
|
}
|
|
446
|
-
function
|
|
469
|
+
function Pt(e) {
|
|
447
470
|
const t = /* @__PURE__ */ new Map();
|
|
448
471
|
for (const n of e.components ?? [])
|
|
449
472
|
n && typeof n.id == "string" && t.set(n.id, n);
|
|
450
473
|
return t;
|
|
451
474
|
}
|
|
452
|
-
function
|
|
475
|
+
function Y(e) {
|
|
453
476
|
const t = e.options;
|
|
454
477
|
return Array.isArray(t) ? t.map((n) => {
|
|
455
478
|
if (!n || typeof n != "object") return null;
|
|
@@ -461,97 +484,99 @@ function $(e) {
|
|
|
461
484
|
}).filter((n) => !!n) : [];
|
|
462
485
|
}
|
|
463
486
|
function Mt(e) {
|
|
464
|
-
const t = typeof e.id == "string" ? e.id :
|
|
487
|
+
const t = typeof e.id == "string" ? e.id : w("block-"), n = String(e.component ?? ""), r = y(e.label) ?? y(e.text) ?? "", o = Tt(e.value), i = (a) => ({ id: t, type: a, label: r });
|
|
465
488
|
switch (n) {
|
|
466
489
|
case "Text": {
|
|
467
|
-
const
|
|
490
|
+
const a = String(e.variant ?? "body"), l = /^h[1-6]$/i.test(a) || a === "title" || a === "subtitle";
|
|
468
491
|
return { id: t, type: l ? "heading" : "paragraph", label: r };
|
|
469
492
|
}
|
|
470
493
|
case "TextField": {
|
|
471
|
-
const
|
|
494
|
+
const a = String(e.variant ?? "shortText");
|
|
472
495
|
let l = "text";
|
|
473
|
-
|
|
496
|
+
a === "longText" ? l = "textarea" : a === "number" ? l = "number" : y(e.validationRegexp) === ye && (l = "email");
|
|
497
|
+
const c = { ...i(l), name: o }, s = y(e.placeholder);
|
|
498
|
+
return s && (c.placeholder = s), c;
|
|
474
499
|
}
|
|
475
500
|
case "CheckBox":
|
|
476
|
-
return { ...
|
|
501
|
+
return { ...i("toggle"), name: o };
|
|
477
502
|
case "SkoponSelect": {
|
|
478
503
|
const l = String(e.mode ?? "single") === "multiple" ? "multiselect" : "select", c = {
|
|
479
|
-
...
|
|
504
|
+
...i(l),
|
|
480
505
|
name: o,
|
|
481
|
-
options:
|
|
506
|
+
options: Y(e)
|
|
482
507
|
}, s = y(e.placeholder);
|
|
483
508
|
return s && (c.placeholder = s), c;
|
|
484
509
|
}
|
|
485
510
|
case "ChoicePicker": {
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
511
|
+
const a = y(e.skoponPickerType);
|
|
512
|
+
if (a === "select" || a === "multiselect" || a === "radio" || a === "checkbox") {
|
|
488
513
|
const s = {
|
|
489
|
-
...a
|
|
514
|
+
...i(a),
|
|
490
515
|
name: o,
|
|
491
|
-
options:
|
|
492
|
-
},
|
|
493
|
-
return
|
|
516
|
+
options: Y(e)
|
|
517
|
+
}, d = y(e.placeholder);
|
|
518
|
+
return d && (s.placeholder = d), s;
|
|
494
519
|
}
|
|
495
520
|
const c = String(e.variant ?? "mutuallyExclusive") === "multipleSelection" ? "checkbox" : "radio";
|
|
496
|
-
return { ...
|
|
521
|
+
return { ...i(c), name: o, options: Y(e) };
|
|
497
522
|
}
|
|
498
523
|
case "DateTimeInput": {
|
|
499
|
-
const
|
|
500
|
-
return
|
|
524
|
+
const a = e.enableDate === !0, l = e.enableTime === !0, s = { ...i(!a && l ? "time" : "datetime"), name: o }, d = y(e.placeholder);
|
|
525
|
+
return d && (s.placeholder = d), s;
|
|
501
526
|
}
|
|
502
527
|
case "SkoponMedia": {
|
|
503
|
-
const
|
|
504
|
-
return
|
|
528
|
+
const a = String(e.mediaType ?? "image");
|
|
529
|
+
return D(e, a === "video" ? "video" : a === "audio" ? "audio" : "image", r);
|
|
505
530
|
}
|
|
506
531
|
case "Image":
|
|
507
|
-
return
|
|
532
|
+
return D(e, "image", r);
|
|
508
533
|
case "Video":
|
|
509
|
-
return
|
|
534
|
+
return D(e, "video", r);
|
|
510
535
|
case "AudioPlayer":
|
|
511
|
-
return
|
|
536
|
+
return D(e, "audio", r);
|
|
512
537
|
case "FileUpload": {
|
|
513
|
-
const
|
|
514
|
-
return
|
|
538
|
+
const a = y(e.accept) ?? "", l = { ...i("file"), name: o };
|
|
539
|
+
return a && (l.fileAcceptExtensions = a.split(",").map((c) => c.trim()).filter(Boolean)), Array.isArray(e.fileAcceptTypes) && (l.fileAcceptTypes = e.fileAcceptTypes.map(String)), typeof e.filePlaceholderIcon == "string" && (l.filePlaceholderIcon = e.filePlaceholderIcon), typeof e.minCount == "number" && (l.fileMinCount = e.minCount), typeof e.maxCount == "number" && (l.fileMaxCount = e.maxCount), l;
|
|
515
540
|
}
|
|
516
541
|
default:
|
|
517
542
|
return null;
|
|
518
543
|
}
|
|
519
544
|
}
|
|
520
|
-
function
|
|
545
|
+
function ge(e, t, n, r) {
|
|
521
546
|
if (n.has(e)) return;
|
|
522
547
|
n.add(e);
|
|
523
548
|
const o = t.get(e);
|
|
524
549
|
if (!o) return;
|
|
525
|
-
const
|
|
526
|
-
if ((
|
|
527
|
-
for (const
|
|
528
|
-
typeof
|
|
550
|
+
const i = String(o.component ?? "");
|
|
551
|
+
if ((i === "Column" || i === "Row") && Array.isArray(o.children)) {
|
|
552
|
+
for (const a of o.children)
|
|
553
|
+
typeof a == "string" && ge(a, t, n, r);
|
|
529
554
|
return;
|
|
530
555
|
}
|
|
531
556
|
r.push(o);
|
|
532
557
|
}
|
|
533
|
-
function
|
|
558
|
+
function Et(e) {
|
|
534
559
|
if (!e || !Array.isArray(e.components))
|
|
535
|
-
return
|
|
536
|
-
const t =
|
|
537
|
-
|
|
560
|
+
return R({ title: "", description: "", blocks: [], jsonSchema: {} });
|
|
561
|
+
const t = Pt(e), n = [];
|
|
562
|
+
ge(e.root ?? V, t, /* @__PURE__ */ new Set(), n);
|
|
538
563
|
let r = "", o = "";
|
|
539
|
-
const
|
|
540
|
-
for (const
|
|
541
|
-
if (
|
|
542
|
-
r = y(
|
|
564
|
+
const i = [];
|
|
565
|
+
for (const a of n) {
|
|
566
|
+
if (a.id === q) {
|
|
567
|
+
r = y(a.text) ?? r;
|
|
543
568
|
continue;
|
|
544
569
|
}
|
|
545
|
-
if (
|
|
546
|
-
o = y(
|
|
570
|
+
if (a.id === J) {
|
|
571
|
+
o = y(a.text) ?? o;
|
|
547
572
|
continue;
|
|
548
573
|
}
|
|
549
|
-
const l = Mt(
|
|
550
|
-
l &&
|
|
574
|
+
const l = Mt(a);
|
|
575
|
+
l && i.push(l);
|
|
551
576
|
}
|
|
552
|
-
return
|
|
577
|
+
return R({ title: r, description: o, blocks: i, jsonSchema: {} });
|
|
553
578
|
}
|
|
554
|
-
function
|
|
579
|
+
function _t(e, t) {
|
|
555
580
|
const { surfaceId: n, catalogId: r } = t, o = [
|
|
556
581
|
{ version: "v0.9", createSurface: { surfaceId: n, catalogId: r } },
|
|
557
582
|
{
|
|
@@ -564,24 +589,24 @@ function It(e, t) {
|
|
|
564
589
|
updateDataModel: { surfaceId: n, path: "/", value: e.dataModel }
|
|
565
590
|
}), o;
|
|
566
591
|
}
|
|
567
|
-
function
|
|
592
|
+
function xe(e) {
|
|
568
593
|
return !!e && typeof e == "object" && !Array.isArray(e) && Array.isArray(e.components);
|
|
569
594
|
}
|
|
570
|
-
function
|
|
595
|
+
function wt(e, t) {
|
|
571
596
|
if (!e || typeof e != "object") return null;
|
|
572
|
-
const n = e, r =
|
|
573
|
-
if (r && !
|
|
597
|
+
const n = e, r = xe(n.a2ui) ? n.a2ui : void 0;
|
|
598
|
+
if (r && !W(r)) return r;
|
|
574
599
|
const o = Array.isArray(n.blocks) ? n.blocks : [];
|
|
575
600
|
if (o.length === 0) return null;
|
|
576
|
-
const
|
|
601
|
+
const i = ve({
|
|
577
602
|
title: typeof n.title == "string" ? n.title : "",
|
|
578
603
|
description: typeof n.description == "string" ? n.description : "",
|
|
579
604
|
blocks: o
|
|
580
|
-
}),
|
|
581
|
-
return
|
|
605
|
+
}), a = be(i, t);
|
|
606
|
+
return W(a) ? null : a;
|
|
582
607
|
}
|
|
583
|
-
function
|
|
584
|
-
return
|
|
608
|
+
function Ft(e, t, n) {
|
|
609
|
+
return be(
|
|
585
610
|
{
|
|
586
611
|
title: e.title,
|
|
587
612
|
description: e.description,
|
|
@@ -590,62 +615,62 @@ function _t(e, t, n) {
|
|
|
590
615
|
n
|
|
591
616
|
);
|
|
592
617
|
}
|
|
593
|
-
function
|
|
618
|
+
function Ot(e) {
|
|
594
619
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
595
620
|
return;
|
|
596
621
|
const t = e;
|
|
597
|
-
return !(Array.isArray(t.blocks) && t.blocks.length > 0) &&
|
|
622
|
+
return !(Array.isArray(t.blocks) && t.blocks.length > 0) && xe(t.a2ui) ? Et(t.a2ui) : ve({
|
|
598
623
|
title: typeof t.title == "string" ? t.title : "",
|
|
599
624
|
description: typeof t.description == "string" ? t.description : "",
|
|
600
625
|
blocks: Array.isArray(t.blocks) ? t.blocks : []
|
|
601
626
|
});
|
|
602
627
|
}
|
|
603
|
-
function
|
|
628
|
+
function Dt(e, t, n) {
|
|
604
629
|
const r = e.model.surfacesMap.get(t);
|
|
605
630
|
if (!r) return {};
|
|
606
631
|
const o = {};
|
|
607
|
-
for (const
|
|
608
|
-
const
|
|
609
|
-
|
|
632
|
+
for (const i of n) {
|
|
633
|
+
const a = i.trim();
|
|
634
|
+
a && (o[a] = r.dataModel.get(`/${a}`));
|
|
610
635
|
}
|
|
611
636
|
return o;
|
|
612
637
|
}
|
|
613
|
-
function
|
|
638
|
+
function jt(e) {
|
|
614
639
|
return e.replace(/'/g, "'\\''");
|
|
615
640
|
}
|
|
616
|
-
function
|
|
641
|
+
function Se(e, t) {
|
|
617
642
|
const n = (t ?? "").trim() || "<callback_url>", r = JSON.stringify(e ?? {}, null, 2);
|
|
618
643
|
return [
|
|
619
644
|
`curl -X POST '${n}' \\`,
|
|
620
645
|
" -H 'Content-Type: application/json' \\",
|
|
621
|
-
` -d '${
|
|
646
|
+
` -d '${jt(r)}'`
|
|
622
647
|
].join(`
|
|
623
648
|
`);
|
|
624
649
|
}
|
|
625
|
-
function
|
|
650
|
+
function Nt(e) {
|
|
626
651
|
return !e || typeof e != "object" || Array.isArray(e) ? [] : Object.keys(e);
|
|
627
652
|
}
|
|
628
|
-
function
|
|
629
|
-
const n =
|
|
653
|
+
function Rt(e, t) {
|
|
654
|
+
const n = Nt(e), r = e ?? {}, o = (t == null ? void 0 : t.blocks) ?? [], i = new Set(
|
|
630
655
|
o.filter((c) => {
|
|
631
656
|
var s;
|
|
632
|
-
return
|
|
657
|
+
return oe(c.type) && ((s = c.name) == null ? void 0 : s.trim());
|
|
633
658
|
}).map((c) => c.name.trim())
|
|
634
|
-
),
|
|
659
|
+
), a = o.filter(
|
|
635
660
|
(c) => {
|
|
636
661
|
var s;
|
|
637
|
-
return
|
|
662
|
+
return oe(c.type) && ((s = c.name) == null ? void 0 : s.trim()) && n.includes(c.name.trim());
|
|
638
663
|
}
|
|
639
664
|
), l = {};
|
|
640
665
|
for (const c of n)
|
|
641
|
-
|
|
642
|
-
return { matchedBlocks:
|
|
666
|
+
i.has(c) || (l[c] = r[c]);
|
|
667
|
+
return { matchedBlocks: a, remainderPayload: l };
|
|
643
668
|
}
|
|
644
669
|
async function Vt(e, t, n) {
|
|
645
670
|
const r = e.trim();
|
|
646
671
|
if (!r)
|
|
647
672
|
throw new Error("callback_url 为空");
|
|
648
|
-
const
|
|
673
|
+
const i = await ((n == null ? void 0 : n.fetch) ?? fetch)(r, {
|
|
649
674
|
method: "POST",
|
|
650
675
|
headers: {
|
|
651
676
|
"Content-Type": "application/json",
|
|
@@ -653,22 +678,22 @@ async function Vt(e, t, n) {
|
|
|
653
678
|
},
|
|
654
679
|
body: JSON.stringify(t ?? {})
|
|
655
680
|
});
|
|
656
|
-
let
|
|
657
|
-
if ((
|
|
681
|
+
let a;
|
|
682
|
+
if ((i.headers.get("content-type") ?? "").includes("application/json"))
|
|
658
683
|
try {
|
|
659
|
-
|
|
684
|
+
a = await i.json();
|
|
660
685
|
} catch {
|
|
661
|
-
|
|
686
|
+
a = void 0;
|
|
662
687
|
}
|
|
663
688
|
else
|
|
664
689
|
try {
|
|
665
|
-
|
|
690
|
+
a = await i.text();
|
|
666
691
|
} catch {
|
|
667
|
-
|
|
692
|
+
a = void 0;
|
|
668
693
|
}
|
|
669
|
-
return { ok:
|
|
694
|
+
return { ok: i.ok, status: i.status, body: a };
|
|
670
695
|
}
|
|
671
|
-
async function
|
|
696
|
+
async function Te(e) {
|
|
672
697
|
await navigator.clipboard.writeText(e);
|
|
673
698
|
}
|
|
674
699
|
async function zt(e) {
|
|
@@ -677,40 +702,40 @@ async function zt(e) {
|
|
|
677
702
|
throw new Error(t.message || `请求失败 (${e.status})`);
|
|
678
703
|
return t.data;
|
|
679
704
|
}
|
|
680
|
-
function
|
|
705
|
+
function In(e = {}) {
|
|
681
706
|
const t = (e.baseUrl ?? "/api/v1").replace(/\/$/, ""), n = e.detailPath ?? "/dev/form/detail", r = e.fetch ?? fetch;
|
|
682
|
-
async function o(
|
|
683
|
-
var
|
|
684
|
-
const
|
|
685
|
-
if (
|
|
686
|
-
|
|
687
|
-
else if (
|
|
688
|
-
|
|
707
|
+
async function o(i) {
|
|
708
|
+
var m;
|
|
709
|
+
const a = new URLSearchParams();
|
|
710
|
+
if (i.formId !== void 0)
|
|
711
|
+
a.set("form_id", String(i.formId));
|
|
712
|
+
else if (i.formUniqueId)
|
|
713
|
+
a.set("form_unique_id", i.formUniqueId);
|
|
689
714
|
else
|
|
690
715
|
throw new Error("form_id 或 form_unique_id 至少传一个");
|
|
691
|
-
const l = await ((
|
|
716
|
+
const l = await ((m = e.getHeaders) == null ? void 0 : m.call(e)) ?? {}, c = await r(`${t}${n}?${a.toString()}`, {
|
|
692
717
|
method: "GET",
|
|
693
718
|
headers: l
|
|
694
|
-
}), s = await zt(c),
|
|
719
|
+
}), s = await zt(c), d = Ot(s.form_definition);
|
|
695
720
|
return {
|
|
696
721
|
formUniqueId: s.form_unique_id,
|
|
697
722
|
formId: s.form_id,
|
|
698
723
|
disabled: s.disabled === 1,
|
|
699
|
-
formDefinition:
|
|
700
|
-
a2ui:
|
|
724
|
+
formDefinition: d,
|
|
725
|
+
a2ui: wt(s.form_definition) ?? void 0
|
|
701
726
|
};
|
|
702
727
|
}
|
|
703
728
|
return { fetchDetail: o };
|
|
704
729
|
}
|
|
705
730
|
const Lt = {
|
|
706
|
-
video:
|
|
707
|
-
audio:
|
|
708
|
-
image:
|
|
731
|
+
video: qe,
|
|
732
|
+
audio: Ke,
|
|
733
|
+
image: Xe,
|
|
709
734
|
file: me,
|
|
710
|
-
spreadsheet:
|
|
711
|
-
document:
|
|
735
|
+
spreadsheet: Ge,
|
|
736
|
+
document: Ye
|
|
712
737
|
};
|
|
713
|
-
function
|
|
738
|
+
function Ut({
|
|
714
739
|
type: e,
|
|
715
740
|
size: t = 40,
|
|
716
741
|
className: n
|
|
@@ -732,25 +757,25 @@ function ke({
|
|
|
732
757
|
}) {
|
|
733
758
|
return /* @__PURE__ */ u(Ae.Provider, { value: { interactive: e }, children: t });
|
|
734
759
|
}
|
|
735
|
-
function
|
|
736
|
-
return
|
|
760
|
+
function k() {
|
|
761
|
+
return Oe(Ae);
|
|
737
762
|
}
|
|
738
|
-
function
|
|
763
|
+
function Bt(e) {
|
|
739
764
|
return e && typeof e == "object" && "path" in e && String(e.path ?? "").trim() || null;
|
|
740
765
|
}
|
|
741
|
-
function
|
|
742
|
-
const r = e.componentModel.properties[t], o =
|
|
766
|
+
function C(e, t = "value") {
|
|
767
|
+
const r = e.componentModel.properties[t], o = Bt(r), i = $(
|
|
743
768
|
(s) => {
|
|
744
769
|
if (!o || r === void 0) return () => {
|
|
745
770
|
};
|
|
746
|
-
const
|
|
747
|
-
return () =>
|
|
771
|
+
const d = e.dataContext.subscribeDynamicValue(r, () => s());
|
|
772
|
+
return () => d.unsubscribe();
|
|
748
773
|
},
|
|
749
774
|
[e, r, o]
|
|
750
|
-
),
|
|
775
|
+
), a = $(() => {
|
|
751
776
|
if (!(!o || r === void 0))
|
|
752
777
|
return e.dataContext.resolveDynamicValue(r);
|
|
753
|
-
}, [e, r, o]), l = o ?
|
|
778
|
+
}, [e, r, o]), l = o ? De(i, a, a) : void 0, c = $(
|
|
754
779
|
(s) => {
|
|
755
780
|
!o || !r || typeof r != "object" || !("path" in r) || e.dataContext.set(String(r.path), s);
|
|
756
781
|
},
|
|
@@ -758,14 +783,14 @@ function _(e, t = "value") {
|
|
|
758
783
|
);
|
|
759
784
|
return { value: l, setValue: c, hasBinding: !!o };
|
|
760
785
|
}
|
|
761
|
-
function
|
|
786
|
+
function _(e) {
|
|
762
787
|
if (typeof e == "string") return e || void 0;
|
|
763
788
|
if (typeof e == "number") return String(e);
|
|
764
789
|
}
|
|
765
790
|
function z(e) {
|
|
766
791
|
return Array.isArray(e) ? e.map(String) : typeof e == "string" && e ? [e] : [];
|
|
767
792
|
}
|
|
768
|
-
const
|
|
793
|
+
const Ce = "skopon-form-v0_9", $t = /* @__PURE__ */ new Set([
|
|
769
794
|
"SkoponMedia",
|
|
770
795
|
"SkoponSelect",
|
|
771
796
|
"Image",
|
|
@@ -774,17 +799,19 @@ const Te = "skopon-form-v0_9", Bt = /* @__PURE__ */ new Set([
|
|
|
774
799
|
"ChoicePicker",
|
|
775
800
|
"CheckBox",
|
|
776
801
|
"DateTimeInput",
|
|
777
|
-
"FileUpload"
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
802
|
+
"FileUpload",
|
|
803
|
+
"TextField",
|
|
804
|
+
"Text"
|
|
805
|
+
]), Ht = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "caption"]);
|
|
806
|
+
function O(e) {
|
|
807
|
+
const t = [...N.components.values()].find((n) => n.name === e);
|
|
781
808
|
if (!t) throw new Error(`Missing basic catalog component: ${e}`);
|
|
782
809
|
return t.schema;
|
|
783
810
|
}
|
|
784
|
-
function
|
|
811
|
+
function h(e) {
|
|
785
812
|
return typeof e == "string" ? e : "";
|
|
786
813
|
}
|
|
787
|
-
function
|
|
814
|
+
function Ie(e) {
|
|
788
815
|
return Array.isArray(e) ? e.map((t) => {
|
|
789
816
|
if (!t || typeof t != "object") return null;
|
|
790
817
|
const n = t, r = String(n.value ?? n.label ?? ""), o = String(n.label ?? n.value ?? "");
|
|
@@ -797,112 +824,112 @@ function U({
|
|
|
797
824
|
mediaSize: n,
|
|
798
825
|
label: r,
|
|
799
826
|
help: o,
|
|
800
|
-
placeholder:
|
|
827
|
+
placeholder: i
|
|
801
828
|
}) {
|
|
802
|
-
const
|
|
829
|
+
const a = r == null ? void 0 : r.trim(), l = o == null ? void 0 : o.trim(), c = nt(n), s = (i == null ? void 0 : i.trim()) || (e === "image" ? "未设置图片 URL" : e === "video" ? "未设置视频 URL" : "未设置音频 URL");
|
|
803
830
|
return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
|
|
804
|
-
|
|
805
|
-
t.length === 0 ? /* @__PURE__ */ u("div", { className: "form-media-preview form-media-preview--empty", children: s }) : /* @__PURE__ */ u("div", { className: c, children: t.map((
|
|
831
|
+
a ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: a }) : null,
|
|
832
|
+
t.length === 0 ? /* @__PURE__ */ u("div", { className: "form-media-preview form-media-preview--empty", children: s }) : /* @__PURE__ */ u("div", { className: c, children: t.map((d, m) => e === "image" ? /* @__PURE__ */ u(
|
|
806
833
|
"img",
|
|
807
834
|
{
|
|
808
|
-
src:
|
|
809
|
-
alt:
|
|
835
|
+
src: d,
|
|
836
|
+
alt: a || "图片",
|
|
810
837
|
className: "form-media-item"
|
|
811
838
|
},
|
|
812
|
-
`media-${
|
|
839
|
+
`media-${m}`
|
|
813
840
|
) : e === "video" ? /* @__PURE__ */ u(
|
|
814
841
|
"video",
|
|
815
842
|
{
|
|
816
|
-
src:
|
|
843
|
+
src: d,
|
|
817
844
|
controls: !0,
|
|
818
845
|
className: "form-media-item"
|
|
819
846
|
},
|
|
820
|
-
`media-${
|
|
847
|
+
`media-${m}`
|
|
821
848
|
) : /* @__PURE__ */ u(
|
|
822
849
|
"audio",
|
|
823
850
|
{
|
|
824
|
-
src:
|
|
851
|
+
src: d,
|
|
825
852
|
controls: !0,
|
|
826
853
|
className: "form-media-item form-media-item--audio"
|
|
827
854
|
},
|
|
828
|
-
`media-${
|
|
855
|
+
`media-${m}`
|
|
829
856
|
)) }),
|
|
830
|
-
l ? /* @__PURE__ */ u(
|
|
857
|
+
l ? /* @__PURE__ */ u(E.Text, { type: "secondary", className: "form-block-preview-help", children: l }) : null
|
|
831
858
|
] });
|
|
832
859
|
}
|
|
833
860
|
function B(e, t) {
|
|
834
|
-
const n = Array.isArray(e.urls) ? e.urls.map((r) => String(r).trim()).filter(Boolean) :
|
|
861
|
+
const n = Array.isArray(e.urls) ? e.urls.map((r) => String(r).trim()).filter(Boolean) : h(e.url).trim() ? [h(e.url).trim()] : [];
|
|
835
862
|
return {
|
|
836
863
|
mediaType: t,
|
|
837
864
|
urls: n,
|
|
838
|
-
mediaSize:
|
|
839
|
-
label:
|
|
840
|
-
help:
|
|
841
|
-
placeholder:
|
|
865
|
+
mediaSize: F(e.mediaSize),
|
|
866
|
+
label: h(e.label) || h(e.description),
|
|
867
|
+
help: h(e.help),
|
|
868
|
+
placeholder: h(e.placeholder)
|
|
842
869
|
};
|
|
843
870
|
}
|
|
844
|
-
const
|
|
871
|
+
const Yt = {
|
|
845
872
|
name: "SkoponMedia",
|
|
846
|
-
schema:
|
|
847
|
-
mediaType:
|
|
848
|
-
urls:
|
|
849
|
-
mediaSize:
|
|
850
|
-
label:
|
|
851
|
-
help:
|
|
852
|
-
placeholder:
|
|
873
|
+
schema: p.object({
|
|
874
|
+
mediaType: p.any().optional(),
|
|
875
|
+
urls: p.any().optional(),
|
|
876
|
+
mediaSize: p.any().optional(),
|
|
877
|
+
label: p.any().optional(),
|
|
878
|
+
help: p.any().optional(),
|
|
879
|
+
placeholder: p.any().optional()
|
|
853
880
|
}).passthrough()
|
|
854
|
-
},
|
|
855
|
-
const t = e.componentModel.properties, n =
|
|
881
|
+
}, Gt = x(Yt, ({ context: e }) => {
|
|
882
|
+
const t = e.componentModel.properties, n = h(t.mediaType);
|
|
856
883
|
return /* @__PURE__ */ u(U, { ...B(t, n === "video" ? "video" : n === "audio" ? "audio" : "image") });
|
|
857
|
-
}),
|
|
858
|
-
{ name: "Image", schema:
|
|
884
|
+
}), Xt = x(
|
|
885
|
+
{ name: "Image", schema: O("Image") },
|
|
859
886
|
({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "image") })
|
|
860
|
-
),
|
|
861
|
-
{ name: "Video", schema:
|
|
887
|
+
), Kt = x(
|
|
888
|
+
{ name: "Video", schema: O("Video") },
|
|
862
889
|
({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "video") })
|
|
863
|
-
),
|
|
864
|
-
{ name: "AudioPlayer", schema:
|
|
890
|
+
), qt = x(
|
|
891
|
+
{ name: "AudioPlayer", schema: O("AudioPlayer") },
|
|
865
892
|
({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "audio") })
|
|
866
|
-
),
|
|
893
|
+
), Jt = {
|
|
867
894
|
name: "SkoponSelect",
|
|
868
|
-
schema:
|
|
869
|
-
label:
|
|
870
|
-
mode:
|
|
871
|
-
placeholder:
|
|
872
|
-
options:
|
|
873
|
-
value:
|
|
895
|
+
schema: p.object({
|
|
896
|
+
label: p.any().optional(),
|
|
897
|
+
mode: p.any().optional(),
|
|
898
|
+
placeholder: p.any().optional(),
|
|
899
|
+
options: p.any().optional(),
|
|
900
|
+
value: p.any().optional()
|
|
874
901
|
}).passthrough()
|
|
875
902
|
};
|
|
876
|
-
function
|
|
877
|
-
const { interactive: t } =
|
|
903
|
+
function Wt({ context: e }) {
|
|
904
|
+
const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = Ie(o.options), c = h(o.mode) === "multiple";
|
|
878
905
|
return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
|
|
879
|
-
|
|
906
|
+
i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
|
|
880
907
|
/* @__PURE__ */ u(
|
|
881
|
-
|
|
908
|
+
G,
|
|
882
909
|
{
|
|
883
910
|
mode: c ? "multiple" : void 0,
|
|
884
911
|
disabled: !t,
|
|
885
912
|
allowClear: !0,
|
|
886
913
|
className: "form-block-preview-control",
|
|
887
914
|
style: { width: "100%" },
|
|
888
|
-
placeholder:
|
|
915
|
+
placeholder: a || (c ? "请选择多项" : "请选择"),
|
|
889
916
|
options: l,
|
|
890
|
-
value: c ? z(n) :
|
|
917
|
+
value: c ? z(n) : _(n),
|
|
891
918
|
onChange: (s) => r(c ? s ?? [] : s ?? "")
|
|
892
919
|
}
|
|
893
920
|
)
|
|
894
921
|
] });
|
|
895
922
|
}
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
|
|
923
|
+
const Zt = x(
|
|
924
|
+
Jt,
|
|
925
|
+
Wt
|
|
899
926
|
);
|
|
900
|
-
function
|
|
901
|
-
const { interactive: t } =
|
|
927
|
+
function Qt({ context: e }) {
|
|
928
|
+
const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.variant) || "mutuallyExclusive", l = h(o.skoponPickerType), c = h(o.placeholder), s = Ie(o.options), m = l === "select" || l === "multiselect" || l === "radio" || l === "checkbox" ? l : a === "multipleSelection" ? "checkbox" : "radio";
|
|
902
929
|
return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
930
|
+
i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
|
|
931
|
+
m === "select" ? /* @__PURE__ */ u(
|
|
932
|
+
G,
|
|
906
933
|
{
|
|
907
934
|
disabled: !t,
|
|
908
935
|
allowClear: !0,
|
|
@@ -910,11 +937,11 @@ function Jt({ context: e }) {
|
|
|
910
937
|
style: { width: "100%" },
|
|
911
938
|
placeholder: c || "请选择",
|
|
912
939
|
options: s,
|
|
913
|
-
value:
|
|
940
|
+
value: _(n),
|
|
914
941
|
onChange: (f) => r(f ?? "")
|
|
915
942
|
}
|
|
916
|
-
) :
|
|
917
|
-
|
|
943
|
+
) : m === "multiselect" ? /* @__PURE__ */ u(
|
|
944
|
+
G,
|
|
918
945
|
{
|
|
919
946
|
mode: "multiple",
|
|
920
947
|
disabled: !t,
|
|
@@ -926,8 +953,8 @@ function Jt({ context: e }) {
|
|
|
926
953
|
value: z(n),
|
|
927
954
|
onChange: (f) => r(f ?? [])
|
|
928
955
|
}
|
|
929
|
-
) :
|
|
930
|
-
|
|
956
|
+
) : m === "checkbox" ? /* @__PURE__ */ u(
|
|
957
|
+
Ve.Group,
|
|
931
958
|
{
|
|
932
959
|
disabled: !t,
|
|
933
960
|
className: "form-block-preview-control",
|
|
@@ -936,87 +963,87 @@ function Jt({ context: e }) {
|
|
|
936
963
|
onChange: (f) => r(f)
|
|
937
964
|
}
|
|
938
965
|
) : /* @__PURE__ */ u(
|
|
939
|
-
|
|
966
|
+
ze.Group,
|
|
940
967
|
{
|
|
941
968
|
disabled: !t,
|
|
942
969
|
className: "form-block-preview-control",
|
|
943
970
|
options: s,
|
|
944
|
-
value:
|
|
971
|
+
value: _(n),
|
|
945
972
|
onChange: (f) => r(f.target.value)
|
|
946
973
|
}
|
|
947
974
|
)
|
|
948
975
|
] });
|
|
949
976
|
}
|
|
950
|
-
const
|
|
977
|
+
const en = x(
|
|
951
978
|
{
|
|
952
979
|
name: "ChoicePicker",
|
|
953
|
-
schema:
|
|
954
|
-
label:
|
|
955
|
-
variant:
|
|
956
|
-
options:
|
|
957
|
-
value:
|
|
958
|
-
skoponPickerType:
|
|
959
|
-
placeholder:
|
|
980
|
+
schema: p.object({
|
|
981
|
+
label: p.any().optional(),
|
|
982
|
+
variant: p.any().optional(),
|
|
983
|
+
options: p.any().optional(),
|
|
984
|
+
value: p.any().optional(),
|
|
985
|
+
skoponPickerType: p.any().optional(),
|
|
986
|
+
placeholder: p.any().optional()
|
|
960
987
|
}).passthrough()
|
|
961
988
|
},
|
|
962
|
-
|
|
989
|
+
Qt
|
|
963
990
|
);
|
|
964
|
-
function
|
|
965
|
-
const { interactive: t } =
|
|
991
|
+
function tn({ context: e }) {
|
|
992
|
+
const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label);
|
|
966
993
|
return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
|
|
967
|
-
|
|
994
|
+
i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
|
|
968
995
|
/* @__PURE__ */ u(
|
|
969
|
-
|
|
996
|
+
Le,
|
|
970
997
|
{
|
|
971
998
|
disabled: !t,
|
|
972
999
|
className: "form-block-preview-control",
|
|
973
1000
|
checked: n === !0,
|
|
974
|
-
onChange: (
|
|
1001
|
+
onChange: (a) => r(a)
|
|
975
1002
|
}
|
|
976
1003
|
)
|
|
977
1004
|
] });
|
|
978
1005
|
}
|
|
979
|
-
const
|
|
980
|
-
{ name: "CheckBox", schema:
|
|
981
|
-
|
|
1006
|
+
const nn = x(
|
|
1007
|
+
{ name: "CheckBox", schema: O("CheckBox") },
|
|
1008
|
+
tn
|
|
982
1009
|
);
|
|
983
|
-
function
|
|
984
|
-
const r =
|
|
1010
|
+
function rn(e, t, n) {
|
|
1011
|
+
const r = _(e);
|
|
985
1012
|
if (!r) return;
|
|
986
1013
|
if (!t && n) {
|
|
987
|
-
const
|
|
988
|
-
return
|
|
1014
|
+
const i = re(r, "HH:mm", !0);
|
|
1015
|
+
return i.isValid() ? i : void 0;
|
|
989
1016
|
}
|
|
990
|
-
const o =
|
|
1017
|
+
const o = re(r);
|
|
991
1018
|
return o.isValid() ? o : void 0;
|
|
992
1019
|
}
|
|
993
|
-
function
|
|
994
|
-
const { interactive: t } =
|
|
995
|
-
if (!
|
|
1020
|
+
function on({ context: e }) {
|
|
1021
|
+
const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = o.enableDate === !0, c = o.enableTime === !0, s = rn(n, l, c), d = (m) => {
|
|
1022
|
+
if (!m) {
|
|
996
1023
|
r("");
|
|
997
1024
|
return;
|
|
998
1025
|
}
|
|
999
1026
|
if (!l && c) {
|
|
1000
|
-
r(
|
|
1027
|
+
r(m.format("HH:mm"));
|
|
1001
1028
|
return;
|
|
1002
1029
|
}
|
|
1003
1030
|
if (l && c) {
|
|
1004
|
-
r(
|
|
1031
|
+
r(m.format("YYYY-MM-DDTHH:mm"));
|
|
1005
1032
|
return;
|
|
1006
1033
|
}
|
|
1007
|
-
r(
|
|
1034
|
+
r(m.format("YYYY-MM-DD"));
|
|
1008
1035
|
};
|
|
1009
1036
|
return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
|
|
1010
|
-
|
|
1037
|
+
i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
|
|
1011
1038
|
!l && c ? /* @__PURE__ */ u(
|
|
1012
1039
|
Ue,
|
|
1013
1040
|
{
|
|
1014
1041
|
disabled: !t,
|
|
1015
1042
|
className: "form-block-preview-control",
|
|
1016
1043
|
style: { width: "100%" },
|
|
1017
|
-
placeholder:
|
|
1044
|
+
placeholder: a || "选择时间",
|
|
1018
1045
|
value: s,
|
|
1019
|
-
onChange:
|
|
1046
|
+
onChange: d
|
|
1020
1047
|
}
|
|
1021
1048
|
) : /* @__PURE__ */ u(
|
|
1022
1049
|
Be,
|
|
@@ -1025,161 +1052,230 @@ function tn({ context: e }) {
|
|
|
1025
1052
|
disabled: !t,
|
|
1026
1053
|
className: "form-block-preview-control",
|
|
1027
1054
|
style: { width: "100%" },
|
|
1028
|
-
placeholder:
|
|
1055
|
+
placeholder: a || (l && c ? "选择日期时间" : "选择日期"),
|
|
1029
1056
|
value: s,
|
|
1030
|
-
onChange:
|
|
1057
|
+
onChange: d
|
|
1031
1058
|
}
|
|
1032
1059
|
)
|
|
1033
1060
|
] });
|
|
1034
1061
|
}
|
|
1035
|
-
const
|
|
1062
|
+
const an = x(
|
|
1036
1063
|
{
|
|
1037
1064
|
name: "DateTimeInput",
|
|
1038
|
-
schema:
|
|
1039
|
-
label:
|
|
1040
|
-
enableDate:
|
|
1041
|
-
enableTime:
|
|
1042
|
-
placeholder:
|
|
1043
|
-
value:
|
|
1044
|
-
min:
|
|
1045
|
-
max:
|
|
1065
|
+
schema: p.object({
|
|
1066
|
+
label: p.any().optional(),
|
|
1067
|
+
enableDate: p.any().optional(),
|
|
1068
|
+
enableTime: p.any().optional(),
|
|
1069
|
+
placeholder: p.any().optional(),
|
|
1070
|
+
value: p.any().optional(),
|
|
1071
|
+
min: p.any().optional(),
|
|
1072
|
+
max: p.any().optional()
|
|
1046
1073
|
}).passthrough()
|
|
1047
1074
|
},
|
|
1048
|
-
|
|
1049
|
-
),
|
|
1075
|
+
on
|
|
1076
|
+
), ln = {
|
|
1050
1077
|
name: "FileUpload",
|
|
1051
|
-
schema:
|
|
1052
|
-
label:
|
|
1053
|
-
accept:
|
|
1054
|
-
fileAcceptTypes:
|
|
1055
|
-
filePlaceholderIcon:
|
|
1056
|
-
minCount:
|
|
1057
|
-
maxCount:
|
|
1058
|
-
value:
|
|
1078
|
+
schema: p.object({
|
|
1079
|
+
label: p.any().optional(),
|
|
1080
|
+
accept: p.any().optional(),
|
|
1081
|
+
fileAcceptTypes: p.any().optional(),
|
|
1082
|
+
filePlaceholderIcon: p.any().optional(),
|
|
1083
|
+
minCount: p.any().optional(),
|
|
1084
|
+
maxCount: p.any().optional(),
|
|
1085
|
+
value: p.any().optional()
|
|
1059
1086
|
}).passthrough()
|
|
1060
1087
|
};
|
|
1061
|
-
function
|
|
1062
|
-
const { interactive: t } =
|
|
1088
|
+
function cn({ context: e }) {
|
|
1089
|
+
const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.accept), l = Array.isArray(o.fileAcceptTypes) ? o.fileAcceptTypes.map(String) : void 0, c = a ? a.split(",").map((v) => v.trim()).filter(Boolean) : void 0, s = ft(l, c), d = typeof o.filePlaceholderIcon == "string" && ["video", "audio", "image", "file", "spreadsheet", "document"].includes(
|
|
1063
1090
|
o.filePlaceholderIcon
|
|
1064
|
-
) ? o.filePlaceholderIcon : "document",
|
|
1091
|
+
) ? o.filePlaceholderIcon : "document", m = typeof o.maxCount == "number" ? o.maxCount : 1, f = z(n);
|
|
1065
1092
|
return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
|
|
1066
|
-
|
|
1093
|
+
i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
|
|
1067
1094
|
/* @__PURE__ */ b(
|
|
1068
|
-
|
|
1095
|
+
te.Dragger,
|
|
1069
1096
|
{
|
|
1070
1097
|
disabled: !t,
|
|
1071
|
-
accept:
|
|
1098
|
+
accept: mt(l, c),
|
|
1072
1099
|
className: "form-file-upload-preview",
|
|
1073
1100
|
showUploadList: t && f.length > 0,
|
|
1074
|
-
fileList: t ? f.map((
|
|
1075
|
-
uid: `${
|
|
1076
|
-
name:
|
|
1101
|
+
fileList: t ? f.map((v, T) => ({
|
|
1102
|
+
uid: `${T}-${v}`,
|
|
1103
|
+
name: v,
|
|
1077
1104
|
status: "done"
|
|
1078
1105
|
})) : [],
|
|
1079
|
-
beforeUpload: (
|
|
1080
|
-
if (!t) return
|
|
1081
|
-
const
|
|
1082
|
-
return r(
|
|
1106
|
+
beforeUpload: (v) => {
|
|
1107
|
+
if (!t) return te.LIST_IGNORE;
|
|
1108
|
+
const T = [...f, v.name].slice(0, Math.max(1, m));
|
|
1109
|
+
return r(T), !1;
|
|
1083
1110
|
},
|
|
1084
|
-
onRemove: (
|
|
1085
|
-
r(f.filter((
|
|
1111
|
+
onRemove: (v) => {
|
|
1112
|
+
r(f.filter((T) => T !== v.name));
|
|
1086
1113
|
},
|
|
1087
1114
|
children: [
|
|
1088
|
-
/* @__PURE__ */ u("p", { className: "form-file-upload-preview-icon", children: /* @__PURE__ */ u(
|
|
1115
|
+
/* @__PURE__ */ u("p", { className: "form-file-upload-preview-icon", children: /* @__PURE__ */ u(Ut, { type: d, size: 40 }) }),
|
|
1089
1116
|
/* @__PURE__ */ u("p", { className: "form-file-upload-preview-text", children: "点击或拖拽文件到此处上传" })
|
|
1090
1117
|
]
|
|
1091
1118
|
}
|
|
1092
1119
|
),
|
|
1093
|
-
/* @__PURE__ */ b(
|
|
1120
|
+
/* @__PURE__ */ b(E.Text, { type: "secondary", className: "form-block-preview-help", children: [
|
|
1094
1121
|
"允许:",
|
|
1095
1122
|
s ?? "全部类型"
|
|
1096
1123
|
] })
|
|
1097
1124
|
] });
|
|
1098
1125
|
}
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
|
|
1126
|
+
const sn = x(
|
|
1127
|
+
ln,
|
|
1128
|
+
cn
|
|
1129
|
+
);
|
|
1130
|
+
function un({ context: e }) {
|
|
1131
|
+
const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = h(o.variant) || "shortText", c = _(n) ?? "", s = !t, d = "form-block-preview-control";
|
|
1132
|
+
let m;
|
|
1133
|
+
return l === "longText" ? m = /* @__PURE__ */ u(
|
|
1134
|
+
H.TextArea,
|
|
1135
|
+
{
|
|
1136
|
+
disabled: s,
|
|
1137
|
+
className: d,
|
|
1138
|
+
placeholder: a || "长文本回答...",
|
|
1139
|
+
autoSize: { minRows: 2, maxRows: 6 },
|
|
1140
|
+
value: c,
|
|
1141
|
+
onChange: (f) => r(f.target.value)
|
|
1142
|
+
}
|
|
1143
|
+
) : l === "number" ? m = /* @__PURE__ */ u(
|
|
1144
|
+
$e,
|
|
1145
|
+
{
|
|
1146
|
+
disabled: s,
|
|
1147
|
+
className: d,
|
|
1148
|
+
style: { width: "100%" },
|
|
1149
|
+
placeholder: a || "数字",
|
|
1150
|
+
value: c ? Number(c) : void 0,
|
|
1151
|
+
onChange: (f) => r(f == null ? "" : String(f))
|
|
1152
|
+
}
|
|
1153
|
+
) : l === "obscured" ? m = /* @__PURE__ */ u(
|
|
1154
|
+
H.Password,
|
|
1155
|
+
{
|
|
1156
|
+
disabled: s,
|
|
1157
|
+
className: d,
|
|
1158
|
+
placeholder: a,
|
|
1159
|
+
value: c,
|
|
1160
|
+
onChange: (f) => r(f.target.value)
|
|
1161
|
+
}
|
|
1162
|
+
) : m = /* @__PURE__ */ u(
|
|
1163
|
+
H,
|
|
1164
|
+
{
|
|
1165
|
+
disabled: s,
|
|
1166
|
+
className: d,
|
|
1167
|
+
placeholder: a,
|
|
1168
|
+
value: c,
|
|
1169
|
+
onChange: (f) => r(f.target.value)
|
|
1170
|
+
}
|
|
1171
|
+
), /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
|
|
1172
|
+
i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
|
|
1173
|
+
m
|
|
1174
|
+
] });
|
|
1175
|
+
}
|
|
1176
|
+
const pn = x(
|
|
1177
|
+
{
|
|
1178
|
+
name: "TextField",
|
|
1179
|
+
schema: p.object({
|
|
1180
|
+
label: p.any().optional(),
|
|
1181
|
+
variant: p.any().optional(),
|
|
1182
|
+
placeholder: p.any().optional(),
|
|
1183
|
+
validationRegexp: p.any().optional(),
|
|
1184
|
+
value: p.any().optional()
|
|
1185
|
+
}).passthrough()
|
|
1186
|
+
},
|
|
1187
|
+
un
|
|
1102
1188
|
);
|
|
1103
|
-
function
|
|
1189
|
+
function dn({ context: e }) {
|
|
1190
|
+
const t = e.componentModel.properties, n = h(t.text), r = h(t.variant) || "body";
|
|
1191
|
+
return Ht.has(r) ? r === "caption" ? /* @__PURE__ */ u(E.Text, { type: "secondary", className: "form-block-preview-paragraph", children: /* @__PURE__ */ u("em", { children: n }) }) : /* @__PURE__ */ u(r, { className: "form-block-preview-heading", children: n }) : /* @__PURE__ */ u(E.Paragraph, { className: "form-block-preview-paragraph", children: n });
|
|
1192
|
+
}
|
|
1193
|
+
const mn = x(
|
|
1194
|
+
{ name: "Text", schema: O("Text") },
|
|
1195
|
+
dn
|
|
1196
|
+
);
|
|
1197
|
+
function Pe() {
|
|
1104
1198
|
const t = [
|
|
1105
|
-
...[...
|
|
1106
|
-
(r) =>
|
|
1199
|
+
...[...N.components.values()].filter(
|
|
1200
|
+
(r) => !$t.has(r.name)
|
|
1107
1201
|
),
|
|
1108
|
-
$t,
|
|
1109
|
-
qt,
|
|
1110
|
-
Ht,
|
|
1111
|
-
Yt,
|
|
1112
1202
|
Gt,
|
|
1113
|
-
|
|
1114
|
-
|
|
1203
|
+
Zt,
|
|
1204
|
+
Xt,
|
|
1205
|
+
Kt,
|
|
1206
|
+
qt,
|
|
1207
|
+
en,
|
|
1115
1208
|
nn,
|
|
1116
|
-
an
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1209
|
+
an,
|
|
1210
|
+
sn,
|
|
1211
|
+
pn,
|
|
1212
|
+
mn
|
|
1213
|
+
], n = [...N.functions.values()];
|
|
1214
|
+
return new Re(Ce, t, n, N.themeSchema);
|
|
1215
|
+
}
|
|
1216
|
+
const fn = je(
|
|
1121
1217
|
function({
|
|
1122
1218
|
doc: t,
|
|
1123
1219
|
surfaceId: n = "skopon-form",
|
|
1124
1220
|
emptyHint: r = null,
|
|
1125
1221
|
interactive: o = !0,
|
|
1126
|
-
fieldNames:
|
|
1127
|
-
},
|
|
1128
|
-
|
|
1129
|
-
|
|
1222
|
+
fieldNames: i = []
|
|
1223
|
+
}, a) {
|
|
1224
|
+
P(() => {
|
|
1225
|
+
pe(), se();
|
|
1130
1226
|
}, []);
|
|
1131
|
-
const l = M(null), c = M(
|
|
1132
|
-
c.current =
|
|
1133
|
-
const s =
|
|
1134
|
-
if (
|
|
1227
|
+
const l = M(null), c = M(i);
|
|
1228
|
+
c.current = i;
|
|
1229
|
+
const s = A(() => {
|
|
1230
|
+
if (W(t))
|
|
1135
1231
|
return l.current = null, [];
|
|
1136
1232
|
try {
|
|
1137
|
-
const
|
|
1233
|
+
const d = new ce([Pe()]), m = _t(t, {
|
|
1138
1234
|
surfaceId: n,
|
|
1139
|
-
catalogId:
|
|
1235
|
+
catalogId: Ce
|
|
1140
1236
|
});
|
|
1141
|
-
return
|
|
1142
|
-
} catch (
|
|
1143
|
-
return console.error("[SkoponFormRenderer] 渲染 A2UI surface 失败",
|
|
1237
|
+
return d.processMessages(m), l.current = d, Array.from(d.model.surfacesMap.values());
|
|
1238
|
+
} catch (d) {
|
|
1239
|
+
return console.error("[SkoponFormRenderer] 渲染 A2UI surface 失败", d), l.current = null, [];
|
|
1144
1240
|
}
|
|
1145
1241
|
}, [t, n]);
|
|
1146
|
-
return
|
|
1147
|
-
|
|
1242
|
+
return Ne(
|
|
1243
|
+
a,
|
|
1148
1244
|
() => ({
|
|
1149
|
-
getValues(
|
|
1150
|
-
const
|
|
1151
|
-
if (!
|
|
1152
|
-
const f = (
|
|
1153
|
-
return
|
|
1245
|
+
getValues(d) {
|
|
1246
|
+
const m = l.current;
|
|
1247
|
+
if (!m) return {};
|
|
1248
|
+
const f = (d ?? c.current).map((v) => v.trim()).filter(Boolean);
|
|
1249
|
+
return Dt(m, n, f);
|
|
1154
1250
|
}
|
|
1155
1251
|
}),
|
|
1156
1252
|
[n]
|
|
1157
|
-
), s.length === 0 ? /* @__PURE__ */ u(
|
|
1253
|
+
), s.length === 0 ? /* @__PURE__ */ u(le, { children: r }) : /* @__PURE__ */ u(ke, { interactive: o, children: /* @__PURE__ */ u("div", { className: "a2ui-surface a2ui-container", children: s.map((d) => /* @__PURE__ */ u(ue, { surface: d }, d.id)) }) });
|
|
1158
1254
|
}
|
|
1159
1255
|
);
|
|
1160
|
-
function
|
|
1256
|
+
function Pn({
|
|
1161
1257
|
messages: e,
|
|
1162
1258
|
surfaceId: t = "skopon-form-stream",
|
|
1163
1259
|
emptyHint: n = null,
|
|
1164
1260
|
interactive: r = !0
|
|
1165
1261
|
}) {
|
|
1166
|
-
|
|
1167
|
-
|
|
1262
|
+
P(() => {
|
|
1263
|
+
pe(), se();
|
|
1168
1264
|
}, []);
|
|
1169
|
-
const o = M(null),
|
|
1170
|
-
const s = new
|
|
1171
|
-
return o.current = s,
|
|
1172
|
-
}, [t]), [l, c] =
|
|
1173
|
-
return
|
|
1174
|
-
const s = () => c(Array.from(
|
|
1265
|
+
const o = M(null), i = M(0), a = A(() => {
|
|
1266
|
+
const s = new ce([Pe()]);
|
|
1267
|
+
return o.current = s, i.current = 0, s;
|
|
1268
|
+
}, [t]), [l, c] = j(() => Array.from(a.model.surfacesMap.values()));
|
|
1269
|
+
return P(() => {
|
|
1270
|
+
const s = () => c(Array.from(a.model.surfacesMap.values())), d = a.onSurfaceCreated(s), m = a.onSurfaceDeleted(s);
|
|
1175
1271
|
return () => {
|
|
1176
|
-
|
|
1272
|
+
d.unsubscribe(), m.unsubscribe();
|
|
1177
1273
|
};
|
|
1178
|
-
}, [
|
|
1274
|
+
}, [a]), P(() => {
|
|
1179
1275
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
1180
|
-
const s = e.slice(
|
|
1181
|
-
s.length !== 0 && (
|
|
1182
|
-
}, [e,
|
|
1276
|
+
const s = e.slice(i.current);
|
|
1277
|
+
s.length !== 0 && (a.processMessages(s), i.current = e.length, c(Array.from(a.model.surfacesMap.values())));
|
|
1278
|
+
}, [e, a]), l.length === 0 ? /* @__PURE__ */ u(le, { children: n }) : /* @__PURE__ */ u(ke, { interactive: r, children: /* @__PURE__ */ u("div", { className: "a2ui-surface a2ui-container", children: l.map((s) => /* @__PURE__ */ u(ue, { surface: s }, s.id)) }) });
|
|
1183
1279
|
}
|
|
1184
1280
|
function ie({
|
|
1185
1281
|
payload: e,
|
|
@@ -1187,146 +1283,146 @@ function ie({
|
|
|
1187
1283
|
title: n,
|
|
1188
1284
|
unpublishedFormId: r,
|
|
1189
1285
|
incompleteFormId: o,
|
|
1190
|
-
onNotify:
|
|
1286
|
+
onNotify: i
|
|
1191
1287
|
}) {
|
|
1192
|
-
const
|
|
1193
|
-
() =>
|
|
1288
|
+
const a = A(
|
|
1289
|
+
() => Se(e, t),
|
|
1194
1290
|
[e, t]
|
|
1195
1291
|
);
|
|
1196
1292
|
async function l() {
|
|
1197
1293
|
try {
|
|
1198
|
-
await
|
|
1294
|
+
await Te(a), i == null || i("success", "已复制到剪贴板");
|
|
1199
1295
|
} catch {
|
|
1200
|
-
|
|
1296
|
+
i == null || i("error", "复制失败");
|
|
1201
1297
|
}
|
|
1202
1298
|
}
|
|
1203
1299
|
return /* @__PURE__ */ b("div", { className: "ask-user-curl-card", children: [
|
|
1204
1300
|
/* @__PURE__ */ b("div", { className: "ask-user-curl-card-header", children: [
|
|
1205
1301
|
/* @__PURE__ */ b("div", { className: "ask-user-curl-card-header-title", children: [
|
|
1206
|
-
/* @__PURE__ */ u(
|
|
1207
|
-
r ? /* @__PURE__ */ u(
|
|
1208
|
-
o ? /* @__PURE__ */ u(
|
|
1302
|
+
/* @__PURE__ */ u(E.Text, { type: "secondary", children: n ?? "curl 命令" }),
|
|
1303
|
+
r ? /* @__PURE__ */ u(X, { title: r, children: /* @__PURE__ */ u(ne, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) : null,
|
|
1304
|
+
o ? /* @__PURE__ */ u(X, { title: o, children: /* @__PURE__ */ u(ne, { className: "ask-user-curl-incomplete-tag", children: "卡片 ID 待补足" }) }) : null
|
|
1209
1305
|
] }),
|
|
1210
|
-
/* @__PURE__ */ u(
|
|
1306
|
+
/* @__PURE__ */ u(de, { size: "small", type: "text", onClick: () => void l(), children: "复制" })
|
|
1211
1307
|
] }),
|
|
1212
|
-
/* @__PURE__ */ u("pre", { className: "skopon-form-curl-json", children:
|
|
1308
|
+
/* @__PURE__ */ u("pre", { className: "skopon-form-curl-json", children: a })
|
|
1213
1309
|
] });
|
|
1214
1310
|
}
|
|
1215
|
-
function
|
|
1311
|
+
function Mn({
|
|
1216
1312
|
payload: e,
|
|
1217
1313
|
formUniqueId: t,
|
|
1218
1314
|
callbackUrl: n,
|
|
1219
1315
|
submitMode: r = "curl",
|
|
1220
1316
|
fetchFormDetail: o,
|
|
1221
|
-
onNotify:
|
|
1317
|
+
onNotify: i
|
|
1222
1318
|
}) {
|
|
1223
|
-
const [
|
|
1224
|
-
|
|
1319
|
+
const [a, l] = j(null), [c, s] = j(!1), [d, m] = j(!0), f = M(null);
|
|
1320
|
+
P(() => {
|
|
1225
1321
|
let g = !1;
|
|
1226
|
-
return
|
|
1227
|
-
g || (s(!!
|
|
1322
|
+
return m(!0), s(!1), o({ formUniqueId: t }).then((S) => {
|
|
1323
|
+
g || (s(!!S.disabled), l(S.disabled ? null : S.formDefinition ?? null));
|
|
1228
1324
|
}).catch(() => {
|
|
1229
1325
|
g || (s(!1), l(null));
|
|
1230
1326
|
}).finally(() => {
|
|
1231
|
-
g ||
|
|
1327
|
+
g || m(!1);
|
|
1232
1328
|
}), () => {
|
|
1233
1329
|
g = !0;
|
|
1234
1330
|
};
|
|
1235
1331
|
}, [t, o]);
|
|
1236
|
-
const { matchedBlocks:
|
|
1237
|
-
() =>
|
|
1238
|
-
[e,
|
|
1239
|
-
),
|
|
1240
|
-
() =>
|
|
1241
|
-
var
|
|
1242
|
-
return (
|
|
1332
|
+
const { matchedBlocks: v, remainderPayload: T } = A(
|
|
1333
|
+
() => Rt(e, a ?? void 0),
|
|
1334
|
+
[e, a]
|
|
1335
|
+
), Q = A(
|
|
1336
|
+
() => v.map((g) => {
|
|
1337
|
+
var S;
|
|
1338
|
+
return (S = g.name) == null ? void 0 : S.trim();
|
|
1243
1339
|
}).filter((g) => !!g),
|
|
1244
|
-
[
|
|
1245
|
-
),
|
|
1246
|
-
if (
|
|
1247
|
-
return /* @__PURE__ */ u("div", { className: "ask-user-form-card", children: /* @__PURE__ */ u(
|
|
1248
|
-
if (
|
|
1340
|
+
[v]
|
|
1341
|
+
), Me = A(() => !a || v.length === 0 ? null : Ft(a, v), [a, v]);
|
|
1342
|
+
if (d)
|
|
1343
|
+
return /* @__PURE__ */ u("div", { className: "ask-user-form-card", children: /* @__PURE__ */ u(He, { size: "small" }) });
|
|
1344
|
+
if (v.length === 0)
|
|
1249
1345
|
return /* @__PURE__ */ u(
|
|
1250
1346
|
ie,
|
|
1251
1347
|
{
|
|
1252
1348
|
payload: e,
|
|
1253
1349
|
callbackUrl: n,
|
|
1254
1350
|
unpublishedFormId: c ? t : void 0,
|
|
1255
|
-
onNotify:
|
|
1351
|
+
onNotify: i
|
|
1256
1352
|
}
|
|
1257
1353
|
);
|
|
1258
|
-
const
|
|
1259
|
-
async function
|
|
1260
|
-
var
|
|
1261
|
-
const g = ((
|
|
1354
|
+
const Ee = Object.keys(T).length > 0;
|
|
1355
|
+
async function _e() {
|
|
1356
|
+
var S;
|
|
1357
|
+
const g = ((S = f.current) == null ? void 0 : S.getValues(Q)) ?? {};
|
|
1262
1358
|
if (r === "post") {
|
|
1263
|
-
const
|
|
1264
|
-
if (!
|
|
1265
|
-
|
|
1359
|
+
const ee = (n ?? "").trim();
|
|
1360
|
+
if (!ee) {
|
|
1361
|
+
i == null || i("error", "callback_url 为空,无法提交");
|
|
1266
1362
|
return;
|
|
1267
1363
|
}
|
|
1268
1364
|
try {
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1271
|
-
} catch (
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1365
|
+
const I = await Vt(ee, g);
|
|
1366
|
+
I.ok ? i == null || i("success", "提交成功") : i == null || i("error", `提交失败 (${I.status})`);
|
|
1367
|
+
} catch (I) {
|
|
1368
|
+
const we = I instanceof Error ? I.message : "提交失败";
|
|
1369
|
+
i == null || i("error", we);
|
|
1274
1370
|
}
|
|
1275
1371
|
return;
|
|
1276
1372
|
}
|
|
1277
1373
|
try {
|
|
1278
|
-
await Se(
|
|
1374
|
+
await Te(Se(g, n)), i == null || i("success", "已复制 curl 到剪贴板");
|
|
1279
1375
|
} catch {
|
|
1280
|
-
|
|
1376
|
+
i == null || i("error", "复制失败");
|
|
1281
1377
|
}
|
|
1282
1378
|
}
|
|
1283
1379
|
return /* @__PURE__ */ b("div", { className: "ask-user-form-card", children: [
|
|
1284
1380
|
/* @__PURE__ */ u(
|
|
1285
|
-
|
|
1381
|
+
fn,
|
|
1286
1382
|
{
|
|
1287
1383
|
ref: f,
|
|
1288
|
-
doc:
|
|
1384
|
+
doc: Me,
|
|
1289
1385
|
surfaceId: `ask-user-${t}`,
|
|
1290
|
-
fieldNames:
|
|
1386
|
+
fieldNames: Q,
|
|
1291
1387
|
interactive: !0
|
|
1292
1388
|
}
|
|
1293
1389
|
),
|
|
1294
|
-
/* @__PURE__ */ u("div", { className: "ask-user-form-actions", children: /* @__PURE__ */ u(
|
|
1295
|
-
|
|
1390
|
+
/* @__PURE__ */ u("div", { className: "ask-user-form-actions", children: /* @__PURE__ */ u(X, { title: r === "curl" ? "点击复制 curl" : "提交 JSON 到 callback_url", children: /* @__PURE__ */ u(de, { type: "primary", size: "small", onClick: () => void _e(), children: "提交" }) }) }),
|
|
1391
|
+
Ee ? /* @__PURE__ */ u(
|
|
1296
1392
|
ie,
|
|
1297
1393
|
{
|
|
1298
|
-
payload:
|
|
1394
|
+
payload: T,
|
|
1299
1395
|
callbackUrl: n,
|
|
1300
1396
|
title: "以下字段不在表单中,请使用 curl 提交",
|
|
1301
1397
|
incompleteFormId: t,
|
|
1302
|
-
onNotify:
|
|
1398
|
+
onNotify: i
|
|
1303
1399
|
}
|
|
1304
1400
|
) : null
|
|
1305
1401
|
] });
|
|
1306
1402
|
}
|
|
1307
1403
|
export {
|
|
1308
|
-
|
|
1309
|
-
|
|
1404
|
+
Cn as A2UI_PROTOCOL_VERSION,
|
|
1405
|
+
Mn as AskUserFormCard,
|
|
1310
1406
|
ie as CurlSubmitBlock,
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1407
|
+
Je as FORM_MEDIA_SIZES,
|
|
1408
|
+
Pn as SkoponA2uiStreamRenderer,
|
|
1409
|
+
fn as SkoponFormRenderer,
|
|
1410
|
+
Et as a2uiToBlocks,
|
|
1411
|
+
be as blocksToA2ui,
|
|
1412
|
+
Ft as buildAskUserSurface,
|
|
1413
|
+
Se as buildCurlStatement,
|
|
1414
|
+
Te as copyTextToClipboard,
|
|
1415
|
+
In as createFormClient,
|
|
1416
|
+
Dt as extractSurfaceValues,
|
|
1417
|
+
Rt as intersectPayloadWithForm,
|
|
1418
|
+
W as isA2uiSurfaceEmpty,
|
|
1419
|
+
oe as isInputBlockType,
|
|
1420
|
+
We as isLayoutBlockType,
|
|
1421
|
+
K as isMediaBlockType,
|
|
1422
|
+
Ot as mapFormDefinitionFromDto,
|
|
1423
|
+
ve as normalizeFormDefinition,
|
|
1424
|
+
wt as resolveSurfaceFromFormDefinition,
|
|
1329
1425
|
Vt as submitFormJson,
|
|
1330
|
-
|
|
1331
|
-
|
|
1426
|
+
_t as surfaceDocToMessages,
|
|
1427
|
+
R as syncFormDefinition
|
|
1332
1428
|
};
|