bank20baht-ui 0.2.2 → 0.2.4
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 +12 -0
- package/dist/components/baht-form.d.ts +1 -0
- package/dist/components/base.d.ts +1 -1
- package/dist/components/primitives/baht-section.d.ts +2 -2
- package/dist/components/primitives/baht-text.d.ts +2 -2
- package/dist/core/display.d.ts +23 -0
- package/dist/core/i18n.d.ts +2 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/custom-elements.json +30 -0
- package/dist/engine.js +207 -166
- package/dist/index.js +887 -859
- package/dist/tokens.css +38 -12
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
package/dist/engine.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(e) {
|
|
2
2
|
if (e.value !== void 0) return e.value;
|
|
3
3
|
switch (e.type) {
|
|
4
4
|
case "checkbox":
|
|
@@ -35,7 +35,7 @@ const W = {
|
|
|
35
35
|
fileTypeNotAllowed: "File type not allowed",
|
|
36
36
|
fileRejectedTooLarge: "Too large, not added: {names}",
|
|
37
37
|
uploading: "Uploading…",
|
|
38
|
-
uploadFailed: "Upload failed
|
|
38
|
+
uploadFailed: "Upload failed, try again",
|
|
39
39
|
removeFile: "Remove file",
|
|
40
40
|
addRow: "Add row",
|
|
41
41
|
removeRow: "Remove row",
|
|
@@ -55,9 +55,10 @@ const W = {
|
|
|
55
55
|
nothingToReview: "Nothing to review.",
|
|
56
56
|
yes: "Yes",
|
|
57
57
|
no: "No",
|
|
58
|
-
emptyValue: "
|
|
58
|
+
emptyValue: "Not provided",
|
|
59
|
+
choose: "Select",
|
|
59
60
|
rowCount: "{n} rows"
|
|
60
|
-
},
|
|
61
|
+
}, G = {
|
|
61
62
|
required: "กรุณากรอกข้อมูลนี้",
|
|
62
63
|
minLength: "ต้องมีอย่างน้อย {n} ตัวอักษร",
|
|
63
64
|
maxLength: "ต้องไม่เกิน {n} ตัวอักษร",
|
|
@@ -75,7 +76,7 @@ const W = {
|
|
|
75
76
|
fileTypeNotAllowed: "ชนิดไฟล์ไม่ได้รับอนุญาต",
|
|
76
77
|
fileRejectedTooLarge: "ขนาดใหญ่เกินไป ไม่ถูกเพิ่ม: {names}",
|
|
77
78
|
uploading: "กำลังอัปโหลด…",
|
|
78
|
-
uploadFailed: "อัปโหลดไม่สำเร็จ
|
|
79
|
+
uploadFailed: "อัปโหลดไม่สำเร็จ ลองอีกครั้ง",
|
|
79
80
|
removeFile: "ลบไฟล์",
|
|
80
81
|
addRow: "เพิ่มแถว",
|
|
81
82
|
removeRow: "ลบแถว",
|
|
@@ -95,27 +96,28 @@ const W = {
|
|
|
95
96
|
nothingToReview: "ไม่มีข้อมูลให้ตรวจสอบ",
|
|
96
97
|
yes: "ใช่",
|
|
97
98
|
no: "ไม่ใช่",
|
|
98
|
-
emptyValue: "
|
|
99
|
+
emptyValue: "ไม่ได้ระบุ",
|
|
100
|
+
choose: "เลือก",
|
|
99
101
|
rowCount: "{n} แถว"
|
|
100
|
-
},
|
|
101
|
-
let
|
|
102
|
-
function
|
|
103
|
-
|
|
102
|
+
}, P = { en: W, th: G };
|
|
103
|
+
let R = W;
|
|
104
|
+
function me(e, t) {
|
|
105
|
+
R = { ...P[e], ...t };
|
|
104
106
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
107
|
+
function de() {
|
|
108
|
+
return R;
|
|
107
109
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
+
function pe(e) {
|
|
111
|
+
R = e;
|
|
110
112
|
}
|
|
111
113
|
function m(e, t) {
|
|
112
|
-
let n =
|
|
114
|
+
let n = R[e];
|
|
113
115
|
if (t)
|
|
114
116
|
for (const [o, r] of Object.entries(t))
|
|
115
117
|
n = n.replaceAll(`{${o}}`, () => String(r));
|
|
116
118
|
return n;
|
|
117
119
|
}
|
|
118
|
-
function
|
|
120
|
+
function J(e) {
|
|
119
121
|
if (e.kind !== "approval") return [];
|
|
120
122
|
const t = (o) => e.field_data.some((r) => r.key === o), n = [];
|
|
121
123
|
return t("decision") || n.push({ order: 9001, type: "text", key: "decision", label: m("decision") }), t("comment") || n.push({ order: 9002, type: "textarea", key: "comment", label: m("comment") }), n;
|
|
@@ -126,10 +128,10 @@ function $(e, t) {
|
|
|
126
128
|
if (n !== -1)
|
|
127
129
|
return (o = e[t.slice(0, n)]) == null ? void 0 : o[t.slice(n + 1)];
|
|
128
130
|
}
|
|
129
|
-
function
|
|
131
|
+
function O(e) {
|
|
130
132
|
return e == null ? !0 : typeof e == "string" ? e === "" : Array.isArray(e) ? e.length === 0 : !1;
|
|
131
133
|
}
|
|
132
|
-
function
|
|
134
|
+
function w(e, t) {
|
|
133
135
|
if (typeof e == "number" && typeof t == "number") return e - t;
|
|
134
136
|
if (e instanceof Date || t instanceof Date) {
|
|
135
137
|
const r = new Date(e).getTime(), s = new Date(t).getTime();
|
|
@@ -142,7 +144,7 @@ function k(e, t) {
|
|
|
142
144
|
const n = Number(e), o = Number(t);
|
|
143
145
|
return Number.isNaN(n) || Number.isNaN(o) ? null : n - o;
|
|
144
146
|
}
|
|
145
|
-
function
|
|
147
|
+
function K(e, t) {
|
|
146
148
|
const n = $(t, e.field), o = e.valueField !== void 0 ? $(t, e.valueField) : e.value;
|
|
147
149
|
switch (e.op) {
|
|
148
150
|
case "eq":
|
|
@@ -150,19 +152,19 @@ function J(e, t) {
|
|
|
150
152
|
case "ne":
|
|
151
153
|
return n !== o;
|
|
152
154
|
case "gt": {
|
|
153
|
-
const r =
|
|
155
|
+
const r = w(n, o);
|
|
154
156
|
return r !== null && r > 0;
|
|
155
157
|
}
|
|
156
158
|
case "gte": {
|
|
157
|
-
const r =
|
|
159
|
+
const r = w(n, o);
|
|
158
160
|
return r !== null && r >= 0;
|
|
159
161
|
}
|
|
160
162
|
case "lt": {
|
|
161
|
-
const r =
|
|
163
|
+
const r = w(n, o);
|
|
162
164
|
return r !== null && r < 0;
|
|
163
165
|
}
|
|
164
166
|
case "lte": {
|
|
165
|
-
const r =
|
|
167
|
+
const r = w(n, o);
|
|
166
168
|
return r !== null && r <= 0;
|
|
167
169
|
}
|
|
168
170
|
case "in":
|
|
@@ -178,23 +180,23 @@ function J(e, t) {
|
|
|
178
180
|
case "endsWith":
|
|
179
181
|
return typeof n == "string" && n.endsWith(String(o));
|
|
180
182
|
case "isEmpty":
|
|
181
|
-
return
|
|
183
|
+
return O(n);
|
|
182
184
|
case "isNotEmpty":
|
|
183
|
-
return !
|
|
185
|
+
return !O(n);
|
|
184
186
|
}
|
|
185
187
|
}
|
|
186
|
-
function
|
|
187
|
-
return e === void 0 ? !0 : "and" in e ? e.and.every((n) =>
|
|
188
|
+
function v(e, t) {
|
|
189
|
+
return e === void 0 ? !0 : "and" in e ? e.and.every((n) => v(n, t)) : "or" in e ? e.or.some((n) => v(n, t)) : "not" in e ? !v(e.not, t) : K(e, t);
|
|
188
190
|
}
|
|
189
|
-
const
|
|
191
|
+
const B = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
190
192
|
function F(e) {
|
|
191
193
|
return e == null ? !0 : typeof e == "string" ? e === "" : Array.isArray(e) ? e.length === 0 : typeof e == "boolean" ? e === !1 : !1;
|
|
192
194
|
}
|
|
193
|
-
function
|
|
195
|
+
function Y(e) {
|
|
194
196
|
const t = [...e.validators ?? []], n = (o) => t.some((r) => r.type === o);
|
|
195
197
|
return e.required && !n("required") && t.push({ type: "required" }), e.maxLength !== void 0 && !n("maxLength") && t.push({ type: "maxLength", value: e.maxLength }), e.minLength !== void 0 && !n("minLength") && t.push({ type: "minLength", value: e.minLength }), e.min !== void 0 && !n("min") && t.push({ type: "min", value: e.min }), e.max !== void 0 && !n("max") && t.push({ type: "max", value: e.max }), e.type === "email" && !n("email") && t.push({ type: "email" }), t;
|
|
196
198
|
}
|
|
197
|
-
function
|
|
199
|
+
function X(e, t, n, o) {
|
|
198
200
|
var r;
|
|
199
201
|
switch (e.type) {
|
|
200
202
|
case "required":
|
|
@@ -212,11 +214,11 @@ function Y(e, t, n, o) {
|
|
|
212
214
|
), null) : typeof t == "string" && t.length > s ? e.message ?? m("maxLength", { n: e.value }) : null;
|
|
213
215
|
}
|
|
214
216
|
case "min": {
|
|
215
|
-
const s =
|
|
217
|
+
const s = w(t, e.value);
|
|
216
218
|
return s !== null && s < 0 ? e.message ?? m("min", { n: e.value }) : null;
|
|
217
219
|
}
|
|
218
220
|
case "max": {
|
|
219
|
-
const s =
|
|
221
|
+
const s = w(t, e.value);
|
|
220
222
|
return s !== null && s > 0 ? e.message ?? m("max", { n: e.value }) : null;
|
|
221
223
|
}
|
|
222
224
|
case "pattern": {
|
|
@@ -230,15 +232,15 @@ function Y(e, t, n, o) {
|
|
|
230
232
|
return s.test(t) ? null : e.message ?? m("pattern");
|
|
231
233
|
}
|
|
232
234
|
case "email":
|
|
233
|
-
return typeof t == "string" && !
|
|
235
|
+
return typeof t == "string" && !B.test(t) ? e.message ?? m("email") : null;
|
|
234
236
|
case "compare": {
|
|
235
237
|
const s = o == null ? void 0 : o[e.field ?? ""];
|
|
236
238
|
if (s === void 0 || F(s)) return null;
|
|
237
|
-
const i =
|
|
239
|
+
const i = w(t, s);
|
|
238
240
|
if (i === null) return null;
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
const p = `compare${
|
|
241
|
+
const a = e.op ?? "eq";
|
|
242
|
+
if (a === "eq" ? i === 0 : a === "ne" ? i !== 0 : a === "gt" ? i > 0 : a === "gte" ? i >= 0 : a === "lt" ? i < 0 : i <= 0) return null;
|
|
243
|
+
const p = `compare${a[0].toUpperCase()}${a.slice(1)}`;
|
|
242
244
|
return e.message ?? m(p, { other: e.field });
|
|
243
245
|
}
|
|
244
246
|
case "custom": {
|
|
@@ -250,47 +252,47 @@ function Y(e, t, n, o) {
|
|
|
250
252
|
}
|
|
251
253
|
}
|
|
252
254
|
}
|
|
253
|
-
function
|
|
254
|
-
const r = [], s =
|
|
255
|
-
for (const
|
|
256
|
-
if (
|
|
257
|
-
const d =
|
|
255
|
+
function H(e, t, n, o) {
|
|
256
|
+
const r = [], s = Y(e), i = F(t);
|
|
257
|
+
for (const a of s) {
|
|
258
|
+
if (a.type !== "required" && i) continue;
|
|
259
|
+
const d = X(a, t, n, o);
|
|
258
260
|
d !== null && r.push({ key: e.key, message: d });
|
|
259
261
|
}
|
|
260
|
-
return e.type === "repeater" && r.push(...
|
|
262
|
+
return e.type === "repeater" && r.push(...te(e, t, n)), e.type === "file" && r.push(...ee(e, t)), r;
|
|
261
263
|
}
|
|
262
|
-
function
|
|
264
|
+
function Q(e) {
|
|
263
265
|
return e !== null && typeof e == "object" && typeof e.url == "string" && typeof e.size == "number" && typeof e.name == "string";
|
|
264
266
|
}
|
|
265
|
-
function
|
|
267
|
+
function Z(e, t, n) {
|
|
266
268
|
return e.split(",").some((o) => {
|
|
267
269
|
const r = o.trim().toLowerCase();
|
|
268
270
|
return r ? r.startsWith(".") ? t.toLowerCase().endsWith(r) : r.endsWith("/*") ? n.toLowerCase().startsWith(r.slice(0, -1)) : n.toLowerCase() === r : !1;
|
|
269
271
|
});
|
|
270
272
|
}
|
|
271
|
-
function
|
|
272
|
-
const n = (Array.isArray(t) ? t : [t]).filter(
|
|
273
|
+
function ee(e, t) {
|
|
274
|
+
const n = (Array.isArray(t) ? t : [t]).filter(Q), o = [];
|
|
273
275
|
for (const r of n)
|
|
274
|
-
e.maxSize !== void 0 && r.size > e.maxSize && o.push({ key: e.key, message: m("fileTooLarge") }), e.accept && !
|
|
276
|
+
e.maxSize !== void 0 && r.size > e.maxSize && o.push({ key: e.key, message: m("fileTooLarge") }), e.accept && !Z(e.accept, r.name ?? "", r.type ?? "") && o.push({ key: e.key, message: m("fileTypeNotAllowed") });
|
|
275
277
|
return o;
|
|
276
278
|
}
|
|
277
|
-
function
|
|
279
|
+
function te(e, t, n) {
|
|
278
280
|
if (t != null && !Array.isArray(t))
|
|
279
281
|
return [{ key: e.key, message: m("pattern") }];
|
|
280
282
|
const o = Array.isArray(t) ? t : [], r = [];
|
|
281
283
|
e.minRows !== void 0 && o.length < e.minRows && r.push({ key: e.key, message: m("minRows", { n: e.minRows }) }), e.maxRows !== void 0 && o.length > e.maxRows && r.push({ key: e.key, message: m("maxRows", { n: e.maxRows }) });
|
|
282
|
-
const s = [...e.fields ?? []].sort((i,
|
|
283
|
-
return o.forEach((i,
|
|
284
|
+
const s = [...e.fields ?? []].sort((i, a) => i.order - a.order);
|
|
285
|
+
return o.forEach((i, a) => {
|
|
284
286
|
const d = i !== null && typeof i == "object" && !Array.isArray(i) ? i : {}, p = {};
|
|
285
|
-
for (const
|
|
286
|
-
|
|
287
|
-
for (const
|
|
288
|
-
if (!(
|
|
289
|
-
for (const y of
|
|
290
|
-
r.push({ key: `${e.key}[${
|
|
287
|
+
for (const u of s)
|
|
288
|
+
u.type === "label" || u.type === "section" || u.type === "repeater" || (p[u.key] = Object.hasOwn(d, u.key) ? d[u.key] : q(u));
|
|
289
|
+
for (const u of s)
|
|
290
|
+
if (!(u.type === "label" || u.type === "section" || u.type === "repeater"))
|
|
291
|
+
for (const y of H(u, p[u.key], n, p))
|
|
292
|
+
r.push({ key: `${e.key}[${a}].${y.key}`, message: y.message });
|
|
291
293
|
}), r;
|
|
292
294
|
}
|
|
293
|
-
function
|
|
295
|
+
function ye(e, t) {
|
|
294
296
|
var r;
|
|
295
297
|
if (!t) return [...e.field_data].sort((s, i) => s.order - i.order);
|
|
296
298
|
const n = (r = e.views) == null ? void 0 : r.find((s) => s.name === t);
|
|
@@ -298,37 +300,37 @@ function ce(e, t) {
|
|
|
298
300
|
const o = new Map(e.field_data.map((s) => [s.key, s]));
|
|
299
301
|
return n.fields.map((s) => o.get(s)).filter((s) => s !== void 0);
|
|
300
302
|
}
|
|
301
|
-
function
|
|
303
|
+
function A(e, t) {
|
|
302
304
|
return e ? e.startsWith("!") ? t[e.slice(1)] !== !0 : t[e] === !0 : !0;
|
|
303
305
|
}
|
|
304
|
-
function
|
|
305
|
-
return e.filter((n) =>
|
|
306
|
+
function U(e, t) {
|
|
307
|
+
return e.filter((n) => A(n.flag, t)).map((n) => n.fields ? { ...n, fields: U(n.fields, t) } : n);
|
|
306
308
|
}
|
|
307
|
-
function
|
|
308
|
-
return e.some((t) => t.flag !== void 0 || (t.fields ?
|
|
309
|
+
function E(e) {
|
|
310
|
+
return e.some((t) => t.flag !== void 0 || (t.fields ? E(t.fields) : !1));
|
|
309
311
|
}
|
|
310
312
|
function T(e, t) {
|
|
311
|
-
if (!
|
|
312
|
-
const n =
|
|
313
|
+
if (!E(e.field_data)) return e;
|
|
314
|
+
const n = U(e.field_data, t), o = new Set(n.map((r) => r.key));
|
|
313
315
|
return {
|
|
314
316
|
...e,
|
|
315
317
|
field_data: n,
|
|
316
318
|
...e.views ? { views: e.views.map((r) => ({ ...r, fields: r.fields.filter((s) => o.has(s)) })) } : {}
|
|
317
319
|
};
|
|
318
320
|
}
|
|
319
|
-
function
|
|
321
|
+
function he(e, t = {}) {
|
|
320
322
|
if ("workflowId" in e) {
|
|
321
323
|
const n = e;
|
|
322
|
-
return n.forms.some((r) => r.flag !== void 0 ||
|
|
324
|
+
return n.forms.some((r) => r.flag !== void 0 || E(r.field_data)) || n.rules.some((r) => r.flag !== void 0) || (n.transitions ?? []).some((r) => r.flag !== void 0) ? {
|
|
323
325
|
...n,
|
|
324
|
-
forms: n.forms.filter((r) =>
|
|
325
|
-
rules: n.rules.filter((r) =>
|
|
326
|
-
...n.transitions ? { transitions: n.transitions.filter((r) =>
|
|
326
|
+
forms: n.forms.filter((r) => A(r.flag, t)).map((r) => T(r, t)),
|
|
327
|
+
rules: n.rules.filter((r) => A(r.flag, t)),
|
|
328
|
+
...n.transitions ? { transitions: n.transitions.filter((r) => A(r.flag, t)) } : {}
|
|
327
329
|
} : e;
|
|
328
330
|
}
|
|
329
331
|
return T(e, t);
|
|
330
332
|
}
|
|
331
|
-
function
|
|
333
|
+
function ne(e) {
|
|
332
334
|
if (e == null || e === "") return null;
|
|
333
335
|
const t = Number(e);
|
|
334
336
|
return Number.isNaN(t) ? null : t;
|
|
@@ -336,14 +338,14 @@ function te(e) {
|
|
|
336
338
|
function L(e) {
|
|
337
339
|
return typeof e == "number" && Number.isNaN(e) ? null : e;
|
|
338
340
|
}
|
|
339
|
-
function
|
|
341
|
+
function S(e, t) {
|
|
340
342
|
if ("ref" in e) return $(t, e.ref);
|
|
341
343
|
if ("const" in e) return e.const;
|
|
342
344
|
if ("if" in e) {
|
|
343
345
|
const [o, r, s] = e.if;
|
|
344
|
-
return
|
|
346
|
+
return v(o, t) ? L(S(r, t)) : L(S(s, t));
|
|
345
347
|
}
|
|
346
|
-
const n = e.args.map((o) => L(
|
|
348
|
+
const n = e.args.map((o) => L(S(o, t)));
|
|
347
349
|
switch (e.op) {
|
|
348
350
|
case "concat":
|
|
349
351
|
return n.map((o) => o == null ? "" : String(o)).join("");
|
|
@@ -353,7 +355,7 @@ function R(e, t) {
|
|
|
353
355
|
case "sub":
|
|
354
356
|
case "mul":
|
|
355
357
|
case "div": {
|
|
356
|
-
const o = n.map(
|
|
358
|
+
const o = n.map(ne);
|
|
357
359
|
return o.length === 0 || o.some((r) => r === null) ? null : o.reduce((r, s, i) => {
|
|
358
360
|
if (i === 0) return s;
|
|
359
361
|
switch (e.op) {
|
|
@@ -370,61 +372,61 @@ function R(e, t) {
|
|
|
370
372
|
}
|
|
371
373
|
}
|
|
372
374
|
}
|
|
373
|
-
function
|
|
374
|
-
return L(
|
|
375
|
+
function re(e, t) {
|
|
376
|
+
return L(S(e, t));
|
|
375
377
|
}
|
|
376
|
-
const M = 20,
|
|
377
|
-
function
|
|
378
|
+
const M = 20, V = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
379
|
+
function _(e, t) {
|
|
378
380
|
return e !== null && typeof e == "object" && Object.hasOwn(e, t) ? e[t] : void 0;
|
|
379
381
|
}
|
|
380
|
-
function
|
|
382
|
+
function j(e, t) {
|
|
381
383
|
if (e === t) return !0;
|
|
382
384
|
if (Array.isArray(e) && Array.isArray(t))
|
|
383
|
-
return e.length === t.length && e.every((n, o) =>
|
|
385
|
+
return e.length === t.length && e.every((n, o) => j(n, t[o]));
|
|
384
386
|
if (e !== null && t !== null && typeof e == "object" && typeof t == "object" && Object.getPrototypeOf(e) === Object.prototype && Object.getPrototypeOf(t) === Object.prototype) {
|
|
385
387
|
const n = Object.keys(e), o = Object.keys(t);
|
|
386
|
-
return n.length === o.length && n.every((r) =>
|
|
388
|
+
return n.length === o.length && n.every((r) => j(e[r], t[r]));
|
|
387
389
|
}
|
|
388
390
|
return !1;
|
|
389
391
|
}
|
|
390
|
-
function
|
|
392
|
+
function oe(e) {
|
|
391
393
|
let t;
|
|
392
394
|
for (const n of e)
|
|
393
395
|
(!t || n.priority > t.priority || n.priority === t.priority && n.index >= t.index) && (t = n);
|
|
394
396
|
return t == null ? void 0 : t.action;
|
|
395
397
|
}
|
|
396
|
-
function
|
|
398
|
+
function se(e, t) {
|
|
397
399
|
const n = [], o = /* @__PURE__ */ new Map(), r = [];
|
|
398
400
|
let s = {};
|
|
399
|
-
for (const
|
|
400
|
-
if (
|
|
401
|
-
n.push({ ref:
|
|
401
|
+
for (const u of e.forms) {
|
|
402
|
+
if (V.has(u.formName)) {
|
|
403
|
+
n.push({ ref: u.formName, message: "unsafe form name", kind: "schema" });
|
|
402
404
|
continue;
|
|
403
405
|
}
|
|
404
|
-
r.push(
|
|
405
|
-
const y = {},
|
|
406
|
-
for (const f of [...
|
|
406
|
+
r.push(u.formName);
|
|
407
|
+
const y = {}, N = _(t, u.formName);
|
|
408
|
+
for (const f of [...u.field_data, ...J(u)]) {
|
|
407
409
|
if (f.type === "label" || f.type === "section") continue;
|
|
408
|
-
if (
|
|
410
|
+
if (V.has(f.key)) {
|
|
409
411
|
n.push({
|
|
410
|
-
ref: `${
|
|
412
|
+
ref: `${u.formName}.${f.key}`,
|
|
411
413
|
message: "unsafe field key",
|
|
412
414
|
kind: "schema"
|
|
413
415
|
});
|
|
414
416
|
continue;
|
|
415
417
|
}
|
|
416
|
-
o.set(`${
|
|
417
|
-
const
|
|
418
|
-
y[f.key] =
|
|
418
|
+
o.set(`${u.formName}.${f.key}`, f);
|
|
419
|
+
const c = _(N, f.key);
|
|
420
|
+
y[f.key] = c !== void 0 ? c : q(f);
|
|
419
421
|
}
|
|
420
|
-
s[
|
|
422
|
+
s[u.formName] = y;
|
|
421
423
|
}
|
|
422
|
-
let i = {},
|
|
423
|
-
for (let
|
|
424
|
-
i = {},
|
|
425
|
-
for (const
|
|
426
|
-
for (const [
|
|
427
|
-
i[
|
|
424
|
+
let i = {}, a = {}, d = !1;
|
|
425
|
+
for (let u = 0; u < M; u++) {
|
|
426
|
+
i = {}, a = {};
|
|
427
|
+
for (const c of r) a[c] = { visible: !0 };
|
|
428
|
+
for (const [c, h] of o)
|
|
429
|
+
i[c] = {
|
|
428
430
|
visible: !0,
|
|
429
431
|
enabled: !h.disabled,
|
|
430
432
|
readonly: !!h.readonly,
|
|
@@ -432,42 +434,42 @@ function oe(e, t) {
|
|
|
432
434
|
computed: !1
|
|
433
435
|
};
|
|
434
436
|
const y = /* @__PURE__ */ new Map();
|
|
435
|
-
e.rules.forEach((
|
|
436
|
-
const
|
|
437
|
-
if (!
|
|
438
|
-
const
|
|
439
|
-
for (const g of
|
|
440
|
-
const b =
|
|
441
|
-
|
|
437
|
+
e.rules.forEach((c, h) => {
|
|
438
|
+
const l = v(c.when, s) ? c.then : c.else;
|
|
439
|
+
if (!l) return;
|
|
440
|
+
const k = c.priority ?? 0;
|
|
441
|
+
for (const g of l) {
|
|
442
|
+
const b = ie(g), x = y.get(b) ?? [];
|
|
443
|
+
x.push({ action: g, priority: k, index: h }), y.set(b, x);
|
|
442
444
|
}
|
|
443
445
|
});
|
|
444
|
-
const
|
|
445
|
-
for (const [
|
|
446
|
-
const
|
|
447
|
-
if (!
|
|
448
|
-
if (
|
|
449
|
-
|
|
446
|
+
const N = [];
|
|
447
|
+
for (const [c, h] of y) {
|
|
448
|
+
const l = oe(h);
|
|
449
|
+
if (!l) continue;
|
|
450
|
+
if (l.action === "setValue") {
|
|
451
|
+
N.push({ ref: `${l.target.form}.${l.target.field}`, action: l });
|
|
450
452
|
continue;
|
|
451
453
|
}
|
|
452
|
-
if (
|
|
453
|
-
const
|
|
454
|
-
if (!
|
|
454
|
+
if (l.action === "showForm" || l.action === "hideForm" || l.action === "skipForm") {
|
|
455
|
+
const x = a[l.target.form];
|
|
456
|
+
if (!x) {
|
|
455
457
|
n.push({
|
|
456
|
-
ref:
|
|
457
|
-
message: `rule targets unknown form (${
|
|
458
|
+
ref: l.target.form,
|
|
459
|
+
message: `rule targets unknown form (${c})`,
|
|
458
460
|
kind: "schema"
|
|
459
461
|
});
|
|
460
462
|
continue;
|
|
461
463
|
}
|
|
462
|
-
|
|
464
|
+
x.visible = l.action === "showForm";
|
|
463
465
|
continue;
|
|
464
466
|
}
|
|
465
|
-
const
|
|
467
|
+
const k = l.target, g = `${k.form}.${k.field}`, b = i[g];
|
|
466
468
|
if (!b) {
|
|
467
469
|
n.push({ ref: g, message: "rule targets unknown field", kind: "schema" });
|
|
468
470
|
continue;
|
|
469
471
|
}
|
|
470
|
-
switch (
|
|
472
|
+
switch (l.action) {
|
|
471
473
|
case "show":
|
|
472
474
|
b.visible = !0;
|
|
473
475
|
break;
|
|
@@ -492,20 +494,20 @@ function oe(e, t) {
|
|
|
492
494
|
}
|
|
493
495
|
}
|
|
494
496
|
const f = {};
|
|
495
|
-
for (const
|
|
496
|
-
for (const [
|
|
497
|
-
const [
|
|
498
|
-
(!
|
|
497
|
+
for (const c of r) f[c] = { ...s[c] };
|
|
498
|
+
for (const [c, h] of o) {
|
|
499
|
+
const [l, k] = C(c);
|
|
500
|
+
(!a[l].visible || !i[c].visible) && (f[l][k] = q(h));
|
|
499
501
|
}
|
|
500
|
-
for (const { ref:
|
|
501
|
-
const [
|
|
502
|
+
for (const { ref: c, action: h } of N) {
|
|
503
|
+
const [l, k] = C(c), g = i[c];
|
|
502
504
|
if (!g) {
|
|
503
|
-
n.push({ ref:
|
|
505
|
+
n.push({ ref: c, message: "setValue targets unknown field", kind: "schema" });
|
|
504
506
|
continue;
|
|
505
507
|
}
|
|
506
|
-
!
|
|
508
|
+
!a[l].visible || !g.visible || (f[l][k] = re(h.value, f), h.lock !== !1 && (g.readonly = !0, g.computed = !0));
|
|
507
509
|
}
|
|
508
|
-
if (
|
|
510
|
+
if (j(f, s)) {
|
|
509
511
|
d = !0, s = f;
|
|
510
512
|
break;
|
|
511
513
|
}
|
|
@@ -517,16 +519,16 @@ function oe(e, t) {
|
|
|
517
519
|
kind: "data"
|
|
518
520
|
});
|
|
519
521
|
const p = {};
|
|
520
|
-
for (const
|
|
521
|
-
if (!u
|
|
522
|
+
for (const u of r) {
|
|
523
|
+
if (!a[u].visible) continue;
|
|
522
524
|
const y = {};
|
|
523
|
-
for (const [
|
|
524
|
-
i[`${
|
|
525
|
-
p[
|
|
525
|
+
for (const [N, f] of Object.entries(s[u]))
|
|
526
|
+
i[`${u}.${N}`].visible && (y[N] = f);
|
|
527
|
+
p[u] = y;
|
|
526
528
|
}
|
|
527
|
-
return { data: p, fields: i, forms:
|
|
529
|
+
return { data: p, fields: i, forms: a, errors: n };
|
|
528
530
|
}
|
|
529
|
-
function
|
|
531
|
+
function ie(e) {
|
|
530
532
|
const t = e.action === "show" || e.action === "hide" ? "visible" : e.action === "enable" || e.action === "disable" ? "enabled" : e.action === "required" || e.action === "optional" ? "required" : e.action === "showForm" || e.action === "hideForm" || e.action === "skipForm" ? "formVisible" : e.action, n = "field" in e.target ? `${e.target.form}.${e.target.field}` : e.target.form;
|
|
531
533
|
return `${t}:${n}`;
|
|
532
534
|
}
|
|
@@ -534,8 +536,8 @@ function C(e) {
|
|
|
534
536
|
const t = e.indexOf(".");
|
|
535
537
|
return [e.slice(0, t), e.slice(t + 1)];
|
|
536
538
|
}
|
|
537
|
-
function
|
|
538
|
-
const n =
|
|
539
|
+
function z(e, t) {
|
|
540
|
+
const n = se(e, t);
|
|
539
541
|
return new Set(
|
|
540
542
|
e.forms.filter((o) => {
|
|
541
543
|
var r;
|
|
@@ -543,47 +545,86 @@ function U(e, t) {
|
|
|
543
545
|
}).map((o) => o.formName)
|
|
544
546
|
);
|
|
545
547
|
}
|
|
546
|
-
function
|
|
548
|
+
function D(e, t, n) {
|
|
547
549
|
for (const s of e.transitions ?? [])
|
|
548
|
-
if (s.from === t &&
|
|
550
|
+
if (s.from === t && v(s.when, n))
|
|
549
551
|
return s.to;
|
|
550
552
|
const o = [...e.forms].sort((s, i) => s.order - i.order), r = o.findIndex((s) => s.formName === t);
|
|
551
553
|
return r >= 0 && r + 1 < o.length ? o[r + 1].formName : "end";
|
|
552
554
|
}
|
|
553
|
-
function
|
|
554
|
-
const r = o ??
|
|
555
|
-
let i =
|
|
555
|
+
function ae(e, t, n, o) {
|
|
556
|
+
const r = o ?? z(e, n), s = /* @__PURE__ */ new Set([t]);
|
|
557
|
+
let i = D(e, t, n);
|
|
556
558
|
for (; i !== "end" && !r.has(i); ) {
|
|
557
559
|
if (s.has(i)) return "end";
|
|
558
|
-
s.add(i), i =
|
|
560
|
+
s.add(i), i = D(e, i, n);
|
|
559
561
|
}
|
|
560
562
|
return i;
|
|
561
563
|
}
|
|
562
|
-
function
|
|
564
|
+
function ge(e, t) {
|
|
563
565
|
var d;
|
|
564
|
-
const n =
|
|
566
|
+
const n = z(e, t), r = (d = [...e.forms].sort((p, u) => p.order - u.order).find((p) => n.has(p.formName))) == null ? void 0 : d.formName;
|
|
565
567
|
if (!r) return [];
|
|
566
568
|
const s = [], i = /* @__PURE__ */ new Set();
|
|
567
|
-
let
|
|
568
|
-
for (;
|
|
569
|
-
i.add(
|
|
569
|
+
let a = r;
|
|
570
|
+
for (; a !== "end" && !i.has(a); )
|
|
571
|
+
i.add(a), s.push(a), a = ae(e, a, t, n);
|
|
570
572
|
return s;
|
|
571
573
|
}
|
|
574
|
+
const ue = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0, I = (e, t) => {
|
|
575
|
+
const n = e == null ? void 0 : e.find((o) => o.key === String(t));
|
|
576
|
+
return n ? n.label : String(t);
|
|
577
|
+
}, ce = (e) => e && typeof e == "object" && "name" in e ? String(e.name) : String(e), le = (e) => {
|
|
578
|
+
const t = new Date(e);
|
|
579
|
+
return Number.isNaN(t.getTime()) ? e : /^\d{4}-\d{2}-\d{2}$/.test(e) ? (/* @__PURE__ */ new Date(e + "T00:00:00")).toLocaleDateString() : t.toLocaleString();
|
|
580
|
+
};
|
|
581
|
+
function fe(e, t, n = e.options) {
|
|
582
|
+
if (ue(t)) return { kind: "empty" };
|
|
583
|
+
switch (e.type) {
|
|
584
|
+
case "checkbox":
|
|
585
|
+
case "toggle":
|
|
586
|
+
return { kind: "text", text: m(t ? "yes" : "no") };
|
|
587
|
+
case "dropdown":
|
|
588
|
+
case "radio":
|
|
589
|
+
return { kind: "text", text: I(n, t) };
|
|
590
|
+
case "multiselect":
|
|
591
|
+
return { kind: "chips", items: (Array.isArray(t) ? t : [t]).map((r) => I(n, r)) };
|
|
592
|
+
case "date":
|
|
593
|
+
return { kind: "text", text: le(String(t)) };
|
|
594
|
+
case "file":
|
|
595
|
+
return { kind: "chips", items: (Array.isArray(t) ? t : [t]).map(ce) };
|
|
596
|
+
case "repeater": {
|
|
597
|
+
const o = Array.isArray(t) ? t : [], r = e.fields ?? [];
|
|
598
|
+
return {
|
|
599
|
+
kind: "rows",
|
|
600
|
+
rows: o.map(
|
|
601
|
+
(s) => r.filter((i) => i.type !== "label" && i.type !== "section").map((i) => {
|
|
602
|
+
const a = fe(i, s == null ? void 0 : s[i.key]), d = a.kind === "text" ? a.text : a.kind === "chips" ? a.items.join(", ") : a.kind === "rows" ? m("rowCount", { n: a.rows.length }) : m("emptyValue");
|
|
603
|
+
return { label: i.label ?? i.key, text: d };
|
|
604
|
+
})
|
|
605
|
+
)
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
default:
|
|
609
|
+
return { kind: "text", text: String(t) };
|
|
610
|
+
}
|
|
611
|
+
}
|
|
572
612
|
export {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
613
|
+
he as applyFlags,
|
|
614
|
+
J as approvalFields,
|
|
615
|
+
q as defaultValue,
|
|
616
|
+
fe as displayValue,
|
|
617
|
+
v as evalCondition,
|
|
618
|
+
re as evalValueExpr,
|
|
619
|
+
se as evaluate,
|
|
620
|
+
A as flagEnabled,
|
|
621
|
+
de as getCatalog,
|
|
581
622
|
$ as readRef,
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
623
|
+
ae as resolveNext,
|
|
624
|
+
ye as resolveViewFields,
|
|
625
|
+
pe as setCatalog,
|
|
626
|
+
me as setLocale,
|
|
586
627
|
m as t,
|
|
587
|
-
|
|
588
|
-
|
|
628
|
+
H as validateField,
|
|
629
|
+
ge as walkPath
|
|
589
630
|
};
|