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/dist/engine.js CHANGED
@@ -1,4 +1,4 @@
1
- function S(e) {
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 — try again",
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
- }, z = {
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
- }, G = { en: W, th: z };
101
- let q = W;
102
- function ae(e, t) {
103
- q = { ...G[e], ...t };
102
+ }, P = { en: W, th: G };
103
+ let R = W;
104
+ function me(e, t) {
105
+ R = { ...P[e], ...t };
104
106
  }
105
- function ue() {
106
- return q;
107
+ function de() {
108
+ return R;
107
109
  }
108
- function le(e) {
109
- q = e;
110
+ function pe(e) {
111
+ R = e;
110
112
  }
111
113
  function m(e, t) {
112
- let n = q[e];
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 P(e) {
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 j(e) {
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 k(e, t) {
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 J(e, t) {
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 = k(n, o);
155
+ const r = w(n, o);
154
156
  return r !== null && r > 0;
155
157
  }
156
158
  case "gte": {
157
- const r = k(n, o);
159
+ const r = w(n, o);
158
160
  return r !== null && r >= 0;
159
161
  }
160
162
  case "lt": {
161
- const r = k(n, o);
163
+ const r = w(n, o);
162
164
  return r !== null && r < 0;
163
165
  }
164
166
  case "lte": {
165
- const r = k(n, o);
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 j(n);
183
+ return O(n);
182
184
  case "isNotEmpty":
183
- return !j(n);
185
+ return !O(n);
184
186
  }
185
187
  }
186
- function w(e, t) {
187
- return e === void 0 ? !0 : "and" in e ? e.and.every((n) => w(n, t)) : "or" in e ? e.or.some((n) => w(n, t)) : "not" in e ? !w(e.not, t) : J(e, t);
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 K = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
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 B(e) {
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 Y(e, t, n, o) {
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 = k(t, e.value);
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 = k(t, e.value);
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" && !K.test(t) ? e.message ?? m("email") : null;
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 = k(t, s);
239
+ const i = w(t, s);
238
240
  if (i === null) return null;
239
- const u = e.op ?? "eq";
240
- if (u === "eq" ? i === 0 : u === "ne" ? i !== 0 : u === "gt" ? i > 0 : u === "gte" ? i >= 0 : u === "lt" ? i < 0 : i <= 0) return null;
241
- const p = `compare${u[0].toUpperCase()}${u.slice(1)}`;
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 X(e, t, n, o) {
254
- const r = [], s = B(e), i = F(t);
255
- for (const u of s) {
256
- if (u.type !== "required" && i) continue;
257
- const d = Y(u, t, n, o);
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(...ee(e, t, n)), e.type === "file" && r.push(...Z(e, t)), r;
262
+ return e.type === "repeater" && r.push(...te(e, t, n)), e.type === "file" && r.push(...ee(e, t)), r;
261
263
  }
262
- function H(e) {
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 Q(e, t, n) {
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 Z(e, t) {
272
- const n = (Array.isArray(t) ? t : [t]).filter(H), o = [];
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 && !Q(e.accept, r.name ?? "", r.type ?? "") && o.push({ key: e.key, message: m("fileTypeNotAllowed") });
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 ee(e, t, n) {
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, u) => i.order - u.order);
283
- return o.forEach((i, u) => {
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 a of s)
286
- a.type === "label" || a.type === "section" || a.type === "repeater" || (p[a.key] = Object.hasOwn(d, a.key) ? d[a.key] : S(a));
287
- for (const a of s)
288
- if (!(a.type === "label" || a.type === "section" || a.type === "repeater"))
289
- for (const y of X(a, p[a.key], n, p))
290
- r.push({ key: `${e.key}[${u}].${y.key}`, message: y.message });
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 ce(e, t) {
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 x(e, t) {
303
+ function A(e, t) {
302
304
  return e ? e.startsWith("!") ? t[e.slice(1)] !== !0 : t[e] === !0 : !0;
303
305
  }
304
- function D(e, t) {
305
- return e.filter((n) => x(n.flag, t)).map((n) => n.fields ? { ...n, fields: D(n.fields, t) } : 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 O(e) {
308
- return e.some((t) => t.flag !== void 0 || (t.fields ? O(t.fields) : !1));
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 (!O(e.field_data)) return e;
312
- const n = D(e.field_data, t), o = new Set(n.map((r) => r.key));
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 fe(e, t = {}) {
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 || O(r.field_data)) || n.rules.some((r) => r.flag !== void 0) || (n.transitions ?? []).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) => x(r.flag, t)).map((r) => T(r, t)),
325
- rules: n.rules.filter((r) => x(r.flag, t)),
326
- ...n.transitions ? { transitions: n.transitions.filter((r) => x(r.flag, t)) } : {}
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 te(e) {
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 R(e, t) {
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 w(o, t) ? L(R(r, t)) : L(R(s, t));
346
+ return v(o, t) ? L(S(r, t)) : L(S(s, t));
345
347
  }
346
- const n = e.args.map((o) => L(R(o, t)));
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(te);
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 ne(e, t) {
374
- return L(R(e, t));
375
+ function re(e, t) {
376
+ return L(S(e, t));
375
377
  }
376
- const M = 20, _ = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
377
- function V(e, t) {
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 E(e, t) {
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) => E(n, t[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) => E(e[r], t[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 re(e) {
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 oe(e, t) {
398
+ function se(e, t) {
397
399
  const n = [], o = /* @__PURE__ */ new Map(), r = [];
398
400
  let s = {};
399
- for (const a of e.forms) {
400
- if (_.has(a.formName)) {
401
- n.push({ ref: a.formName, message: "unsafe form name", kind: "schema" });
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(a.formName);
405
- const y = {}, v = V(t, a.formName);
406
- for (const f of [...a.field_data, ...P(a)]) {
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 (_.has(f.key)) {
410
+ if (V.has(f.key)) {
409
411
  n.push({
410
- ref: `${a.formName}.${f.key}`,
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(`${a.formName}.${f.key}`, f);
417
- const l = V(v, f.key);
418
- y[f.key] = l !== void 0 ? l : S(f);
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[a.formName] = y;
422
+ s[u.formName] = y;
421
423
  }
422
- let i = {}, u = {}, d = !1;
423
- for (let a = 0; a < M; a++) {
424
- i = {}, u = {};
425
- for (const l of r) u[l] = { visible: !0 };
426
- for (const [l, h] of o)
427
- i[l] = {
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((l, h) => {
436
- const c = w(l.when, s) ? l.then : l.else;
437
- if (!c) return;
438
- const N = l.priority ?? 0;
439
- for (const g of c) {
440
- const b = se(g), A = y.get(b) ?? [];
441
- A.push({ action: g, priority: N, index: h }), y.set(b, A);
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 v = [];
445
- for (const [l, h] of y) {
446
- const c = re(h);
447
- if (!c) continue;
448
- if (c.action === "setValue") {
449
- v.push({ ref: `${c.target.form}.${c.target.field}`, action: c });
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 (c.action === "showForm" || c.action === "hideForm" || c.action === "skipForm") {
453
- const A = u[c.target.form];
454
- if (!A) {
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: c.target.form,
457
- message: `rule targets unknown form (${l})`,
458
+ ref: l.target.form,
459
+ message: `rule targets unknown form (${c})`,
458
460
  kind: "schema"
459
461
  });
460
462
  continue;
461
463
  }
462
- A.visible = c.action === "showForm";
464
+ x.visible = l.action === "showForm";
463
465
  continue;
464
466
  }
465
- const N = c.target, g = `${N.form}.${N.field}`, b = i[g];
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 (c.action) {
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 l of r) f[l] = { ...s[l] };
496
- for (const [l, h] of o) {
497
- const [c, N] = C(l);
498
- (!u[c].visible || !i[l].visible) && (f[c][N] = S(h));
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: l, action: h } of v) {
501
- const [c, N] = C(l), g = i[l];
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: l, message: "setValue targets unknown field", kind: "schema" });
505
+ n.push({ ref: c, message: "setValue targets unknown field", kind: "schema" });
504
506
  continue;
505
507
  }
506
- !u[c].visible || !g.visible || (f[c][N] = ne(h.value, f), h.lock !== !1 && (g.readonly = !0, g.computed = !0));
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 (E(f, s)) {
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 a of r) {
521
- if (!u[a].visible) continue;
522
+ for (const u of r) {
523
+ if (!a[u].visible) continue;
522
524
  const y = {};
523
- for (const [v, f] of Object.entries(s[a]))
524
- i[`${a}.${v}`].visible && (y[v] = f);
525
- p[a] = y;
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: u, errors: n };
529
+ return { data: p, fields: i, forms: a, errors: n };
528
530
  }
529
- function se(e) {
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 U(e, t) {
538
- const n = oe(e, t);
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 I(e, t, n) {
548
+ function D(e, t, n) {
547
549
  for (const s of e.transitions ?? [])
548
- if (s.from === t && w(s.when, n))
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 ie(e, t, n, o) {
554
- const r = o ?? U(e, n), s = /* @__PURE__ */ new Set([t]);
555
- let i = I(e, t, n);
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 = I(e, i, n);
560
+ s.add(i), i = D(e, i, n);
559
561
  }
560
562
  return i;
561
563
  }
562
- function me(e, t) {
564
+ function ge(e, t) {
563
565
  var d;
564
- const n = U(e, t), r = (d = [...e.forms].sort((p, a) => p.order - a.order).find((p) => n.has(p.formName))) == null ? void 0 : d.formName;
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 u = r;
568
- for (; u !== "end" && !i.has(u); )
569
- i.add(u), s.push(u), u = ie(e, u, t, n);
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
- fe as applyFlags,
574
- P as approvalFields,
575
- S as defaultValue,
576
- w as evalCondition,
577
- ne as evalValueExpr,
578
- oe as evaluate,
579
- x as flagEnabled,
580
- ue as getCatalog,
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
- ie as resolveNext,
583
- ce as resolveViewFields,
584
- le as setCatalog,
585
- ae as setLocale,
623
+ ae as resolveNext,
624
+ ye as resolveViewFields,
625
+ pe as setCatalog,
626
+ me as setLocale,
586
627
  m as t,
587
- X as validateField,
588
- me as walkPath
628
+ H as validateField,
629
+ ge as walkPath
589
630
  };