@evlop/commons 1.0.206 → 1.0.207
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.
@@ -1,19 +1,18 @@
|
|
1
1
|
import React, { PropsWithChildren, PropsWithoutRef, RefAttributes } from 'react';
|
2
|
-
|
3
|
-
declare type SettingProp = {
|
2
|
+
declare type ModalProps = {
|
4
3
|
model?: string;
|
5
4
|
dataModel?: string;
|
6
5
|
configModel?: string;
|
7
|
-
action?: Action;
|
8
6
|
};
|
9
|
-
export declare type ComponentWithSettings<P extends Object> = React.ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<P &
|
10
|
-
export declare
|
11
|
-
valueOptions
|
12
|
-
configurationOptions
|
13
|
-
}
|
14
|
-
export declare const
|
15
|
-
|
16
|
-
|
17
|
-
}) =>
|
7
|
+
export declare type ComponentWithSettings<P extends Object> = React.ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<P & ModalProps>> & RefAttributes<any>>;
|
8
|
+
export declare type SettingOptions = {
|
9
|
+
valueOptions: any[];
|
10
|
+
configurationOptions: any[];
|
11
|
+
};
|
12
|
+
export declare const withSettings: (settingOptions: SettingOptions) => <P extends Object>(BaseComponent: React.ComponentType<P>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<React.PropsWithChildren<P & ModalProps>> & React.RefAttributes<any>>;
|
13
|
+
export declare const withModelPropsLoader: (settingOptions: SettingOptions) => <P extends Object>(BaseComponent: React.ComponentType<P>) => (props: P & ModalProps & {
|
14
|
+
_innerRef: any;
|
15
|
+
}) => JSX.Element;
|
16
|
+
export declare const withToolbar: (settingOptions: SettingOptions) => <P extends Object>(BaseComponent: React.ComponentType<P>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<React.PropsWithChildren<P & ModalProps>> & React.RefAttributes<any>>;
|
18
17
|
export default withSettings;
|
19
18
|
//# sourceMappingURL=withSettings.native.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withSettings.native.d.ts","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAW,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"withSettings.native.d.ts","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.native.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAW,MAAM,OAAO,CAAC;AAGtG,aAAK,UAAU,GAAG;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE7E,oBAAY,qBAAqB,CAAC,CAAC,SAAS,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;AAE9J,oBAAY,cAAc,GAAG;IAAC,YAAY,EAAE,GAAG,EAAE,CAAC;IAAC,oBAAoB,EAAE,GAAG,EAAE,CAAA;CAAC,CAAC;AAEhF,eAAO,MAAM,YAAY,mBAAoB,cAAc,4LAkB1D,CAAA;AAGD,eAAO,MAAM,oBAAoB,mBAAkB,cAAc;eAAwG,GAAG;iBAiB3K,CAAC;AAGF,eAAO,MAAM,WAAW,mBAzCqB,cAAc,4LAyCpB,CAAC;AACxC,eAAe,YAAY,CAAC"}
|
@@ -30,36 +30,33 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
30
30
|
return t;
|
31
31
|
};
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
33
|
-
exports.withToolbar = exports.withSettings = void 0;
|
33
|
+
exports.withToolbar = exports.withModelPropsLoader = exports.withSettings = void 0;
|
34
34
|
const lodash_1 = require("lodash");
|
35
35
|
const react_1 = __importStar(require("react"));
|
36
36
|
const hooks_1 = require("../../hooks");
|
37
|
-
const withSettings = (
|
38
|
-
const
|
37
|
+
const withSettings = (settingOptions) => (BaseComponent) => {
|
38
|
+
const ComponentWithModalPropsLoader = exports.withModelPropsLoader(settingOptions)(BaseComponent);
|
39
|
+
return react_1.forwardRef((props, forwardedRef) => {
|
40
|
+
const { model, dataModel = model, configModel = dataModel && `${dataModel}_config` } = props, remainingProps = __rest(props, ["model", "dataModel", "configModel"]);
|
41
|
+
if (dataModel || configModel) {
|
42
|
+
return react_1.default.createElement(ComponentWithModalPropsLoader, Object.assign({ _innerRef: forwardedRef, dataModel: dataModel, configModel: configModel }, remainingProps));
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
return react_1.default.createElement(BaseComponent, Object.assign({ ref: forwardedRef }, props));
|
46
|
+
}
|
47
|
+
});
|
48
|
+
};
|
49
|
+
exports.withSettings = withSettings;
|
50
|
+
const withModelPropsLoader = (settingOptions) => (BaseComponent) => (props) => {
|
51
|
+
const { model, _innerRef, dataModel = model, configModel = dataModel && `${dataModel}_config` } = props, remainingProps = __rest(props, ["model", "_innerRef", "dataModel", "configModel"]);
|
39
52
|
const { data } = hooks_1.useComponentData();
|
40
|
-
// Extract values from component data
|
41
|
-
const
|
42
|
-
|
43
|
-
return {};
|
44
|
-
// merge configuration option from props and configuration option values from model
|
45
|
-
const valuePropNames = lodash_1.map(valueOptions, 'name');
|
46
|
-
const propsForValue = lodash_1.pick(props, valuePropNames);
|
47
|
-
return lodash_1.assign(propsForValue, lodash_1.get(data, dataModel));
|
53
|
+
// Extract values from component data,
|
54
|
+
const propsFromModel = react_1.useMemo(() => {
|
55
|
+
return lodash_1.assign({}, lodash_1.get(data, configModel), lodash_1.get(data, dataModel));
|
48
56
|
}, [dataModel, props, data]);
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
return {};
|
53
|
-
// merge configuration option from props and configuration option values from model
|
54
|
-
const configOptionPropNames = lodash_1.map(configurationOptions, 'name');
|
55
|
-
const propsForConfigOptions = lodash_1.pick(props, configOptionPropNames);
|
56
|
-
return lodash_1.assign(propsForConfigOptions, lodash_1.get(data, configModel));
|
57
|
-
}, [configModel, props, data]);
|
58
|
-
const action = values.action || actionProp || onPress;
|
59
|
-
const actionHandeller = hooks_1.useAction(action);
|
60
|
-
return (react_1.default.createElement(BaseComponent, Object.assign({ ref: forwardedRef }, remainingProps, configs, values, { onPress: actionHandeller, action: action })));
|
61
|
-
});
|
62
|
-
exports.withSettings = withSettings;
|
57
|
+
return (react_1.default.createElement(BaseComponent, Object.assign({ ref: _innerRef }, remainingProps, propsFromModel)));
|
58
|
+
};
|
59
|
+
exports.withModelPropsLoader = withModelPropsLoader;
|
63
60
|
exports.withToolbar = exports.withSettings;
|
64
61
|
exports.default = exports.withSettings;
|
65
62
|
//# sourceMappingURL=withSettings.native.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withSettings.native.js","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.native.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgD;AAChD,+CAAsG;AACtG,
|
1
|
+
{"version":3,"file":"withSettings.native.js","sourceRoot":"","sources":["../../../../src/components/hoc/withSettings.native.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAgD;AAChD,+CAAsG;AACtG,uCAA+C;AAQxC,MAAM,YAAY,GAAG,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAmB,aAAqC,EAAE,EAAE;IAExH,MAAM,6BAA6B,GAAG,4BAAoB,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC,CAAC;IAE1F,OAAO,kBAAU,CAAyC,CAAC,KAAU,EAAE,YAAY,EAAE,EAAE;QACnF,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,EAAG,WAAW,GAAG,SAAS,IAAI,GAAG,SAAS,SAAS,KAAuB,KAAK,EAAvB,cAAc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