@react-typed-forms/schemas 11.1.0 → 11.2.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/controlRender.d.ts +3 -1
- package/lib/index.js +24 -12
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +1 -0
- package/lib/schemaInterface.d.ts +2 -1
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/lib/controlRender.d.ts
CHANGED
|
@@ -143,6 +143,7 @@ export interface DataControlProps {
|
|
|
143
143
|
elementIndex?: number;
|
|
144
144
|
allowedOptions?: Control<any[] | undefined>;
|
|
145
145
|
useChildVisibility: ChildVisibilityFunc;
|
|
146
|
+
schemaInterface?: SchemaInterface;
|
|
146
147
|
}
|
|
147
148
|
export type CreateDataProps = (controlProps: DataControlProps) => DataRendererProps;
|
|
148
149
|
export interface ControlRenderOptions extends FormContextOptions {
|
|
@@ -164,7 +165,7 @@ export declare function ControlRenderer({ definition, fields, renderer, options,
|
|
|
164
165
|
control: Control<any>;
|
|
165
166
|
parentPath?: JsonPath[];
|
|
166
167
|
}): React.JSX.Element;
|
|
167
|
-
export declare function defaultDataProps({ definition, field, control, formOptions, style, allowedOptions, ...props }: DataControlProps): DataRendererProps;
|
|
168
|
+
export declare function defaultDataProps({ definition, field, control, formOptions, style, allowedOptions, schemaInterface, ...props }: DataControlProps): DataRendererProps;
|
|
168
169
|
export declare function defaultArrayProps(arrayControl: Control<any[] | undefined | null>, field: SchemaField, required: boolean, style: CSSProperties | undefined, className: string | undefined, renderElement: (elemIndex: number) => ReactNode, min: number | undefined | null, max: number | undefined | null): ArrayRendererProps;
|
|
169
170
|
export interface ChildRendererOptions {
|
|
170
171
|
elementIndex?: number;
|
|
@@ -189,6 +190,7 @@ export interface RenderControlProps {
|
|
|
189
190
|
actionDataControl?: Control<any | undefined | null>;
|
|
190
191
|
useChildVisibility: ChildVisibilityFunc;
|
|
191
192
|
actionOnClick?: (actionId: string, actionData: any) => () => void;
|
|
193
|
+
schemaInterface?: SchemaInterface;
|
|
192
194
|
}
|
|
193
195
|
export declare function renderControlLayout(props: RenderControlProps): ControlLayoutProps;
|
|
194
196
|
export declare function appendMarkup(k: keyof Omit<RenderedLayout, "errorControl" | "style" | "className">, markup: ReactNode): (layout: RenderedLayout) => void;
|
package/lib/index.js
CHANGED
|
@@ -1250,6 +1250,10 @@ function cc(n) {
|
|
|
1250
1250
|
var DefaultSchemaInterface = /*#__PURE__*/function () {
|
|
1251
1251
|
function DefaultSchemaInterface() {}
|
|
1252
1252
|
var _proto = DefaultSchemaInterface.prototype;
|
|
1253
|
+
_proto.getOptions = function getOptions(_ref) {
|
|
1254
|
+
var options = _ref.options;
|
|
1255
|
+
return options && options.length > 0 ? options : null;
|
|
1256
|
+
};
|
|
1253
1257
|
_proto.isEmptyValue = function isEmptyValue(f, value) {
|
|
1254
1258
|
if (f.collection) return Array.isArray(value) ? value.length === 0 : value == null;
|
|
1255
1259
|
switch (f.type) {
|
|
@@ -1274,14 +1278,14 @@ var DefaultSchemaInterface = /*#__PURE__*/function () {
|
|
|
1274
1278
|
return f.collection ? (_control$elements$len = (_control$elements = control.elements) == null ? void 0 : _control$elements.length) != null ? _control$elements$len : 0 : this.valueLength(f, control.value);
|
|
1275
1279
|
};
|
|
1276
1280
|
_proto.valueLength = function valueLength(field, value) {
|
|
1277
|
-
var
|
|
1278
|
-
return (
|
|
1281
|
+
var _ref2;
|
|
1282
|
+
return (_ref2 = value && (value == null ? void 0 : value.length)) != null ? _ref2 : 0;
|
|
1279
1283
|
};
|
|
1280
1284
|
return DefaultSchemaInterface;
|
|
1281
1285
|
}();
|
|
1282
1286
|
var defaultSchemaInterface = new DefaultSchemaInterface();
|
|
1283
1287
|
|
|
1284
|
-
var _excluded$3 = ["definition", "field", "control", "formOptions", "style", "allowedOptions"];
|
|
1288
|
+
var _excluded$3 = ["definition", "field", "control", "formOptions", "style", "allowedOptions", "schemaInterface"];
|
|
1285
1289
|
var AppendAdornmentPriority = 0;
|
|
1286
1290
|
var WrapAdornmentPriority = 1000;
|
|
1287
1291
|
exports.LabelType = void 0;
|
|
@@ -1441,6 +1445,7 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1441
1445
|
parentContext: parentDataContext,
|
|
1442
1446
|
control: displayControl != null ? displayControl : control,
|
|
1443
1447
|
elementIndex: _elementIndex,
|
|
1448
|
+
schemaInterface: schemaInterface,
|
|
1444
1449
|
labelText: labelText,
|
|
1445
1450
|
field: _schemaField,
|
|
1446
1451
|
displayControl: displayControl,
|
|
@@ -1529,20 +1534,22 @@ function ControlRenderer(_ref3) {
|
|
|
1529
1534
|
}
|
|
1530
1535
|
}
|
|
1531
1536
|
function defaultDataProps(_ref4) {
|
|
1532
|
-
var _definition$validator,
|
|
1537
|
+
var _definition$validator, _allowedOptions$value, _definition$children, _definition$renderOpt;
|
|
1533
1538
|
var definition = _ref4.definition,
|
|
1534
1539
|
field = _ref4.field,
|
|
1535
1540
|
control = _ref4.control,
|
|
1536
1541
|
formOptions = _ref4.formOptions,
|
|
1537
1542
|
style = _ref4.style,
|
|
1538
1543
|
allowedOptions = _ref4.allowedOptions,
|
|
1544
|
+
_ref4$schemaInterface = _ref4.schemaInterface,
|
|
1545
|
+
schemaInterface = _ref4$schemaInterface === void 0 ? defaultSchemaInterface : _ref4$schemaInterface,
|
|
1539
1546
|
props = _objectWithoutPropertiesLoose(_ref4, _excluded$3);
|
|
1540
1547
|
var lengthVal = (_definition$validator = definition.validators) == null ? void 0 : _definition$validator.find(function (x) {
|
|
1541
1548
|
return x.type === exports.ValidatorType.Length;
|
|
1542
1549
|
});
|
|
1543
1550
|
var className = cc(definition.styleClass);
|
|
1544
1551
|
var required = !!definition.required;
|
|
1545
|
-
var fieldOptions = (
|
|
1552
|
+
var fieldOptions = schemaInterface.getOptions(field);
|
|
1546
1553
|
var allowed = (_allowedOptions$value = allowedOptions == null ? void 0 : allowedOptions.value) != null ? _allowedOptions$value : [];
|
|
1547
1554
|
return _extends({
|
|
1548
1555
|
definition: definition,
|
|
@@ -1789,6 +1796,13 @@ function createLayoutRenderer(render, options) {
|
|
|
1789
1796
|
render: render
|
|
1790
1797
|
}, options);
|
|
1791
1798
|
}
|
|
1799
|
+
function createActionRenderer(actionId, render, options) {
|
|
1800
|
+
return _extends({
|
|
1801
|
+
type: "action",
|
|
1802
|
+
actionType: actionId,
|
|
1803
|
+
render: render
|
|
1804
|
+
}, options);
|
|
1805
|
+
}
|
|
1792
1806
|
function createArrayRenderer(render, options) {
|
|
1793
1807
|
return _extends({
|
|
1794
1808
|
type: "array",
|
|
@@ -1977,12 +1991,13 @@ function createSelectRenderer(options) {
|
|
|
1977
1991
|
options = {};
|
|
1978
1992
|
}
|
|
1979
1993
|
return createDataRenderer(function (props, asArray) {
|
|
1994
|
+
var _props$options;
|
|
1980
1995
|
return /*#__PURE__*/React__default["default"].createElement(SelectDataRenderer, {
|
|
1981
1996
|
className: rendererClass(props.className, options.className),
|
|
1982
1997
|
state: props.control,
|
|
1983
1998
|
id: props.id,
|
|
1984
1999
|
readonly: props.readonly,
|
|
1985
|
-
options: props.options,
|
|
2000
|
+
options: (_props$options = props.options) != null ? _props$options : [],
|
|
1986
2001
|
required: props.required,
|
|
1987
2002
|
emptyText: options.emptyText,
|
|
1988
2003
|
requiredText: options.requiredText,
|
|
@@ -2322,18 +2337,14 @@ function createDefaultActionRenderer(options) {
|
|
|
2322
2337
|
if (options === void 0) {
|
|
2323
2338
|
options = {};
|
|
2324
2339
|
}
|
|
2325
|
-
function
|
|
2340
|
+
return createActionRenderer(undefined, function (_ref) {
|
|
2326
2341
|
var onClick = _ref.onClick,
|
|
2327
2342
|
actionText = _ref.actionText;
|
|
2328
2343
|
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
2329
2344
|
className: options.className,
|
|
2330
2345
|
onClick: onClick
|
|
2331
2346
|
}, actionText);
|
|
2332
|
-
}
|
|
2333
|
-
return {
|
|
2334
|
-
render: render,
|
|
2335
|
-
type: "action"
|
|
2336
|
-
};
|
|
2347
|
+
});
|
|
2337
2348
|
}
|
|
2338
2349
|
function createDefaultGroupRenderer(options) {
|
|
2339
2350
|
var _ref2 = options != null ? options : {},
|
|
@@ -2746,6 +2757,7 @@ exports.compoundControl = compoundControl;
|
|
|
2746
2757
|
exports.compoundField = compoundField;
|
|
2747
2758
|
exports.controlTitle = controlTitle;
|
|
2748
2759
|
exports.createAction = createAction;
|
|
2760
|
+
exports.createActionRenderer = createActionRenderer;
|
|
2749
2761
|
exports.createAdornmentRenderer = createAdornmentRenderer;
|
|
2750
2762
|
exports.createArrayRenderer = createArrayRenderer;
|
|
2751
2763
|
exports.createCheckListRenderer = createCheckListRenderer;
|