@golemui/gui-shared 0.17.0 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1542 +0,0 @@
1
- import "@golemui/core";
2
- const R = {
3
- INPUTS: "INPUTS",
4
- ACTIONS: "ACTIONS",
5
- LAYOUTS: "LAYOUTS",
6
- DISPLAYS: "DISPLAYS"
7
- };
8
- function N(e) {
9
- return function(t, s = () => !0) {
10
- return {
11
- kind: "leaf",
12
- selectorType: e,
13
- matcher: s,
14
- config: t
15
- };
16
- };
17
- }
18
- function g(e, t) {
19
- return typeof e == "function" ? e : { type: t, ...e ?? {} };
20
- }
21
- const K = (e, t) => ({
22
- type: "ITEMS",
23
- itemType: R.DISPLAYS,
24
- items: [{ render: e }],
25
- tags: t ?? []
26
- }), f = /* @__PURE__ */ new Map();
27
- function x(e, t) {
28
- if (f.has(e))
29
- throw new Error(`Item type "${e}" is already registered.`);
30
- f.set(e, t);
31
- }
32
- function C(e) {
33
- const t = f.get(e);
34
- if (!t)
35
- throw new Error(
36
- `No handler registered for item type "${e}". Did you forget to import the registration module?`
37
- );
38
- return t;
39
- }
40
- function F(e) {
41
- return f.has(e);
42
- }
43
- function c(e) {
44
- const t = (o) => {
45
- if (!e.sensibleDefaults)
46
- return {};
47
- let r = { ...e.sensibleDefaults.base };
48
- for (const u of o) {
49
- const p = u.config;
50
- for (const d of e.sensibleDefaults.fields) {
51
- const y = d;
52
- p[y] != null && (r = { ...r, [y]: p[y] });
53
- }
54
- }
55
- return r;
56
- }, s = (o, r) => e.sensibleDefaults ? e.sensibleDefaults.apply(o, r) : o, a = (o) => {
57
- switch (e.entryShape) {
58
- case "bare":
59
- return { baseDef: o };
60
- case "keyed": {
61
- const r = o;
62
- return { baseDef: r.def, path: r.key };
63
- }
64
- case "compound": {
65
- const r = o;
66
- return { baseDef: r.def, children: r.children };
67
- }
68
- }
69
- }, l = {
70
- rollUpSensibleDefaults: t,
71
- applySensibleDefaults: s,
72
- mapToWidget: e.mapToWidget,
73
- parseEntry: a,
74
- ...e.afterMerge ? { afterMerge: e.afterMerge } : {},
75
- ...e.buildCustomWidget ? { buildCustomWidget: e.buildCustomWidget } : {},
76
- ...e.getChildren ? { getChildren: e.getChildren } : {}
77
- };
78
- x(e.itemType, l);
79
- const n = N(e.itemType);
80
- return { gsl: n, gslByUid: (o, r) => n(r, ((u) => u.uid === o)) };
81
- }
82
- function b(e) {
83
- const {
84
- uid: t,
85
- path: s,
86
- label: a,
87
- disabled: l,
88
- readonly: n,
89
- defaultValue: i,
90
- tags: o,
91
- type: r,
92
- size: u,
93
- onLoad: p,
94
- onChange: d,
95
- onFilter: y,
96
- on: A,
97
- states: k,
98
- include: v,
99
- exclude: E,
100
- validator: P,
101
- ..._
102
- } = e;
103
- return _;
104
- }
105
- function V(e) {
106
- return e ? e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (t) => t.toUpperCase()) : "";
107
- }
108
- function m(e, t) {
109
- return e.label != null || t.suppressAutomaticLabels || !e.path ? e : { ...e, label: V(e.path) };
110
- }
111
- function S(e, t) {
112
- return e.placeholder != null || t.suppressAutomaticPlaceholders || !e.path ? e : { ...e, placeholder: e.path };
113
- }
114
- function G(e) {
115
- switch (e.type) {
116
- case "text":
117
- return H(e);
118
- case "number":
119
- return Z(e);
120
- case "boolean":
121
- return X(e);
122
- default:
123
- throw new Error(`Unsupported field type "${e.type}"`);
124
- }
125
- }
126
- function X(e) {
127
- const t = b(e);
128
- return {
129
- uid: e.uid ?? "",
130
- kind: "input",
131
- type: "toggle",
132
- path: e.path ?? "",
133
- ...e.label != null ? { label: e.label } : {},
134
- ...e.disabled != null ? { disabled: e.disabled } : {},
135
- ...e.readonly != null ? { readonly: e.readonly } : {},
136
- ...e.validator != null ? { validator: g(e.validator, "boolean") } : {},
137
- props: t
138
- };
139
- }
140
- function H(e) {
141
- const t = b(e);
142
- return {
143
- uid: e.uid ?? "",
144
- kind: "input",
145
- type: "textinput",
146
- path: e.path ?? "",
147
- ...e.label != null ? { label: e.label } : {},
148
- ...e.disabled != null ? { disabled: e.disabled } : {},
149
- ...e.readonly != null ? { readonly: e.readonly } : {},
150
- props: {
151
- placeholder: t.placeholder ?? "",
152
- ...t
153
- },
154
- validator: g(e.validator, "string")
155
- };
156
- }
157
- function Z(e) {
158
- const t = b(e);
159
- return {
160
- uid: e.uid ?? "",
161
- kind: "input",
162
- type: "number",
163
- path: e.path ?? "",
164
- ...e.label != null ? { label: e.label } : {},
165
- ...e.disabled != null ? { disabled: e.disabled } : {},
166
- ...e.readonly != null ? { readonly: e.readonly } : {},
167
- props: {
168
- placeholder: t.placeholder ?? "",
169
- ...t
170
- },
171
- validator: g(e.validator, "number")
172
- };
173
- }
174
- const { gsl: Ye, gslByUid: ze } = c({
175
- itemType: "INPUTS",
176
- entryShape: "keyed",
177
- sensibleDefaults: {
178
- base: {
179
- suppressAutomaticLabels: !1,
180
- suppressAutomaticPlaceholders: !1
181
- },
182
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
183
- apply: (e, t) => {
184
- let s = m(e, t);
185
- return s = S(s, t), s;
186
- }
187
- },
188
- mapToWidget: G
189
- }), { gsl: Ke, gslByUid: Ve } = c({
190
- itemType: "SELECT",
191
- entryShape: "keyed",
192
- sensibleDefaults: {
193
- base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
194
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
195
- apply: (e, t) => S(m(e, t), t)
196
- },
197
- mapToWidget: (e) => ({
198
- uid: e.uid ?? "",
199
- kind: "input",
200
- type: "select",
201
- path: e.path ?? "",
202
- ...e.label != null ? { label: e.label } : {},
203
- ...e.disabled != null ? { disabled: e.disabled } : {},
204
- ...e.readonly != null ? { readonly: e.readonly } : {},
205
- ...e.validator != null ? { validator: e.validator } : {},
206
- props: b(e)
207
- })
208
- }), { gsl: Ge, gslByUid: Xe } = c({
209
- itemType: "DROPDOWN",
210
- entryShape: "keyed",
211
- sensibleDefaults: {
212
- base: {
213
- suppressAutomaticLabels: !1,
214
- suppressAutomaticPlaceholders: !1
215
- },
216
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
217
- apply: (e, t) => S(m(e, t), t)
218
- },
219
- mapToWidget: (e) => ({
220
- uid: e.uid ?? "",
221
- kind: "input",
222
- type: "dropdown",
223
- path: e.path ?? "",
224
- ...e.label != null ? { label: e.label } : {},
225
- ...e.disabled != null ? { disabled: e.disabled } : {},
226
- ...e.readonly != null ? { readonly: e.readonly } : {},
227
- ...e.validator != null ? { validator: e.validator } : {},
228
- props: b(e)
229
- })
230
- }), { gsl: He, gslByUid: Ze } = c({
231
- itemType: "RADIOGROUP",
232
- entryShape: "keyed",
233
- sensibleDefaults: {
234
- base: { suppressAutomaticLabels: !1 },
235
- fields: ["suppressAutomaticLabels"],
236
- apply: (e, t) => m(e, t)
237
- },
238
- mapToWidget: (e) => ({
239
- uid: e.uid ?? "",
240
- kind: "input",
241
- type: "radiogroup",
242
- path: e.path ?? "",
243
- ...e.label != null ? { label: e.label } : {},
244
- ...e.disabled != null ? { disabled: e.disabled } : {},
245
- ...e.readonly != null ? { readonly: e.readonly } : {},
246
- ...e.validator != null ? { validator: e.validator } : {},
247
- props: b(e)
248
- })
249
- }), { gsl: qe, gslByUid: Je } = c({
250
- itemType: "CHECKBOX",
251
- entryShape: "keyed",
252
- sensibleDefaults: {
253
- base: { suppressAutomaticLabels: !1 },
254
- fields: ["suppressAutomaticLabels"],
255
- apply: (e, t) => m(e, t)
256
- },
257
- mapToWidget: (e) => ({
258
- uid: e.uid ?? "",
259
- kind: "input",
260
- type: "checkbox",
261
- path: e.path ?? "",
262
- ...e.label != null ? { label: e.label } : {},
263
- ...e.disabled != null ? { disabled: e.disabled } : {},
264
- ...e.readonly != null ? { readonly: e.readonly } : {},
265
- ...e.validator != null ? { validator: g(e.validator, "boolean") } : {},
266
- props: b(e)
267
- })
268
- }), { gsl: Qe, gslByUid: et } = c({
269
- itemType: "TEXTAREA",
270
- entryShape: "keyed",
271
- sensibleDefaults: {
272
- base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
273
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
274
- apply: (e, t) => S(m(e, t), t)
275
- },
276
- mapToWidget: (e) => ({
277
- uid: e.uid ?? "",
278
- kind: "input",
279
- type: "textarea",
280
- path: e.path ?? "",
281
- ...e.label != null ? { label: e.label } : {},
282
- ...e.disabled != null ? { disabled: e.disabled } : {},
283
- ...e.readonly != null ? { readonly: e.readonly } : {},
284
- ...e.validator != null ? { validator: g(e.validator, "string") } : {},
285
- props: b(e)
286
- })
287
- }), { gsl: tt, gslByUid: st } = c({
288
- itemType: "PASSWORD",
289
- entryShape: "keyed",
290
- sensibleDefaults: {
291
- base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
292
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
293
- apply: (e, t) => S(m(e, t), t)
294
- },
295
- mapToWidget: (e) => ({
296
- uid: e.uid ?? "",
297
- kind: "input",
298
- type: "password",
299
- path: e.path ?? "",
300
- ...e.label != null ? { label: e.label } : {},
301
- ...e.disabled != null ? { disabled: e.disabled } : {},
302
- ...e.readonly != null ? { readonly: e.readonly } : {},
303
- ...e.validator != null ? { validator: g(e.validator, "string") } : {},
304
- props: b(e)
305
- })
306
- }), { gsl: lt, gslByUid: at } = c({
307
- itemType: "CURRENCY",
308
- entryShape: "keyed",
309
- sensibleDefaults: {
310
- base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
311
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
312
- apply: (e, t) => S(m(e, t), t)
313
- },
314
- mapToWidget: (e) => ({
315
- uid: e.uid ?? "",
316
- kind: "input",
317
- type: "currency",
318
- path: e.path ?? "",
319
- ...e.label != null ? { label: e.label } : {},
320
- ...e.disabled != null ? { disabled: e.disabled } : {},
321
- ...e.readonly != null ? { readonly: e.readonly } : {},
322
- ...e.validator != null ? { validator: g(e.validator, "number") } : {},
323
- props: b(e)
324
- })
325
- }), { gsl: nt, gslByUid: it } = c({
326
- itemType: "MARKDOWN",
327
- entryShape: "keyed",
328
- sensibleDefaults: {
329
- base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
330
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
331
- apply: (e, t) => S(m(e, t), t)
332
- },
333
- mapToWidget: (e) => ({
334
- uid: e.uid ?? "",
335
- kind: "input",
336
- type: "markdown",
337
- path: e.path ?? "",
338
- ...e.label != null ? { label: e.label } : {},
339
- ...e.disabled != null ? { disabled: e.disabled } : {},
340
- ...e.readonly != null ? { readonly: e.readonly } : {},
341
- ...e.validator != null ? { validator: g(e.validator, "string") } : {},
342
- props: b(e)
343
- })
344
- }), { gsl: rt, gslByUid: ot } = c({
345
- itemType: "LIST",
346
- entryShape: "keyed",
347
- sensibleDefaults: {
348
- base: { suppressAutomaticLabels: !1 },
349
- fields: ["suppressAutomaticLabels"],
350
- apply: (e, t) => m(e, t)
351
- },
352
- mapToWidget: (e) => ({
353
- uid: e.uid ?? "",
354
- kind: "input",
355
- type: "list",
356
- path: e.path ?? "",
357
- ...e.label != null ? { label: e.label } : {},
358
- ...e.disabled != null ? { disabled: e.disabled } : {},
359
- ...e.readonly != null ? { readonly: e.readonly } : {},
360
- ...e.validator != null ? { validator: e.validator } : {},
361
- props: b(e)
362
- })
363
- }), { gsl: ut, gslByUid: pt } = c({
364
- itemType: "CALENDAR",
365
- entryShape: "bare",
366
- sensibleDefaults: {
367
- base: { suppressAutomaticLabels: !1 },
368
- fields: ["suppressAutomaticLabels"],
369
- apply: (e, t) => m(e, t)
370
- },
371
- mapToWidget: (e) => ({
372
- uid: e.uid ?? "",
373
- kind: "input",
374
- type: "calendar",
375
- path: e.path ?? "",
376
- ...e.label != null ? { label: e.label } : {},
377
- ...e.disabled != null ? { disabled: e.disabled } : {},
378
- ...e.readonly != null ? { readonly: e.readonly } : {},
379
- ...e.validator != null ? { validator: g(e.validator, "string") } : {},
380
- props: b(e)
381
- })
382
- }), { gsl: ct, gslByUid: dt } = c({
383
- itemType: "DATE_INPUT",
384
- entryShape: "keyed",
385
- sensibleDefaults: {
386
- base: { suppressAutomaticLabels: !1 },
387
- fields: ["suppressAutomaticLabels"],
388
- apply: (e, t) => m(e, t)
389
- },
390
- mapToWidget: (e) => ({
391
- uid: e.uid ?? "",
392
- kind: "input",
393
- type: "dateInput",
394
- path: e.path ?? "",
395
- ...e.label != null ? { label: e.label } : {},
396
- ...e.disabled != null ? { disabled: e.disabled } : {},
397
- ...e.readonly != null ? { readonly: e.readonly } : {},
398
- ...e.validator != null ? { validator: g(e.validator, "string") } : {},
399
- props: b(e)
400
- })
401
- }), { gsl: yt, gslByUid: bt } = c({
402
- itemType: "DATE_PICKER",
403
- entryShape: "keyed",
404
- sensibleDefaults: {
405
- base: {
406
- suppressAutomaticLabels: !1,
407
- suppressAutomaticPlaceholders: !1
408
- },
409
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
410
- apply: (e, t) => S(m(e, t), t)
411
- },
412
- mapToWidget: (e) => ({
413
- uid: e.uid ?? "",
414
- kind: "input",
415
- type: "datePicker",
416
- path: e.path ?? "",
417
- ...e.label != null ? { label: e.label } : {},
418
- ...e.disabled != null ? { disabled: e.disabled } : {},
419
- ...e.readonly != null ? { readonly: e.readonly } : {},
420
- ...e.validator != null ? { validator: g(e.validator, "string") } : {},
421
- props: b(e)
422
- })
423
- }), { gsl: mt, gslByUid: ht } = c({
424
- itemType: "RANGE_CALENDAR",
425
- entryShape: "keyed",
426
- sensibleDefaults: {
427
- base: { suppressAutomaticLabels: !1 },
428
- fields: ["suppressAutomaticLabels"],
429
- apply: (e, t) => m(e, t)
430
- },
431
- mapToWidget: (e) => ({
432
- uid: e.uid ?? "",
433
- kind: "input",
434
- type: "rangeCalendar",
435
- path: e.path ?? "",
436
- ...e.label != null ? { label: e.label } : {},
437
- ...e.disabled != null ? { disabled: e.disabled } : {},
438
- ...e.readonly != null ? { readonly: e.readonly } : {},
439
- ...e.validator != null ? { validator: g(e.validator, "array") } : {},
440
- props: b(e)
441
- })
442
- }), { gsl: gt, gslByUid: Tt } = c({
443
- itemType: "RANGE_DATE_INPUT",
444
- entryShape: "keyed",
445
- sensibleDefaults: {
446
- base: { suppressAutomaticLabels: !1 },
447
- fields: ["suppressAutomaticLabels"],
448
- apply: (e, t) => m(e, t)
449
- },
450
- mapToWidget: (e) => ({
451
- uid: e.uid ?? "",
452
- kind: "input",
453
- type: "rangeDateInput",
454
- path: e.path ?? "",
455
- ...e.label != null ? { label: e.label } : {},
456
- ...e.disabled != null ? { disabled: e.disabled } : {},
457
- ...e.readonly != null ? { readonly: e.readonly } : {},
458
- ...e.validator != null ? { validator: g(e.validator, "array") } : {},
459
- props: b(e)
460
- })
461
- }), { gsl: St, gslByUid: At } = c({
462
- itemType: "RANGE_DATE_PICKER",
463
- entryShape: "keyed",
464
- sensibleDefaults: {
465
- base: {
466
- suppressAutomaticLabels: !1,
467
- suppressAutomaticPlaceholders: !1
468
- },
469
- fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
470
- apply: (e, t) => S(m(e, t), t)
471
- },
472
- mapToWidget: (e) => ({
473
- uid: e.uid ?? "",
474
- kind: "input",
475
- type: "rangeDatePicker",
476
- path: e.path ?? "",
477
- ...e.label != null ? { label: e.label } : {},
478
- ...e.disabled != null ? { disabled: e.disabled } : {},
479
- ...e.readonly != null ? { readonly: e.readonly } : {},
480
- ...e.validator != null ? { validator: g(e.validator, "array") } : {},
481
- props: b(e)
482
- })
483
- });
484
- function q(e) {
485
- const t = {};
486
- return e.addLabel != null && (t.addLabel = e.addLabel), e.removeLabel != null && (t.removeLabel = e.removeLabel), e.limit != null && (t.limit = e.limit), e.title != null && (t.title = e.title), e.addButtonIcon != null && (t.addButtonIcon = e.addButtonIcon), e.removeButtonIcon != null && (t.removeButtonIcon = e.removeButtonIcon), t;
487
- }
488
- function J(e) {
489
- return {
490
- uid: e.uid ?? "",
491
- kind: "input",
492
- type: "repeater",
493
- path: e.path ?? "",
494
- ...e.label != null ? { label: e.label } : {},
495
- ...e.disabled != null ? { disabled: e.disabled } : {},
496
- ...e.readonly != null ? { readonly: e.readonly } : {},
497
- ...e.validator != null ? { validator: g(e.validator, "array") } : {},
498
- props: {
499
- ...q(e),
500
- template: { kind: "layout", type: "flex", children: [], props: { direction: "column" } }
501
- }
502
- };
503
- }
504
- function L(e, t) {
505
- for (const s of e) {
506
- if (typeof s == "function") continue;
507
- const a = s;
508
- typeof a.path == "string" && a.path && (a.path = t + a.path), "children" in a && Array.isArray(a.children) && L(a.children, t);
509
- const l = a.props;
510
- l?.template?.children && Array.isArray(l.template.children) && L(l.template.children, t);
511
- }
512
- }
513
- function Q(e, t) {
514
- const s = t.walkChildren(t.children ?? []), a = e.kind === "static" ? e.def.path ?? "" : e.fn({})?.path ?? "";
515
- a && L(s, a + ".items.");
516
- const l = {
517
- kind: "layout",
518
- type: "flex",
519
- uid: "",
520
- children: s,
521
- props: { direction: "column" }
522
- };
523
- if (e.kind === "static") {
524
- const i = t.mapStaticDef(e.def, "REPEATER");
525
- return {
526
- ...i,
527
- props: { ...i.props, template: l }
528
- };
529
- }
530
- const n = e.fn;
531
- return ((i) => {
532
- const o = n(i), r = t.mapStaticDef(o, "REPEATER");
533
- return {
534
- ...r,
535
- props: { ...r.props, template: l }
536
- };
537
- });
538
- }
539
- function ee(e) {
540
- return {
541
- baseDef: e.def,
542
- path: e.key,
543
- children: e.children
544
- };
545
- }
546
- function te(e) {
547
- return e.children;
548
- }
549
- const se = {
550
- parseEntry: ee,
551
- rollUpSensibleDefaults: () => ({}),
552
- applySensibleDefaults: (e) => e,
553
- mapToWidget: J,
554
- buildCustomWidget: Q,
555
- getChildren: te
556
- };
557
- x("REPEATER", se);
558
- const le = N("REPEATER"), _t = (e, t) => le(t, ((s) => s.uid === e)), j = {
559
- onLoad: "load",
560
- onChange: "change",
561
- onFilter: "filter",
562
- onBlur: "blur"
563
- }, ae = Object.keys(j);
564
- class ne {
565
- // ── Action-specific: onClick ───────────────────────────────────
566
- extractOnClickFromMergeResult(t, s, a) {
567
- if (t.kind === "dynamic") {
568
- const i = t.fn;
569
- return { kind: "dynamic", fn: (r) => {
570
- const u = i(r);
571
- return this.wireOnClick(u, s, a);
572
- } };
573
- }
574
- const l = t.def;
575
- return { kind: "static", def: this.wireOnClick(l, s, a) };
576
- }
577
- wireOnClick(t, s, a) {
578
- const l = a.next(), n = t.onClick;
579
- if (typeof n == "function") {
580
- const { onClick: i, ...o } = t, r = n(void 0);
581
- return typeof r == "string" ? { ...o, uid: l, on: { click: r } } : (s.set(l, (u) => n(u.data)), { ...o, uid: l, on: { click: l } });
582
- }
583
- return { ...t, uid: l };
584
- }
585
- // ── Universal: onLoad, onChange, onFilter ──────────────────────
586
- wireInputLayoutEvents(t, s, a) {
587
- if (t.kind === "dynamic") {
588
- const n = t.fn;
589
- return { kind: "dynamic", fn: (o) => {
590
- const r = n(o);
591
- return this.wireEventProperties(r, s, a);
592
- } };
593
- }
594
- return { kind: "static", def: this.wireEventProperties(t.def, s, a) };
595
- }
596
- wireEventProperties(t, s, a) {
597
- const l = { ...t.on || {} };
598
- let n = !1;
599
- const i = { ...t };
600
- for (const o of ae) {
601
- const r = t[o];
602
- if (r == null) continue;
603
- const u = j[o];
604
- if (typeof r == "function") {
605
- const p = a.next();
606
- s.set(p, r), l[u] = p, n = !0;
607
- } else typeof r == "string" && (l[u] = r, n = !0);
608
- delete i[o];
609
- }
610
- return n && (i.on = l), i;
611
- }
612
- }
613
- const D = new ne();
614
- function ie(e) {
615
- const {
616
- uid: t,
617
- label: s,
618
- actionType: a,
619
- disabled: l,
620
- on: n,
621
- onClick: i,
622
- data: o,
623
- type: r,
624
- tags: u,
625
- size: p,
626
- include: d,
627
- exclude: y,
628
- states: A,
629
- ...k
630
- } = e;
631
- return {
632
- uid: t ?? "",
633
- kind: "action",
634
- type: "button",
635
- disabled: l,
636
- actionType: a,
637
- label: s,
638
- ...n != null ? { on: n } : {},
639
- props: k
640
- };
641
- }
642
- const { gsl: kt, gslByUid: vt } = c({
643
- itemType: "ACTIONS",
644
- entryShape: "bare",
645
- mapToWidget: ie,
646
- afterMerge: (e, t) => D.extractOnClickFromMergeResult(
647
- e,
648
- t.eventRegistry,
649
- t.eventIdGenerator
650
- )
651
- });
652
- function re(e) {
653
- const {
654
- uid: t,
655
- widgetName: s,
656
- tags: a,
657
- size: l,
658
- onChange: n,
659
- include: i,
660
- exclude: o,
661
- ...r
662
- } = e, { on: u, ...p } = r;
663
- return {
664
- uid: t ?? "",
665
- kind: "layout",
666
- type: s ?? "flex",
667
- props: {
668
- direction: p.direction ?? "column",
669
- ...p
670
- },
671
- children: []
672
- };
673
- }
674
- function oe(e, t) {
675
- const s = t.walkChildren(t.children ?? []);
676
- if (e.kind === "static")
677
- return { ...t.mapStaticDef(e.def, "LAYOUTS"), children: s };
678
- const a = e.fn;
679
- return ((l) => {
680
- const n = a(l);
681
- return { ...t.mapStaticDef(n, "LAYOUTS"), children: s };
682
- });
683
- }
684
- function ue(e) {
685
- return e.children;
686
- }
687
- const { gsl: ft, gslByUid: Ct } = c({
688
- itemType: "LAYOUTS",
689
- entryShape: "compound",
690
- mapToWidget: re,
691
- buildCustomWidget: oe,
692
- getChildren: ue
693
- });
694
- function pe(e) {
695
- return {
696
- uid: "",
697
- kind: "display",
698
- type: "renderer",
699
- props: { render: e.render }
700
- };
701
- }
702
- function ce(e, t) {
703
- if (e.kind === "static") {
704
- const a = e.def;
705
- return ((l) => ({
706
- uid: "",
707
- kind: "display",
708
- type: "renderer",
709
- ...a.include != null ? { include: a.include } : {},
710
- ...a.exclude != null ? { exclude: a.exclude } : {},
711
- props: { render: a.render(l ?? {}) }
712
- }));
713
- }
714
- const s = e.fn;
715
- return ((a) => {
716
- const l = s(a);
717
- return {
718
- uid: "",
719
- kind: "display",
720
- type: "renderer",
721
- ...l.include != null ? { include: l.include } : {},
722
- ...l.exclude != null ? { exclude: l.exclude } : {},
723
- props: { render: l.render(a ?? {}) }
724
- };
725
- });
726
- }
727
- const { gsl: Ut, gslByUid: Ot } = c({
728
- itemType: "DISPLAYS",
729
- entryShape: "bare",
730
- mapToWidget: pe,
731
- buildCustomWidget: ce
732
- }), { gsl: Lt, gslByUid: Dt } = c({
733
- itemType: "ALERTS",
734
- entryShape: "bare",
735
- mapToWidget: (e) => ({
736
- uid: e.uid ?? "",
737
- kind: "display",
738
- type: "alert",
739
- props: {
740
- text: e.text,
741
- ...e.level != null ? { level: e.level } : {}
742
- }
743
- })
744
- });
745
- function de(e) {
746
- return {
747
- uid: e.uid ?? "",
748
- kind: "layout",
749
- type: "tabs",
750
- props: {
751
- tabs: e.tabs,
752
- renderMode: e.renderMode ?? "all",
753
- ...e.defaultOpen != null ? { defaultOpen: e.defaultOpen } : {}
754
- },
755
- children: []
756
- };
757
- }
758
- function ye(e, t) {
759
- const s = t.walkChildren(t.children ?? []);
760
- if (e.kind === "static")
761
- return { ...t.mapStaticDef(e.def, "TABS"), children: s };
762
- const a = e.fn;
763
- return ((l) => {
764
- const n = a(l);
765
- return { ...t.mapStaticDef(n, "TABS"), children: s };
766
- });
767
- }
768
- function be(e) {
769
- return e.children;
770
- }
771
- const { gsl: Et, gslByUid: Pt } = c({
772
- itemType: "TABS",
773
- entryShape: "compound",
774
- mapToWidget: de,
775
- buildCustomWidget: ye,
776
- getChildren: be
777
- });
778
- function me(e) {
779
- return {
780
- uid: e.uid ?? "",
781
- kind: "layout",
782
- type: "accordion",
783
- props: {
784
- sections: e.sections,
785
- renderMode: e.renderMode ?? "all",
786
- ...e.singleOpen != null ? { singleOpen: e.singleOpen } : {},
787
- ...e.defaultOpen != null ? { defaultOpen: e.defaultOpen } : {}
788
- },
789
- children: []
790
- };
791
- }
792
- function he(e, t) {
793
- const s = t.walkChildren(t.children ?? []);
794
- if (e.kind === "static")
795
- return { ...t.mapStaticDef(e.def, "ACCORDION"), children: s };
796
- const a = e.fn;
797
- return ((l) => {
798
- const n = a(l);
799
- return { ...t.mapStaticDef(n, "ACCORDION"), children: s };
800
- });
801
- }
802
- function ge(e) {
803
- return e.children;
804
- }
805
- const { gsl: It, gslByUid: Wt } = c({
806
- itemType: "ACCORDION",
807
- entryShape: "compound",
808
- mapToWidget: me,
809
- buildCustomWidget: he,
810
- getChildren: ge
811
- }), { gsl: wt, gslByUid: Bt } = c({
812
- itemType: "CUSTOM_INPUT",
813
- entryShape: "keyed",
814
- sensibleDefaults: {
815
- base: {
816
- suppressAutomaticLabels: !1
817
- },
818
- fields: ["suppressAutomaticLabels"],
819
- apply: (e, t) => m(e, t)
820
- },
821
- mapToWidget: (e) => ({
822
- uid: e.uid ?? "",
823
- kind: "input",
824
- type: e.customType,
825
- path: e.path ?? "",
826
- ...e.label != null ? { label: e.label } : {},
827
- ...e.disabled != null ? { disabled: e.disabled } : {},
828
- ...e.readonly != null ? { readonly: e.readonly } : {},
829
- ...e.defaultValue != null ? { defaultValue: e.defaultValue } : {},
830
- ...e.validator != null ? { validator: e.validator } : {},
831
- props: e.props ?? {}
832
- })
833
- }), { gsl: Mt, gslByUid: Rt } = c({
834
- itemType: "CUSTOM_ACTION",
835
- entryShape: "bare",
836
- mapToWidget: (e) => {
837
- const {
838
- uid: t,
839
- label: s,
840
- disabled: a,
841
- on: l,
842
- onClick: n,
843
- data: i,
844
- customType: o,
845
- tags: r,
846
- size: u,
847
- include: p,
848
- exclude: d,
849
- states: y,
850
- props: A,
851
- ...k
852
- } = e;
853
- return {
854
- uid: t ?? "",
855
- kind: "action",
856
- type: e.customType,
857
- label: s,
858
- disabled: a,
859
- ...l != null ? { on: l } : {},
860
- props: { ...A, ...k }
861
- };
862
- },
863
- afterMerge: (e, t) => D.extractOnClickFromMergeResult(
864
- e,
865
- t.eventRegistry,
866
- t.eventIdGenerator
867
- )
868
- }), { gsl: Nt, gslByUid: xt } = c({
869
- itemType: "CUSTOM_DISPLAY",
870
- entryShape: "bare",
871
- mapToWidget: (e) => ({
872
- uid: e.uid ?? "",
873
- kind: "display",
874
- type: e.customType,
875
- props: e.props ?? {}
876
- })
877
- });
878
- function Te(e) {
879
- return {
880
- uid: e.uid ?? "",
881
- kind: "layout",
882
- type: e.customType,
883
- props: e.props ?? {},
884
- children: []
885
- };
886
- }
887
- function Se(e, t) {
888
- const s = t.walkChildren(t.children ?? []);
889
- if (e.kind === "static")
890
- return { ...t.mapStaticDef(e.def, "CUSTOM_LAYOUT"), children: s };
891
- const a = e.fn;
892
- return ((l) => {
893
- const n = a(l);
894
- return { ...t.mapStaticDef(n, "CUSTOM_LAYOUT"), children: s };
895
- });
896
- }
897
- function Ae(e) {
898
- return e.children;
899
- }
900
- const { gsl: Ft, gslByUid: jt } = c({
901
- itemType: "CUSTOM_LAYOUT",
902
- entryShape: "compound",
903
- mapToWidget: Te,
904
- buildCustomWidget: Se,
905
- getChildren: Ae
906
- }), $ = {
907
- INPUTS: /* @__PURE__ */ new Set([
908
- "INPUTS",
909
- "TEXTAREA",
910
- "PASSWORD",
911
- "SELECT",
912
- "DROPDOWN",
913
- "RADIOGROUP",
914
- "CHECKBOX",
915
- "CALENDAR",
916
- "DATE_INPUT",
917
- "DATE_PICKER",
918
- "RANGE_CALENDAR",
919
- "RANGE_DATE_INPUT",
920
- "RANGE_DATE_PICKER",
921
- "CURRENCY",
922
- "MARKDOWN",
923
- "LIST",
924
- "CUSTOM_INPUT",
925
- "REPEATER",
926
- "TAGS"
927
- ]),
928
- ACTIONS: /* @__PURE__ */ new Set(["ACTIONS", "CUSTOM_ACTION"]),
929
- DISPLAYS: /* @__PURE__ */ new Set(["DISPLAYS", "ALERTS", "MARKDOWN_TEXTS", "CUSTOM_DISPLAY"]),
930
- LAYOUTS: /* @__PURE__ */ new Set(["LAYOUTS", "TABS", "ACCORDION", "CUSTOM_LAYOUT"])
931
- };
932
- function _e(e, t) {
933
- const s = $[e];
934
- return s ? s.has(t) : e === t;
935
- }
936
- class ke {
937
- resolve(t, s) {
938
- const a = [];
939
- for (const n of s)
940
- n.kind === "aggregated" ? this.collectFromAggregated(n, t, a) : this.collectFromLeaf(n, t, a);
941
- const l = this.rollUpSensibleDefaults(a);
942
- return {
943
- leafSelectors: a,
944
- sensibleDefaults: l
945
- };
946
- }
947
- collectFromAggregated(t, s, a) {
948
- if (t.matcher(s))
949
- for (const l of t.children)
950
- this.collectFromLeaf(l, s, a);
951
- }
952
- collectFromLeaf(t, s, a) {
953
- _e(t.selectorType, s.itemType ?? "") && t.matcher(s) && a.push(t);
954
- }
955
- rollUpSensibleDefaults(t) {
956
- const s = /* @__PURE__ */ new Map(), a = (n, i) => {
957
- const o = s.get(n) ?? [];
958
- o.push(i), s.set(n, o);
959
- };
960
- for (const n of t) {
961
- const i = $[n.selectorType];
962
- if (i)
963
- for (const o of i) a(o, n);
964
- else
965
- a(n.selectorType, n);
966
- }
967
- const l = {};
968
- for (const [n, i] of s)
969
- F(n) && (l[n] = C(n).rollUpSensibleDefaults(i));
970
- return l;
971
- }
972
- }
973
- const ve = new ke();
974
- class fe {
975
- /**
976
- * Deep merges two objects, with right taking precedence over left when properties conflict.
977
- * Arrays are replaced, not merged.
978
- * @param left - The base object
979
- * @param right - The object whose properties take precedence
980
- * @returns A new merged object
981
- */
982
- deepMerge(t, s) {
983
- if (s == null)
984
- return t;
985
- if (t == null || typeof t != "object" || typeof s != "object" || Array.isArray(t) || Array.isArray(s))
986
- return s;
987
- const a = { ...t };
988
- for (const l in s)
989
- Object.prototype.hasOwnProperty.call(s, l) && (typeof s[l] == "object" && !Array.isArray(s[l]) && s[l] !== null && typeof t[l] == "object" && !Array.isArray(t[l]) && t[l] !== null ? a[l] = this.deepMerge(t[l], s[l]) : a[l] = s[l]);
990
- return a;
991
- }
992
- }
993
- const Ce = new fe();
994
- class Ue {
995
- constructor(t) {
996
- this.objectUtils = t;
997
- }
998
- merge(t, s, a) {
999
- let l = {}, n = null;
1000
- typeof t == "function" && (n = t);
1001
- const i = this.collectDecorators(a);
1002
- for (const u of i) {
1003
- if (n != null) {
1004
- n = this.composeRuntimeFunctions(n, u);
1005
- continue;
1006
- }
1007
- if (typeof u == "function") {
1008
- const p = u({
1009
- ...l,
1010
- ...typeof t == "function" ? {} : t
1011
- });
1012
- if (typeof p == "function") {
1013
- n = this.createPromotedFunction(
1014
- l,
1015
- t,
1016
- p,
1017
- s,
1018
- a
1019
- );
1020
- continue;
1021
- }
1022
- l = this.objectUtils.deepMerge(l, p);
1023
- } else
1024
- l = this.objectUtils.deepMerge(l, u);
1025
- }
1026
- if (n != null)
1027
- return {
1028
- kind: "dynamic",
1029
- fn: this.wrapWithSensibleDefaults(n, l, s, a)
1030
- };
1031
- const o = this.objectUtils.deepMerge(t, l);
1032
- return { kind: "static", def: this.applySensibleDefaults({ ...o }, s, a) };
1033
- }
1034
- // ── Collect all decorators in priority order ──
1035
- collectDecorators(t) {
1036
- const s = [];
1037
- for (const a of t.leafSelectors) {
1038
- const l = a.config;
1039
- l.override != null && s.push(l.override);
1040
- }
1041
- return s;
1042
- }
1043
- // ── Apply sensible defaults via registry ──
1044
- applySensibleDefaults(t, s, a) {
1045
- if (!F(s)) return t;
1046
- const l = a.sensibleDefaults[s] ?? {};
1047
- return C(s).applySensibleDefaults(t, l);
1048
- }
1049
- // ── Create promoted FunctionWidget ──
1050
- createPromotedFunction(t, s, a, l, n) {
1051
- return (i) => {
1052
- const o = a(i);
1053
- let r = this.objectUtils.deepMerge(t, o);
1054
- return r = this.objectUtils.deepMerge(r, s), this.applySensibleDefaults(r, l, n);
1055
- };
1056
- }
1057
- // ── Wrap runtime function with accumulated static decorators and sensible defaults ──
1058
- wrapWithSensibleDefaults(t, s, a, l) {
1059
- return (n) => {
1060
- let i = t(n);
1061
- return Object.keys(s).length > 0 && (i = this.objectUtils.deepMerge(s, i)), this.applySensibleDefaults(i, a, l);
1062
- };
1063
- }
1064
- // ── Compose two runtime functions ──
1065
- composeRuntimeFunctions(t, s) {
1066
- return typeof s == "function" ? (a) => {
1067
- const l = t(a), n = s(l);
1068
- return typeof n == "function" ? n(a) : this.objectUtils.deepMerge(n, l);
1069
- } : (a) => {
1070
- const l = t(a);
1071
- return this.objectUtils.deepMerge(l, s);
1072
- };
1073
- }
1074
- }
1075
- const Oe = new Ue(Ce);
1076
- class Le {
1077
- mapToWidget(t, s) {
1078
- if (t.kind === "dynamic") {
1079
- const a = t.fn;
1080
- return ((l) => {
1081
- const n = a(l);
1082
- return this.mapStaticDef(n, s);
1083
- });
1084
- }
1085
- return this.mapStaticDef(t.def, s);
1086
- }
1087
- mapStaticDef(t, s) {
1088
- const a = C(s).mapToWidget(t);
1089
- return this.applyBaseWidgetFields(a, t);
1090
- }
1091
- /**
1092
- * Injects BaseWidget-level fields that all widget types share.
1093
- * Centralized here so individual mappers don't need to repeat the pattern.
1094
- */
1095
- applyBaseWidgetFields(t, s) {
1096
- return s.size != null && (t.size = s.size), s.defaultValue != null && t.kind === "input" && (t.defaultValue = s.defaultValue), s.on != null && (t.on = s.on), s.include != null && (t.include = s.include), s.exclude != null && (t.exclude = s.exclude), t;
1097
- }
1098
- }
1099
- const De = new Le();
1100
- class Ee {
1101
- /**
1102
- * Ensures the output is always a uniform GslSelector[] of aggregated selectors.
1103
- *
1104
- * Callers can pass flat leaf selectors (single styling rules) or pre-grouped
1105
- * aggregated selectors. This method separates them into two buckets, then wraps
1106
- * any bare leaves into a catch-all aggregated selector so downstream code only
1107
- * deals with one shape.
1108
- */
1109
- normalizeSelectors(t) {
1110
- const s = Array.isArray(t) ? t : [t], a = [], l = [];
1111
- for (const n of s)
1112
- n.kind === "leaf" ? l.push(n) : a.push(n);
1113
- return l.length > 0 && a.unshift({
1114
- kind: "aggregated",
1115
- matcher: () => !0,
1116
- children: l
1117
- }), a;
1118
- }
1119
- extractFormConfig() {
1120
- return {
1121
- suppressAutomaticStack: !1
1122
- };
1123
- }
1124
- }
1125
- const Pe = new Ee(), Ie = {
1126
- input: /* @__PURE__ */ new Set(["disabled", "readonly", "label", "validator", "size"]),
1127
- action: /* @__PURE__ */ new Set(["disabled", "label", "size"]),
1128
- layout: /* @__PURE__ */ new Set(["size"]),
1129
- display: /* @__PURE__ */ new Set([])
1130
- }, W = {
1131
- onChange: "change",
1132
- onLoad: "load",
1133
- onFilter: "filter",
1134
- onClick: "click"
1135
- };
1136
- class We {
1137
- /**
1138
- * Extracts `states` from a merge result, combining with state-targeted
1139
- * GSL leaf selectors from `_gslStates`.
1140
- *
1141
- * Returns a cleaned merge result (no states) and accumulated state data.
1142
- */
1143
- extractFromMergeResult(t, s) {
1144
- const a = {};
1145
- for (const o of s) {
1146
- const r = o.targetState, u = o.config, p = u.override && typeof u.override != "function" ? u.override : u;
1147
- a[r] = {
1148
- ...a[r] || {},
1149
- ...p
1150
- };
1151
- }
1152
- if (t.kind === "dynamic") {
1153
- const o = t.fn;
1154
- return {
1155
- cleanedResult: { kind: "dynamic", fn: (u) => {
1156
- const p = o(u), { states: d, ...y } = p;
1157
- return y;
1158
- } },
1159
- stateData: { stateOverrides: a }
1160
- };
1161
- }
1162
- const { states: l, ...n } = t.def, i = {};
1163
- for (const [o, r] of Object.entries(a))
1164
- i[o] = { ...r };
1165
- if (l)
1166
- for (const [o, r] of Object.entries(
1167
- l
1168
- ))
1169
- i[o] = { ...i[o] || {}, ...r };
1170
- return {
1171
- cleanedResult: { kind: "static", def: n },
1172
- stateData: { stateOverrides: i }
1173
- };
1174
- }
1175
- /**
1176
- * Applies state overrides to a core widget. Each override produces:
1177
- * - `visible: true/false` → `include: { in }` / `exclude: { from }`
1178
- * - Core suffixable props → `'prop.stateName': value` at widget root
1179
- * - Event handlers → `on: { 'eventType.stateName': eventId }` with registry wiring
1180
- * - Custom props → `props: { 'prop.stateName': value }`
1181
- */
1182
- applyToWidget(t, s, a, l) {
1183
- const { stateOverrides: n } = s;
1184
- if (Object.keys(n).length === 0)
1185
- return t;
1186
- const i = { ...t }, o = t.kind, r = Ie[o] || /* @__PURE__ */ new Set();
1187
- t.props && (i.props = { ...t.props }), t.on && (i.on = { ...t.on });
1188
- for (const [u, p] of Object.entries(n))
1189
- for (const [d, y] of Object.entries(p))
1190
- d === "visible" ? this.applyVisibility(i, u, y) : W[d] ? this.applyStateEvent(i, u, d, y, a, l) : r.has(d) ? i[`${d}.${u}`] = y : (i.props || (i.props = {}), i.props[`${d}.${u}`] = y);
1191
- return i;
1192
- }
1193
- hasStateData(t) {
1194
- return Object.keys(t.stateOverrides).length > 0;
1195
- }
1196
- // ── Visibility helpers ──
1197
- applyVisibility(t, s, a) {
1198
- if (a) {
1199
- const l = t.include?.in || [];
1200
- t.include = { ...t.include || {}, in: [...l, s] };
1201
- } else {
1202
- const l = t.exclude?.from || [];
1203
- t.exclude = { ...t.exclude || {}, from: [...l, s] };
1204
- }
1205
- }
1206
- // ── State-suffixed event helpers ──
1207
- applyStateEvent(t, s, a, l, n, i) {
1208
- const o = W[a];
1209
- if (t.on || (t.on = {}), typeof l == "function") {
1210
- const r = i.next();
1211
- n.set(r, l), t.on[`${o}.${s}`] = r;
1212
- } else typeof l == "string" && (t.on[`${o}.${s}`] = l);
1213
- }
1214
- }
1215
- const we = new We();
1216
- function Be() {
1217
- let e = 0;
1218
- return { next: () => `event_${e++}` };
1219
- }
1220
- class Me {
1221
- constructor(t, s, a, l, n) {
1222
- this.resolver = t, this.merger = s, this.mapper = a, this.eventWiring = l, this.stateExpansion = n;
1223
- }
1224
- walkAndMap(t, s, a) {
1225
- const l = /* @__PURE__ */ new Map(), n = Be(), i = { value: 0 }, o = /* @__PURE__ */ new Set();
1226
- return { widgets: this.walkItems(
1227
- t,
1228
- s,
1229
- l,
1230
- a,
1231
- n,
1232
- i,
1233
- o
1234
- ), eventRegistry: l };
1235
- }
1236
- walkItems(t, s, a, l, n, i, o) {
1237
- return t.flatMap((r) => {
1238
- if (r.type !== "ITEMS")
1239
- throw new Error("Unexpected gui shortcut type");
1240
- return r.items.map((u) => this.processItem(
1241
- u,
1242
- r.itemType,
1243
- r.tags,
1244
- s,
1245
- a,
1246
- l,
1247
- n,
1248
- i,
1249
- o
1250
- ));
1251
- });
1252
- }
1253
- processItem(t, s, a, l, n, i, o, r, u) {
1254
- const p = s, d = C(s), y = d.parseEntry(t), A = this.buildBaseDef(y), k = this.buildDecoratorForMatching(A, p, a), v = this.resolver.resolve(k, l), E = v.leafSelectors.filter((h) => h.targetState != null), P = {
1255
- leafSelectors: v.leafSelectors.filter((h) => h.targetState == null),
1256
- sensibleDefaults: v.sensibleDefaults
1257
- };
1258
- let _ = this.merger.merge(A, p, P);
1259
- d.afterMerge && (_ = d.afterMerge(_, {
1260
- eventRegistry: n,
1261
- formConfig: i,
1262
- eventIdGenerator: o
1263
- })), _ = this.eventWiring.wireInputLayoutEvents(
1264
- _,
1265
- n,
1266
- o
1267
- );
1268
- const { cleanedResult: I, stateData: U } = this.stateExpansion.extractFromMergeResult(
1269
- _,
1270
- E
1271
- );
1272
- let T;
1273
- if (d.buildCustomWidget) {
1274
- const h = this.buildCustomWidgetContext(
1275
- y.children,
1276
- l,
1277
- n,
1278
- i,
1279
- o,
1280
- r,
1281
- u
1282
- );
1283
- T = this.buildCustomWidget(d, I, h);
1284
- } else
1285
- T = this.mapper.mapToWidget(I, p);
1286
- if (typeof T != "function") {
1287
- const h = T;
1288
- h.uid || (h.path && !u.has(h.path) ? (h.uid = h.path, u.add(h.path)) : h.uid = `dx_${r.value++}`);
1289
- }
1290
- if (this.stateExpansion.hasStateData(U))
1291
- if (typeof T == "function") {
1292
- const h = T;
1293
- T = ((Y) => {
1294
- const z = h(Y);
1295
- return this.stateExpansion.applyToWidget(
1296
- z,
1297
- U,
1298
- n,
1299
- o
1300
- );
1301
- });
1302
- } else
1303
- T = this.stateExpansion.applyToWidget(
1304
- T,
1305
- U,
1306
- n,
1307
- o
1308
- );
1309
- return T;
1310
- }
1311
- buildCustomWidgetContext(t, s, a, l, n, i, o) {
1312
- return {
1313
- children: t,
1314
- mapStaticDef: (r, u) => this.mapper.mapStaticDef(r, u),
1315
- walkChildren: (r) => this.walkItems(
1316
- r,
1317
- s,
1318
- a,
1319
- l,
1320
- n,
1321
- i,
1322
- o
1323
- )
1324
- };
1325
- }
1326
- buildCustomWidget(t, s, a) {
1327
- return t.buildCustomWidget(s, a);
1328
- }
1329
- /**
1330
- * Resolves the base definition from a parsed entry, injecting the path for keyed entries.
1331
- * For runtime (function) providers, wraps them to inject the path at evaluation time.
1332
- */
1333
- buildBaseDef(t) {
1334
- const s = t.baseDef;
1335
- return typeof s == "function" ? (a) => {
1336
- const n = s(a ?? {});
1337
- return t.path != null ? { ...n, path: t.path } : n;
1338
- } : t.path != null ? { ...s, path: t.path } : s;
1339
- }
1340
- buildDecoratorForMatching(t, s, a) {
1341
- if (typeof t == "function")
1342
- return { itemType: s, tags: [...a] };
1343
- const l = [...a, ..."tags" in t && t.tags ? t.tags : []], n = "uid" in t ? t.uid : void 0, i = "type" in t ? t.type : void 0;
1344
- return { itemType: s, tags: l, uid: n, type: i };
1345
- }
1346
- }
1347
- class Re {
1348
- constructor(t, s) {
1349
- this.selectorNormalizer = t, this.walker = s;
1350
- }
1351
- processDxFacade(t, s = [], a) {
1352
- const { defs: l, gslSelectors: n, formConfig: i } = this.prepareForm(
1353
- t,
1354
- s,
1355
- a
1356
- ), { widgets: o, eventRegistry: r } = this.walker.walkAndMap(
1357
- l,
1358
- n,
1359
- i
1360
- ), u = o[0];
1361
- return this.buildResult({ form: u }, r, i);
1362
- }
1363
- /**
1364
- * Normalizes raw form definitions and applies form-level defaults.
1365
- *
1366
- * Steps:
1367
- * 1. Normalize definitions — ensure a flat array; convert bare functions to display widgets.
1368
- * 2. Normalize selectors — convert mixed leaf/aggregated selectors into a uniform
1369
- * aggregated shape, and extract form-level config (see {@link FormConfig}).
1370
- * 3. Auto-stack — unless suppressed, wrap all definitions in a synthetic root
1371
- * flex column layout so the form renders as a single vertical container.
1372
- */
1373
- prepareForm(t, s, a) {
1374
- const n = (Array.isArray(t) ? [...t] : [t]).map(
1375
- (r) => typeof r == "function" ? K(r) : r
1376
- ), i = this.selectorNormalizer.normalizeSelectors(s), o = {
1377
- ...this.selectorNormalizer.extractFormConfig(),
1378
- ...a
1379
- };
1380
- if (!o.suppressAutomaticStack) {
1381
- const r = {
1382
- def: { uid: "#root", direction: "column", widgetName: "flex" },
1383
- children: n
1384
- };
1385
- return {
1386
- defs: [{ type: "ITEMS", itemType: R.LAYOUTS, items: [r], tags: [] }],
1387
- gslSelectors: i,
1388
- formConfig: o
1389
- };
1390
- }
1391
- return { defs: n, gslSelectors: i, formConfig: o };
1392
- }
1393
- /**
1394
- * Converts DX `$`-separated state names to core's `:`-separated names.
1395
- * E.g. `{ register$adult: 'expr' }` → `{ 'register:adult': 'expr' }`.
1396
- */
1397
- convertStateNames(t) {
1398
- const s = {};
1399
- for (const [a, l] of Object.entries(t))
1400
- s[a.replace(/\$/g, ":")] = l;
1401
- return s;
1402
- }
1403
- buildResult(t, s, a) {
1404
- a.states && Object.keys(a.states).length > 0 && (t = {
1405
- ...t,
1406
- states: this.convertStateNames(a.states)
1407
- });
1408
- const l = { form: t };
1409
- return s.size > 0 && (l.events = (n) => {
1410
- const i = s.get(n.name);
1411
- if (i) {
1412
- const o = (u) => {
1413
- if (u && typeof u == "object" && "path" in u && !("type" in u)) {
1414
- const { path: p, ...d } = u;
1415
- for (const [y, A] of Object.entries(d))
1416
- n.callback({
1417
- type: "OVERRIDE_WIDGET_PROP",
1418
- payload: { path: p, prop: y, value: A }
1419
- });
1420
- } else
1421
- n.callback(u);
1422
- }, r = {
1423
- ...n,
1424
- callback: o,
1425
- update: o
1426
- };
1427
- i(r);
1428
- }
1429
- }), a.dependencies && (l.dependencies = a.dependencies), a.widgetLoaders && (l.widgetLoaders = a.widgetLoaders), a.validateOn && (l.validateOn = a.validateOn), a.itemRenderers && (l.itemRenderers = a.itemRenderers), l;
1430
- }
1431
- }
1432
- const Ne = new Me(
1433
- ve,
1434
- Oe,
1435
- De,
1436
- D,
1437
- we
1438
- ), xe = new Re(Pe, Ne);
1439
- function Fe(e) {
1440
- return typeof e == "function" ? !0 : Array.isArray(e) ? e.length === 0 || e.every(w) : w(e);
1441
- }
1442
- function w(e) {
1443
- if (typeof e == "function") return !0;
1444
- if (e === null || typeof e != "object") return !1;
1445
- const t = e;
1446
- return t.type === "ITEMS" && typeof t.itemType == "string";
1447
- }
1448
- const B = Object.freeze({}), je = Object.freeze({}), M = /* @__PURE__ */ new WeakMap();
1449
- function O(e, t) {
1450
- return e == null ? t : typeof e == "object" ? e : {};
1451
- }
1452
- function $t(e, t, s) {
1453
- if (!Fe(e))
1454
- return { formDef: e };
1455
- const a = O(e, B), l = O(t, B), n = O(s, je);
1456
- let i = M.get(a);
1457
- i || (i = /* @__PURE__ */ new WeakMap(), M.set(a, i));
1458
- let o = i.get(l);
1459
- o || (o = /* @__PURE__ */ new WeakMap(), i.set(l, o));
1460
- const r = o.get(n);
1461
- if (r) return r;
1462
- const u = xe.processDxFacade(
1463
- e,
1464
- t,
1465
- s
1466
- ), p = {
1467
- formDef: u.form,
1468
- formEvent: u.events,
1469
- dependencies: u.dependencies,
1470
- widgetLoaders: u.widgetLoaders,
1471
- validateOn: u.validateOn,
1472
- itemRenderers: u.itemRenderers
1473
- };
1474
- return o.set(n, p), p;
1475
- }
1476
- export {
1477
- xt as $,
1478
- mt as A,
1479
- ht as B,
1480
- gt as C,
1481
- Tt as D,
1482
- St as E,
1483
- At as F,
1484
- R as G,
1485
- le as H,
1486
- _t as I,
1487
- kt as J,
1488
- vt as K,
1489
- ft as L,
1490
- Ct as M,
1491
- Ut as N,
1492
- Ot as O,
1493
- Lt as P,
1494
- Dt as Q,
1495
- Et as R,
1496
- Pt as S,
1497
- It as T,
1498
- Wt as U,
1499
- wt as V,
1500
- Bt as W,
1501
- Mt as X,
1502
- Rt as Y,
1503
- Nt as Z,
1504
- Ye as _,
1505
- ze as a,
1506
- Ft as a0,
1507
- jt as a1,
1508
- K as a2,
1509
- b as a3,
1510
- g as a4,
1511
- S as a5,
1512
- m as a6,
1513
- N as a7,
1514
- xe as a8,
1515
- Fe as a9,
1516
- $t as aa,
1517
- Ke as b,
1518
- Ve as c,
1519
- c as d,
1520
- Ge as e,
1521
- Xe as f,
1522
- He as g,
1523
- Ze as h,
1524
- qe as i,
1525
- Je as j,
1526
- Qe as k,
1527
- et as l,
1528
- tt as m,
1529
- st as n,
1530
- lt as o,
1531
- at as p,
1532
- nt as q,
1533
- it as r,
1534
- rt as s,
1535
- ot as t,
1536
- ut as u,
1537
- pt as v,
1538
- ct as w,
1539
- dt as x,
1540
- yt as y,
1541
- bt as z
1542
- };