react-luna-form 0.0.27 → 0.0.29

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,1423 +1 @@
1
- // src/component/control.tsx
2
- import { jsx } from "react/jsx-runtime";
3
- function Control(props) {
4
- const content = typeof props.children === "function" ? props.children({ isPending: props.isPending }) : props.children;
5
- return /* @__PURE__ */ jsx("div", { "data-slot": "field-control", className: "w-full", children: content });
6
- }
7
-
8
- // src/component/field/field-set-advanced.tsx
9
- import { Activity, useCallback, useState } from "react";
10
-
11
- // src/component/chevron-icon.tsx
12
- import { jsx as jsx2 } from "react/jsx-runtime";
13
- function ChevronIcon(props) {
14
- return /* @__PURE__ */ jsx2(
15
- "svg",
16
- {
17
- xmlns: "http://www.w3.org/2000/svg",
18
- viewBox: "0 0 20 20",
19
- fill: "currentColor",
20
- className: `size-4 transition-transform duration-200 ${props.expanded ? "rotate-90" : ""}`,
21
- children: /* @__PURE__ */ jsx2(
22
- "path",
23
- {
24
- fillRule: "evenodd",
25
- d: "M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",
26
- clipRule: "evenodd"
27
- }
28
- )
29
- }
30
- );
31
- }
32
-
33
- // ../luna-core/src/util/constant.ts
34
- var INPUT = "input";
35
- var INPUT_EMAIL = "input/email";
36
- var INPUT_NUMBER = "input/number";
37
- var TEXTAREA = "textarea";
38
- var RADIO = "radio";
39
- var CHECKBOX = "checkbox";
40
- var LIST = "list";
41
- var SELECT = "select";
42
- var SELECT_MONTH = "select/month";
43
- var SELECT_YEAR = "select/year";
44
- var COLUMN = "column";
45
- var FIELDS = "fields";
46
- var LABEL = "label";
47
- var VALUE = "value";
48
- var OPTIONS = "options";
49
- var TYPE_EMAIL = "email";
50
- var TYPE_NUMBER = "number";
51
- var TYPE_PASSWORD = "password";
52
- var TYPE_TEL = "tel";
53
- var TYPE_TEXT = "text";
54
- var ARIA_ERROR_MESSAGE = "aria-errormessage";
55
- var ARIA_INVALID = "aria-invalid";
56
- var DATA_INVALID = "data-invalid";
57
- var DATA_READONLY = "data-readonly";
58
- var PREFIX_ARIA = "aria";
59
- var PREFIX_DATA = "data";
60
- var MIN = "min";
61
- var MAX = "max";
62
- var MIN_LENGTH = "minLength";
63
- var MAX_LENGTH = "maxLength";
64
- var $REF = "$ref";
65
- var VERTICAL = "vertical";
66
- var HORIZONTAL = "horizontal";
67
- var TYPE = "type";
68
-
69
- // ../luna-core/src/util/is-type.ts
70
- function isObject(value) {
71
- return value !== null && Object.prototype.toString.call(value) === "[object Object]";
72
- }
73
- function isValue(value) {
74
- return isString(value) || typeof value === "number" || isBoolean(value);
75
- }
76
- function isString(value) {
77
- return typeof value === "string";
78
- }
79
- function isBoolean(value) {
80
- return typeof value === "boolean";
81
- }
82
-
83
- // ../luna-core/src/util/extract.ts
84
- var REGEX_TYPE = /[^/]+$/;
85
- function getCurrentValue(value, entity = VALUE) {
86
- if (value !== null && value !== void 0) {
87
- if (isValue(value)) {
88
- return value;
89
- }
90
- if (isObject(value)) {
91
- const result = getValue(value, entity);
92
- if (isValue(result)) {
93
- return result;
94
- }
95
- }
96
- }
97
- }
98
- function getValue(value, namespace) {
99
- const result = extract(value, namespace);
100
- if (isValue(result)) {
101
- return result;
102
- }
103
- }
104
- function extract(value, namespace) {
105
- if (!namespace || !isObject(value)) {
106
- return null;
107
- }
108
- const keys = namespace.split(".").filter((key) => key !== "");
109
- if (keys.length === 0) {
110
- return null;
111
- }
112
- let result = value;
113
- for (const key of keys) {
114
- if (isObject(result) && key in result) {
115
- const obj = result;
116
- result = obj[key];
117
- } else {
118
- return null;
119
- }
120
- }
121
- return result;
122
- }
123
- function toOptions(data, options = { label: LABEL, value: VALUE }) {
124
- return data.map((item) => {
125
- if (isObject(item)) {
126
- const label = extract(item, options.label);
127
- const value = extract(item, options.value);
128
- if (isValue(label) && isValue(value)) {
129
- return {
130
- label: `${label}`,
131
- value: `${value}`
132
- };
133
- }
134
- }
135
- return item;
136
- });
137
- }
138
- function getType(value = TYPE_TEXT) {
139
- if (value) {
140
- const result = value.match(REGEX_TYPE);
141
- if (result) {
142
- const [type] = result;
143
- if (type !== INPUT) {
144
- return type.trim().toLowerCase();
145
- }
146
- }
147
- }
148
- return TYPE_TEXT;
149
- }
150
-
151
- // ../luna-core/src/util/string.ts
152
- var REGEX_MARKDOWN_LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
153
- function interpolate(template, values = {}) {
154
- if (isString(template)) {
155
- return replacePlaceholders(template, values);
156
- }
157
- if (Array.isArray(template)) {
158
- return template.map((item) => {
159
- return interpolate(item, values);
160
- });
161
- }
162
- if (isObject(template)) {
163
- const results = {};
164
- for (const key in template) {
165
- results[key] = interpolate(template[key], values);
166
- }
167
- return results;
168
- }
169
- return template;
170
- }
171
- function interpolateIfNeeded(template, values = {}) {
172
- return isInterpolated(template) ? interpolate(template, values) : template;
173
- }
174
- function isInterpolated(template) {
175
- if (isString(template)) {
176
- return /{([^}]+)}/.test(template);
177
- }
178
- if (Array.isArray(template)) {
179
- return template.some((item) => isInterpolated(item));
180
- }
181
- if (isObject(template)) {
182
- return Object.values(template).some((value) => isInterpolated(value));
183
- }
184
- return false;
185
- }
186
- function replacePlaceholders(template, values = {}) {
187
- return template.replace(/{([^}]+)}/g, (match, key) => {
188
- const value = key.includes(".") ? extract(values, key) : values[key];
189
- if (isValue(value)) {
190
- return String(value);
191
- }
192
- return match;
193
- });
194
- }
195
- function formatMarkdown(text, callback) {
196
- if (!text || text.trim().length === 0) {
197
- return null;
198
- }
199
- let match;
200
- let lastIndex = 0;
201
- let hasMatch = false;
202
- const parts = [];
203
- while ((match = REGEX_MARKDOWN_LINK.exec(text)) !== null) {
204
- const [fullMatch, linkText, url] = match;
205
- const index = match.index;
206
- hasMatch = true;
207
- if (index > lastIndex) {
208
- parts.push(text.substring(lastIndex, index));
209
- }
210
- const value = callback ? callback(index, url, linkText) : fullMatch;
211
- parts.push(value);
212
- lastIndex = index + fullMatch.length;
213
- }
214
- if (!hasMatch) {
215
- return text;
216
- }
217
- if (lastIndex < text.length) {
218
- parts.push(text.substring(lastIndex));
219
- }
220
- return parts;
221
- }
222
-
223
- // ../luna-core/src/util/is-input.ts
224
- var isSelectMonth = (field) => createTypeChecker(SELECT_MONTH)(field);
225
- var isSelectYear = (field) => createTypeChecker(SELECT_YEAR)(field);
226
- var isCheckbox = createTypeChecker(CHECKBOX);
227
- var isInput = createTypeChecker(INPUT);
228
- var isRadio = createTypeChecker(RADIO);
229
- var isSelect = createTypeChecker(SELECT);
230
- var isTextArea = createTypeChecker(TEXTAREA);
231
- var isText = createTypeChecker(
232
- TYPE_TEXT,
233
- TYPE_EMAIL,
234
- TYPE_PASSWORD,
235
- TYPE_TEL
236
- );
237
- var isEmail = createTypeChecker(INPUT_EMAIL, TYPE_EMAIL);
238
- var isNumber = createTypeChecker(INPUT_NUMBER, TYPE_NUMBER);
239
- function isClickable(field) {
240
- return isRadio(field) || isCheckbox(field);
241
- }
242
- function isList(slot) {
243
- return slot.type === LIST;
244
- }
245
- function isColumn(slot) {
246
- return slot.type === COLUMN;
247
- }
248
- function isField(slot) {
249
- return slot.type !== COLUMN && slot.type !== LIST;
250
- }
251
- function isOptions(field) {
252
- return isSelect(field) || isRadio(field);
253
- }
254
- function isValidValue(value) {
255
- return value !== void 0 && value !== null && value !== "";
256
- }
257
- function createTypeChecker(...types) {
258
- return (field) => {
259
- const inputType = isString(field.type) ? field.type : void 0;
260
- if (!inputType) {
261
- return false;
262
- }
263
- return types.some((type) => {
264
- return inputType === type || inputType?.startsWith(`${type}/`);
265
- });
266
- };
267
- }
268
-
269
- // ../luna-core/src/util/build.ts
270
- function buildOptions(field, values = {}) {
271
- if (isSelect(field) && field.disabled) {
272
- const current = field.name ? values?.[field.name] : void 0;
273
- if (current && isObject(current)) {
274
- return [current];
275
- }
276
- }
277
- }
278
- function buildOrientation(field) {
279
- if (isRadio(field) || isCheckbox(field)) {
280
- return HORIZONTAL;
281
- }
282
- return field.advanced?.orientation ?? VERTICAL;
283
- }
284
- function buildReverse(field) {
285
- if (!isCheckbox(field)) {
286
- return false;
287
- }
288
- return field.advanced?.reverse !== false;
289
- }
290
- function buildDisabled(field, disabled) {
291
- const readonly = field.readonly ?? false;
292
- return disabled ? disabled : readonly;
293
- }
294
- function buildSource(field) {
295
- if (isRadio(field) || isSelect(field) && !field.disabled) {
296
- const source = field.source;
297
- if (Array.isArray(source) || isObject(source) && !($REF in source)) {
298
- return source;
299
- }
300
- }
301
- }
302
-
303
- // ../luna-core/src/util/date.ts
304
- var REGEX_DIGITS = /^\d+$/;
305
- function getMonth() {
306
- return Array.from({ length: 12 }, (_, i) => ({
307
- value: (i + 1).toString(),
308
- label: new Date(0, i).toLocaleString("default", {
309
- month: "long"
310
- })
311
- }));
312
- }
313
- function getYear(min, max) {
314
- if (max >= min) {
315
- return Array.from({ length: max - min + 1 }, (_, i) => {
316
- const year = min + i;
317
- return {
318
- value: year.toString(),
319
- label: year.toString()
320
- };
321
- });
322
- }
323
- return [];
324
- }
325
- function getCurrentYear() {
326
- return (/* @__PURE__ */ new Date()).getFullYear();
327
- }
328
- function getConvert(value, current) {
329
- if (typeof value === "number") {
330
- return value;
331
- }
332
- const now2 = current ?? getCurrentYear();
333
- const trimmed = value.trim().toLowerCase();
334
- if (trimmed.startsWith("current")) {
335
- const match = trimmed.match(/^current([+-])(\d+)$/);
336
- if (match) {
337
- const [, operator, offsetStr] = match;
338
- const offset = parseInt(offsetStr, 10);
339
- if (!isNaN(offset)) {
340
- return operator === "+" ? now2 + offset : now2 - offset;
341
- }
342
- }
343
- return now2;
344
- }
345
- if (REGEX_DIGITS.test(trimmed)) {
346
- return parseInt(trimmed, 10);
347
- }
348
- return now2;
349
- }
350
-
351
- // ../luna-core/src/helper/input.ts
352
- var now = getCurrentYear();
353
- function buildOptionSelect(field) {
354
- if (isSelect(field)) {
355
- return defineOption(field);
356
- }
357
- }
358
- function defineOption(select) {
359
- if (isSelectMonth(select)) {
360
- return getMonth();
361
- }
362
- if (isSelectYear(select)) {
363
- const min = select.advanced?.length?.min ?? now;
364
- const max = select.advanced?.length?.max ?? now + 5;
365
- return getYear(getConvert(min, now), getConvert(max, now));
366
- }
367
- }
368
- function buildCommon(field, disabled = false) {
369
- const commonProps = {
370
- disabled,
371
- id: field.name,
372
- name: field.name,
373
- placeholder: field.placeholder,
374
- required: field.required
375
- };
376
- if (isInput(field)) {
377
- return {
378
- ...commonProps,
379
- ...defineInput(field)
380
- };
381
- }
382
- if (isSelect(field)) {
383
- return {
384
- ...commonProps,
385
- ...defineSelect(field)
386
- };
387
- }
388
- if (isTextArea(field)) {
389
- return {
390
- ...commonProps,
391
- ...defineTextArea(field)
392
- };
393
- }
394
- return commonProps;
395
- }
396
- function defineInput(input) {
397
- const type = getType(input.type);
398
- const copy = { ...input, type };
399
- return {
400
- ...defineAutoComplete(input),
401
- ...defineNumberLimits(copy),
402
- ...isText(copy) ? defineLength(copy) : {},
403
- type
404
- };
405
- }
406
- function defineSelect(field) {
407
- const options = buildOptionSelect(field);
408
- if (options) {
409
- return { options };
410
- }
411
- return {};
412
- }
413
- function defineTextArea(field) {
414
- return {
415
- ...defineAutoComplete(field),
416
- ...defineLength(field)
417
- };
418
- }
419
- function defineAutoComplete(input) {
420
- const autoComplete = input.advanced?.autocomplete;
421
- if (autoComplete) {
422
- return { autoComplete };
423
- }
424
- return {};
425
- }
426
- function defineNumberLimits(input) {
427
- if (isNumber(input)) {
428
- return defineMinMax(input);
429
- }
430
- return {};
431
- }
432
- function defineLength(input) {
433
- return defineConstraints(input, { min: MIN_LENGTH, max: MAX_LENGTH });
434
- }
435
- function defineMinMax(input) {
436
- return defineConstraints(input, { min: MIN, max: MAX });
437
- }
438
- function defineConstraints(input, keys) {
439
- const result = {};
440
- const length = input.advanced?.length;
441
- if (length) {
442
- if (length.min !== void 0) {
443
- result[keys.min] = length.min;
444
- }
445
- if (length.max !== void 0) {
446
- result[keys.max] = length.max;
447
- }
448
- }
449
- return result;
450
- }
451
- function resolveSource(field, value) {
452
- const current = buildSource(field);
453
- if (current) {
454
- return current;
455
- }
456
- return buildOptions(field, value);
457
- }
458
- function getInputValue(field, value) {
459
- const newValue = isObject(value) && field.name in value ? value[field.name] : value;
460
- return getCurrentValue(newValue, field.advanced?.entity);
461
- }
462
- function mergeOptionsProps(field, commonProps, options) {
463
- return isOptions(field) && Array.isArray(options) ? { ...commonProps, [OPTIONS]: options } : commonProps;
464
- }
465
- function getPreselectedValue(field, commonProps, value) {
466
- if (field.required && !isValidValue(value)) {
467
- if (isSelect(field)) {
468
- if (field.advanced?.preselected !== false && OPTIONS in commonProps) {
469
- const options = commonProps[OPTIONS];
470
- if (Array.isArray(options) && options.length === 1) {
471
- return options[0];
472
- }
473
- }
474
- }
475
- }
476
- return value;
477
- }
478
- function getOptions(field, data) {
479
- if (isSelect(field) && Array.isArray(data)) {
480
- return toOptions(data, field.advanced?.options);
481
- }
482
- return data;
483
- }
484
- function prepareInputProps(field, commonProps, data, value) {
485
- const currentValue = getInputValue(field, value);
486
- const options = Array.isArray(data) ? getOptions(field, data) : data;
487
- const commonPropsWithOptions = mergeOptionsProps(field, commonProps, options);
488
- const defaultValue = getPreselectedValue(
489
- field,
490
- commonPropsWithOptions,
491
- currentValue
492
- );
493
- return {
494
- commonPropsWithOptions,
495
- defaultValue
496
- };
497
- }
498
- function prepareDefaultValue(field, value) {
499
- if (isCheckbox(field)) {
500
- return {
501
- defaultChecked: isValidValue(value)
502
- };
503
- }
504
- return { defaultValue: value };
505
- }
506
-
507
- // ../luna-core/src/util/prepare.ts
508
- var REGEX_REF = /^#\/definition\//;
509
- function prepare(base = [], definition) {
510
- const resolved = resolveRefs(base, definition);
511
- return Array.isArray(resolved) ? resolved.filter(filter).sort((a, b) => getOrder(a) - getOrder(b)) : [];
512
- }
513
- function resolveRefs(base, definition, cache = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new WeakSet()) {
514
- if (!isDefinition(definition) || !base || typeof base !== "object") {
515
- return base;
516
- }
517
- if (cache.has(base)) {
518
- return cache.get(base);
519
- }
520
- if (visited.has(base)) {
521
- return base;
522
- }
523
- visited.add(base);
524
- if (Array.isArray(base)) {
525
- return base.map((item) => resolveRefs(item, definition, cache, visited));
526
- }
527
- if ($REF in base && isString(base[$REF])) {
528
- const path = base[$REF].replace(REGEX_REF, "");
529
- const resolved = extract(definition, path);
530
- if (resolved !== null) {
531
- return resolveRefs(resolved, definition, cache, visited);
532
- }
533
- return base;
534
- }
535
- const result = {};
536
- for (const [key, value] of Object.entries(base)) {
537
- result[key] = resolveRefs(value, definition, cache, visited);
538
- }
539
- visited.delete(base);
540
- cache.set(base, result);
541
- return result;
542
- }
543
- function entries(values) {
544
- return Object.entries(values ?? {});
545
- }
546
- function getOrder(item) {
547
- return item.order ?? Number.MAX_VALUE;
548
- }
549
- function isDefinition(definition) {
550
- return definition !== void 0 && isObject(definition) && Object.keys(definition).length > 0;
551
- }
552
- function filter(base) {
553
- if (TYPE in base) {
554
- return true;
555
- }
556
- if (Array.isArray(base[FIELDS])) {
557
- return base[FIELDS].length > 0;
558
- }
559
- return true;
560
- }
561
-
562
- // ../luna-core/src/util/attributes.ts
563
- function getPrefixedAttributes(prefix, record) {
564
- const attrs = {};
565
- for (const [key, value] of entries(record)) {
566
- attrs[`${prefix}-${key}`] = value;
567
- }
568
- return attrs;
569
- }
570
- function getAriaAttributes(record) {
571
- return getPrefixedAttributes(PREFIX_ARIA, record);
572
- }
573
- function getDataAttributes(record) {
574
- return getPrefixedAttributes(PREFIX_DATA, record);
575
- }
576
- function buildAriaAttributes(field, errors) {
577
- const ariaAttributes = getAriaAttributes(field.advanced?.aria);
578
- if (errors && errors.length > 0) {
579
- ariaAttributes[ARIA_INVALID] = "true";
580
- ariaAttributes[ARIA_ERROR_MESSAGE] = `${field.name}-error`;
581
- }
582
- return ariaAttributes;
583
- }
584
- function buildDataAttributes(field) {
585
- return getDataAttributes(field.advanced?.data);
586
- }
587
-
588
- // ../luna-core/src/util/column.ts
589
- var cols = {
590
- 1: "md:grid-cols-1",
591
- 2: "md:grid-cols-2",
592
- 3: "md:grid-cols-3"
593
- };
594
- var span = {
595
- 1: "md:col-span-1",
596
- 2: "md:col-span-2",
597
- 3: "md:col-span-3"
598
- };
599
- function getColumn(value, defaultCols = 2) {
600
- return cols[value && value in cols ? value : defaultCols];
601
- }
602
- function getSpan(value) {
603
- if (value && value in span) {
604
- return span[value];
605
- }
606
- }
607
-
608
- // ../luna-core/src/util/list.ts
609
- function getInitialCount(list, value) {
610
- const min = list.advanced?.length?.min ?? 1;
611
- if (value) {
612
- const data = extract(value, list.name);
613
- if (Array.isArray(data)) {
614
- return Math.max(data.length, min);
615
- }
616
- }
617
- return Math.max(min, 0);
618
- }
619
- function isMultiFieldList(list) {
620
- if (!Array.isArray(list.fields) || list.fields.length === 0) {
621
- return false;
622
- }
623
- return list.fields.length > 1 || list.fields[0].type === COLUMN;
624
- }
625
- function getInitialList(list, value) {
626
- const count = getInitialCount(list, value);
627
- return Array.from({ length: count }, (_, index) => index);
628
- }
629
- function getLabel(list) {
630
- return list.label ?? list.name;
631
- }
632
-
633
- // ../luna-core/src/util/translate.ts
634
- function translate(key, dictionary) {
635
- if (!key) {
636
- return "";
637
- }
638
- if (!dictionary) {
639
- return key;
640
- }
641
- return dictionary[key] ?? key;
642
- }
643
-
644
- // ../luna-core/src/util/style.ts
645
- function mergeStyle(globalStyle, localStyle) {
646
- return { ...globalStyle, ...localStyle };
647
- }
648
-
649
- // src/lib/string.tsx
650
- import { jsx as jsx3 } from "react/jsx-runtime";
651
- function formatMarkdown2(text) {
652
- return formatMarkdown(
653
- text,
654
- (index, url, text2) => {
655
- return /* @__PURE__ */ jsx3(
656
- "a",
657
- {
658
- className: "underline",
659
- href: url,
660
- rel: "noopener noreferrer",
661
- target: "_blank",
662
- children: text2
663
- },
664
- `${url}-${index}`
665
- );
666
- }
667
- );
668
- }
669
-
670
- // src/component/field/field-set-advanced.tsx
671
- import { jsx as jsx4, jsxs } from "react/jsx-runtime";
672
- function FieldSetAdvanced(props) {
673
- const { fields = [] } = props.section;
674
- const [isOpen, setIsOpen] = useState(false);
675
- const handleOpen = useCallback(() => setIsOpen((previous) => !previous), []);
676
- return /* @__PURE__ */ jsxs(
677
- "fieldset",
678
- {
679
- "data-slot": "field-set",
680
- "data-advanced": "true",
681
- "data-expanded": isOpen,
682
- "data-empty": fields.length === 0,
683
- className: "flex flex-col",
684
- id: props.section.id?.toString(),
685
- children: [
686
- /* @__PURE__ */ jsx4("legend", { children: /* @__PURE__ */ jsxs(
687
- "button",
688
- {
689
- className: "flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",
690
- onClick: handleOpen,
691
- type: "button",
692
- children: [
693
- /* @__PURE__ */ jsx4(ChevronIcon, { expanded: isOpen }),
694
- /* @__PURE__ */ jsx4("span", { children: formatMarkdown2(props.section.title) })
695
- ]
696
- }
697
- ) }),
698
- /* @__PURE__ */ jsx4(Activity, { mode: isOpen ? "visible" : "hidden", children: /* @__PURE__ */ jsxs(
699
- "div",
700
- {
701
- className: "mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600",
702
- "data-slot": "field-set-content",
703
- children: [
704
- props.section.description && /* @__PURE__ */ jsx4("p", { className: "text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.section.description) }),
705
- props.group
706
- ]
707
- }
708
- ) })
709
- ]
710
- }
711
- );
712
- }
713
-
714
- // src/component/legend.tsx
715
- import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
716
- function Legend(props) {
717
- return /* @__PURE__ */ jsxs2(Fragment, { children: [
718
- props.title && /* @__PURE__ */ jsx5("legend", { className: "mb-3 font-medium text-slate-800 dark:text-slate-200", children: formatMarkdown2(props.title) }),
719
- props.description && /* @__PURE__ */ jsx5("p", { className: "-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.description) })
720
- ] });
721
- }
722
-
723
- // src/component/field/field-set-base.tsx
724
- import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
725
- function FieldSetBase(props) {
726
- return /* @__PURE__ */ jsxs3(
727
- "fieldset",
728
- {
729
- "data-slot": "field-set",
730
- "data-empty": props.empty,
731
- className: "flex flex-col data-[empty=false]:gap-6",
732
- id: props.id,
733
- children: [
734
- /* @__PURE__ */ jsx6(Legend, { description: props.description, title: props.title }),
735
- props.children
736
- ]
737
- }
738
- );
739
- }
740
-
741
- // src/component/group.tsx
742
- import { jsx as jsx7 } from "react/jsx-runtime";
743
- function Group(props) {
744
- return /* @__PURE__ */ jsx7(
745
- "div",
746
- {
747
- "data-slot": "field-group",
748
- "data-compact": props.compact,
749
- className: "flex w-full flex-col gap-8 data-[compact=true]:gap-3",
750
- children: props.children
751
- }
752
- );
753
- }
754
-
755
- // src/component/field/field-set.tsx
756
- import { jsx as jsx8 } from "react/jsx-runtime";
757
- function FieldSet(props) {
758
- const { fields = [] } = props.section;
759
- const { compact } = mergeStyle(props.style, {
760
- compact: props.section.compact
761
- });
762
- const group = /* @__PURE__ */ jsx8(Group, { compact, children: props.children });
763
- if (!props.section.title && !props.section.description) {
764
- return group;
765
- }
766
- if (props.section.advanced) {
767
- return /* @__PURE__ */ jsx8(FieldSetAdvanced, { section: props.section, group });
768
- }
769
- return /* @__PURE__ */ jsx8(
770
- FieldSetBase,
771
- {
772
- description: props.section.description,
773
- empty: fields.length === 0,
774
- id: props.section.id?.toString(),
775
- title: props.section.title,
776
- children: group
777
- }
778
- );
779
- }
780
-
781
- // src/client/component/guard/visibility-guard.tsx
782
- import { useAtomValue } from "jotai";
783
-
784
- // src/client/lib/store-helper.ts
785
- import { atom } from "jotai";
786
- import { atomFamily } from "jotai-family";
787
- import { deepEqual } from "fast-equals";
788
- function createRecordAtomFamily(baseAtom) {
789
- return atomFamily(
790
- (name) => atom(
791
- (get) => {
792
- return get(baseAtom)[name] ?? void 0;
793
- },
794
- (get, set, newValue) => {
795
- const current = get(baseAtom);
796
- if (newValue !== void 0 && newValue !== null) {
797
- const currentValue = current[name];
798
- if (!currentValue || !deepEqual(currentValue, newValue)) {
799
- set(baseAtom, { ...current, [name]: newValue });
800
- }
801
- } else if (current[name]) {
802
- const { [name]: _unused, ...rest } = current;
803
- set(baseAtom, rest);
804
- }
805
- }
806
- )
807
- );
808
- }
809
- function createClearAllAtom(baseAtom) {
810
- return atom(null, (get, set) => {
811
- const current = get(baseAtom);
812
- if (current && Object.keys(current).length > 0) {
813
- set(baseAtom, {});
814
- }
815
- });
816
- }
817
- function createClearAtom(baseAtom) {
818
- return atom(null, (get, set, names) => {
819
- const current = get(baseAtom);
820
- const next = { ...current };
821
- let hasChanges = false;
822
- for (const name of names) {
823
- if (next[name]) {
824
- delete next[name];
825
- hasChanges = true;
826
- }
827
- }
828
- if (hasChanges) {
829
- set(baseAtom, next);
830
- }
831
- });
832
- }
833
- function createBulkReportAtom(baseAtom) {
834
- return atom(null, (get, set, newValue) => {
835
- const current = get(baseAtom);
836
- if (!deepEqual(current, newValue)) {
837
- set(baseAtom, newValue);
838
- }
839
- });
840
- }
841
- function createAtomStore(initialValue = {}) {
842
- const baseAtom = atom(initialValue);
843
- return {
844
- atom: baseAtom,
845
- clearAll: createClearAllAtom(baseAtom),
846
- clear: createClearAtom(baseAtom),
847
- bulkReport: createBulkReportAtom(baseAtom),
848
- report: createRecordAtomFamily(baseAtom)
849
- };
850
- }
851
-
852
- // src/client/lib/state-store.ts
853
- var store = createAtomStore();
854
- var fieldStateAtom = store.atom;
855
- var reportFieldStateAtom = store.report;
856
-
857
- // src/client/component/guard/visibility-guard.tsx
858
- function isColumnHidden(column, states) {
859
- return column.fields.every((field) => isFieldHidden(field, states));
860
- }
861
- function isFieldHidden(field, states) {
862
- return states[field.name]?.hidden ?? field.hidden ?? false;
863
- }
864
- function isEntryHidden(entry, states) {
865
- return isColumn(entry) ? isColumnHidden(entry, states) : isFieldHidden(entry, states);
866
- }
867
- function VisibilityGuard(props) {
868
- const states = useAtomValue(fieldStateAtom);
869
- if (props.container) {
870
- const hidden = states[props.container.name]?.hidden ?? props.container.hidden ?? false;
871
- if (hidden) {
872
- return null;
873
- }
874
- }
875
- if (props.fields.length === 0) {
876
- return null;
877
- }
878
- const allHidden = props.fields.every((entry) => isEntryHidden(entry, states));
879
- if (allHidden) {
880
- return null;
881
- }
882
- return props.children;
883
- }
884
-
885
- // src/component/separator.tsx
886
- import { jsx as jsx9 } from "react/jsx-runtime";
887
- function Separator() {
888
- return /* @__PURE__ */ jsx9("div", { "data-slot": "field-separator", className: "relative -my-2 h-5 text-sm", children: /* @__PURE__ */ jsx9("div", { className: "absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800" }) });
889
- }
890
-
891
- // src/component/form.tsx
892
- import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
893
- function Form(props) {
894
- const sections = prepare(props.sections, props.definition);
895
- return /* @__PURE__ */ jsx10("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx10("form", { noValidate: props.noValidate, action: props.action, children: /* @__PURE__ */ jsxs4(Group, { children: [
896
- sections.map((section, index) => /* @__PURE__ */ jsxs4(VisibilityGuard, { fields: section.fields ?? [], children: [
897
- /* @__PURE__ */ jsx10(FieldSet, { section, style: props.config.style, children: props.children({
898
- disabled: props.readOnly,
899
- fields: section.fields
900
- }) }),
901
- section.separator && /* @__PURE__ */ jsx10(Separator, {})
902
- ] }, index)),
903
- props.control && /* @__PURE__ */ jsx10(Control, { isPending: props.isPending, children: props.control })
904
- ] }) }) });
905
- }
906
-
907
- // src/component/description.tsx
908
- import { jsx as jsx11 } from "react/jsx-runtime";
909
- function Description(props) {
910
- return /* @__PURE__ */ jsx11("p", { className: "-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400", children: props.children });
911
- }
912
-
913
- // src/component/formatted-description.tsx
914
- import { jsx as jsx12 } from "react/jsx-runtime";
915
- function FormattedDescription(props) {
916
- const content = formatMarkdown2(props.text);
917
- if (content) {
918
- return /* @__PURE__ */ jsx12(Description, { children: content });
919
- }
920
- return null;
921
- }
922
-
923
- // src/component/label.tsx
924
- import { twMerge } from "tailwind-merge";
925
- import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
926
- function Label(props) {
927
- const showOptionalLabel = props.style?.showOptionalLabel ?? true;
928
- const normal = isRadio(props.field) || isCheckbox(props.field);
929
- return /* @__PURE__ */ jsxs5(
930
- "label",
931
- {
932
- "data-slot": "field-label",
933
- "data-normal": normal,
934
- className: twMerge(
935
- "flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",
936
- "data-[normal=true]:font-normal",
937
- "group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"
938
- ),
939
- htmlFor: props.field.name,
940
- children: [
941
- props.children,
942
- showOptionalLabel && !props.field.required && /* @__PURE__ */ jsx13("span", { className: "text-sm text-slate-600 dark:text-slate-400", children: translate("(Optional)", props.translations) })
943
- ]
944
- }
945
- );
946
- }
947
-
948
- // src/component/input-label.tsx
949
- import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
950
- function InputLabel(props) {
951
- const interpolateOpts = {
952
- context: props.context,
953
- env: props.config?.env
954
- };
955
- const label = interpolateIfNeeded(props.field.label, interpolateOpts);
956
- const description = interpolateIfNeeded(
957
- props.field.description,
958
- interpolateOpts
959
- );
960
- return /* @__PURE__ */ jsxs6(
961
- "div",
962
- {
963
- "data-slot": "field-content",
964
- className: "flex w-full flex-1 flex-col gap-1.5 leading-snug",
965
- children: [
966
- /* @__PURE__ */ jsx14(
967
- Label,
968
- {
969
- field: props.field,
970
- style: props.config?.style,
971
- translations: props.translations,
972
- children: translate(label, props.translations)
973
- }
974
- ),
975
- props.orientation === HORIZONTAL && /* @__PURE__ */ jsx14(
976
- FormattedDescription,
977
- {
978
- text: translate(description, props.translations)
979
- }
980
- )
981
- ]
982
- }
983
- );
984
- }
985
-
986
- // src/component/input-group.tsx
987
- import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
988
- function InputGroup(props) {
989
- return /* @__PURE__ */ jsxs7(Fragment2, { children: [
990
- props.field.name && props.field.label && /* @__PURE__ */ jsx15(
991
- InputLabel,
992
- {
993
- config: props.config,
994
- context: props.context,
995
- field: props.field,
996
- orientation: props.orientation,
997
- translations: props.translations
998
- }
999
- ),
1000
- props.children,
1001
- props.orientation === VERTICAL && props.field.description && /* @__PURE__ */ jsx15(
1002
- FormattedDescription,
1003
- {
1004
- text: translate(props.field.description, props.translations)
1005
- }
1006
- )
1007
- ] });
1008
- }
1009
-
1010
- // src/lib/render-If-exists.ts
1011
- function renderIfExists(value, render) {
1012
- if (!value) {
1013
- return null;
1014
- }
1015
- return render(value);
1016
- }
1017
-
1018
- // src/server/component/input.tsx
1019
- import { jsx as jsx16 } from "react/jsx-runtime";
1020
- function Input(props) {
1021
- const source = resolveSource(props.field, props.value);
1022
- const { commonPropsWithOptions, defaultValue } = prepareInputProps(
1023
- props.field,
1024
- props.commonProps,
1025
- source,
1026
- props.value
1027
- );
1028
- const defaultProps = prepareDefaultValue(props.field, defaultValue);
1029
- return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ jsx16(
1030
- InputGroup,
1031
- {
1032
- config: props.config,
1033
- context: props.context,
1034
- field: props.field,
1035
- orientation: props.orientation,
1036
- translations: props.translations,
1037
- children: /* @__PURE__ */ jsx16(
1038
- Component,
1039
- {
1040
- ...props.ariaAttributes,
1041
- ...commonPropsWithOptions,
1042
- ...props.dataAttributes,
1043
- ...defaultProps
1044
- }
1045
- )
1046
- }
1047
- ));
1048
- }
1049
-
1050
- // src/component/field/field-error.tsx
1051
- import { jsx as jsx17 } from "react/jsx-runtime";
1052
- function FieldError(props) {
1053
- if (!props.errors || props.errors.length === 0) {
1054
- return null;
1055
- }
1056
- return /* @__PURE__ */ jsx17(
1057
- "ul",
1058
- {
1059
- className: "text-sm text-red-600 dark:text-red-500",
1060
- id: props.name ? `${props.name}-error` : void 0,
1061
- children: props.errors?.map((error, index) => /* @__PURE__ */ jsx17("li", { children: error }, props.name ? `${props.name}-error-${index}` : index))
1062
- }
1063
- );
1064
- }
1065
-
1066
- // src/component/field/field-base.tsx
1067
- import { twMerge as twMerge2 } from "tailwind-merge";
1068
- import { jsx as jsx18 } from "react/jsx-runtime";
1069
- function FieldBase(props) {
1070
- const errors = props.errors && props.errors.length > 0;
1071
- return /* @__PURE__ */ jsx18(
1072
- "div",
1073
- {
1074
- "data-slot": "field",
1075
- "data-clickable": props.isClickable ? "true" : "false",
1076
- ...errors && { [DATA_INVALID]: "true" },
1077
- ...props.disabled && { [DATA_READONLY]: "true" },
1078
- "data-orientation": props.orientation,
1079
- className: twMerge2(
1080
- "group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500",
1081
- "data-[clickable=true]:items-start",
1082
- props.isCheckbox && (props.isReversed ? "flex-row-reverse!" : "flex-row!"),
1083
- "data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",
1084
- props.className
1085
- ),
1086
- children: props.children
1087
- }
1088
- );
1089
- }
1090
-
1091
- // src/component/field/field-vertical.tsx
1092
- import { twMerge as twMerge3 } from "tailwind-merge";
1093
- import { jsx as jsx19 } from "react/jsx-runtime";
1094
- function FieldVertical(props) {
1095
- return /* @__PURE__ */ jsx19(
1096
- FieldBase,
1097
- {
1098
- ...props,
1099
- orientation: VERTICAL,
1100
- className: twMerge3(
1101
- "gap-3 has-[>[data-slot=field-content]]:items-start",
1102
- !props.isClickable && "[&>*]:w-full"
1103
- ),
1104
- children: props.children
1105
- }
1106
- );
1107
- }
1108
-
1109
- // src/component/field/field-horizontal.tsx
1110
- import { twMerge as twMerge4 } from "tailwind-merge";
1111
- import { jsx as jsx20 } from "react/jsx-runtime";
1112
- function FieldHorizontal(props) {
1113
- return /* @__PURE__ */ jsx20(
1114
- FieldBase,
1115
- {
1116
- ...props,
1117
- orientation: HORIZONTAL,
1118
- className: twMerge4(
1119
- "gap-2 md:flex-row md:gap-4",
1120
- "[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start",
1121
- "[&_[role=checkbox]]:mt-[1.5px]",
1122
- props.isClickable && "md:flex-col",
1123
- !props.isClickable && [
1124
- "md:justify-between",
1125
- "[&>*:not([data-slot=field-content])]:w-full",
1126
- "[&>*:not([data-slot=field-content])]:md:w-1/2",
1127
- "[&>*:not([data-slot=field-content])]:xl:w-2/5"
1128
- ]
1129
- ),
1130
- children: props.children
1131
- }
1132
- );
1133
- }
1134
-
1135
- // src/component/field/field-group.tsx
1136
- import { jsx as jsx21 } from "react/jsx-runtime";
1137
- function FieldGroup(props) {
1138
- const clickable = isClickable(props.field);
1139
- const checkbox = isCheckbox(props.field);
1140
- const reversed = buildReverse(props.field);
1141
- if (props.orientation === VERTICAL) {
1142
- return /* @__PURE__ */ jsx21(
1143
- FieldVertical,
1144
- {
1145
- disabled: props.disabled,
1146
- errors: props.errors,
1147
- isCheckbox: checkbox,
1148
- isReversed: reversed,
1149
- isClickable: clickable,
1150
- children: props.children
1151
- }
1152
- );
1153
- }
1154
- return /* @__PURE__ */ jsx21(
1155
- FieldHorizontal,
1156
- {
1157
- disabled: props.disabled,
1158
- errors: props.errors,
1159
- isCheckbox: checkbox,
1160
- isReversed: reversed,
1161
- isClickable: clickable,
1162
- children: props.children
1163
- }
1164
- );
1165
- }
1166
-
1167
- // src/component/input/input-base.tsx
1168
- function InputBase(props) {
1169
- if (!props.field.type) {
1170
- return null;
1171
- }
1172
- const commonProps = buildCommon(props.field, props.disabled);
1173
- const dataAttributes = buildDataAttributes(props.field);
1174
- const ariaAttributes = buildAriaAttributes(props.field, props.errors);
1175
- const field = {
1176
- ...props.field,
1177
- disabled: commonProps.disabled
1178
- };
1179
- return props.children({
1180
- ariaAttributes,
1181
- commonProps,
1182
- dataAttributes,
1183
- field,
1184
- orientation: props.orientation
1185
- });
1186
- }
1187
-
1188
- // src/component/field/field.tsx
1189
- import { twMerge as twMerge5 } from "tailwind-merge";
1190
- import { jsx as jsx22, jsxs as jsxs8 } from "react/jsx-runtime";
1191
- function Field(props) {
1192
- const cols2 = props.field.advanced?.cols;
1193
- const errors = props.field.name ? props.errors?.[props.field.name] : void 0;
1194
- const { orientation } = mergeStyle(props.style, {
1195
- orientation: buildOrientation(props.field)
1196
- });
1197
- const disabled = buildDisabled(props.field, props.disabled);
1198
- return /* @__PURE__ */ jsxs8("div", { className: twMerge5("flex flex-col gap-3", getSpan(cols2)), children: [
1199
- /* @__PURE__ */ jsx22(
1200
- FieldGroup,
1201
- {
1202
- disabled,
1203
- errors,
1204
- field: props.field,
1205
- orientation,
1206
- children: /* @__PURE__ */ jsx22(
1207
- InputBase,
1208
- {
1209
- disabled,
1210
- errors,
1211
- field: props.field,
1212
- orientation,
1213
- children: props.children
1214
- }
1215
- )
1216
- }
1217
- ),
1218
- /* @__PURE__ */ jsx22(FieldError, { errors, name: props.field.name })
1219
- ] });
1220
- }
1221
-
1222
- // src/component/field/field-list-item.tsx
1223
- import { twMerge as twMerge6 } from "tailwind-merge";
1224
- import { jsx as jsx23, jsxs as jsxs9 } from "react/jsx-runtime";
1225
- function FieldListItem(props) {
1226
- function handleRemove() {
1227
- if (props.canRemove && props.onRemove) {
1228
- props.onRemove(props.index);
1229
- }
1230
- }
1231
- const removeButton = props.canRemove && props.onRemove != null && /* @__PURE__ */ jsx23(
1232
- "button",
1233
- {
1234
- "aria-label": `Remove ${props.label} item ${props.index + 1}`,
1235
- className: twMerge6(
1236
- "rounded p-1 text-xl text-slate-400",
1237
- "transition-colors duration-150",
1238
- "hover:text-red-500",
1239
- "focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none",
1240
- "dark:text-slate-500 dark:hover:text-red-400"
1241
- ),
1242
- onClick: handleRemove,
1243
- type: "button",
1244
- children: /* @__PURE__ */ jsx23("span", { "aria-hidden": "true", children: "\xD7" })
1245
- }
1246
- );
1247
- if (props.isMultiField) {
1248
- return /* @__PURE__ */ jsxs9("div", { className: "rounded-lg border border-slate-100 p-4 dark:border-slate-900", children: [
1249
- /* @__PURE__ */ jsxs9("div", { className: "mb-3 flex items-center justify-between", children: [
1250
- /* @__PURE__ */ jsxs9("span", { className: "text-sm font-medium text-slate-400 dark:text-slate-500", children: [
1251
- props.label,
1252
- " ",
1253
- props.index + 1
1254
- ] }),
1255
- removeButton
1256
- ] }),
1257
- /* @__PURE__ */ jsx23(Group, { children: props.children })
1258
- ] });
1259
- }
1260
- return /* @__PURE__ */ jsxs9("div", { className: "flex items-start gap-2", children: [
1261
- /* @__PURE__ */ jsx23(Group, { children: props.children }),
1262
- removeButton && /* @__PURE__ */ jsx23("div", { className: "shrink-0", children: removeButton })
1263
- ] });
1264
- }
1265
-
1266
- // src/component/field/field-list.tsx
1267
- import { jsx as jsx24 } from "react/jsx-runtime";
1268
- function FieldList(props) {
1269
- const label = getLabel(props.field);
1270
- const isMultiField = isMultiFieldList(props.field);
1271
- return getInitialList(props.field, props.value).map((index) => /* @__PURE__ */ jsx24(
1272
- FieldListItem,
1273
- {
1274
- index,
1275
- isMultiField,
1276
- label,
1277
- children: props.children(index)
1278
- },
1279
- index
1280
- ));
1281
- }
1282
-
1283
- // src/component/list.tsx
1284
- import { jsx as jsx25 } from "react/jsx-runtime";
1285
- function List(props) {
1286
- const empty = Array.isArray(props.field.fields) && props.field.fields.length === 0;
1287
- return /* @__PURE__ */ jsx25(
1288
- FieldSetBase,
1289
- {
1290
- description: props.field.description,
1291
- empty,
1292
- id: props.field.name,
1293
- title: props.field.label,
1294
- children: props.children
1295
- }
1296
- );
1297
- }
1298
-
1299
- // src/component/slot/list-slot.tsx
1300
- import { jsx as jsx26 } from "react/jsx-runtime";
1301
- function ListSlot({ children, field, value }) {
1302
- return /* @__PURE__ */ jsx26(List, { field, children: /* @__PURE__ */ jsx26(FieldList, { field, value, children }) });
1303
- }
1304
-
1305
- // src/component/column.tsx
1306
- import { twMerge as twMerge7 } from "tailwind-merge";
1307
- import { jsx as jsx27 } from "react/jsx-runtime";
1308
- function Column(props) {
1309
- const cols2 = getColumn(props.column?.advanced?.cols);
1310
- return /* @__PURE__ */ jsx27("div", { className: "flex w-full flex-col gap-4", children: /* @__PURE__ */ jsx27("div", { className: twMerge7("grid grid-cols-1 gap-3 sm:gap-4", cols2), children: props.children }) });
1311
- }
1312
-
1313
- // src/component/slot/slot-base.tsx
1314
- import { Fragment as Fragment3 } from "react";
1315
-
1316
- // src/component/slot/slot-list.tsx
1317
- import { jsx as jsx28 } from "react/jsx-runtime";
1318
- function SlotList(props) {
1319
- const fields = Array.isArray(props.field.fields) ? props.field.fields.map((field) => {
1320
- if (isField(field)) {
1321
- return {
1322
- ...field,
1323
- name: `${props.field.name}.${props.index}.${field.name}`
1324
- };
1325
- }
1326
- if (isColumn(field)) {
1327
- return {
1328
- ...field,
1329
- fields: field.fields.map((columnField) => ({
1330
- ...columnField,
1331
- name: `${props.field.name}.${props.index}.${columnField.name}`
1332
- }))
1333
- };
1334
- }
1335
- return field;
1336
- }) : [];
1337
- return /* @__PURE__ */ jsx28(
1338
- SlotBase,
1339
- {
1340
- children: props.children,
1341
- components: props.components,
1342
- disabled: props.disabled,
1343
- fields,
1344
- style: props.style,
1345
- value: props.value
1346
- }
1347
- );
1348
- }
1349
-
1350
- // src/component/slot/slot-base.tsx
1351
- import { jsx as jsx29, jsxs as jsxs10 } from "react/jsx-runtime";
1352
- function SlotBase(props) {
1353
- const { field: Field2, list: List2 } = props.components;
1354
- return prepare(props.fields).map((field, index) => /* @__PURE__ */ jsxs10(Fragment3, { children: [
1355
- isColumn(field) && /* @__PURE__ */ jsx29(Column, { column: field, children: /* @__PURE__ */ jsx29(SlotBase, { ...props, fields: field.fields }) }),
1356
- isField(field) && /* @__PURE__ */ jsx29(Field2, { disabled: props.disabled, field, style: props.style, children: props.children }),
1357
- isList(field) && /* @__PURE__ */ jsx29(List2, { field, value: props.value, children: (index2) => /* @__PURE__ */ jsx29(
1358
- SlotList,
1359
- {
1360
- children: props.children,
1361
- components: props.components,
1362
- disabled: props.disabled,
1363
- field,
1364
- index: index2,
1365
- style: props.style,
1366
- value: props.value
1367
- }
1368
- ) })
1369
- ] }, index));
1370
- }
1371
-
1372
- // src/component/slot/slot-create.tsx
1373
- import { jsx as jsx30 } from "react/jsx-runtime";
1374
- function createSlot(components) {
1375
- const CreateSlot = (props) => /* @__PURE__ */ jsx30(SlotBase, { ...props, components });
1376
- return CreateSlot;
1377
- }
1378
-
1379
- // src/component/slot/slot.tsx
1380
- var Slot = createSlot({ field: Field, list: ListSlot });
1381
-
1382
- // src/server/component/form.tsx
1383
- import { jsx as jsx31 } from "react/jsx-runtime";
1384
- function Form2(props) {
1385
- const translations = props.translations?.[props.lang ?? ""];
1386
- return /* @__PURE__ */ jsx31(
1387
- Form,
1388
- {
1389
- config: props.config,
1390
- control: props.children,
1391
- definition: props.definition,
1392
- readOnly: props.readOnly,
1393
- sections: props.sections,
1394
- children: ({ disabled, fields }) => /* @__PURE__ */ jsx31(Slot, { disabled, fields, style: props.config.style, children: (internal) => /* @__PURE__ */ jsx31(
1395
- Input,
1396
- {
1397
- ...internal,
1398
- config: props.config,
1399
- context: props.context,
1400
- translations,
1401
- value: props.value
1402
- }
1403
- ) })
1404
- }
1405
- );
1406
- }
1407
-
1408
- // src/server/component/fallback.tsx
1409
- import { Suspense } from "react";
1410
- import { jsx as jsx32 } from "react/jsx-runtime";
1411
- function Fallback(props) {
1412
- return /* @__PURE__ */ jsx32(
1413
- Suspense,
1414
- {
1415
- fallback: /* @__PURE__ */ jsx32(Form2, { config: props.config, sections: props.sections, readOnly: true }),
1416
- children: props.children
1417
- }
1418
- );
1419
- }
1420
- export {
1421
- Fallback,
1422
- Form2 as Form
1423
- };
1
+ import{jsx as ln}from"react/jsx-runtime";function oe(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return ln("div",{"data-slot":"field-control",className:"w-full",children:t})}import{Activity as vn,useCallback as En,useState as On}from"react";import{jsx as ie}from"react/jsx-runtime";function le(e){return ie("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:`size-4 transition-transform duration-200 ${e.expanded?"rotate-90":""}`,children:ie("path",{fillRule:"evenodd",d:"M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})})}var O="input",ae="input/email",se="input/number";var de="textarea",ce="radio",ue="checkbox",Y="list";var fe="select",me="select/month",pe="select/year";var F="column",H="fields",ge="label",X="value",w="options",K="email",ye="number",xe="password",be="tel",S="text",Re="aria-errormessage",Te="aria-invalid",he="data-invalid",Ae="data-readonly",Fe="aria",Se="data",Ne="min",Ce="max",Ie="minLength",Le="maxLength",T="$ref";var m="vertical",h="horizontal";var ke="type";function a(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function p(e){return g(e)||typeof e=="number"||an(e)}function g(e){return typeof e=="string"}function an(e){return typeof e=="boolean"}function ve(e,t=X){if(e!=null){if(p(e))return e;if(a(e)){let n=sn(e,t);if(p(n))return n}}}function sn(e,t){let n=u(e,t);if(p(n))return n}function u(e,t){if(!t||!a(e))return null;let n=t.split(".").filter(o=>o!=="");if(n.length===0)return null;let r=e;for(let o of n)if(a(r)&&o in r)r=r[o];else return null;return r}function Ee(e,t={label:ge,value:X}){return e.map(n=>{if(a(n)){let r=u(n,t.label),o=u(n,t.value);if(p(r)&&p(o))return{label:`${r}`,value:`${o}`}}return n})}function Oe(e=S){if(e){let t=e.lastIndexOf("/"),n=t===-1?e:e.slice(t+1);if(n&&n!==O)return n.trim().toLowerCase()}return S}var dn=/\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g;function W(e,t={}){if(g(e))return cn(e,t);if(Array.isArray(e))return e.map(n=>W(n,t));if(a(e)){let n={};for(let r in e)n[r]=W(e[r],t);return n}return e}function z(e,t={}){return q(e)?W(e,t):e}function q(e){return g(e)?/{([^}]{1,200})}/.test(e):Array.isArray(e)?e.some(t=>q(t)):a(e)?Object.values(e).some(t=>q(t)):!1}function cn(e,t={}){return e.replace(/{([^}]{1,200})}/g,(n,r)=>{let o=r.includes(".")?u(t,r):t[r];return p(o)?String(o):n})}function we(e,t){if(!e||e.trim().length===0)return null;let n,r=0,o=!1,i=[];for(;(n=dn.exec(e))!==null;){let[l,s,rn]=n,E=n.index;o=!0,E>r&&i.push(e.substring(r,E));let on=t?t(E,rn,s):l;i.push(on),r=E+l.length}return o?(r<e.length&&i.push(e.substring(r)),i):e}var Pe=e=>c(me)(e),Me=e=>c(pe)(e),d=c(ue),De=c(O),x=c(ce),f=c(fe),_e=c(de),Ve=c(S,K,xe,be),wr=c(ae,K),Be=c(se,ye);function Ge(e){return x(e)||d(e)}function $e(e){return e.type===Y}function A(e){return e.type===F}function P(e){return e.type!==F&&e.type!==Y}function Ue(e){return f(e)||x(e)}function Z(e){return e!=null&&e!==""}function c(...e){return t=>{let n=g(t.type)?t.type:void 0;return n?e.some(r=>n===r||n?.startsWith(`${r}/`)):!1}}function Ye(e,t={}){if(f(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&a(n))return[n]}}function He(e){return x(e)||d(e)?h:e.advanced?.orientation??m}function Xe(e){return d(e)?e.advanced?.reverse!==!1:!1}function Ke(e,t){let n=e.readonly??!1;return t||n}function We(e){if(x(e)||f(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||a(t)&&!(T in t))return t}}var un=/^\d+$/;function qe(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function ze(e,t){return t>=e?Array.from({length:t-e+1},(n,r)=>{let o=e+r;return{value:o.toString(),label:o.toString()}}):[]}function J(){return new Date().getFullYear()}function Q(e,t){if(typeof e=="number")return e;let n=t??J(),r=e.trim().toLowerCase();if(r.startsWith("current")){let o=r.match(/^current([+-])(\d+)$/);if(o){let[,i,l]=o,s=parseInt(l,10);if(!isNaN(s))return i==="+"?n+s:n-s}return n}return un.test(r)?parseInt(r,10):n}var M=J();function fn(e){if(f(e))return mn(e)}function mn(e){if(Pe(e))return qe();if(Me(e)){let t=e.advanced?.length?.min??M,n=e.advanced?.length?.max??M+5;return ze(Q(t,M),Q(n,M))}}function Ze(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return De(e)?{...n,...pn(e)}:f(e)?{...n,...gn(e)}:_e(e)?{...n,...yn(e)}:n}function pn(e){let t=Oe(e.type),n={...e,type:t};return{...Je(e),...xn(n),...Ve(n)?Qe(n):{},type:t}}function gn(e){let t=fn(e);return t?{options:t}:{}}function yn(e){return{...Je(e),...Qe(e)}}function Je(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function xn(e){return Be(e)?bn(e):{}}function Qe(e){return je(e,{min:Ie,max:Le})}function bn(e){return je(e,{min:Ne,max:Ce})}function je(e,t){let n={},r=e.advanced?.length;return r&&(r.min!==void 0&&(n[t.min]=r.min),r.max!==void 0&&(n[t.max]=r.max)),n}function et(e,t){let n=We(e);return n||Ye(e,t)}function Rn(e,t){let n=a(t)&&e.name in t?t[e.name]:t;return ve(n,e.advanced?.entity)}function Tn(e,t,n){return Ue(e)&&Array.isArray(n)?{...t,[w]:n}:t}function hn(e,t,n){if(e.required&&!Z(n)&&f(e)&&e.advanced?.preselected!==!1&&w in t){let r=t[w];if(Array.isArray(r)&&r.length===1)return r[0]}return n}function An(e,t){return f(e)&&Array.isArray(t)?Ee(t,e.advanced?.options):t}function tt(e,t,n,r){let o=Rn(e,r),i=Array.isArray(n)?An(e,n):n,l=Tn(e,t,i),s=hn(e,l,o);return{commonPropsWithOptions:l,defaultValue:s}}function nt(e,t){return d(e)?{defaultChecked:Z(t)}:{defaultValue:t}}var Fn=/^#\/definition\//;function _(e=[],t){let n=D(e,t);return Array.isArray(n)?n.filter(Nn).sort((r,o)=>rt(r)-rt(o)):[]}function D(e,t,n=new Map,r=new WeakSet){if(!Sn(t)||!e||typeof e!="object")return e;if(n.has(e))return n.get(e);if(r.has(e))return e;if(r.add(e),Array.isArray(e))return e.map(i=>D(i,t,n,r));if(T in e&&g(e[T])){let i=e[T].replace(Fn,""),l=u(t,i);return l!==null?D(l,t,n,r):e}let o={};for(let[i,l]of Object.entries(e))o[i]=D(l,t,n,r);return r.delete(e),n.set(e,o),o}function ot(e){return Object.entries(e??{})}function rt(e){return e.order??Number.MAX_VALUE}function Sn(e){return e!==void 0&&a(e)&&Object.keys(e).length>0}function Nn(e){return ke in e?!0:Array.isArray(e[H])?e[H].length>0:!0}function it(e,t){let n={};for(let[r,o]of ot(t))n[`${e}-${r}`]=o;return n}function Cn(e){return it(Fe,e)}function In(e){return it(Se,e)}function lt(e,t){let n=Cn(e.advanced?.aria);return t&&t.length>0&&(n[Te]="true",n[Re]=`${e.name}-error`),n}function at(e){return In(e.advanced?.data)}var st={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},dt={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function ct(e,t=2){return st[e&&e in st?e:t]}function ut(e){if(e&&e in dt)return dt[e]}function Ln(e,t){let n=e.advanced?.length?.min??1;if(t){let r=u(t,e.name);if(Array.isArray(r))return Math.max(r.length,n)}return Math.max(n,0)}function ft(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===F}function mt(e,t){let n=Ln(e,t);return Array.from({length:n},(r,o)=>o)}function pt(e){return e.label??e.name}function b(e,t){return e?t?t[e]??e:e:""}function V(e,t){return{...e,...t}}import{jsx as kn}from"react/jsx-runtime";function y(e){return we(e,(t,n,r)=>kn("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:r},`${n}-${t}`))}import{jsx as N,jsxs as j}from"react/jsx-runtime";function gt(e){let{fields:t=[]}=e.section,[n,r]=On(!1),o=En(()=>r(i=>!i),[]);return j("fieldset",{"data-slot":"field-set","data-advanced":"true","data-expanded":n,"data-empty":t.length===0,className:"flex flex-col",id:e.section.id?.toString(),children:[N("legend",{children:j("button",{className:"flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",onClick:o,type:"button",children:[N(le,{expanded:n}),N("span",{children:y(e.section.title)})]})}),N(vn,{mode:n?"visible":"hidden",children:j("div",{className:"mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600","data-slot":"field-set-content",children:[e.section.description&&N("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:y(e.section.description)}),e.group]})})]})}import{Fragment as wn,jsx as yt,jsxs as Pn}from"react/jsx-runtime";function xt(e){return Pn(wn,{children:[e.title&&yt("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:y(e.title)}),e.description&&yt("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:y(e.description)})]})}import{jsx as Mn,jsxs as Dn}from"react/jsx-runtime";function B(e){return Dn("fieldset",{"data-slot":"field-set","data-empty":e.empty,className:"flex flex-col data-[empty=false]:gap-6",id:e.id,children:[Mn(xt,{description:e.description,title:e.title}),e.children]})}import{jsx as _n}from"react/jsx-runtime";function R(e){return _n("div",{"data-slot":"field-group","data-compact":e.compact,className:"flex w-full flex-col gap-8 data-[compact=true]:gap-3",children:e.children})}import{jsx as ee}from"react/jsx-runtime";function bt(e){let{fields:t=[]}=e.section,{compact:n}=V(e.style,{compact:e.section.compact}),r=ee(R,{compact:n,children:e.children});return!e.section.title&&!e.section.description?r:e.section.advanced?ee(gt,{section:e.section,group:r}):ee(B,{description:e.section.description,empty:t.length===0,id:e.section.id?.toString(),title:e.section.title,children:r})}import{useAtomValue as Hn}from"jotai";import{atom as C}from"jotai";import{atomFamily as Vn}from"jotai-family";import{deepEqual as Rt}from"fast-equals";function Bn(e,t){let{[t]:n,...r}=e;return r}function Gn(e){return Vn(t=>C(n=>n(e)[t]??void 0,(n,r,o)=>{let i=n(e);if(o!=null){let l=i[t];(!l||!Rt(l,o))&&r(e,{...i,[t]:o})}else i[t]&&r(e,Bn(i,t))}))}function $n(e){return C(null,(t,n)=>{let r=t(e);r&&Object.keys(r).length>0&&n(e,{})})}function Un(e){return C(null,(t,n,r)=>{let i={...t(e)},l=!1;for(let s of r)i[s]&&(delete i[s],l=!0);l&&n(e,i)})}function Yn(e){return C(null,(t,n,r)=>{let o=t(e);Rt(o,r)||n(e,r)})}function Tt(e={}){let t=C(e);return{atom:t,clearAll:$n(t),clear:Un(t),bulkReport:Yn(t),report:Gn(t)}}var ht=Tt(),At=ht.atom,Po=ht.report;function Xn(e,t){return e.fields.every(n=>Ft(n,t))}function Ft(e,t){return t[e.name]?.hidden??e.hidden??!1}function Kn(e,t){return A(e)?Xn(e,t):Ft(e,t)}function St(e){let t=Hn(At);return e.container&&(t[e.container.name]?.hidden??e.container.hidden??!1)||e.fields.length===0||e.fields.every(r=>Kn(r,t))?null:e.children}import{jsx as Nt}from"react/jsx-runtime";function Ct(){return Nt("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:Nt("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}import{jsx as I,jsxs as It}from"react/jsx-runtime";function Lt(e){let t=_(e.sections,e.definition);return I("div",{className:"h-full w-full",children:I("form",{noValidate:e.noValidate,action:e.action,children:It(R,{children:[t.map((n,r)=>It(St,{fields:n.fields??[],children:[I(bt,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&I(Ct,{})]},r)),e.control&&I(oe,{isPending:e.isPending,children:e.control})]})})})}import{jsx as Wn}from"react/jsx-runtime";function kt(e){return Wn("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}import{jsx as qn}from"react/jsx-runtime";function G(e){let t=y(e.text);return t?qn(kt,{children:t}):null}import{twMerge as zn}from"tailwind-merge";import{jsx as Zn,jsxs as Jn}from"react/jsx-runtime";function vt(e){let t=e.style?.showOptionalLabel??!0,n=x(e.field)||d(e.field);return Jn("label",{"data-slot":"field-label","data-normal":n,className:zn("flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none","data-[normal=true]:font-normal","group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"),htmlFor:e.field.name,children:[e.children,t&&!e.field.required&&Zn("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:b("(Optional)",e.translations)})]})}import{jsx as Et,jsxs as Qn}from"react/jsx-runtime";function Ot(e){let t={context:e.context,env:e.config?.env},n=z(e.field.label,t),r=z(e.field.description,t);return Qn("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[Et(vt,{field:e.field,style:e.config?.style,translations:e.translations,children:b(n,e.translations)}),e.orientation===h&&Et(G,{text:b(r,e.translations)})]})}import{Fragment as jn,jsx as wt,jsxs as er}from"react/jsx-runtime";function Pt(e){return er(jn,{children:[e.field.name&&e.field.label&&wt(Ot,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations}),e.children,e.orientation===m&&e.field.description&&wt(G,{text:b(e.field.description,e.translations)})]})}function Mt(e,t){return e?t(e):null}import{jsx as Dt}from"react/jsx-runtime";function _t(e){let t=et(e.field,e.value),{commonPropsWithOptions:n,defaultValue:r}=tt(e.field,e.commonProps,t,e.value),o=nt(e.field,r);return Mt(e.config.inputs[e.field.type],i=>Dt(Pt,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations,children:Dt(i,{...e.ariaAttributes,...n,...e.dataAttributes,...o})}))}import{jsx as Vt}from"react/jsx-runtime";function Bt(e){return!e.errors||e.errors.length===0?null:Vt("ul",{className:"text-sm text-red-600 dark:text-red-500",id:e.name?`${e.name}-error`:void 0,children:e.errors?.map((t,n)=>Vt("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}import{twMerge as tr}from"tailwind-merge";import{jsx as nr}from"react/jsx-runtime";function $(e){let t=e.errors&&e.errors.length>0;return nr("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[he]:"true"},...e.disabled&&{[Ae]:"true"},"data-orientation":e.orientation,className:tr("group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500","data-[clickable=true]:items-start",e.isCheckbox&&(e.isReversed?"flex-row-reverse!":"flex-row!"),"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",e.className),children:e.children})}import{twMerge as rr}from"tailwind-merge";import{jsx as or}from"react/jsx-runtime";function Gt(e){return or($,{...e,orientation:m,className:rr("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as ir}from"tailwind-merge";import{jsx as lr}from"react/jsx-runtime";function $t(e){return lr($,{...e,orientation:h,className:ir("gap-2 md:flex-row md:gap-4","[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start","[&_[role=checkbox]]:mt-[1.5px]",e.isClickable&&"md:flex-col",!e.isClickable&&["md:justify-between","[&>*:not([data-slot=field-content])]:w-full","[&>*:not([data-slot=field-content])]:md:w-1/2","[&>*:not([data-slot=field-content])]:xl:w-2/5"]),children:e.children})}import{jsx as Ut}from"react/jsx-runtime";function Yt(e){let t=Ge(e.field),n=d(e.field),r=Xe(e.field);return e.orientation===m?Ut(Gt,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children}):Ut($t,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children})}function Ht(e){if(!e.field.type)return null;let t=Ze(e.field,e.disabled),n=at(e.field),r=lt(e.field,e.errors),o={...e.field,disabled:t.disabled};return e.children({ariaAttributes:r,commonProps:t,dataAttributes:n,field:o,orientation:e.orientation})}import{twMerge as ar}from"tailwind-merge";import{jsx as te,jsxs as sr}from"react/jsx-runtime";function Xt(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{orientation:r}=V(e.style,{orientation:He(e.field)}),o=Ke(e.field,e.disabled);return sr("div",{className:ar("flex flex-col gap-3",ut(t)),children:[te(Yt,{disabled:o,errors:n,field:e.field,orientation:r,children:te(Ht,{disabled:o,errors:n,field:e.field,orientation:r,children:e.children})}),te(Bt,{errors:n,name:e.field.name})]})}import{twMerge as dr}from"tailwind-merge";import{jsx as L,jsxs as U}from"react/jsx-runtime";function Kt(e){function t(){e.canRemove&&e.onRemove&&e.onRemove(e.index)}let n=e.canRemove&&e.onRemove!=null&&L("button",{"aria-label":`Remove ${e.label} item ${e.index+1}`,className:dr("rounded p-1 text-xl text-slate-400","transition-colors duration-150","hover:text-red-500","focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none","dark:text-slate-500 dark:hover:text-red-400"),onClick:t,type:"button",children:L("span",{"aria-hidden":"true",children:"\xD7"})});return e.isMultiField?U("div",{className:"rounded-lg border border-slate-100 p-4 dark:border-slate-900",children:[U("div",{className:"mb-3 flex items-center justify-between",children:[U("span",{className:"text-sm font-medium text-slate-400 dark:text-slate-500",children:[e.label," ",e.index+1]}),n]}),L(R,{children:e.children})]}):U("div",{className:"flex items-start gap-2",children:[L(R,{children:e.children}),n&&L("div",{className:"shrink-0",children:n})]})}import{jsx as cr}from"react/jsx-runtime";function Wt(e){let t=pt(e.field),n=ft(e.field);return mt(e.field,e.value).map(r=>cr(Kt,{index:r,isMultiField:n,label:t,children:e.children(r)},r))}import{jsx as ur}from"react/jsx-runtime";function qt(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0;return ur(B,{description:e.field.description,empty:t,id:e.field.name,title:e.field.label,children:e.children})}import{jsx as zt}from"react/jsx-runtime";function Zt({children:e,field:t,value:n}){return zt(qt,{field:t,children:zt(Wt,{field:t,value:n,children:e})})}import{twMerge as fr}from"tailwind-merge";import{jsx as Jt}from"react/jsx-runtime";function Qt(e){let t=ct(e.column?.advanced?.cols);return Jt("div",{className:"flex w-full flex-col gap-4",children:Jt("div",{className:fr("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children})})}import{Fragment as pr}from"react";import{jsx as mr}from"react/jsx-runtime";function jt(e){let t=Array.isArray(e.field.fields)?e.field.fields.map(n=>P(n)?{...n,name:`${e.field.name}.${e.index}.${n.name}`}:A(n)?{...n,fields:n.fields.map(r=>({...r,name:`${e.field.name}.${e.index}.${r.name}`}))}:n):[];return mr(k,{children:e.children,components:e.components,disabled:e.disabled,fields:t,style:e.style,value:e.value})}import{jsx as v,jsxs as gr}from"react/jsx-runtime";function k(e){let{field:t,list:n}=e.components;return _(e.fields).map((r,o)=>gr(pr,{children:[A(r)&&v(Qt,{column:r,children:v(k,{...e,fields:r.fields})}),P(r)&&v(t,{disabled:e.disabled,field:r,style:e.style,children:e.children}),$e(r)&&v(n,{field:r,value:e.value,children:i=>v(jt,{children:e.children,components:e.components,disabled:e.disabled,field:r,index:i,style:e.style,value:e.value})})]},o))}import{jsx as yr}from"react/jsx-runtime";function en(e){return n=>yr(k,{...n,components:e})}var tn=en({field:Xt,list:Zt});import{jsx as ne}from"react/jsx-runtime";function re(e){let t=e.translations?.[e.lang??""];return ne(Lt,{config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:r})=>ne(tn,{disabled:n,fields:r,style:e.config.style,children:o=>ne(_t,{...o,config:e.config,context:e.context,translations:t,value:e.value})})})}import{Suspense as xr}from"react";import{jsx as nn}from"react/jsx-runtime";function br(e){return nn(xr,{fallback:nn(re,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{br as Fallback,re as Form};