@arkcit/engine 0.3.0
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/README.md +68 -0
- package/dist/UIEngine.d.ts +6 -0
- package/dist/UIEngine.js +3235 -0
- package/dist/bindings.d.ts +8 -0
- package/dist/bindings.js +146 -0
- package/dist/components/index.d.ts +17 -0
- package/dist/components/index.js +143 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +9 -0
- package/dist/form/engineFormValidation.d.ts +2 -0
- package/dist/form/engineFormValidation.js +241 -0
- package/dist/form.d.ts +67 -0
- package/dist/form.js +241 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +3336 -0
- package/dist/layout.d.ts +6 -0
- package/dist/layout.js +82 -0
- package/dist/preview/index.d.ts +63 -0
- package/dist/preview/index.js +1514 -0
- package/dist/react-web/index.d.ts +8 -0
- package/dist/react-web/index.js +3246 -0
- package/dist/registry.d.ts +2 -0
- package/dist/registry.js +0 -0
- package/dist/render-layer/index.d.ts +1 -0
- package/dist/render-layer/index.js +13 -0
- package/dist/renderStudioForm-CPQEzvT7.d.ts +75 -0
- package/dist/renderers/index.d.ts +8 -0
- package/dist/renderers/index.js +1570 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +0 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +0 -0
- package/dist/studio-bridge/index.d.ts +501 -0
- package/dist/studio-bridge/index.js +2840 -0
- package/dist/studioProps.d.ts +8 -0
- package/dist/studioProps.js +97 -0
- package/dist/types-9TZ2lQDP.d.ts +60 -0
- package/dist/types-CyAE6ZLH.d.ts +19 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.js +0 -0
- package/dist/wizardEditingHandlers-D50tR-6n.d.ts +163 -0
- package/package.json +160 -0
package/dist/form.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/form/engineFormValidation.ts
|
|
19
|
+
var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
20
|
+
var isEmptyValue = (value) => {
|
|
21
|
+
if (value == null) return true;
|
|
22
|
+
if (typeof value === "string") return value.trim().length === 0;
|
|
23
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
var toNumber = (value) => {
|
|
27
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
const parsed = Number(value);
|
|
30
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
var getPathValue = (source, ref) => {
|
|
35
|
+
const normalizedRef = ref.replace(/^@/, "").trim();
|
|
36
|
+
if (!normalizedRef) return void 0;
|
|
37
|
+
return normalizedRef.split(".").filter(Boolean).reduce((accumulator, segment) => {
|
|
38
|
+
if (!accumulator || typeof accumulator !== "object") return void 0;
|
|
39
|
+
return accumulator[segment];
|
|
40
|
+
}, source);
|
|
41
|
+
};
|
|
42
|
+
var resolveBindableText = (value, options) => {
|
|
43
|
+
var _a;
|
|
44
|
+
if (typeof value === "string") {
|
|
45
|
+
const trimmed = value.trim();
|
|
46
|
+
if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
|
47
|
+
try {
|
|
48
|
+
const parsed = JSON.parse(trimmed);
|
|
49
|
+
return resolveBindableText(parsed, options);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
57
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return "";
|
|
58
|
+
const candidate = value;
|
|
59
|
+
if (typeof candidate.$t === "string") {
|
|
60
|
+
const translated = (_a = options == null ? void 0 : options.t) == null ? void 0 : _a.call(
|
|
61
|
+
options,
|
|
62
|
+
candidate.$t,
|
|
63
|
+
candidate.values && typeof candidate.values === "object" ? candidate.values : void 0
|
|
64
|
+
);
|
|
65
|
+
if (typeof translated === "string" && translated.trim().length > 0) return translated;
|
|
66
|
+
return candidate.$t;
|
|
67
|
+
}
|
|
68
|
+
if (typeof candidate.$ref === "string" && (options == null ? void 0 : options.values)) {
|
|
69
|
+
const resolved = getPathValue(options.values, candidate.$ref);
|
|
70
|
+
if (resolved == null) return "";
|
|
71
|
+
return String(resolved);
|
|
72
|
+
}
|
|
73
|
+
return "";
|
|
74
|
+
};
|
|
75
|
+
var defaultDeclarativeValidatorRegistry = {
|
|
76
|
+
required: (value) => isEmptyValue(value) ? { code: "required" } : null,
|
|
77
|
+
minLength: (value, params) => {
|
|
78
|
+
var _a;
|
|
79
|
+
if (isEmptyValue(value)) return null;
|
|
80
|
+
const min = toNumber((_a = params == null ? void 0 : params.min) != null ? _a : params == null ? void 0 : params.value);
|
|
81
|
+
if (min == null) return null;
|
|
82
|
+
return String(value).length < min ? { code: "minLength", params: { min } } : null;
|
|
83
|
+
},
|
|
84
|
+
maxLength: (value, params) => {
|
|
85
|
+
var _a;
|
|
86
|
+
if (isEmptyValue(value)) return null;
|
|
87
|
+
const max = toNumber((_a = params == null ? void 0 : params.max) != null ? _a : params == null ? void 0 : params.value);
|
|
88
|
+
if (max == null) return null;
|
|
89
|
+
return String(value).length > max ? { code: "maxLength", params: { max } } : null;
|
|
90
|
+
},
|
|
91
|
+
email: (value) => {
|
|
92
|
+
if (isEmptyValue(value)) return null;
|
|
93
|
+
return EMAIL_REGEX.test(String(value)) ? null : { code: "email" };
|
|
94
|
+
},
|
|
95
|
+
pattern: (value, params) => {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
if (isEmptyValue(value)) return null;
|
|
98
|
+
const rawPattern = String((_b = (_a = params == null ? void 0 : params.pattern) != null ? _a : params == null ? void 0 : params.value) != null ? _b : "").trim();
|
|
99
|
+
if (!rawPattern) return null;
|
|
100
|
+
try {
|
|
101
|
+
const regex = new RegExp(rawPattern);
|
|
102
|
+
return regex.test(String(value)) ? null : { code: "pattern", params: { pattern: rawPattern } };
|
|
103
|
+
} catch (e) {
|
|
104
|
+
return { code: "pattern" };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var buildLegacyValidators = (field) => {
|
|
109
|
+
var _a, _b, _c;
|
|
110
|
+
const validators = [];
|
|
111
|
+
if (field.required) {
|
|
112
|
+
validators.push({
|
|
113
|
+
id: `${String((_a = field.name) != null ? _a : "field")}:required`,
|
|
114
|
+
type: "required",
|
|
115
|
+
stopOnFailure: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (String((_b = field.pattern) != null ? _b : "").trim()) {
|
|
119
|
+
validators.push({
|
|
120
|
+
id: `${String((_c = field.name) != null ? _c : "field")}:pattern`,
|
|
121
|
+
type: "pattern",
|
|
122
|
+
params: { pattern: String(field.pattern) }
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return validators;
|
|
126
|
+
};
|
|
127
|
+
var normalizeValidators = (field, options) => {
|
|
128
|
+
const explicit = Array.isArray(field.validators) ? field.validators : [];
|
|
129
|
+
if (explicit.length > 0) return explicit;
|
|
130
|
+
if (!(options == null ? void 0 : options.useLegacyFieldConstraints)) return [];
|
|
131
|
+
return buildLegacyValidators(field);
|
|
132
|
+
};
|
|
133
|
+
var toIssueArray = (issue) => {
|
|
134
|
+
if (!issue) return [];
|
|
135
|
+
return Array.isArray(issue) ? issue : [issue];
|
|
136
|
+
};
|
|
137
|
+
var validateFieldWithConfig = (field, value, values, config, registry) => {
|
|
138
|
+
if (config.enabled === false) return [];
|
|
139
|
+
const validate = registry[config.type];
|
|
140
|
+
if (!validate) return [];
|
|
141
|
+
const baseIssues = toIssueArray(
|
|
142
|
+
validate(value, config.params, {
|
|
143
|
+
field,
|
|
144
|
+
values
|
|
145
|
+
})
|
|
146
|
+
);
|
|
147
|
+
return baseIssues.map((baseIssue) => {
|
|
148
|
+
var _a, _b, _c, _d, _e;
|
|
149
|
+
return {
|
|
150
|
+
field: String((_a = field.name) != null ? _a : ""),
|
|
151
|
+
validatorId: config.id || baseIssue.validatorId,
|
|
152
|
+
code: baseIssue.code,
|
|
153
|
+
messageKey: (_b = baseIssue.messageKey) != null ? _b : config.messageKey,
|
|
154
|
+
message: (_c = baseIssue.message) != null ? _c : config.message,
|
|
155
|
+
params: __spreadValues(__spreadValues({}, (_d = config.params) != null ? _d : {}), (_e = baseIssue.params) != null ? _e : {})
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
var hasDeclarativeValidators = (fields) => fields.some((field) => Array.isArray(field.validators) && field.validators.length > 0);
|
|
160
|
+
var resolveIssueMessage = (issue, t) => {
|
|
161
|
+
const defaultMessageByCode = () => {
|
|
162
|
+
var _a, _b, _c, _d, _e, _f;
|
|
163
|
+
switch (issue.code) {
|
|
164
|
+
case "required":
|
|
165
|
+
return "This field is required";
|
|
166
|
+
case "email":
|
|
167
|
+
return "Invalid email address";
|
|
168
|
+
case "pattern":
|
|
169
|
+
return "Invalid format";
|
|
170
|
+
case "minLength": {
|
|
171
|
+
const min = (_c = (_a = issue.params) == null ? void 0 : _a.min) != null ? _c : (_b = issue.params) == null ? void 0 : _b.value;
|
|
172
|
+
return min != null ? `Minimum ${String(min)} characters` : "Value is too short";
|
|
173
|
+
}
|
|
174
|
+
case "maxLength": {
|
|
175
|
+
const max = (_f = (_d = issue.params) == null ? void 0 : _d.max) != null ? _f : (_e = issue.params) == null ? void 0 : _e.value;
|
|
176
|
+
return max != null ? `Maximum ${String(max)} characters` : "Value is too long";
|
|
177
|
+
}
|
|
178
|
+
default:
|
|
179
|
+
return void 0;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
if (issue.messageKey && t) {
|
|
183
|
+
const translated = t(issue.messageKey, issue.params);
|
|
184
|
+
if (typeof translated === "string" && translated.trim().length > 0) {
|
|
185
|
+
return translated;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (issue.message && issue.message.trim().length > 0) return issue.message;
|
|
189
|
+
if (issue.messageKey && issue.messageKey.trim().length > 0) return issue.messageKey;
|
|
190
|
+
return defaultMessageByCode();
|
|
191
|
+
};
|
|
192
|
+
var validateFormValues = (fields, values, options) => {
|
|
193
|
+
var _a;
|
|
194
|
+
const mergedRegistry = __spreadValues(__spreadValues({}, defaultDeclarativeValidatorRegistry), (_a = options == null ? void 0 : options.registry) != null ? _a : {});
|
|
195
|
+
const issues = [];
|
|
196
|
+
fields.forEach((field) => {
|
|
197
|
+
var _a2;
|
|
198
|
+
const fieldName = String((_a2 = field.name) != null ? _a2 : "").trim();
|
|
199
|
+
if (!fieldName) return;
|
|
200
|
+
const fieldValue = values[fieldName];
|
|
201
|
+
const validators = normalizeValidators(field, options);
|
|
202
|
+
if (validators.length === 0) return;
|
|
203
|
+
for (const validatorConfig of validators) {
|
|
204
|
+
const fieldIssues = validateFieldWithConfig(
|
|
205
|
+
field,
|
|
206
|
+
fieldValue,
|
|
207
|
+
values,
|
|
208
|
+
validatorConfig,
|
|
209
|
+
mergedRegistry
|
|
210
|
+
);
|
|
211
|
+
if (fieldIssues.length > 0) {
|
|
212
|
+
issues.push(...fieldIssues);
|
|
213
|
+
if (validatorConfig.stopOnFailure) break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
const errors = {};
|
|
218
|
+
issues.forEach((issue) => {
|
|
219
|
+
if (errors[issue.field]) return;
|
|
220
|
+
errors[issue.field] = resolveIssueMessage(issue, options == null ? void 0 : options.t);
|
|
221
|
+
});
|
|
222
|
+
return { issues, errors };
|
|
223
|
+
};
|
|
224
|
+
var createFormState = (input) => ({
|
|
225
|
+
values: input.values,
|
|
226
|
+
touched: input.touched,
|
|
227
|
+
issues: input.issues,
|
|
228
|
+
errors: input.errors,
|
|
229
|
+
dirty: input.dirty,
|
|
230
|
+
isValid: Object.values(input.errors).every((error) => !error),
|
|
231
|
+
isSubmitting: input.isSubmitting,
|
|
232
|
+
submitCount: input.submitCount
|
|
233
|
+
});
|
|
234
|
+
export {
|
|
235
|
+
createFormState,
|
|
236
|
+
defaultDeclarativeValidatorRegistry,
|
|
237
|
+
hasDeclarativeValidators,
|
|
238
|
+
resolveBindableText,
|
|
239
|
+
resolveIssueMessage,
|
|
240
|
+
validateFormValues
|
|
241
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { EngineWarningFallback, NodeErrorBoundary, configurePreviewLinkBehavior, materializeBoundTable } from '@arkcit/engine-react';
|
|
2
|
+
export { ReactWebEngineRoot } from './react-web/index.js';
|
|
3
|
+
export { UIExprValue, UII18nValue, UINode, UINodeEventName, UINodeLayout, UINodeProps, UIRefValue, UISchema, UIValue } from '@arkcit/engine-schema';
|
|
4
|
+
export { UIStudioNodeMeta } from './types.js';
|
|
5
|
+
export { UIActionRef, UIRuntime } from '@arkcit/engine-runtime';
|
|
6
|
+
export { U as UIInlineEditingMode, a as UIInlineEditingState } from './types-CyAE6ZLH.js';
|
|
7
|
+
export { readNodeLayout, writeNodeLayout } from './layout.js';
|
|
8
|
+
export { default as UIEngine } from './UIEngine.js';
|
|
9
|
+
export { configurePreviewAccordion, configurePreviewExpandablePanel, configurePreviewFormWizard, configurePreviewTabs, materializePreviewForm } from './preview/index.js';
|
|
10
|
+
export { c as configureStudioAccordion, a as configureStudioExpandablePanel, b as configureStudioFormWizard, d as configureStudioLink, e as configureStudioTabs, r as renderBoundTable, f as renderStudioForm } from './renderStudioForm-CPQEzvT7.js';
|
|
11
|
+
export { RENDER_BINDING_PROP_NAMES, STUDIO_INTERNAL_PROP_NAMES, getRenderBindingProps, getStudioProps, omitStudioProps } from './studioProps.js';
|
|
12
|
+
export { ComponentRegistry, ComponentRegistryEntry, ReactWebRendererProps, UIEngineProps, UINodeWrapperProps } from '@arkcit/engine-core';
|
|
13
|
+
import 'react/jsx-runtime';
|
|
14
|
+
import '@arkcit/engine-render-layer';
|
|
15
|
+
import 'react';
|