@react-typed-forms/schemas 14.3.0 → 14.3.1
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/index.cjs +7 -6
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +7 -6
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/createFormRenderer.tsx +16 -11
package/package.json
CHANGED
|
@@ -103,28 +103,33 @@ export function createFormRenderer(
|
|
|
103
103
|
|
|
104
104
|
const options = hasOptions(props);
|
|
105
105
|
const renderType = renderOptions.type;
|
|
106
|
-
const renderer =
|
|
107
|
-
dataRegistrations.find(matchesRenderer) ?? defaultRenderers.data;
|
|
106
|
+
const renderer = dataRegistrations.find(matchesRenderer);
|
|
108
107
|
|
|
109
|
-
const result = renderer.render(
|
|
108
|
+
const result = (renderer ?? defaultRenderers.data).render(
|
|
109
|
+
props,
|
|
110
|
+
formRenderers,
|
|
111
|
+
);
|
|
110
112
|
if (typeof result === "function") return result;
|
|
111
113
|
return (l) => ({ ...l, children: result });
|
|
112
114
|
|
|
113
115
|
function matchesRenderer(x: DataRendererRegistration) {
|
|
116
|
+
const noMatch = x.match ? !x.match(props, renderOptions) : undefined;
|
|
117
|
+
if (noMatch === true) return false;
|
|
114
118
|
const matchCollection =
|
|
115
119
|
(x.collection ?? false) ===
|
|
116
120
|
(props.elementIndex == null && (field.collection ?? false));
|
|
117
|
-
const
|
|
118
|
-
x.schemaType &&
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
121
|
+
const isSchemaAllowed =
|
|
122
|
+
!!x.schemaType && renderType == DataRenderType.Standard
|
|
123
|
+
? isOneOf(x.schemaType, field.type)
|
|
124
|
+
: undefined;
|
|
125
|
+
const isRendererAllowed =
|
|
126
|
+
!!x.renderType && isOneOf(x.renderType, renderType);
|
|
123
127
|
return (
|
|
124
128
|
matchCollection &&
|
|
125
129
|
(x.options ?? false) === options &&
|
|
126
|
-
(
|
|
127
|
-
|
|
130
|
+
(isSchemaAllowed ||
|
|
131
|
+
isRendererAllowed ||
|
|
132
|
+
(!x.renderType && !x.schemaType && noMatch === false))
|
|
128
133
|
);
|
|
129
134
|
}
|
|
130
135
|
}
|