@jsonui/react 0.4.3 → 0.4.4
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/dist/cjs/index.js +52 -24
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/stock/components/Button.d.ts +1 -1
- package/dist/cjs/types/stock/components/Fragment.d.ts +1 -5
- package/dist/cjs/types/stock/components/PrimitiveProp.d.ts +1 -4
- package/dist/cjs/types/stock/components/Text.d.ts +1 -1
- package/dist/cjs/types/stock/components/View.d.ts +1 -1
- package/dist/cjs/types/stock/components.d.ts +18 -0
- package/dist/cjs/types/stock/stockToRenderer.d.ts +20 -0
- package/dist/esm/index.js +53 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/stock/components/Button.d.ts +1 -1
- package/dist/esm/types/stock/components/Fragment.d.ts +1 -5
- package/dist/esm/types/stock/components/PrimitiveProp.d.ts +1 -4
- package/dist/esm/types/stock/components/Text.d.ts +1 -1
- package/dist/esm/types/stock/components/View.d.ts +1 -1
- package/dist/esm/types/stock/components.d.ts +18 -0
- package/dist/esm/types/stock/stockToRenderer.d.ts +20 -0
- package/package.json +3 -3
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { constants as c } from '@jsonui/core';
|
|
3
|
-
declare const Fragment: ({ [c.V_CHILDREN_NAME]: props, ...a }: {
|
|
4
|
-
[c.V_CHILDREN_NAME]: any;
|
|
5
|
-
}) => JSX.Element;
|
|
1
|
+
declare const Fragment: ({ children }: any) => any;
|
|
6
2
|
export default Fragment;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
declare function PrimitiveProp({ [c.V_CHILDREN_NAME]: children }: {
|
|
4
|
-
[c.V_CHILDREN_NAME]: any;
|
|
5
|
-
}): JSX.Element;
|
|
2
|
+
declare function PrimitiveProp({ children }: any): JSX.Element;
|
|
6
3
|
export default PrimitiveProp;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Text from './components/Text';
|
|
2
|
+
import Button from './components/Button';
|
|
3
|
+
import Edit from './components/Edit';
|
|
4
|
+
import View from './components/View';
|
|
5
|
+
import Image from './components/Image';
|
|
6
|
+
import _Undefined from './components/Undefined';
|
|
7
|
+
import _PrimitiveProp from './components/PrimitiveProp';
|
|
8
|
+
declare const Components: {
|
|
9
|
+
View: typeof View;
|
|
10
|
+
_PrimitiveProp: typeof _PrimitiveProp;
|
|
11
|
+
_Undefined: typeof _Undefined;
|
|
12
|
+
Fragment: ({ children }: any) => any;
|
|
13
|
+
Image: typeof Image;
|
|
14
|
+
Text: typeof Text;
|
|
15
|
+
Button: typeof Button;
|
|
16
|
+
Edit: typeof Edit;
|
|
17
|
+
};
|
|
18
|
+
export default Components;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Stock } from '@jsonui/core';
|
|
2
|
+
export declare const getStock: (stockInit: any, model: any, Wrapper: any, reduxStore: any) => Stock;
|
|
3
|
+
declare const stock: {
|
|
4
|
+
components: {
|
|
5
|
+
View: typeof import("./components/View").default;
|
|
6
|
+
_PrimitiveProp: typeof import("./components/PrimitiveProp").default;
|
|
7
|
+
_Undefined: typeof import("./components/Undefined").default;
|
|
8
|
+
Fragment: ({ children }: any) => any;
|
|
9
|
+
Image: typeof import("./components/Image").default;
|
|
10
|
+
Text: typeof import("./components/Text").default;
|
|
11
|
+
Button: typeof import("./components/Button").default;
|
|
12
|
+
Edit: typeof import("./components/Edit").default;
|
|
13
|
+
};
|
|
14
|
+
functions: {
|
|
15
|
+
getStateValue: (attr: any, props: any, callerArgs: any, stock: any) => any;
|
|
16
|
+
get: (attr: any, props: any, callerArgs: any, stock: any) => any;
|
|
17
|
+
set: (attr: any, props: any, callerArgs: any, stock: any) => any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default stock;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext,
|
|
1
|
+
import React, { createContext, useLayoutEffect, useEffect, useMemo, useContext, useDebugValue, useReducer, useRef, PureComponent, forwardRef, createElement, Fragment as Fragment$1 } from 'react';
|
|
2
2
|
import { unstable_batchedUpdates } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -6348,9 +6348,10 @@ const REDUX_PATHS = '$$reduxPaths';
|
|
|
6348
6348
|
const V_CHILDREN_PREFIX = '$child';
|
|
6349
6349
|
const PARENT_PROP_NAME = '__parentprop';
|
|
6350
6350
|
const CURRENT_PATH_NAME = '__currentPaths';
|
|
6351
|
+
const UNDEFINED_COMP_NAME = '_Undefined';
|
|
6351
6352
|
const PRIMITIVE_COMP_NAME = '_PrimitiveProp'; // TODO check all literal and replace with this constant
|
|
6352
6353
|
const FRAGMENT_COMP_NAME = 'Fragment'; // TODO check all literal and replace with this constant
|
|
6353
|
-
var constants=/*#__PURE__*/Object.freeze({__proto__:null,SEPARATOR:SEPARATOR,STORE_ERROR_POSTFIX:STORE_ERROR_POSTFIX,PATH_MODIFIERS_KEY:PATH_MODIFIERS_KEY,MODIFIER_KEY:MODIFIER_KEY,ACTION_KEY:ACTION_KEY,PERSIST_STORAGE_KEY:PERSIST_STORAGE_KEY,PERSIST_STORAGE_NAMES:PERSIST_STORAGE_NAMES,REF_ASSETS:REF_ASSETS,REF_LOCALES:REF_LOCALES,REF_VALIDATES:REF_VALIDATES,STYLE_WEB_NAME:STYLE_WEB_NAME,STYLE_RN_NAME:STYLE_RN_NAME,REDUX_GET_FUNCTION:REDUX_GET_FUNCTION,REDUX_SET_FUNCTION:REDUX_SET_FUNCTION,REDUX_FUNCTIONS:REDUX_FUNCTIONS,PATHNAME:PATHNAME,SIMPLE_DATA_TYPES:SIMPLE_DATA_TYPES,V_CHILDREN_NAME:V_CHILDREN_NAME,V_COMP_NAME:V_COMP_NAME,LIST_SEMAPHORE:LIST_SEMAPHORE,LIST_ITEM:LIST_ITEM,LIST_PAGE:LIST_PAGE,LIST_ITEM_PER_PAGE:LIST_ITEM_PER_PAGE,LIST_LENGTH:LIST_LENGTH,LIST_ITEM_PER_PAGE_DEFAULT:LIST_ITEM_PER_PAGE_DEFAULT,REDUX_PATHS:REDUX_PATHS,V_CHILDREN_PREFIX:V_CHILDREN_PREFIX,PARENT_PROP_NAME:PARENT_PROP_NAME,CURRENT_PATH_NAME:CURRENT_PATH_NAME,PRIMITIVE_COMP_NAME:PRIMITIVE_COMP_NAME,FRAGMENT_COMP_NAME:FRAGMENT_COMP_NAME});var jsonpointer = {};var hasExcape = /~/;
|
|
6354
|
+
var constants=/*#__PURE__*/Object.freeze({__proto__:null,SEPARATOR:SEPARATOR,STORE_ERROR_POSTFIX:STORE_ERROR_POSTFIX,PATH_MODIFIERS_KEY:PATH_MODIFIERS_KEY,MODIFIER_KEY:MODIFIER_KEY,ACTION_KEY:ACTION_KEY,PERSIST_STORAGE_KEY:PERSIST_STORAGE_KEY,PERSIST_STORAGE_NAMES:PERSIST_STORAGE_NAMES,REF_ASSETS:REF_ASSETS,REF_LOCALES:REF_LOCALES,REF_VALIDATES:REF_VALIDATES,STYLE_WEB_NAME:STYLE_WEB_NAME,STYLE_RN_NAME:STYLE_RN_NAME,REDUX_GET_FUNCTION:REDUX_GET_FUNCTION,REDUX_SET_FUNCTION:REDUX_SET_FUNCTION,REDUX_FUNCTIONS:REDUX_FUNCTIONS,PATHNAME:PATHNAME,SIMPLE_DATA_TYPES:SIMPLE_DATA_TYPES,V_CHILDREN_NAME:V_CHILDREN_NAME,V_COMP_NAME:V_COMP_NAME,LIST_SEMAPHORE:LIST_SEMAPHORE,LIST_ITEM:LIST_ITEM,LIST_PAGE:LIST_PAGE,LIST_ITEM_PER_PAGE:LIST_ITEM_PER_PAGE,LIST_LENGTH:LIST_LENGTH,LIST_ITEM_PER_PAGE_DEFAULT:LIST_ITEM_PER_PAGE_DEFAULT,REDUX_PATHS:REDUX_PATHS,V_CHILDREN_PREFIX:V_CHILDREN_PREFIX,PARENT_PROP_NAME:PARENT_PROP_NAME,CURRENT_PATH_NAME:CURRENT_PATH_NAME,UNDEFINED_COMP_NAME:UNDEFINED_COMP_NAME,PRIMITIVE_COMP_NAME:PRIMITIVE_COMP_NAME,FRAGMENT_COMP_NAME:FRAGMENT_COMP_NAME});var jsonpointer = {};var hasExcape = /~/;
|
|
6354
6355
|
var escapeMatcher = /~[01]/g;
|
|
6355
6356
|
function escapeReplacer (m) {
|
|
6356
6357
|
switch (m) {
|
|
@@ -8206,11 +8207,11 @@ const getRootWrapperProps = (props, stock) => {
|
|
|
8206
8207
|
newProps.subscriberPaths = subscriberPaths;
|
|
8207
8208
|
return newProps;
|
|
8208
8209
|
};
|
|
8209
|
-
const
|
|
8210
|
+
const isChildrenProp = (propName) => !!propName && typeof propName === 'string' && propName.startsWith(V_CHILDREN_PREFIX);
|
|
8210
8211
|
const getParentProps = (props) => {
|
|
8211
8212
|
return props && typeof props === 'object' && !Array.isArray(props)
|
|
8212
8213
|
? Object.keys(props)
|
|
8213
|
-
.filter((key) => !
|
|
8214
|
+
.filter((key) => !isChildrenProp(key) && key !== PARENT_PROP_NAME)
|
|
8214
8215
|
.reduce((newObj, key) => {
|
|
8215
8216
|
// eslint-disable-next-line no-param-reassign
|
|
8216
8217
|
newObj[key] = props[key];
|
|
@@ -8220,7 +8221,7 @@ const getParentProps = (props) => {
|
|
|
8220
8221
|
};
|
|
8221
8222
|
const getPropsChildrenFilter = ({ props, filter }) => props && typeof props === 'object' && !Array.isArray(props)
|
|
8222
8223
|
? Object.keys(props)
|
|
8223
|
-
.filter((key) => ((filter === 'withoutChildren' && !
|
|
8224
|
+
.filter((key) => ((filter === 'withoutChildren' && !isChildrenProp(key)) || (filter === 'onlyChildren' && isChildrenProp(key))) && key !== PARENT_PROP_NAME)
|
|
8224
8225
|
.reduce((newObj, key) => {
|
|
8225
8226
|
// eslint-disable-next-line no-param-reassign
|
|
8226
8227
|
newObj[key] = props[key];
|
|
@@ -8254,10 +8255,25 @@ const generateNewChildren = (props, { Wrapper }) => {
|
|
|
8254
8255
|
}
|
|
8255
8256
|
return undefined;
|
|
8256
8257
|
};
|
|
8258
|
+
const isTechnicalProp = (propName) => [
|
|
8259
|
+
PARENT_PROP_NAME,
|
|
8260
|
+
STYLE_WEB_NAME,
|
|
8261
|
+
V_COMP_NAME,
|
|
8262
|
+
PATH_MODIFIERS_KEY,
|
|
8263
|
+
CURRENT_PATH_NAME,
|
|
8264
|
+
PATH_MODIFIERS_KEY,
|
|
8265
|
+
LIST_SEMAPHORE,
|
|
8266
|
+
LIST_ITEM,
|
|
8267
|
+
LIST_PAGE,
|
|
8268
|
+
LIST_ITEM_PER_PAGE,
|
|
8269
|
+
LIST_LENGTH,
|
|
8270
|
+
'style',
|
|
8271
|
+
'subscriberPaths',
|
|
8272
|
+
].includes(propName);
|
|
8257
8273
|
const removeTechnicalProps = (changeableProps) => {
|
|
8258
8274
|
const _a = changeableProps, _b = PARENT_PROP_NAME; _a[_b]; const _c = STYLE_WEB_NAME; _a[_c]; const _d = V_COMP_NAME; _a[_d]; const _e = PATH_MODIFIERS_KEY; _a[_e]; const _f = CURRENT_PATH_NAME; _a[_f]; const _g = PATH_MODIFIERS_KEY; _a[_g]; const _h = LIST_SEMAPHORE; _a[_h]; const _j = LIST_ITEM; _a[_j]; const _k = LIST_PAGE; _a[_k]; const _l = LIST_ITEM_PER_PAGE; _a[_l]; const _m = LIST_LENGTH; _a[_m]; const newProps = __rest(_a, [_b + "", "style", _c + "", _d + "", _e + "", _f + "", "subscriberPaths", _g + "", _h + "", _j + "", _k + "", _l + "", _m + ""]);
|
|
8259
8275
|
return newProps;
|
|
8260
|
-
};var wrapperUtil=/*#__PURE__*/Object.freeze({__proto__:null,getFilteredPath:getFilteredPath,actionBuilder:actionBuilder,calculatePropsFromModifier:calculatePropsFromModifier,getCurrentPaths:getCurrentPaths,normalisePrimitives:normalisePrimitives,getRootWrapperProps:getRootWrapperProps,
|
|
8276
|
+
};var wrapperUtil=/*#__PURE__*/Object.freeze({__proto__:null,getFilteredPath:getFilteredPath,actionBuilder:actionBuilder,calculatePropsFromModifier:calculatePropsFromModifier,getCurrentPaths:getCurrentPaths,normalisePrimitives:normalisePrimitives,getRootWrapperProps:getRootWrapperProps,isChildrenProp:isChildrenProp,getParentProps:getParentProps,getPropsChildrenFilter:getPropsChildrenFilter,getChildrensForRoot:getChildrensForRoot,generateChildren:generateChildren,generateNewChildren:generateNewChildren,isTechnicalProp:isTechnicalProp,removeTechnicalProps:removeTechnicalProps});var ajv = {exports: {}};var core$2 = {};var validate = {};var boolSchema = {};var errors = {};var codegen = {};var code$1 = {};(function (exports) {
|
|
8261
8277
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8262
8278
|
exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
|
|
8263
8279
|
class _CodeOrName {
|
|
@@ -18515,14 +18531,13 @@ var defaultsDeep = baseRest(function(args) {
|
|
|
18515
18531
|
var defaultsDeep_1 = defaultsDeep;
|
|
18516
18532
|
|
|
18517
18533
|
function Text(_a) {
|
|
18518
|
-
var { value
|
|
18519
|
-
|
|
18520
|
-
return jsxRuntime$1.exports.jsx("p", Object.assign({}, props, { children: wrapperUtil.generateNewChildren(value || children, stock) }), void 0);
|
|
18534
|
+
var { value, children } = _a, props = __rest$1(_a, ["value", "children"]);
|
|
18535
|
+
return jsxRuntime$1.exports.jsx("p", Object.assign({}, props, { children: value || children }), void 0);
|
|
18521
18536
|
}
|
|
18522
18537
|
|
|
18523
|
-
function Button(
|
|
18524
|
-
|
|
18525
|
-
return jsxRuntime$1.exports.jsx("button", Object.assign({}, props), void 0);
|
|
18538
|
+
function Button(_a) {
|
|
18539
|
+
var { children, type } = _a, props = __rest$1(_a, ["children", "type"]);
|
|
18540
|
+
return (jsxRuntime$1.exports.jsx("button", Object.assign({ type: "button" }, props, { children: children }), void 0));
|
|
18526
18541
|
}
|
|
18527
18542
|
|
|
18528
18543
|
function Edit(props) {
|
|
@@ -18556,10 +18571,8 @@ function Edit(props) {
|
|
|
18556
18571
|
return (jsxRuntime$1.exports.jsxs(jsxRuntime$1.exports.Fragment, { children: [jsxRuntime$1.exports.jsx("p", Object.assign({ style: { fontSize: 20, color: error ? 'red' : undefined } }, { children: label }), void 0), jsxRuntime$1.exports.jsx("input", Object.assign({}, ownProps, { value: value || '', onChange: handleChange }), void 0), jsxRuntime$1.exports.jsx("p", Object.assign({ style: { fontSize: 10, color: error ? 'red' : undefined } }, { children: helperText }), void 0)] }, void 0));
|
|
18557
18572
|
}
|
|
18558
18573
|
|
|
18559
|
-
function View(
|
|
18560
|
-
|
|
18561
|
-
const stock = useContext(StockContext);
|
|
18562
|
-
return jsxRuntime$1.exports.jsx("div", Object.assign({}, props, { children: wrapperUtil.generateNewChildren(children, stock) }), void 0);
|
|
18574
|
+
function View(props) {
|
|
18575
|
+
return jsxRuntime$1.exports.jsx("div", Object.assign({}, props), void 0);
|
|
18563
18576
|
}
|
|
18564
18577
|
|
|
18565
18578
|
function Image(props) {
|
|
@@ -18632,20 +18645,16 @@ function Undefined(props) {
|
|
|
18632
18645
|
} }, { children: getLabel(props) }), void 0));
|
|
18633
18646
|
}
|
|
18634
18647
|
|
|
18635
|
-
function PrimitiveProp({
|
|
18648
|
+
function PrimitiveProp({ children }) {
|
|
18636
18649
|
return jsxRuntime$1.exports.jsx("span", { children: !constants.SIMPLE_DATA_TYPES.includes(typeof children) || typeof children === 'boolean' ? JSON.stringify(children) : children }, void 0);
|
|
18637
18650
|
}
|
|
18638
18651
|
|
|
18639
|
-
const Fragment = (
|
|
18640
|
-
var _b = constants.V_CHILDREN_NAME, props = _a[_b]; __rest$1(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
18641
|
-
const stock = useContext(StockContext);
|
|
18642
|
-
return jsxRuntime$1.exports.jsx(jsxRuntime$1.exports.Fragment, { children: wrapperUtil.generateNewChildren(props, stock) }, void 0);
|
|
18643
|
-
};
|
|
18652
|
+
const Fragment = ({ children }) => children;
|
|
18644
18653
|
|
|
18645
18654
|
const Components = {
|
|
18646
18655
|
View,
|
|
18647
|
-
|
|
18648
|
-
|
|
18656
|
+
[constants.PRIMITIVE_COMP_NAME]: PrimitiveProp,
|
|
18657
|
+
[constants.UNDEFINED_COMP_NAME]: Undefined,
|
|
18649
18658
|
Fragment,
|
|
18650
18659
|
Image,
|
|
18651
18660
|
Text,
|
|
@@ -24132,7 +24141,26 @@ function Wrapper({ props: origProps }) {
|
|
|
24132
24141
|
const newStyle = ownProps.style || ownProps[constants.STYLE_WEB_NAME] ? getStyle(ownProps, component) : undefined;
|
|
24133
24142
|
return (jsxRuntime$1.exports.jsx(ErrorBoundary, Object.assign({ type: "wrapper", id: props.id }, { children: jsxRuntime$1.exports.jsx(ClassNames, { children: ({ css, cx }) => {
|
|
24134
24143
|
ownProps.className = newStyle ? cx(css(newStyle)) : undefined;
|
|
24135
|
-
const newProps =
|
|
24144
|
+
const newProps = Object.keys(ownProps).reduce((newObj, childName) => {
|
|
24145
|
+
// eslint-disable-next-line no-param-reassign
|
|
24146
|
+
if (wrapperUtil.isChildrenProp(childName)) {
|
|
24147
|
+
const res = component === constants.PRIMITIVE_COMP_NAME ? ownProps[childName] : wrapperUtil.generateNewChildren(ownProps[childName], stock);
|
|
24148
|
+
// eslint-disable-next-line no-param-reassign
|
|
24149
|
+
if (childName === constants.V_CHILDREN_NAME) {
|
|
24150
|
+
// eslint-disable-next-line no-param-reassign
|
|
24151
|
+
newObj.children = res;
|
|
24152
|
+
}
|
|
24153
|
+
else {
|
|
24154
|
+
// eslint-disable-next-line no-param-reassign
|
|
24155
|
+
newObj[childName] = res;
|
|
24156
|
+
}
|
|
24157
|
+
}
|
|
24158
|
+
else if (!wrapperUtil.isTechnicalProp(childName)) {
|
|
24159
|
+
// eslint-disable-next-line no-param-reassign
|
|
24160
|
+
newObj[childName] = ownProps[childName];
|
|
24161
|
+
}
|
|
24162
|
+
return newObj;
|
|
24163
|
+
}, {});
|
|
24136
24164
|
// children was {wrapperUtil.generateChildren(ownProps, stock)}
|
|
24137
24165
|
return ownProps[constants.PATH_MODIFIERS_KEY] ? (jsxRuntime$1.exports.jsxs(PathModifierContext.Provider, Object.assign({ value: props[constants.CURRENT_PATH_NAME] }, { children: [jsxRuntime$1.exports.jsx(Comp, Object.assign({}, newProps), void 0), infobox ] }), void 0)) : (jsxRuntime$1.exports.jsxs(jsxRuntime$1.exports.Fragment, { children: [jsxRuntime$1.exports.jsx(Comp, Object.assign({}, newProps), void 0), infobox ] }, void 0));
|
|
24138
24166
|
} }, void 0) }), void 0));
|