react-luna-form 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/cjs/index.js +927 -447
- package/dist/client/esm/index.js +916 -436
- package/dist/server/cjs/index.js +462 -101
- package/dist/server/esm/index.js +463 -102
- package/dist/types/luna-core/src/handle/state-event.d.ts +1 -1
- package/dist/types/luna-core/src/index.d.ts +1 -0
- package/dist/types/luna-core/src/type.d.ts +17 -2
- package/dist/types/luna-core/src/util/constant.d.ts +4 -0
- package/dist/types/luna-core/src/util/extract.d.ts +2 -1
- package/dist/types/luna-core/src/util/is-input.d.ts +4 -3
- package/dist/types/luna-core/src/util/is-type.d.ts +1 -0
- package/dist/types/luna-core/src/util/list.d.ts +4 -0
- package/dist/types/luna-core/src/util/prepare.d.ts +2 -2
- package/dist/types/luna-core/src/util/string.d.ts +1 -0
- package/dist/types/luna-react/src/client/component/field/field-list.d.ts +2 -0
- package/dist/types/luna-react/src/client/component/{wrapper/with-error.d.ts → field/field-with-error.d.ts} +1 -1
- package/dist/types/luna-react/src/client/component/{wrapper/with-field-state.d.ts → field/field-with-state.d.ts} +1 -1
- package/dist/types/luna-react/src/client/component/guard/list-guard.d.ts +2 -0
- package/dist/types/luna-react/src/client/component/guard/visibility-guard.d.ts +6 -0
- package/dist/types/luna-react/src/client/component/slot/slot.d.ts +7 -0
- package/dist/types/luna-react/src/client/hook/use-field-list.d.ts +2 -0
- package/dist/types/luna-react/src/component/chevron-icon.d.ts +3 -0
- package/dist/types/luna-react/src/component/column.d.ts +2 -3
- package/dist/types/luna-react/src/component/field/field-base.d.ts +4 -2
- package/dist/types/luna-react/src/component/field/field-horizontal.d.ts +2 -8
- package/dist/types/luna-react/src/component/field/field-list-item.d.ts +8 -0
- package/dist/types/luna-react/src/component/field/field-list.d.ts +7 -0
- package/dist/types/luna-react/src/component/field/field-set-advanced.d.ts +5 -0
- package/dist/types/luna-react/src/component/field/field-set-base.d.ts +7 -0
- package/dist/types/luna-react/src/component/field/field-vertical.d.ts +2 -8
- package/dist/types/luna-react/src/component/list.d.ts +5 -0
- package/dist/types/luna-react/src/component/slot/list-slot.d.ts +2 -0
- package/dist/types/luna-react/src/component/slot/slot-base.d.ts +8 -6
- package/dist/types/luna-react/src/component/slot/slot-create.d.ts +4 -3
- package/dist/types/luna-react/src/component/slot/slot-list.d.ts +12 -0
- package/dist/types/luna-react/src/component/slot/slot.d.ts +1 -0
- package/package.json +5 -5
- package/dist/types/luna-react/src/component/input/input-attributes.d.ts +0 -3
- package/dist/types/luna-react/src/component/input/input-common.d.ts +0 -2
- package/dist/types/luna-react/src/component/input/input-option-select.d.ts +0 -5
- /package/dist/types/luna-react/src/client/component/{wrapper/index.d.ts → field/field.d.ts} +0 -0
package/dist/server/cjs/index.js
CHANGED
|
@@ -32,16 +32,27 @@ function Control(props) {
|
|
|
32
32
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "field-control", className: "w-full", children: content });
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// src/component/
|
|
35
|
+
// src/component/field/field-set-advanced.tsx
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
|
|
38
|
+
// src/component/chevron-icon.tsx
|
|
36
39
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
37
|
-
function
|
|
40
|
+
function ChevronIcon(props) {
|
|
38
41
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
39
|
-
"
|
|
42
|
+
"svg",
|
|
40
43
|
{
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
+
viewBox: "0 0 20 20",
|
|
46
|
+
fill: "currentColor",
|
|
47
|
+
className: `size-4 transition-transform duration-200 ${props.expanded ? "rotate-90" : ""}`,
|
|
48
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
49
|
+
"path",
|
|
50
|
+
{
|
|
51
|
+
fillRule: "evenodd",
|
|
52
|
+
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",
|
|
53
|
+
clipRule: "evenodd"
|
|
54
|
+
}
|
|
55
|
+
)
|
|
45
56
|
}
|
|
46
57
|
);
|
|
47
58
|
}
|
|
@@ -53,10 +64,12 @@ var INPUT_NUMBER = "input/number";
|
|
|
53
64
|
var TEXTAREA = "textarea";
|
|
54
65
|
var RADIO = "radio";
|
|
55
66
|
var CHECKBOX = "checkbox";
|
|
67
|
+
var LIST = "list";
|
|
56
68
|
var SELECT = "select";
|
|
57
69
|
var SELECT_MONTH = "select/month";
|
|
58
70
|
var SELECT_YEAR = "select/year";
|
|
59
71
|
var COLUMN = "column";
|
|
72
|
+
var FIELDS = "fields";
|
|
60
73
|
var LABEL = "label";
|
|
61
74
|
var VALUE = "value";
|
|
62
75
|
var OPTIONS = "options";
|
|
@@ -78,17 +91,21 @@ var MAX_LENGTH = "maxLength";
|
|
|
78
91
|
var $REF = "$ref";
|
|
79
92
|
var VERTICAL = "vertical";
|
|
80
93
|
var HORIZONTAL = "horizontal";
|
|
94
|
+
var TYPE = "type";
|
|
81
95
|
|
|
82
96
|
// ../luna-core/src/util/is-type.ts
|
|
83
97
|
function isObject(value) {
|
|
84
98
|
return value !== null && Object.prototype.toString.call(value) === "[object Object]";
|
|
85
99
|
}
|
|
86
100
|
function isValue(value) {
|
|
87
|
-
return
|
|
101
|
+
return isString(value) || typeof value === "number" || isBoolean(value);
|
|
88
102
|
}
|
|
89
103
|
function isString(value) {
|
|
90
104
|
return typeof value === "string";
|
|
91
105
|
}
|
|
106
|
+
function isBoolean(value) {
|
|
107
|
+
return typeof value === "boolean";
|
|
108
|
+
}
|
|
92
109
|
|
|
93
110
|
// ../luna-core/src/util/extract.ts
|
|
94
111
|
var REGEX_TYPE = /[^/]+$/;
|
|
@@ -178,6 +195,9 @@ function interpolate(template, values = {}) {
|
|
|
178
195
|
}
|
|
179
196
|
return template;
|
|
180
197
|
}
|
|
198
|
+
function interpolateIfNeeded(template, values = {}) {
|
|
199
|
+
return isInterpolated(template) ? interpolate(template, values) : template;
|
|
200
|
+
}
|
|
181
201
|
function isInterpolated(template) {
|
|
182
202
|
if (isString(template)) {
|
|
183
203
|
return /{([^}]+)}/.test(template);
|
|
@@ -246,11 +266,14 @@ var isNumber = createTypeChecker(INPUT_NUMBER, TYPE_NUMBER);
|
|
|
246
266
|
function isClickable(field) {
|
|
247
267
|
return isRadio(field) || isCheckbox(field);
|
|
248
268
|
}
|
|
269
|
+
function isList(slot) {
|
|
270
|
+
return slot.type === LIST;
|
|
271
|
+
}
|
|
249
272
|
function isColumn(slot) {
|
|
250
273
|
return slot.type === COLUMN;
|
|
251
274
|
}
|
|
252
275
|
function isField(slot) {
|
|
253
|
-
return slot.type !== COLUMN;
|
|
276
|
+
return slot.type !== COLUMN && slot.type !== LIST;
|
|
254
277
|
}
|
|
255
278
|
function isOptions(field) {
|
|
256
279
|
return isSelect(field) || isRadio(field);
|
|
@@ -512,7 +535,7 @@ function prepareDefaultValue(field, value) {
|
|
|
512
535
|
var REGEX_REF = /^#\/definition\//;
|
|
513
536
|
function prepare(base = [], definition) {
|
|
514
537
|
const resolved = resolveRefs(base, definition);
|
|
515
|
-
return Array.isArray(resolved) ? resolved.sort((a, b) => getOrder(a) - getOrder(b)) : [];
|
|
538
|
+
return Array.isArray(resolved) ? resolved.filter(filter).sort((a, b) => getOrder(a) - getOrder(b)) : [];
|
|
516
539
|
}
|
|
517
540
|
function resolveRefs(base, definition, cache = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new WeakSet()) {
|
|
518
541
|
if (!isDefinition(definition) || !base || typeof base !== "object") {
|
|
@@ -553,6 +576,15 @@ function getOrder(item) {
|
|
|
553
576
|
function isDefinition(definition) {
|
|
554
577
|
return definition !== void 0 && isObject(definition) && Object.keys(definition).length > 0;
|
|
555
578
|
}
|
|
579
|
+
function filter(base) {
|
|
580
|
+
if (TYPE in base) {
|
|
581
|
+
return true;
|
|
582
|
+
}
|
|
583
|
+
if (Array.isArray(base[FIELDS])) {
|
|
584
|
+
return base[FIELDS].length > 0;
|
|
585
|
+
}
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
556
588
|
|
|
557
589
|
// ../luna-core/src/util/attributes.ts
|
|
558
590
|
function getPrefixedAttributes(prefix, record) {
|
|
@@ -600,6 +632,31 @@ function getSpan(value) {
|
|
|
600
632
|
}
|
|
601
633
|
}
|
|
602
634
|
|
|
635
|
+
// ../luna-core/src/util/list.ts
|
|
636
|
+
function getInitialCount(list, value) {
|
|
637
|
+
const min = list.advanced?.length?.min ?? 1;
|
|
638
|
+
if (value) {
|
|
639
|
+
const data = extract(value, list.name);
|
|
640
|
+
if (Array.isArray(data)) {
|
|
641
|
+
return Math.max(data.length, min);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return Math.max(min, 0);
|
|
645
|
+
}
|
|
646
|
+
function isMultiFieldList(list) {
|
|
647
|
+
if (!Array.isArray(list.fields) || list.fields.length === 0) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
return list.fields.length > 1 || list.fields[0].type === COLUMN;
|
|
651
|
+
}
|
|
652
|
+
function getInitialList(list, value) {
|
|
653
|
+
const count = getInitialCount(list, value);
|
|
654
|
+
return Array.from({ length: count }, (_, index) => index);
|
|
655
|
+
}
|
|
656
|
+
function getLabel(list) {
|
|
657
|
+
return list.label ?? list.name;
|
|
658
|
+
}
|
|
659
|
+
|
|
603
660
|
// ../luna-core/src/util/translate.ts
|
|
604
661
|
function translate(key, dictionary) {
|
|
605
662
|
if (!key) {
|
|
@@ -637,94 +694,266 @@ function formatMarkdown2(text) {
|
|
|
637
694
|
);
|
|
638
695
|
}
|
|
639
696
|
|
|
640
|
-
// src/component/
|
|
697
|
+
// src/component/field/field-set-advanced.tsx
|
|
641
698
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
699
|
+
function FieldSetAdvanced(props) {
|
|
700
|
+
const { fields = [] } = props.section;
|
|
701
|
+
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
|
702
|
+
const handleOpen = (0, import_react.useCallback)(() => setIsOpen((previous) => !previous), []);
|
|
703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
704
|
+
"fieldset",
|
|
705
|
+
{
|
|
706
|
+
"data-slot": "field-set",
|
|
707
|
+
"data-advanced": "true",
|
|
708
|
+
"data-expanded": isOpen,
|
|
709
|
+
"data-empty": fields.length === 0,
|
|
710
|
+
className: "flex flex-col",
|
|
711
|
+
id: props.section.id?.toString(),
|
|
712
|
+
children: [
|
|
713
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
714
|
+
"button",
|
|
715
|
+
{
|
|
716
|
+
className: "flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",
|
|
717
|
+
onClick: handleOpen,
|
|
718
|
+
type: "button",
|
|
719
|
+
children: [
|
|
720
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChevronIcon, { expanded: isOpen }),
|
|
721
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: formatMarkdown2(props.section.title) })
|
|
722
|
+
]
|
|
723
|
+
}
|
|
724
|
+
) }),
|
|
725
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react.Activity, { mode: isOpen ? "visible" : "hidden", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
726
|
+
"div",
|
|
727
|
+
{
|
|
728
|
+
className: "mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600",
|
|
729
|
+
"data-slot": "field-set-content",
|
|
730
|
+
children: [
|
|
731
|
+
props.section.description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.section.description) }),
|
|
732
|
+
props.group
|
|
733
|
+
]
|
|
734
|
+
}
|
|
735
|
+
) })
|
|
736
|
+
]
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// src/component/legend.tsx
|
|
742
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
642
743
|
function Legend(props) {
|
|
643
|
-
return /* @__PURE__ */ (0,
|
|
644
|
-
props.title && /* @__PURE__ */ (0,
|
|
645
|
-
props.description && /* @__PURE__ */ (0,
|
|
744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
745
|
+
props.title && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("legend", { className: "mb-3 font-medium text-slate-800 dark:text-slate-200", children: formatMarkdown2(props.title) }),
|
|
746
|
+
props.description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.description) })
|
|
646
747
|
] });
|
|
647
748
|
}
|
|
648
749
|
|
|
750
|
+
// src/component/field/field-set-base.tsx
|
|
751
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
752
|
+
function FieldSetBase(props) {
|
|
753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
754
|
+
"fieldset",
|
|
755
|
+
{
|
|
756
|
+
"data-slot": "field-set",
|
|
757
|
+
"data-empty": props.empty,
|
|
758
|
+
className: "flex flex-col data-[empty=false]:gap-6",
|
|
759
|
+
id: props.id,
|
|
760
|
+
children: [
|
|
761
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Legend, { description: props.description, title: props.title }),
|
|
762
|
+
props.children
|
|
763
|
+
]
|
|
764
|
+
}
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// src/component/group.tsx
|
|
769
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
770
|
+
function Group(props) {
|
|
771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
772
|
+
"div",
|
|
773
|
+
{
|
|
774
|
+
"data-slot": "field-group",
|
|
775
|
+
"data-compact": props.compact,
|
|
776
|
+
className: "flex w-full flex-col gap-8 data-[compact=true]:gap-3",
|
|
777
|
+
children: props.children
|
|
778
|
+
}
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
|
|
649
782
|
// src/component/field/field-set.tsx
|
|
650
|
-
var
|
|
783
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
651
784
|
function FieldSet(props) {
|
|
652
|
-
const fields = props.section
|
|
785
|
+
const { fields = [] } = props.section;
|
|
653
786
|
const { compact } = mergeStyle(props.style, {
|
|
654
787
|
compact: props.section.compact
|
|
655
788
|
});
|
|
789
|
+
const group = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Group, { compact, children: props.children });
|
|
656
790
|
if (!props.section.title && !props.section.description) {
|
|
657
|
-
return
|
|
791
|
+
return group;
|
|
658
792
|
}
|
|
659
|
-
|
|
660
|
-
|
|
793
|
+
if (props.section.advanced) {
|
|
794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FieldSetAdvanced, { section: props.section, group });
|
|
795
|
+
}
|
|
796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
797
|
+
FieldSetBase,
|
|
661
798
|
{
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
className: "flex flex-col data-[empty=false]:gap-6",
|
|
799
|
+
description: props.section.description,
|
|
800
|
+
empty: fields.length === 0,
|
|
665
801
|
id: props.section.id?.toString(),
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
Legend,
|
|
669
|
-
{
|
|
670
|
-
description: props.section.description,
|
|
671
|
-
title: props.section.title
|
|
672
|
-
}
|
|
673
|
-
),
|
|
674
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Group, { compact, children: props.children })
|
|
675
|
-
]
|
|
802
|
+
title: props.section.title,
|
|
803
|
+
children: group
|
|
676
804
|
}
|
|
677
805
|
);
|
|
678
806
|
}
|
|
679
807
|
|
|
680
|
-
// src/component/
|
|
681
|
-
var
|
|
808
|
+
// src/client/component/guard/visibility-guard.tsx
|
|
809
|
+
var import_jotai2 = require("jotai");
|
|
810
|
+
|
|
811
|
+
// src/client/lib/store-helper.ts
|
|
812
|
+
var import_jotai = require("jotai");
|
|
813
|
+
var import_jotai_family = require("jotai-family");
|
|
814
|
+
var import_fast_equals = require("fast-equals");
|
|
815
|
+
function createRecordAtomFamily(baseAtom) {
|
|
816
|
+
return (0, import_jotai_family.atomFamily)(
|
|
817
|
+
(name) => (0, import_jotai.atom)(
|
|
818
|
+
(get) => {
|
|
819
|
+
return get(baseAtom)[name] ?? void 0;
|
|
820
|
+
},
|
|
821
|
+
(get, set, newValue) => {
|
|
822
|
+
const current = get(baseAtom);
|
|
823
|
+
if (newValue !== void 0 && newValue !== null) {
|
|
824
|
+
const currentValue = current[name];
|
|
825
|
+
if (!currentValue || !(0, import_fast_equals.deepEqual)(currentValue, newValue)) {
|
|
826
|
+
set(baseAtom, { ...current, [name]: newValue });
|
|
827
|
+
}
|
|
828
|
+
} else if (current[name]) {
|
|
829
|
+
const { [name]: _unused, ...rest } = current;
|
|
830
|
+
set(baseAtom, rest);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
)
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
function createClearAllAtom(baseAtom) {
|
|
837
|
+
return (0, import_jotai.atom)(null, (get, set) => {
|
|
838
|
+
const current = get(baseAtom);
|
|
839
|
+
if (current && Object.keys(current).length > 0) {
|
|
840
|
+
set(baseAtom, {});
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
function createClearAtom(baseAtom) {
|
|
845
|
+
return (0, import_jotai.atom)(null, (get, set, names) => {
|
|
846
|
+
const current = get(baseAtom);
|
|
847
|
+
const next = { ...current };
|
|
848
|
+
let hasChanges = false;
|
|
849
|
+
for (const name of names) {
|
|
850
|
+
if (next[name]) {
|
|
851
|
+
delete next[name];
|
|
852
|
+
hasChanges = true;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
if (hasChanges) {
|
|
856
|
+
set(baseAtom, next);
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
function createBulkReportAtom(baseAtom) {
|
|
861
|
+
return (0, import_jotai.atom)(null, (get, set, newValue) => {
|
|
862
|
+
const current = get(baseAtom);
|
|
863
|
+
if (!(0, import_fast_equals.deepEqual)(current, newValue)) {
|
|
864
|
+
set(baseAtom, newValue);
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
function createAtomStore(initialValue = {}) {
|
|
869
|
+
const baseAtom = (0, import_jotai.atom)(initialValue);
|
|
870
|
+
return {
|
|
871
|
+
atom: baseAtom,
|
|
872
|
+
clearAll: createClearAllAtom(baseAtom),
|
|
873
|
+
clear: createClearAtom(baseAtom),
|
|
874
|
+
bulkReport: createBulkReportAtom(baseAtom),
|
|
875
|
+
report: createRecordAtomFamily(baseAtom)
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// src/client/lib/state-store.ts
|
|
880
|
+
var store = createAtomStore();
|
|
881
|
+
var fieldStateAtom = store.atom;
|
|
882
|
+
var reportFieldStateAtom = store.report;
|
|
883
|
+
|
|
884
|
+
// src/client/component/guard/visibility-guard.tsx
|
|
885
|
+
function isColumnHidden(column, states) {
|
|
886
|
+
return column.fields.every((field) => isFieldHidden(field, states));
|
|
887
|
+
}
|
|
888
|
+
function isFieldHidden(field, states) {
|
|
889
|
+
return states[field.name]?.hidden ?? field.hidden ?? false;
|
|
890
|
+
}
|
|
891
|
+
function isEntryHidden(entry, states) {
|
|
892
|
+
return isColumn(entry) ? isColumnHidden(entry, states) : isFieldHidden(entry, states);
|
|
893
|
+
}
|
|
894
|
+
function VisibilityGuard(props) {
|
|
895
|
+
const states = (0, import_jotai2.useAtomValue)(fieldStateAtom);
|
|
896
|
+
if (props.container) {
|
|
897
|
+
const hidden = states[props.container.name]?.hidden ?? props.container.hidden ?? false;
|
|
898
|
+
if (hidden) {
|
|
899
|
+
return null;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
if (props.fields.length === 0) {
|
|
903
|
+
return null;
|
|
904
|
+
}
|
|
905
|
+
const allHidden = props.fields.every((entry) => isEntryHidden(entry, states));
|
|
906
|
+
if (allHidden) {
|
|
907
|
+
return null;
|
|
908
|
+
}
|
|
909
|
+
return props.children;
|
|
910
|
+
}
|
|
682
911
|
|
|
683
912
|
// src/component/separator.tsx
|
|
684
|
-
var
|
|
913
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
685
914
|
function Separator() {
|
|
686
|
-
return /* @__PURE__ */ (0,
|
|
915
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { "data-slot": "field-separator", className: "relative -my-2 h-5 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800" }) });
|
|
687
916
|
}
|
|
688
917
|
|
|
689
918
|
// src/component/form.tsx
|
|
690
|
-
var
|
|
919
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
691
920
|
function Form(props) {
|
|
692
921
|
const sections = prepare(props.sections, props.definition);
|
|
693
|
-
return /* @__PURE__ */ (0,
|
|
694
|
-
sections.map((section, index) => /* @__PURE__ */ (0,
|
|
695
|
-
/* @__PURE__ */ (0,
|
|
922
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "h-full w-full", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("form", { noValidate: props.noValidate, action: props.action, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Group, { children: [
|
|
923
|
+
sections.map((section, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(VisibilityGuard, { fields: section.fields ?? [], children: [
|
|
924
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FieldSet, { section, style: props.config.style, children: props.children({
|
|
696
925
|
disabled: props.readOnly,
|
|
697
926
|
fields: section.fields
|
|
698
927
|
}) }),
|
|
699
|
-
section.separator && /* @__PURE__ */ (0,
|
|
928
|
+
section.separator && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Separator, {})
|
|
700
929
|
] }, index)),
|
|
701
|
-
props.control && /* @__PURE__ */ (0,
|
|
930
|
+
props.control && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Control, { isPending: props.isPending, children: props.control })
|
|
702
931
|
] }) }) });
|
|
703
932
|
}
|
|
704
933
|
|
|
705
934
|
// src/component/description.tsx
|
|
706
|
-
var
|
|
935
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
707
936
|
function Description(props) {
|
|
708
|
-
return /* @__PURE__ */ (0,
|
|
937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400", children: props.children });
|
|
709
938
|
}
|
|
710
939
|
|
|
711
940
|
// src/component/formatted-description.tsx
|
|
712
|
-
var
|
|
941
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
713
942
|
function FormattedDescription(props) {
|
|
714
943
|
const content = formatMarkdown2(props.text);
|
|
715
944
|
if (content) {
|
|
716
|
-
return /* @__PURE__ */ (0,
|
|
945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Description, { children: content });
|
|
717
946
|
}
|
|
718
947
|
return null;
|
|
719
948
|
}
|
|
720
949
|
|
|
721
950
|
// src/component/label.tsx
|
|
722
951
|
var import_tailwind_merge = require("tailwind-merge");
|
|
723
|
-
var
|
|
952
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
724
953
|
function Label(props) {
|
|
725
954
|
const showOptionalLabel = props.style?.showOptionalLabel ?? true;
|
|
726
955
|
const normal = isRadio(props.field) || isCheckbox(props.field);
|
|
727
|
-
return /* @__PURE__ */ (0,
|
|
956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
728
957
|
"label",
|
|
729
958
|
{
|
|
730
959
|
"data-slot": "field-label",
|
|
@@ -737,30 +966,31 @@ function Label(props) {
|
|
|
737
966
|
htmlFor: props.field.name,
|
|
738
967
|
children: [
|
|
739
968
|
props.children,
|
|
740
|
-
showOptionalLabel && !props.field.required && /* @__PURE__ */ (0,
|
|
969
|
+
showOptionalLabel && !props.field.required && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-sm text-slate-600 dark:text-slate-400", children: translate("(Optional)", props.translations) })
|
|
741
970
|
]
|
|
742
971
|
}
|
|
743
972
|
);
|
|
744
973
|
}
|
|
745
974
|
|
|
746
975
|
// src/component/input-label.tsx
|
|
747
|
-
var
|
|
976
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
748
977
|
function InputLabel(props) {
|
|
749
|
-
const
|
|
978
|
+
const interpolateOpts = {
|
|
750
979
|
context: props.context,
|
|
751
980
|
env: props.config?.env
|
|
752
|
-
}
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
981
|
+
};
|
|
982
|
+
const label = interpolateIfNeeded(props.field.label, interpolateOpts);
|
|
983
|
+
const description = interpolateIfNeeded(
|
|
984
|
+
props.field.description,
|
|
985
|
+
interpolateOpts
|
|
986
|
+
);
|
|
987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
758
988
|
"div",
|
|
759
989
|
{
|
|
760
990
|
"data-slot": "field-content",
|
|
761
991
|
className: "flex w-full flex-1 flex-col gap-1.5 leading-snug",
|
|
762
992
|
children: [
|
|
763
|
-
/* @__PURE__ */ (0,
|
|
993
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
764
994
|
Label,
|
|
765
995
|
{
|
|
766
996
|
field: props.field,
|
|
@@ -769,7 +999,7 @@ function InputLabel(props) {
|
|
|
769
999
|
children: translate(label, props.translations)
|
|
770
1000
|
}
|
|
771
1001
|
),
|
|
772
|
-
props.orientation === HORIZONTAL && /* @__PURE__ */ (0,
|
|
1002
|
+
props.orientation === HORIZONTAL && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
773
1003
|
FormattedDescription,
|
|
774
1004
|
{
|
|
775
1005
|
text: translate(description, props.translations)
|
|
@@ -781,10 +1011,10 @@ function InputLabel(props) {
|
|
|
781
1011
|
}
|
|
782
1012
|
|
|
783
1013
|
// src/component/input-group.tsx
|
|
784
|
-
var
|
|
1014
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
785
1015
|
function InputGroup(props) {
|
|
786
|
-
return /* @__PURE__ */ (0,
|
|
787
|
-
props.field.name && props.field.label && /* @__PURE__ */ (0,
|
|
1016
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
1017
|
+
props.field.name && props.field.label && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
788
1018
|
InputLabel,
|
|
789
1019
|
{
|
|
790
1020
|
config: props.config,
|
|
@@ -795,7 +1025,7 @@ function InputGroup(props) {
|
|
|
795
1025
|
}
|
|
796
1026
|
),
|
|
797
1027
|
props.children,
|
|
798
|
-
props.orientation === VERTICAL && props.field.description && /* @__PURE__ */ (0,
|
|
1028
|
+
props.orientation === VERTICAL && props.field.description && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
799
1029
|
FormattedDescription,
|
|
800
1030
|
{
|
|
801
1031
|
text: translate(props.field.description, props.translations)
|
|
@@ -813,7 +1043,7 @@ function renderIfExists(value, render) {
|
|
|
813
1043
|
}
|
|
814
1044
|
|
|
815
1045
|
// src/server/component/input.tsx
|
|
816
|
-
var
|
|
1046
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
817
1047
|
function Input(props) {
|
|
818
1048
|
const source = resolveSource(props.field, props.value);
|
|
819
1049
|
const { commonPropsWithOptions, defaultValue } = prepareInputProps(
|
|
@@ -823,7 +1053,7 @@ function Input(props) {
|
|
|
823
1053
|
props.value
|
|
824
1054
|
);
|
|
825
1055
|
const defaultProps = prepareDefaultValue(props.field, defaultValue);
|
|
826
|
-
return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ (0,
|
|
1056
|
+
return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
827
1057
|
InputGroup,
|
|
828
1058
|
{
|
|
829
1059
|
config: props.config,
|
|
@@ -831,7 +1061,7 @@ function Input(props) {
|
|
|
831
1061
|
field: props.field,
|
|
832
1062
|
orientation: props.orientation,
|
|
833
1063
|
translations: props.translations,
|
|
834
|
-
children: /* @__PURE__ */ (0,
|
|
1064
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
835
1065
|
Component,
|
|
836
1066
|
{
|
|
837
1067
|
...props.ariaAttributes,
|
|
@@ -845,27 +1075,27 @@ function Input(props) {
|
|
|
845
1075
|
}
|
|
846
1076
|
|
|
847
1077
|
// src/component/field/field-error.tsx
|
|
848
|
-
var
|
|
1078
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
849
1079
|
function FieldError(props) {
|
|
850
1080
|
if (!props.errors || props.errors.length === 0) {
|
|
851
1081
|
return null;
|
|
852
1082
|
}
|
|
853
|
-
return /* @__PURE__ */ (0,
|
|
1083
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
854
1084
|
"ul",
|
|
855
1085
|
{
|
|
856
1086
|
className: "text-sm text-red-600 dark:text-red-500",
|
|
857
1087
|
id: props.name ? `${props.name}-error` : void 0,
|
|
858
|
-
children: props.errors?.map((error, index) => /* @__PURE__ */ (0,
|
|
1088
|
+
children: props.errors?.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { children: error }, props.name ? `${props.name}-error-${index}` : index))
|
|
859
1089
|
}
|
|
860
1090
|
);
|
|
861
1091
|
}
|
|
862
1092
|
|
|
863
1093
|
// src/component/field/field-base.tsx
|
|
864
1094
|
var import_tailwind_merge2 = require("tailwind-merge");
|
|
865
|
-
var
|
|
1095
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
866
1096
|
function FieldBase(props) {
|
|
867
1097
|
const errors = props.errors && props.errors.length > 0;
|
|
868
|
-
return /* @__PURE__ */ (0,
|
|
1098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
869
1099
|
"div",
|
|
870
1100
|
{
|
|
871
1101
|
"data-slot": "field",
|
|
@@ -887,9 +1117,9 @@ function FieldBase(props) {
|
|
|
887
1117
|
|
|
888
1118
|
// src/component/field/field-vertical.tsx
|
|
889
1119
|
var import_tailwind_merge3 = require("tailwind-merge");
|
|
890
|
-
var
|
|
1120
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
891
1121
|
function FieldVertical(props) {
|
|
892
|
-
return /* @__PURE__ */ (0,
|
|
1122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
893
1123
|
FieldBase,
|
|
894
1124
|
{
|
|
895
1125
|
...props,
|
|
@@ -905,9 +1135,9 @@ function FieldVertical(props) {
|
|
|
905
1135
|
|
|
906
1136
|
// src/component/field/field-horizontal.tsx
|
|
907
1137
|
var import_tailwind_merge4 = require("tailwind-merge");
|
|
908
|
-
var
|
|
1138
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
909
1139
|
function FieldHorizontal(props) {
|
|
910
|
-
return /* @__PURE__ */ (0,
|
|
1140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
911
1141
|
FieldBase,
|
|
912
1142
|
{
|
|
913
1143
|
...props,
|
|
@@ -930,13 +1160,13 @@ function FieldHorizontal(props) {
|
|
|
930
1160
|
}
|
|
931
1161
|
|
|
932
1162
|
// src/component/field/field-group.tsx
|
|
933
|
-
var
|
|
1163
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
934
1164
|
function FieldGroup(props) {
|
|
935
1165
|
const clickable = isClickable(props.field);
|
|
936
1166
|
const checkbox = isCheckbox(props.field);
|
|
937
1167
|
const reversed = buildReverse(props.field);
|
|
938
1168
|
if (props.orientation === VERTICAL) {
|
|
939
|
-
return /* @__PURE__ */ (0,
|
|
1169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
940
1170
|
FieldVertical,
|
|
941
1171
|
{
|
|
942
1172
|
disabled: props.disabled,
|
|
@@ -948,7 +1178,7 @@ function FieldGroup(props) {
|
|
|
948
1178
|
}
|
|
949
1179
|
);
|
|
950
1180
|
}
|
|
951
|
-
return /* @__PURE__ */ (0,
|
|
1181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
952
1182
|
FieldHorizontal,
|
|
953
1183
|
{
|
|
954
1184
|
disabled: props.disabled,
|
|
@@ -984,7 +1214,7 @@ function InputBase(props) {
|
|
|
984
1214
|
|
|
985
1215
|
// src/component/field/field.tsx
|
|
986
1216
|
var import_tailwind_merge5 = require("tailwind-merge");
|
|
987
|
-
var
|
|
1217
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
988
1218
|
function Field(props) {
|
|
989
1219
|
const cols2 = props.field.advanced?.cols;
|
|
990
1220
|
const errors = props.field.name ? props.errors?.[props.field.name] : void 0;
|
|
@@ -992,15 +1222,15 @@ function Field(props) {
|
|
|
992
1222
|
orientation: buildOrientation(props.field)
|
|
993
1223
|
});
|
|
994
1224
|
const disabled = buildDisabled(props.field, props.disabled);
|
|
995
|
-
return /* @__PURE__ */ (0,
|
|
996
|
-
/* @__PURE__ */ (0,
|
|
1225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: (0, import_tailwind_merge5.twMerge)("flex flex-col gap-3", getSpan(cols2)), children: [
|
|
1226
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
997
1227
|
FieldGroup,
|
|
998
1228
|
{
|
|
999
1229
|
disabled,
|
|
1000
1230
|
errors,
|
|
1001
1231
|
field: props.field,
|
|
1002
1232
|
orientation,
|
|
1003
|
-
children: /* @__PURE__ */ (0,
|
|
1233
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1004
1234
|
InputBase,
|
|
1005
1235
|
{
|
|
1006
1236
|
disabled,
|
|
@@ -1012,44 +1242,175 @@ function Field(props) {
|
|
|
1012
1242
|
)
|
|
1013
1243
|
}
|
|
1014
1244
|
),
|
|
1015
|
-
/* @__PURE__ */ (0,
|
|
1245
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FieldError, { errors, name: props.field.name })
|
|
1016
1246
|
] });
|
|
1017
1247
|
}
|
|
1018
1248
|
|
|
1019
|
-
// src/component/
|
|
1249
|
+
// src/component/field/field-list-item.tsx
|
|
1020
1250
|
var import_tailwind_merge6 = require("tailwind-merge");
|
|
1021
|
-
var
|
|
1251
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1252
|
+
function FieldListItem(props) {
|
|
1253
|
+
function handleRemove() {
|
|
1254
|
+
if (props.canRemove && props.onRemove) {
|
|
1255
|
+
props.onRemove(props.index);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
const removeButton = props.canRemove && props.onRemove != null && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1259
|
+
"button",
|
|
1260
|
+
{
|
|
1261
|
+
"aria-label": `Remove ${props.label} item ${props.index + 1}`,
|
|
1262
|
+
className: (0, import_tailwind_merge6.twMerge)(
|
|
1263
|
+
"rounded p-1 text-xl text-slate-400",
|
|
1264
|
+
"transition-colors duration-150",
|
|
1265
|
+
"hover:text-red-500",
|
|
1266
|
+
"focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none",
|
|
1267
|
+
"dark:text-slate-500 dark:hover:text-red-400"
|
|
1268
|
+
),
|
|
1269
|
+
onClick: handleRemove,
|
|
1270
|
+
type: "button",
|
|
1271
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { "aria-hidden": "true", children: "\xD7" })
|
|
1272
|
+
}
|
|
1273
|
+
);
|
|
1274
|
+
if (props.isMultiField) {
|
|
1275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "rounded-lg border border-slate-100 p-4 dark:border-slate-900", children: [
|
|
1276
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "mb-3 flex items-center justify-between", children: [
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "text-sm font-medium text-slate-400 dark:text-slate-500", children: [
|
|
1278
|
+
props.label,
|
|
1279
|
+
" ",
|
|
1280
|
+
props.index + 1
|
|
1281
|
+
] }),
|
|
1282
|
+
removeButton
|
|
1283
|
+
] }),
|
|
1284
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Group, { children: props.children })
|
|
1285
|
+
] });
|
|
1286
|
+
}
|
|
1287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-start gap-2", children: [
|
|
1288
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Group, { children: props.children }),
|
|
1289
|
+
removeButton && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "shrink-0", children: removeButton })
|
|
1290
|
+
] });
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/component/field/field-list.tsx
|
|
1294
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1295
|
+
function FieldList(props) {
|
|
1296
|
+
const label = getLabel(props.field);
|
|
1297
|
+
const isMultiField = isMultiFieldList(props.field);
|
|
1298
|
+
return getInitialList(props.field, props.value).map((index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1299
|
+
FieldListItem,
|
|
1300
|
+
{
|
|
1301
|
+
index,
|
|
1302
|
+
isMultiField,
|
|
1303
|
+
label,
|
|
1304
|
+
children: props.children(index)
|
|
1305
|
+
},
|
|
1306
|
+
index
|
|
1307
|
+
));
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
// src/component/list.tsx
|
|
1311
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1312
|
+
function List(props) {
|
|
1313
|
+
const empty = Array.isArray(props.field.fields) && props.field.fields.length === 0;
|
|
1314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1315
|
+
FieldSetBase,
|
|
1316
|
+
{
|
|
1317
|
+
description: props.field.description,
|
|
1318
|
+
empty,
|
|
1319
|
+
id: props.field.name,
|
|
1320
|
+
title: props.field.label,
|
|
1321
|
+
children: props.children
|
|
1322
|
+
}
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
// src/component/slot/list-slot.tsx
|
|
1327
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1328
|
+
function ListSlot({ children, field, value }) {
|
|
1329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(List, { field, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FieldList, { field, value, children }) });
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// src/component/column.tsx
|
|
1333
|
+
var import_tailwind_merge7 = require("tailwind-merge");
|
|
1334
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1022
1335
|
function Column(props) {
|
|
1023
1336
|
const cols2 = getColumn(props.column?.advanced?.cols);
|
|
1024
|
-
return /* @__PURE__ */ (0,
|
|
1337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex w-full flex-col gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: (0, import_tailwind_merge7.twMerge)("grid grid-cols-1 gap-3 sm:gap-4", cols2), children: props.children }) });
|
|
1025
1338
|
}
|
|
1026
1339
|
|
|
1027
1340
|
// src/component/slot/slot-base.tsx
|
|
1028
1341
|
var import_react2 = require("react");
|
|
1029
|
-
|
|
1342
|
+
|
|
1343
|
+
// src/component/slot/slot-list.tsx
|
|
1344
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1345
|
+
function SlotList(props) {
|
|
1346
|
+
const fields = Array.isArray(props.field.fields) ? props.field.fields.map((field) => {
|
|
1347
|
+
if (isField(field)) {
|
|
1348
|
+
return {
|
|
1349
|
+
...field,
|
|
1350
|
+
name: `${props.field.name}.${props.index}.${field.name}`
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
if (isColumn(field)) {
|
|
1354
|
+
return {
|
|
1355
|
+
...field,
|
|
1356
|
+
fields: field.fields.map((columnField) => ({
|
|
1357
|
+
...columnField,
|
|
1358
|
+
name: `${props.field.name}.${props.index}.${columnField.name}`
|
|
1359
|
+
}))
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
return field;
|
|
1363
|
+
}) : [];
|
|
1364
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1365
|
+
SlotBase,
|
|
1366
|
+
{
|
|
1367
|
+
children: props.children,
|
|
1368
|
+
components: props.components,
|
|
1369
|
+
disabled: props.disabled,
|
|
1370
|
+
fields,
|
|
1371
|
+
style: props.style,
|
|
1372
|
+
value: props.value
|
|
1373
|
+
}
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
// src/component/slot/slot-base.tsx
|
|
1378
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1030
1379
|
function SlotBase(props) {
|
|
1031
|
-
const {
|
|
1032
|
-
return prepare(props.fields).map((field, index) => /* @__PURE__ */ (0,
|
|
1033
|
-
isColumn(field) && /* @__PURE__ */ (0,
|
|
1034
|
-
isField(field) && /* @__PURE__ */ (0,
|
|
1380
|
+
const { field: Field2, list: List2 } = props.components;
|
|
1381
|
+
return prepare(props.fields).map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_react2.Fragment, { children: [
|
|
1382
|
+
isColumn(field) && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Column, { column: field, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SlotBase, { ...props, fields: field.fields }) }),
|
|
1383
|
+
isField(field) && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Field2, { disabled: props.disabled, field, style: props.style, children: props.children }),
|
|
1384
|
+
isList(field) && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(List2, { field, value: props.value, children: (index2) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
1385
|
+
SlotList,
|
|
1386
|
+
{
|
|
1387
|
+
children: props.children,
|
|
1388
|
+
components: props.components,
|
|
1389
|
+
disabled: props.disabled,
|
|
1390
|
+
field,
|
|
1391
|
+
index: index2,
|
|
1392
|
+
style: props.style,
|
|
1393
|
+
value: props.value
|
|
1394
|
+
}
|
|
1395
|
+
) })
|
|
1035
1396
|
] }, index));
|
|
1036
1397
|
}
|
|
1037
1398
|
|
|
1038
1399
|
// src/component/slot/slot-create.tsx
|
|
1039
|
-
var
|
|
1040
|
-
function createSlot(
|
|
1041
|
-
const CreateSlot = (props) => /* @__PURE__ */ (0,
|
|
1400
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1401
|
+
function createSlot(components) {
|
|
1402
|
+
const CreateSlot = (props) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(SlotBase, { ...props, components });
|
|
1042
1403
|
return CreateSlot;
|
|
1043
1404
|
}
|
|
1044
1405
|
|
|
1045
1406
|
// src/component/slot/slot.tsx
|
|
1046
|
-
var Slot = createSlot(Field);
|
|
1407
|
+
var Slot = createSlot({ field: Field, list: ListSlot });
|
|
1047
1408
|
|
|
1048
1409
|
// src/server/component/form.tsx
|
|
1049
|
-
var
|
|
1410
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1050
1411
|
function Form2(props) {
|
|
1051
1412
|
const translations = props.translations?.[props.lang ?? ""];
|
|
1052
|
-
return /* @__PURE__ */ (0,
|
|
1413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1053
1414
|
Form,
|
|
1054
1415
|
{
|
|
1055
1416
|
config: props.config,
|
|
@@ -1057,7 +1418,7 @@ function Form2(props) {
|
|
|
1057
1418
|
definition: props.definition,
|
|
1058
1419
|
readOnly: props.readOnly,
|
|
1059
1420
|
sections: props.sections,
|
|
1060
|
-
children: ({ disabled, fields }) => /* @__PURE__ */ (0,
|
|
1421
|
+
children: ({ disabled, fields }) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Slot, { disabled, fields, style: props.config.style, children: (internal) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1061
1422
|
Input,
|
|
1062
1423
|
{
|
|
1063
1424
|
...internal,
|
|
@@ -1073,12 +1434,12 @@ function Form2(props) {
|
|
|
1073
1434
|
|
|
1074
1435
|
// src/server/component/fallback.tsx
|
|
1075
1436
|
var import_react3 = require("react");
|
|
1076
|
-
var
|
|
1437
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1077
1438
|
function Fallback(props) {
|
|
1078
|
-
return /* @__PURE__ */ (0,
|
|
1439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1079
1440
|
import_react3.Suspense,
|
|
1080
1441
|
{
|
|
1081
|
-
fallback: /* @__PURE__ */ (0,
|
|
1442
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Form2, { config: props.config, sections: props.sections, readOnly: true }),
|
|
1082
1443
|
children: props.children
|
|
1083
1444
|
}
|
|
1084
1445
|
);
|