@react-typed-forms/schemas 16.1.0 → 16.2.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/lib/controlBuilder.d.ts +3 -0
- package/lib/index.cjs +11 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +12 -3
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/controlBuilder.ts +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-typed-forms/schemas",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"clsx": "^1 || ^2",
|
|
35
35
|
"uuid": "^10.0.0",
|
|
36
36
|
"jsonata": "^2.0.4",
|
|
37
|
-
"@astroapps/forms-core": "^1.
|
|
37
|
+
"@astroapps/forms-core": "^1.2.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^18.2.0 || ^19",
|
package/src/controlBuilder.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
JsonataRenderOptions,
|
|
26
26
|
JsonataValidator,
|
|
27
27
|
LengthValidator,
|
|
28
|
+
mergeOption,
|
|
28
29
|
RadioButtonRenderOptions,
|
|
29
30
|
RenderOptions,
|
|
30
31
|
SchemaField,
|
|
@@ -239,6 +240,7 @@ export interface CustomRenderOptions {
|
|
|
239
240
|
fields?: SchemaField[];
|
|
240
241
|
groups?: EditorGroup[];
|
|
241
242
|
applies?: (sf: SchemaNode) => boolean;
|
|
243
|
+
optionField?: string;
|
|
242
244
|
}
|
|
243
245
|
|
|
244
246
|
export type ControlDefinitionExtension = {
|
|
@@ -247,6 +249,7 @@ export type ControlDefinitionExtension = {
|
|
|
247
249
|
ControlAdornment?: CustomRenderOptions | CustomRenderOptions[];
|
|
248
250
|
SchemaValidator?: CustomRenderOptions | CustomRenderOptions[];
|
|
249
251
|
DisplayData?: CustomRenderOptions | CustomRenderOptions[];
|
|
252
|
+
IconReference?: CustomRenderOptions | CustomRenderOptions[];
|
|
250
253
|
};
|
|
251
254
|
|
|
252
255
|
export function applyExtensionToSchema<A extends SchemaMap>(
|
|
@@ -256,7 +259,10 @@ export function applyExtensionToSchema<A extends SchemaMap>(
|
|
|
256
259
|
const outMap = { ...schemaMap };
|
|
257
260
|
Object.entries(extension).forEach(([field, cro]) => {
|
|
258
261
|
outMap[field as keyof A] = (Array.isArray(cro) ? cro : [cro]).reduce(
|
|
259
|
-
(a, cr) =>
|
|
262
|
+
(a, cr) =>
|
|
263
|
+
cr.optionField
|
|
264
|
+
? mergeOption(a, cr.name, cr.value, cr.optionField)
|
|
265
|
+
: mergeFields(a, cr.name, cr.value, cr.fields ?? []),
|
|
260
266
|
outMap[field],
|
|
261
267
|
) as A[string];
|
|
262
268
|
});
|
|
@@ -269,3 +275,16 @@ export function applyExtensionsToSchema<A extends SchemaMap>(
|
|
|
269
275
|
) {
|
|
270
276
|
return resolveSchemas(extensions.reduce(applyExtensionToSchema, schemaMap));
|
|
271
277
|
}
|
|
278
|
+
|
|
279
|
+
export function createIconLibraryExtension(
|
|
280
|
+
name: string,
|
|
281
|
+
value: string,
|
|
282
|
+
): ControlDefinitionExtension {
|
|
283
|
+
return {
|
|
284
|
+
IconReference: {
|
|
285
|
+
optionField: "library",
|
|
286
|
+
name,
|
|
287
|
+
value,
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|