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