@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-typed-forms/schemas",
3
- "version": "14.3.0",
3
+ "version": "14.3.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "lib/index.cjs",
@@ -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(props, formRenderers);
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 matchSchemaType =
118
- x.schemaType &&
119
- renderType == DataRenderType.Standard &&
120
- isOneOf(x.schemaType, field.type);
121
- const matchRenderType =
122
- !x.renderType || isOneOf(x.renderType, renderType);
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
- (matchSchemaType || matchRenderType) &&
127
- (!x.match || x.match(props, renderOptions))
130
+ (isSchemaAllowed ||
131
+ isRendererAllowed ||
132
+ (!x.renderType && !x.schemaType && noMatch === false))
128
133
  );
129
134
  }
130
135
  }