@react-typed-forms/schemas 11.2.2 → 11.3.3
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/components/DefaultLayout.d.ts +3 -2
- package/lib/index.js +10 -3
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { RenderedLayout } from "../controlRender";
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
3
|
export interface DefaultLayoutRendererOptions {
|
|
4
4
|
className?: string;
|
|
5
5
|
errorClass?: string;
|
|
6
|
+
renderError?: (errorText: string | null | undefined) => ReactNode;
|
|
6
7
|
}
|
|
7
|
-
export declare function DefaultLayout({ errorClass, layout: { controlEnd, controlStart, label, children, errorControl }, }: DefaultLayoutRendererOptions & {
|
|
8
|
+
export declare function DefaultLayout({ errorClass, renderError, layout: { controlEnd, controlStart, label, children, errorControl }, }: DefaultLayoutRendererOptions & {
|
|
8
9
|
layout: RenderedLayout;
|
|
9
10
|
}): React.JSX.Element;
|
package/lib/index.js
CHANGED
|
@@ -762,6 +762,9 @@ function mergeFields(fields, name, value, newFields) {
|
|
|
762
762
|
function addFieldOption(typeField, name, value) {
|
|
763
763
|
var _typeField$options;
|
|
764
764
|
var options = (_typeField$options = typeField.options) != null ? _typeField$options : [];
|
|
765
|
+
if (options.some(function (x) {
|
|
766
|
+
return x.value === value;
|
|
767
|
+
})) return typeField;
|
|
765
768
|
return _extends({}, typeField, {
|
|
766
769
|
options: [].concat(options, [{
|
|
767
770
|
name: name,
|
|
@@ -1942,6 +1945,12 @@ function DefaultLayout(_ref) {
|
|
|
1942
1945
|
var _effect = core.useComponentTracking();
|
|
1943
1946
|
try {
|
|
1944
1947
|
var errorClass = _ref.errorClass,
|
|
1948
|
+
_ref$renderError = _ref.renderError,
|
|
1949
|
+
renderError = _ref$renderError === void 0 ? function (e) {
|
|
1950
|
+
return e && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1951
|
+
className: errorClass
|
|
1952
|
+
}, e);
|
|
1953
|
+
} : _ref$renderError,
|
|
1945
1954
|
_ref$layout = _ref.layout,
|
|
1946
1955
|
controlEnd = _ref$layout.controlEnd,
|
|
1947
1956
|
controlStart = _ref$layout.controlStart,
|
|
@@ -1950,9 +1959,7 @@ function DefaultLayout(_ref) {
|
|
|
1950
1959
|
errorControl = _ref$layout.errorControl;
|
|
1951
1960
|
var ec = errorControl;
|
|
1952
1961
|
var errorText = ec && ec.touched ? ec.error : undefined;
|
|
1953
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, label, controlStart, children, errorText
|
|
1954
|
-
className: errorClass
|
|
1955
|
-
}, errorText), controlEnd);
|
|
1962
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, label, controlStart, children, renderError(errorText), controlEnd);
|
|
1956
1963
|
} finally {
|
|
1957
1964
|
_effect();
|
|
1958
1965
|
}
|