zova-module-a-form 5.1.50 → 5.1.52
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/component/form/controller.d.ts +14 -0
- package/dist/component/form/controller.d.ts.map +1 -1
- package/dist/component/formField/controller.d.ts +8 -0
- package/dist/component/formField/controller.d.ts.map +1 -1
- package/dist/index.js +757 -33
- package/dist/index.js.map +1 -1
- package/dist/lib/formLayout.d.ts.map +1 -1
- package/dist/lib/schemaRefresh.d.ts +40 -0
- package/dist/lib/schemaRefresh.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/component/form/controller.tsx +86 -1
- package/src/component/formField/controller.tsx +88 -13
- package/src/lib/formLayout.ts +0 -6
- package/src/lib/schemaRefresh.ts +751 -0
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import { catchError, celEnvBase, isEmptyObject, isNil } from "@cabloy/utils";
|
|
|
3
3
|
import { ZodMetadata } from "@cabloy/zod-openapi";
|
|
4
4
|
import { determineFormLevelErrorSourceAndValue, getBy, isGlobalFormValidationError, revalidateLogic, useField, useForm } from "@tanstack/vue-form";
|
|
5
5
|
import { useSelector } from "@tanstack/vue-store";
|
|
6
|
+
import { Fragment, createVNode, defineComponent, h, markRaw, nextTick } from "vue";
|
|
6
7
|
import { ZovaJsx, isJsxComponent } from "zova-jsx";
|
|
7
8
|
import { Controller, Render, Scope } from "zova-module-a-bean";
|
|
8
9
|
import { renderFormFieldTopPropsSystem } from "zova-module-a-openapi";
|
|
9
|
-
import { Fragment, createVNode, defineComponent, h, markRaw } from "vue";
|
|
10
10
|
//#region src/lib/beanControllerFormBase.ts
|
|
11
11
|
var BeanControllerFormBase = class extends BeanControllerBase {
|
|
12
12
|
constructor(...args) {
|
|
@@ -27,11 +27,600 @@ var BeanControllerFormBase = class extends BeanControllerBase {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
|
+
//#region src/lib/schemaRefresh.ts
|
|
31
|
+
var schemaMaps = /* @__PURE__ */ new Set([
|
|
32
|
+
"properties",
|
|
33
|
+
"patternProperties",
|
|
34
|
+
"$defs",
|
|
35
|
+
"definitions",
|
|
36
|
+
"dependentSchemas"
|
|
37
|
+
]);
|
|
38
|
+
var schemaArrays = /* @__PURE__ */ new Set([
|
|
39
|
+
"allOf",
|
|
40
|
+
"anyOf",
|
|
41
|
+
"oneOf",
|
|
42
|
+
"prefixItems"
|
|
43
|
+
]);
|
|
44
|
+
var schemaSingles = /* @__PURE__ */ new Set([
|
|
45
|
+
"items",
|
|
46
|
+
"additionalItems",
|
|
47
|
+
"additionalProperties",
|
|
48
|
+
"unevaluatedItems",
|
|
49
|
+
"unevaluatedProperties",
|
|
50
|
+
"contains",
|
|
51
|
+
"propertyNames",
|
|
52
|
+
"not",
|
|
53
|
+
"if",
|
|
54
|
+
"then",
|
|
55
|
+
"else",
|
|
56
|
+
"contentSchema"
|
|
57
|
+
]);
|
|
58
|
+
var restScenes = /* @__PURE__ */ new Set([
|
|
59
|
+
"table",
|
|
60
|
+
"form",
|
|
61
|
+
"form-view",
|
|
62
|
+
"form-create",
|
|
63
|
+
"filter"
|
|
64
|
+
]);
|
|
65
|
+
var restKeys = /* @__PURE__ */ new Set([
|
|
66
|
+
"schemaScene",
|
|
67
|
+
"fieldSource",
|
|
68
|
+
"visible",
|
|
69
|
+
"disableNotifyChanged",
|
|
70
|
+
"readonly",
|
|
71
|
+
"required",
|
|
72
|
+
"draft",
|
|
73
|
+
"order",
|
|
74
|
+
"align",
|
|
75
|
+
"width",
|
|
76
|
+
"fixed",
|
|
77
|
+
"enableSorting",
|
|
78
|
+
"sortDescFirst",
|
|
79
|
+
"render",
|
|
80
|
+
"options",
|
|
81
|
+
"class",
|
|
82
|
+
"style",
|
|
83
|
+
"placeholder",
|
|
84
|
+
"blocks",
|
|
85
|
+
"columnProps"
|
|
86
|
+
]);
|
|
87
|
+
var renderProps = /* @__PURE__ */ new Set([
|
|
88
|
+
"items",
|
|
89
|
+
"placeholder",
|
|
90
|
+
"readonly",
|
|
91
|
+
"required",
|
|
92
|
+
"name",
|
|
93
|
+
"type",
|
|
94
|
+
"options",
|
|
95
|
+
"class",
|
|
96
|
+
"style",
|
|
97
|
+
"relationName",
|
|
98
|
+
"imageScene",
|
|
99
|
+
"enableCrop",
|
|
100
|
+
"cropAspectRatio",
|
|
101
|
+
"resize",
|
|
102
|
+
"itemValue",
|
|
103
|
+
"itemTitle"
|
|
104
|
+
]);
|
|
105
|
+
var unsafeKeys = /* @__PURE__ */ new Set([
|
|
106
|
+
"__proto__",
|
|
107
|
+
"prototype",
|
|
108
|
+
"constructor"
|
|
109
|
+
]);
|
|
110
|
+
var opaqueSnapshots = /* @__PURE__ */ new WeakSet();
|
|
111
|
+
var opaqueIds = /* @__PURE__ */ new WeakMap();
|
|
112
|
+
var symbolIds = /* @__PURE__ */ new Map();
|
|
113
|
+
var nextOpaqueId = 0;
|
|
114
|
+
function opaqueId(value) {
|
|
115
|
+
let id = opaqueIds.get(value);
|
|
116
|
+
if (id === void 0) opaqueIds.set(value, id = ++nextOpaqueId);
|
|
117
|
+
return id;
|
|
118
|
+
}
|
|
119
|
+
/** Stable configuration signature without invoking getters or retaining caller values. */
|
|
120
|
+
function schemaRefreshFingerprint(value) {
|
|
121
|
+
function encode(item, ancestors = /* @__PURE__ */ new Set()) {
|
|
122
|
+
if (typeof item === "symbol") {
|
|
123
|
+
let id = symbolIds.get(item);
|
|
124
|
+
if (id === void 0) symbolIds.set(item, id = ++nextOpaqueId);
|
|
125
|
+
return ["symbol", id];
|
|
126
|
+
}
|
|
127
|
+
if (typeof item === "function") return ["opaque", opaqueId(item)];
|
|
128
|
+
if (typeof item === "bigint") return ["bigint", String(item)];
|
|
129
|
+
if (typeof item === "number" && !Number.isFinite(item)) return ["number", String(item)];
|
|
130
|
+
if (item === null || typeof item !== "object") return data(item);
|
|
131
|
+
if (ancestors.has(item)) return ["cycle", opaqueId(item)];
|
|
132
|
+
if (!Array.isArray(item) && !isRecord(item)) return ["opaque", opaqueId(item)];
|
|
133
|
+
const next = new Set(ancestors).add(item);
|
|
134
|
+
const descriptors = Object.getOwnPropertyDescriptors(item);
|
|
135
|
+
return [
|
|
136
|
+
Array.isArray(item) ? "array" : "object",
|
|
137
|
+
Object.keys(descriptors).sort().map((key) => {
|
|
138
|
+
const descriptor = descriptors[key];
|
|
139
|
+
return [
|
|
140
|
+
key,
|
|
141
|
+
descriptor.enumerable,
|
|
142
|
+
"value" in descriptor ? encode(descriptor.value, next) : [
|
|
143
|
+
"accessor",
|
|
144
|
+
descriptor.get && opaqueId(descriptor.get),
|
|
145
|
+
descriptor.set && opaqueId(descriptor.set)
|
|
146
|
+
]
|
|
147
|
+
];
|
|
148
|
+
}),
|
|
149
|
+
Object.getOwnPropertySymbols(item).map((key) => [encode(key), encode(Object.getOwnPropertyDescriptor(item, key)?.value, next)])
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
return JSON.stringify(encode(value));
|
|
153
|
+
}
|
|
154
|
+
var UnresolvedSchemaError = class extends Error {};
|
|
155
|
+
function isRecord(value) {
|
|
156
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
157
|
+
const prototype = Object.getPrototypeOf(value);
|
|
158
|
+
return prototype === null || prototype === Object.prototype;
|
|
159
|
+
}
|
|
160
|
+
function snapshot(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
161
|
+
if (value === null || value === void 0 || typeof value === "string" || typeof value === "boolean") return value;
|
|
162
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
163
|
+
if (typeof value === "function") {
|
|
164
|
+
const marker = { $opaqueRuntime: opaqueId(value) };
|
|
165
|
+
opaqueSnapshots.add(marker);
|
|
166
|
+
return marker;
|
|
167
|
+
}
|
|
168
|
+
if (typeof value !== "object" || ancestors.has(value)) throw new Error("Opaque metadata");
|
|
169
|
+
if (!Array.isArray(value) && !isRecord(value)) throw new Error("Opaque metadata");
|
|
170
|
+
if (Object.getOwnPropertySymbols(value).length) throw new Error("Opaque metadata");
|
|
171
|
+
const next = new Set(ancestors).add(value);
|
|
172
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
173
|
+
if (Array.isArray(value)) {
|
|
174
|
+
if (Object.keys(descriptors).length !== value.length + 1) throw new Error("Opaque array");
|
|
175
|
+
return Array.from({ length: value.length }, (_, index) => {
|
|
176
|
+
const descriptor = descriptors[index];
|
|
177
|
+
if (!descriptor || !descriptor.enumerable || !("value" in descriptor)) throw new Error("Opaque array");
|
|
178
|
+
return snapshot(descriptor.value, next);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const result = Object.create(null);
|
|
182
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
183
|
+
if (!descriptor.enumerable || !("value" in descriptor)) throw new Error("Opaque metadata");
|
|
184
|
+
result[key] = snapshot(descriptor.value, next);
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
function data(value) {
|
|
189
|
+
if (value === void 0) return ["undefined"];
|
|
190
|
+
if (value === null) return ["null"];
|
|
191
|
+
if (typeof value === "number") return ["number", Object.is(value, -0) ? "-0" : value];
|
|
192
|
+
if (typeof value === "string" || typeof value === "boolean") return [typeof value, value];
|
|
193
|
+
if (Array.isArray(value)) return ["array", value.map(data)];
|
|
194
|
+
if (isRecord(value)) return ["object", Object.keys(value).sort().map((key) => [key, data(value[key])])];
|
|
195
|
+
throw new Error("Opaque metadata");
|
|
196
|
+
}
|
|
197
|
+
function containsOpaque(value) {
|
|
198
|
+
if (!value || typeof value !== "object") return false;
|
|
199
|
+
if (opaqueSnapshots.has(value)) return true;
|
|
200
|
+
return Array.isArray(value) ? value.some(containsOpaque) : isRecord(value) && Object.values(value).some(containsOpaque);
|
|
201
|
+
}
|
|
202
|
+
function opaqueBehavior(value) {
|
|
203
|
+
if (typeof value === "string") return value.startsWith("cel://");
|
|
204
|
+
if (Array.isArray(value)) return value.some(opaqueBehavior);
|
|
205
|
+
if (!isRecord(value)) return false;
|
|
206
|
+
return Object.entries(value).some(([key, item]) => (key === "$$typeof" ? ![
|
|
207
|
+
"zova-jsx:component",
|
|
208
|
+
"zova-jsx:block",
|
|
209
|
+
"zova-jsx:actionRow",
|
|
210
|
+
"zova-jsx:actionBulk"
|
|
211
|
+
].includes(String(item)) : /^(?:on[A-Z]|effect|evaluate|expression|command|behavior|validator|slot|v-|\$)/i.test(key)) || opaqueBehavior(item));
|
|
212
|
+
}
|
|
213
|
+
var blockOptions = {
|
|
214
|
+
"basic-pageentry:blockPageEntry": [
|
|
215
|
+
"blocks",
|
|
216
|
+
"resource",
|
|
217
|
+
"id",
|
|
218
|
+
"formScene",
|
|
219
|
+
"pageTitleKey",
|
|
220
|
+
"draft"
|
|
221
|
+
],
|
|
222
|
+
"basic-pageentry:blockForm": ["blocks"],
|
|
223
|
+
"basic-form:blockFormLayout": ["formLayout"],
|
|
224
|
+
"basic-pageentry:blockToolbarRow": ["actions"]
|
|
225
|
+
};
|
|
226
|
+
function safeLayoutNode(value) {
|
|
227
|
+
if (!isRecord(value) || typeof value.type !== "string") return false;
|
|
228
|
+
const allowed = {
|
|
229
|
+
tabs: [
|
|
230
|
+
"type",
|
|
231
|
+
"id",
|
|
232
|
+
"children"
|
|
233
|
+
],
|
|
234
|
+
tab: [
|
|
235
|
+
"type",
|
|
236
|
+
"id",
|
|
237
|
+
"title",
|
|
238
|
+
"children"
|
|
239
|
+
],
|
|
240
|
+
group: [
|
|
241
|
+
"type",
|
|
242
|
+
"id",
|
|
243
|
+
"title",
|
|
244
|
+
"description",
|
|
245
|
+
"children"
|
|
246
|
+
],
|
|
247
|
+
section: [
|
|
248
|
+
"type",
|
|
249
|
+
"id",
|
|
250
|
+
"title",
|
|
251
|
+
"description",
|
|
252
|
+
"layout",
|
|
253
|
+
"columns",
|
|
254
|
+
"children"
|
|
255
|
+
],
|
|
256
|
+
field: [
|
|
257
|
+
"type",
|
|
258
|
+
"name",
|
|
259
|
+
"span"
|
|
260
|
+
]
|
|
261
|
+
}[value.type];
|
|
262
|
+
if (!allowed || Object.keys(value).some((key) => !allowed.includes(key))) return false;
|
|
263
|
+
if (value.title !== void 0 && typeof value.title !== "string") return false;
|
|
264
|
+
if (value.type === "field") return safeName(value.name);
|
|
265
|
+
return Array.isArray(value.children) && value.children.every(safeLayoutNode);
|
|
266
|
+
}
|
|
267
|
+
function safeLayout(value) {
|
|
268
|
+
return isRecord(value) && Object.keys(value).every((key) => key === "children") && Array.isArray(value.children) && value.children.every(safeLayoutNode);
|
|
269
|
+
}
|
|
270
|
+
function safeActions(value) {
|
|
271
|
+
return Array.isArray(value) && value.every((action) => {
|
|
272
|
+
if (!isRecord(action) || typeof action.render !== "string") return false;
|
|
273
|
+
if (Object.keys(action).some((key) => ![
|
|
274
|
+
"$$typeof",
|
|
275
|
+
"name",
|
|
276
|
+
"render",
|
|
277
|
+
"options"
|
|
278
|
+
].includes(key))) return false;
|
|
279
|
+
if (action.$$typeof !== void 0 && action.$$typeof !== "zova-jsx:actionRow") return false;
|
|
280
|
+
return action.options === void 0 || isRecord(action.options) && Object.keys(action.options).every((key) => [
|
|
281
|
+
"permission",
|
|
282
|
+
"class",
|
|
283
|
+
"style"
|
|
284
|
+
].includes(key));
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
function safeBlocks(value) {
|
|
288
|
+
return Array.isArray(value) && value.every((block) => {
|
|
289
|
+
if (!isRecord(block) || typeof block.render !== "string") return false;
|
|
290
|
+
if (Object.keys(block).some((key) => ![
|
|
291
|
+
"$$typeof",
|
|
292
|
+
"render",
|
|
293
|
+
"options"
|
|
294
|
+
].includes(key))) return false;
|
|
295
|
+
if (block.$$typeof !== void 0 && block.$$typeof !== "zova-jsx:block") return false;
|
|
296
|
+
const allowed = blockOptions[block.render];
|
|
297
|
+
if (!allowed) return false;
|
|
298
|
+
if (block.options === void 0) return true;
|
|
299
|
+
if (!isRecord(block.options)) return false;
|
|
300
|
+
return Object.entries(block.options).every(([key, item]) => {
|
|
301
|
+
if (!allowed.includes(key) && !["class", "style"].includes(key)) return false;
|
|
302
|
+
if (key === "blocks") return safeBlocks(item);
|
|
303
|
+
if (key === "formLayout") return safeLayout(item);
|
|
304
|
+
if (key === "actions") return safeActions(item);
|
|
305
|
+
return true;
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function normalizeLayoutNode(value) {
|
|
310
|
+
if (!isRecord(value)) return value;
|
|
311
|
+
const result = { ...value };
|
|
312
|
+
if ([
|
|
313
|
+
"tab",
|
|
314
|
+
"group",
|
|
315
|
+
"section"
|
|
316
|
+
].includes(String(value.type)) && typeof value.title === "string") result.title = "";
|
|
317
|
+
if (Array.isArray(value.children)) result.children = value.children.map(normalizeLayoutNode);
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
function normalizeBlocks(value) {
|
|
321
|
+
if (!Array.isArray(value)) return value;
|
|
322
|
+
return value.map((block) => {
|
|
323
|
+
if (!isRecord(block) || !isRecord(block.options)) return block;
|
|
324
|
+
const options = { ...block.options };
|
|
325
|
+
if (Object.hasOwn(options, "blocks")) options.blocks = normalizeBlocks(options.blocks);
|
|
326
|
+
if (block.render === "basic-form:blockFormLayout" && safeLayout(options.formLayout)) options.formLayout = { children: options.formLayout.children.map(normalizeLayoutNode) };
|
|
327
|
+
return {
|
|
328
|
+
...block,
|
|
329
|
+
options
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function normalizeAncestorRest(value) {
|
|
334
|
+
if (!isRecord(value)) return value;
|
|
335
|
+
const result = { ...value };
|
|
336
|
+
for (const [key, item] of Object.entries(value)) if (key === "blocks" && safeBlocks(item)) result[key] = normalizeBlocks(item);
|
|
337
|
+
else if (restScenes.has(key)) result[key] = normalizeAncestorRest(item);
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
function safeRest(value) {
|
|
341
|
+
if (value === void 0 || value === null) return true;
|
|
342
|
+
if (!isRecord(value) || opaqueBehavior(value)) return false;
|
|
343
|
+
return Object.entries(value).every(([key, item]) => {
|
|
344
|
+
if (restScenes.has(key)) return safeRest(item);
|
|
345
|
+
if (!restKeys.has(key)) return false;
|
|
346
|
+
if (item === void 0 || item === null) return true;
|
|
347
|
+
if ([
|
|
348
|
+
"visible",
|
|
349
|
+
"disableNotifyChanged",
|
|
350
|
+
"readonly",
|
|
351
|
+
"required",
|
|
352
|
+
"draft",
|
|
353
|
+
"enableSorting",
|
|
354
|
+
"sortDescFirst"
|
|
355
|
+
].includes(key)) return typeof item === "boolean";
|
|
356
|
+
if (["order", "width"].includes(key)) return typeof item === "number";
|
|
357
|
+
if ([
|
|
358
|
+
"schemaScene",
|
|
359
|
+
"fieldSource",
|
|
360
|
+
"align",
|
|
361
|
+
"fixed",
|
|
362
|
+
"placeholder",
|
|
363
|
+
"class"
|
|
364
|
+
].includes(key)) return typeof item === "string";
|
|
365
|
+
if (key === "style") return isRecord(item);
|
|
366
|
+
if (key === "blocks") return safeBlocks(item);
|
|
367
|
+
if (key === "options" || key === "columnProps") return isRecord(item) && Object.keys(item).every((part) => renderProps.has(part));
|
|
368
|
+
if (key !== "render" || typeof item === "string") return true;
|
|
369
|
+
if (!isRecord(item) || typeof item.type !== "string") return false;
|
|
370
|
+
if (Object.keys(item).some((part) => ![
|
|
371
|
+
"$$typeof",
|
|
372
|
+
"type",
|
|
373
|
+
"props",
|
|
374
|
+
"key",
|
|
375
|
+
"children"
|
|
376
|
+
].includes(part))) return false;
|
|
377
|
+
return item.props === void 0 || isRecord(item.props) && Object.keys(item.props).every((part) => renderProps.has(part));
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
function safeName(value) {
|
|
381
|
+
return typeof value === "string" && value.split(".").every((part) => !!part && !unsafeKeys.has(part));
|
|
382
|
+
}
|
|
383
|
+
/** Compile detached comparison facts from schema truth and SDK-canonical effective fields. */
|
|
384
|
+
function createSchemaRefreshContract(schema, properties, resolveSchema) {
|
|
385
|
+
if (schema === void 0 || schema === null || properties === void 0) return {
|
|
386
|
+
ready: false,
|
|
387
|
+
fields: {}
|
|
388
|
+
};
|
|
389
|
+
const resolvedInputs = /* @__PURE__ */ new Map();
|
|
390
|
+
try {
|
|
391
|
+
const root = snapshot(schema);
|
|
392
|
+
const effective = snapshot(properties);
|
|
393
|
+
if (!isRecord(root) || !Array.isArray(effective)) throw new Error("Schema unavailable");
|
|
394
|
+
const targets = /* @__PURE__ */ new Map();
|
|
395
|
+
let eligible = true;
|
|
396
|
+
const ancestorsRest = [];
|
|
397
|
+
const ancestorsRestRaw = [];
|
|
398
|
+
const detailNames = /* @__PURE__ */ new Set();
|
|
399
|
+
for (const property of effective) {
|
|
400
|
+
if (!isRecord(property) || !isRecord(property.rest)) continue;
|
|
401
|
+
const rest = property.rest;
|
|
402
|
+
const form = isRecord(rest.form) ? rest.form : void 0;
|
|
403
|
+
const render = rest.render ?? form?.render;
|
|
404
|
+
if ((isRecord(render) ? render.type : render) !== "basic-details:formFieldDetails") continue;
|
|
405
|
+
for (const name of [
|
|
406
|
+
property.key,
|
|
407
|
+
property.schemaKey,
|
|
408
|
+
...Array.isArray(property.schemaKeys) ? property.schemaKeys : []
|
|
409
|
+
]) if (typeof name === "string") detailNames.add(name);
|
|
410
|
+
}
|
|
411
|
+
const auxiliaryDetails = /* @__PURE__ */ new Set();
|
|
412
|
+
for (const property of effective) {
|
|
413
|
+
if (!isRecord(property) || typeof property.key !== "string" || !property.key.startsWith("_") || !detailNames.has(property.key.slice(1)) || !isRecord(property.rest) || property.rest.visible !== false || !(property.type === "array" || Array.isArray(property.type) && property.type.length === 2 && property.type.includes("array") && property.type.includes("null")) || !isRecord(property.items) || typeof property.items.$ref !== "string") continue;
|
|
414
|
+
auxiliaryDetails.add(property.key);
|
|
415
|
+
}
|
|
416
|
+
for (const name of auxiliaryDetails) detailNames.add(name);
|
|
417
|
+
let localEligible = true;
|
|
418
|
+
function insideDetails(path) {
|
|
419
|
+
return path[0] === "fields" ? detailNames.has(path[1]) && path.slice(2).some((part) => schemaMaps.has(part) || schemaSingles.has(part) || schemaArrays.has(part)) : path[0] === "properties" && detailNames.has(path[1]) && path.slice(2).some((part) => schemaMaps.has(part) || schemaSingles.has(part) || schemaArrays.has(part));
|
|
420
|
+
}
|
|
421
|
+
function target(ref) {
|
|
422
|
+
if (targets.has(ref)) return targets.get(ref);
|
|
423
|
+
let resolved = resolveSchema(ref);
|
|
424
|
+
if (resolved === void 0 && ref.startsWith("#/")) {
|
|
425
|
+
resolved = root;
|
|
426
|
+
for (const part of ref.slice(2).split("/")) {
|
|
427
|
+
const key = decodeURIComponent(part).replace(/~1/g, "/").replace(/~0/g, "~");
|
|
428
|
+
resolved = isRecord(resolved) && Object.hasOwn(resolved, key) ? resolved[key] : void 0;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (resolved === void 0) throw new UnresolvedSchemaError("Unresolved reference");
|
|
432
|
+
resolvedInputs.set(ref, resolved);
|
|
433
|
+
const detached = snapshot(resolved);
|
|
434
|
+
targets.set(ref, detached);
|
|
435
|
+
return detached;
|
|
436
|
+
}
|
|
437
|
+
function project(node, normalized, includeRest, refs = /* @__PURE__ */ new Set(), path = [], collect = false) {
|
|
438
|
+
if (typeof node === "boolean") return ["schema", data(node)];
|
|
439
|
+
if (!isRecord(node)) throw new Error("Invalid schema node");
|
|
440
|
+
if (collect && Object.hasOwn(node, "rest")) {
|
|
441
|
+
const safe = safeRest(node.rest);
|
|
442
|
+
if (insideDetails(path)) {
|
|
443
|
+
if (path[0] === "fields") localEligible &&= safe;
|
|
444
|
+
} else eligible &&= safe;
|
|
445
|
+
if (!insideDetails(path) && (path.length === 0 || path[0] !== "fields" && [
|
|
446
|
+
"properties",
|
|
447
|
+
"patternProperties",
|
|
448
|
+
"items",
|
|
449
|
+
"prefixItems",
|
|
450
|
+
"additionalProperties"
|
|
451
|
+
].some((key) => Object.hasOwn(node, key)))) {
|
|
452
|
+
ancestorsRestRaw.push([path, data(node.rest)]);
|
|
453
|
+
ancestorsRest.push([path, data(normalizeAncestorRest(node.rest))]);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
const entries = [];
|
|
457
|
+
for (const key of Object.keys(node).sort()) {
|
|
458
|
+
const value = node[key];
|
|
459
|
+
if (key === "rest" && !includeRest) continue;
|
|
460
|
+
let projected;
|
|
461
|
+
if (key === "$ref") {
|
|
462
|
+
if (typeof value !== "string" || refs.has(value)) throw new Error("Cyclic reference");
|
|
463
|
+
projected = [
|
|
464
|
+
"reference",
|
|
465
|
+
value,
|
|
466
|
+
project(target(value), normalized, includeRest, new Set(refs).add(value), [...path, key], collect)
|
|
467
|
+
];
|
|
468
|
+
} else if (normalized && (key === "title" || key === "description") && typeof value === "string") projected = ["display"];
|
|
469
|
+
else if (normalized && key === "errorMessage" && isRecord(value)) projected = ["messages", Object.keys(value).sort().map((part) => [part, typeof value[part] === "string" ? ["display"] : data(value[part])])];
|
|
470
|
+
else if (schemaMaps.has(key)) {
|
|
471
|
+
if (!isRecord(value)) throw new Error("Invalid schema map");
|
|
472
|
+
projected = ["map", Object.keys(value).sort().map((part) => [part, project(value[part], normalized, includeRest, refs, [
|
|
473
|
+
...path,
|
|
474
|
+
key,
|
|
475
|
+
part
|
|
476
|
+
], collect)])];
|
|
477
|
+
} else if (schemaArrays.has(key) || key === "items" && Array.isArray(value)) {
|
|
478
|
+
if (!Array.isArray(value)) throw new Error("Invalid schema array");
|
|
479
|
+
projected = ["schemas", value.map((item, index) => project(item, normalized, includeRest, refs, [
|
|
480
|
+
...path,
|
|
481
|
+
key,
|
|
482
|
+
String(index)
|
|
483
|
+
], collect))];
|
|
484
|
+
} else if (schemaSingles.has(key)) projected = project(value, normalized, includeRest, refs, [...path, key], collect);
|
|
485
|
+
else if (key === "dependencies") {
|
|
486
|
+
if (!isRecord(value)) throw new Error("Invalid dependencies");
|
|
487
|
+
projected = ["dependencies", Object.keys(value).sort().map((part) => [part, Array.isArray(value[part]) ? data(value[part]) : project(value[part], normalized, includeRest, refs, [
|
|
488
|
+
...path,
|
|
489
|
+
key,
|
|
490
|
+
part
|
|
491
|
+
], collect)])];
|
|
492
|
+
} else {
|
|
493
|
+
if (collect && key !== "rest" && containsOpaque(value)) {
|
|
494
|
+
if (insideDetails(path)) {
|
|
495
|
+
if (path[0] === "fields") localEligible = false;
|
|
496
|
+
} else eligible = false;
|
|
497
|
+
}
|
|
498
|
+
projected = data(value);
|
|
499
|
+
}
|
|
500
|
+
entries.push([key, projected]);
|
|
501
|
+
}
|
|
502
|
+
return ["schema", entries];
|
|
503
|
+
}
|
|
504
|
+
const validationRaw = JSON.stringify(project(root, false, false, /* @__PURE__ */ new Set(), [], true));
|
|
505
|
+
const validation = JSON.stringify(project(root, true, false));
|
|
506
|
+
const fields = {};
|
|
507
|
+
for (const property of effective) {
|
|
508
|
+
if (!isRecord(property) || !safeName(property.key) || Object.hasOwn(fields, property.key)) throw new Error("Invalid canonical field");
|
|
509
|
+
if (property.schemaKey !== void 0 && !safeName(property.schemaKey) || property.schemaKeys !== void 0 && (!Array.isArray(property.schemaKeys) || !property.schemaKeys.every(safeName))) throw new Error("Invalid field alias");
|
|
510
|
+
localEligible = true;
|
|
511
|
+
const raw = JSON.stringify(project(property, false, true, /* @__PURE__ */ new Set(), ["fields", property.key], true));
|
|
512
|
+
const compatible = JSON.stringify(project(property, true, true));
|
|
513
|
+
fields[property.key] = {
|
|
514
|
+
raw,
|
|
515
|
+
compatible,
|
|
516
|
+
eligible: localEligible
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
for (const field of Object.values(fields)) field.eligible &&= eligible;
|
|
520
|
+
return {
|
|
521
|
+
ready: true,
|
|
522
|
+
validation,
|
|
523
|
+
validationRaw,
|
|
524
|
+
fields,
|
|
525
|
+
behavior: JSON.stringify([eligible, ancestorsRest]),
|
|
526
|
+
behaviorRaw: JSON.stringify([eligible, ancestorsRestRaw])
|
|
527
|
+
};
|
|
528
|
+
} catch (error) {
|
|
529
|
+
if (error instanceof UnresolvedSchemaError) return {
|
|
530
|
+
ready: false,
|
|
531
|
+
fields: {}
|
|
532
|
+
};
|
|
533
|
+
const raw = schemaRefreshFingerprint([schema, [...resolvedInputs.entries()]]);
|
|
534
|
+
const fields = {};
|
|
535
|
+
if (Array.isArray(properties)) for (const property of properties) {
|
|
536
|
+
if (!isRecord(property)) continue;
|
|
537
|
+
const descriptor = Object.getOwnPropertyDescriptor(property, "key");
|
|
538
|
+
if (!descriptor || !("value" in descriptor) || !safeName(descriptor.value)) continue;
|
|
539
|
+
const fieldRaw = schemaRefreshFingerprint(property);
|
|
540
|
+
fields[descriptor.value] = {
|
|
541
|
+
raw: fieldRaw,
|
|
542
|
+
compatible: fieldRaw,
|
|
543
|
+
eligible: false
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
return {
|
|
547
|
+
ready: true,
|
|
548
|
+
validation: raw,
|
|
549
|
+
validationRaw: raw,
|
|
550
|
+
fields,
|
|
551
|
+
behavior: raw
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
/** Owns comparison facts only, never form values, errors, or schema facade references. */
|
|
556
|
+
var SchemaRefreshTracker = class {
|
|
557
|
+
constructor() {
|
|
558
|
+
this.facts = /* @__PURE__ */ new Map();
|
|
559
|
+
}
|
|
560
|
+
has(name) {
|
|
561
|
+
return this.facts.has(name);
|
|
562
|
+
}
|
|
563
|
+
clear() {
|
|
564
|
+
this.facts.clear();
|
|
565
|
+
}
|
|
566
|
+
prune(contract) {
|
|
567
|
+
if (!contract.ready) return;
|
|
568
|
+
for (const [name, facts] of this.facts) if (facts.fieldRaw !== void 0 && !Object.hasOwn(contract.fields, name)) this.facts.delete(name);
|
|
569
|
+
}
|
|
570
|
+
consume(name, context) {
|
|
571
|
+
if (!context.contract.ready) return {
|
|
572
|
+
changed: false,
|
|
573
|
+
preserve: false
|
|
574
|
+
};
|
|
575
|
+
const { contract, ...scope } = context;
|
|
576
|
+
const field = contract.fields[name];
|
|
577
|
+
const next = {
|
|
578
|
+
...scope,
|
|
579
|
+
validation: contract.validation,
|
|
580
|
+
validationRaw: contract.validationRaw ?? contract.validation,
|
|
581
|
+
behavior: contract.behavior,
|
|
582
|
+
behaviorRaw: contract.behaviorRaw ?? contract.behavior,
|
|
583
|
+
fieldRaw: field?.raw,
|
|
584
|
+
fieldCompatible: field?.compatible,
|
|
585
|
+
fieldEligible: field?.eligible === true
|
|
586
|
+
};
|
|
587
|
+
const previous = this.facts.get(name);
|
|
588
|
+
this.facts.set(name, next);
|
|
589
|
+
if (!previous) return {
|
|
590
|
+
changed: false,
|
|
591
|
+
preserve: false
|
|
592
|
+
};
|
|
593
|
+
const changed = [
|
|
594
|
+
"locale",
|
|
595
|
+
"identity",
|
|
596
|
+
"scene",
|
|
597
|
+
"configuration",
|
|
598
|
+
"enabled",
|
|
599
|
+
"eligible",
|
|
600
|
+
"validationRaw",
|
|
601
|
+
"behaviorRaw",
|
|
602
|
+
"fieldRaw",
|
|
603
|
+
"fieldEligible"
|
|
604
|
+
].some((key) => previous[key] !== next[key]);
|
|
605
|
+
return {
|
|
606
|
+
changed,
|
|
607
|
+
preserve: changed && previous.locale !== next.locale && next.identity !== void 0 && previous.identity === next.identity && previous.epoch === next.epoch && previous.scene === next.scene && previous.configuration === next.configuration && previous.enabled && next.enabled && previous.eligible && next.eligible && previous.fieldEligible && next.fieldEligible && previous.validation === next.validation && previous.behavior === next.behavior && previous.fieldCompatible === next.fieldCompatible
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
//#endregion
|
|
30
612
|
//#region src/types/formField.ts
|
|
31
613
|
var constFieldProps = "$$FieldProps";
|
|
32
614
|
//#endregion
|
|
33
615
|
//#region src/component/form/controller.tsx
|
|
34
|
-
var _dec$6
|
|
616
|
+
var _dec$6;
|
|
617
|
+
var _dec2$6;
|
|
618
|
+
var _dec3$3;
|
|
619
|
+
var _dec4$3;
|
|
620
|
+
var _class$6;
|
|
621
|
+
var _class2$3;
|
|
622
|
+
var _descriptor$3;
|
|
623
|
+
var _ControllerForm;
|
|
35
624
|
function _initializerDefineProperty$3(e, i, r, l) {
|
|
36
625
|
r && Object.defineProperty(e, i, {
|
|
37
626
|
enumerable: r.enumerable,
|
|
@@ -57,6 +646,11 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
57
646
|
this.properties = void 0;
|
|
58
647
|
this.zovaJsx = void 0;
|
|
59
648
|
this.fieldCelEnv = void 0;
|
|
649
|
+
this.schemaRefresh = void 0;
|
|
650
|
+
this._schemaRefreshTracker = markRaw(new SchemaRefreshTracker());
|
|
651
|
+
this._schemaRefreshEpoch = 0;
|
|
652
|
+
this._schemaRefreshPending = false;
|
|
653
|
+
this._schemaRefreshDisposed = false;
|
|
60
654
|
_initializerDefineProperty$3(this, "$$scopeOpenapi", _descriptor$3, this);
|
|
61
655
|
}
|
|
62
656
|
async __init__() {
|
|
@@ -76,9 +670,38 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
76
670
|
this.properties = this.$computed(() => {
|
|
77
671
|
return this.$sdk.loadSchemaProperties(this.schema, this.$props.schemaScene);
|
|
78
672
|
});
|
|
673
|
+
this.schemaRefresh = this.$computed(() => {
|
|
674
|
+
const locale = this.app.meta.locale.current;
|
|
675
|
+
const schema = this.schema;
|
|
676
|
+
const policy = this.$props.localePresentationRefresh;
|
|
677
|
+
const contract = schema ? createSchemaRefreshContract(schema, this.properties ?? [], (reference) => {
|
|
678
|
+
return this.$sdk.getSchema(reference).data;
|
|
679
|
+
}) : {
|
|
680
|
+
ready: !policy,
|
|
681
|
+
fields: {}
|
|
682
|
+
};
|
|
683
|
+
if (schema && this.$sdk.selector !== locale) contract.ready = false;
|
|
684
|
+
return {
|
|
685
|
+
locale,
|
|
686
|
+
identity: policy?.identity,
|
|
687
|
+
epoch: this._schemaRefreshEpoch,
|
|
688
|
+
scene: schemaRefreshFingerprint([
|
|
689
|
+
this.$props.schemaScene,
|
|
690
|
+
this.formMeta,
|
|
691
|
+
this.formProvider,
|
|
692
|
+
this.$props.zodSchema,
|
|
693
|
+
this.$props.validateOnDynamic,
|
|
694
|
+
this.$props.validateOnDynamicLogic
|
|
695
|
+
]),
|
|
696
|
+
enabled: !!policy && !this.$props.zodSchema,
|
|
697
|
+
contract
|
|
698
|
+
};
|
|
699
|
+
});
|
|
700
|
+
this.$watch(() => this.schemaRefresh.contract, (contract) => this._schemaRefreshTracker.prune(contract), { flush: "sync" });
|
|
79
701
|
this.fieldCelEnv = this._getFieldCelEnv();
|
|
80
702
|
this.zovaJsx = this.bean._newBeanSimple(ZovaJsx, false, this.formProvider.components, this.fieldCelEnv);
|
|
81
703
|
this.$watch(() => this.$props.data, (newValue, oldValue) => {
|
|
704
|
+
++this._schemaRefreshEpoch;
|
|
82
705
|
if (deepEqual(newValue, oldValue)) return;
|
|
83
706
|
this.reset(this.$props.data);
|
|
84
707
|
});
|
|
@@ -90,7 +713,34 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
90
713
|
});
|
|
91
714
|
return !error && this.formState.isValid;
|
|
92
715
|
}
|
|
716
|
+
__dispose__() {
|
|
717
|
+
this._schemaRefreshDisposed = true;
|
|
718
|
+
++this._schemaRefreshEpoch;
|
|
719
|
+
this._schemaRefreshTracker.clear();
|
|
720
|
+
}
|
|
721
|
+
hasSchemaRefresh(name) {
|
|
722
|
+
return this._schemaRefreshTracker.has(name);
|
|
723
|
+
}
|
|
724
|
+
consumeSchemaRefresh(name, configuration, eligible) {
|
|
725
|
+
return this._schemaRefreshTracker.consume(name, {
|
|
726
|
+
...this.schemaRefresh,
|
|
727
|
+
configuration,
|
|
728
|
+
eligible
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
schemaFieldRefreshed() {
|
|
732
|
+
if (this._schemaRefreshPending || !this.$props.onSchemaRefreshed) return;
|
|
733
|
+
this._schemaRefreshPending = true;
|
|
734
|
+
const epoch = this._schemaRefreshEpoch;
|
|
735
|
+
const locale = this.app.meta.locale.current;
|
|
736
|
+
const { identity, scene } = this.schemaRefresh;
|
|
737
|
+
nextTick(() => {
|
|
738
|
+
this._schemaRefreshPending = false;
|
|
739
|
+
if (!this._schemaRefreshDisposed && epoch === this._schemaRefreshEpoch && locale === this.app.meta.locale.current && identity === this.schemaRefresh.identity && scene === this.schemaRefresh.scene && this.schemaRefresh.contract.ready) this.$props.onSchemaRefreshed?.(this.form.state.values);
|
|
740
|
+
});
|
|
741
|
+
}
|
|
93
742
|
reset(values, opts) {
|
|
743
|
+
++this._schemaRefreshEpoch;
|
|
94
744
|
this.form.reset(values ?? {}, opts);
|
|
95
745
|
return this.form.state.values;
|
|
96
746
|
}
|
|
@@ -183,9 +833,10 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
183
833
|
for (const key of keys) {
|
|
184
834
|
const value = rest[key];
|
|
185
835
|
let keyValue;
|
|
186
|
-
if (key === "render")
|
|
187
|
-
|
|
188
|
-
|
|
836
|
+
if (key === "render") {
|
|
837
|
+
if (typeof value === "string") keyValue = this.zovaJsx.evaluateExpression(value, celScope);
|
|
838
|
+
else keyValue = value;
|
|
839
|
+
} else keyValue = this.zovaJsx.renderJsxOrCel(value, void 0, celScope, jsxRenderContext);
|
|
189
840
|
props[key] = keyValue;
|
|
190
841
|
}
|
|
191
842
|
if (isJsxComponent(props.render) && this.isComponentFormField(props.render.type) && !isEmptyObject(props.render.props)) {
|
|
@@ -374,7 +1025,17 @@ function getErrorMapKey(cause) {
|
|
|
374
1025
|
}
|
|
375
1026
|
//#endregion
|
|
376
1027
|
//#region src/component/formField/controller.tsx
|
|
377
|
-
var _dec$5
|
|
1028
|
+
var _dec$5;
|
|
1029
|
+
var _dec2$5;
|
|
1030
|
+
var _dec3$2;
|
|
1031
|
+
var _dec4$2;
|
|
1032
|
+
var _dec5;
|
|
1033
|
+
var _dec6;
|
|
1034
|
+
var _class$5;
|
|
1035
|
+
var _class2$2;
|
|
1036
|
+
var _descriptor$2;
|
|
1037
|
+
var _descriptor2;
|
|
1038
|
+
var _ControllerFormField;
|
|
378
1039
|
function _initializerDefineProperty$2(e, i, r, l) {
|
|
379
1040
|
r && Object.defineProperty(e, i, {
|
|
380
1041
|
enumerable: r.enumerable,
|
|
@@ -395,6 +1056,11 @@ var ControllerFormField = (_dec$5 = Controller(), _dec2$5 = BeanInfo({ module: "
|
|
|
395
1056
|
constructor(...args) {
|
|
396
1057
|
super(...args);
|
|
397
1058
|
this._formField = void 0;
|
|
1059
|
+
this._initialized = false;
|
|
1060
|
+
this._mounted = false;
|
|
1061
|
+
this._disposed = false;
|
|
1062
|
+
this._readyNotified = false;
|
|
1063
|
+
this._remount = false;
|
|
398
1064
|
this.propsBucket = void 0;
|
|
399
1065
|
_initializerDefineProperty$2(this, "$$form", _descriptor$2, this);
|
|
400
1066
|
_initializerDefineProperty$2(this, "$$beanBehaviorsHolder", _descriptor2, this);
|
|
@@ -402,17 +1068,16 @@ var ControllerFormField = (_dec$5 = Controller(), _dec2$5 = BeanInfo({ module: "
|
|
|
402
1068
|
async __init__() {
|
|
403
1069
|
if (!this.$$form) throw new Error(`FormField component should be used in Form component: ${this.name}`);
|
|
404
1070
|
this.bean._setBean("$$formField", this);
|
|
1071
|
+
this._remount = this.$$form.hasSchemaRefresh(this.name);
|
|
405
1072
|
this._formField = this._createField();
|
|
406
1073
|
this.propsBucket = this.$computed(() => {
|
|
407
1074
|
return this._getPropsBucket();
|
|
408
1075
|
});
|
|
409
|
-
this.$
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
this._formField.api.update(options);
|
|
413
|
-
this.form.resetField(this.name);
|
|
414
|
-
this.$props.onFieldStateReady?.(this);
|
|
1076
|
+
this.$controllerMounted(() => {
|
|
1077
|
+
this._mounted = true;
|
|
1078
|
+
this._refreshField();
|
|
415
1079
|
});
|
|
1080
|
+
this.$watch(() => [this.$$form.schemaRefresh, this._getRefreshConfiguration()], () => this._refreshField(), { flush: "post" });
|
|
416
1081
|
await this.$$beanBehaviorsHolder.initialize({
|
|
417
1082
|
behaviorTag: void 0,
|
|
418
1083
|
behaviors: () => {
|
|
@@ -423,7 +1088,51 @@ var ControllerFormField = (_dec$5 = Controller(), _dec2$5 = BeanInfo({ module: "
|
|
|
423
1088
|
if (newValue === oldValue) return;
|
|
424
1089
|
this.$props.onEffect?.(newValue);
|
|
425
1090
|
});
|
|
426
|
-
this
|
|
1091
|
+
this._initialized = true;
|
|
1092
|
+
this._refreshField();
|
|
1093
|
+
}
|
|
1094
|
+
__dispose__() {
|
|
1095
|
+
this._disposed = true;
|
|
1096
|
+
}
|
|
1097
|
+
_getRefreshConfiguration() {
|
|
1098
|
+
const props = this.$props;
|
|
1099
|
+
return schemaRefreshFingerprint([
|
|
1100
|
+
props.name,
|
|
1101
|
+
props.render,
|
|
1102
|
+
props.options,
|
|
1103
|
+
props.readonly,
|
|
1104
|
+
props.required,
|
|
1105
|
+
props.sys,
|
|
1106
|
+
props.validators,
|
|
1107
|
+
props.behaviors,
|
|
1108
|
+
!!props.onEffect,
|
|
1109
|
+
!!props.slotDefault
|
|
1110
|
+
]);
|
|
1111
|
+
}
|
|
1112
|
+
_refreshField() {
|
|
1113
|
+
if (!this._initialized || this._disposed || process.env.CLIENT && this._remount && !this._mounted || !this.$$form.schemaRefresh.contract.ready) return;
|
|
1114
|
+
const props = this.$props;
|
|
1115
|
+
const inputBindingSlot = props["$$FieldProps"] === true && (props.render ? this.$$form.getRenderProvider(props.render) : this.formProvider.components?.Input) === "basic-input:formFieldInput";
|
|
1116
|
+
const eligible = !props.sys && !props.behaviors && !props.onEffect && (!props.slotDefault || inputBindingSlot) && Object.values(props.validators ?? {}).every((value) => typeof value === "boolean");
|
|
1117
|
+
const refresh = this.$$form.consumeSchemaRefresh(this.name, this._getRefreshConfiguration(), eligible);
|
|
1118
|
+
if (refresh.changed) {
|
|
1119
|
+
const value = this.form.getFieldValue(this.name);
|
|
1120
|
+
this.field.api.update(this._getFormFieldOptions());
|
|
1121
|
+
this.form.resetField(this.name);
|
|
1122
|
+
if (refresh.preserve) {
|
|
1123
|
+
this.form.setFieldValue(this.name, value, {
|
|
1124
|
+
dontUpdateMeta: true,
|
|
1125
|
+
dontRunListeners: true,
|
|
1126
|
+
dontValidate: true
|
|
1127
|
+
});
|
|
1128
|
+
this.field.api.validateSync("change", {});
|
|
1129
|
+
}
|
|
1130
|
+
} else if (this._remount && !this._readyNotified) this.field.api.update(this._getFormFieldOptions());
|
|
1131
|
+
if (refresh.changed || !this._readyNotified) {
|
|
1132
|
+
this._readyNotified = true;
|
|
1133
|
+
this.$props.onFieldStateReady?.(this);
|
|
1134
|
+
}
|
|
1135
|
+
if (refresh.changed) this.$$form.schemaFieldRefreshed();
|
|
427
1136
|
}
|
|
428
1137
|
get form() {
|
|
429
1138
|
return this.$$form.form;
|
|
@@ -471,7 +1180,9 @@ var ControllerFormField = (_dec$5 = Controller(), _dec2$5 = BeanInfo({ module: "
|
|
|
471
1180
|
};
|
|
472
1181
|
}
|
|
473
1182
|
_createField() {
|
|
474
|
-
const
|
|
1183
|
+
const options = this._getFormFieldOptions();
|
|
1184
|
+
if (this._remount) delete options.defaultValue;
|
|
1185
|
+
const field = markRaw(useField(options));
|
|
475
1186
|
const fieldState = useSelector(field.api.store, (state) => state);
|
|
476
1187
|
return {
|
|
477
1188
|
api: field.api,
|
|
@@ -535,7 +1246,8 @@ var ControllerFormField = (_dec$5 = Controller(), _dec2$5 = BeanInfo({ module: "
|
|
|
535
1246
|
behaviors[behaviorFormFieldLayout] = {};
|
|
536
1247
|
}
|
|
537
1248
|
_getFormFieldOptions() {
|
|
538
|
-
const
|
|
1249
|
+
const value = this.$$form.getFieldValue(this.name);
|
|
1250
|
+
const defaultValue = isNil(value) ? this.$props.sys?.defaultValue ?? this.property?.default : void 0;
|
|
539
1251
|
const validators = this._getFormFieldOptionsValidators();
|
|
540
1252
|
return Object.assign({ defaultValue }, this.$props.sys, {
|
|
541
1253
|
name: this.name,
|
|
@@ -574,7 +1286,14 @@ function _normalizeValidateSchema(validateSchema, zodSchemaField) {
|
|
|
574
1286
|
}
|
|
575
1287
|
//#endregion
|
|
576
1288
|
//#region src/component/formFieldBlank/controller.tsx
|
|
577
|
-
var _dec$4
|
|
1289
|
+
var _dec$4;
|
|
1290
|
+
var _dec2$4;
|
|
1291
|
+
var _dec3$1;
|
|
1292
|
+
var _dec4$1;
|
|
1293
|
+
var _class$4;
|
|
1294
|
+
var _class2$1;
|
|
1295
|
+
var _descriptor$1;
|
|
1296
|
+
var _ControllerFormFieldBlank;
|
|
578
1297
|
function _initializerDefineProperty$1(e, i, r, l) {
|
|
579
1298
|
r && Object.defineProperty(e, i, {
|
|
580
1299
|
enumerable: r.enumerable,
|
|
@@ -611,7 +1330,14 @@ var ControllerFormFieldBlank = (_dec$4 = Controller(), _dec2$4 = BeanInfo({ modu
|
|
|
611
1330
|
}), _class2$1)) || _class$4) || _class$4);
|
|
612
1331
|
//#endregion
|
|
613
1332
|
//#region src/component/formFieldPreset/controller.tsx
|
|
614
|
-
var _dec$3
|
|
1333
|
+
var _dec$3;
|
|
1334
|
+
var _dec2$3;
|
|
1335
|
+
var _dec3;
|
|
1336
|
+
var _dec4;
|
|
1337
|
+
var _class$3;
|
|
1338
|
+
var _class2;
|
|
1339
|
+
var _descriptor;
|
|
1340
|
+
var _ControllerFormFieldPreset;
|
|
615
1341
|
function _initializerDefineProperty(e, i, r, l) {
|
|
616
1342
|
r && Object.defineProperty(e, i, {
|
|
617
1343
|
enumerable: r.enumerable,
|
|
@@ -650,15 +1376,19 @@ var ControllerFormFieldPreset = (_dec$3 = Controller(), _dec2$3 = BeanInfo({ mod
|
|
|
650
1376
|
}), _class2)) || _class$3) || _class$3);
|
|
651
1377
|
//#endregion
|
|
652
1378
|
//#region src/component/form/render.tsx
|
|
653
|
-
var _dec$2
|
|
1379
|
+
var _dec$2;
|
|
1380
|
+
var _dec2$2;
|
|
1381
|
+
var _class$2;
|
|
654
1382
|
var RenderForm = (_dec$2 = Render(), _dec2$2 = BeanInfo({ module: "a-form" }), _dec$2(_class$2 = _dec2$2(_class$2 = class RenderForm extends BeanRenderBase {
|
|
655
1383
|
_renderSchema() {
|
|
656
1384
|
if (!this.properties) return;
|
|
657
1385
|
const children = [];
|
|
658
1386
|
for (const property of this.properties) {
|
|
659
1387
|
const child = this._renderFieldByKey(property.key);
|
|
660
|
-
if (child)
|
|
661
|
-
|
|
1388
|
+
if (child) {
|
|
1389
|
+
if (Array.isArray(child)) children.push(...child);
|
|
1390
|
+
else children.push(child);
|
|
1391
|
+
}
|
|
662
1392
|
}
|
|
663
1393
|
return children;
|
|
664
1394
|
}
|
|
@@ -722,7 +1452,9 @@ var ZForm = defineComponent((_props) => {
|
|
|
722
1452
|
}, prepareComponentOptions());
|
|
723
1453
|
//#endregion
|
|
724
1454
|
//#region src/component/formField/render.tsx
|
|
725
|
-
var _dec$1
|
|
1455
|
+
var _dec$1;
|
|
1456
|
+
var _dec2$1;
|
|
1457
|
+
var _class$1;
|
|
726
1458
|
var RenderFormField = (_dec$1 = Render(), _dec2$1 = BeanInfo({ module: "a-form" }), _dec$1(_class$1 = _dec2$1(_class$1 = class RenderFormField extends BeanRenderBase {
|
|
727
1459
|
render() {
|
|
728
1460
|
const renderContext = this.getRenderContext();
|
|
@@ -762,7 +1494,9 @@ var config = (_sys) => {
|
|
|
762
1494
|
//#region src/.metadata/index.ts
|
|
763
1495
|
/** config: end */
|
|
764
1496
|
/** scope: begin */
|
|
765
|
-
var _dec
|
|
1497
|
+
var _dec;
|
|
1498
|
+
var _dec2;
|
|
1499
|
+
var _class;
|
|
766
1500
|
var components = {
|
|
767
1501
|
"form": ZForm,
|
|
768
1502
|
"formField": ZFormField,
|
|
@@ -837,18 +1571,8 @@ function resolveFormLayout(layout, properties) {
|
|
|
837
1571
|
const nodeIds = /* @__PURE__ */ new Set();
|
|
838
1572
|
const diagnostics = [];
|
|
839
1573
|
const fieldTabPaths = {};
|
|
840
|
-
const children = layout.children.map((node, index) => resolveNode(node, [index], [], propertyNames, propertyAliases, fieldNames, nodeIds, diagnostics, fieldTabPaths)).filter(Boolean);
|
|
841
|
-
for (const property of properties ?? []) {
|
|
842
|
-
const name = property.key;
|
|
843
|
-
if (!name || !propertyNames.has(name) || fieldNames.has(name)) continue;
|
|
844
|
-
fieldNames.add(name);
|
|
845
|
-
children.push({
|
|
846
|
-
type: "field",
|
|
847
|
-
name
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
1574
|
return {
|
|
851
|
-
children,
|
|
1575
|
+
children: layout.children.map((node, index) => resolveNode(node, [index], [], propertyNames, propertyAliases, fieldNames, nodeIds, diagnostics, fieldTabPaths)).filter(Boolean),
|
|
852
1576
|
fieldTabPaths,
|
|
853
1577
|
diagnostics
|
|
854
1578
|
};
|