react-luna-form 0.0.25 → 0.0.26
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 +1 -2261
- package/dist/client/esm/index.js +1 -2228
- package/dist/config/cjs/index.js +1 -229
- package/dist/config/esm/index.js +1 -206
- package/dist/server/cjs/index.js +1 -1085
- package/dist/server/esm/index.js +1 -1062
- package/dist/types/luna-core/src/type.d.ts +1 -0
- package/dist/types/luna-react/src/component/chevron-icon.d.ts +3 -0
- package/package.json +2 -2
package/dist/server/esm/index.js
CHANGED
|
@@ -1,1062 +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/group.tsx
|
|
9
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
10
|
-
function Group(props) {
|
|
11
|
-
return /* @__PURE__ */ jsx2(
|
|
12
|
-
"div",
|
|
13
|
-
{
|
|
14
|
-
"data-slot": "field-group",
|
|
15
|
-
"data-compact": props.compact,
|
|
16
|
-
className: "flex w-full flex-col gap-8 data-[compact=true]:gap-3",
|
|
17
|
-
children: props.children
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// ../luna-core/src/util/constant.ts
|
|
23
|
-
var INPUT = "input";
|
|
24
|
-
var INPUT_EMAIL = "input/email";
|
|
25
|
-
var INPUT_NUMBER = "input/number";
|
|
26
|
-
var TEXTAREA = "textarea";
|
|
27
|
-
var RADIO = "radio";
|
|
28
|
-
var CHECKBOX = "checkbox";
|
|
29
|
-
var SELECT = "select";
|
|
30
|
-
var SELECT_MONTH = "select/month";
|
|
31
|
-
var SELECT_YEAR = "select/year";
|
|
32
|
-
var COLUMN = "column";
|
|
33
|
-
var LABEL = "label";
|
|
34
|
-
var VALUE = "value";
|
|
35
|
-
var OPTIONS = "options";
|
|
36
|
-
var TYPE_EMAIL = "email";
|
|
37
|
-
var TYPE_NUMBER = "number";
|
|
38
|
-
var TYPE_PASSWORD = "password";
|
|
39
|
-
var TYPE_TEL = "tel";
|
|
40
|
-
var TYPE_TEXT = "text";
|
|
41
|
-
var ARIA_ERROR_MESSAGE = "aria-errormessage";
|
|
42
|
-
var ARIA_INVALID = "aria-invalid";
|
|
43
|
-
var DATA_INVALID = "data-invalid";
|
|
44
|
-
var DATA_READONLY = "data-readonly";
|
|
45
|
-
var PREFIX_ARIA = "aria";
|
|
46
|
-
var PREFIX_DATA = "data";
|
|
47
|
-
var MIN = "min";
|
|
48
|
-
var MAX = "max";
|
|
49
|
-
var MIN_LENGTH = "minLength";
|
|
50
|
-
var MAX_LENGTH = "maxLength";
|
|
51
|
-
var $REF = "$ref";
|
|
52
|
-
var VERTICAL = "vertical";
|
|
53
|
-
var HORIZONTAL = "horizontal";
|
|
54
|
-
|
|
55
|
-
// ../luna-core/src/util/is-type.ts
|
|
56
|
-
function isObject(value) {
|
|
57
|
-
return value !== null && Object.prototype.toString.call(value) === "[object Object]";
|
|
58
|
-
}
|
|
59
|
-
function isValue(value) {
|
|
60
|
-
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
61
|
-
}
|
|
62
|
-
function isString(value) {
|
|
63
|
-
return typeof value === "string";
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ../luna-core/src/util/extract.ts
|
|
67
|
-
var REGEX_TYPE = /[^/]+$/;
|
|
68
|
-
function getCurrentValue(value, entity = VALUE) {
|
|
69
|
-
if (value !== null && value !== void 0) {
|
|
70
|
-
if (isValue(value)) {
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
if (isObject(value)) {
|
|
74
|
-
const result = getValue(value, entity);
|
|
75
|
-
if (isValue(result)) {
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function getValue(value, namespace) {
|
|
82
|
-
const result = extract(value, namespace);
|
|
83
|
-
if (isValue(result)) {
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function extract(value, namespace) {
|
|
88
|
-
if (!namespace || !isObject(value)) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
const keys = namespace.split(".").filter((key) => key !== "");
|
|
92
|
-
if (keys.length === 0) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
let result = value;
|
|
96
|
-
for (const key of keys) {
|
|
97
|
-
if (isObject(result) && key in result) {
|
|
98
|
-
const obj = result;
|
|
99
|
-
result = obj[key];
|
|
100
|
-
} else {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
function toOptions(data, options = { label: LABEL, value: VALUE }) {
|
|
107
|
-
return data.map((item) => {
|
|
108
|
-
if (isObject(item)) {
|
|
109
|
-
const label = extract(item, options.label);
|
|
110
|
-
const value = extract(item, options.value);
|
|
111
|
-
if (isValue(label) && isValue(value)) {
|
|
112
|
-
return {
|
|
113
|
-
label: `${label}`,
|
|
114
|
-
value: `${value}`
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return item;
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function getType(value = TYPE_TEXT) {
|
|
122
|
-
if (value) {
|
|
123
|
-
const result = value.match(REGEX_TYPE);
|
|
124
|
-
if (result) {
|
|
125
|
-
const [type] = result;
|
|
126
|
-
if (type !== INPUT) {
|
|
127
|
-
return type.trim().toLowerCase();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return TYPE_TEXT;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ../luna-core/src/util/string.ts
|
|
135
|
-
var REGEX_MARKDOWN_LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
136
|
-
function interpolate(template, values = {}) {
|
|
137
|
-
if (isString(template)) {
|
|
138
|
-
return replacePlaceholders(template, values);
|
|
139
|
-
}
|
|
140
|
-
if (Array.isArray(template)) {
|
|
141
|
-
return template.map((item) => {
|
|
142
|
-
return interpolate(item, values);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (isObject(template)) {
|
|
146
|
-
const results = {};
|
|
147
|
-
for (const key in template) {
|
|
148
|
-
results[key] = interpolate(template[key], values);
|
|
149
|
-
}
|
|
150
|
-
return results;
|
|
151
|
-
}
|
|
152
|
-
return template;
|
|
153
|
-
}
|
|
154
|
-
function isInterpolated(template) {
|
|
155
|
-
if (isString(template)) {
|
|
156
|
-
return /{([^}]+)}/.test(template);
|
|
157
|
-
}
|
|
158
|
-
if (Array.isArray(template)) {
|
|
159
|
-
return template.some((item) => isInterpolated(item));
|
|
160
|
-
}
|
|
161
|
-
if (isObject(template)) {
|
|
162
|
-
return Object.values(template).some((value) => isInterpolated(value));
|
|
163
|
-
}
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
function replacePlaceholders(template, values = {}) {
|
|
167
|
-
return template.replace(/{([^}]+)}/g, (match, key) => {
|
|
168
|
-
const value = key.includes(".") ? extract(values, key) : values[key];
|
|
169
|
-
if (isValue(value)) {
|
|
170
|
-
return String(value);
|
|
171
|
-
}
|
|
172
|
-
return match;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
function formatMarkdown(text, callback) {
|
|
176
|
-
if (!text || text.trim().length === 0) {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
let match;
|
|
180
|
-
let lastIndex = 0;
|
|
181
|
-
let hasMatch = false;
|
|
182
|
-
const parts = [];
|
|
183
|
-
while ((match = REGEX_MARKDOWN_LINK.exec(text)) !== null) {
|
|
184
|
-
const [fullMatch, linkText, url] = match;
|
|
185
|
-
const index = match.index;
|
|
186
|
-
hasMatch = true;
|
|
187
|
-
if (index > lastIndex) {
|
|
188
|
-
parts.push(text.substring(lastIndex, index));
|
|
189
|
-
}
|
|
190
|
-
const value = callback ? callback(index, url, linkText) : fullMatch;
|
|
191
|
-
parts.push(value);
|
|
192
|
-
lastIndex = index + fullMatch.length;
|
|
193
|
-
}
|
|
194
|
-
if (!hasMatch) {
|
|
195
|
-
return text;
|
|
196
|
-
}
|
|
197
|
-
if (lastIndex < text.length) {
|
|
198
|
-
parts.push(text.substring(lastIndex));
|
|
199
|
-
}
|
|
200
|
-
return parts;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ../luna-core/src/util/is-input.ts
|
|
204
|
-
var isSelectMonth = (field) => createTypeChecker(SELECT_MONTH)(field);
|
|
205
|
-
var isSelectYear = (field) => createTypeChecker(SELECT_YEAR)(field);
|
|
206
|
-
var isCheckbox = createTypeChecker(CHECKBOX);
|
|
207
|
-
var isInput = createTypeChecker(INPUT);
|
|
208
|
-
var isRadio = createTypeChecker(RADIO);
|
|
209
|
-
var isSelect = createTypeChecker(SELECT);
|
|
210
|
-
var isTextArea = createTypeChecker(TEXTAREA);
|
|
211
|
-
var isText = createTypeChecker(
|
|
212
|
-
TYPE_TEXT,
|
|
213
|
-
TYPE_EMAIL,
|
|
214
|
-
TYPE_PASSWORD,
|
|
215
|
-
TYPE_TEL
|
|
216
|
-
);
|
|
217
|
-
var isEmail = createTypeChecker(INPUT_EMAIL, TYPE_EMAIL);
|
|
218
|
-
var isNumber = createTypeChecker(INPUT_NUMBER, TYPE_NUMBER);
|
|
219
|
-
function isClickable(field) {
|
|
220
|
-
return isRadio(field) || isCheckbox(field);
|
|
221
|
-
}
|
|
222
|
-
function isColumn(slot) {
|
|
223
|
-
return slot.type === COLUMN;
|
|
224
|
-
}
|
|
225
|
-
function isField(slot) {
|
|
226
|
-
return slot.type !== COLUMN;
|
|
227
|
-
}
|
|
228
|
-
function isOptions(field) {
|
|
229
|
-
return isSelect(field) || isRadio(field);
|
|
230
|
-
}
|
|
231
|
-
function isValidValue(value) {
|
|
232
|
-
return value !== void 0 && value !== null && value !== "";
|
|
233
|
-
}
|
|
234
|
-
function createTypeChecker(...types) {
|
|
235
|
-
return (field) => {
|
|
236
|
-
const inputType = isString(field.type) ? field.type : void 0;
|
|
237
|
-
if (!inputType) {
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
return types.some((type) => {
|
|
241
|
-
return inputType === type || inputType?.startsWith(`${type}/`);
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// ../luna-core/src/util/build.ts
|
|
247
|
-
function buildOptions(field, values = {}) {
|
|
248
|
-
if (isSelect(field) && field.disabled) {
|
|
249
|
-
const current = field.name ? values?.[field.name] : void 0;
|
|
250
|
-
if (current && isObject(current)) {
|
|
251
|
-
return [current];
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function buildOrientation(field) {
|
|
256
|
-
if (isRadio(field) || isCheckbox(field)) {
|
|
257
|
-
return HORIZONTAL;
|
|
258
|
-
}
|
|
259
|
-
return field.advanced?.orientation ?? VERTICAL;
|
|
260
|
-
}
|
|
261
|
-
function buildReverse(field) {
|
|
262
|
-
if (!isCheckbox(field)) {
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
return field.advanced?.reverse !== false;
|
|
266
|
-
}
|
|
267
|
-
function buildDisabled(field, disabled) {
|
|
268
|
-
const readonly = field.readonly ?? false;
|
|
269
|
-
return disabled ? disabled : readonly;
|
|
270
|
-
}
|
|
271
|
-
function buildSource(field) {
|
|
272
|
-
if (isRadio(field) || isSelect(field) && !field.disabled) {
|
|
273
|
-
const source = field.source;
|
|
274
|
-
if (Array.isArray(source) || isObject(source) && !($REF in source)) {
|
|
275
|
-
return source;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// ../luna-core/src/util/date.ts
|
|
281
|
-
var REGEX_DIGITS = /^\d+$/;
|
|
282
|
-
function getMonth() {
|
|
283
|
-
return Array.from({ length: 12 }, (_, i) => ({
|
|
284
|
-
value: (i + 1).toString(),
|
|
285
|
-
label: new Date(0, i).toLocaleString("default", {
|
|
286
|
-
month: "long"
|
|
287
|
-
})
|
|
288
|
-
}));
|
|
289
|
-
}
|
|
290
|
-
function getYear(min, max) {
|
|
291
|
-
if (max >= min) {
|
|
292
|
-
return Array.from({ length: max - min + 1 }, (_, i) => {
|
|
293
|
-
const year = min + i;
|
|
294
|
-
return {
|
|
295
|
-
value: year.toString(),
|
|
296
|
-
label: year.toString()
|
|
297
|
-
};
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
return [];
|
|
301
|
-
}
|
|
302
|
-
function getCurrentYear() {
|
|
303
|
-
return (/* @__PURE__ */ new Date()).getFullYear();
|
|
304
|
-
}
|
|
305
|
-
function getConvert(value, current) {
|
|
306
|
-
if (typeof value === "number") {
|
|
307
|
-
return value;
|
|
308
|
-
}
|
|
309
|
-
const now2 = current ?? getCurrentYear();
|
|
310
|
-
const trimmed = value.trim().toLowerCase();
|
|
311
|
-
if (trimmed.startsWith("current")) {
|
|
312
|
-
const match = trimmed.match(/^current([+-])(\d+)$/);
|
|
313
|
-
if (match) {
|
|
314
|
-
const [, operator, offsetStr] = match;
|
|
315
|
-
const offset = parseInt(offsetStr, 10);
|
|
316
|
-
if (!isNaN(offset)) {
|
|
317
|
-
return operator === "+" ? now2 + offset : now2 - offset;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return now2;
|
|
321
|
-
}
|
|
322
|
-
if (REGEX_DIGITS.test(trimmed)) {
|
|
323
|
-
return parseInt(trimmed, 10);
|
|
324
|
-
}
|
|
325
|
-
return now2;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// ../luna-core/src/helper/input.ts
|
|
329
|
-
var now = getCurrentYear();
|
|
330
|
-
function buildOptionSelect(field) {
|
|
331
|
-
if (isSelect(field)) {
|
|
332
|
-
return defineOption(field);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function defineOption(select) {
|
|
336
|
-
if (isSelectMonth(select)) {
|
|
337
|
-
return getMonth();
|
|
338
|
-
}
|
|
339
|
-
if (isSelectYear(select)) {
|
|
340
|
-
const min = select.advanced?.length?.min ?? now;
|
|
341
|
-
const max = select.advanced?.length?.max ?? now + 5;
|
|
342
|
-
return getYear(getConvert(min, now), getConvert(max, now));
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
function buildCommon(field, disabled = false) {
|
|
346
|
-
const commonProps = {
|
|
347
|
-
disabled,
|
|
348
|
-
id: field.name,
|
|
349
|
-
name: field.name,
|
|
350
|
-
placeholder: field.placeholder,
|
|
351
|
-
required: field.required
|
|
352
|
-
};
|
|
353
|
-
if (isInput(field)) {
|
|
354
|
-
return {
|
|
355
|
-
...commonProps,
|
|
356
|
-
...defineInput(field)
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
if (isSelect(field)) {
|
|
360
|
-
return {
|
|
361
|
-
...commonProps,
|
|
362
|
-
...defineSelect(field)
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
if (isTextArea(field)) {
|
|
366
|
-
return {
|
|
367
|
-
...commonProps,
|
|
368
|
-
...defineTextArea(field)
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
return commonProps;
|
|
372
|
-
}
|
|
373
|
-
function defineInput(input) {
|
|
374
|
-
const type = getType(input.type);
|
|
375
|
-
const copy = { ...input, type };
|
|
376
|
-
return {
|
|
377
|
-
...defineAutoComplete(input),
|
|
378
|
-
...defineNumberLimits(copy),
|
|
379
|
-
...isText(copy) ? defineLength(copy) : {},
|
|
380
|
-
type
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
function defineSelect(field) {
|
|
384
|
-
const options = buildOptionSelect(field);
|
|
385
|
-
if (options) {
|
|
386
|
-
return { options };
|
|
387
|
-
}
|
|
388
|
-
return {};
|
|
389
|
-
}
|
|
390
|
-
function defineTextArea(field) {
|
|
391
|
-
return {
|
|
392
|
-
...defineAutoComplete(field),
|
|
393
|
-
...defineLength(field)
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
function defineAutoComplete(input) {
|
|
397
|
-
const autoComplete = input.advanced?.autocomplete;
|
|
398
|
-
if (autoComplete) {
|
|
399
|
-
return { autoComplete };
|
|
400
|
-
}
|
|
401
|
-
return {};
|
|
402
|
-
}
|
|
403
|
-
function defineNumberLimits(input) {
|
|
404
|
-
if (isNumber(input)) {
|
|
405
|
-
return defineMinMax(input);
|
|
406
|
-
}
|
|
407
|
-
return {};
|
|
408
|
-
}
|
|
409
|
-
function defineLength(input) {
|
|
410
|
-
return defineConstraints(input, { min: MIN_LENGTH, max: MAX_LENGTH });
|
|
411
|
-
}
|
|
412
|
-
function defineMinMax(input) {
|
|
413
|
-
return defineConstraints(input, { min: MIN, max: MAX });
|
|
414
|
-
}
|
|
415
|
-
function defineConstraints(input, keys) {
|
|
416
|
-
const result = {};
|
|
417
|
-
const length = input.advanced?.length;
|
|
418
|
-
if (length) {
|
|
419
|
-
if (length.min !== void 0) {
|
|
420
|
-
result[keys.min] = length.min;
|
|
421
|
-
}
|
|
422
|
-
if (length.max !== void 0) {
|
|
423
|
-
result[keys.max] = length.max;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
return result;
|
|
427
|
-
}
|
|
428
|
-
function resolveSource(field, value) {
|
|
429
|
-
const current = buildSource(field);
|
|
430
|
-
if (current) {
|
|
431
|
-
return current;
|
|
432
|
-
}
|
|
433
|
-
return buildOptions(field, value);
|
|
434
|
-
}
|
|
435
|
-
function getInputValue(field, value) {
|
|
436
|
-
const newValue = isObject(value) && field.name in value ? value[field.name] : value;
|
|
437
|
-
return getCurrentValue(newValue, field.advanced?.entity);
|
|
438
|
-
}
|
|
439
|
-
function mergeOptionsProps(field, commonProps, options) {
|
|
440
|
-
return isOptions(field) && Array.isArray(options) ? { ...commonProps, [OPTIONS]: options } : commonProps;
|
|
441
|
-
}
|
|
442
|
-
function getPreselectedValue(field, commonProps, value) {
|
|
443
|
-
if (field.required && !isValidValue(value)) {
|
|
444
|
-
if (isSelect(field)) {
|
|
445
|
-
if (field.advanced?.preselected !== false && OPTIONS in commonProps) {
|
|
446
|
-
const options = commonProps[OPTIONS];
|
|
447
|
-
if (Array.isArray(options) && options.length === 1) {
|
|
448
|
-
return options[0];
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
return value;
|
|
454
|
-
}
|
|
455
|
-
function getOptions(field, data) {
|
|
456
|
-
if (isSelect(field) && Array.isArray(data)) {
|
|
457
|
-
return toOptions(data, field.advanced?.options);
|
|
458
|
-
}
|
|
459
|
-
return data;
|
|
460
|
-
}
|
|
461
|
-
function prepareInputProps(field, commonProps, data, value) {
|
|
462
|
-
const currentValue = getInputValue(field, value);
|
|
463
|
-
const options = Array.isArray(data) ? getOptions(field, data) : data;
|
|
464
|
-
const commonPropsWithOptions = mergeOptionsProps(field, commonProps, options);
|
|
465
|
-
const defaultValue = getPreselectedValue(
|
|
466
|
-
field,
|
|
467
|
-
commonPropsWithOptions,
|
|
468
|
-
currentValue
|
|
469
|
-
);
|
|
470
|
-
return {
|
|
471
|
-
commonPropsWithOptions,
|
|
472
|
-
defaultValue
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
function prepareDefaultValue(field, value) {
|
|
476
|
-
if (isCheckbox(field)) {
|
|
477
|
-
return {
|
|
478
|
-
defaultChecked: isValidValue(value)
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
return { defaultValue: value };
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// ../luna-core/src/util/prepare.ts
|
|
485
|
-
var REGEX_REF = /^#\/definition\//;
|
|
486
|
-
function prepare(base = [], definition) {
|
|
487
|
-
const resolved = resolveRefs(base, definition);
|
|
488
|
-
return Array.isArray(resolved) ? resolved.sort((a, b) => getOrder(a) - getOrder(b)) : [];
|
|
489
|
-
}
|
|
490
|
-
function resolveRefs(base, definition, cache = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new WeakSet()) {
|
|
491
|
-
if (!isDefinition(definition) || !base || typeof base !== "object") {
|
|
492
|
-
return base;
|
|
493
|
-
}
|
|
494
|
-
if (cache.has(base)) {
|
|
495
|
-
return cache.get(base);
|
|
496
|
-
}
|
|
497
|
-
if (visited.has(base)) {
|
|
498
|
-
return base;
|
|
499
|
-
}
|
|
500
|
-
visited.add(base);
|
|
501
|
-
if (Array.isArray(base)) {
|
|
502
|
-
return base.map((item) => resolveRefs(item, definition, cache, visited));
|
|
503
|
-
}
|
|
504
|
-
if ($REF in base && isString(base[$REF])) {
|
|
505
|
-
const path = base[$REF].replace(REGEX_REF, "");
|
|
506
|
-
const resolved = extract(definition, path);
|
|
507
|
-
if (resolved !== null) {
|
|
508
|
-
return resolveRefs(resolved, definition, cache, visited);
|
|
509
|
-
}
|
|
510
|
-
return base;
|
|
511
|
-
}
|
|
512
|
-
const result = {};
|
|
513
|
-
for (const [key, value] of Object.entries(base)) {
|
|
514
|
-
result[key] = resolveRefs(value, definition, cache, visited);
|
|
515
|
-
}
|
|
516
|
-
visited.delete(base);
|
|
517
|
-
cache.set(base, result);
|
|
518
|
-
return result;
|
|
519
|
-
}
|
|
520
|
-
function entries(values) {
|
|
521
|
-
return Object.entries(values ?? {});
|
|
522
|
-
}
|
|
523
|
-
function getOrder(item) {
|
|
524
|
-
return item.order ?? Number.MAX_VALUE;
|
|
525
|
-
}
|
|
526
|
-
function isDefinition(definition) {
|
|
527
|
-
return definition !== void 0 && isObject(definition) && Object.keys(definition).length > 0;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// ../luna-core/src/util/attributes.ts
|
|
531
|
-
function getPrefixedAttributes(prefix, record) {
|
|
532
|
-
const attrs = {};
|
|
533
|
-
for (const [key, value] of entries(record)) {
|
|
534
|
-
attrs[`${prefix}-${key}`] = value;
|
|
535
|
-
}
|
|
536
|
-
return attrs;
|
|
537
|
-
}
|
|
538
|
-
function getAriaAttributes(record) {
|
|
539
|
-
return getPrefixedAttributes(PREFIX_ARIA, record);
|
|
540
|
-
}
|
|
541
|
-
function getDataAttributes(record) {
|
|
542
|
-
return getPrefixedAttributes(PREFIX_DATA, record);
|
|
543
|
-
}
|
|
544
|
-
function buildAriaAttributes(field, errors) {
|
|
545
|
-
const ariaAttributes = getAriaAttributes(field.advanced?.aria);
|
|
546
|
-
if (errors && errors.length > 0) {
|
|
547
|
-
ariaAttributes[ARIA_INVALID] = "true";
|
|
548
|
-
ariaAttributes[ARIA_ERROR_MESSAGE] = `${field.name}-error`;
|
|
549
|
-
}
|
|
550
|
-
return ariaAttributes;
|
|
551
|
-
}
|
|
552
|
-
function buildDataAttributes(field) {
|
|
553
|
-
return getDataAttributes(field.advanced?.data);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// ../luna-core/src/util/column.ts
|
|
557
|
-
var cols = {
|
|
558
|
-
1: "md:grid-cols-1",
|
|
559
|
-
2: "md:grid-cols-2",
|
|
560
|
-
3: "md:grid-cols-3"
|
|
561
|
-
};
|
|
562
|
-
var span = {
|
|
563
|
-
1: "md:col-span-1",
|
|
564
|
-
2: "md:col-span-2",
|
|
565
|
-
3: "md:col-span-3"
|
|
566
|
-
};
|
|
567
|
-
function getColumn(value, defaultCols = 2) {
|
|
568
|
-
return cols[value && value in cols ? value : defaultCols];
|
|
569
|
-
}
|
|
570
|
-
function getSpan(value) {
|
|
571
|
-
if (value && value in span) {
|
|
572
|
-
return span[value];
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
// ../luna-core/src/util/translate.ts
|
|
577
|
-
function translate(key, dictionary) {
|
|
578
|
-
if (!key) {
|
|
579
|
-
return "";
|
|
580
|
-
}
|
|
581
|
-
if (!dictionary) {
|
|
582
|
-
return key;
|
|
583
|
-
}
|
|
584
|
-
return dictionary[key] ?? key;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// ../luna-core/src/util/style.ts
|
|
588
|
-
function mergeStyle(globalStyle, localStyle) {
|
|
589
|
-
return { ...globalStyle, ...localStyle };
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// src/lib/string.tsx
|
|
593
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
594
|
-
function formatMarkdown2(text) {
|
|
595
|
-
return formatMarkdown(
|
|
596
|
-
text,
|
|
597
|
-
(index, url, text2) => {
|
|
598
|
-
return /* @__PURE__ */ jsx3(
|
|
599
|
-
"a",
|
|
600
|
-
{
|
|
601
|
-
className: "underline",
|
|
602
|
-
href: url,
|
|
603
|
-
rel: "noopener noreferrer",
|
|
604
|
-
target: "_blank",
|
|
605
|
-
children: text2
|
|
606
|
-
},
|
|
607
|
-
`${url}-${index}`
|
|
608
|
-
);
|
|
609
|
-
}
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
// src/component/legend.tsx
|
|
614
|
-
import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
615
|
-
function Legend(props) {
|
|
616
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
617
|
-
props.title && /* @__PURE__ */ jsx4("legend", { className: "mb-3 font-medium text-slate-800 dark:text-slate-200", children: formatMarkdown2(props.title) }),
|
|
618
|
-
props.description && /* @__PURE__ */ jsx4("p", { className: "-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400", children: formatMarkdown2(props.description) })
|
|
619
|
-
] });
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
// src/component/field/field-set.tsx
|
|
623
|
-
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
624
|
-
function FieldSet(props) {
|
|
625
|
-
const fields = props.section.fields || [];
|
|
626
|
-
const { compact } = mergeStyle(props.style, {
|
|
627
|
-
compact: props.section.compact
|
|
628
|
-
});
|
|
629
|
-
if (!props.section.title && !props.section.description) {
|
|
630
|
-
return /* @__PURE__ */ jsx5(Group, { compact, children: props.children });
|
|
631
|
-
}
|
|
632
|
-
return /* @__PURE__ */ jsxs2(
|
|
633
|
-
"fieldset",
|
|
634
|
-
{
|
|
635
|
-
"data-slot": "field-set",
|
|
636
|
-
"data-empty": fields.length === 0,
|
|
637
|
-
className: "flex flex-col data-[empty=false]:gap-6",
|
|
638
|
-
id: props.section.id?.toString(),
|
|
639
|
-
children: [
|
|
640
|
-
/* @__PURE__ */ jsx5(
|
|
641
|
-
Legend,
|
|
642
|
-
{
|
|
643
|
-
description: props.section.description,
|
|
644
|
-
title: props.section.title
|
|
645
|
-
}
|
|
646
|
-
),
|
|
647
|
-
/* @__PURE__ */ jsx5(Group, { compact, children: props.children })
|
|
648
|
-
]
|
|
649
|
-
}
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
// src/component/form.tsx
|
|
654
|
-
import { Fragment as Fragment2 } from "react";
|
|
655
|
-
|
|
656
|
-
// src/component/separator.tsx
|
|
657
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
658
|
-
function Separator() {
|
|
659
|
-
return /* @__PURE__ */ jsx6("div", { "data-slot": "field-separator", className: "relative -my-2 h-5 text-sm", children: /* @__PURE__ */ jsx6("div", { className: "absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800" }) });
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
// src/component/form.tsx
|
|
663
|
-
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
664
|
-
function Form(props) {
|
|
665
|
-
const sections = prepare(props.sections, props.definition);
|
|
666
|
-
return /* @__PURE__ */ jsx7("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx7("form", { noValidate: props.noValidate, action: props.action, children: /* @__PURE__ */ jsxs3(Group, { children: [
|
|
667
|
-
sections.map((section, index) => /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
668
|
-
/* @__PURE__ */ jsx7(FieldSet, { section, style: props.config.style, children: props.children({
|
|
669
|
-
disabled: props.readOnly,
|
|
670
|
-
fields: section.fields
|
|
671
|
-
}) }),
|
|
672
|
-
section.separator && /* @__PURE__ */ jsx7(Separator, {})
|
|
673
|
-
] }, index)),
|
|
674
|
-
props.control && /* @__PURE__ */ jsx7(Control, { isPending: props.isPending, children: props.control })
|
|
675
|
-
] }) }) });
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
// src/component/description.tsx
|
|
679
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
680
|
-
function Description(props) {
|
|
681
|
-
return /* @__PURE__ */ jsx8("p", { className: "-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400", children: props.children });
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// src/component/formatted-description.tsx
|
|
685
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
686
|
-
function FormattedDescription(props) {
|
|
687
|
-
const content = formatMarkdown2(props.text);
|
|
688
|
-
if (content) {
|
|
689
|
-
return /* @__PURE__ */ jsx9(Description, { children: content });
|
|
690
|
-
}
|
|
691
|
-
return null;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
// src/component/label.tsx
|
|
695
|
-
import { twMerge } from "tailwind-merge";
|
|
696
|
-
import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
697
|
-
function Label(props) {
|
|
698
|
-
const showOptionalLabel = props.style?.showOptionalLabel ?? true;
|
|
699
|
-
const normal = isRadio(props.field) || isCheckbox(props.field);
|
|
700
|
-
return /* @__PURE__ */ jsxs4(
|
|
701
|
-
"label",
|
|
702
|
-
{
|
|
703
|
-
"data-slot": "field-label",
|
|
704
|
-
"data-normal": normal,
|
|
705
|
-
className: twMerge(
|
|
706
|
-
"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",
|
|
707
|
-
"data-[normal=true]:font-normal",
|
|
708
|
-
"group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"
|
|
709
|
-
),
|
|
710
|
-
htmlFor: props.field.name,
|
|
711
|
-
children: [
|
|
712
|
-
props.children,
|
|
713
|
-
showOptionalLabel && !props.field.required && /* @__PURE__ */ jsx10("span", { className: "text-sm text-slate-600 dark:text-slate-400", children: translate("(Optional)", props.translations) })
|
|
714
|
-
]
|
|
715
|
-
}
|
|
716
|
-
);
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
// src/component/input-label.tsx
|
|
720
|
-
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
721
|
-
function InputLabel(props) {
|
|
722
|
-
const label = isInterpolated(props.field.label) ? interpolate(props.field.label, {
|
|
723
|
-
context: props.context,
|
|
724
|
-
env: props.config?.env
|
|
725
|
-
}) : props.field.label;
|
|
726
|
-
const description = isInterpolated(props.field.description) ? interpolate(props.field.description, {
|
|
727
|
-
context: props.context,
|
|
728
|
-
env: props.config?.env
|
|
729
|
-
}) : props.field.description;
|
|
730
|
-
return /* @__PURE__ */ jsxs5(
|
|
731
|
-
"div",
|
|
732
|
-
{
|
|
733
|
-
"data-slot": "field-content",
|
|
734
|
-
className: "flex w-full flex-1 flex-col gap-1.5 leading-snug",
|
|
735
|
-
children: [
|
|
736
|
-
/* @__PURE__ */ jsx11(
|
|
737
|
-
Label,
|
|
738
|
-
{
|
|
739
|
-
field: props.field,
|
|
740
|
-
style: props.config?.style,
|
|
741
|
-
translations: props.translations,
|
|
742
|
-
children: translate(label, props.translations)
|
|
743
|
-
}
|
|
744
|
-
),
|
|
745
|
-
props.orientation === HORIZONTAL && /* @__PURE__ */ jsx11(
|
|
746
|
-
FormattedDescription,
|
|
747
|
-
{
|
|
748
|
-
text: translate(description, props.translations)
|
|
749
|
-
}
|
|
750
|
-
)
|
|
751
|
-
]
|
|
752
|
-
}
|
|
753
|
-
);
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
// src/component/input-group.tsx
|
|
757
|
-
import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
758
|
-
function InputGroup(props) {
|
|
759
|
-
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
760
|
-
props.field.name && props.field.label && /* @__PURE__ */ jsx12(
|
|
761
|
-
InputLabel,
|
|
762
|
-
{
|
|
763
|
-
config: props.config,
|
|
764
|
-
context: props.context,
|
|
765
|
-
field: props.field,
|
|
766
|
-
orientation: props.orientation,
|
|
767
|
-
translations: props.translations
|
|
768
|
-
}
|
|
769
|
-
),
|
|
770
|
-
props.children,
|
|
771
|
-
props.orientation === VERTICAL && props.field.description && /* @__PURE__ */ jsx12(
|
|
772
|
-
FormattedDescription,
|
|
773
|
-
{
|
|
774
|
-
text: translate(props.field.description, props.translations)
|
|
775
|
-
}
|
|
776
|
-
)
|
|
777
|
-
] });
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
// src/lib/render-If-exists.ts
|
|
781
|
-
function renderIfExists(value, render) {
|
|
782
|
-
if (!value) {
|
|
783
|
-
return null;
|
|
784
|
-
}
|
|
785
|
-
return render(value);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
// src/server/component/input.tsx
|
|
789
|
-
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
790
|
-
function Input(props) {
|
|
791
|
-
const source = resolveSource(props.field, props.value);
|
|
792
|
-
const { commonPropsWithOptions, defaultValue } = prepareInputProps(
|
|
793
|
-
props.field,
|
|
794
|
-
props.commonProps,
|
|
795
|
-
source,
|
|
796
|
-
props.value
|
|
797
|
-
);
|
|
798
|
-
const defaultProps = prepareDefaultValue(props.field, defaultValue);
|
|
799
|
-
return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ jsx13(
|
|
800
|
-
InputGroup,
|
|
801
|
-
{
|
|
802
|
-
config: props.config,
|
|
803
|
-
context: props.context,
|
|
804
|
-
field: props.field,
|
|
805
|
-
orientation: props.orientation,
|
|
806
|
-
translations: props.translations,
|
|
807
|
-
children: /* @__PURE__ */ jsx13(
|
|
808
|
-
Component,
|
|
809
|
-
{
|
|
810
|
-
...props.ariaAttributes,
|
|
811
|
-
...commonPropsWithOptions,
|
|
812
|
-
...props.dataAttributes,
|
|
813
|
-
...defaultProps
|
|
814
|
-
}
|
|
815
|
-
)
|
|
816
|
-
}
|
|
817
|
-
));
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
// src/component/field/field-error.tsx
|
|
821
|
-
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
822
|
-
function FieldError(props) {
|
|
823
|
-
if (!props.errors || props.errors.length === 0) {
|
|
824
|
-
return null;
|
|
825
|
-
}
|
|
826
|
-
return /* @__PURE__ */ jsx14(
|
|
827
|
-
"ul",
|
|
828
|
-
{
|
|
829
|
-
className: "text-sm text-red-600 dark:text-red-500",
|
|
830
|
-
id: props.name ? `${props.name}-error` : void 0,
|
|
831
|
-
children: props.errors?.map((error, index) => /* @__PURE__ */ jsx14("li", { children: error }, props.name ? `${props.name}-error-${index}` : index))
|
|
832
|
-
}
|
|
833
|
-
);
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
// src/component/field/field-base.tsx
|
|
837
|
-
import { twMerge as twMerge2 } from "tailwind-merge";
|
|
838
|
-
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
839
|
-
function FieldBase(props) {
|
|
840
|
-
const errors = props.errors && props.errors.length > 0;
|
|
841
|
-
return /* @__PURE__ */ jsx15(
|
|
842
|
-
"div",
|
|
843
|
-
{
|
|
844
|
-
"data-slot": "field",
|
|
845
|
-
"data-clickable": props.isClickable ? "true" : "false",
|
|
846
|
-
...errors && { [DATA_INVALID]: "true" },
|
|
847
|
-
...props.disabled && { [DATA_READONLY]: "true" },
|
|
848
|
-
"data-orientation": props.orientation,
|
|
849
|
-
className: twMerge2(
|
|
850
|
-
"group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500",
|
|
851
|
-
"data-[clickable=true]:items-start",
|
|
852
|
-
props.isCheckbox && (props.isReversed ? "flex-row-reverse!" : "flex-row!"),
|
|
853
|
-
"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",
|
|
854
|
-
props.className
|
|
855
|
-
),
|
|
856
|
-
children: props.children
|
|
857
|
-
}
|
|
858
|
-
);
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
// src/component/field/field-vertical.tsx
|
|
862
|
-
import { twMerge as twMerge3 } from "tailwind-merge";
|
|
863
|
-
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
864
|
-
function FieldVertical(props) {
|
|
865
|
-
return /* @__PURE__ */ jsx16(
|
|
866
|
-
FieldBase,
|
|
867
|
-
{
|
|
868
|
-
...props,
|
|
869
|
-
orientation: VERTICAL,
|
|
870
|
-
className: twMerge3(
|
|
871
|
-
"gap-3 has-[>[data-slot=field-content]]:items-start",
|
|
872
|
-
!props.isClickable && "[&>*]:w-full"
|
|
873
|
-
),
|
|
874
|
-
children: props.children
|
|
875
|
-
}
|
|
876
|
-
);
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
// src/component/field/field-horizontal.tsx
|
|
880
|
-
import { twMerge as twMerge4 } from "tailwind-merge";
|
|
881
|
-
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
882
|
-
function FieldHorizontal(props) {
|
|
883
|
-
return /* @__PURE__ */ jsx17(
|
|
884
|
-
FieldBase,
|
|
885
|
-
{
|
|
886
|
-
...props,
|
|
887
|
-
orientation: HORIZONTAL,
|
|
888
|
-
className: twMerge4(
|
|
889
|
-
"gap-2 md:flex-row md:gap-4",
|
|
890
|
-
"[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start",
|
|
891
|
-
"[&_[role=checkbox]]:mt-[1.5px]",
|
|
892
|
-
props.isClickable && "md:flex-col",
|
|
893
|
-
!props.isClickable && [
|
|
894
|
-
"md:justify-between",
|
|
895
|
-
"[&>*:not([data-slot=field-content])]:w-full",
|
|
896
|
-
"[&>*:not([data-slot=field-content])]:md:w-1/2",
|
|
897
|
-
"[&>*:not([data-slot=field-content])]:xl:w-2/5"
|
|
898
|
-
]
|
|
899
|
-
),
|
|
900
|
-
children: props.children
|
|
901
|
-
}
|
|
902
|
-
);
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
// src/component/field/field-group.tsx
|
|
906
|
-
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
907
|
-
function FieldGroup(props) {
|
|
908
|
-
const clickable = isClickable(props.field);
|
|
909
|
-
const checkbox = isCheckbox(props.field);
|
|
910
|
-
const reversed = buildReverse(props.field);
|
|
911
|
-
if (props.orientation === VERTICAL) {
|
|
912
|
-
return /* @__PURE__ */ jsx18(
|
|
913
|
-
FieldVertical,
|
|
914
|
-
{
|
|
915
|
-
disabled: props.disabled,
|
|
916
|
-
errors: props.errors,
|
|
917
|
-
isCheckbox: checkbox,
|
|
918
|
-
isReversed: reversed,
|
|
919
|
-
isClickable: clickable,
|
|
920
|
-
children: props.children
|
|
921
|
-
}
|
|
922
|
-
);
|
|
923
|
-
}
|
|
924
|
-
return /* @__PURE__ */ jsx18(
|
|
925
|
-
FieldHorizontal,
|
|
926
|
-
{
|
|
927
|
-
disabled: props.disabled,
|
|
928
|
-
errors: props.errors,
|
|
929
|
-
isCheckbox: checkbox,
|
|
930
|
-
isReversed: reversed,
|
|
931
|
-
isClickable: clickable,
|
|
932
|
-
children: props.children
|
|
933
|
-
}
|
|
934
|
-
);
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
// src/component/input/input-base.tsx
|
|
938
|
-
function InputBase(props) {
|
|
939
|
-
if (!props.field.type) {
|
|
940
|
-
return null;
|
|
941
|
-
}
|
|
942
|
-
const commonProps = buildCommon(props.field, props.disabled);
|
|
943
|
-
const dataAttributes = buildDataAttributes(props.field);
|
|
944
|
-
const ariaAttributes = buildAriaAttributes(props.field, props.errors);
|
|
945
|
-
const field = {
|
|
946
|
-
...props.field,
|
|
947
|
-
disabled: commonProps.disabled
|
|
948
|
-
};
|
|
949
|
-
return props.children({
|
|
950
|
-
ariaAttributes,
|
|
951
|
-
commonProps,
|
|
952
|
-
dataAttributes,
|
|
953
|
-
field,
|
|
954
|
-
orientation: props.orientation
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
// src/component/field/field.tsx
|
|
959
|
-
import { twMerge as twMerge5 } from "tailwind-merge";
|
|
960
|
-
import { jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
961
|
-
function Field(props) {
|
|
962
|
-
const cols2 = props.field.advanced?.cols;
|
|
963
|
-
const errors = props.field.name ? props.errors?.[props.field.name] : void 0;
|
|
964
|
-
const { orientation } = mergeStyle(props.style, {
|
|
965
|
-
orientation: buildOrientation(props.field)
|
|
966
|
-
});
|
|
967
|
-
const disabled = buildDisabled(props.field, props.disabled);
|
|
968
|
-
return /* @__PURE__ */ jsxs7("div", { className: twMerge5("flex flex-col gap-3", getSpan(cols2)), children: [
|
|
969
|
-
/* @__PURE__ */ jsx19(
|
|
970
|
-
FieldGroup,
|
|
971
|
-
{
|
|
972
|
-
disabled,
|
|
973
|
-
errors,
|
|
974
|
-
field: props.field,
|
|
975
|
-
orientation,
|
|
976
|
-
children: /* @__PURE__ */ jsx19(
|
|
977
|
-
InputBase,
|
|
978
|
-
{
|
|
979
|
-
disabled,
|
|
980
|
-
errors,
|
|
981
|
-
field: props.field,
|
|
982
|
-
orientation,
|
|
983
|
-
children: props.children
|
|
984
|
-
}
|
|
985
|
-
)
|
|
986
|
-
}
|
|
987
|
-
),
|
|
988
|
-
/* @__PURE__ */ jsx19(FieldError, { errors, name: props.field.name })
|
|
989
|
-
] });
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
// src/component/column.tsx
|
|
993
|
-
import { twMerge as twMerge6 } from "tailwind-merge";
|
|
994
|
-
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
995
|
-
function Column(props) {
|
|
996
|
-
const cols2 = getColumn(props.column?.advanced?.cols);
|
|
997
|
-
return /* @__PURE__ */ jsx20("div", { className: "flex w-full flex-col gap-4", children: /* @__PURE__ */ jsx20("div", { className: twMerge6("grid grid-cols-1 gap-3 sm:gap-4", cols2), children: props.children }) });
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
// src/component/slot/slot-base.tsx
|
|
1001
|
-
import { Fragment as Fragment4 } from "react";
|
|
1002
|
-
import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1003
|
-
function SlotBase(props) {
|
|
1004
|
-
const { column: Column2, field: Field2 } = props.components;
|
|
1005
|
-
return prepare(props.fields).map((field, index) => /* @__PURE__ */ jsxs8(Fragment4, { children: [
|
|
1006
|
-
isColumn(field) && /* @__PURE__ */ jsx21(Column2, { column: field, children: /* @__PURE__ */ jsx21(SlotBase, { ...props, fields: field.fields }) }),
|
|
1007
|
-
isField(field) && /* @__PURE__ */ jsx21(Field2, { disabled: props.disabled, field, style: props.style, children: props.children })
|
|
1008
|
-
] }, index));
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
// src/component/slot/slot-create.tsx
|
|
1012
|
-
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1013
|
-
function createSlot(Field2) {
|
|
1014
|
-
const CreateSlot = (props) => /* @__PURE__ */ jsx22(SlotBase, { ...props, components: { column: Column, field: Field2 } });
|
|
1015
|
-
return CreateSlot;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
// src/component/slot/slot.tsx
|
|
1019
|
-
var Slot = createSlot(Field);
|
|
1020
|
-
|
|
1021
|
-
// src/server/component/form.tsx
|
|
1022
|
-
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1023
|
-
function Form2(props) {
|
|
1024
|
-
const translations = props.translations?.[props.lang ?? ""];
|
|
1025
|
-
return /* @__PURE__ */ jsx23(
|
|
1026
|
-
Form,
|
|
1027
|
-
{
|
|
1028
|
-
config: props.config,
|
|
1029
|
-
control: props.children,
|
|
1030
|
-
definition: props.definition,
|
|
1031
|
-
readOnly: props.readOnly,
|
|
1032
|
-
sections: props.sections,
|
|
1033
|
-
children: ({ disabled, fields }) => /* @__PURE__ */ jsx23(Slot, { disabled, fields, style: props.config.style, children: (internal) => /* @__PURE__ */ jsx23(
|
|
1034
|
-
Input,
|
|
1035
|
-
{
|
|
1036
|
-
...internal,
|
|
1037
|
-
config: props.config,
|
|
1038
|
-
context: props.context,
|
|
1039
|
-
translations,
|
|
1040
|
-
value: props.value
|
|
1041
|
-
}
|
|
1042
|
-
) })
|
|
1043
|
-
}
|
|
1044
|
-
);
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
// src/server/component/fallback.tsx
|
|
1048
|
-
import { Suspense } from "react";
|
|
1049
|
-
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
1050
|
-
function Fallback(props) {
|
|
1051
|
-
return /* @__PURE__ */ jsx24(
|
|
1052
|
-
Suspense,
|
|
1053
|
-
{
|
|
1054
|
-
fallback: /* @__PURE__ */ jsx24(Form2, { config: props.config, sections: props.sections, readOnly: true }),
|
|
1055
|
-
children: props.children
|
|
1056
|
-
}
|
|
1057
|
-
);
|
|
1058
|
-
}
|
|
1059
|
-
export {
|
|
1060
|
-
Fallback,
|
|
1061
|
-
Form2 as Form
|
|
1062
|
-
};
|
|
1
|
+
import{jsx as vt}from"react/jsx-runtime";function z(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return vt("div",{"data-slot":"field-control",className:"w-full",children:t})}import{Activity as rn,useState as ln}from"react";import{jsx as Z}from"react/jsx-runtime";function q(e){return Z("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:Z("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"})})}import{jsx as Lt}from"react/jsx-runtime";function T(e){return Lt("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})}var I="input",J="input/email",Q="input/number";var j="textarea",ee="radio",te="checkbox",ne="select",oe="select/month",re="select/year";var M="column";var ie="label",V="value",k="options",G="email",le="number",ae="password",se="tel",C="text",ce="aria-errormessage",de="aria-invalid",ue="data-invalid",fe="data-readonly",me="aria",pe="data",ge="min",xe="max",be="minLength",ye="maxLength",A="$ref";var f="vertical",h="horizontal";function l(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function m(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function x(e){return typeof e=="string"}var Dt=/[^/]+$/;function Re(e,t=V){if(e!=null){if(m(e))return e;if(l(e)){let n=_t(e,t);if(m(n))return n}}}function _t(e,t){let n=b(e,t);if(m(n))return n}function b(e,t){if(!t||!l(e))return null;let n=t.split(".").filter(r=>r!=="");if(n.length===0)return null;let o=e;for(let r of n)if(l(o)&&r in o)o=o[r];else return null;return o}function Te(e,t={label:ie,value:V}){return e.map(n=>{if(l(n)){let o=b(n,t.label),r=b(n,t.value);if(m(o)&&m(r))return{label:`${o}`,value:`${r}`}}return n})}function Ae(e=C){if(e){let t=e.match(Dt);if(t){let[n]=t;if(n!==I)return n.trim().toLowerCase()}}return C}var Mt=/\[([^\]]+)\]\(([^)]+)\)/g;function N(e,t={}){if(x(e))return Vt(e,t);if(Array.isArray(e))return e.map(n=>N(n,t));if(l(e)){let n={};for(let o in e)n[o]=N(e[o],t);return n}return e}function S(e){return x(e)?/{([^}]+)}/.test(e):Array.isArray(e)?e.some(t=>S(t)):l(e)?Object.values(e).some(t=>S(t)):!1}function Vt(e,t={}){return e.replace(/{([^}]+)}/g,(n,o)=>{let r=o.includes(".")?b(t,o):t[o];return m(r)?String(r):n})}function he(e,t){if(!e||e.trim().length===0)return null;let n,o=0,r=!1,i=[];for(;(n=Mt.exec(e))!==null;){let[a,g,Pt]=n,E=n.index;r=!0,E>o&&i.push(e.substring(o,E));let wt=t?t(E,Pt,g):a;i.push(wt),o=E+a.length}return r?(o<e.length&&i.push(e.substring(o)),i):e}var Ce=e=>c(oe)(e),Ne=e=>c(re)(e),s=c(te),Se=c(I),y=c(ee),d=c(ne),Fe=c(j),Ee=c(C,G,ae,se),Kn=c(J,G),Ie=c(Q,le);function ke(e){return y(e)||s(e)}function Oe(e){return e.type===M}function Pe(e){return e.type!==M}function we(e){return d(e)||y(e)}function X(e){return e!=null&&e!==""}function c(...e){return t=>{let n=x(t.type)?t.type:void 0;return n?e.some(o=>n===o||n?.startsWith(`${o}/`)):!1}}function ve(e,t={}){if(d(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&l(n))return[n]}}function Le(e){return y(e)||s(e)?h:e.advanced?.orientation??f}function De(e){return s(e)?e.advanced?.reverse!==!1:!1}function _e(e,t){let n=e.readonly??!1;return t||n}function Me(e){if(y(e)||d(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||l(t)&&!(A in t))return t}}var Gt=/^\d+$/;function Ve(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function Ge(e,t){return t>=e?Array.from({length:t-e+1},(n,o)=>{let r=e+o;return{value:r.toString(),label:r.toString()}}):[]}function Y(){return new Date().getFullYear()}function B(e,t){if(typeof e=="number")return e;let n=t??Y(),o=e.trim().toLowerCase();if(o.startsWith("current")){let r=o.match(/^current([+-])(\d+)$/);if(r){let[,i,a]=r,g=parseInt(a,10);if(!isNaN(g))return i==="+"?n+g:n-g}return n}return Gt.test(o)?parseInt(o,10):n}var O=Y();function Xt(e){if(d(e))return Yt(e)}function Yt(e){if(Ce(e))return Ve();if(Ne(e)){let t=e.advanced?.length?.min??O,n=e.advanced?.length?.max??O+5;return Ge(B(t,O),B(n,O))}}function Xe(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return Se(e)?{...n,...Bt(e)}:d(e)?{...n,...Ut(e)}:Fe(e)?{...n,...$t(e)}:n}function Bt(e){let t=Ae(e.type),n={...e,type:t};return{...Ye(e),...Ht(n),...Ee(n)?Be(n):{},type:t}}function Ut(e){let t=Xt(e);return t?{options:t}:{}}function $t(e){return{...Ye(e),...Be(e)}}function Ye(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function Ht(e){return Ie(e)?Kt(e):{}}function Be(e){return Ue(e,{min:be,max:ye})}function Kt(e){return Ue(e,{min:ge,max:xe})}function Ue(e,t){let n={},o=e.advanced?.length;return o&&(o.min!==void 0&&(n[t.min]=o.min),o.max!==void 0&&(n[t.max]=o.max)),n}function $e(e,t){let n=Me(e);return n||ve(e,t)}function Wt(e,t){let n=l(t)&&e.name in t?t[e.name]:t;return Re(n,e.advanced?.entity)}function zt(e,t,n){return we(e)&&Array.isArray(n)?{...t,[k]:n}:t}function Zt(e,t,n){if(e.required&&!X(n)&&d(e)&&e.advanced?.preselected!==!1&&k in t){let o=t[k];if(Array.isArray(o)&&o.length===1)return o[0]}return n}function qt(e,t){return d(e)&&Array.isArray(t)?Te(t,e.advanced?.options):t}function He(e,t,n,o){let r=Wt(e,o),i=Array.isArray(n)?qt(e,n):n,a=zt(e,t,i),g=Zt(e,a,r);return{commonPropsWithOptions:a,defaultValue:g}}function Ke(e,t){return s(e)?{defaultChecked:X(t)}:{defaultValue:t}}var Jt=/^#\/definition\//;function w(e=[],t){let n=P(e,t);return Array.isArray(n)?n.sort((o,r)=>We(o)-We(r)):[]}function P(e,t,n=new Map,o=new WeakSet){if(!Qt(t)||!e||typeof e!="object")return e;if(n.has(e))return n.get(e);if(o.has(e))return e;if(o.add(e),Array.isArray(e))return e.map(i=>P(i,t,n,o));if(A in e&&x(e[A])){let i=e[A].replace(Jt,""),a=b(t,i);return a!==null?P(a,t,n,o):e}let r={};for(let[i,a]of Object.entries(e))r[i]=P(a,t,n,o);return o.delete(e),n.set(e,r),r}function ze(e){return Object.entries(e??{})}function We(e){return e.order??Number.MAX_VALUE}function Qt(e){return e!==void 0&&l(e)&&Object.keys(e).length>0}function Ze(e,t){let n={};for(let[o,r]of ze(t))n[`${e}-${o}`]=r;return n}function jt(e){return Ze(me,e)}function en(e){return Ze(pe,e)}function qe(e,t){let n=jt(e.advanced?.aria);return t&&t.length>0&&(n[de]="true",n[ce]=`${e.name}-error`),n}function Je(e){return en(e.advanced?.data)}var Qe={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},je={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function et(e,t=2){return Qe[e&&e in Qe?e:t]}function tt(e){if(e&&e in je)return je[e]}function R(e,t){return e?t?t[e]??e:e:""}function v(e,t){return{...e,...t}}import{jsx as tn}from"react/jsx-runtime";function p(e){return he(e,(t,n,o)=>tn("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:o},`${n}-${t}`))}import{Fragment as nn,jsx as nt,jsxs as on}from"react/jsx-runtime";function ot(e){return on(nn,{children:[e.title&&nt("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:p(e.title)}),e.description&&nt("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:p(e.description)})]})}import{jsx as u,jsxs as L}from"react/jsx-runtime";function rt(e){let t=e.section.fields||[],[n,o]=ln(!1),{compact:r}=v(e.style,{compact:e.section.compact});return!e.section.title&&!e.section.description?u(T,{compact:r,children:e.children}):e.section.advanced?L("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:[u("legend",{children:L("button",{type:"button",onClick:()=>o(i=>!i),className:"flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",children:[u(q,{expanded:n}),u("span",{children:p(e.section.title)})]})}),u(rn,{mode:n?"visible":"hidden",children:L("div",{className:"mt-3 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&&u("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:p(e.section.description)}),u(T,{compact:r,children:e.children})]})})]}):L("fieldset",{"data-slot":"field-set","data-empty":t.length===0,className:"flex flex-col data-[empty=false]:gap-6",id:e.section.id?.toString(),children:[u(ot,{description:e.section.description,title:e.section.title}),u(T,{compact:r,children:e.children})]})}import{Fragment as an}from"react";import{jsx as it}from"react/jsx-runtime";function lt(){return it("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:it("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}import{jsx as F,jsxs as at}from"react/jsx-runtime";function st(e){let t=w(e.sections,e.definition);return F("div",{className:"h-full w-full",children:F("form",{noValidate:e.noValidate,action:e.action,children:at(T,{children:[t.map((n,o)=>at(an,{children:[F(rt,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&F(lt,{})]},o)),e.control&&F(z,{isPending:e.isPending,children:e.control})]})})})}import{jsx as sn}from"react/jsx-runtime";function ct(e){return sn("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}import{jsx as cn}from"react/jsx-runtime";function D(e){let t=p(e.text);return t?cn(ct,{children:t}):null}import{twMerge as dn}from"tailwind-merge";import{jsx as un,jsxs as fn}from"react/jsx-runtime";function dt(e){let t=e.style?.showOptionalLabel??!0,n=y(e.field)||s(e.field);return fn("label",{"data-slot":"field-label","data-normal":n,className:dn("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&&un("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:R("(Optional)",e.translations)})]})}import{jsx as ut,jsxs as mn}from"react/jsx-runtime";function ft(e){let t=S(e.field.label)?N(e.field.label,{context:e.context,env:e.config?.env}):e.field.label,n=S(e.field.description)?N(e.field.description,{context:e.context,env:e.config?.env}):e.field.description;return mn("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[ut(dt,{field:e.field,style:e.config?.style,translations:e.translations,children:R(t,e.translations)}),e.orientation===h&&ut(D,{text:R(n,e.translations)})]})}import{Fragment as pn,jsx as mt,jsxs as gn}from"react/jsx-runtime";function pt(e){return gn(pn,{children:[e.field.name&&e.field.label&&mt(ft,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations}),e.children,e.orientation===f&&e.field.description&&mt(D,{text:R(e.field.description,e.translations)})]})}function gt(e,t){return e?t(e):null}import{jsx as xt}from"react/jsx-runtime";function bt(e){let t=$e(e.field,e.value),{commonPropsWithOptions:n,defaultValue:o}=He(e.field,e.commonProps,t,e.value),r=Ke(e.field,o);return gt(e.config.inputs[e.field.type],i=>xt(pt,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations,children:xt(i,{...e.ariaAttributes,...n,...e.dataAttributes,...r})}))}import{jsx as yt}from"react/jsx-runtime";function Rt(e){return!e.errors||e.errors.length===0?null:yt("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)=>yt("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}import{twMerge as xn}from"tailwind-merge";import{jsx as bn}from"react/jsx-runtime";function _(e){let t=e.errors&&e.errors.length>0;return bn("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[ue]:"true"},...e.disabled&&{[fe]:"true"},"data-orientation":e.orientation,className:xn("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 yn}from"tailwind-merge";import{jsx as Rn}from"react/jsx-runtime";function Tt(e){return Rn(_,{...e,orientation:f,className:yn("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as Tn}from"tailwind-merge";import{jsx as An}from"react/jsx-runtime";function At(e){return An(_,{...e,orientation:h,className:Tn("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 ht}from"react/jsx-runtime";function Ct(e){let t=ke(e.field),n=s(e.field),o=De(e.field);return e.orientation===f?ht(Tt,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children}):ht(At,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children})}function Nt(e){if(!e.field.type)return null;let t=Xe(e.field,e.disabled),n=Je(e.field),o=qe(e.field,e.errors),r={...e.field,disabled:t.disabled};return e.children({ariaAttributes:o,commonProps:t,dataAttributes:n,field:r,orientation:e.orientation})}import{twMerge as hn}from"tailwind-merge";import{jsx as U,jsxs as Cn}from"react/jsx-runtime";function St(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{orientation:o}=v(e.style,{orientation:Le(e.field)}),r=_e(e.field,e.disabled);return Cn("div",{className:hn("flex flex-col gap-3",tt(t)),children:[U(Ct,{disabled:r,errors:n,field:e.field,orientation:o,children:U(Nt,{disabled:r,errors:n,field:e.field,orientation:o,children:e.children})}),U(Rt,{errors:n,name:e.field.name})]})}import{twMerge as Nn}from"tailwind-merge";import{jsx as Ft}from"react/jsx-runtime";function Et(e){let t=et(e.column?.advanced?.cols);return Ft("div",{className:"flex w-full flex-col gap-4",children:Ft("div",{className:Nn("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children})})}import{Fragment as Sn}from"react";import{jsx as $,jsxs as Fn}from"react/jsx-runtime";function H(e){let{column:t,field:n}=e.components;return w(e.fields).map((o,r)=>Fn(Sn,{children:[Oe(o)&&$(t,{column:o,children:$(H,{...e,fields:o.fields})}),Pe(o)&&$(n,{disabled:e.disabled,field:o,style:e.style,children:e.children})]},r))}import{jsx as En}from"react/jsx-runtime";function It(e){return n=>En(H,{...n,components:{column:Et,field:e}})}var kt=It(St);import{jsx as K}from"react/jsx-runtime";function W(e){let t=e.translations?.[e.lang??""];return K(st,{config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:o})=>K(kt,{disabled:n,fields:o,style:e.config.style,children:r=>K(bt,{...r,config:e.config,context:e.context,translations:t,value:e.value})})})}import{Suspense as In}from"react";import{jsx as Ot}from"react/jsx-runtime";function kn(e){return Ot(In,{fallback:Ot(W,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{kn as Fallback,W as Form};
|