@react-typed-forms/schemas 15.0.0 → 15.1.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 +16 -6
- package/lib/index.cjs +61 -52
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +44 -37
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +3 -2
- package/package.json +3 -3
- package/src/controlRender.tsx +27 -10
- package/src/createFormRenderer.tsx +14 -13
- package/src/renderers.tsx +3 -1
package/lib/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { newControl, getElementIndex, ensureMetaValue, ControlChange, useControl, useComputed, useRefState, SubscriptionTracker, addAfterChangesCallback, trackedValue, collectChanges, useCalculatedControl, useValueChangeEffect, useValidator, useComponentTracking, useControlEffect, removeElement, RenderArrayElements, addElement } from '@react-typed-forms/core';
|
|
2
|
-
import
|
|
2
|
+
import { useRef, useMemo, useCallback, useEffect } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import jsonata from 'jsonata';
|
|
5
5
|
import { v4 } from 'uuid';
|
|
6
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Enum representing the various field types.
|
|
@@ -2125,8 +2126,9 @@ class DefaultSchemaInterface {
|
|
|
2125
2126
|
}
|
|
2126
2127
|
const defaultSchemaInterface = new DefaultSchemaInterface();
|
|
2127
2128
|
|
|
2128
|
-
const _excluded = ["
|
|
2129
|
-
_excluded2 = ["
|
|
2129
|
+
const _excluded = ["styleClass", "labelClass", "layoutClass"],
|
|
2130
|
+
_excluded2 = ["parentDataNode"],
|
|
2131
|
+
_excluded3 = ["definition", "control", "formOptions", "style", "allowedOptions", "schemaInterface", "styleClass"];
|
|
2130
2132
|
const AppendAdornmentPriority = 0;
|
|
2131
2133
|
const WrapAdornmentPriority = 1000;
|
|
2132
2134
|
/**
|
|
@@ -2158,7 +2160,7 @@ function useControlRenderer(definition, fields, renderer, options = {}) {
|
|
|
2158
2160
|
control,
|
|
2159
2161
|
parentPath
|
|
2160
2162
|
}) => {
|
|
2161
|
-
return /*#__PURE__*/
|
|
2163
|
+
return /*#__PURE__*/jsx(ControlRenderer, _extends({}, r.current, {
|
|
2162
2164
|
control: control,
|
|
2163
2165
|
parentPath: parentPath
|
|
2164
2166
|
}));
|
|
@@ -2274,14 +2276,14 @@ function useControlRendererComponent(controlOrFormNode, renderer, options = {},
|
|
|
2274
2276
|
hiddenControl: myOptionsControl.fields.hidden,
|
|
2275
2277
|
dataContext
|
|
2276
2278
|
});
|
|
2277
|
-
const
|
|
2278
|
-
|
|
2279
|
-
|
|
2279
|
+
const inheritableOptions = _objectWithoutPropertiesLoose(options, _excluded);
|
|
2280
|
+
const childOptions = _extends({}, inheritableOptions, myOptions, {
|
|
2281
|
+
elementIndex: undefined
|
|
2280
2282
|
});
|
|
2281
2283
|
useEffect(() => {
|
|
2282
2284
|
if (control && typeof myOptions.disabled === "boolean" && control.disabled != myOptions.disabled) control.disabled = myOptions.disabled;
|
|
2283
2285
|
}, [control, myOptions.disabled]);
|
|
2284
|
-
if (parentControl.isNull) return /*#__PURE__*/
|
|
2286
|
+
if (parentControl.isNull) return /*#__PURE__*/jsx(Fragment, {});
|
|
2285
2287
|
const adornments = (_definition$adornment2 = (_definition$adornment3 = definition.adornments) == null ? void 0 : _definition$adornment3.map(x => renderer.renderAdornment({
|
|
2286
2288
|
adornment: x,
|
|
2287
2289
|
dataContext,
|
|
@@ -2300,15 +2302,16 @@ function useControlRendererComponent(controlOrFormNode, renderer, options = {},
|
|
|
2300
2302
|
{
|
|
2301
2303
|
parentDataNode
|
|
2302
2304
|
} = _ref,
|
|
2303
|
-
renderOptions = _objectWithoutPropertiesLoose(_ref,
|
|
2305
|
+
renderOptions = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
2304
2306
|
const dContext = (_ref2 = parentDataNode != null ? parentDataNode : dataContext.dataNode) != null ? _ref2 : dataContext.parentNode;
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
+
const allChildOptions = _extends({}, childOptions, overrideClasses, renderOptions);
|
|
2308
|
+
console.log(allChildOptions, overrideClasses);
|
|
2309
|
+
return /*#__PURE__*/jsx(NewControlRenderer, {
|
|
2307
2310
|
definition: child,
|
|
2308
2311
|
renderer: renderer,
|
|
2309
2312
|
parentDataNode: dContext,
|
|
2310
|
-
options:
|
|
2311
|
-
});
|
|
2313
|
+
options: allChildOptions
|
|
2314
|
+
}, k);
|
|
2312
2315
|
},
|
|
2313
2316
|
createDataProps: dataProps,
|
|
2314
2317
|
formOptions: myOptions,
|
|
@@ -2361,7 +2364,7 @@ function ControlRenderer({
|
|
|
2361
2364
|
"": fields
|
|
2362
2365
|
}).getSchema(""), control);
|
|
2363
2366
|
const Render = useControlRendererComponent(definition, renderer, options, schemaDataNode);
|
|
2364
|
-
return /*#__PURE__*/
|
|
2367
|
+
return /*#__PURE__*/jsx(Render, {});
|
|
2365
2368
|
} finally {
|
|
2366
2369
|
_effect();
|
|
2367
2370
|
}
|
|
@@ -2375,7 +2378,7 @@ function NewControlRenderer({
|
|
|
2375
2378
|
var _effect2 = useComponentTracking();
|
|
2376
2379
|
try {
|
|
2377
2380
|
const Render = useControlRendererComponent(definition, renderer, options, parentDataNode);
|
|
2378
|
-
return /*#__PURE__*/
|
|
2381
|
+
return /*#__PURE__*/jsx(Render, {});
|
|
2379
2382
|
} finally {
|
|
2380
2383
|
_effect2();
|
|
2381
2384
|
}
|
|
@@ -2391,7 +2394,7 @@ function defaultDataProps(_ref4) {
|
|
|
2391
2394
|
schemaInterface = defaultSchemaInterface,
|
|
2392
2395
|
styleClass
|
|
2393
2396
|
} = _ref4,
|
|
2394
|
-
props = _objectWithoutPropertiesLoose(_ref4,
|
|
2397
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded3);
|
|
2395
2398
|
const dataNode = props.dataContext.dataNode;
|
|
2396
2399
|
const field = dataNode.schema.field;
|
|
2397
2400
|
const className = rendererClass(styleClass, definition.styleClass);
|
|
@@ -2534,7 +2537,9 @@ function renderControlLayout(props) {
|
|
|
2534
2537
|
}
|
|
2535
2538
|
}
|
|
2536
2539
|
function appendMarkup(k, markup) {
|
|
2537
|
-
return layout => layout[k] = /*#__PURE__*/
|
|
2540
|
+
return layout => layout[k] = /*#__PURE__*/jsxs(Fragment, {
|
|
2541
|
+
children: [layout[k], markup]
|
|
2542
|
+
});
|
|
2538
2543
|
}
|
|
2539
2544
|
function wrapMarkup(k, wrap) {
|
|
2540
2545
|
return layout => layout[k] = wrap(layout[k]);
|
|
@@ -2703,15 +2708,16 @@ function applyArrayLengthRestrictions({
|
|
|
2703
2708
|
};
|
|
2704
2709
|
}
|
|
2705
2710
|
function fieldOptionAdornment(p) {
|
|
2706
|
-
return (o, i, selected) => /*#__PURE__*/
|
|
2707
|
-
array: p.formNode.getChildNodes()
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2711
|
+
return (o, i, selected) => /*#__PURE__*/jsx(RenderArrayElements, {
|
|
2712
|
+
array: p.formNode.getChildNodes(),
|
|
2713
|
+
children: (cd, i) => p.renderChild(i, cd, {
|
|
2714
|
+
parentDataNode: p.dataContext.parentNode,
|
|
2715
|
+
formData: {
|
|
2716
|
+
option: o,
|
|
2717
|
+
optionSelected: selected
|
|
2718
|
+
}
|
|
2719
|
+
})
|
|
2720
|
+
});
|
|
2715
2721
|
}
|
|
2716
2722
|
|
|
2717
2723
|
function isIconAdornment(a) {
|
|
@@ -2784,16 +2790,17 @@ function createAdornmentRenderer(render, options) {
|
|
|
2784
2790
|
}
|
|
2785
2791
|
|
|
2786
2792
|
function createFormRenderer(customRenderers = [], defaultRenderers) {
|
|
2787
|
-
var
|
|
2788
|
-
const
|
|
2789
|
-
const
|
|
2790
|
-
const
|
|
2791
|
-
const
|
|
2792
|
-
const
|
|
2793
|
-
const
|
|
2794
|
-
const
|
|
2795
|
-
const
|
|
2796
|
-
const
|
|
2793
|
+
var _defaultRenderers$ext, _allRenderers$find;
|
|
2794
|
+
const allRenderers = [...customRenderers, ...((_defaultRenderers$ext = defaultRenderers.extraRenderers) != null ? _defaultRenderers$ext : [])];
|
|
2795
|
+
const dataRegistrations = allRenderers.filter(isDataRegistration);
|
|
2796
|
+
const groupRegistrations = allRenderers.filter(isGroupRegistration);
|
|
2797
|
+
const adornmentRegistrations = allRenderers.filter(isAdornmentRegistration);
|
|
2798
|
+
const displayRegistrations = allRenderers.filter(isDisplayRegistration);
|
|
2799
|
+
const labelRenderers = allRenderers.filter(isLabelRegistration);
|
|
2800
|
+
const arrayRenderers = allRenderers.filter(isArrayRegistration);
|
|
2801
|
+
const actionRenderers = allRenderers.filter(isActionRegistration);
|
|
2802
|
+
const layoutRenderers = allRenderers.filter(isLayoutRegistration);
|
|
2803
|
+
const visibilityRenderer = (_allRenderers$find = allRenderers.find(isVisibilityRegistration)) != null ? _allRenderers$find : defaultRenderers.visibility;
|
|
2797
2804
|
const formRenderers = {
|
|
2798
2805
|
renderAction,
|
|
2799
2806
|
renderData,
|
|
@@ -2806,7 +2813,7 @@ function createFormRenderer(customRenderers = [], defaultRenderers) {
|
|
|
2806
2813
|
renderVisibility,
|
|
2807
2814
|
renderLabelText,
|
|
2808
2815
|
renderText: defaultRenderers.renderText,
|
|
2809
|
-
|
|
2816
|
+
html: defaultRenderers.html
|
|
2810
2817
|
};
|
|
2811
2818
|
function renderVisibility(props) {
|
|
2812
2819
|
return visibilityRenderer.render(props, formRenderers);
|