react-luna-form 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/cjs/index.js +1 -2741
- package/dist/client/esm/index.js +1 -2708
- package/dist/config/cjs/index.js +1 -229
- package/dist/config/esm/index.js +1 -206
- package/dist/server/cjs/index.js +1 -1446
- package/dist/server/esm/index.js +1 -1423
- package/dist/types/luna-react/src/client/component/field/field-with-state.d.ts +6 -0
- package/dist/types/luna-react/src/client/lib/store-helper.d.ts +1 -0
- package/package.json +2 -2
- package/dist/types/luna-react/src/client/component/field/field-with-error.d.ts +0 -6
package/dist/server/cjs/index.js
CHANGED
|
@@ -1,1446 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/server/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
Fallback: () => Fallback,
|
|
24
|
-
Form: () => Form2
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
|
|
28
|
-
// src/component/control.tsx
|
|
29
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
-
function Control(props) {
|
|
31
|
-
const content = typeof props.children === "function" ? props.children({ isPending: props.isPending }) : props.children;
|
|
32
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "field-control", className: "w-full", children: content });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/component/field/field-set-advanced.tsx
|
|
36
|
-
var import_react = require("react");
|
|
37
|
-
|
|
38
|
-
// src/component/chevron-icon.tsx
|
|
39
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
40
|
-
function ChevronIcon(props) {
|
|
41
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
42
|
-
"svg",
|
|
43
|
-
{
|
|
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
|
-
)
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ../luna-core/src/util/constant.ts
|
|
61
|
-
var INPUT = "input";
|
|
62
|
-
var INPUT_EMAIL = "input/email";
|
|
63
|
-
var INPUT_NUMBER = "input/number";
|
|
64
|
-
var TEXTAREA = "textarea";
|
|
65
|
-
var RADIO = "radio";
|
|
66
|
-
var CHECKBOX = "checkbox";
|
|
67
|
-
var LIST = "list";
|
|
68
|
-
var SELECT = "select";
|
|
69
|
-
var SELECT_MONTH = "select/month";
|
|
70
|
-
var SELECT_YEAR = "select/year";
|
|
71
|
-
var COLUMN = "column";
|
|
72
|
-
var FIELDS = "fields";
|
|
73
|
-
var LABEL = "label";
|
|
74
|
-
var VALUE = "value";
|
|
75
|
-
var OPTIONS = "options";
|
|
76
|
-
var TYPE_EMAIL = "email";
|
|
77
|
-
var TYPE_NUMBER = "number";
|
|
78
|
-
var TYPE_PASSWORD = "password";
|
|
79
|
-
var TYPE_TEL = "tel";
|
|
80
|
-
var TYPE_TEXT = "text";
|
|
81
|
-
var ARIA_ERROR_MESSAGE = "aria-errormessage";
|
|
82
|
-
var ARIA_INVALID = "aria-invalid";
|
|
83
|
-
var DATA_INVALID = "data-invalid";
|
|
84
|
-
var DATA_READONLY = "data-readonly";
|
|
85
|
-
var PREFIX_ARIA = "aria";
|
|
86
|
-
var PREFIX_DATA = "data";
|
|
87
|
-
var MIN = "min";
|
|
88
|
-
var MAX = "max";
|
|
89
|
-
var MIN_LENGTH = "minLength";
|
|
90
|
-
var MAX_LENGTH = "maxLength";
|
|
91
|
-
var $REF = "$ref";
|
|
92
|
-
var VERTICAL = "vertical";
|
|
93
|
-
var HORIZONTAL = "horizontal";
|
|
94
|
-
var TYPE = "type";
|
|
95
|
-
|
|
96
|
-
// ../luna-core/src/util/is-type.ts
|
|
97
|
-
function isObject(value) {
|
|
98
|
-
return value !== null && Object.prototype.toString.call(value) === "[object Object]";
|
|
99
|
-
}
|
|
100
|
-
function isValue(value) {
|
|
101
|
-
return isString(value) || typeof value === "number" || isBoolean(value);
|
|
102
|
-
}
|
|
103
|
-
function isString(value) {
|
|
104
|
-
return typeof value === "string";
|
|
105
|
-
}
|
|
106
|
-
function isBoolean(value) {
|
|
107
|
-
return typeof value === "boolean";
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// ../luna-core/src/util/extract.ts
|
|
111
|
-
var REGEX_TYPE = /[^/]+$/;
|
|
112
|
-
function getCurrentValue(value, entity = VALUE) {
|
|
113
|
-
if (value !== null && value !== void 0) {
|
|
114
|
-
if (isValue(value)) {
|
|
115
|
-
return value;
|
|
116
|
-
}
|
|
117
|
-
if (isObject(value)) {
|
|
118
|
-
const result = getValue(value, entity);
|
|
119
|
-
if (isValue(result)) {
|
|
120
|
-
return result;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function getValue(value, namespace) {
|
|
126
|
-
const result = extract(value, namespace);
|
|
127
|
-
if (isValue(result)) {
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function extract(value, namespace) {
|
|
132
|
-
if (!namespace || !isObject(value)) {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
const keys = namespace.split(".").filter((key) => key !== "");
|
|
136
|
-
if (keys.length === 0) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
let result = value;
|
|
140
|
-
for (const key of keys) {
|
|
141
|
-
if (isObject(result) && key in result) {
|
|
142
|
-
const obj = result;
|
|
143
|
-
result = obj[key];
|
|
144
|
-
} else {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return result;
|
|
149
|
-
}
|
|
150
|
-
function toOptions(data, options = { label: LABEL, value: VALUE }) {
|
|
151
|
-
return data.map((item) => {
|
|
152
|
-
if (isObject(item)) {
|
|
153
|
-
const label = extract(item, options.label);
|
|
154
|
-
const value = extract(item, options.value);
|
|
155
|
-
if (isValue(label) && isValue(value)) {
|
|
156
|
-
return {
|
|
157
|
-
label: `${label}`,
|
|
158
|
-
value: `${value}`
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return item;
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function getType(value = TYPE_TEXT) {
|
|
166
|
-
if (value) {
|
|
167
|
-
const result = value.match(REGEX_TYPE);
|
|
168
|
-
if (result) {
|
|
169
|
-
const [type] = result;
|
|
170
|
-
if (type !== INPUT) {
|
|
171
|
-
return type.trim().toLowerCase();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return TYPE_TEXT;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// ../luna-core/src/util/string.ts
|
|
179
|
-
var REGEX_MARKDOWN_LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
180
|
-
function interpolate(template, values = {}) {
|
|
181
|
-
if (isString(template)) {
|
|
182
|
-
return replacePlaceholders(template, values);
|
|
183
|
-
}
|
|
184
|
-
if (Array.isArray(template)) {
|
|
185
|
-
return template.map((item) => {
|
|
186
|
-
return interpolate(item, values);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
if (isObject(template)) {
|
|
190
|
-
const results = {};
|
|
191
|
-
for (const key in template) {
|
|
192
|
-
results[key] = interpolate(template[key], values);
|
|
193
|
-
}
|
|
194
|
-
return results;
|
|
195
|
-
}
|
|
196
|
-
return template;
|
|
197
|
-
}
|
|
198
|
-
function interpolateIfNeeded(template, values = {}) {
|
|
199
|
-
return isInterpolated(template) ? interpolate(template, values) : template;
|
|
200
|
-
}
|
|
201
|
-
function isInterpolated(template) {
|
|
202
|
-
if (isString(template)) {
|
|
203
|
-
return /{([^}]+)}/.test(template);
|
|
204
|
-
}
|
|
205
|
-
if (Array.isArray(template)) {
|
|
206
|
-
return template.some((item) => isInterpolated(item));
|
|
207
|
-
}
|
|
208
|
-
if (isObject(template)) {
|
|
209
|
-
return Object.values(template).some((value) => isInterpolated(value));
|
|
210
|
-
}
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
function replacePlaceholders(template, values = {}) {
|
|
214
|
-
return template.replace(/{([^}]+)}/g, (match, key) => {
|
|
215
|
-
const value = key.includes(".") ? extract(values, key) : values[key];
|
|
216
|
-
if (isValue(value)) {
|
|
217
|
-
return String(value);
|
|
218
|
-
}
|
|
219
|
-
return match;
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function formatMarkdown(text, callback) {
|
|
223
|
-
if (!text || text.trim().length === 0) {
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
let match;
|
|
227
|
-
let lastIndex = 0;
|
|
228
|
-
let hasMatch = false;
|
|
229
|
-
const parts = [];
|
|
230
|
-
while ((match = REGEX_MARKDOWN_LINK.exec(text)) !== null) {
|
|
231
|
-
const [fullMatch, linkText, url] = match;
|
|
232
|
-
const index = match.index;
|
|
233
|
-
hasMatch = true;
|
|
234
|
-
if (index > lastIndex) {
|
|
235
|
-
parts.push(text.substring(lastIndex, index));
|
|
236
|
-
}
|
|
237
|
-
const value = callback ? callback(index, url, linkText) : fullMatch;
|
|
238
|
-
parts.push(value);
|
|
239
|
-
lastIndex = index + fullMatch.length;
|
|
240
|
-
}
|
|
241
|
-
if (!hasMatch) {
|
|
242
|
-
return text;
|
|
243
|
-
}
|
|
244
|
-
if (lastIndex < text.length) {
|
|
245
|
-
parts.push(text.substring(lastIndex));
|
|
246
|
-
}
|
|
247
|
-
return parts;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// ../luna-core/src/util/is-input.ts
|
|
251
|
-
var isSelectMonth = (field) => createTypeChecker(SELECT_MONTH)(field);
|
|
252
|
-
var isSelectYear = (field) => createTypeChecker(SELECT_YEAR)(field);
|
|
253
|
-
var isCheckbox = createTypeChecker(CHECKBOX);
|
|
254
|
-
var isInput = createTypeChecker(INPUT);
|
|
255
|
-
var isRadio = createTypeChecker(RADIO);
|
|
256
|
-
var isSelect = createTypeChecker(SELECT);
|
|
257
|
-
var isTextArea = createTypeChecker(TEXTAREA);
|
|
258
|
-
var isText = createTypeChecker(
|
|
259
|
-
TYPE_TEXT,
|
|
260
|
-
TYPE_EMAIL,
|
|
261
|
-
TYPE_PASSWORD,
|
|
262
|
-
TYPE_TEL
|
|
263
|
-
);
|
|
264
|
-
var isEmail = createTypeChecker(INPUT_EMAIL, TYPE_EMAIL);
|
|
265
|
-
var isNumber = createTypeChecker(INPUT_NUMBER, TYPE_NUMBER);
|
|
266
|
-
function isClickable(field) {
|
|
267
|
-
return isRadio(field) || isCheckbox(field);
|
|
268
|
-
}
|
|
269
|
-
function isList(slot) {
|
|
270
|
-
return slot.type === LIST;
|
|
271
|
-
}
|
|
272
|
-
function isColumn(slot) {
|
|
273
|
-
return slot.type === COLUMN;
|
|
274
|
-
}
|
|
275
|
-
function isField(slot) {
|
|
276
|
-
return slot.type !== COLUMN && slot.type !== LIST;
|
|
277
|
-
}
|
|
278
|
-
function isOptions(field) {
|
|
279
|
-
return isSelect(field) || isRadio(field);
|
|
280
|
-
}
|
|
281
|
-
function isValidValue(value) {
|
|
282
|
-
return value !== void 0 && value !== null && value !== "";
|
|
283
|
-
}
|
|
284
|
-
function createTypeChecker(...types) {
|
|
285
|
-
return (field) => {
|
|
286
|
-
const inputType = isString(field.type) ? field.type : void 0;
|
|
287
|
-
if (!inputType) {
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
return types.some((type) => {
|
|
291
|
-
return inputType === type || inputType?.startsWith(`${type}/`);
|
|
292
|
-
});
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// ../luna-core/src/util/build.ts
|
|
297
|
-
function buildOptions(field, values = {}) {
|
|
298
|
-
if (isSelect(field) && field.disabled) {
|
|
299
|
-
const current = field.name ? values?.[field.name] : void 0;
|
|
300
|
-
if (current && isObject(current)) {
|
|
301
|
-
return [current];
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function buildOrientation(field) {
|
|
306
|
-
if (isRadio(field) || isCheckbox(field)) {
|
|
307
|
-
return HORIZONTAL;
|
|
308
|
-
}
|
|
309
|
-
return field.advanced?.orientation ?? VERTICAL;
|
|
310
|
-
}
|
|
311
|
-
function buildReverse(field) {
|
|
312
|
-
if (!isCheckbox(field)) {
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
return field.advanced?.reverse !== false;
|
|
316
|
-
}
|
|
317
|
-
function buildDisabled(field, disabled) {
|
|
318
|
-
const readonly = field.readonly ?? false;
|
|
319
|
-
return disabled ? disabled : readonly;
|
|
320
|
-
}
|
|
321
|
-
function buildSource(field) {
|
|
322
|
-
if (isRadio(field) || isSelect(field) && !field.disabled) {
|
|
323
|
-
const source = field.source;
|
|
324
|
-
if (Array.isArray(source) || isObject(source) && !($REF in source)) {
|
|
325
|
-
return source;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ../luna-core/src/util/date.ts
|
|
331
|
-
var REGEX_DIGITS = /^\d+$/;
|
|
332
|
-
function getMonth() {
|
|
333
|
-
return Array.from({ length: 12 }, (_, i) => ({
|
|
334
|
-
value: (i + 1).toString(),
|
|
335
|
-
label: new Date(0, i).toLocaleString("default", {
|
|
336
|
-
month: "long"
|
|
337
|
-
})
|
|
338
|
-
}));
|
|
339
|
-
}
|
|
340
|
-
function getYear(min, max) {
|
|
341
|
-
if (max >= min) {
|
|
342
|
-
return Array.from({ length: max - min + 1 }, (_, i) => {
|
|
343
|
-
const year = min + i;
|
|
344
|
-
return {
|
|
345
|
-
value: year.toString(),
|
|
346
|
-
label: year.toString()
|
|
347
|
-
};
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
return [];
|
|
351
|
-
}
|
|
352
|
-
function getCurrentYear() {
|
|
353
|
-
return (/* @__PURE__ */ new Date()).getFullYear();
|
|
354
|
-
}
|
|
355
|
-
function getConvert(value, current) {
|
|
356
|
-
if (typeof value === "number") {
|
|
357
|
-
return value;
|
|
358
|
-
}
|
|
359
|
-
const now2 = current ?? getCurrentYear();
|
|
360
|
-
const trimmed = value.trim().toLowerCase();
|
|
361
|
-
if (trimmed.startsWith("current")) {
|
|
362
|
-
const match = trimmed.match(/^current([+-])(\d+)$/);
|
|
363
|
-
if (match) {
|
|
364
|
-
const [, operator, offsetStr] = match;
|
|
365
|
-
const offset = parseInt(offsetStr, 10);
|
|
366
|
-
if (!isNaN(offset)) {
|
|
367
|
-
return operator === "+" ? now2 + offset : now2 - offset;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
return now2;
|
|
371
|
-
}
|
|
372
|
-
if (REGEX_DIGITS.test(trimmed)) {
|
|
373
|
-
return parseInt(trimmed, 10);
|
|
374
|
-
}
|
|
375
|
-
return now2;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// ../luna-core/src/helper/input.ts
|
|
379
|
-
var now = getCurrentYear();
|
|
380
|
-
function buildOptionSelect(field) {
|
|
381
|
-
if (isSelect(field)) {
|
|
382
|
-
return defineOption(field);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
function defineOption(select) {
|
|
386
|
-
if (isSelectMonth(select)) {
|
|
387
|
-
return getMonth();
|
|
388
|
-
}
|
|
389
|
-
if (isSelectYear(select)) {
|
|
390
|
-
const min = select.advanced?.length?.min ?? now;
|
|
391
|
-
const max = select.advanced?.length?.max ?? now + 5;
|
|
392
|
-
return getYear(getConvert(min, now), getConvert(max, now));
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
function buildCommon(field, disabled = false) {
|
|
396
|
-
const commonProps = {
|
|
397
|
-
disabled,
|
|
398
|
-
id: field.name,
|
|
399
|
-
name: field.name,
|
|
400
|
-
placeholder: field.placeholder,
|
|
401
|
-
required: field.required
|
|
402
|
-
};
|
|
403
|
-
if (isInput(field)) {
|
|
404
|
-
return {
|
|
405
|
-
...commonProps,
|
|
406
|
-
...defineInput(field)
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
if (isSelect(field)) {
|
|
410
|
-
return {
|
|
411
|
-
...commonProps,
|
|
412
|
-
...defineSelect(field)
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
if (isTextArea(field)) {
|
|
416
|
-
return {
|
|
417
|
-
...commonProps,
|
|
418
|
-
...defineTextArea(field)
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
return commonProps;
|
|
422
|
-
}
|
|
423
|
-
function defineInput(input) {
|
|
424
|
-
const type = getType(input.type);
|
|
425
|
-
const copy = { ...input, type };
|
|
426
|
-
return {
|
|
427
|
-
...defineAutoComplete(input),
|
|
428
|
-
...defineNumberLimits(copy),
|
|
429
|
-
...isText(copy) ? defineLength(copy) : {},
|
|
430
|
-
type
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
function defineSelect(field) {
|
|
434
|
-
const options = buildOptionSelect(field);
|
|
435
|
-
if (options) {
|
|
436
|
-
return { options };
|
|
437
|
-
}
|
|
438
|
-
return {};
|
|
439
|
-
}
|
|
440
|
-
function defineTextArea(field) {
|
|
441
|
-
return {
|
|
442
|
-
...defineAutoComplete(field),
|
|
443
|
-
...defineLength(field)
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
function defineAutoComplete(input) {
|
|
447
|
-
const autoComplete = input.advanced?.autocomplete;
|
|
448
|
-
if (autoComplete) {
|
|
449
|
-
return { autoComplete };
|
|
450
|
-
}
|
|
451
|
-
return {};
|
|
452
|
-
}
|
|
453
|
-
function defineNumberLimits(input) {
|
|
454
|
-
if (isNumber(input)) {
|
|
455
|
-
return defineMinMax(input);
|
|
456
|
-
}
|
|
457
|
-
return {};
|
|
458
|
-
}
|
|
459
|
-
function defineLength(input) {
|
|
460
|
-
return defineConstraints(input, { min: MIN_LENGTH, max: MAX_LENGTH });
|
|
461
|
-
}
|
|
462
|
-
function defineMinMax(input) {
|
|
463
|
-
return defineConstraints(input, { min: MIN, max: MAX });
|
|
464
|
-
}
|
|
465
|
-
function defineConstraints(input, keys) {
|
|
466
|
-
const result = {};
|
|
467
|
-
const length = input.advanced?.length;
|
|
468
|
-
if (length) {
|
|
469
|
-
if (length.min !== void 0) {
|
|
470
|
-
result[keys.min] = length.min;
|
|
471
|
-
}
|
|
472
|
-
if (length.max !== void 0) {
|
|
473
|
-
result[keys.max] = length.max;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return result;
|
|
477
|
-
}
|
|
478
|
-
function resolveSource(field, value) {
|
|
479
|
-
const current = buildSource(field);
|
|
480
|
-
if (current) {
|
|
481
|
-
return current;
|
|
482
|
-
}
|
|
483
|
-
return buildOptions(field, value);
|
|
484
|
-
}
|
|
485
|
-
function getInputValue(field, value) {
|
|
486
|
-
const newValue = isObject(value) && field.name in value ? value[field.name] : value;
|
|
487
|
-
return getCurrentValue(newValue, field.advanced?.entity);
|
|
488
|
-
}
|
|
489
|
-
function mergeOptionsProps(field, commonProps, options) {
|
|
490
|
-
return isOptions(field) && Array.isArray(options) ? { ...commonProps, [OPTIONS]: options } : commonProps;
|
|
491
|
-
}
|
|
492
|
-
function getPreselectedValue(field, commonProps, value) {
|
|
493
|
-
if (field.required && !isValidValue(value)) {
|
|
494
|
-
if (isSelect(field)) {
|
|
495
|
-
if (field.advanced?.preselected !== false && OPTIONS in commonProps) {
|
|
496
|
-
const options = commonProps[OPTIONS];
|
|
497
|
-
if (Array.isArray(options) && options.length === 1) {
|
|
498
|
-
return options[0];
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
return value;
|
|
504
|
-
}
|
|
505
|
-
function getOptions(field, data) {
|
|
506
|
-
if (isSelect(field) && Array.isArray(data)) {
|
|
507
|
-
return toOptions(data, field.advanced?.options);
|
|
508
|
-
}
|
|
509
|
-
return data;
|
|
510
|
-
}
|
|
511
|
-
function prepareInputProps(field, commonProps, data, value) {
|
|
512
|
-
const currentValue = getInputValue(field, value);
|
|
513
|
-
const options = Array.isArray(data) ? getOptions(field, data) : data;
|
|
514
|
-
const commonPropsWithOptions = mergeOptionsProps(field, commonProps, options);
|
|
515
|
-
const defaultValue = getPreselectedValue(
|
|
516
|
-
field,
|
|
517
|
-
commonPropsWithOptions,
|
|
518
|
-
currentValue
|
|
519
|
-
);
|
|
520
|
-
return {
|
|
521
|
-
commonPropsWithOptions,
|
|
522
|
-
defaultValue
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
|
-
function prepareDefaultValue(field, value) {
|
|
526
|
-
if (isCheckbox(field)) {
|
|
527
|
-
return {
|
|
528
|
-
defaultChecked: isValidValue(value)
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
return { defaultValue: value };
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// ../luna-core/src/util/prepare.ts
|
|
535
|
-
var REGEX_REF = /^#\/definition\//;
|
|
536
|
-
function prepare(base = [], definition) {
|
|
537
|
-
const resolved = resolveRefs(base, definition);
|
|
538
|
-
return Array.isArray(resolved) ? resolved.filter(filter).sort((a, b) => getOrder(a) - getOrder(b)) : [];
|
|
539
|
-
}
|
|
540
|
-
function resolveRefs(base, definition, cache = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new WeakSet()) {
|
|
541
|
-
if (!isDefinition(definition) || !base || typeof base !== "object") {
|
|
542
|
-
return base;
|
|
543
|
-
}
|
|
544
|
-
if (cache.has(base)) {
|
|
545
|
-
return cache.get(base);
|
|
546
|
-
}
|
|
547
|
-
if (visited.has(base)) {
|
|
548
|
-
return base;
|
|
549
|
-
}
|
|
550
|
-
visited.add(base);
|
|
551
|
-
if (Array.isArray(base)) {
|
|
552
|
-
return base.map((item) => resolveRefs(item, definition, cache, visited));
|
|
553
|
-
}
|
|
554
|
-
if ($REF in base && isString(base[$REF])) {
|
|
555
|
-
const path = base[$REF].replace(REGEX_REF, "");
|
|
556
|
-
const resolved = extract(definition, path);
|
|
557
|
-
if (resolved !== null) {
|
|
558
|
-
return resolveRefs(resolved, definition, cache, visited);
|
|
559
|
-
}
|
|
560
|
-
return base;
|
|
561
|
-
}
|
|
562
|
-
const result = {};
|
|
563
|
-
for (const [key, value] of Object.entries(base)) {
|
|
564
|
-
result[key] = resolveRefs(value, definition, cache, visited);
|
|
565
|
-
}
|
|
566
|
-
visited.delete(base);
|
|
567
|
-
cache.set(base, result);
|
|
568
|
-
return result;
|
|
569
|
-
}
|
|
570
|
-
function entries(values) {
|
|
571
|
-
return Object.entries(values ?? {});
|
|
572
|
-
}
|
|
573
|
-
function getOrder(item) {
|
|
574
|
-
return item.order ?? Number.MAX_VALUE;
|
|
575
|
-
}
|
|
576
|
-
function isDefinition(definition) {
|
|
577
|
-
return definition !== void 0 && isObject(definition) && Object.keys(definition).length > 0;
|
|
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
|
-
}
|
|
588
|
-
|
|
589
|
-
// ../luna-core/src/util/attributes.ts
|
|
590
|
-
function getPrefixedAttributes(prefix, record) {
|
|
591
|
-
const attrs = {};
|
|
592
|
-
for (const [key, value] of entries(record)) {
|
|
593
|
-
attrs[`${prefix}-${key}`] = value;
|
|
594
|
-
}
|
|
595
|
-
return attrs;
|
|
596
|
-
}
|
|
597
|
-
function getAriaAttributes(record) {
|
|
598
|
-
return getPrefixedAttributes(PREFIX_ARIA, record);
|
|
599
|
-
}
|
|
600
|
-
function getDataAttributes(record) {
|
|
601
|
-
return getPrefixedAttributes(PREFIX_DATA, record);
|
|
602
|
-
}
|
|
603
|
-
function buildAriaAttributes(field, errors) {
|
|
604
|
-
const ariaAttributes = getAriaAttributes(field.advanced?.aria);
|
|
605
|
-
if (errors && errors.length > 0) {
|
|
606
|
-
ariaAttributes[ARIA_INVALID] = "true";
|
|
607
|
-
ariaAttributes[ARIA_ERROR_MESSAGE] = `${field.name}-error`;
|
|
608
|
-
}
|
|
609
|
-
return ariaAttributes;
|
|
610
|
-
}
|
|
611
|
-
function buildDataAttributes(field) {
|
|
612
|
-
return getDataAttributes(field.advanced?.data);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
// ../luna-core/src/util/column.ts
|
|
616
|
-
var cols = {
|
|
617
|
-
1: "md:grid-cols-1",
|
|
618
|
-
2: "md:grid-cols-2",
|
|
619
|
-
3: "md:grid-cols-3"
|
|
620
|
-
};
|
|
621
|
-
var span = {
|
|
622
|
-
1: "md:col-span-1",
|
|
623
|
-
2: "md:col-span-2",
|
|
624
|
-
3: "md:col-span-3"
|
|
625
|
-
};
|
|
626
|
-
function getColumn(value, defaultCols = 2) {
|
|
627
|
-
return cols[value && value in cols ? value : defaultCols];
|
|
628
|
-
}
|
|
629
|
-
function getSpan(value) {
|
|
630
|
-
if (value && value in span) {
|
|
631
|
-
return span[value];
|
|
632
|
-
}
|
|
633
|
-
}
|
|
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
|
-
|
|
660
|
-
// ../luna-core/src/util/translate.ts
|
|
661
|
-
function translate(key, dictionary) {
|
|
662
|
-
if (!key) {
|
|
663
|
-
return "";
|
|
664
|
-
}
|
|
665
|
-
if (!dictionary) {
|
|
666
|
-
return key;
|
|
667
|
-
}
|
|
668
|
-
return dictionary[key] ?? key;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
// ../luna-core/src/util/style.ts
|
|
672
|
-
function mergeStyle(globalStyle, localStyle) {
|
|
673
|
-
return { ...globalStyle, ...localStyle };
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
// src/lib/string.tsx
|
|
677
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
678
|
-
function formatMarkdown2(text) {
|
|
679
|
-
return formatMarkdown(
|
|
680
|
-
text,
|
|
681
|
-
(index, url, text2) => {
|
|
682
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
683
|
-
"a",
|
|
684
|
-
{
|
|
685
|
-
className: "underline",
|
|
686
|
-
href: url,
|
|
687
|
-
rel: "noopener noreferrer",
|
|
688
|
-
target: "_blank",
|
|
689
|
-
children: text2
|
|
690
|
-
},
|
|
691
|
-
`${url}-${index}`
|
|
692
|
-
);
|
|
693
|
-
}
|
|
694
|
-
);
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// src/component/field/field-set-advanced.tsx
|
|
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");
|
|
743
|
-
function Legend(props) {
|
|
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) })
|
|
747
|
-
] });
|
|
748
|
-
}
|
|
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
|
-
|
|
782
|
-
// src/component/field/field-set.tsx
|
|
783
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
784
|
-
function FieldSet(props) {
|
|
785
|
-
const { fields = [] } = props.section;
|
|
786
|
-
const { compact } = mergeStyle(props.style, {
|
|
787
|
-
compact: props.section.compact
|
|
788
|
-
});
|
|
789
|
-
const group = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Group, { compact, children: props.children });
|
|
790
|
-
if (!props.section.title && !props.section.description) {
|
|
791
|
-
return group;
|
|
792
|
-
}
|
|
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,
|
|
798
|
-
{
|
|
799
|
-
description: props.section.description,
|
|
800
|
-
empty: fields.length === 0,
|
|
801
|
-
id: props.section.id?.toString(),
|
|
802
|
-
title: props.section.title,
|
|
803
|
-
children: group
|
|
804
|
-
}
|
|
805
|
-
);
|
|
806
|
-
}
|
|
807
|
-
|
|
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
|
-
}
|
|
911
|
-
|
|
912
|
-
// src/component/separator.tsx
|
|
913
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
914
|
-
function Separator() {
|
|
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" }) });
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// src/component/form.tsx
|
|
919
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
920
|
-
function Form(props) {
|
|
921
|
-
const sections = prepare(props.sections, props.definition);
|
|
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({
|
|
925
|
-
disabled: props.readOnly,
|
|
926
|
-
fields: section.fields
|
|
927
|
-
}) }),
|
|
928
|
-
section.separator && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Separator, {})
|
|
929
|
-
] }, index)),
|
|
930
|
-
props.control && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Control, { isPending: props.isPending, children: props.control })
|
|
931
|
-
] }) }) });
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
// src/component/description.tsx
|
|
935
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
936
|
-
function Description(props) {
|
|
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 });
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
// src/component/formatted-description.tsx
|
|
941
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
942
|
-
function FormattedDescription(props) {
|
|
943
|
-
const content = formatMarkdown2(props.text);
|
|
944
|
-
if (content) {
|
|
945
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Description, { children: content });
|
|
946
|
-
}
|
|
947
|
-
return null;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
// src/component/label.tsx
|
|
951
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
952
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
953
|
-
function Label(props) {
|
|
954
|
-
const showOptionalLabel = props.style?.showOptionalLabel ?? true;
|
|
955
|
-
const normal = isRadio(props.field) || isCheckbox(props.field);
|
|
956
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
957
|
-
"label",
|
|
958
|
-
{
|
|
959
|
-
"data-slot": "field-label",
|
|
960
|
-
"data-normal": normal,
|
|
961
|
-
className: (0, import_tailwind_merge.twMerge)(
|
|
962
|
-
"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",
|
|
963
|
-
"data-[normal=true]:font-normal",
|
|
964
|
-
"group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"
|
|
965
|
-
),
|
|
966
|
-
htmlFor: props.field.name,
|
|
967
|
-
children: [
|
|
968
|
-
props.children,
|
|
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) })
|
|
970
|
-
]
|
|
971
|
-
}
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
// src/component/input-label.tsx
|
|
976
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
977
|
-
function InputLabel(props) {
|
|
978
|
-
const interpolateOpts = {
|
|
979
|
-
context: props.context,
|
|
980
|
-
env: props.config?.env
|
|
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)(
|
|
988
|
-
"div",
|
|
989
|
-
{
|
|
990
|
-
"data-slot": "field-content",
|
|
991
|
-
className: "flex w-full flex-1 flex-col gap-1.5 leading-snug",
|
|
992
|
-
children: [
|
|
993
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
994
|
-
Label,
|
|
995
|
-
{
|
|
996
|
-
field: props.field,
|
|
997
|
-
style: props.config?.style,
|
|
998
|
-
translations: props.translations,
|
|
999
|
-
children: translate(label, props.translations)
|
|
1000
|
-
}
|
|
1001
|
-
),
|
|
1002
|
-
props.orientation === HORIZONTAL && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1003
|
-
FormattedDescription,
|
|
1004
|
-
{
|
|
1005
|
-
text: translate(description, props.translations)
|
|
1006
|
-
}
|
|
1007
|
-
)
|
|
1008
|
-
]
|
|
1009
|
-
}
|
|
1010
|
-
);
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
// src/component/input-group.tsx
|
|
1014
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1015
|
-
function InputGroup(props) {
|
|
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)(
|
|
1018
|
-
InputLabel,
|
|
1019
|
-
{
|
|
1020
|
-
config: props.config,
|
|
1021
|
-
context: props.context,
|
|
1022
|
-
field: props.field,
|
|
1023
|
-
orientation: props.orientation,
|
|
1024
|
-
translations: props.translations
|
|
1025
|
-
}
|
|
1026
|
-
),
|
|
1027
|
-
props.children,
|
|
1028
|
-
props.orientation === VERTICAL && props.field.description && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1029
|
-
FormattedDescription,
|
|
1030
|
-
{
|
|
1031
|
-
text: translate(props.field.description, props.translations)
|
|
1032
|
-
}
|
|
1033
|
-
)
|
|
1034
|
-
] });
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
// src/lib/render-If-exists.ts
|
|
1038
|
-
function renderIfExists(value, render) {
|
|
1039
|
-
if (!value) {
|
|
1040
|
-
return null;
|
|
1041
|
-
}
|
|
1042
|
-
return render(value);
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
// src/server/component/input.tsx
|
|
1046
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1047
|
-
function Input(props) {
|
|
1048
|
-
const source = resolveSource(props.field, props.value);
|
|
1049
|
-
const { commonPropsWithOptions, defaultValue } = prepareInputProps(
|
|
1050
|
-
props.field,
|
|
1051
|
-
props.commonProps,
|
|
1052
|
-
source,
|
|
1053
|
-
props.value
|
|
1054
|
-
);
|
|
1055
|
-
const defaultProps = prepareDefaultValue(props.field, defaultValue);
|
|
1056
|
-
return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1057
|
-
InputGroup,
|
|
1058
|
-
{
|
|
1059
|
-
config: props.config,
|
|
1060
|
-
context: props.context,
|
|
1061
|
-
field: props.field,
|
|
1062
|
-
orientation: props.orientation,
|
|
1063
|
-
translations: props.translations,
|
|
1064
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1065
|
-
Component,
|
|
1066
|
-
{
|
|
1067
|
-
...props.ariaAttributes,
|
|
1068
|
-
...commonPropsWithOptions,
|
|
1069
|
-
...props.dataAttributes,
|
|
1070
|
-
...defaultProps
|
|
1071
|
-
}
|
|
1072
|
-
)
|
|
1073
|
-
}
|
|
1074
|
-
));
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
// src/component/field/field-error.tsx
|
|
1078
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1079
|
-
function FieldError(props) {
|
|
1080
|
-
if (!props.errors || props.errors.length === 0) {
|
|
1081
|
-
return null;
|
|
1082
|
-
}
|
|
1083
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1084
|
-
"ul",
|
|
1085
|
-
{
|
|
1086
|
-
className: "text-sm text-red-600 dark:text-red-500",
|
|
1087
|
-
id: props.name ? `${props.name}-error` : void 0,
|
|
1088
|
-
children: props.errors?.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { children: error }, props.name ? `${props.name}-error-${index}` : index))
|
|
1089
|
-
}
|
|
1090
|
-
);
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
// src/component/field/field-base.tsx
|
|
1094
|
-
var import_tailwind_merge2 = require("tailwind-merge");
|
|
1095
|
-
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1096
|
-
function FieldBase(props) {
|
|
1097
|
-
const errors = props.errors && props.errors.length > 0;
|
|
1098
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1099
|
-
"div",
|
|
1100
|
-
{
|
|
1101
|
-
"data-slot": "field",
|
|
1102
|
-
"data-clickable": props.isClickable ? "true" : "false",
|
|
1103
|
-
...errors && { [DATA_INVALID]: "true" },
|
|
1104
|
-
...props.disabled && { [DATA_READONLY]: "true" },
|
|
1105
|
-
"data-orientation": props.orientation,
|
|
1106
|
-
className: (0, import_tailwind_merge2.twMerge)(
|
|
1107
|
-
"group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500",
|
|
1108
|
-
"data-[clickable=true]:items-start",
|
|
1109
|
-
props.isCheckbox && (props.isReversed ? "flex-row-reverse!" : "flex-row!"),
|
|
1110
|
-
"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",
|
|
1111
|
-
props.className
|
|
1112
|
-
),
|
|
1113
|
-
children: props.children
|
|
1114
|
-
}
|
|
1115
|
-
);
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
// src/component/field/field-vertical.tsx
|
|
1119
|
-
var import_tailwind_merge3 = require("tailwind-merge");
|
|
1120
|
-
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1121
|
-
function FieldVertical(props) {
|
|
1122
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1123
|
-
FieldBase,
|
|
1124
|
-
{
|
|
1125
|
-
...props,
|
|
1126
|
-
orientation: VERTICAL,
|
|
1127
|
-
className: (0, import_tailwind_merge3.twMerge)(
|
|
1128
|
-
"gap-3 has-[>[data-slot=field-content]]:items-start",
|
|
1129
|
-
!props.isClickable && "[&>*]:w-full"
|
|
1130
|
-
),
|
|
1131
|
-
children: props.children
|
|
1132
|
-
}
|
|
1133
|
-
);
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
// src/component/field/field-horizontal.tsx
|
|
1137
|
-
var import_tailwind_merge4 = require("tailwind-merge");
|
|
1138
|
-
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1139
|
-
function FieldHorizontal(props) {
|
|
1140
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1141
|
-
FieldBase,
|
|
1142
|
-
{
|
|
1143
|
-
...props,
|
|
1144
|
-
orientation: HORIZONTAL,
|
|
1145
|
-
className: (0, import_tailwind_merge4.twMerge)(
|
|
1146
|
-
"gap-2 md:flex-row md:gap-4",
|
|
1147
|
-
"[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start",
|
|
1148
|
-
"[&_[role=checkbox]]:mt-[1.5px]",
|
|
1149
|
-
props.isClickable && "md:flex-col",
|
|
1150
|
-
!props.isClickable && [
|
|
1151
|
-
"md:justify-between",
|
|
1152
|
-
"[&>*:not([data-slot=field-content])]:w-full",
|
|
1153
|
-
"[&>*:not([data-slot=field-content])]:md:w-1/2",
|
|
1154
|
-
"[&>*:not([data-slot=field-content])]:xl:w-2/5"
|
|
1155
|
-
]
|
|
1156
|
-
),
|
|
1157
|
-
children: props.children
|
|
1158
|
-
}
|
|
1159
|
-
);
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
// src/component/field/field-group.tsx
|
|
1163
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1164
|
-
function FieldGroup(props) {
|
|
1165
|
-
const clickable = isClickable(props.field);
|
|
1166
|
-
const checkbox = isCheckbox(props.field);
|
|
1167
|
-
const reversed = buildReverse(props.field);
|
|
1168
|
-
if (props.orientation === VERTICAL) {
|
|
1169
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1170
|
-
FieldVertical,
|
|
1171
|
-
{
|
|
1172
|
-
disabled: props.disabled,
|
|
1173
|
-
errors: props.errors,
|
|
1174
|
-
isCheckbox: checkbox,
|
|
1175
|
-
isReversed: reversed,
|
|
1176
|
-
isClickable: clickable,
|
|
1177
|
-
children: props.children
|
|
1178
|
-
}
|
|
1179
|
-
);
|
|
1180
|
-
}
|
|
1181
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1182
|
-
FieldHorizontal,
|
|
1183
|
-
{
|
|
1184
|
-
disabled: props.disabled,
|
|
1185
|
-
errors: props.errors,
|
|
1186
|
-
isCheckbox: checkbox,
|
|
1187
|
-
isReversed: reversed,
|
|
1188
|
-
isClickable: clickable,
|
|
1189
|
-
children: props.children
|
|
1190
|
-
}
|
|
1191
|
-
);
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
// src/component/input/input-base.tsx
|
|
1195
|
-
function InputBase(props) {
|
|
1196
|
-
if (!props.field.type) {
|
|
1197
|
-
return null;
|
|
1198
|
-
}
|
|
1199
|
-
const commonProps = buildCommon(props.field, props.disabled);
|
|
1200
|
-
const dataAttributes = buildDataAttributes(props.field);
|
|
1201
|
-
const ariaAttributes = buildAriaAttributes(props.field, props.errors);
|
|
1202
|
-
const field = {
|
|
1203
|
-
...props.field,
|
|
1204
|
-
disabled: commonProps.disabled
|
|
1205
|
-
};
|
|
1206
|
-
return props.children({
|
|
1207
|
-
ariaAttributes,
|
|
1208
|
-
commonProps,
|
|
1209
|
-
dataAttributes,
|
|
1210
|
-
field,
|
|
1211
|
-
orientation: props.orientation
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
// src/component/field/field.tsx
|
|
1216
|
-
var import_tailwind_merge5 = require("tailwind-merge");
|
|
1217
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1218
|
-
function Field(props) {
|
|
1219
|
-
const cols2 = props.field.advanced?.cols;
|
|
1220
|
-
const errors = props.field.name ? props.errors?.[props.field.name] : void 0;
|
|
1221
|
-
const { orientation } = mergeStyle(props.style, {
|
|
1222
|
-
orientation: buildOrientation(props.field)
|
|
1223
|
-
});
|
|
1224
|
-
const disabled = buildDisabled(props.field, props.disabled);
|
|
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)(
|
|
1227
|
-
FieldGroup,
|
|
1228
|
-
{
|
|
1229
|
-
disabled,
|
|
1230
|
-
errors,
|
|
1231
|
-
field: props.field,
|
|
1232
|
-
orientation,
|
|
1233
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1234
|
-
InputBase,
|
|
1235
|
-
{
|
|
1236
|
-
disabled,
|
|
1237
|
-
errors,
|
|
1238
|
-
field: props.field,
|
|
1239
|
-
orientation,
|
|
1240
|
-
children: props.children
|
|
1241
|
-
}
|
|
1242
|
-
)
|
|
1243
|
-
}
|
|
1244
|
-
),
|
|
1245
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FieldError, { errors, name: props.field.name })
|
|
1246
|
-
] });
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
// src/component/field/field-list-item.tsx
|
|
1250
|
-
var import_tailwind_merge6 = require("tailwind-merge");
|
|
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");
|
|
1335
|
-
function Column(props) {
|
|
1336
|
-
const cols2 = getColumn(props.column?.advanced?.cols);
|
|
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 }) });
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
// src/component/slot/slot-base.tsx
|
|
1341
|
-
var import_react2 = require("react");
|
|
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");
|
|
1379
|
-
function SlotBase(props) {
|
|
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
|
-
) })
|
|
1396
|
-
] }, index));
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
// src/component/slot/slot-create.tsx
|
|
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 });
|
|
1403
|
-
return CreateSlot;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
// src/component/slot/slot.tsx
|
|
1407
|
-
var Slot = createSlot({ field: Field, list: ListSlot });
|
|
1408
|
-
|
|
1409
|
-
// src/server/component/form.tsx
|
|
1410
|
-
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1411
|
-
function Form2(props) {
|
|
1412
|
-
const translations = props.translations?.[props.lang ?? ""];
|
|
1413
|
-
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1414
|
-
Form,
|
|
1415
|
-
{
|
|
1416
|
-
config: props.config,
|
|
1417
|
-
control: props.children,
|
|
1418
|
-
definition: props.definition,
|
|
1419
|
-
readOnly: props.readOnly,
|
|
1420
|
-
sections: props.sections,
|
|
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)(
|
|
1422
|
-
Input,
|
|
1423
|
-
{
|
|
1424
|
-
...internal,
|
|
1425
|
-
config: props.config,
|
|
1426
|
-
context: props.context,
|
|
1427
|
-
translations,
|
|
1428
|
-
value: props.value
|
|
1429
|
-
}
|
|
1430
|
-
) })
|
|
1431
|
-
}
|
|
1432
|
-
);
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
// src/server/component/fallback.tsx
|
|
1436
|
-
var import_react3 = require("react");
|
|
1437
|
-
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1438
|
-
function Fallback(props) {
|
|
1439
|
-
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1440
|
-
import_react3.Suspense,
|
|
1441
|
-
{
|
|
1442
|
-
fallback: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Form2, { config: props.config, sections: props.sections, readOnly: true }),
|
|
1443
|
-
children: props.children
|
|
1444
|
-
}
|
|
1445
|
-
);
|
|
1446
|
-
}
|
|
1
|
+
"use strict";var Q=Object.defineProperty;var En=Object.getOwnPropertyDescriptor;var On=Object.getOwnPropertyNames;var wn=Object.prototype.hasOwnProperty;var Pn=(e,t)=>{for(var n in t)Q(e,n,{get:t[n],enumerable:!0})},Mn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of On(t))!wn.call(e,o)&&o!==n&&Q(e,o,{get:()=>t[o],enumerable:!(r=En(t,o))||r.enumerable});return e};var Dn=e=>Mn(Q({},"__esModule",{value:!0}),e);var fr={};Pn(fr,{Fallback:()=>Ln,Form:()=>J});module.exports=Dn(fr);var Re=require("react/jsx-runtime");function be(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return(0,Re.jsx)("div",{"data-slot":"field-control",className:"w-full",children:t})}var k=require("react");var j=require("react/jsx-runtime");function Te(e){return(0,j.jsx)("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:(0,j.jsx)("path",{fillRule:"evenodd",d:"M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})})}var _="input",he="input/email",Ae="input/number";var Fe="textarea",Se="radio",Ne="checkbox",ee="list";var Ce="select",Ie="select/month",Le="select/year";var O="column",te="fields",ke="label",ne="value",V="options",re="email",ve="number",Ee="password",Oe="tel",w="text",we="aria-errormessage",Pe="aria-invalid",Me="data-invalid",De="data-readonly",_e="aria",Ve="data",Be="min",Ge="max",$e="minLength",Ue="maxLength",C="$ref";var y="vertical",I="horizontal";var Ye="type";function a(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function x(e){return b(e)||typeof e=="number"||_n(e)}function b(e){return typeof e=="string"}function _n(e){return typeof e=="boolean"}function He(e,t=ne){if(e!=null){if(x(e))return e;if(a(e)){let n=Vn(e,t);if(x(n))return n}}}function Vn(e,t){let n=m(e,t);if(x(n))return n}function m(e,t){if(!t||!a(e))return null;let n=t.split(".").filter(o=>o!=="");if(n.length===0)return null;let r=e;for(let o of n)if(a(r)&&o in r)r=r[o];else return null;return r}function Xe(e,t={label:ke,value:ne}){return e.map(n=>{if(a(n)){let r=m(n,t.label),o=m(n,t.value);if(x(r)&&x(o))return{label:`${r}`,value:`${o}`}}return n})}function Ke(e=w){if(e){let t=e.lastIndexOf("/"),n=t===-1?e:e.slice(t+1);if(n&&n!==_)return n.trim().toLowerCase()}return w}var Bn=/\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g;function oe(e,t={}){if(b(e))return Gn(e,t);if(Array.isArray(e))return e.map(n=>oe(n,t));if(a(e)){let n={};for(let r in e)n[r]=oe(e[r],t);return n}return e}function le(e,t={}){return ie(e)?oe(e,t):e}function ie(e){return b(e)?/{([^}]{1,200})}/.test(e):Array.isArray(e)?e.some(t=>ie(t)):a(e)?Object.values(e).some(t=>ie(t)):!1}function Gn(e,t={}){return e.replace(/{([^}]{1,200})}/g,(n,r)=>{let o=r.includes(".")?m(t,r):t[r];return x(o)?String(o):n})}function We(e,t){if(!e||e.trim().length===0)return null;let n,r=0,o=!1,i=[];for(;(n=Bn.exec(e))!==null;){let[l,d,kn]=n,D=n.index;o=!0,D>r&&i.push(e.substring(r,D));let vn=t?t(D,kn,d):l;i.push(vn),r=D+l.length}return o?(r<e.length&&i.push(e.substring(r)),i):e}var qe=e=>u(Ie)(e),ze=e=>u(Le)(e),c=u(Ne),Ze=u(_),h=u(Se),p=u(Ce),Je=u(Fe),Qe=u(w,re,Ee,Oe),Cr=u(he,re),je=u(Ae,ve);function et(e){return h(e)||c(e)}function tt(e){return e.type===ee}function L(e){return e.type===O}function B(e){return e.type!==O&&e.type!==ee}function nt(e){return p(e)||h(e)}function ae(e){return e!=null&&e!==""}function u(...e){return t=>{let n=b(t.type)?t.type:void 0;return n?e.some(r=>n===r||n?.startsWith(`${r}/`)):!1}}function rt(e,t={}){if(p(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&a(n))return[n]}}function ot(e){return h(e)||c(e)?I:e.advanced?.orientation??y}function it(e){return c(e)?e.advanced?.reverse!==!1:!1}function lt(e,t){let n=e.readonly??!1;return t||n}function at(e){if(h(e)||p(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||a(t)&&!(C in t))return t}}var $n=/^\d+$/;function st(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function dt(e,t){return t>=e?Array.from({length:t-e+1},(n,r)=>{let o=e+r;return{value:o.toString(),label:o.toString()}}):[]}function se(){return new Date().getFullYear()}function de(e,t){if(typeof e=="number")return e;let n=t??se(),r=e.trim().toLowerCase();if(r.startsWith("current")){let o=r.match(/^current([+-])(\d+)$/);if(o){let[,i,l]=o,d=parseInt(l,10);if(!isNaN(d))return i==="+"?n+d:n-d}return n}return $n.test(r)?parseInt(r,10):n}var G=se();function Un(e){if(p(e))return Yn(e)}function Yn(e){if(qe(e))return st();if(ze(e)){let t=e.advanced?.length?.min??G,n=e.advanced?.length?.max??G+5;return dt(de(t,G),de(n,G))}}function ct(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return Ze(e)?{...n,...Hn(e)}:p(e)?{...n,...Xn(e)}:Je(e)?{...n,...Kn(e)}:n}function Hn(e){let t=Ke(e.type),n={...e,type:t};return{...ut(e),...Wn(n),...Qe(n)?ft(n):{},type:t}}function Xn(e){let t=Un(e);return t?{options:t}:{}}function Kn(e){return{...ut(e),...ft(e)}}function ut(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function Wn(e){return je(e)?qn(e):{}}function ft(e){return mt(e,{min:$e,max:Ue})}function qn(e){return mt(e,{min:Be,max:Ge})}function mt(e,t){let n={},r=e.advanced?.length;return r&&(r.min!==void 0&&(n[t.min]=r.min),r.max!==void 0&&(n[t.max]=r.max)),n}function pt(e,t){let n=at(e);return n||rt(e,t)}function zn(e,t){let n=a(t)&&e.name in t?t[e.name]:t;return He(n,e.advanced?.entity)}function Zn(e,t,n){return nt(e)&&Array.isArray(n)?{...t,[V]:n}:t}function Jn(e,t,n){if(e.required&&!ae(n)&&p(e)&&e.advanced?.preselected!==!1&&V in t){let r=t[V];if(Array.isArray(r)&&r.length===1)return r[0]}return n}function Qn(e,t){return p(e)&&Array.isArray(t)?Xe(t,e.advanced?.options):t}function gt(e,t,n,r){let o=zn(e,r),i=Array.isArray(n)?Qn(e,n):n,l=Zn(e,t,i),d=Jn(e,l,o);return{commonPropsWithOptions:l,defaultValue:d}}function yt(e,t){return c(e)?{defaultChecked:ae(t)}:{defaultValue:t}}var jn=/^#\/definition\//;function U(e=[],t){let n=$(e,t);return Array.isArray(n)?n.filter(tr).sort((r,o)=>xt(r)-xt(o)):[]}function $(e,t,n=new Map,r=new WeakSet){if(!er(t)||!e||typeof e!="object")return e;if(n.has(e))return n.get(e);if(r.has(e))return e;if(r.add(e),Array.isArray(e))return e.map(i=>$(i,t,n,r));if(C in e&&b(e[C])){let i=e[C].replace(jn,""),l=m(t,i);return l!==null?$(l,t,n,r):e}let o={};for(let[i,l]of Object.entries(e))o[i]=$(l,t,n,r);return r.delete(e),n.set(e,o),o}function bt(e){return Object.entries(e??{})}function xt(e){return e.order??Number.MAX_VALUE}function er(e){return e!==void 0&&a(e)&&Object.keys(e).length>0}function tr(e){return Ye in e?!0:Array.isArray(e[te])?e[te].length>0:!0}function Rt(e,t){let n={};for(let[r,o]of bt(t))n[`${e}-${r}`]=o;return n}function nr(e){return Rt(_e,e)}function rr(e){return Rt(Ve,e)}function Tt(e,t){let n=nr(e.advanced?.aria);return t&&t.length>0&&(n[Pe]="true",n[we]=`${e.name}-error`),n}function ht(e){return rr(e.advanced?.data)}var At={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Ft={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function St(e,t=2){return At[e&&e in At?e:t]}function Nt(e){if(e&&e in Ft)return Ft[e]}function or(e,t){let n=e.advanced?.length?.min??1;if(t){let r=m(t,e.name);if(Array.isArray(r))return Math.max(r.length,n)}return Math.max(n,0)}function Ct(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===O}function It(e,t){let n=or(e,t);return Array.from({length:n},(r,o)=>o)}function Lt(e){return e.label??e.name}function A(e,t){return e?t?t[e]??e:e:""}function Y(e,t){return{...e,...t}}var kt=require("react/jsx-runtime");function R(e){return We(e,(t,n,r)=>(0,kt.jsx)("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:r},`${n}-${t}`))}var f=require("react/jsx-runtime");function vt(e){let{fields:t=[]}=e.section,[n,r]=(0,k.useState)(!1),o=(0,k.useCallback)(()=>r(i=>!i),[]);return(0,f.jsxs)("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:[(0,f.jsx)("legend",{children:(0,f.jsxs)("button",{className:"flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",onClick:o,type:"button",children:[(0,f.jsx)(Te,{expanded:n}),(0,f.jsx)("span",{children:R(e.section.title)})]})}),(0,f.jsx)(k.Activity,{mode:n?"visible":"hidden",children:(0,f.jsxs)("div",{className:"mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600","data-slot":"field-set-content",children:[e.section.description&&(0,f.jsx)("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:R(e.section.description)}),e.group]})})]})}var F=require("react/jsx-runtime");function Et(e){return(0,F.jsxs)(F.Fragment,{children:[e.title&&(0,F.jsx)("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:R(e.title)}),e.description&&(0,F.jsx)("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:R(e.description)})]})}var X=require("react/jsx-runtime");function H(e){return(0,X.jsxs)("fieldset",{"data-slot":"field-set","data-empty":e.empty,className:"flex flex-col data-[empty=false]:gap-6",id:e.id,children:[(0,X.jsx)(Et,{description:e.description,title:e.title}),e.children]})}var Ot=require("react/jsx-runtime");function S(e){return(0,Ot.jsx)("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 K=require("react/jsx-runtime");function wt(e){let{fields:t=[]}=e.section,{compact:n}=Y(e.style,{compact:e.section.compact}),r=(0,K.jsx)(S,{compact:n,children:e.children});return!e.section.title&&!e.section.description?r:e.section.advanced?(0,K.jsx)(vt,{section:e.section,group:r}):(0,K.jsx)(H,{description:e.section.description,empty:t.length===0,id:e.section.id?.toString(),title:e.section.title,children:r})}var Vt=require("jotai");var v=require("jotai"),Pt=require("jotai-family"),ce=require("fast-equals");function ir(e,t){let{[t]:n,...r}=e;return r}function lr(e){return(0,Pt.atomFamily)(t=>(0,v.atom)(n=>n(e)[t]??void 0,(n,r,o)=>{let i=n(e);if(o!=null){let l=i[t];(!l||!(0,ce.deepEqual)(l,o))&&r(e,{...i,[t]:o})}else i[t]&&r(e,ir(i,t))}))}function ar(e){return(0,v.atom)(null,(t,n)=>{let r=t(e);r&&Object.keys(r).length>0&&n(e,{})})}function sr(e){return(0,v.atom)(null,(t,n,r)=>{let i={...t(e)},l=!1;for(let d of r)i[d]&&(delete i[d],l=!0);l&&n(e,i)})}function dr(e){return(0,v.atom)(null,(t,n,r)=>{let o=t(e);(0,ce.deepEqual)(o,r)||n(e,r)})}function Mt(e={}){let t=(0,v.atom)(e);return{atom:t,clearAll:ar(t),clear:sr(t),bulkReport:dr(t),report:lr(t)}}var Dt=Mt(),_t=Dt.atom,xo=Dt.report;function cr(e,t){return e.fields.every(n=>Bt(n,t))}function Bt(e,t){return t[e.name]?.hidden??e.hidden??!1}function ur(e,t){return L(e)?cr(e,t):Bt(e,t)}function Gt(e){let t=(0,Vt.useAtomValue)(_t);return e.container&&(t[e.container.name]?.hidden??e.container.hidden??!1)||e.fields.length===0||e.fields.every(r=>ur(r,t))?null:e.children}var ue=require("react/jsx-runtime");function $t(){return(0,ue.jsx)("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:(0,ue.jsx)("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}var g=require("react/jsx-runtime");function Ut(e){let t=U(e.sections,e.definition);return(0,g.jsx)("div",{className:"h-full w-full",children:(0,g.jsx)("form",{noValidate:e.noValidate,action:e.action,children:(0,g.jsxs)(S,{children:[t.map((n,r)=>(0,g.jsxs)(Gt,{fields:n.fields??[],children:[(0,g.jsx)(wt,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&(0,g.jsx)($t,{})]},r)),e.control&&(0,g.jsx)(be,{isPending:e.isPending,children:e.control})]})})})}var Ht=require("react/jsx-runtime");function Yt(e){return(0,Ht.jsx)("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}var Xt=require("react/jsx-runtime");function W(e){let t=R(e.text);return t?(0,Xt.jsx)(Yt,{children:t}):null}var Kt=require("tailwind-merge"),q=require("react/jsx-runtime");function Wt(e){let t=e.style?.showOptionalLabel??!0,n=h(e.field)||c(e.field);return(0,q.jsxs)("label",{"data-slot":"field-label","data-normal":n,className:(0,Kt.twMerge)("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&&(0,q.jsx)("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:A("(Optional)",e.translations)})]})}var P=require("react/jsx-runtime");function qt(e){let t={context:e.context,env:e.config?.env},n=le(e.field.label,t),r=le(e.field.description,t);return(0,P.jsxs)("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[(0,P.jsx)(Wt,{field:e.field,style:e.config?.style,translations:e.translations,children:A(n,e.translations)}),e.orientation===I&&(0,P.jsx)(W,{text:A(r,e.translations)})]})}var N=require("react/jsx-runtime");function zt(e){return(0,N.jsxs)(N.Fragment,{children:[e.field.name&&e.field.label&&(0,N.jsx)(qt,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations}),e.children,e.orientation===y&&e.field.description&&(0,N.jsx)(W,{text:A(e.field.description,e.translations)})]})}function Zt(e,t){return e?t(e):null}var fe=require("react/jsx-runtime");function Jt(e){let t=pt(e.field,e.value),{commonPropsWithOptions:n,defaultValue:r}=gt(e.field,e.commonProps,t,e.value),o=yt(e.field,r);return Zt(e.config.inputs[e.field.type],i=>(0,fe.jsx)(zt,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations,children:(0,fe.jsx)(i,{...e.ariaAttributes,...n,...e.dataAttributes,...o})}))}var me=require("react/jsx-runtime");function Qt(e){return!e.errors||e.errors.length===0?null:(0,me.jsx)("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)=>(0,me.jsx)("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}var jt=require("tailwind-merge"),en=require("react/jsx-runtime");function z(e){let t=e.errors&&e.errors.length>0;return(0,en.jsx)("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[Me]:"true"},...e.disabled&&{[De]:"true"},"data-orientation":e.orientation,className:(0,jt.twMerge)("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})}var tn=require("tailwind-merge"),rn=require("react/jsx-runtime");function nn(e){return(0,rn.jsx)(z,{...e,orientation:y,className:(0,tn.twMerge)("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}var on=require("tailwind-merge"),an=require("react/jsx-runtime");function ln(e){return(0,an.jsx)(z,{...e,orientation:I,className:(0,on.twMerge)("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})}var pe=require("react/jsx-runtime");function sn(e){let t=et(e.field),n=c(e.field),r=it(e.field);return e.orientation===y?(0,pe.jsx)(nn,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children}):(0,pe.jsx)(ln,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children})}function dn(e){if(!e.field.type)return null;let t=ct(e.field,e.disabled),n=ht(e.field),r=Tt(e.field,e.errors),o={...e.field,disabled:t.disabled};return e.children({ariaAttributes:r,commonProps:t,dataAttributes:n,field:o,orientation:e.orientation})}var cn=require("tailwind-merge"),E=require("react/jsx-runtime");function un(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{orientation:r}=Y(e.style,{orientation:ot(e.field)}),o=lt(e.field,e.disabled);return(0,E.jsxs)("div",{className:(0,cn.twMerge)("flex flex-col gap-3",Nt(t)),children:[(0,E.jsx)(sn,{disabled:o,errors:n,field:e.field,orientation:r,children:(0,E.jsx)(dn,{disabled:o,errors:n,field:e.field,orientation:r,children:e.children})}),(0,E.jsx)(Qt,{errors:n,name:e.field.name})]})}var fn=require("tailwind-merge");var s=require("react/jsx-runtime");function mn(e){function t(){e.canRemove&&e.onRemove&&e.onRemove(e.index)}let n=e.canRemove&&e.onRemove!=null&&(0,s.jsx)("button",{"aria-label":`Remove ${e.label} item ${e.index+1}`,className:(0,fn.twMerge)("rounded p-1 text-xl text-slate-400","transition-colors duration-150","hover:text-red-500","focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none","dark:text-slate-500 dark:hover:text-red-400"),onClick:t,type:"button",children:(0,s.jsx)("span",{"aria-hidden":"true",children:"\xD7"})});return e.isMultiField?(0,s.jsxs)("div",{className:"rounded-lg border border-slate-100 p-4 dark:border-slate-900",children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-sm font-medium text-slate-400 dark:text-slate-500",children:[e.label," ",e.index+1]}),n]}),(0,s.jsx)(S,{children:e.children})]}):(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(S,{children:e.children}),n&&(0,s.jsx)("div",{className:"shrink-0",children:n})]})}var gn=require("react/jsx-runtime");function pn(e){let t=Lt(e.field),n=Ct(e.field);return It(e.field,e.value).map(r=>(0,gn.jsx)(mn,{index:r,isMultiField:n,label:t,children:e.children(r)},r))}var xn=require("react/jsx-runtime");function yn(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0;return(0,xn.jsx)(H,{description:e.field.description,empty:t,id:e.field.name,title:e.field.label,children:e.children})}var ge=require("react/jsx-runtime");function bn({children:e,field:t,value:n}){return(0,ge.jsx)(yn,{field:t,children:(0,ge.jsx)(pn,{field:t,value:n,children:e})})}var Rn=require("tailwind-merge"),ye=require("react/jsx-runtime");function Tn(e){let t=St(e.column?.advanced?.cols);return(0,ye.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,ye.jsx)("div",{className:(0,Rn.twMerge)("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children})})}var Fn=require("react");var An=require("react/jsx-runtime");function hn(e){let t=Array.isArray(e.field.fields)?e.field.fields.map(n=>B(n)?{...n,name:`${e.field.name}.${e.index}.${n.name}`}:L(n)?{...n,fields:n.fields.map(r=>({...r,name:`${e.field.name}.${e.index}.${r.name}`}))}:n):[];return(0,An.jsx)(M,{children:e.children,components:e.components,disabled:e.disabled,fields:t,style:e.style,value:e.value})}var T=require("react/jsx-runtime");function M(e){let{field:t,list:n}=e.components;return U(e.fields).map((r,o)=>(0,T.jsxs)(Fn.Fragment,{children:[L(r)&&(0,T.jsx)(Tn,{column:r,children:(0,T.jsx)(M,{...e,fields:r.fields})}),B(r)&&(0,T.jsx)(t,{disabled:e.disabled,field:r,style:e.style,children:e.children}),tt(r)&&(0,T.jsx)(n,{field:r,value:e.value,children:i=>(0,T.jsx)(hn,{children:e.children,components:e.components,disabled:e.disabled,field:r,index:i,style:e.style,value:e.value})})]},o))}var Nn=require("react/jsx-runtime");function Sn(e){return n=>(0,Nn.jsx)(M,{...n,components:e})}var Cn=Sn({field:un,list:bn});var Z=require("react/jsx-runtime");function J(e){let t=e.translations?.[e.lang??""];return(0,Z.jsx)(Ut,{config:e.config,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,children:({disabled:n,fields:r})=>(0,Z.jsx)(Cn,{disabled:n,fields:r,style:e.config.style,children:o=>(0,Z.jsx)(Jt,{...o,config:e.config,context:e.context,translations:t,value:e.value})})})}var In=require("react");var xe=require("react/jsx-runtime");function Ln(e){return(0,xe.jsx)(In.Suspense,{fallback:(0,xe.jsx)(J,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}
|