react-luna-form 0.0.27 → 0.0.28
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/package.json +2 -2
package/dist/client/cjs/index.js
CHANGED
|
@@ -1,2741 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/client/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
Form: () => Form2
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(index_exports);
|
|
36
|
-
|
|
37
|
-
// src/component/control.tsx
|
|
38
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
-
function Control(props) {
|
|
40
|
-
const content = typeof props.children === "function" ? props.children({ isPending: props.isPending }) : props.children;
|
|
41
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "field-control", className: "w-full", children: content });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/component/field/field-set-advanced.tsx
|
|
45
|
-
var import_react = require("react");
|
|
46
|
-
|
|
47
|
-
// src/component/chevron-icon.tsx
|
|
48
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
49
|
-
function ChevronIcon(props) {
|
|
50
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
51
|
-
"svg",
|
|
52
|
-
{
|
|
53
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
-
viewBox: "0 0 20 20",
|
|
55
|
-
fill: "currentColor",
|
|
56
|
-
className: `size-4 transition-transform duration-200 ${props.expanded ? "rotate-90" : ""}`,
|
|
57
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
58
|
-
"path",
|
|
59
|
-
{
|
|
60
|
-
fillRule: "evenodd",
|
|
61
|
-
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",
|
|
62
|
-
clipRule: "evenodd"
|
|
63
|
-
}
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ../luna-core/src/util/constant.ts
|
|
70
|
-
var INPUT = "input";
|
|
71
|
-
var INPUT_EMAIL = "input/email";
|
|
72
|
-
var INPUT_NUMBER = "input/number";
|
|
73
|
-
var TEXTAREA = "textarea";
|
|
74
|
-
var RADIO = "radio";
|
|
75
|
-
var CHECKBOX = "checkbox";
|
|
76
|
-
var LIST = "list";
|
|
77
|
-
var SELECT = "select";
|
|
78
|
-
var SELECT_MONTH = "select/month";
|
|
79
|
-
var SELECT_YEAR = "select/year";
|
|
80
|
-
var COLUMN = "column";
|
|
81
|
-
var FIELDS = "fields";
|
|
82
|
-
var LABEL = "label";
|
|
83
|
-
var VALUE = "value";
|
|
84
|
-
var OPTIONS = "options";
|
|
85
|
-
var TYPE_EMAIL = "email";
|
|
86
|
-
var TYPE_NUMBER = "number";
|
|
87
|
-
var TYPE_PASSWORD = "password";
|
|
88
|
-
var TYPE_TEL = "tel";
|
|
89
|
-
var TYPE_TEXT = "text";
|
|
90
|
-
var ARIA_ERROR_MESSAGE = "aria-errormessage";
|
|
91
|
-
var ARIA_INVALID = "aria-invalid";
|
|
92
|
-
var DATA_INVALID = "data-invalid";
|
|
93
|
-
var DATA_READONLY = "data-readonly";
|
|
94
|
-
var PREFIX_ARIA = "aria";
|
|
95
|
-
var PREFIX_DATA = "data";
|
|
96
|
-
var MIN = "min";
|
|
97
|
-
var MAX = "max";
|
|
98
|
-
var MIN_LENGTH = "minLength";
|
|
99
|
-
var MAX_LENGTH = "maxLength";
|
|
100
|
-
var $REF = "$ref";
|
|
101
|
-
var SOURCE = "source";
|
|
102
|
-
var STATE = "state";
|
|
103
|
-
var COMMON_URL = "http://luna.internal";
|
|
104
|
-
var VERTICAL = "vertical";
|
|
105
|
-
var HORIZONTAL = "horizontal";
|
|
106
|
-
var TYPE = "type";
|
|
107
|
-
|
|
108
|
-
// ../luna-core/src/util/is-type.ts
|
|
109
|
-
function isObject(value) {
|
|
110
|
-
return value !== null && Object.prototype.toString.call(value) === "[object Object]";
|
|
111
|
-
}
|
|
112
|
-
function isEmpty(value) {
|
|
113
|
-
return value === null || value === void 0 || value === "";
|
|
114
|
-
}
|
|
115
|
-
function isValue(value) {
|
|
116
|
-
return isString(value) || typeof value === "number" || isBoolean(value);
|
|
117
|
-
}
|
|
118
|
-
function isString(value) {
|
|
119
|
-
return typeof value === "string";
|
|
120
|
-
}
|
|
121
|
-
function isDataSource(value) {
|
|
122
|
-
return isObject(value) && "url" in value;
|
|
123
|
-
}
|
|
124
|
-
function isBoolean(value) {
|
|
125
|
-
return typeof value === "boolean";
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ../luna-core/src/util/extract.ts
|
|
129
|
-
var REGEX_TYPE = /[^/]+$/;
|
|
130
|
-
var REGEX_NUMERIC = /^\d+$/;
|
|
131
|
-
function getEntity(selected, collection = [], entity = VALUE) {
|
|
132
|
-
if (Array.isArray(collection)) {
|
|
133
|
-
return collection.find((item) => {
|
|
134
|
-
const current = getCurrentValue(item, entity);
|
|
135
|
-
if (current !== void 0 && `${current}` === selected) {
|
|
136
|
-
return item;
|
|
137
|
-
}
|
|
138
|
-
}) ?? { value: selected };
|
|
139
|
-
}
|
|
140
|
-
return { value: selected };
|
|
141
|
-
}
|
|
142
|
-
function getCurrentValue(value, entity = VALUE) {
|
|
143
|
-
if (value !== null && value !== void 0) {
|
|
144
|
-
if (isValue(value)) {
|
|
145
|
-
return value;
|
|
146
|
-
}
|
|
147
|
-
if (isObject(value)) {
|
|
148
|
-
const result = getValue(value, entity);
|
|
149
|
-
if (isValue(result)) {
|
|
150
|
-
return result;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function getValue(value, namespace) {
|
|
156
|
-
const result = extract(value, namespace);
|
|
157
|
-
if (isValue(result)) {
|
|
158
|
-
return result;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function getArray(value, namespace) {
|
|
162
|
-
if (Array.isArray(value)) {
|
|
163
|
-
return value;
|
|
164
|
-
}
|
|
165
|
-
const result = extract(value, namespace);
|
|
166
|
-
if (Array.isArray(result)) {
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
function extract(value, namespace) {
|
|
172
|
-
if (!namespace || !isObject(value)) {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
const keys = namespace.split(".").filter((key) => key !== "");
|
|
176
|
-
if (keys.length === 0) {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
let result = value;
|
|
180
|
-
for (const key of keys) {
|
|
181
|
-
if (isObject(result) && key in result) {
|
|
182
|
-
const obj = result;
|
|
183
|
-
result = obj[key];
|
|
184
|
-
} else {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return result;
|
|
189
|
-
}
|
|
190
|
-
function toOptions(data, options = { label: LABEL, value: VALUE }) {
|
|
191
|
-
return data.map((item) => {
|
|
192
|
-
if (isObject(item)) {
|
|
193
|
-
const label = extract(item, options.label);
|
|
194
|
-
const value = extract(item, options.value);
|
|
195
|
-
if (isValue(label) && isValue(value)) {
|
|
196
|
-
return {
|
|
197
|
-
label: `${label}`,
|
|
198
|
-
value: `${value}`
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return item;
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
function getType(value = TYPE_TEXT) {
|
|
206
|
-
if (value) {
|
|
207
|
-
const result = value.match(REGEX_TYPE);
|
|
208
|
-
if (result) {
|
|
209
|
-
const [type] = result;
|
|
210
|
-
if (type !== INPUT) {
|
|
211
|
-
return type.trim().toLowerCase();
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return TYPE_TEXT;
|
|
216
|
-
}
|
|
217
|
-
function getFormData(formData) {
|
|
218
|
-
const data = {};
|
|
219
|
-
for (const key of formData.keys()) {
|
|
220
|
-
const values = formData.getAll(key);
|
|
221
|
-
data[key] = values.length > 1 ? values : values[0];
|
|
222
|
-
}
|
|
223
|
-
return data;
|
|
224
|
-
}
|
|
225
|
-
function unflatten(data) {
|
|
226
|
-
const result = {};
|
|
227
|
-
for (const key in data) {
|
|
228
|
-
const parts = key.split(".");
|
|
229
|
-
if (parts.length === 1) {
|
|
230
|
-
result[key] = data[key];
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
let current = result;
|
|
234
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
235
|
-
const part = parts[i];
|
|
236
|
-
const next = parts[i + 1];
|
|
237
|
-
const isNextIndex = REGEX_NUMERIC.test(next);
|
|
238
|
-
if (!(part in current)) {
|
|
239
|
-
current[part] = isNextIndex ? [] : {};
|
|
240
|
-
}
|
|
241
|
-
current = current[part];
|
|
242
|
-
}
|
|
243
|
-
const last = parts[parts.length - 1];
|
|
244
|
-
current[last] = data[key];
|
|
245
|
-
}
|
|
246
|
-
compactArrays(result);
|
|
247
|
-
return result;
|
|
248
|
-
}
|
|
249
|
-
function compactArrays(obj) {
|
|
250
|
-
for (const key in obj) {
|
|
251
|
-
const value = obj[key];
|
|
252
|
-
if (Array.isArray(value)) {
|
|
253
|
-
const compacted = value.filter((item) => item !== void 0);
|
|
254
|
-
compacted.forEach((item) => {
|
|
255
|
-
if (item !== null && typeof item === "object" && !Array.isArray(item)) {
|
|
256
|
-
compactArrays(item);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
obj[key] = compacted;
|
|
260
|
-
} else if (value !== null && typeof value === "object") {
|
|
261
|
-
compactArrays(value);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// ../luna-core/src/util/string.ts
|
|
267
|
-
var REGEX_MARKDOWN_LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
268
|
-
function interpolate(template, values = {}) {
|
|
269
|
-
if (isString(template)) {
|
|
270
|
-
return replacePlaceholders(template, values);
|
|
271
|
-
}
|
|
272
|
-
if (Array.isArray(template)) {
|
|
273
|
-
return template.map((item) => {
|
|
274
|
-
return interpolate(item, values);
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
if (isObject(template)) {
|
|
278
|
-
const results = {};
|
|
279
|
-
for (const key in template) {
|
|
280
|
-
results[key] = interpolate(template[key], values);
|
|
281
|
-
}
|
|
282
|
-
return results;
|
|
283
|
-
}
|
|
284
|
-
return template;
|
|
285
|
-
}
|
|
286
|
-
function interpolateIfNeeded(template, values = {}) {
|
|
287
|
-
return isInterpolated(template) ? interpolate(template, values) : template;
|
|
288
|
-
}
|
|
289
|
-
function isInterpolated(template) {
|
|
290
|
-
if (isString(template)) {
|
|
291
|
-
return /{([^}]+)}/.test(template);
|
|
292
|
-
}
|
|
293
|
-
if (Array.isArray(template)) {
|
|
294
|
-
return template.some((item) => isInterpolated(item));
|
|
295
|
-
}
|
|
296
|
-
if (isObject(template)) {
|
|
297
|
-
return Object.values(template).some((value) => isInterpolated(value));
|
|
298
|
-
}
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
function replacePlaceholders(template, values = {}) {
|
|
302
|
-
return template.replace(/{([^}]+)}/g, (match, key) => {
|
|
303
|
-
const value = key.includes(".") ? extract(values, key) : values[key];
|
|
304
|
-
if (isValue(value)) {
|
|
305
|
-
return String(value);
|
|
306
|
-
}
|
|
307
|
-
return match;
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
function formatMarkdown(text, callback) {
|
|
311
|
-
if (!text || text.trim().length === 0) {
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
let match;
|
|
315
|
-
let lastIndex = 0;
|
|
316
|
-
let hasMatch = false;
|
|
317
|
-
const parts = [];
|
|
318
|
-
while ((match = REGEX_MARKDOWN_LINK.exec(text)) !== null) {
|
|
319
|
-
const [fullMatch, linkText, url] = match;
|
|
320
|
-
const index = match.index;
|
|
321
|
-
hasMatch = true;
|
|
322
|
-
if (index > lastIndex) {
|
|
323
|
-
parts.push(text.substring(lastIndex, index));
|
|
324
|
-
}
|
|
325
|
-
const value = callback ? callback(index, url, linkText) : fullMatch;
|
|
326
|
-
parts.push(value);
|
|
327
|
-
lastIndex = index + fullMatch.length;
|
|
328
|
-
}
|
|
329
|
-
if (!hasMatch) {
|
|
330
|
-
return text;
|
|
331
|
-
}
|
|
332
|
-
if (lastIndex < text.length) {
|
|
333
|
-
parts.push(text.substring(lastIndex));
|
|
334
|
-
}
|
|
335
|
-
return parts;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// ../luna-core/src/util/logger.ts
|
|
339
|
-
var logger = {
|
|
340
|
-
error: (...args) => {
|
|
341
|
-
if (isConsoleAvailable() && !isProduction()) {
|
|
342
|
-
getConsole().error("[Luna Form]", ...args);
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
warn: (...args) => {
|
|
346
|
-
if (isConsoleAvailable() && !isProduction()) {
|
|
347
|
-
getConsole().warn("[Luna Form]", ...args);
|
|
348
|
-
}
|
|
349
|
-
},
|
|
350
|
-
info: (...args) => {
|
|
351
|
-
if (isConsoleAvailable() && !isProduction()) {
|
|
352
|
-
getConsole().info("[Luna Form]", ...args);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
var isConsoleAvailable = () => typeof getConsole() !== "undefined";
|
|
357
|
-
var isProduction = () => false;
|
|
358
|
-
var getConsole = () => globalThis.console;
|
|
359
|
-
|
|
360
|
-
// ../luna-core/src/handle/proxy-event.ts
|
|
361
|
-
function handleProxyEvent(events = [], callback) {
|
|
362
|
-
const values = [];
|
|
363
|
-
const sources = [];
|
|
364
|
-
const states = [];
|
|
365
|
-
for (const event of events) {
|
|
366
|
-
if (event.action === VALUE) {
|
|
367
|
-
values.push(event);
|
|
368
|
-
}
|
|
369
|
-
if (event.action === SOURCE) {
|
|
370
|
-
sources.push(event);
|
|
371
|
-
}
|
|
372
|
-
if (event.action === STATE) {
|
|
373
|
-
states.push(event);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
callback({ sources, states, values });
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// ../luna-core/src/handle/source-event.ts
|
|
380
|
-
function handleSourceEvent(selected = null, events = [], setSource) {
|
|
381
|
-
for (const event of events) {
|
|
382
|
-
const { target, source } = event;
|
|
383
|
-
if (!selected) {
|
|
384
|
-
setSource(target, void 0);
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
if (isDataSource(source)) {
|
|
388
|
-
const newUrl = interpolate(source.url, selected);
|
|
389
|
-
const newBody = source.body ? interpolate(source.body, selected) : source.body;
|
|
390
|
-
setSource(target, {
|
|
391
|
-
...source,
|
|
392
|
-
url: newUrl,
|
|
393
|
-
body: newBody
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// ../luna-core/src/util/operator.ts
|
|
400
|
-
var operators = {
|
|
401
|
-
eq,
|
|
402
|
-
gt,
|
|
403
|
-
gte,
|
|
404
|
-
in: includes,
|
|
405
|
-
lt,
|
|
406
|
-
lte,
|
|
407
|
-
neq,
|
|
408
|
-
nin
|
|
409
|
-
};
|
|
410
|
-
var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/;
|
|
411
|
-
var DMY_DATE_REGEX = /^(\d{2})[/-](\d{2})[/-](\d{4})(?: (\d{2}):(\d{2})(?::(\d{2}))?)?$/;
|
|
412
|
-
function isISODateString(value) {
|
|
413
|
-
return typeof value === "string" && ISO_DATE_REGEX.test(value);
|
|
414
|
-
}
|
|
415
|
-
function isDMYDateString(value) {
|
|
416
|
-
return typeof value === "string" && DMY_DATE_REGEX.test(value);
|
|
417
|
-
}
|
|
418
|
-
function parseDMYDate(value) {
|
|
419
|
-
const match = value.match(DMY_DATE_REGEX);
|
|
420
|
-
if (match) {
|
|
421
|
-
const [, day, month, year, hours, minutes, seconds] = match;
|
|
422
|
-
return new Date(
|
|
423
|
-
Number(year),
|
|
424
|
-
Number(month) - 1,
|
|
425
|
-
Number(day),
|
|
426
|
-
Number(hours ?? 0),
|
|
427
|
-
Number(minutes ?? 0),
|
|
428
|
-
Number(seconds ?? 0)
|
|
429
|
-
).getTime();
|
|
430
|
-
}
|
|
431
|
-
return NaN;
|
|
432
|
-
}
|
|
433
|
-
function toComparableNumber(value) {
|
|
434
|
-
if (isISODateString(value)) {
|
|
435
|
-
return new Date(value).getTime();
|
|
436
|
-
}
|
|
437
|
-
if (isDMYDateString(value)) {
|
|
438
|
-
return parseDMYDate(value);
|
|
439
|
-
}
|
|
440
|
-
return Number(value);
|
|
441
|
-
}
|
|
442
|
-
function eq(current, value) {
|
|
443
|
-
return current === value;
|
|
444
|
-
}
|
|
445
|
-
function neq(current, value) {
|
|
446
|
-
return current !== value;
|
|
447
|
-
}
|
|
448
|
-
function includes(current, value) {
|
|
449
|
-
return Array.isArray(value) && value.includes(String(current));
|
|
450
|
-
}
|
|
451
|
-
function nin(current, value) {
|
|
452
|
-
return Array.isArray(value) && !value.includes(String(current));
|
|
453
|
-
}
|
|
454
|
-
function gt(current, value) {
|
|
455
|
-
return toComparableNumber(current) > toComparableNumber(value);
|
|
456
|
-
}
|
|
457
|
-
function gte(current, value) {
|
|
458
|
-
return toComparableNumber(current) >= toComparableNumber(value);
|
|
459
|
-
}
|
|
460
|
-
function lt(current, value) {
|
|
461
|
-
return toComparableNumber(current) < toComparableNumber(value);
|
|
462
|
-
}
|
|
463
|
-
function lte(current, value) {
|
|
464
|
-
return toComparableNumber(current) <= toComparableNumber(value);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// ../luna-core/src/handle/state-event.ts
|
|
468
|
-
function handleStateEvent(selected = null, events = [], setState) {
|
|
469
|
-
for (const event of events) {
|
|
470
|
-
const { target, state, when } = event;
|
|
471
|
-
const targets = Array.isArray(target) ? target : [target];
|
|
472
|
-
if (!selected) {
|
|
473
|
-
setState(targets);
|
|
474
|
-
continue;
|
|
475
|
-
}
|
|
476
|
-
logger.info(`Selected value for state event: ${JSON.stringify(selected)}, evaluating condition: ${JSON.stringify(when)}`);
|
|
477
|
-
const matches = evaluateCondition(selected, when);
|
|
478
|
-
logger.info(`Condition evaluated to: ${matches}, setting state for targets: ${targets.join(", ")}`);
|
|
479
|
-
setState(targets, matches ? state : void 0);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
function evaluateCondition(selected, when) {
|
|
483
|
-
if (when === void 0) {
|
|
484
|
-
return true;
|
|
485
|
-
}
|
|
486
|
-
if (isString(when)) {
|
|
487
|
-
logger.info(`Evaluating string condition: ${when} against selected value: ${JSON.stringify(selected)} using VALUE field`);
|
|
488
|
-
logger.info(`Extracted value for comparison: ${JSON.stringify(getValue2(selected, VALUE))}`);
|
|
489
|
-
logger.info(`Comparison result: ${getValue2(selected, VALUE) === when}`);
|
|
490
|
-
return getValue2(selected, VALUE) === when;
|
|
491
|
-
}
|
|
492
|
-
if (isBoolean(when)) {
|
|
493
|
-
return Boolean(getValue2(selected, VALUE)) === when;
|
|
494
|
-
}
|
|
495
|
-
if (Array.isArray(when)) {
|
|
496
|
-
return when.includes(String(getValue2(selected, VALUE)));
|
|
497
|
-
}
|
|
498
|
-
return evaluateOperator(selected, when);
|
|
499
|
-
}
|
|
500
|
-
function evaluateOperator(selected = null, condition) {
|
|
501
|
-
const current = getValue2(selected, condition.field ?? VALUE);
|
|
502
|
-
const { operator = "eq", value } = condition;
|
|
503
|
-
const operation = operators[operator];
|
|
504
|
-
if (operation) {
|
|
505
|
-
return operation(current, value);
|
|
506
|
-
}
|
|
507
|
-
return false;
|
|
508
|
-
}
|
|
509
|
-
function getValue2(selected, field) {
|
|
510
|
-
if (isObject(selected)) {
|
|
511
|
-
return extract(selected, field);
|
|
512
|
-
}
|
|
513
|
-
return selected;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// ../luna-core/src/handle/value-event.ts
|
|
517
|
-
function handleValueEvent(selected = null, events = [], setValue) {
|
|
518
|
-
for (const event of events) {
|
|
519
|
-
for (const [target, value] of Object.entries(event.value)) {
|
|
520
|
-
setValue(target, selected ? interpolate(value, selected) : void 0);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
// ../luna-core/src/util/is-input.ts
|
|
526
|
-
var isSelectMonth = (field) => createTypeChecker(SELECT_MONTH)(field);
|
|
527
|
-
var isSelectYear = (field) => createTypeChecker(SELECT_YEAR)(field);
|
|
528
|
-
var isCheckbox = createTypeChecker(CHECKBOX);
|
|
529
|
-
var isInput = createTypeChecker(INPUT);
|
|
530
|
-
var isRadio = createTypeChecker(RADIO);
|
|
531
|
-
var isSelect = createTypeChecker(SELECT);
|
|
532
|
-
var isTextArea = createTypeChecker(TEXTAREA);
|
|
533
|
-
var isText = createTypeChecker(
|
|
534
|
-
TYPE_TEXT,
|
|
535
|
-
TYPE_EMAIL,
|
|
536
|
-
TYPE_PASSWORD,
|
|
537
|
-
TYPE_TEL
|
|
538
|
-
);
|
|
539
|
-
var isEmail = createTypeChecker(INPUT_EMAIL, TYPE_EMAIL);
|
|
540
|
-
var isNumber = createTypeChecker(INPUT_NUMBER, TYPE_NUMBER);
|
|
541
|
-
function isClickable(field) {
|
|
542
|
-
return isRadio(field) || isCheckbox(field);
|
|
543
|
-
}
|
|
544
|
-
function isList(slot) {
|
|
545
|
-
return slot.type === LIST;
|
|
546
|
-
}
|
|
547
|
-
function isColumn(slot) {
|
|
548
|
-
return slot.type === COLUMN;
|
|
549
|
-
}
|
|
550
|
-
function isField(slot) {
|
|
551
|
-
return slot.type !== COLUMN && slot.type !== LIST;
|
|
552
|
-
}
|
|
553
|
-
function isOptions(field) {
|
|
554
|
-
return isSelect(field) || isRadio(field);
|
|
555
|
-
}
|
|
556
|
-
function isTextable(field) {
|
|
557
|
-
return isInput(field) || isTextArea(field);
|
|
558
|
-
}
|
|
559
|
-
function isValidValue(value) {
|
|
560
|
-
return value !== void 0 && value !== null && value !== "";
|
|
561
|
-
}
|
|
562
|
-
function createTypeChecker(...types) {
|
|
563
|
-
return (field) => {
|
|
564
|
-
const inputType = isString(field.type) ? field.type : void 0;
|
|
565
|
-
if (!inputType) {
|
|
566
|
-
return false;
|
|
567
|
-
}
|
|
568
|
-
return types.some((type) => {
|
|
569
|
-
return inputType === type || inputType?.startsWith(`${type}/`);
|
|
570
|
-
});
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// ../luna-core/src/util/build.ts
|
|
575
|
-
function buildOptions(field, values = {}) {
|
|
576
|
-
if (isSelect(field) && field.disabled) {
|
|
577
|
-
const current = field.name ? values?.[field.name] : void 0;
|
|
578
|
-
if (current && isObject(current)) {
|
|
579
|
-
return [current];
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
function buildOrientation(field) {
|
|
584
|
-
if (isRadio(field) || isCheckbox(field)) {
|
|
585
|
-
return HORIZONTAL;
|
|
586
|
-
}
|
|
587
|
-
return field.advanced?.orientation ?? VERTICAL;
|
|
588
|
-
}
|
|
589
|
-
function buildReverse(field) {
|
|
590
|
-
if (!isCheckbox(field)) {
|
|
591
|
-
return false;
|
|
592
|
-
}
|
|
593
|
-
return field.advanced?.reverse !== false;
|
|
594
|
-
}
|
|
595
|
-
function buildDisabled(field, disabled) {
|
|
596
|
-
const readonly = field.readonly ?? false;
|
|
597
|
-
return disabled ? disabled : readonly;
|
|
598
|
-
}
|
|
599
|
-
function buildSource(field) {
|
|
600
|
-
if (isRadio(field) || isSelect(field) && !field.disabled) {
|
|
601
|
-
const source = field.source;
|
|
602
|
-
if (Array.isArray(source) || isObject(source) && !($REF in source)) {
|
|
603
|
-
return source;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// ../luna-core/src/util/date.ts
|
|
609
|
-
var REGEX_DIGITS = /^\d+$/;
|
|
610
|
-
function getMonth() {
|
|
611
|
-
return Array.from({ length: 12 }, (_, i) => ({
|
|
612
|
-
value: (i + 1).toString(),
|
|
613
|
-
label: new Date(0, i).toLocaleString("default", {
|
|
614
|
-
month: "long"
|
|
615
|
-
})
|
|
616
|
-
}));
|
|
617
|
-
}
|
|
618
|
-
function getYear(min2, max2) {
|
|
619
|
-
if (max2 >= min2) {
|
|
620
|
-
return Array.from({ length: max2 - min2 + 1 }, (_, i) => {
|
|
621
|
-
const year = min2 + i;
|
|
622
|
-
return {
|
|
623
|
-
value: year.toString(),
|
|
624
|
-
label: year.toString()
|
|
625
|
-
};
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
return [];
|
|
629
|
-
}
|
|
630
|
-
function getCurrentYear() {
|
|
631
|
-
return (/* @__PURE__ */ new Date()).getFullYear();
|
|
632
|
-
}
|
|
633
|
-
function getConvert(value, current) {
|
|
634
|
-
if (typeof value === "number") {
|
|
635
|
-
return value;
|
|
636
|
-
}
|
|
637
|
-
const now2 = current ?? getCurrentYear();
|
|
638
|
-
const trimmed = value.trim().toLowerCase();
|
|
639
|
-
if (trimmed.startsWith("current")) {
|
|
640
|
-
const match = trimmed.match(/^current([+-])(\d+)$/);
|
|
641
|
-
if (match) {
|
|
642
|
-
const [, operator, offsetStr] = match;
|
|
643
|
-
const offset = parseInt(offsetStr, 10);
|
|
644
|
-
if (!isNaN(offset)) {
|
|
645
|
-
return operator === "+" ? now2 + offset : now2 - offset;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
return now2;
|
|
649
|
-
}
|
|
650
|
-
if (REGEX_DIGITS.test(trimmed)) {
|
|
651
|
-
return parseInt(trimmed, 10);
|
|
652
|
-
}
|
|
653
|
-
return now2;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
// ../luna-core/src/helper/input.ts
|
|
657
|
-
var now = getCurrentYear();
|
|
658
|
-
function buildOptionSelect(field) {
|
|
659
|
-
if (isSelect(field)) {
|
|
660
|
-
return defineOption(field);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
function defineOption(select) {
|
|
664
|
-
if (isSelectMonth(select)) {
|
|
665
|
-
return getMonth();
|
|
666
|
-
}
|
|
667
|
-
if (isSelectYear(select)) {
|
|
668
|
-
const min2 = select.advanced?.length?.min ?? now;
|
|
669
|
-
const max2 = select.advanced?.length?.max ?? now + 5;
|
|
670
|
-
return getYear(getConvert(min2, now), getConvert(max2, now));
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
function buildCommon(field, disabled = false) {
|
|
674
|
-
const commonProps = {
|
|
675
|
-
disabled,
|
|
676
|
-
id: field.name,
|
|
677
|
-
name: field.name,
|
|
678
|
-
placeholder: field.placeholder,
|
|
679
|
-
required: field.required
|
|
680
|
-
};
|
|
681
|
-
if (isInput(field)) {
|
|
682
|
-
return {
|
|
683
|
-
...commonProps,
|
|
684
|
-
...defineInput(field)
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
if (isSelect(field)) {
|
|
688
|
-
return {
|
|
689
|
-
...commonProps,
|
|
690
|
-
...defineSelect(field)
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
if (isTextArea(field)) {
|
|
694
|
-
return {
|
|
695
|
-
...commonProps,
|
|
696
|
-
...defineTextArea(field)
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
return commonProps;
|
|
700
|
-
}
|
|
701
|
-
function defineInput(input) {
|
|
702
|
-
const type = getType(input.type);
|
|
703
|
-
const copy = { ...input, type };
|
|
704
|
-
return {
|
|
705
|
-
...defineAutoComplete(input),
|
|
706
|
-
...defineNumberLimits(copy),
|
|
707
|
-
...isText(copy) ? defineLength(copy) : {},
|
|
708
|
-
type
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
function defineSelect(field) {
|
|
712
|
-
const options = buildOptionSelect(field);
|
|
713
|
-
if (options) {
|
|
714
|
-
return { options };
|
|
715
|
-
}
|
|
716
|
-
return {};
|
|
717
|
-
}
|
|
718
|
-
function defineTextArea(field) {
|
|
719
|
-
return {
|
|
720
|
-
...defineAutoComplete(field),
|
|
721
|
-
...defineLength(field)
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
function defineAutoComplete(input) {
|
|
725
|
-
const autoComplete = input.advanced?.autocomplete;
|
|
726
|
-
if (autoComplete) {
|
|
727
|
-
return { autoComplete };
|
|
728
|
-
}
|
|
729
|
-
return {};
|
|
730
|
-
}
|
|
731
|
-
function defineNumberLimits(input) {
|
|
732
|
-
if (isNumber(input)) {
|
|
733
|
-
return defineMinMax(input);
|
|
734
|
-
}
|
|
735
|
-
return {};
|
|
736
|
-
}
|
|
737
|
-
function defineLength(input) {
|
|
738
|
-
return defineConstraints(input, { min: MIN_LENGTH, max: MAX_LENGTH });
|
|
739
|
-
}
|
|
740
|
-
function defineMinMax(input) {
|
|
741
|
-
return defineConstraints(input, { min: MIN, max: MAX });
|
|
742
|
-
}
|
|
743
|
-
function defineConstraints(input, keys) {
|
|
744
|
-
const result = {};
|
|
745
|
-
const length = input.advanced?.length;
|
|
746
|
-
if (length) {
|
|
747
|
-
if (length.min !== void 0) {
|
|
748
|
-
result[keys.min] = length.min;
|
|
749
|
-
}
|
|
750
|
-
if (length.max !== void 0) {
|
|
751
|
-
result[keys.max] = length.max;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
return result;
|
|
755
|
-
}
|
|
756
|
-
function resolveSource(field, value) {
|
|
757
|
-
const current = buildSource(field);
|
|
758
|
-
if (current) {
|
|
759
|
-
return current;
|
|
760
|
-
}
|
|
761
|
-
return buildOptions(field, value);
|
|
762
|
-
}
|
|
763
|
-
function getInputValue(field, value) {
|
|
764
|
-
const newValue = isObject(value) && field.name in value ? value[field.name] : value;
|
|
765
|
-
return getCurrentValue(newValue, field.advanced?.entity);
|
|
766
|
-
}
|
|
767
|
-
function mergeOptionsProps(field, commonProps, options) {
|
|
768
|
-
return isOptions(field) && Array.isArray(options) ? { ...commonProps, [OPTIONS]: options } : commonProps;
|
|
769
|
-
}
|
|
770
|
-
function getPreselectedValue(field, commonProps, value) {
|
|
771
|
-
if (field.required && !isValidValue(value)) {
|
|
772
|
-
if (isSelect(field)) {
|
|
773
|
-
if (field.advanced?.preselected !== false && OPTIONS in commonProps) {
|
|
774
|
-
const options = commonProps[OPTIONS];
|
|
775
|
-
if (Array.isArray(options) && options.length === 1) {
|
|
776
|
-
return options[0];
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
return value;
|
|
782
|
-
}
|
|
783
|
-
function getOptions(field, data) {
|
|
784
|
-
if (isSelect(field) && Array.isArray(data)) {
|
|
785
|
-
return toOptions(data, field.advanced?.options);
|
|
786
|
-
}
|
|
787
|
-
return data;
|
|
788
|
-
}
|
|
789
|
-
function prepareInputProps(field, commonProps, data, value) {
|
|
790
|
-
const currentValue = getInputValue(field, value);
|
|
791
|
-
const options = Array.isArray(data) ? getOptions(field, data) : data;
|
|
792
|
-
const commonPropsWithOptions = mergeOptionsProps(field, commonProps, options);
|
|
793
|
-
const defaultValue = getPreselectedValue(
|
|
794
|
-
field,
|
|
795
|
-
commonPropsWithOptions,
|
|
796
|
-
currentValue
|
|
797
|
-
);
|
|
798
|
-
return {
|
|
799
|
-
commonPropsWithOptions,
|
|
800
|
-
defaultValue
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
function prepareInputValue(field, value) {
|
|
804
|
-
if (isCheckbox(field)) {
|
|
805
|
-
return {
|
|
806
|
-
checked: isValidValue(value) ? value : false
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
return { value: value ?? "" };
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
// ../luna-core/src/util/prepare.ts
|
|
813
|
-
var REGEX_REF = /^#\/definition\//;
|
|
814
|
-
function prepare(base = [], definition) {
|
|
815
|
-
const resolved = resolveRefs(base, definition);
|
|
816
|
-
return Array.isArray(resolved) ? resolved.filter(filter).sort((a, b) => getOrder(a) - getOrder(b)) : [];
|
|
817
|
-
}
|
|
818
|
-
function resolveRefs(base, definition, cache = /* @__PURE__ */ new Map(), visited = /* @__PURE__ */ new WeakSet()) {
|
|
819
|
-
if (!isDefinition(definition) || !base || typeof base !== "object") {
|
|
820
|
-
return base;
|
|
821
|
-
}
|
|
822
|
-
if (cache.has(base)) {
|
|
823
|
-
return cache.get(base);
|
|
824
|
-
}
|
|
825
|
-
if (visited.has(base)) {
|
|
826
|
-
return base;
|
|
827
|
-
}
|
|
828
|
-
visited.add(base);
|
|
829
|
-
if (Array.isArray(base)) {
|
|
830
|
-
return base.map((item) => resolveRefs(item, definition, cache, visited));
|
|
831
|
-
}
|
|
832
|
-
if ($REF in base && isString(base[$REF])) {
|
|
833
|
-
const path = base[$REF].replace(REGEX_REF, "");
|
|
834
|
-
const resolved = extract(definition, path);
|
|
835
|
-
if (resolved !== null) {
|
|
836
|
-
return resolveRefs(resolved, definition, cache, visited);
|
|
837
|
-
}
|
|
838
|
-
return base;
|
|
839
|
-
}
|
|
840
|
-
const result = {};
|
|
841
|
-
for (const [key, value] of Object.entries(base)) {
|
|
842
|
-
result[key] = resolveRefs(value, definition, cache, visited);
|
|
843
|
-
}
|
|
844
|
-
visited.delete(base);
|
|
845
|
-
cache.set(base, result);
|
|
846
|
-
return result;
|
|
847
|
-
}
|
|
848
|
-
function entries(values) {
|
|
849
|
-
return Object.entries(values ?? {});
|
|
850
|
-
}
|
|
851
|
-
function getOrder(item) {
|
|
852
|
-
return item.order ?? Number.MAX_VALUE;
|
|
853
|
-
}
|
|
854
|
-
function isDefinition(definition) {
|
|
855
|
-
return definition !== void 0 && isObject(definition) && Object.keys(definition).length > 0;
|
|
856
|
-
}
|
|
857
|
-
function filter(base) {
|
|
858
|
-
if (TYPE in base) {
|
|
859
|
-
return true;
|
|
860
|
-
}
|
|
861
|
-
if (Array.isArray(base[FIELDS])) {
|
|
862
|
-
return base[FIELDS].length > 0;
|
|
863
|
-
}
|
|
864
|
-
return true;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
// ../luna-core/src/util/attributes.ts
|
|
868
|
-
function getPrefixedAttributes(prefix, record) {
|
|
869
|
-
const attrs = {};
|
|
870
|
-
for (const [key, value] of entries(record)) {
|
|
871
|
-
attrs[`${prefix}-${key}`] = value;
|
|
872
|
-
}
|
|
873
|
-
return attrs;
|
|
874
|
-
}
|
|
875
|
-
function getAriaAttributes(record) {
|
|
876
|
-
return getPrefixedAttributes(PREFIX_ARIA, record);
|
|
877
|
-
}
|
|
878
|
-
function getDataAttributes(record) {
|
|
879
|
-
return getPrefixedAttributes(PREFIX_DATA, record);
|
|
880
|
-
}
|
|
881
|
-
function buildAriaAttributes(field, errors) {
|
|
882
|
-
const ariaAttributes = getAriaAttributes(field.advanced?.aria);
|
|
883
|
-
if (errors && errors.length > 0) {
|
|
884
|
-
ariaAttributes[ARIA_INVALID] = "true";
|
|
885
|
-
ariaAttributes[ARIA_ERROR_MESSAGE] = `${field.name}-error`;
|
|
886
|
-
}
|
|
887
|
-
return ariaAttributes;
|
|
888
|
-
}
|
|
889
|
-
function buildDataAttributes(field) {
|
|
890
|
-
return getDataAttributes(field.advanced?.data);
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
// ../luna-core/src/util/column.ts
|
|
894
|
-
var cols = {
|
|
895
|
-
1: "md:grid-cols-1",
|
|
896
|
-
2: "md:grid-cols-2",
|
|
897
|
-
3: "md:grid-cols-3"
|
|
898
|
-
};
|
|
899
|
-
var span = {
|
|
900
|
-
1: "md:col-span-1",
|
|
901
|
-
2: "md:col-span-2",
|
|
902
|
-
3: "md:col-span-3"
|
|
903
|
-
};
|
|
904
|
-
function getColumn(value, defaultCols = 2) {
|
|
905
|
-
return cols[value && value in cols ? value : defaultCols];
|
|
906
|
-
}
|
|
907
|
-
function getSpan(value) {
|
|
908
|
-
if (value && value in span) {
|
|
909
|
-
return span[value];
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
// ../luna-core/src/util/list.ts
|
|
914
|
-
function getInitialCount(list, value) {
|
|
915
|
-
const min2 = list.advanced?.length?.min ?? 1;
|
|
916
|
-
if (value) {
|
|
917
|
-
const data = extract(value, list.name);
|
|
918
|
-
if (Array.isArray(data)) {
|
|
919
|
-
return Math.max(data.length, min2);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
return Math.max(min2, 0);
|
|
923
|
-
}
|
|
924
|
-
function isMultiFieldList(list) {
|
|
925
|
-
if (!Array.isArray(list.fields) || list.fields.length === 0) {
|
|
926
|
-
return false;
|
|
927
|
-
}
|
|
928
|
-
return list.fields.length > 1 || list.fields[0].type === COLUMN;
|
|
929
|
-
}
|
|
930
|
-
function getInitialList(list, value) {
|
|
931
|
-
const count = getInitialCount(list, value);
|
|
932
|
-
return Array.from({ length: count }, (_, index) => index);
|
|
933
|
-
}
|
|
934
|
-
function getLabel(list) {
|
|
935
|
-
return list.label ?? list.name;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
// ../luna-core/src/util/schema.ts
|
|
939
|
-
var import_zod = require("zod");
|
|
940
|
-
|
|
941
|
-
// ../luna-core/src/util/translate.ts
|
|
942
|
-
function translate(key, dictionary) {
|
|
943
|
-
if (!key) {
|
|
944
|
-
return "";
|
|
945
|
-
}
|
|
946
|
-
if (!dictionary) {
|
|
947
|
-
return key;
|
|
948
|
-
}
|
|
949
|
-
return dictionary[key] ?? key;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
// ../luna-core/src/util/schema.ts
|
|
953
|
-
var approach = [
|
|
954
|
-
[isNumber, getNumber],
|
|
955
|
-
[isEmail, getEmail],
|
|
956
|
-
[isSelectYear, getYearSchema],
|
|
957
|
-
[isSelectMonth, getMonthSchema],
|
|
958
|
-
[isCheckbox, getBoolean],
|
|
959
|
-
[isRadio, getRadio]
|
|
960
|
-
];
|
|
961
|
-
function buildSchema(schemas, fields = [], translations) {
|
|
962
|
-
const schema = import_zod.z.object(schemas);
|
|
963
|
-
if (fields.length === 0) {
|
|
964
|
-
return schema;
|
|
965
|
-
}
|
|
966
|
-
return applyCustomValidation(schema, fields, translations);
|
|
967
|
-
}
|
|
968
|
-
function flatten(error) {
|
|
969
|
-
const results = {};
|
|
970
|
-
const errors = import_zod.z.flattenError(error).fieldErrors;
|
|
971
|
-
for (const [key, value] of Object.entries(errors)) {
|
|
972
|
-
if (value !== void 0) {
|
|
973
|
-
results[key] = value;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
return results;
|
|
977
|
-
}
|
|
978
|
-
function getSchema(input, translations) {
|
|
979
|
-
for (const [check, getSchema2] of approach) {
|
|
980
|
-
if (check(input)) {
|
|
981
|
-
return getSchema2(input, translations);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
return getText(input, translations);
|
|
985
|
-
}
|
|
986
|
-
function getEmail(input, translations) {
|
|
987
|
-
const baseSchema = import_zod.z.string().trim();
|
|
988
|
-
if (input.required) {
|
|
989
|
-
const message = getRequiredMessage(input, translations);
|
|
990
|
-
const schema = baseSchema.min(1, message).pipe(applyEmail(input, translations));
|
|
991
|
-
return import_zod.z.preprocess((value) => isEmpty(value) ? "" : value, schema);
|
|
992
|
-
}
|
|
993
|
-
return baseSchema.pipe(applyEmail(input, translations)).or(import_zod.z.literal("")).nullable();
|
|
994
|
-
}
|
|
995
|
-
function getBoolean(input, translations) {
|
|
996
|
-
let schema = import_zod.z.coerce.boolean();
|
|
997
|
-
if (input.required) {
|
|
998
|
-
schema = schema.refine((value) => value === true, {
|
|
999
|
-
message: getRequiredMessage(input, translations)
|
|
1000
|
-
});
|
|
1001
|
-
return import_zod.z.preprocess((value) => value === null ? false : value, schema);
|
|
1002
|
-
}
|
|
1003
|
-
return schema.nullable();
|
|
1004
|
-
}
|
|
1005
|
-
function getRadio(input, translations) {
|
|
1006
|
-
let schema = import_zod.z.coerce.string();
|
|
1007
|
-
if (input.required) {
|
|
1008
|
-
schema = schema.min(1, getRequiredMessage(input, translations));
|
|
1009
|
-
return import_zod.z.preprocess((value) => isEmpty(value) ? "" : value, schema);
|
|
1010
|
-
}
|
|
1011
|
-
return schema.or(import_zod.z.literal("")).nullable();
|
|
1012
|
-
}
|
|
1013
|
-
function getText(input, translations) {
|
|
1014
|
-
let schema = import_zod.z.coerce.string().trim();
|
|
1015
|
-
schema = applyMinAndMax(schema, input, translations);
|
|
1016
|
-
if (input.required) {
|
|
1017
|
-
schema = applyRequired(schema, input, translations);
|
|
1018
|
-
return import_zod.z.preprocess((value) => isEmpty(value) ? "" : value, schema);
|
|
1019
|
-
}
|
|
1020
|
-
return schema.nullable();
|
|
1021
|
-
}
|
|
1022
|
-
function getNumber(input, translations) {
|
|
1023
|
-
let schema = import_zod.z.coerce.number().int();
|
|
1024
|
-
schema = applyMinAndMax(schema, input, translations);
|
|
1025
|
-
if (input.required) {
|
|
1026
|
-
schema = applyRequired(schema, input, translations);
|
|
1027
|
-
return import_zod.z.preprocess((value) => value === null ? void 0 : value, schema);
|
|
1028
|
-
}
|
|
1029
|
-
return schema.nullable();
|
|
1030
|
-
}
|
|
1031
|
-
function getYearSchema(input, translations) {
|
|
1032
|
-
if (input.required) {
|
|
1033
|
-
return import_zod.z.preprocess(
|
|
1034
|
-
normalize,
|
|
1035
|
-
import_zod.z.coerce.number({ message: getRequiredMessage(input, translations) }).int()
|
|
1036
|
-
);
|
|
1037
|
-
}
|
|
1038
|
-
return import_zod.z.coerce.number().int().nullable();
|
|
1039
|
-
}
|
|
1040
|
-
function getMonthSchema(input, translations) {
|
|
1041
|
-
const message = getRequiredMessage(input, translations);
|
|
1042
|
-
const schema = import_zod.z.coerce.number().int().min(1, message).max(12, message);
|
|
1043
|
-
return !input.required ? schema.nullable() : schema;
|
|
1044
|
-
}
|
|
1045
|
-
function normalize(value) {
|
|
1046
|
-
return value === null || value === "" ? void 0 : value;
|
|
1047
|
-
}
|
|
1048
|
-
function applyEmail(input, translations) {
|
|
1049
|
-
const message = input.validation?.email ? translate(input.validation?.email, translations) : void 0;
|
|
1050
|
-
return import_zod.z.email(message);
|
|
1051
|
-
}
|
|
1052
|
-
function applyMinAndMax(schema, input, translations) {
|
|
1053
|
-
schema = min(schema, input, translations);
|
|
1054
|
-
schema = max(schema, input, translations);
|
|
1055
|
-
return schema;
|
|
1056
|
-
}
|
|
1057
|
-
function applyRequired(schema, input, translations) {
|
|
1058
|
-
const min2 = input.advanced?.length?.min;
|
|
1059
|
-
if (min2 === void 0 || min2 < 1) {
|
|
1060
|
-
return schema.min(1, getRequiredMessage(input, translations));
|
|
1061
|
-
}
|
|
1062
|
-
return schema;
|
|
1063
|
-
}
|
|
1064
|
-
var min = (schema, input, translations) => applyConstraint(schema, input, MIN, translations);
|
|
1065
|
-
var max = (schema, input, translations) => applyConstraint(schema, input, MAX, translations);
|
|
1066
|
-
function applyConstraint(schema, input, method, translations) {
|
|
1067
|
-
const value = input.advanced?.length?.[method];
|
|
1068
|
-
if (value !== void 0) {
|
|
1069
|
-
const message = input.validation?.length?.[method] ? translate(input.validation?.length?.[method], translations) : void 0;
|
|
1070
|
-
return schema[method](value, message);
|
|
1071
|
-
}
|
|
1072
|
-
return schema;
|
|
1073
|
-
}
|
|
1074
|
-
function applyCustomValidation(schema, fields = [], translations) {
|
|
1075
|
-
const rules = getRules(fields);
|
|
1076
|
-
if (rules.length === 0) {
|
|
1077
|
-
return schema;
|
|
1078
|
-
}
|
|
1079
|
-
return schema.superRefine((data, context) => {
|
|
1080
|
-
for (const { name, rule } of rules) {
|
|
1081
|
-
if (!evaluate(data, name, rule)) {
|
|
1082
|
-
const message = translate(rule.message, translations);
|
|
1083
|
-
context.addIssue({
|
|
1084
|
-
code: "custom",
|
|
1085
|
-
message,
|
|
1086
|
-
path: [name]
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
function evaluate(data, name, rule) {
|
|
1093
|
-
const operator = rule.operator ?? "eq";
|
|
1094
|
-
const operation = operators[operator];
|
|
1095
|
-
if (operation) {
|
|
1096
|
-
return operation(data[name], data[rule.field]);
|
|
1097
|
-
}
|
|
1098
|
-
return false;
|
|
1099
|
-
}
|
|
1100
|
-
function getRules(fields) {
|
|
1101
|
-
const results = [];
|
|
1102
|
-
for (const field of fields) {
|
|
1103
|
-
const custom = field.validation?.custom;
|
|
1104
|
-
if (!custom) {
|
|
1105
|
-
continue;
|
|
1106
|
-
}
|
|
1107
|
-
const rules = Array.isArray(custom) ? custom : [custom];
|
|
1108
|
-
for (const rule of rules) {
|
|
1109
|
-
results.push({ name: field.name, rule });
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
return results;
|
|
1113
|
-
}
|
|
1114
|
-
function validateCustom(value, rules, getValue3, translations) {
|
|
1115
|
-
const errors = [];
|
|
1116
|
-
const collections = Array.isArray(rules) ? rules : [rules];
|
|
1117
|
-
for (const rule of collections) {
|
|
1118
|
-
const operator = rule.operator ?? "eq";
|
|
1119
|
-
const operation = operators[operator];
|
|
1120
|
-
if (operation && !operation(value, getValue3(rule.field))) {
|
|
1121
|
-
if (rule.message) {
|
|
1122
|
-
const message = translate(rule.message, translations);
|
|
1123
|
-
errors.push(message);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
return errors;
|
|
1128
|
-
}
|
|
1129
|
-
function getRequiredMessage(input, translations) {
|
|
1130
|
-
return input.validation?.required ? translate(input.validation?.required, translations) : void 0;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
// ../luna-core/src/util/url.ts
|
|
1134
|
-
function matchRemotePattern(urlStr, patterns) {
|
|
1135
|
-
if (!patterns || !isExternalUrl(urlStr)) {
|
|
1136
|
-
return true;
|
|
1137
|
-
}
|
|
1138
|
-
if (patterns.length === 0) {
|
|
1139
|
-
return false;
|
|
1140
|
-
}
|
|
1141
|
-
try {
|
|
1142
|
-
const url = new URL(urlStr);
|
|
1143
|
-
const protocol = url.protocol.replace(":", "");
|
|
1144
|
-
const hostname = url.hostname;
|
|
1145
|
-
const port = url.port || getPort(protocol);
|
|
1146
|
-
return patterns.some((pattern) => {
|
|
1147
|
-
if (pattern.protocol && pattern.protocol !== protocol) {
|
|
1148
|
-
return false;
|
|
1149
|
-
}
|
|
1150
|
-
if (pattern.hostname && pattern.hostname !== hostname) {
|
|
1151
|
-
return false;
|
|
1152
|
-
}
|
|
1153
|
-
if (pattern.port !== void 0 && String(pattern.port) !== port) {
|
|
1154
|
-
return false;
|
|
1155
|
-
}
|
|
1156
|
-
return true;
|
|
1157
|
-
});
|
|
1158
|
-
} catch {
|
|
1159
|
-
return false;
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
function getPort(protocol) {
|
|
1163
|
-
return protocol === "https" ? "443" : "80";
|
|
1164
|
-
}
|
|
1165
|
-
function isExternalUrl(url) {
|
|
1166
|
-
return /^(https?:)?\/\//.test(url);
|
|
1167
|
-
}
|
|
1168
|
-
function mergeUrl(baseUrl, targetUrl) {
|
|
1169
|
-
try {
|
|
1170
|
-
if (!baseUrl) {
|
|
1171
|
-
return targetUrl;
|
|
1172
|
-
}
|
|
1173
|
-
if (!targetUrl) {
|
|
1174
|
-
return baseUrl;
|
|
1175
|
-
}
|
|
1176
|
-
const url1 = new URL(baseUrl, COMMON_URL);
|
|
1177
|
-
const url2 = new URL(targetUrl, COMMON_URL);
|
|
1178
|
-
url2.searchParams.forEach((value, key) => {
|
|
1179
|
-
url1.searchParams.set(key, value);
|
|
1180
|
-
});
|
|
1181
|
-
const result = url1.toString();
|
|
1182
|
-
return baseUrl.startsWith("/") || !baseUrl.includes("://") ? result.replace(COMMON_URL, "") : result;
|
|
1183
|
-
} catch {
|
|
1184
|
-
return targetUrl || baseUrl;
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
// ../luna-core/src/util/source.ts
|
|
1189
|
-
function mergeSource(sources) {
|
|
1190
|
-
if (!Array.isArray(sources) || sources.length === 0) {
|
|
1191
|
-
return null;
|
|
1192
|
-
}
|
|
1193
|
-
return sources.reduce((previous, current) => {
|
|
1194
|
-
const url = mergeUrl(previous.url, current.url);
|
|
1195
|
-
const body = getBody(previous, current);
|
|
1196
|
-
const headers = getHeaders(previous, current);
|
|
1197
|
-
return {
|
|
1198
|
-
...previous,
|
|
1199
|
-
...current,
|
|
1200
|
-
url,
|
|
1201
|
-
body,
|
|
1202
|
-
headers
|
|
1203
|
-
};
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
function getBody(previous, current) {
|
|
1207
|
-
if (isObject(current.body) && isObject(previous?.body)) {
|
|
1208
|
-
return {
|
|
1209
|
-
...previous.body,
|
|
1210
|
-
...current.body
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
return current.body ?? previous?.body;
|
|
1214
|
-
}
|
|
1215
|
-
function getHeaders(previous, current) {
|
|
1216
|
-
if (isObject(current.headers) && isObject(previous?.headers)) {
|
|
1217
|
-
return {
|
|
1218
|
-
...previous.headers,
|
|
1219
|
-
...current.headers
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
return current.headers ?? previous?.headers;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
// ../luna-core/src/util/style.ts
|
|
1226
|
-
function mergeStyle(globalStyle, localStyle) {
|
|
1227
|
-
return { ...globalStyle, ...localStyle };
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
// src/lib/string.tsx
|
|
1231
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1232
|
-
function formatMarkdown2(text) {
|
|
1233
|
-
return formatMarkdown(
|
|
1234
|
-
text,
|
|
1235
|
-
(index, url, text2) => {
|
|
1236
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1237
|
-
"a",
|
|
1238
|
-
{
|
|
1239
|
-
className: "underline",
|
|
1240
|
-
href: url,
|
|
1241
|
-
rel: "noopener noreferrer",
|
|
1242
|
-
target: "_blank",
|
|
1243
|
-
children: text2
|
|
1244
|
-
},
|
|
1245
|
-
`${url}-${index}`
|
|
1246
|
-
);
|
|
1247
|
-
}
|
|
1248
|
-
);
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
// src/component/field/field-set-advanced.tsx
|
|
1252
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1253
|
-
function FieldSetAdvanced(props) {
|
|
1254
|
-
const { fields = [] } = props.section;
|
|
1255
|
-
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
|
1256
|
-
const handleOpen = (0, import_react.useCallback)(() => setIsOpen((previous) => !previous), []);
|
|
1257
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1258
|
-
"fieldset",
|
|
1259
|
-
{
|
|
1260
|
-
"data-slot": "field-set",
|
|
1261
|
-
"data-advanced": "true",
|
|
1262
|
-
"data-expanded": isOpen,
|
|
1263
|
-
"data-empty": fields.length === 0,
|
|
1264
|
-
className: "flex flex-col",
|
|
1265
|
-
id: props.section.id?.toString(),
|
|
1266
|
-
children: [
|
|
1267
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1268
|
-
"button",
|
|
1269
|
-
{
|
|
1270
|
-
className: "flex cursor-pointer items-center gap-2 text-base font-medium text-slate-600 dark:text-slate-400",
|
|
1271
|
-
onClick: handleOpen,
|
|
1272
|
-
type: "button",
|
|
1273
|
-
children: [
|
|
1274
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChevronIcon, { expanded: isOpen }),
|
|
1275
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: formatMarkdown2(props.section.title) })
|
|
1276
|
-
]
|
|
1277
|
-
}
|
|
1278
|
-
) }),
|
|
1279
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react.Activity, { mode: isOpen ? "visible" : "hidden", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1280
|
-
"div",
|
|
1281
|
-
{
|
|
1282
|
-
className: "mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-slate-300 pl-4 dark:border-slate-600",
|
|
1283
|
-
"data-slot": "field-set-content",
|
|
1284
|
-
children: [
|
|
1285
|
-
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) }),
|
|
1286
|
-
props.group
|
|
1287
|
-
]
|
|
1288
|
-
}
|
|
1289
|
-
) })
|
|
1290
|
-
]
|
|
1291
|
-
}
|
|
1292
|
-
);
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
// src/component/legend.tsx
|
|
1296
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1297
|
-
function Legend(props) {
|
|
1298
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1299
|
-
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) }),
|
|
1300
|
-
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) })
|
|
1301
|
-
] });
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
// src/component/field/field-set-base.tsx
|
|
1305
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1306
|
-
function FieldSetBase(props) {
|
|
1307
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1308
|
-
"fieldset",
|
|
1309
|
-
{
|
|
1310
|
-
"data-slot": "field-set",
|
|
1311
|
-
"data-empty": props.empty,
|
|
1312
|
-
className: "flex flex-col data-[empty=false]:gap-6",
|
|
1313
|
-
id: props.id,
|
|
1314
|
-
children: [
|
|
1315
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Legend, { description: props.description, title: props.title }),
|
|
1316
|
-
props.children
|
|
1317
|
-
]
|
|
1318
|
-
}
|
|
1319
|
-
);
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
// src/component/group.tsx
|
|
1323
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1324
|
-
function Group(props) {
|
|
1325
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1326
|
-
"div",
|
|
1327
|
-
{
|
|
1328
|
-
"data-slot": "field-group",
|
|
1329
|
-
"data-compact": props.compact,
|
|
1330
|
-
className: "flex w-full flex-col gap-8 data-[compact=true]:gap-3",
|
|
1331
|
-
children: props.children
|
|
1332
|
-
}
|
|
1333
|
-
);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
// src/component/field/field-set.tsx
|
|
1337
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1338
|
-
function FieldSet(props) {
|
|
1339
|
-
const { fields = [] } = props.section;
|
|
1340
|
-
const { compact } = mergeStyle(props.style, {
|
|
1341
|
-
compact: props.section.compact
|
|
1342
|
-
});
|
|
1343
|
-
const group = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Group, { compact, children: props.children });
|
|
1344
|
-
if (!props.section.title && !props.section.description) {
|
|
1345
|
-
return group;
|
|
1346
|
-
}
|
|
1347
|
-
if (props.section.advanced) {
|
|
1348
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FieldSetAdvanced, { section: props.section, group });
|
|
1349
|
-
}
|
|
1350
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1351
|
-
FieldSetBase,
|
|
1352
|
-
{
|
|
1353
|
-
description: props.section.description,
|
|
1354
|
-
empty: fields.length === 0,
|
|
1355
|
-
id: props.section.id?.toString(),
|
|
1356
|
-
title: props.section.title,
|
|
1357
|
-
children: group
|
|
1358
|
-
}
|
|
1359
|
-
);
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
// src/client/component/guard/visibility-guard.tsx
|
|
1363
|
-
var import_jotai2 = require("jotai");
|
|
1364
|
-
|
|
1365
|
-
// src/client/lib/store-helper.ts
|
|
1366
|
-
var import_jotai = require("jotai");
|
|
1367
|
-
var import_jotai_family = require("jotai-family");
|
|
1368
|
-
var import_fast_equals = require("fast-equals");
|
|
1369
|
-
function createRecordAtomFamily(baseAtom) {
|
|
1370
|
-
return (0, import_jotai_family.atomFamily)(
|
|
1371
|
-
(name) => (0, import_jotai.atom)(
|
|
1372
|
-
(get) => {
|
|
1373
|
-
return get(baseAtom)[name] ?? void 0;
|
|
1374
|
-
},
|
|
1375
|
-
(get, set, newValue) => {
|
|
1376
|
-
const current = get(baseAtom);
|
|
1377
|
-
if (newValue !== void 0 && newValue !== null) {
|
|
1378
|
-
const currentValue = current[name];
|
|
1379
|
-
if (!currentValue || !(0, import_fast_equals.deepEqual)(currentValue, newValue)) {
|
|
1380
|
-
set(baseAtom, { ...current, [name]: newValue });
|
|
1381
|
-
}
|
|
1382
|
-
} else if (current[name]) {
|
|
1383
|
-
const { [name]: _unused, ...rest } = current;
|
|
1384
|
-
set(baseAtom, rest);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
)
|
|
1388
|
-
);
|
|
1389
|
-
}
|
|
1390
|
-
function createClearAllAtom(baseAtom) {
|
|
1391
|
-
return (0, import_jotai.atom)(null, (get, set) => {
|
|
1392
|
-
const current = get(baseAtom);
|
|
1393
|
-
if (current && Object.keys(current).length > 0) {
|
|
1394
|
-
set(baseAtom, {});
|
|
1395
|
-
}
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
function createClearAtom(baseAtom) {
|
|
1399
|
-
return (0, import_jotai.atom)(null, (get, set, names) => {
|
|
1400
|
-
const current = get(baseAtom);
|
|
1401
|
-
const next = { ...current };
|
|
1402
|
-
let hasChanges = false;
|
|
1403
|
-
for (const name of names) {
|
|
1404
|
-
if (next[name]) {
|
|
1405
|
-
delete next[name];
|
|
1406
|
-
hasChanges = true;
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
if (hasChanges) {
|
|
1410
|
-
set(baseAtom, next);
|
|
1411
|
-
}
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
function createBulkReportAtom(baseAtom) {
|
|
1415
|
-
return (0, import_jotai.atom)(null, (get, set, newValue) => {
|
|
1416
|
-
const current = get(baseAtom);
|
|
1417
|
-
if (!(0, import_fast_equals.deepEqual)(current, newValue)) {
|
|
1418
|
-
set(baseAtom, newValue);
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
|
-
function createNestedRecordAtomFamily(baseAtom, options = {}) {
|
|
1423
|
-
const { merge: merge2, validateTarget } = options;
|
|
1424
|
-
return (0, import_jotai_family.atomFamily)(
|
|
1425
|
-
(contributorName) => (0, import_jotai.atom)(
|
|
1426
|
-
(get) => {
|
|
1427
|
-
const current = get(baseAtom)[contributorName];
|
|
1428
|
-
if (current && merge2) {
|
|
1429
|
-
return merge2(Object.values(current));
|
|
1430
|
-
}
|
|
1431
|
-
return void 0;
|
|
1432
|
-
},
|
|
1433
|
-
(get, set, target, value) => {
|
|
1434
|
-
if (validateTarget && !validateTarget(target)) {
|
|
1435
|
-
return;
|
|
1436
|
-
}
|
|
1437
|
-
const current = get(baseAtom);
|
|
1438
|
-
const targetContributions = { ...current[target] ?? {} };
|
|
1439
|
-
if (value !== void 0 && value !== null) {
|
|
1440
|
-
const currentContribution = targetContributions[contributorName];
|
|
1441
|
-
if (!currentContribution || !(0, import_fast_equals.deepEqual)(currentContribution, value)) {
|
|
1442
|
-
targetContributions[contributorName] = value;
|
|
1443
|
-
set(baseAtom, {
|
|
1444
|
-
...current,
|
|
1445
|
-
[target]: targetContributions
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
} else if (targetContributions[contributorName]) {
|
|
1449
|
-
delete targetContributions[contributorName];
|
|
1450
|
-
if (Object.keys(targetContributions).length === 0) {
|
|
1451
|
-
const { [target]: _unused, ...rest } = current;
|
|
1452
|
-
set(baseAtom, rest);
|
|
1453
|
-
} else {
|
|
1454
|
-
set(baseAtom, {
|
|
1455
|
-
...current,
|
|
1456
|
-
[target]: targetContributions
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
)
|
|
1462
|
-
);
|
|
1463
|
-
}
|
|
1464
|
-
function createNestedClearAtom(baseAtom) {
|
|
1465
|
-
return (0, import_jotai.atom)(null, (get, set, contributorNames) => {
|
|
1466
|
-
const current = get(baseAtom);
|
|
1467
|
-
const next = { ...current };
|
|
1468
|
-
let hasChanges = false;
|
|
1469
|
-
for (const name of contributorNames) {
|
|
1470
|
-
if (next[name]) {
|
|
1471
|
-
delete next[name];
|
|
1472
|
-
hasChanges = true;
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
for (const target in next) {
|
|
1476
|
-
const targetContributions = { ...next[target] };
|
|
1477
|
-
let targetChanged = false;
|
|
1478
|
-
for (const contributorName of contributorNames) {
|
|
1479
|
-
if (targetContributions[contributorName]) {
|
|
1480
|
-
delete targetContributions[contributorName];
|
|
1481
|
-
targetChanged = true;
|
|
1482
|
-
hasChanges = true;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
if (targetChanged) {
|
|
1486
|
-
if (Object.keys(targetContributions).length === 0) {
|
|
1487
|
-
delete next[target];
|
|
1488
|
-
} else {
|
|
1489
|
-
next[target] = targetContributions;
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
if (hasChanges) {
|
|
1494
|
-
set(baseAtom, next);
|
|
1495
|
-
}
|
|
1496
|
-
});
|
|
1497
|
-
}
|
|
1498
|
-
function createAtomStore(initialValue = {}) {
|
|
1499
|
-
const baseAtom = (0, import_jotai.atom)(initialValue);
|
|
1500
|
-
return {
|
|
1501
|
-
atom: baseAtom,
|
|
1502
|
-
clearAll: createClearAllAtom(baseAtom),
|
|
1503
|
-
clear: createClearAtom(baseAtom),
|
|
1504
|
-
bulkReport: createBulkReportAtom(baseAtom),
|
|
1505
|
-
report: createRecordAtomFamily(baseAtom)
|
|
1506
|
-
};
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
// src/client/lib/state-store.ts
|
|
1510
|
-
var store = createAtomStore();
|
|
1511
|
-
var fieldStateAtom = store.atom;
|
|
1512
|
-
var reportFieldStateAtom = store.report;
|
|
1513
|
-
|
|
1514
|
-
// src/client/component/guard/visibility-guard.tsx
|
|
1515
|
-
function isColumnHidden(column, states) {
|
|
1516
|
-
return column.fields.every((field) => isFieldHidden(field, states));
|
|
1517
|
-
}
|
|
1518
|
-
function isFieldHidden(field, states) {
|
|
1519
|
-
return states[field.name]?.hidden ?? field.hidden ?? false;
|
|
1520
|
-
}
|
|
1521
|
-
function isEntryHidden(entry, states) {
|
|
1522
|
-
return isColumn(entry) ? isColumnHidden(entry, states) : isFieldHidden(entry, states);
|
|
1523
|
-
}
|
|
1524
|
-
function VisibilityGuard(props) {
|
|
1525
|
-
const states = (0, import_jotai2.useAtomValue)(fieldStateAtom);
|
|
1526
|
-
if (props.container) {
|
|
1527
|
-
const hidden = states[props.container.name]?.hidden ?? props.container.hidden ?? false;
|
|
1528
|
-
if (hidden) {
|
|
1529
|
-
return null;
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
if (props.fields.length === 0) {
|
|
1533
|
-
return null;
|
|
1534
|
-
}
|
|
1535
|
-
const allHidden = props.fields.every((entry) => isEntryHidden(entry, states));
|
|
1536
|
-
if (allHidden) {
|
|
1537
|
-
return null;
|
|
1538
|
-
}
|
|
1539
|
-
return props.children;
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
// src/component/separator.tsx
|
|
1543
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1544
|
-
function Separator() {
|
|
1545
|
-
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" }) });
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
// src/component/form.tsx
|
|
1549
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1550
|
-
function Form(props) {
|
|
1551
|
-
const sections = prepare(props.sections, props.definition);
|
|
1552
|
-
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: [
|
|
1553
|
-
sections.map((section, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(VisibilityGuard, { fields: section.fields ?? [], children: [
|
|
1554
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FieldSet, { section, style: props.config.style, children: props.children({
|
|
1555
|
-
disabled: props.readOnly,
|
|
1556
|
-
fields: section.fields
|
|
1557
|
-
}) }),
|
|
1558
|
-
section.separator && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Separator, {})
|
|
1559
|
-
] }, index)),
|
|
1560
|
-
props.control && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Control, { isPending: props.isPending, children: props.control })
|
|
1561
|
-
] }) }) });
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
|
-
// src/component/description.tsx
|
|
1565
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1566
|
-
function Description(props) {
|
|
1567
|
-
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 });
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
// src/component/formatted-description.tsx
|
|
1571
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1572
|
-
function FormattedDescription(props) {
|
|
1573
|
-
const content = formatMarkdown2(props.text);
|
|
1574
|
-
if (content) {
|
|
1575
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Description, { children: content });
|
|
1576
|
-
}
|
|
1577
|
-
return null;
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
// src/component/label.tsx
|
|
1581
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
1582
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1583
|
-
function Label(props) {
|
|
1584
|
-
const showOptionalLabel = props.style?.showOptionalLabel ?? true;
|
|
1585
|
-
const normal = isRadio(props.field) || isCheckbox(props.field);
|
|
1586
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1587
|
-
"label",
|
|
1588
|
-
{
|
|
1589
|
-
"data-slot": "field-label",
|
|
1590
|
-
"data-normal": normal,
|
|
1591
|
-
className: (0, import_tailwind_merge.twMerge)(
|
|
1592
|
-
"flex w-fit items-center gap-2 text-sm leading-snug font-medium select-none",
|
|
1593
|
-
"data-[normal=true]:font-normal",
|
|
1594
|
-
"group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"
|
|
1595
|
-
),
|
|
1596
|
-
htmlFor: props.field.name,
|
|
1597
|
-
children: [
|
|
1598
|
-
props.children,
|
|
1599
|
-
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) })
|
|
1600
|
-
]
|
|
1601
|
-
}
|
|
1602
|
-
);
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
// src/component/input-label.tsx
|
|
1606
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1607
|
-
function InputLabel(props) {
|
|
1608
|
-
const interpolateOpts = {
|
|
1609
|
-
context: props.context,
|
|
1610
|
-
env: props.config?.env
|
|
1611
|
-
};
|
|
1612
|
-
const label = interpolateIfNeeded(props.field.label, interpolateOpts);
|
|
1613
|
-
const description = interpolateIfNeeded(
|
|
1614
|
-
props.field.description,
|
|
1615
|
-
interpolateOpts
|
|
1616
|
-
);
|
|
1617
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1618
|
-
"div",
|
|
1619
|
-
{
|
|
1620
|
-
"data-slot": "field-content",
|
|
1621
|
-
className: "flex w-full flex-1 flex-col gap-1.5 leading-snug",
|
|
1622
|
-
children: [
|
|
1623
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1624
|
-
Label,
|
|
1625
|
-
{
|
|
1626
|
-
field: props.field,
|
|
1627
|
-
style: props.config?.style,
|
|
1628
|
-
translations: props.translations,
|
|
1629
|
-
children: translate(label, props.translations)
|
|
1630
|
-
}
|
|
1631
|
-
),
|
|
1632
|
-
props.orientation === HORIZONTAL && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1633
|
-
FormattedDescription,
|
|
1634
|
-
{
|
|
1635
|
-
text: translate(description, props.translations)
|
|
1636
|
-
}
|
|
1637
|
-
)
|
|
1638
|
-
]
|
|
1639
|
-
}
|
|
1640
|
-
);
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
// src/component/input-group.tsx
|
|
1644
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1645
|
-
function InputGroup(props) {
|
|
1646
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
1647
|
-
props.field.name && props.field.label && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1648
|
-
InputLabel,
|
|
1649
|
-
{
|
|
1650
|
-
config: props.config,
|
|
1651
|
-
context: props.context,
|
|
1652
|
-
field: props.field,
|
|
1653
|
-
orientation: props.orientation,
|
|
1654
|
-
translations: props.translations
|
|
1655
|
-
}
|
|
1656
|
-
),
|
|
1657
|
-
props.children,
|
|
1658
|
-
props.orientation === VERTICAL && props.field.description && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1659
|
-
FormattedDescription,
|
|
1660
|
-
{
|
|
1661
|
-
text: translate(props.field.description, props.translations)
|
|
1662
|
-
}
|
|
1663
|
-
)
|
|
1664
|
-
] });
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
|
-
// src/lib/render-If-exists.ts
|
|
1668
|
-
function renderIfExists(value, render) {
|
|
1669
|
-
if (!value) {
|
|
1670
|
-
return null;
|
|
1671
|
-
}
|
|
1672
|
-
return render(value);
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
// src/client/lib/error-store.ts
|
|
1676
|
-
var store2 = createAtomStore();
|
|
1677
|
-
var clearInputErrorAtom = store2.clear;
|
|
1678
|
-
var reportErrorAtom = store2.bulkReport;
|
|
1679
|
-
var reportInputErrorAtom = store2.report;
|
|
1680
|
-
|
|
1681
|
-
// src/client/component/input.tsx
|
|
1682
|
-
var import_react5 = require("react");
|
|
1683
|
-
|
|
1684
|
-
// src/client/lib/source-store.ts
|
|
1685
|
-
var import_jotai3 = require("jotai");
|
|
1686
|
-
var merge = (values) => {
|
|
1687
|
-
const merged = mergeSource(values);
|
|
1688
|
-
if (merged) {
|
|
1689
|
-
return merged;
|
|
1690
|
-
}
|
|
1691
|
-
return void 0;
|
|
1692
|
-
};
|
|
1693
|
-
var validate = (target) => target.trim() !== "";
|
|
1694
|
-
var sourceAtom = (0, import_jotai3.atom)({});
|
|
1695
|
-
var reportSourceAtom = createNestedRecordAtomFamily(
|
|
1696
|
-
sourceAtom,
|
|
1697
|
-
{
|
|
1698
|
-
merge,
|
|
1699
|
-
validateTarget: validate
|
|
1700
|
-
}
|
|
1701
|
-
);
|
|
1702
|
-
var clearInputSourceAtom = createNestedClearAtom(sourceAtom);
|
|
1703
|
-
|
|
1704
|
-
// src/client/hook/use-data-source.ts
|
|
1705
|
-
var import_jotai4 = require("jotai");
|
|
1706
|
-
|
|
1707
|
-
// src/client/hook/use-fetch.ts
|
|
1708
|
-
var import_swr = __toESM(require("swr"), 1);
|
|
1709
|
-
function useFetch(dataSource = null, config, disabled = false) {
|
|
1710
|
-
const { data, error } = (0, import_swr.default)(
|
|
1711
|
-
buildSource2(dataSource, config, disabled),
|
|
1712
|
-
config.fetcher.provider
|
|
1713
|
-
);
|
|
1714
|
-
if (error) {
|
|
1715
|
-
logger.error("Error fetching data source:", error);
|
|
1716
|
-
}
|
|
1717
|
-
if (dataSource) {
|
|
1718
|
-
if (Array.isArray(dataSource)) {
|
|
1719
|
-
return dataSource;
|
|
1720
|
-
}
|
|
1721
|
-
if (data) {
|
|
1722
|
-
return getArray(data, dataSource.namespace);
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
return null;
|
|
1726
|
-
}
|
|
1727
|
-
function buildSource2(dataSource = null, config, disabled = false) {
|
|
1728
|
-
if (dataSource && !Array.isArray(dataSource) && !disabled) {
|
|
1729
|
-
if (dataSource.url) {
|
|
1730
|
-
const interpolated = isInterpolated(dataSource.url);
|
|
1731
|
-
if (!interpolated) {
|
|
1732
|
-
const allowed = matchRemotePattern(
|
|
1733
|
-
dataSource.url,
|
|
1734
|
-
config.fetcher.remotePatterns
|
|
1735
|
-
);
|
|
1736
|
-
if (allowed) {
|
|
1737
|
-
return dataSource;
|
|
1738
|
-
}
|
|
1739
|
-
logger.warn(
|
|
1740
|
-
`URL blocked by remotePatterns: ${dataSource.url}. Check your luna.config.ts`
|
|
1741
|
-
);
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
return null;
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
// src/client/hook/use-data-source.ts
|
|
1749
|
-
function useDataSource(field, config, value) {
|
|
1750
|
-
const dataSource = resolveSource(field, value);
|
|
1751
|
-
const [source, setSource] = (0, import_jotai4.useAtom)(reportSourceAtom(field.name));
|
|
1752
|
-
const currentSource = source ?? dataSource;
|
|
1753
|
-
const data = useFetch(currentSource, config, field.disabled);
|
|
1754
|
-
return [data, setSource];
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
// src/client/hook/use-input.ts
|
|
1758
|
-
var import_react2 = require("react");
|
|
1759
|
-
function useInput(field, onMount, onUnmount, translations) {
|
|
1760
|
-
const { name } = field;
|
|
1761
|
-
const schema = (0, import_react2.useMemo)(
|
|
1762
|
-
() => getSchema(field, translations),
|
|
1763
|
-
[field, translations]
|
|
1764
|
-
);
|
|
1765
|
-
const onMountHandler = (0, import_react2.useEffectEvent)((name2) => {
|
|
1766
|
-
if (name2) {
|
|
1767
|
-
onMount(name2, schema, field);
|
|
1768
|
-
}
|
|
1769
|
-
});
|
|
1770
|
-
const onUnmountHandler = (0, import_react2.useEffectEvent)((name2) => {
|
|
1771
|
-
if (name2) {
|
|
1772
|
-
onUnmount(name2);
|
|
1773
|
-
}
|
|
1774
|
-
});
|
|
1775
|
-
(0, import_react2.useEffect)(() => {
|
|
1776
|
-
onMountHandler(name);
|
|
1777
|
-
return () => {
|
|
1778
|
-
onUnmountHandler(name);
|
|
1779
|
-
};
|
|
1780
|
-
}, [name]);
|
|
1781
|
-
return schema;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
// src/client/component/input.tsx
|
|
1785
|
-
var import_jotai6 = require("jotai");
|
|
1786
|
-
|
|
1787
|
-
// src/client/hook/use-timeout.ts
|
|
1788
|
-
var import_react3 = require("react");
|
|
1789
|
-
function useTimeout() {
|
|
1790
|
-
const timeoutRef = (0, import_react3.useRef)(null);
|
|
1791
|
-
(0, import_react3.useEffect)(() => {
|
|
1792
|
-
return () => {
|
|
1793
|
-
if (timeoutRef.current) {
|
|
1794
|
-
clearTimeout(timeoutRef.current);
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
|
-
}, []);
|
|
1798
|
-
const setTimeoutRef = (0, import_react3.useCallback)((callback, delay) => {
|
|
1799
|
-
if (timeoutRef.current) {
|
|
1800
|
-
clearTimeout(timeoutRef.current);
|
|
1801
|
-
timeoutRef.current = null;
|
|
1802
|
-
}
|
|
1803
|
-
timeoutRef.current = setTimeout(callback, delay);
|
|
1804
|
-
}, []);
|
|
1805
|
-
return setTimeoutRef;
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
// src/client/lib/value-store.ts
|
|
1809
|
-
var store3 = createAtomStore();
|
|
1810
|
-
var valueAtom = store3.atom;
|
|
1811
|
-
var clearAllValueAtom = store3.clearAll;
|
|
1812
|
-
var clearInputValueAtom = store3.clear;
|
|
1813
|
-
var reportValueAtom = store3.report;
|
|
1814
|
-
|
|
1815
|
-
// src/client/hook/use-value.ts
|
|
1816
|
-
var import_jotai5 = require("jotai");
|
|
1817
|
-
var import_react4 = require("react");
|
|
1818
|
-
function useValue(field, currentValue) {
|
|
1819
|
-
const { name } = field;
|
|
1820
|
-
const skipNextOnChangeRef = (0, import_react4.useRef)(false);
|
|
1821
|
-
const [value, setValue] = (0, import_jotai5.useAtom)(reportValueAtom(name));
|
|
1822
|
-
const onCurrentValueChange = (0, import_react4.useEffectEvent)(
|
|
1823
|
-
(currentValue2) => {
|
|
1824
|
-
const newValue = resolveValue(name, currentValue2);
|
|
1825
|
-
if (isValidValue(newValue)) {
|
|
1826
|
-
skipNextOnChangeRef.current = true;
|
|
1827
|
-
setValue(newValue);
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
);
|
|
1831
|
-
(0, import_react4.useEffect)(() => {
|
|
1832
|
-
if (!currentValue) {
|
|
1833
|
-
return;
|
|
1834
|
-
}
|
|
1835
|
-
onCurrentValueChange(currentValue);
|
|
1836
|
-
}, [currentValue]);
|
|
1837
|
-
const shouldSkipOnChange = (0, import_react4.useCallback)(() => {
|
|
1838
|
-
if (skipNextOnChangeRef.current) {
|
|
1839
|
-
skipNextOnChangeRef.current = false;
|
|
1840
|
-
return true;
|
|
1841
|
-
}
|
|
1842
|
-
return false;
|
|
1843
|
-
}, []);
|
|
1844
|
-
return {
|
|
1845
|
-
setValue,
|
|
1846
|
-
shouldSkipOnChange,
|
|
1847
|
-
value
|
|
1848
|
-
};
|
|
1849
|
-
}
|
|
1850
|
-
function resolveValue(name, currentValue) {
|
|
1851
|
-
if (name in currentValue) {
|
|
1852
|
-
return currentValue[name];
|
|
1853
|
-
}
|
|
1854
|
-
if (!name.includes(".")) {
|
|
1855
|
-
return void 0;
|
|
1856
|
-
}
|
|
1857
|
-
const keys = name.split(".");
|
|
1858
|
-
let result = currentValue;
|
|
1859
|
-
for (const key of keys) {
|
|
1860
|
-
if (result === null || result === void 0) {
|
|
1861
|
-
return void 0;
|
|
1862
|
-
}
|
|
1863
|
-
if (Array.isArray(result)) {
|
|
1864
|
-
const index = Number(key);
|
|
1865
|
-
result = Number.isInteger(index) ? result[index] : void 0;
|
|
1866
|
-
} else if (typeof result === "object") {
|
|
1867
|
-
result = result[key];
|
|
1868
|
-
} else {
|
|
1869
|
-
return void 0;
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
return result;
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
// src/client/component/input.tsx
|
|
1876
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1877
|
-
function Input(props) {
|
|
1878
|
-
const entity = props.field.advanced?.entity;
|
|
1879
|
-
const store4 = (0, import_jotai6.useStore)();
|
|
1880
|
-
const setTimeoutRef = useTimeout();
|
|
1881
|
-
const [, startTransition2] = (0, import_react5.useTransition)();
|
|
1882
|
-
const { setValue, shouldSkipOnChange, value } = useValue(
|
|
1883
|
-
props.field,
|
|
1884
|
-
props.value
|
|
1885
|
-
);
|
|
1886
|
-
const valueRef = (0, import_react5.useRef)(value);
|
|
1887
|
-
valueRef.current = value;
|
|
1888
|
-
const translationsRef = (0, import_react5.useRef)(props.translations);
|
|
1889
|
-
translationsRef.current = props.translations;
|
|
1890
|
-
const hasTextable = isTextable(props.field);
|
|
1891
|
-
const hasClickable = isClickable(props.field);
|
|
1892
|
-
const setValues = (0, import_jotai6.useSetAtom)(valueAtom);
|
|
1893
|
-
const setFieldStates = (0, import_jotai6.useSetAtom)(fieldStateAtom);
|
|
1894
|
-
const setErrors = (0, import_jotai6.useSetAtom)(reportInputErrorAtom(props.field.name));
|
|
1895
|
-
const [data, setSource] = useDataSource(props.field, props.config, value);
|
|
1896
|
-
const schema = useInput(
|
|
1897
|
-
props.field,
|
|
1898
|
-
props.onMount,
|
|
1899
|
-
props.onUnmount,
|
|
1900
|
-
props.translations
|
|
1901
|
-
);
|
|
1902
|
-
const placeholder = translate(
|
|
1903
|
-
props.commonProps.placeholder,
|
|
1904
|
-
props.translations
|
|
1905
|
-
);
|
|
1906
|
-
const commonProps = {
|
|
1907
|
-
...props.commonProps,
|
|
1908
|
-
placeholder
|
|
1909
|
-
};
|
|
1910
|
-
const { commonPropsWithOptions, defaultValue } = prepareInputProps(
|
|
1911
|
-
props.field,
|
|
1912
|
-
commonProps,
|
|
1913
|
-
data,
|
|
1914
|
-
value
|
|
1915
|
-
);
|
|
1916
|
-
const onValueChangeRef = (0, import_react5.useRef)(null);
|
|
1917
|
-
onValueChangeRef.current = (value2) => {
|
|
1918
|
-
setValue(value2);
|
|
1919
|
-
if (props.onValueChange) {
|
|
1920
|
-
props.onValueChange({ name: props.field.name, value: value2 });
|
|
1921
|
-
}
|
|
1922
|
-
};
|
|
1923
|
-
const inputProps = prepareInputValue(props.field, defaultValue);
|
|
1924
|
-
const validated = (0, import_react5.useCallback)(
|
|
1925
|
-
(value2) => {
|
|
1926
|
-
const results = schema.safeParse(value2);
|
|
1927
|
-
const errors = results.error?.issues.map((issue) => issue.message) ?? [];
|
|
1928
|
-
const custom = props.field.validation?.custom;
|
|
1929
|
-
const customErrors = custom ? validateCustom(
|
|
1930
|
-
value2,
|
|
1931
|
-
custom,
|
|
1932
|
-
(name) => store4.get(reportValueAtom(name)),
|
|
1933
|
-
translationsRef.current
|
|
1934
|
-
) : [];
|
|
1935
|
-
setErrors([...errors, ...customErrors]);
|
|
1936
|
-
},
|
|
1937
|
-
[props.field.validation?.custom, schema, setErrors, store4]
|
|
1938
|
-
);
|
|
1939
|
-
const handleTriggerEvent = (0, import_react5.useCallback)(
|
|
1940
|
-
(value2, callback) => {
|
|
1941
|
-
if (hasTextable) {
|
|
1942
|
-
setTimeoutRef(() => {
|
|
1943
|
-
callback({ value: value2 });
|
|
1944
|
-
}, 500);
|
|
1945
|
-
return;
|
|
1946
|
-
}
|
|
1947
|
-
callback(getEntity(value2, data, entity));
|
|
1948
|
-
},
|
|
1949
|
-
[data, entity, hasTextable, setTimeoutRef]
|
|
1950
|
-
);
|
|
1951
|
-
const onChange = (0, import_react5.useCallback)(
|
|
1952
|
-
(event) => {
|
|
1953
|
-
const inputValue = event.target.value;
|
|
1954
|
-
if (!hasClickable && shouldSkipOnChange()) {
|
|
1955
|
-
if (!hasTextable || inputValue === valueRef.current) {
|
|
1956
|
-
return;
|
|
1957
|
-
}
|
|
1958
|
-
}
|
|
1959
|
-
onValueChangeRef.current?.(inputValue);
|
|
1960
|
-
if (props.config.validation.change) {
|
|
1961
|
-
validated(inputValue);
|
|
1962
|
-
}
|
|
1963
|
-
const events = props.field.event?.change;
|
|
1964
|
-
if (events) {
|
|
1965
|
-
handleTriggerEvent(inputValue, (selected) => {
|
|
1966
|
-
handleProxyEvent(events, ({ sources, states, values }) => {
|
|
1967
|
-
startTransition2(() => {
|
|
1968
|
-
handleSourceEvent(
|
|
1969
|
-
selected,
|
|
1970
|
-
sources,
|
|
1971
|
-
(target, source) => setSource(target, source)
|
|
1972
|
-
);
|
|
1973
|
-
handleStateEvent(selected, states, (targets, state) => {
|
|
1974
|
-
logger.info(
|
|
1975
|
-
`Setting field states for targets: ${targets.join(
|
|
1976
|
-
", "
|
|
1977
|
-
)} with state: ${JSON.stringify(state)}`
|
|
1978
|
-
);
|
|
1979
|
-
setFieldStates((prev) => {
|
|
1980
|
-
if (state) {
|
|
1981
|
-
return targets.reduce(
|
|
1982
|
-
(acc, target) => ({
|
|
1983
|
-
...acc,
|
|
1984
|
-
[target]: state
|
|
1985
|
-
}),
|
|
1986
|
-
prev
|
|
1987
|
-
);
|
|
1988
|
-
}
|
|
1989
|
-
return targets.reduce((acc, target) => {
|
|
1990
|
-
const { [target]: _removed, ...rest } = acc;
|
|
1991
|
-
return rest;
|
|
1992
|
-
}, prev);
|
|
1993
|
-
});
|
|
1994
|
-
});
|
|
1995
|
-
handleValueEvent(selected, values, (target, value2) => {
|
|
1996
|
-
setValues((prev) => ({
|
|
1997
|
-
...prev,
|
|
1998
|
-
[target]: value2
|
|
1999
|
-
}));
|
|
2000
|
-
});
|
|
2001
|
-
});
|
|
2002
|
-
});
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
|
-
},
|
|
2006
|
-
[
|
|
2007
|
-
handleTriggerEvent,
|
|
2008
|
-
hasClickable,
|
|
2009
|
-
hasTextable,
|
|
2010
|
-
props.config.validation.change,
|
|
2011
|
-
props.field.event?.change,
|
|
2012
|
-
setFieldStates,
|
|
2013
|
-
setSource,
|
|
2014
|
-
setValues,
|
|
2015
|
-
shouldSkipOnChange,
|
|
2016
|
-
validated
|
|
2017
|
-
]
|
|
2018
|
-
);
|
|
2019
|
-
const onBlur = (0, import_react5.useCallback)(
|
|
2020
|
-
(event) => {
|
|
2021
|
-
if (!hasClickable) {
|
|
2022
|
-
const value2 = event.target.value;
|
|
2023
|
-
if (props.config.validation.blur) {
|
|
2024
|
-
validated(value2);
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
},
|
|
2028
|
-
[hasClickable, props.config.validation.blur, validated]
|
|
2029
|
-
);
|
|
2030
|
-
return renderIfExists(props.config.inputs[props.field.type], (Component) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2031
|
-
InputGroup,
|
|
2032
|
-
{
|
|
2033
|
-
config: props.config,
|
|
2034
|
-
context: props.context,
|
|
2035
|
-
field: props.field,
|
|
2036
|
-
orientation: props.orientation,
|
|
2037
|
-
translations: props.translations,
|
|
2038
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2039
|
-
Component,
|
|
2040
|
-
{
|
|
2041
|
-
...commonPropsWithOptions,
|
|
2042
|
-
...props.ariaAttributes,
|
|
2043
|
-
...props.dataAttributes,
|
|
2044
|
-
...inputProps,
|
|
2045
|
-
onBlur,
|
|
2046
|
-
onChange
|
|
2047
|
-
}
|
|
2048
|
-
)
|
|
2049
|
-
}
|
|
2050
|
-
));
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
// src/component/field/field-error.tsx
|
|
2054
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2055
|
-
function FieldError(props) {
|
|
2056
|
-
if (!props.errors || props.errors.length === 0) {
|
|
2057
|
-
return null;
|
|
2058
|
-
}
|
|
2059
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2060
|
-
"ul",
|
|
2061
|
-
{
|
|
2062
|
-
className: "text-sm text-red-600 dark:text-red-500",
|
|
2063
|
-
id: props.name ? `${props.name}-error` : void 0,
|
|
2064
|
-
children: props.errors?.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { children: error }, props.name ? `${props.name}-error-${index}` : index))
|
|
2065
|
-
}
|
|
2066
|
-
);
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
// src/component/field/field-base.tsx
|
|
2070
|
-
var import_tailwind_merge2 = require("tailwind-merge");
|
|
2071
|
-
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2072
|
-
function FieldBase(props) {
|
|
2073
|
-
const errors = props.errors && props.errors.length > 0;
|
|
2074
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2075
|
-
"div",
|
|
2076
|
-
{
|
|
2077
|
-
"data-slot": "field",
|
|
2078
|
-
"data-clickable": props.isClickable ? "true" : "false",
|
|
2079
|
-
...errors && { [DATA_INVALID]: "true" },
|
|
2080
|
-
...props.disabled && { [DATA_READONLY]: "true" },
|
|
2081
|
-
"data-orientation": props.orientation,
|
|
2082
|
-
className: (0, import_tailwind_merge2.twMerge)(
|
|
2083
|
-
"group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500",
|
|
2084
|
-
"data-[clickable=true]:items-start",
|
|
2085
|
-
props.isCheckbox && (props.isReversed ? "flex-row-reverse!" : "flex-row!"),
|
|
2086
|
-
"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",
|
|
2087
|
-
props.className
|
|
2088
|
-
),
|
|
2089
|
-
children: props.children
|
|
2090
|
-
}
|
|
2091
|
-
);
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
// src/component/field/field-vertical.tsx
|
|
2095
|
-
var import_tailwind_merge3 = require("tailwind-merge");
|
|
2096
|
-
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2097
|
-
function FieldVertical(props) {
|
|
2098
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2099
|
-
FieldBase,
|
|
2100
|
-
{
|
|
2101
|
-
...props,
|
|
2102
|
-
orientation: VERTICAL,
|
|
2103
|
-
className: (0, import_tailwind_merge3.twMerge)(
|
|
2104
|
-
"gap-3 has-[>[data-slot=field-content]]:items-start",
|
|
2105
|
-
!props.isClickable && "[&>*]:w-full"
|
|
2106
|
-
),
|
|
2107
|
-
children: props.children
|
|
2108
|
-
}
|
|
2109
|
-
);
|
|
2110
|
-
}
|
|
2111
|
-
|
|
2112
|
-
// src/component/field/field-horizontal.tsx
|
|
2113
|
-
var import_tailwind_merge4 = require("tailwind-merge");
|
|
2114
|
-
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2115
|
-
function FieldHorizontal(props) {
|
|
2116
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2117
|
-
FieldBase,
|
|
2118
|
-
{
|
|
2119
|
-
...props,
|
|
2120
|
-
orientation: HORIZONTAL,
|
|
2121
|
-
className: (0, import_tailwind_merge4.twMerge)(
|
|
2122
|
-
"gap-2 md:flex-row md:gap-4",
|
|
2123
|
-
"[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start",
|
|
2124
|
-
"[&_[role=checkbox]]:mt-[1.5px]",
|
|
2125
|
-
props.isClickable && "md:flex-col",
|
|
2126
|
-
!props.isClickable && [
|
|
2127
|
-
"md:justify-between",
|
|
2128
|
-
"[&>*:not([data-slot=field-content])]:w-full",
|
|
2129
|
-
"[&>*:not([data-slot=field-content])]:md:w-1/2",
|
|
2130
|
-
"[&>*:not([data-slot=field-content])]:xl:w-2/5"
|
|
2131
|
-
]
|
|
2132
|
-
),
|
|
2133
|
-
children: props.children
|
|
2134
|
-
}
|
|
2135
|
-
);
|
|
2136
|
-
}
|
|
2137
|
-
|
|
2138
|
-
// src/component/field/field-group.tsx
|
|
2139
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2140
|
-
function FieldGroup(props) {
|
|
2141
|
-
const clickable = isClickable(props.field);
|
|
2142
|
-
const checkbox = isCheckbox(props.field);
|
|
2143
|
-
const reversed = buildReverse(props.field);
|
|
2144
|
-
if (props.orientation === VERTICAL) {
|
|
2145
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2146
|
-
FieldVertical,
|
|
2147
|
-
{
|
|
2148
|
-
disabled: props.disabled,
|
|
2149
|
-
errors: props.errors,
|
|
2150
|
-
isCheckbox: checkbox,
|
|
2151
|
-
isReversed: reversed,
|
|
2152
|
-
isClickable: clickable,
|
|
2153
|
-
children: props.children
|
|
2154
|
-
}
|
|
2155
|
-
);
|
|
2156
|
-
}
|
|
2157
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2158
|
-
FieldHorizontal,
|
|
2159
|
-
{
|
|
2160
|
-
disabled: props.disabled,
|
|
2161
|
-
errors: props.errors,
|
|
2162
|
-
isCheckbox: checkbox,
|
|
2163
|
-
isReversed: reversed,
|
|
2164
|
-
isClickable: clickable,
|
|
2165
|
-
children: props.children
|
|
2166
|
-
}
|
|
2167
|
-
);
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
// src/component/input/input-base.tsx
|
|
2171
|
-
function InputBase(props) {
|
|
2172
|
-
if (!props.field.type) {
|
|
2173
|
-
return null;
|
|
2174
|
-
}
|
|
2175
|
-
const commonProps = buildCommon(props.field, props.disabled);
|
|
2176
|
-
const dataAttributes = buildDataAttributes(props.field);
|
|
2177
|
-
const ariaAttributes = buildAriaAttributes(props.field, props.errors);
|
|
2178
|
-
const field = {
|
|
2179
|
-
...props.field,
|
|
2180
|
-
disabled: commonProps.disabled
|
|
2181
|
-
};
|
|
2182
|
-
return props.children({
|
|
2183
|
-
ariaAttributes,
|
|
2184
|
-
commonProps,
|
|
2185
|
-
dataAttributes,
|
|
2186
|
-
field,
|
|
2187
|
-
orientation: props.orientation
|
|
2188
|
-
});
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
|
-
// src/component/field/field.tsx
|
|
2192
|
-
var import_tailwind_merge5 = require("tailwind-merge");
|
|
2193
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2194
|
-
function Field(props) {
|
|
2195
|
-
const cols2 = props.field.advanced?.cols;
|
|
2196
|
-
const errors = props.field.name ? props.errors?.[props.field.name] : void 0;
|
|
2197
|
-
const { orientation } = mergeStyle(props.style, {
|
|
2198
|
-
orientation: buildOrientation(props.field)
|
|
2199
|
-
});
|
|
2200
|
-
const disabled = buildDisabled(props.field, props.disabled);
|
|
2201
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: (0, import_tailwind_merge5.twMerge)("flex flex-col gap-3", getSpan(cols2)), children: [
|
|
2202
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2203
|
-
FieldGroup,
|
|
2204
|
-
{
|
|
2205
|
-
disabled,
|
|
2206
|
-
errors,
|
|
2207
|
-
field: props.field,
|
|
2208
|
-
orientation,
|
|
2209
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2210
|
-
InputBase,
|
|
2211
|
-
{
|
|
2212
|
-
disabled,
|
|
2213
|
-
errors,
|
|
2214
|
-
field: props.field,
|
|
2215
|
-
orientation,
|
|
2216
|
-
children: props.children
|
|
2217
|
-
}
|
|
2218
|
-
)
|
|
2219
|
-
}
|
|
2220
|
-
),
|
|
2221
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FieldError, { errors, name: props.field.name })
|
|
2222
|
-
] });
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
// src/client/component/field/field-with-error.tsx
|
|
2226
|
-
var import_jotai7 = require("jotai");
|
|
2227
|
-
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2228
|
-
function withError(Component) {
|
|
2229
|
-
const WithError = (props) => {
|
|
2230
|
-
const errors = (0, import_jotai7.useAtomValue)(reportInputErrorAtom(props.field.name));
|
|
2231
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2232
|
-
Component,
|
|
2233
|
-
{
|
|
2234
|
-
...props,
|
|
2235
|
-
errors: errors ? { [props.field.name]: errors } : void 0
|
|
2236
|
-
}
|
|
2237
|
-
);
|
|
2238
|
-
};
|
|
2239
|
-
return WithError;
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
// src/client/component/field/field-with-state.tsx
|
|
2243
|
-
var import_jotai8 = require("jotai");
|
|
2244
|
-
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2245
|
-
function withState(Component) {
|
|
2246
|
-
const WithFieldState = (props) => {
|
|
2247
|
-
const fieldState = (0, import_jotai8.useAtomValue)(reportFieldStateAtom(props.field.name));
|
|
2248
|
-
const hidden = fieldState?.hidden ?? props.field.hidden ?? false;
|
|
2249
|
-
if (hidden) {
|
|
2250
|
-
return null;
|
|
2251
|
-
}
|
|
2252
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Component, { ...props, disabled: fieldState?.disabled ?? props.disabled });
|
|
2253
|
-
};
|
|
2254
|
-
return WithFieldState;
|
|
2255
|
-
}
|
|
2256
|
-
|
|
2257
|
-
// src/client/component/field/field.tsx
|
|
2258
|
-
var Field2 = withState(withError(Field));
|
|
2259
|
-
|
|
2260
|
-
// src/component/field/field-list-item.tsx
|
|
2261
|
-
var import_tailwind_merge6 = require("tailwind-merge");
|
|
2262
|
-
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2263
|
-
function FieldListItem(props) {
|
|
2264
|
-
function handleRemove() {
|
|
2265
|
-
if (props.canRemove && props.onRemove) {
|
|
2266
|
-
props.onRemove(props.index);
|
|
2267
|
-
}
|
|
2268
|
-
}
|
|
2269
|
-
const removeButton = props.canRemove && props.onRemove != null && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2270
|
-
"button",
|
|
2271
|
-
{
|
|
2272
|
-
"aria-label": `Remove ${props.label} item ${props.index + 1}`,
|
|
2273
|
-
className: (0, import_tailwind_merge6.twMerge)(
|
|
2274
|
-
"rounded p-1 text-xl text-slate-400",
|
|
2275
|
-
"transition-colors duration-150",
|
|
2276
|
-
"hover:text-red-500",
|
|
2277
|
-
"focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:outline-none",
|
|
2278
|
-
"dark:text-slate-500 dark:hover:text-red-400"
|
|
2279
|
-
),
|
|
2280
|
-
onClick: handleRemove,
|
|
2281
|
-
type: "button",
|
|
2282
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "aria-hidden": "true", children: "\xD7" })
|
|
2283
|
-
}
|
|
2284
|
-
);
|
|
2285
|
-
if (props.isMultiField) {
|
|
2286
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "rounded-lg border border-slate-100 p-4 dark:border-slate-900", children: [
|
|
2287
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mb-3 flex items-center justify-between", children: [
|
|
2288
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "text-sm font-medium text-slate-400 dark:text-slate-500", children: [
|
|
2289
|
-
props.label,
|
|
2290
|
-
" ",
|
|
2291
|
-
props.index + 1
|
|
2292
|
-
] }),
|
|
2293
|
-
removeButton
|
|
2294
|
-
] }),
|
|
2295
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Group, { children: props.children })
|
|
2296
|
-
] });
|
|
2297
|
-
}
|
|
2298
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-start gap-2", children: [
|
|
2299
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Group, { children: props.children }),
|
|
2300
|
-
removeButton && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "shrink-0", children: removeButton })
|
|
2301
|
-
] });
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
|
-
// src/client/component/field/field-list.tsx
|
|
2305
|
-
var import_tailwind_merge7 = require("tailwind-merge");
|
|
2306
|
-
|
|
2307
|
-
// src/client/hook/use-field-list.ts
|
|
2308
|
-
var import_jotai9 = require("jotai");
|
|
2309
|
-
var import_react6 = require("react");
|
|
2310
|
-
function useFieldList(field, value) {
|
|
2311
|
-
const min2 = field.advanced?.length?.min ?? 1;
|
|
2312
|
-
const max2 = field.advanced?.length?.max ?? Infinity;
|
|
2313
|
-
const [items, setItems] = (0, import_react6.useState)(
|
|
2314
|
-
() => getInitialList(field, value)
|
|
2315
|
-
);
|
|
2316
|
-
const nextId = (0, import_react6.useRef)(items.length);
|
|
2317
|
-
const itemsRef = (0, import_react6.useRef)(items);
|
|
2318
|
-
itemsRef.current = items;
|
|
2319
|
-
const setValues = (0, import_jotai9.useSetAtom)(valueAtom);
|
|
2320
|
-
const addItem = (0, import_react6.useCallback)(() => {
|
|
2321
|
-
setItems((previous) => {
|
|
2322
|
-
if (previous.length >= max2) {
|
|
2323
|
-
return previous;
|
|
2324
|
-
}
|
|
2325
|
-
const id = nextId.current++;
|
|
2326
|
-
return [...previous, id];
|
|
2327
|
-
});
|
|
2328
|
-
}, [max2]);
|
|
2329
|
-
const handleRemove = (0, import_react6.useCallback)(
|
|
2330
|
-
(index) => {
|
|
2331
|
-
if (items.length <= min2) {
|
|
2332
|
-
return;
|
|
2333
|
-
}
|
|
2334
|
-
const stableId = items[index];
|
|
2335
|
-
setItems((previous) => {
|
|
2336
|
-
if (previous.length <= min2) {
|
|
2337
|
-
return previous;
|
|
2338
|
-
}
|
|
2339
|
-
return previous.filter((_, i) => i !== index);
|
|
2340
|
-
});
|
|
2341
|
-
setValues((current) => {
|
|
2342
|
-
const next = { ...current };
|
|
2343
|
-
const prefix = `${field.name}.`;
|
|
2344
|
-
const leafNames = [];
|
|
2345
|
-
for (const row of field.fields) {
|
|
2346
|
-
if (isColumn(row)) {
|
|
2347
|
-
for (const columnField of row.fields) {
|
|
2348
|
-
leafNames.push(columnField.name);
|
|
2349
|
-
}
|
|
2350
|
-
} else {
|
|
2351
|
-
leafNames.push(row.name);
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
for (const name of leafNames) {
|
|
2355
|
-
delete next[`${prefix}${stableId}.${name}`];
|
|
2356
|
-
}
|
|
2357
|
-
return next;
|
|
2358
|
-
});
|
|
2359
|
-
},
|
|
2360
|
-
[field.name, field.fields, items, min2, setValues]
|
|
2361
|
-
);
|
|
2362
|
-
const canAdd = items.length < max2;
|
|
2363
|
-
const canRemove = items.length > min2;
|
|
2364
|
-
return [items, addItem, handleRemove, canAdd, canRemove, max2];
|
|
2365
|
-
}
|
|
2366
|
-
|
|
2367
|
-
// src/client/component/field/field-list.tsx
|
|
2368
|
-
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2369
|
-
function FieldList(props) {
|
|
2370
|
-
const [items, addItem, handleRemove, canAdd, canRemove, max2] = useFieldList(
|
|
2371
|
-
props.field,
|
|
2372
|
-
props.value
|
|
2373
|
-
);
|
|
2374
|
-
const label = getLabel(props.field);
|
|
2375
|
-
const action = props.field.advanced?.action ?? "Add item";
|
|
2376
|
-
const hasLimit = max2 !== Infinity;
|
|
2377
|
-
const isMultiField = isMultiFieldList(props.field);
|
|
2378
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
2379
|
-
items.map((key, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2380
|
-
FieldListItem,
|
|
2381
|
-
{
|
|
2382
|
-
canRemove,
|
|
2383
|
-
index,
|
|
2384
|
-
isMultiField,
|
|
2385
|
-
label,
|
|
2386
|
-
onRemove: handleRemove,
|
|
2387
|
-
children: props.children(key)
|
|
2388
|
-
},
|
|
2389
|
-
key
|
|
2390
|
-
)),
|
|
2391
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2392
|
-
"button",
|
|
2393
|
-
{
|
|
2394
|
-
"aria-disabled": !canAdd,
|
|
2395
|
-
"aria-label": hasLimit ? `${action}, ${items.length} of ${max2}` : action,
|
|
2396
|
-
className: (0, import_tailwind_merge7.twMerge)(
|
|
2397
|
-
"flex w-full items-center gap-1.5 rounded py-1",
|
|
2398
|
-
"text-sm font-medium text-slate-500",
|
|
2399
|
-
"transition-colors duration-150",
|
|
2400
|
-
"hover:text-slate-800",
|
|
2401
|
-
"focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:ring-offset-2 focus-visible:outline-none",
|
|
2402
|
-
"dark:text-slate-400 dark:hover:text-slate-200",
|
|
2403
|
-
!canAdd && "cursor-not-allowed opacity-50 hover:text-slate-500 dark:hover:text-slate-400"
|
|
2404
|
-
),
|
|
2405
|
-
disabled: !canAdd,
|
|
2406
|
-
onClick: addItem,
|
|
2407
|
-
type: "button",
|
|
2408
|
-
children: [
|
|
2409
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", children: "+" }),
|
|
2410
|
-
action,
|
|
2411
|
-
hasLimit && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2412
|
-
"span",
|
|
2413
|
-
{
|
|
2414
|
-
"aria-hidden": "true",
|
|
2415
|
-
className: "ml-auto text-slate-400 tabular-nums dark:text-slate-500",
|
|
2416
|
-
children: [
|
|
2417
|
-
items.length,
|
|
2418
|
-
" / ",
|
|
2419
|
-
max2
|
|
2420
|
-
]
|
|
2421
|
-
}
|
|
2422
|
-
)
|
|
2423
|
-
]
|
|
2424
|
-
}
|
|
2425
|
-
)
|
|
2426
|
-
] });
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
// src/component/list.tsx
|
|
2430
|
-
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2431
|
-
function List(props) {
|
|
2432
|
-
const empty = Array.isArray(props.field.fields) && props.field.fields.length === 0;
|
|
2433
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2434
|
-
FieldSetBase,
|
|
2435
|
-
{
|
|
2436
|
-
description: props.field.description,
|
|
2437
|
-
empty,
|
|
2438
|
-
id: props.field.name,
|
|
2439
|
-
title: props.field.label,
|
|
2440
|
-
children: props.children
|
|
2441
|
-
}
|
|
2442
|
-
);
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
|
-
// src/client/component/guard/list-guard.tsx
|
|
2446
|
-
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2447
|
-
function ListGuard({ children, field, value }) {
|
|
2448
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(VisibilityGuard, { container: field, fields: field.fields, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(List, { field, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FieldList, { field, value, children }) }) });
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2451
|
-
// src/component/column.tsx
|
|
2452
|
-
var import_tailwind_merge8 = require("tailwind-merge");
|
|
2453
|
-
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2454
|
-
function Column(props) {
|
|
2455
|
-
const cols2 = getColumn(props.column?.advanced?.cols);
|
|
2456
|
-
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex w-full flex-col gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: (0, import_tailwind_merge8.twMerge)("grid grid-cols-1 gap-3 sm:gap-4", cols2), children: props.children }) });
|
|
2457
|
-
}
|
|
2458
|
-
|
|
2459
|
-
// src/component/slot/slot-base.tsx
|
|
2460
|
-
var import_react7 = require("react");
|
|
2461
|
-
|
|
2462
|
-
// src/component/slot/slot-list.tsx
|
|
2463
|
-
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2464
|
-
function SlotList(props) {
|
|
2465
|
-
const fields = Array.isArray(props.field.fields) ? props.field.fields.map((field) => {
|
|
2466
|
-
if (isField(field)) {
|
|
2467
|
-
return {
|
|
2468
|
-
...field,
|
|
2469
|
-
name: `${props.field.name}.${props.index}.${field.name}`
|
|
2470
|
-
};
|
|
2471
|
-
}
|
|
2472
|
-
if (isColumn(field)) {
|
|
2473
|
-
return {
|
|
2474
|
-
...field,
|
|
2475
|
-
fields: field.fields.map((columnField) => ({
|
|
2476
|
-
...columnField,
|
|
2477
|
-
name: `${props.field.name}.${props.index}.${columnField.name}`
|
|
2478
|
-
}))
|
|
2479
|
-
};
|
|
2480
|
-
}
|
|
2481
|
-
return field;
|
|
2482
|
-
}) : [];
|
|
2483
|
-
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2484
|
-
SlotBase,
|
|
2485
|
-
{
|
|
2486
|
-
children: props.children,
|
|
2487
|
-
components: props.components,
|
|
2488
|
-
disabled: props.disabled,
|
|
2489
|
-
fields,
|
|
2490
|
-
style: props.style,
|
|
2491
|
-
value: props.value
|
|
2492
|
-
}
|
|
2493
|
-
);
|
|
2494
|
-
}
|
|
2495
|
-
|
|
2496
|
-
// src/component/slot/slot-base.tsx
|
|
2497
|
-
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
2498
|
-
function SlotBase(props) {
|
|
2499
|
-
const { field: Field3, list: List2 } = props.components;
|
|
2500
|
-
return prepare(props.fields).map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_react7.Fragment, { children: [
|
|
2501
|
-
isColumn(field) && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Column, { column: field, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(SlotBase, { ...props, fields: field.fields }) }),
|
|
2502
|
-
isField(field) && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Field3, { disabled: props.disabled, field, style: props.style, children: props.children }),
|
|
2503
|
-
isList(field) && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(List2, { field, value: props.value, children: (index2) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2504
|
-
SlotList,
|
|
2505
|
-
{
|
|
2506
|
-
children: props.children,
|
|
2507
|
-
components: props.components,
|
|
2508
|
-
disabled: props.disabled,
|
|
2509
|
-
field,
|
|
2510
|
-
index: index2,
|
|
2511
|
-
style: props.style,
|
|
2512
|
-
value: props.value
|
|
2513
|
-
}
|
|
2514
|
-
) })
|
|
2515
|
-
] }, index));
|
|
2516
|
-
}
|
|
2517
|
-
|
|
2518
|
-
// src/component/slot/slot-create.tsx
|
|
2519
|
-
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
2520
|
-
function createSlot(components) {
|
|
2521
|
-
const CreateSlot = (props) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(SlotBase, { ...props, components });
|
|
2522
|
-
return CreateSlot;
|
|
2523
|
-
}
|
|
2524
|
-
|
|
2525
|
-
// src/client/component/slot/slot.tsx
|
|
2526
|
-
var Slot = createSlot({ field: Field2, list: ListGuard });
|
|
2527
|
-
|
|
2528
|
-
// src/client/hook/use-form-action.ts
|
|
2529
|
-
var import_jotai10 = require("jotai");
|
|
2530
|
-
var import_react8 = require("react");
|
|
2531
|
-
function useFormState(getSchema2, action, options) {
|
|
2532
|
-
const {
|
|
2533
|
-
onSuccess,
|
|
2534
|
-
preserveValues = false,
|
|
2535
|
-
validation = true,
|
|
2536
|
-
translations
|
|
2537
|
-
} = options ?? {};
|
|
2538
|
-
const setError = (0, import_jotai10.useSetAtom)(reportErrorAtom);
|
|
2539
|
-
const clearValues = (0, import_jotai10.useSetAtom)(clearAllValueAtom);
|
|
2540
|
-
const initialState = {
|
|
2541
|
-
data: null,
|
|
2542
|
-
error: null,
|
|
2543
|
-
success: false
|
|
2544
|
-
};
|
|
2545
|
-
const [state, formAction, isPending] = (0, import_react8.useActionState)(
|
|
2546
|
-
async (prevState, formData) => {
|
|
2547
|
-
const [schemas, fields] = getSchema2();
|
|
2548
|
-
const schema = buildSchema(schemas, fields, translations);
|
|
2549
|
-
if (validation === false) {
|
|
2550
|
-
if (action) {
|
|
2551
|
-
return await action(formData, schema);
|
|
2552
|
-
}
|
|
2553
|
-
return prevState;
|
|
2554
|
-
}
|
|
2555
|
-
const form = getFormData(formData);
|
|
2556
|
-
const validated = schema.safeParse(form);
|
|
2557
|
-
if (!validated.success) {
|
|
2558
|
-
const errors = flatten(validated.error);
|
|
2559
|
-
(0, import_react8.startTransition)(() => {
|
|
2560
|
-
setError(errors);
|
|
2561
|
-
});
|
|
2562
|
-
return failure(form, {
|
|
2563
|
-
description: translate(
|
|
2564
|
-
"Please correct the errors and try again.",
|
|
2565
|
-
translations
|
|
2566
|
-
),
|
|
2567
|
-
details: [],
|
|
2568
|
-
title: translate(
|
|
2569
|
-
"There were validation errors submitting the form.",
|
|
2570
|
-
translations
|
|
2571
|
-
)
|
|
2572
|
-
});
|
|
2573
|
-
}
|
|
2574
|
-
const unflattened = unflatten(form);
|
|
2575
|
-
if (action) {
|
|
2576
|
-
try {
|
|
2577
|
-
const result = await action(unflattened, schema);
|
|
2578
|
-
if (!result.success) {
|
|
2579
|
-
return failure(unflattened, result.error);
|
|
2580
|
-
}
|
|
2581
|
-
onSuccess?.(result.data);
|
|
2582
|
-
if (!preserveValues) {
|
|
2583
|
-
(0, import_react8.startTransition)(() => {
|
|
2584
|
-
clearValues();
|
|
2585
|
-
});
|
|
2586
|
-
}
|
|
2587
|
-
return success(unflattened, preserveValues);
|
|
2588
|
-
} catch (error) {
|
|
2589
|
-
logger.error("Error executing form action:", error);
|
|
2590
|
-
return failure(unflattened, {
|
|
2591
|
-
title: translate(
|
|
2592
|
-
"An unexpected error occurred submitting the form.",
|
|
2593
|
-
translations
|
|
2594
|
-
),
|
|
2595
|
-
details: buildError(error, translations)
|
|
2596
|
-
});
|
|
2597
|
-
}
|
|
2598
|
-
}
|
|
2599
|
-
return success(validated.data, preserveValues);
|
|
2600
|
-
},
|
|
2601
|
-
initialState
|
|
2602
|
-
);
|
|
2603
|
-
return [formAction, state, isPending];
|
|
2604
|
-
}
|
|
2605
|
-
function buildError(error, translations) {
|
|
2606
|
-
if (error instanceof Error) {
|
|
2607
|
-
return [error.message];
|
|
2608
|
-
}
|
|
2609
|
-
return [translate("Unknown error", translations)];
|
|
2610
|
-
}
|
|
2611
|
-
function success(value, preserveValues = false) {
|
|
2612
|
-
const data = preserveValues ? value : null;
|
|
2613
|
-
return {
|
|
2614
|
-
data,
|
|
2615
|
-
error: null,
|
|
2616
|
-
success: true
|
|
2617
|
-
};
|
|
2618
|
-
}
|
|
2619
|
-
function failure(value, error) {
|
|
2620
|
-
return {
|
|
2621
|
-
data: value,
|
|
2622
|
-
error,
|
|
2623
|
-
success: false
|
|
2624
|
-
};
|
|
2625
|
-
}
|
|
2626
|
-
|
|
2627
|
-
// src/client/hook/use-schema.ts
|
|
2628
|
-
var import_react10 = require("react");
|
|
2629
|
-
|
|
2630
|
-
// src/client/hook/use-store.ts
|
|
2631
|
-
var import_react9 = require("react");
|
|
2632
|
-
var import_jotai11 = require("jotai");
|
|
2633
|
-
function useStore2() {
|
|
2634
|
-
const clearErrors = (0, import_jotai11.useSetAtom)(clearInputErrorAtom);
|
|
2635
|
-
const clearValues = (0, import_jotai11.useSetAtom)(clearInputValueAtom);
|
|
2636
|
-
const clearSources = (0, import_jotai11.useSetAtom)(clearInputSourceAtom);
|
|
2637
|
-
return (0, import_react9.useCallback)(
|
|
2638
|
-
(names) => {
|
|
2639
|
-
const target = Array.isArray(names) ? names : [names];
|
|
2640
|
-
clearErrors(target);
|
|
2641
|
-
clearSources(target);
|
|
2642
|
-
clearValues(target);
|
|
2643
|
-
},
|
|
2644
|
-
[clearErrors, clearSources, clearValues]
|
|
2645
|
-
);
|
|
2646
|
-
}
|
|
2647
|
-
|
|
2648
|
-
// src/client/hook/use-schema.ts
|
|
2649
|
-
function useSchema() {
|
|
2650
|
-
const clear = useStore2();
|
|
2651
|
-
const schemaRef = (0, import_react10.useRef)({});
|
|
2652
|
-
const fieldsRef = (0, import_react10.useRef)([]);
|
|
2653
|
-
const onMount = (0, import_react10.useCallback)((name, schema, field) => {
|
|
2654
|
-
if (!(name in schemaRef.current)) {
|
|
2655
|
-
schemaRef.current[name] = schema;
|
|
2656
|
-
fieldsRef.current.push(field);
|
|
2657
|
-
}
|
|
2658
|
-
}, []);
|
|
2659
|
-
const onUnmount = (0, import_react10.useCallback)(
|
|
2660
|
-
(name) => {
|
|
2661
|
-
if (schemaRef.current[name]) {
|
|
2662
|
-
delete schemaRef.current[name];
|
|
2663
|
-
fieldsRef.current = fieldsRef.current.filter((field) => {
|
|
2664
|
-
return field.name !== name;
|
|
2665
|
-
});
|
|
2666
|
-
clear([name]);
|
|
2667
|
-
}
|
|
2668
|
-
},
|
|
2669
|
-
[clear]
|
|
2670
|
-
);
|
|
2671
|
-
const getSchema2 = (0, import_react10.useCallback)(() => {
|
|
2672
|
-
return [schemaRef.current, fieldsRef.current];
|
|
2673
|
-
}, []);
|
|
2674
|
-
return [getSchema2, onMount, onUnmount];
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
|
-
// src/client/component/form-content.tsx
|
|
2678
|
-
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2679
|
-
function FormContent(props) {
|
|
2680
|
-
const translations = props.translations?.[props.lang ?? ""];
|
|
2681
|
-
const [schema, onMount, onUnmount] = useSchema();
|
|
2682
|
-
const [action, state, isPending] = useFormState(schema, props.action, {
|
|
2683
|
-
onSuccess: props.onSuccess,
|
|
2684
|
-
validation: props.config.validation.submit,
|
|
2685
|
-
translations
|
|
2686
|
-
});
|
|
2687
|
-
const isShowingError = props.config.validation.showError && !state.success && state.error;
|
|
2688
|
-
const value = state.data ?? props.value;
|
|
2689
|
-
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
2690
|
-
isShowingError && renderIfExists(props.config.alert, (Alert) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "mb-4 w-full", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
2691
|
-
Alert,
|
|
2692
|
-
{
|
|
2693
|
-
description: state.error?.description,
|
|
2694
|
-
details: state.error?.details,
|
|
2695
|
-
title: state.error.title
|
|
2696
|
-
}
|
|
2697
|
-
) })),
|
|
2698
|
-
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
2699
|
-
Form,
|
|
2700
|
-
{
|
|
2701
|
-
action,
|
|
2702
|
-
config: props.config,
|
|
2703
|
-
control: props.children,
|
|
2704
|
-
definition: props.definition,
|
|
2705
|
-
isPending,
|
|
2706
|
-
noValidate: true,
|
|
2707
|
-
readOnly: props.readOnly,
|
|
2708
|
-
sections: props.sections,
|
|
2709
|
-
children: ({ disabled, fields }) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
2710
|
-
Slot,
|
|
2711
|
-
{
|
|
2712
|
-
disabled,
|
|
2713
|
-
fields,
|
|
2714
|
-
style: props.config.style,
|
|
2715
|
-
value,
|
|
2716
|
-
children: (internal) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
2717
|
-
Input,
|
|
2718
|
-
{
|
|
2719
|
-
...internal,
|
|
2720
|
-
config: props.config,
|
|
2721
|
-
context: props.context,
|
|
2722
|
-
onMount,
|
|
2723
|
-
onUnmount,
|
|
2724
|
-
onValueChange: props.onValueChange,
|
|
2725
|
-
translations,
|
|
2726
|
-
value
|
|
2727
|
-
}
|
|
2728
|
-
)
|
|
2729
|
-
}
|
|
2730
|
-
)
|
|
2731
|
-
}
|
|
2732
|
-
)
|
|
2733
|
-
] });
|
|
2734
|
-
}
|
|
2735
|
-
|
|
2736
|
-
// src/client/component/form.tsx
|
|
2737
|
-
var import_jotai12 = require("jotai");
|
|
2738
|
-
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
2739
|
-
function Form2(props) {
|
|
2740
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jotai12.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(FormContent, { ...props }) });
|
|
2741
|
-
}
|
|
1
|
+
"use strict";var Yo=Object.create;var Ce=Object.defineProperty;var Ho=Object.getOwnPropertyDescriptor;var Xo=Object.getOwnPropertyNames;var qo=Object.getPrototypeOf,Zo=Object.prototype.hasOwnProperty;var Wo=(e,t)=>{for(var n in t)Ce(e,n,{get:t[n],enumerable:!0})},Mt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xo(t))!Zo.call(e,o)&&o!==n&&Ce(e,o,{get:()=>t[o],enumerable:!(r=Ho(t,o))||r.enumerable});return e};var Ko=(e,t,n)=>(n=e!=null?Yo(qo(e)):{},Mt(t||!e||!e.__esModule?Ce(n,"default",{value:e,enumerable:!0}):n,e)),zo=e=>Mt(Ce({},"__esModule",{value:!0}),e);var cl={};Wo(cl,{Form:()=>_o});module.exports=zo(cl);var $t=require("react/jsx-runtime");function _t(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return(0,$t.jsx)("div",{"data-slot":"field-control",className:"w-full",children:t})}var ue=require("react");var ut=require("react/jsx-runtime");function Bt(e){return(0,ut.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,ut.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 Ne="input",Gt="input/email",Ut="input/number";var Yt="textarea",Ht="radio",Xt="checkbox",dt="list";var qt="select",Zt="select/month",Wt="select/year";var pe="column",ft="fields",Kt="label",R="value",Ee="options",mt="email",zt="number",Jt="password",Qt="tel",ye="text",jt="aria-errormessage",en="aria-invalid",tn="data-invalid",nn="data-readonly",rn="aria",on="data",ke="min",Ie="max",ln="minLength",an="maxLength",le="$ref";var sn="source",cn="state",we="http://luna.internal",U="vertical",ae="horizontal";var un="type";function d(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function Le(e){return e==null||e===""}function Y(e){return w(e)||typeof e=="number"||gt(e)}function w(e){return typeof e=="string"}function dn(e){return d(e)&&"url"in e}function gt(e){return typeof e=="boolean"}var Jo=/[^/]+$/,Qo=/^\d+$/;function yt(e,t=[],n=R){return Array.isArray(t)?t.find(r=>{let o=bt(r,n);if(o!==void 0&&`${o}`===e)return r})??{value:e}:{value:e}}function bt(e,t=R){if(e!=null){if(Y(e))return e;if(d(e)){let n=jo(e,t);if(Y(n))return n}}}function jo(e,t){let n=T(e,t);if(Y(n))return n}function fn(e,t){if(Array.isArray(e))return e;let n=T(e,t);return Array.isArray(n)?n:null}function T(e,t){if(!t||!d(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(d(r)&&o in r)r=r[o];else return null;return r}function mn(e,t={label:Kt,value:R}){return e.map(n=>{if(d(n)){let r=T(n,t.label),o=T(n,t.value);if(Y(r)&&Y(o))return{label:`${r}`,value:`${o}`}}return n})}function gn(e=ye){if(e){let t=e.match(Jo);if(t){let[n]=t;if(n!==Ne)return n.trim().toLowerCase()}}return ye}function pn(e){let t={};for(let n of e.keys()){let r=e.getAll(n);t[n]=r.length>1?r:r[0]}return t}function yn(e){let t={};for(let n in e){let r=n.split(".");if(r.length===1){t[n]=e[n];continue}let o=t;for(let l=0;l<r.length-1;l++){let a=r[l],s=r[l+1],c=Qo.test(s);a in o||(o[a]=c?[]:{}),o=o[a]}let i=r[r.length-1];o[i]=e[n]}return pt(t),t}function pt(e){for(let t in e){let n=e[t];if(Array.isArray(n)){let r=n.filter(o=>o!==void 0);r.forEach(o=>{o!==null&&typeof o=="object"&&!Array.isArray(o)&&pt(o)}),e[t]=r}else n!==null&&typeof n=="object"&&pt(n)}}var ei=/\[([^\]]+)\]\(([^)]+)\)/g;function H(e,t={}){if(w(e))return ti(e,t);if(Array.isArray(e))return e.map(n=>H(n,t));if(d(e)){let n={};for(let r in e)n[r]=H(e[r],t);return n}return e}function xt(e,t={}){return be(e)?H(e,t):e}function be(e){return w(e)?/{([^}]+)}/.test(e):Array.isArray(e)?e.some(t=>be(t)):d(e)?Object.values(e).some(t=>be(t)):!1}function ti(e,t={}){return e.replace(/{([^}]+)}/g,(n,r)=>{let o=r.includes(".")?T(t,r):t[r];return Y(o)?String(o):n})}function bn(e,t){if(!e||e.trim().length===0)return null;let n,r=0,o=!1,i=[];for(;(n=ei.exec(e))!==null;){let[l,a,s]=n,c=n.index;o=!0,c>r&&i.push(e.substring(r,c));let u=t?t(c,s,a):l;i.push(u),r=c+l.length}return o?(r<e.length&&i.push(e.substring(r)),i):e}var v={error:(...e)=>{ht()&&!Rt()&&Pe().error("[Luna Form]",...e)},warn:(...e)=>{ht()&&!Rt()&&Pe().warn("[Luna Form]",...e)},info:(...e)=>{ht()&&!Rt()&&Pe().info("[Luna Form]",...e)}},ht=()=>typeof Pe()<"u",Rt=()=>!0,Pe=()=>globalThis.console;function xn(e=[],t){let n=[],r=[],o=[];for(let i of e)i.action===R&&n.push(i),i.action===sn&&r.push(i),i.action===cn&&o.push(i);t({sources:r,states:o,values:n})}function hn(e=null,t=[],n){for(let r of t){let{target:o,source:i}=r;if(!e){n(o,void 0);continue}if(dn(i)){let l=H(i.url,e),a=i.body?H(i.body,e):i.body;n(o,{...i,url:l,body:a})}}}var xe={eq:li,gt:ui,gte:di,in:si,lt:fi,lte:mi,neq:ai,nin:ci},ni=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/,Rn=/^(\d{2})[/-](\d{2})[/-](\d{4})(?: (\d{2}):(\d{2})(?::(\d{2}))?)?$/;function ri(e){return typeof e=="string"&&ni.test(e)}function oi(e){return typeof e=="string"&&Rn.test(e)}function ii(e){let t=e.match(Rn);if(t){let[,n,r,o,i,l,a]=t;return new Date(Number(o),Number(r)-1,Number(n),Number(i??0),Number(l??0),Number(a??0)).getTime()}return NaN}function X(e){return ri(e)?new Date(e).getTime():oi(e)?ii(e):Number(e)}function li(e,t){return e===t}function ai(e,t){return e!==t}function si(e,t){return Array.isArray(t)&&t.includes(String(e))}function ci(e,t){return Array.isArray(t)&&!t.includes(String(e))}function ui(e,t){return X(e)>X(t)}function di(e,t){return X(e)>=X(t)}function fi(e,t){return X(e)<X(t)}function mi(e,t){return X(e)<=X(t)}function Tn(e=null,t=[],n){for(let r of t){let{target:o,state:i,when:l}=r,a=Array.isArray(o)?o:[o];if(!e){n(a);continue}v.info(`Selected value for state event: ${JSON.stringify(e)}, evaluating condition: ${JSON.stringify(l)}`);let s=gi(e,l);v.info(`Condition evaluated to: ${s}, setting state for targets: ${a.join(", ")}`),n(a,s?i:void 0)}}function gi(e,t){return t===void 0?!0:w(t)?(v.info(`Evaluating string condition: ${t} against selected value: ${JSON.stringify(e)} using VALUE field`),v.info(`Extracted value for comparison: ${JSON.stringify(se(e,R))}`),v.info(`Comparison result: ${se(e,R)===t}`),se(e,R)===t):gt(t)?!!se(e,R)===t:Array.isArray(t)?t.includes(String(se(e,R))):pi(e,t)}function pi(e=null,t){let n=se(e,t.field??R),{operator:r="eq",value:o}=t,i=xe[r];return i?i(n,o):!1}function se(e,t){return d(e)?T(e,t):e}function Sn(e=null,t=[],n){for(let r of t)for(let[o,i]of Object.entries(r.value))n(o,e?H(i,e):void 0)}var Oe=e=>L(Zt)(e),Ve=e=>L(Wt)(e),S=L(Xt),Tt=L(Ne),D=L(Ht),M=L(qt),St=L(Yt),An=L(ye,mt,Jt,Qt),vn=L(Gt,mt),De=L(Ut,zt);function Me(e){return D(e)||S(e)}function Fn(e){return e.type===dt}function q(e){return e.type===pe}function _e(e){return e.type!==pe&&e.type!==dt}function $e(e){return M(e)||D(e)}function Cn(e){return Tt(e)||St(e)}function j(e){return e!=null&&e!==""}function L(...e){return t=>{let n=w(t.type)?t.type:void 0;return n?e.some(r=>n===r||n?.startsWith(`${r}/`)):!1}}function Nn(e,t={}){if(M(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&d(n))return[n]}}function En(e){return D(e)||S(e)?ae:e.advanced?.orientation??U}function kn(e){return S(e)?e.advanced?.reverse!==!1:!1}function In(e,t){let n=e.readonly??!1;return t||n}function wn(e){if(D(e)||M(e)&&!e.disabled){let t=e.source;if(Array.isArray(t)||d(t)&&!(le in t))return t}}var yi=/^\d+$/;function Ln(){return Array.from({length:12},(e,t)=>({value:(t+1).toString(),label:new Date(0,t).toLocaleString("default",{month:"long"})}))}function Pn(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 At(){return new Date().getFullYear()}function vt(e,t){if(typeof e=="number")return e;let n=t??At(),r=e.trim().toLowerCase();if(r.startsWith("current")){let o=r.match(/^current([+-])(\d+)$/);if(o){let[,i,l]=o,a=parseInt(l,10);if(!isNaN(a))return i==="+"?n+a:n-a}return n}return yi.test(r)?parseInt(r,10):n}var Be=At();function bi(e){if(M(e))return xi(e)}function xi(e){if(Oe(e))return Ln();if(Ve(e)){let t=e.advanced?.length?.min??Be,n=e.advanced?.length?.max??Be+5;return Pn(vt(t,Be),vt(n,Be))}}function On(e,t=!1){let n={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return Tt(e)?{...n,...hi(e)}:M(e)?{...n,...Ri(e)}:St(e)?{...n,...Ti(e)}:n}function hi(e){let t=gn(e.type),n={...e,type:t};return{...Vn(e),...Si(n),...An(n)?Dn(n):{},type:t}}function Ri(e){let t=bi(e);return t?{options:t}:{}}function Ti(e){return{...Vn(e),...Dn(e)}}function Vn(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function Si(e){return De(e)?Ai(e):{}}function Dn(e){return Mn(e,{min:ln,max:an})}function Ai(e){return Mn(e,{min:ke,max:Ie})}function Mn(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 _n(e,t){let n=wn(e);return n||Nn(e,t)}function vi(e,t){let n=d(t)&&e.name in t?t[e.name]:t;return bt(n,e.advanced?.entity)}function Fi(e,t,n){return $e(e)&&Array.isArray(n)?{...t,[Ee]:n}:t}function Ci(e,t,n){if(e.required&&!j(n)&&M(e)&&e.advanced?.preselected!==!1&&Ee in t){let r=t[Ee];if(Array.isArray(r)&&r.length===1)return r[0]}return n}function Ni(e,t){return M(e)&&Array.isArray(t)?mn(t,e.advanced?.options):t}function $n(e,t,n,r){let o=vi(e,r),i=Array.isArray(n)?Ni(e,n):n,l=Fi(e,t,i),a=Ci(e,l,o);return{commonPropsWithOptions:l,defaultValue:a}}function Bn(e,t){return S(e)?{checked:j(t)?t:!1}:{value:t??""}}var Ei=/^#\/definition\//;function Ue(e=[],t){let n=Ge(e,t);return Array.isArray(n)?n.filter(Ii).sort((r,o)=>Gn(r)-Gn(o)):[]}function Ge(e,t,n=new Map,r=new WeakSet){if(!ki(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=>Ge(i,t,n,r));if(le in e&&w(e[le])){let i=e[le].replace(Ei,""),l=T(t,i);return l!==null?Ge(l,t,n,r):e}let o={};for(let[i,l]of Object.entries(e))o[i]=Ge(l,t,n,r);return r.delete(e),n.set(e,o),o}function Un(e){return Object.entries(e??{})}function Gn(e){return e.order??Number.MAX_VALUE}function ki(e){return e!==void 0&&d(e)&&Object.keys(e).length>0}function Ii(e){return un in e?!0:Array.isArray(e[ft])?e[ft].length>0:!0}function Yn(e,t){let n={};for(let[r,o]of Un(t))n[`${e}-${r}`]=o;return n}function wi(e){return Yn(rn,e)}function Li(e){return Yn(on,e)}function Hn(e,t){let n=wi(e.advanced?.aria);return t&&t.length>0&&(n[en]="true",n[jt]=`${e.name}-error`),n}function Xn(e){return Li(e.advanced?.data)}var qn={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Zn={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function Wn(e,t=2){return qn[e&&e in qn?e:t]}function Kn(e){if(e&&e in Zn)return Zn[e]}function Pi(e,t){let n=e.advanced?.length?.min??1;if(t){let r=T(t,e.name);if(Array.isArray(r))return Math.max(r.length,n)}return Math.max(n,0)}function zn(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===pe}function Jn(e,t){let n=Pi(e,t);return Array.from({length:n},(r,o)=>o)}function Qn(e){return e.label??e.name}var m=require("zod");function f(e,t){return e?t?t[e]??e:e:""}var Oi=[[De,$i],[vn,Vi],[Ve,Bi],[Oe,Gi],[S,Di],[D,Mi]];function er(e,t=[],n){let r=m.z.object(e);return t.length===0?r:Xi(r,t,n)}function tr(e){let t={},n=m.z.flattenError(e).fieldErrors;for(let[r,o]of Object.entries(n))o!==void 0&&(t[r]=o);return t}function nr(e,t){for(let[n,r]of Oi)if(n(e))return r(e,t);return _i(e,t)}function Vi(e,t){let n=m.z.string().trim();if(e.required){let r=ce(e,t),o=n.min(1,r).pipe(jn(e,t));return m.z.preprocess(i=>Le(i)?"":i,o)}return n.pipe(jn(e,t)).or(m.z.literal("")).nullable()}function Di(e,t){let n=m.z.coerce.boolean();return e.required?(n=n.refine(r=>r===!0,{message:ce(e,t)}),m.z.preprocess(r=>r===null?!1:r,n)):n.nullable()}function Mi(e,t){let n=m.z.coerce.string();return e.required?(n=n.min(1,ce(e,t)),m.z.preprocess(r=>Le(r)?"":r,n)):n.or(m.z.literal("")).nullable()}function _i(e,t){let n=m.z.coerce.string().trim();return n=rr(n,e,t),e.required?(n=or(n,e,t),m.z.preprocess(r=>Le(r)?"":r,n)):n.nullable()}function $i(e,t){let n=m.z.coerce.number().int();return n=rr(n,e,t),e.required?(n=or(n,e,t),m.z.preprocess(r=>r===null?void 0:r,n)):n.nullable()}function Bi(e,t){return e.required?m.z.preprocess(Ui,m.z.coerce.number({message:ce(e,t)}).int()):m.z.coerce.number().int().nullable()}function Gi(e,t){let n=ce(e,t),r=m.z.coerce.number().int().min(1,n).max(12,n);return e.required?r:r.nullable()}function Ui(e){return e===null||e===""?void 0:e}function jn(e,t){let n=e.validation?.email?f(e.validation?.email,t):void 0;return m.z.email(n)}function rr(e,t,n){return e=Yi(e,t,n),e=Hi(e,t,n),e}function or(e,t,n){let r=t.advanced?.length?.min;return r===void 0||r<1?e.min(1,ce(t,n)):e}var Yi=(e,t,n)=>ir(e,t,ke,n),Hi=(e,t,n)=>ir(e,t,Ie,n);function ir(e,t,n,r){let o=t.advanced?.length?.[n];if(o!==void 0){let i=t.validation?.length?.[n]?f(t.validation?.length?.[n],r):void 0;return e[n](o,i)}return e}function Xi(e,t=[],n){let r=Zi(t);return r.length===0?e:e.superRefine((o,i)=>{for(let{name:l,rule:a}of r)if(!qi(o,l,a)){let s=f(a.message,n);i.addIssue({code:"custom",message:s,path:[l]})}})}function qi(e,t,n){let r=n.operator??"eq",o=xe[r];return o?o(e[t],e[n.field]):!1}function Zi(e){let t=[];for(let n of e){let r=n.validation?.custom;if(!r)continue;let o=Array.isArray(r)?r:[r];for(let i of o)t.push({name:n.name,rule:i})}return t}function lr(e,t,n,r){let o=[],i=Array.isArray(t)?t:[t];for(let l of i){let a=l.operator??"eq",s=xe[a];if(s&&!s(e,n(l.field))&&l.message){let c=f(l.message,r);o.push(c)}}return o}function ce(e,t){return e.validation?.required?f(e.validation?.required,t):void 0}function ar(e,t){if(!t||!Ki(e))return!0;if(t.length===0)return!1;try{let n=new URL(e),r=n.protocol.replace(":",""),o=n.hostname,i=n.port||Wi(r);return t.some(l=>!(l.protocol&&l.protocol!==r||l.hostname&&l.hostname!==o||l.port!==void 0&&String(l.port)!==i))}catch{return!1}}function Wi(e){return e==="https"?"443":"80"}function Ki(e){return/^(https?:)?\/\//.test(e)}function sr(e,t){try{if(!e)return t;if(!t)return e;let n=new URL(e,we);new URL(t,we).searchParams.forEach((i,l)=>{n.searchParams.set(l,i)});let o=n.toString();return e.startsWith("/")||!e.includes("://")?o.replace(we,""):o}catch{return t||e}}function cr(e){return!Array.isArray(e)||e.length===0?null:e.reduce((t,n)=>{let r=sr(t.url,n.url),o=zi(t,n),i=Ji(t,n);return{...t,...n,url:r,body:o,headers:i}})}function zi(e,t){return d(t.body)&&d(e?.body)?{...e.body,...t.body}:t.body??e?.body}function Ji(e,t){return d(t.headers)&&d(e?.headers)?{...e.headers,...t.headers}:t.headers??e?.headers}function Ye(e,t){return{...e,...t}}var ur=require("react/jsx-runtime");function Z(e){return bn(e,(t,n,r)=>(0,ur.jsx)("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:r},`${n}-${t}`))}var P=require("react/jsx-runtime");function dr(e){let{fields:t=[]}=e.section,[n,r]=(0,ue.useState)(!1),o=(0,ue.useCallback)(()=>r(i=>!i),[]);return(0,P.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,P.jsx)("legend",{children:(0,P.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,P.jsx)(Bt,{expanded:n}),(0,P.jsx)("span",{children:Z(e.section.title)})]})}),(0,P.jsx)(ue.Activity,{mode:n?"visible":"hidden",children:(0,P.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,P.jsx)("p",{className:"text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:Z(e.section.description)}),e.group]})})]})}var ee=require("react/jsx-runtime");function fr(e){return(0,ee.jsxs)(ee.Fragment,{children:[e.title&&(0,ee.jsx)("legend",{className:"mb-3 font-medium text-slate-800 dark:text-slate-200",children:Z(e.title)}),e.description&&(0,ee.jsx)("p",{className:"-mt-2 text-sm leading-normal font-normal text-slate-600 dark:text-slate-400",children:Z(e.description)})]})}var Xe=require("react/jsx-runtime");function He(e){return(0,Xe.jsxs)("fieldset",{"data-slot":"field-set","data-empty":e.empty,className:"flex flex-col data-[empty=false]:gap-6",id:e.id,children:[(0,Xe.jsx)(fr,{description:e.description,title:e.title}),e.children]})}var mr=require("react/jsx-runtime");function te(e){return(0,mr.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 qe=require("react/jsx-runtime");function gr(e){let{fields:t=[]}=e.section,{compact:n}=Ye(e.style,{compact:e.section.compact}),r=(0,qe.jsx)(te,{compact:n,children:e.children});return!e.section.title&&!e.section.description?r:e.section.advanced?(0,qe.jsx)(dr,{section:e.section,group:r}):(0,qe.jsx)(He,{description:e.section.description,empty:t.length===0,id:e.section.id?.toString(),title:e.section.title,children:r})}var hr=require("jotai");var W=require("jotai"),Ft=require("jotai-family"),Ze=require("fast-equals");function Qi(e){return(0,Ft.atomFamily)(t=>(0,W.atom)(n=>n(e)[t]??void 0,(n,r,o)=>{let i=n(e);if(o!=null){let l=i[t];(!l||!(0,Ze.deepEqual)(l,o))&&r(e,{...i,[t]:o})}else if(i[t]){let{[t]:l,...a}=i;r(e,a)}}))}function ji(e){return(0,W.atom)(null,(t,n)=>{let r=t(e);r&&Object.keys(r).length>0&&n(e,{})})}function el(e){return(0,W.atom)(null,(t,n,r)=>{let i={...t(e)},l=!1;for(let a of r)i[a]&&(delete i[a],l=!0);l&&n(e,i)})}function tl(e){return(0,W.atom)(null,(t,n,r)=>{let o=t(e);(0,Ze.deepEqual)(o,r)||n(e,r)})}function pr(e,t={}){let{merge:n,validateTarget:r}=t;return(0,Ft.atomFamily)(o=>(0,W.atom)(i=>{let l=i(e)[o];if(l&&n)return n(Object.values(l))},(i,l,a,s)=>{if(r&&!r(a))return;let c=i(e),u={...c[a]??{}};if(s!=null){let g=u[o];(!g||!(0,Ze.deepEqual)(g,s))&&(u[o]=s,l(e,{...c,[a]:u}))}else if(u[o])if(delete u[o],Object.keys(u).length===0){let{[a]:g,...x}=c;l(e,x)}else l(e,{...c,[a]:u})}))}function yr(e){return(0,W.atom)(null,(t,n,r)=>{let i={...t(e)},l=!1;for(let a of r)i[a]&&(delete i[a],l=!0);for(let a in i){let s={...i[a]},c=!1;for(let u of r)s[u]&&(delete s[u],c=!0,l=!0);c&&(Object.keys(s).length===0?delete i[a]:i[a]=s)}l&&n(e,i)})}function de(e={}){let t=(0,W.atom)(e);return{atom:t,clearAll:ji(t),clear:el(t),bulkReport:tl(t),report:Qi(t)}}var br=de(),We=br.atom,xr=br.report;function nl(e,t){return e.fields.every(n=>Rr(n,t))}function Rr(e,t){return t[e.name]?.hidden??e.hidden??!1}function rl(e,t){return q(e)?nl(e,t):Rr(e,t)}function Ke(e){let t=(0,hr.useAtomValue)(We);return e.container&&(t[e.container.name]?.hidden??e.container.hidden??!1)||e.fields.length===0||e.fields.every(r=>rl(r,t))?null:e.children}var Ct=require("react/jsx-runtime");function Tr(){return(0,Ct.jsx)("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:(0,Ct.jsx)("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-slate-200 dark:bg-slate-800"})})}var _=require("react/jsx-runtime");function Sr(e){let t=Ue(e.sections,e.definition);return(0,_.jsx)("div",{className:"h-full w-full",children:(0,_.jsx)("form",{noValidate:e.noValidate,action:e.action,children:(0,_.jsxs)(te,{children:[t.map((n,r)=>(0,_.jsxs)(Ke,{fields:n.fields??[],children:[(0,_.jsx)(gr,{section:n,style:e.config.style,children:e.children({disabled:e.readOnly,fields:n.fields})}),n.separator&&(0,_.jsx)(Tr,{})]},r)),e.control&&(0,_.jsx)(_t,{isPending:e.isPending,children:e.control})]})})})}var vr=require("react/jsx-runtime");function Ar(e){return(0,vr.jsx)("p",{className:"-mt-2 text-xs leading-normal font-normal text-slate-600 dark:text-slate-400",children:e.children})}var Fr=require("react/jsx-runtime");function ze(e){let t=Z(e.text);return t?(0,Fr.jsx)(Ar,{children:t}):null}var Cr=require("tailwind-merge"),Je=require("react/jsx-runtime");function Nr(e){let t=e.style?.showOptionalLabel??!0,n=D(e.field)||S(e.field);return(0,Je.jsxs)("label",{"data-slot":"field-label","data-normal":n,className:(0,Cr.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,Je.jsx)("span",{className:"text-sm text-slate-600 dark:text-slate-400",children:f("(Optional)",e.translations)})]})}var he=require("react/jsx-runtime");function Er(e){let t={context:e.context,env:e.config?.env},n=xt(e.field.label,t),r=xt(e.field.description,t);return(0,he.jsxs)("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[(0,he.jsx)(Nr,{field:e.field,style:e.config?.style,translations:e.translations,children:f(n,e.translations)}),e.orientation===ae&&(0,he.jsx)(ze,{text:f(r,e.translations)})]})}var ne=require("react/jsx-runtime");function kr(e){return(0,ne.jsxs)(ne.Fragment,{children:[e.field.name&&e.field.label&&(0,ne.jsx)(Er,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations}),e.children,e.orientation===U&&e.field.description&&(0,ne.jsx)(ze,{text:f(e.field.description,e.translations)})]})}function Qe(e,t){return e?t(e):null}var Nt=de(),Ir=Nt.clear,wr=Nt.bulkReport,je=Nt.report;var b=require("react");var Lr=require("jotai");var ol=e=>{let t=cr(e);if(t)return t},il=e=>e.trim()!=="",Pr=(0,Lr.atom)({}),Or=pr(Pr,{merge:ol,validateTarget:il}),Vr=yr(Pr);var _r=require("jotai");var Dr=Ko(require("swr"),1);function Mr(e=null,t,n=!1){let{data:r,error:o}=(0,Dr.default)(ll(e,t,n),t.fetcher.provider);if(o&&v.error("Error fetching data source:",o),e){if(Array.isArray(e))return e;if(r)return fn(r,e.namespace)}return null}function ll(e=null,t,n=!1){if(e&&!Array.isArray(e)&&!n&&e.url&&!be(e.url)){if(ar(e.url,t.fetcher.remotePatterns))return e;v.warn(`URL blocked by remotePatterns: ${e.url}. Check your luna.config.ts`)}return null}function $r(e,t,n){let r=_n(e,n),[o,i]=(0,_r.useAtom)(Or(e.name));return[Mr(o??r,t,e.disabled),i]}var re=require("react");function Br(e,t,n,r){let{name:o}=e,i=(0,re.useMemo)(()=>nr(e,r),[e,r]),l=(0,re.useEffectEvent)(s=>{s&&t(s,i,e)}),a=(0,re.useEffectEvent)(s=>{s&&n(s)});return(0,re.useEffect)(()=>(l(o),()=>{a(o)}),[o]),i}var me=require("jotai");var fe=require("react");function Gr(){let e=(0,fe.useRef)(null);return(0,fe.useEffect)(()=>()=>{e.current&&clearTimeout(e.current)},[]),(0,fe.useCallback)((n,r)=>{e.current&&(clearTimeout(e.current),e.current=null),e.current=setTimeout(n,r)},[])}var et=de(),tt=et.atom,Ur=et.clearAll,Yr=et.clear,nt=et.report;var Hr=require("jotai"),K=require("react");function Xr(e,t){let{name:n}=e,r=(0,K.useRef)(!1),[o,i]=(0,Hr.useAtom)(nt(n)),l=(0,K.useEffectEvent)(s=>{let c=al(n,s);j(c)&&(r.current=!0,i(c))});(0,K.useEffect)(()=>{t&&l(t)},[t]);let a=(0,K.useCallback)(()=>r.current?(r.current=!1,!0):!1,[]);return{setValue:i,shouldSkipOnChange:a,value:o}}function al(e,t){if(e in t)return t[e];if(!e.includes("."))return;let n=e.split("."),r=t;for(let o of n){if(r==null)return;if(Array.isArray(r)){let i=Number(o);r=Number.isInteger(i)?r[i]:void 0}else if(typeof r=="object")r=r[o];else return}return r}var Et=require("react/jsx-runtime");function qr(e){let t=e.field.advanced?.entity,n=(0,me.useStore)(),r=Gr(),[,o]=(0,b.useTransition)(),{setValue:i,shouldSkipOnChange:l,value:a}=Xr(e.field,e.value),s=(0,b.useRef)(!1),c=(0,b.useRef)(a);c.current=a;let u=(0,b.useRef)(e.translations);u.current=e.translations;let g=Cn(e.field),x=Me(e.field),C=(0,me.useSetAtom)(tt),B=(0,me.useSetAtom)(We),N=(0,me.useSetAtom)(je(e.field.name)),[h,V]=$r(e.field,e.config,a),E=Br(e.field,e.onMount,e.onUnmount,e.translations),A=f(e.commonProps.placeholder,e.translations),G={...e.commonProps,placeholder:A},{commonPropsWithOptions:k,defaultValue:Se}=$n(e.field,G,h,a),Vt=(0,b.useRef)(null);Vt.current=p=>{i(p),e.onValueChange&&e.onValueChange({name:e.field.name,value:p})};let lt=(0,b.useRef)(null);lt.current=p=>{let y=e.field.event?.change;y&&xn(y,({sources:Q,states:ve,values:at})=>{o(()=>{hn(p,Q,(I,ie)=>V(I,ie)),Tn(p,ve,(I,ie)=>{B(Fe=>ie?I.reduce((st,ct)=>({...st,[ct]:ie}),Fe):I.reduce((st,ct)=>{let{[ct]:ul,...Uo}=st;return Uo},Fe))}),Sn(p,at,(I,ie)=>{C(Fe=>({...Fe,[I]:ie}))})})})};let $o=Bn(e.field,Se),Ae=(0,b.useCallback)(p=>{let Q=E.safeParse(p).error?.issues.map(I=>I.message)??[],ve=e.field.validation?.custom,at=ve?lr(p,ve,I=>n.get(nt(I)),u.current):[];N([...Q,...at])},[e.field.validation?.custom,E,N,n]),Dt=(0,b.useCallback)((p,y)=>{if(g){r(()=>{y({value:p})},500);return}y(yt(p,h,t))},[h,t,g,r]);(0,b.useEffect)(()=>{if(s.current||!e.value)return;if(!e.field.event?.change){s.current=!0;return}if(!((!$e(e.field)||!!h&&h.length>0)&&j(Se)))return;s.current=!0;let y=String(Se),Q=g?{value:y}:yt(y,h,t);lt.current?.(Q)},[h,Se,t,g,e.field,e.value]);let Bo=(0,b.useCallback)(p=>{let y=p.target.value;!x&&l()&&(!g||y===c.current)||(Vt.current?.(y),e.config.validation.change&&Ae(y),e.field.event?.change&&Dt(y,Q=>{lt.current?.(Q)}))},[Dt,x,g,e.config.validation.change,e.field.event?.change,l,Ae]),Go=(0,b.useCallback)(p=>{if(!x){let y=p.target.value;e.config.validation.blur&&Ae(y)}},[x,e.config.validation.blur,Ae]);return Qe(e.config.inputs[e.field.type],p=>(0,Et.jsx)(kr,{config:e.config,context:e.context,field:e.field,orientation:e.orientation,translations:e.translations,children:(0,Et.jsx)(p,{...k,...e.ariaAttributes,...e.dataAttributes,...$o,onBlur:Go,onChange:Bo})}))}var kt=require("react/jsx-runtime");function Zr(e){return!e.errors||e.errors.length===0?null:(0,kt.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,kt.jsx)("li",{children:t},e.name?`${e.name}-error-${n}`:n))})}var Wr=require("tailwind-merge"),Kr=require("react/jsx-runtime");function rt(e){let t=e.errors&&e.errors.length>0;return(0,Kr.jsx)("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[tn]:"true"},...e.disabled&&{[nn]:"true"},"data-orientation":e.orientation,className:(0,Wr.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 zr=require("tailwind-merge"),Qr=require("react/jsx-runtime");function Jr(e){return(0,Qr.jsx)(rt,{...e,orientation:U,className:(0,zr.twMerge)("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}var jr=require("tailwind-merge"),to=require("react/jsx-runtime");function eo(e){return(0,to.jsx)(rt,{...e,orientation:ae,className:(0,jr.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 It=require("react/jsx-runtime");function no(e){let t=Me(e.field),n=S(e.field),r=kn(e.field);return e.orientation===U?(0,It.jsx)(Jr,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children}):(0,It.jsx)(eo,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:r,isClickable:t,children:e.children})}function ro(e){if(!e.field.type)return null;let t=On(e.field,e.disabled),n=Xn(e.field),r=Hn(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 oo=require("tailwind-merge"),ge=require("react/jsx-runtime");function io(e){let t=e.field.advanced?.cols,n=e.field.name?e.errors?.[e.field.name]:void 0,{orientation:r}=Ye(e.style,{orientation:En(e.field)}),o=In(e.field,e.disabled);return(0,ge.jsxs)("div",{className:(0,oo.twMerge)("flex flex-col gap-3",Kn(t)),children:[(0,ge.jsx)(no,{disabled:o,errors:n,field:e.field,orientation:r,children:(0,ge.jsx)(ro,{disabled:o,errors:n,field:e.field,orientation:r,children:e.children})}),(0,ge.jsx)(Zr,{errors:n,name:e.field.name})]})}var lo=require("jotai"),so=require("react/jsx-runtime");function ao(e){return n=>{let r=(0,lo.useAtomValue)(je(n.field.name));return(0,so.jsx)(e,{...n,errors:r?{[n.field.name]:r}:void 0})}}var co=require("jotai"),fo=require("react/jsx-runtime");function uo(e){return n=>{let r=(0,co.useAtomValue)(xr(n.field.name));return r?.hidden??n.field.hidden??!1?null:(0,fo.jsx)(e,{...n,disabled:r?.disabled??n.disabled})}}var mo=uo(ao(io));var go=require("tailwind-merge");var F=require("react/jsx-runtime");function po(e){function t(){e.canRemove&&e.onRemove&&e.onRemove(e.index)}let n=e.canRemove&&e.onRemove!=null&&(0,F.jsx)("button",{"aria-label":`Remove ${e.label} item ${e.index+1}`,className:(0,go.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,F.jsx)("span",{"aria-hidden":"true",children:"\xD7"})});return e.isMultiField?(0,F.jsxs)("div",{className:"rounded-lg border border-slate-100 p-4 dark:border-slate-900",children:[(0,F.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,F.jsxs)("span",{className:"text-sm font-medium text-slate-400 dark:text-slate-500",children:[e.label," ",e.index+1]}),n]}),(0,F.jsx)(te,{children:e.children})]}):(0,F.jsxs)("div",{className:"flex items-start gap-2",children:[(0,F.jsx)(te,{children:e.children}),n&&(0,F.jsx)("div",{className:"shrink-0",children:n})]})}var xo=require("tailwind-merge");var yo=require("jotai"),z=require("react");function bo(e,t){let n=e.advanced?.length?.min??1,r=e.advanced?.length?.max??1/0,[o,i]=(0,z.useState)(()=>Jn(e,t)),l=(0,z.useRef)(o.length),a=(0,z.useRef)(o);a.current=o;let s=(0,yo.useSetAtom)(tt),c=(0,z.useCallback)(()=>{i(C=>{if(C.length>=r)return C;let B=l.current++;return[...C,B]})},[r]),u=(0,z.useCallback)(C=>{if(o.length<=n)return;let B=o[C];i(N=>N.length<=n?N:N.filter((h,V)=>V!==C)),s(N=>{let h={...N},V=`${e.name}.`,E=[];for(let A of e.fields)if(q(A))for(let G of A.fields)E.push(G.name);else E.push(A.name);for(let A of E)delete h[`${V}${B}.${A}`];return h})},[e.name,e.fields,o,n,s]),g=o.length<r,x=o.length>n;return[o,c,u,g,x,r]}var $=require("react/jsx-runtime");function ho(e){let[t,n,r,o,i,l]=bo(e.field,e.value),a=Qn(e.field),s=e.field.advanced?.action??"Add item",c=l!==1/0,u=zn(e.field);return(0,$.jsxs)($.Fragment,{children:[t.map((g,x)=>(0,$.jsx)(po,{canRemove:i,index:x,isMultiField:u,label:a,onRemove:r,children:e.children(g)},g)),(0,$.jsxs)("button",{"aria-disabled":!o,"aria-label":c?`${s}, ${t.length} of ${l}`:s,className:(0,xo.twMerge)("flex w-full items-center gap-1.5 rounded py-1","text-sm font-medium text-slate-500","transition-colors duration-150","hover:text-slate-800","focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:ring-offset-2 focus-visible:outline-none","dark:text-slate-400 dark:hover:text-slate-200",!o&&"cursor-not-allowed opacity-50 hover:text-slate-500 dark:hover:text-slate-400"),disabled:!o,onClick:n,type:"button",children:[(0,$.jsx)("span",{"aria-hidden":"true",children:"+"}),s,c&&(0,$.jsxs)("span",{"aria-hidden":"true",className:"ml-auto text-slate-400 tabular-nums dark:text-slate-500",children:[t.length," / ",l]})]})]})}var To=require("react/jsx-runtime");function Ro(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0;return(0,To.jsx)(He,{description:e.field.description,empty:t,id:e.field.name,title:e.field.label,children:e.children})}var ot=require("react/jsx-runtime");function So({children:e,field:t,value:n}){return(0,ot.jsx)(Ke,{container:t,fields:t.fields,children:(0,ot.jsx)(Ro,{field:t,children:(0,ot.jsx)(ho,{field:t,value:n,children:e})})})}var Ao=require("tailwind-merge"),wt=require("react/jsx-runtime");function vo(e){let t=Wn(e.column?.advanced?.cols);return(0,wt.jsx)("div",{className:"flex w-full flex-col gap-4",children:(0,wt.jsx)("div",{className:(0,Ao.twMerge)("grid grid-cols-1 gap-3 sm:gap-4",t),children:e.children})})}var No=require("react");var Co=require("react/jsx-runtime");function Fo(e){let t=Array.isArray(e.field.fields)?e.field.fields.map(n=>_e(n)?{...n,name:`${e.field.name}.${e.index}.${n.name}`}:q(n)?{...n,fields:n.fields.map(r=>({...r,name:`${e.field.name}.${e.index}.${r.name}`}))}:n):[];return(0,Co.jsx)(Re,{children:e.children,components:e.components,disabled:e.disabled,fields:t,style:e.style,value:e.value})}var J=require("react/jsx-runtime");function Re(e){let{field:t,list:n}=e.components;return Ue(e.fields).map((r,o)=>(0,J.jsxs)(No.Fragment,{children:[q(r)&&(0,J.jsx)(vo,{column:r,children:(0,J.jsx)(Re,{...e,fields:r.fields})}),_e(r)&&(0,J.jsx)(t,{disabled:e.disabled,field:r,style:e.style,children:e.children}),Fn(r)&&(0,J.jsx)(n,{field:r,value:e.value,children:i=>(0,J.jsx)(Fo,{children:e.children,components:e.components,disabled:e.disabled,field:r,index:i,style:e.style,value:e.value})})]},o))}var ko=require("react/jsx-runtime");function Eo(e){return n=>(0,ko.jsx)(Re,{...n,components:e})}var Io=Eo({field:mo,list:So});var Pt=require("jotai");var Te=require("react");function Lo(e,t,n){let{onSuccess:r,preserveValues:o=!1,validation:i=!0,translations:l}=n??{},a=(0,Pt.useSetAtom)(wr),s=(0,Pt.useSetAtom)(Ur),c={data:null,error:null,success:!1},[u,g,x]=(0,Te.useActionState)(async(C,B)=>{let[N,h]=e(),V=er(N,h,l);if(i===!1)return t?await t(B,V):C;let E=pn(B),A=V.safeParse(E);if(!A.success){let k=tr(A.error);return(0,Te.startTransition)(()=>{a(k)}),Lt(E,{description:f("Please correct the errors and try again.",l),details:[],title:f("There were validation errors submitting the form.",l)})}let G=yn(E);if(t)try{let k=await t(G,V);return k.success?(r?.(k.data),o||(0,Te.startTransition)(()=>{s()}),wo(G,o)):Lt(G,k.error)}catch(k){return v.error("Error executing form action:",k),Lt(G,{title:f("An unexpected error occurred submitting the form.",l),details:sl(k,l)})}return wo(A.data,o)},c);return[g,u,x]}function sl(e,t){return e instanceof Error?[e.message]:[f("Unknown error",t)]}function wo(e,t=!1){return{data:t?e:null,error:null,success:!0}}function Lt(e,t){return{data:e,error:t,success:!1}}var oe=require("react");var Po=require("react"),it=require("jotai");function Oo(){let e=(0,it.useSetAtom)(Ir),t=(0,it.useSetAtom)(Yr),n=(0,it.useSetAtom)(Vr);return(0,Po.useCallback)(r=>{let o=Array.isArray(r)?r:[r];e(o),n(o),t(o)},[e,n,t])}function Vo(){let e=Oo(),t=(0,oe.useRef)({}),n=(0,oe.useRef)([]),r=(0,oe.useCallback)((l,a,s)=>{l in t.current||(t.current[l]=a,n.current.push(s))},[]),o=(0,oe.useCallback)(l=>{t.current[l]&&(delete t.current[l],n.current=n.current.filter(a=>a.name!==l),e([l]))},[e]);return[(0,oe.useCallback)(()=>[t.current,n.current],[]),r,o]}var O=require("react/jsx-runtime");function Do(e){let t=e.translations?.[e.lang??""],[n,r,o]=Vo(),[i,l,a]=Lo(n,e.action,{onSuccess:e.onSuccess,validation:e.config.validation.submit,translations:t}),s=e.config.validation.showError&&!l.success&&l.error,c=l.data??e.value;return(0,O.jsxs)(O.Fragment,{children:[s&&Qe(e.config.alert,u=>(0,O.jsx)("div",{className:"mb-4 w-full",children:(0,O.jsx)(u,{description:l.error?.description,details:l.error?.details,title:l.error.title})})),(0,O.jsx)(Sr,{action:i,config:e.config,control:e.children,definition:e.definition,isPending:a,noValidate:!0,readOnly:e.readOnly,sections:e.sections,children:({disabled:u,fields:g})=>(0,O.jsx)(Io,{disabled:u,fields:g,style:e.config.style,value:c,children:x=>(0,O.jsx)(qr,{...x,config:e.config,context:e.context,onMount:r,onUnmount:o,onValueChange:e.onValueChange,translations:t,value:c})})})]})}var Mo=require("jotai"),Ot=require("react/jsx-runtime");function _o(e){return(0,Ot.jsx)(Mo.Provider,{children:(0,Ot.jsx)(Do,{...e})})}
|