@semcore/core 1.14.5 → 1.14.7
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/CHANGELOG.md +2 -2
- package/lib/cjs/Component.js +0 -16
- package/lib/cjs/Component.js.map +1 -1
- package/lib/cjs/enhancement/Children.js +17 -42
- package/lib/cjs/enhancement/Children.js.map +1 -1
- package/lib/cjs/enhancement/Root.js +15 -33
- package/lib/cjs/enhancement/Root.js.map +1 -1
- package/lib/cjs/enhancement/bindHandler.js +0 -11
- package/lib/cjs/enhancement/bindHandler.js.map +1 -1
- package/lib/cjs/enhancement/dataName.js +0 -4
- package/lib/cjs/enhancement/dataName.js.map +1 -1
- package/lib/cjs/enhancement/enhance.js +0 -2
- package/lib/cjs/enhancement/enhance.js.map +1 -1
- package/lib/cjs/enhancement/functionDefaultProps.js +0 -5
- package/lib/cjs/enhancement/functionDefaultProps.js.map +1 -1
- package/lib/cjs/enhancement/hoistProps.js +10 -27
- package/lib/cjs/enhancement/hoistProps.js.map +1 -1
- package/lib/cjs/enhancement/inheritedName.js +0 -6
- package/lib/cjs/enhancement/inheritedName.js.map +1 -1
- package/lib/cjs/enhancement/staticChildren.js +14 -45
- package/lib/cjs/enhancement/staticChildren.js.map +1 -1
- package/lib/cjs/enhancement/style.js +4 -16
- package/lib/cjs/enhancement/style.js.map +1 -1
- package/lib/cjs/enhancement/uncontrolledProps.js +16 -49
- package/lib/cjs/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/cjs/index.js +49 -134
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/register.js +0 -9
- package/lib/cjs/register.js.map +1 -1
- package/lib/cjs/styled/index.js +0 -5
- package/lib/cjs/styled/index.js.map +1 -1
- package/lib/cjs/styled/sstyled.js +16 -55
- package/lib/cjs/styled/sstyled.js.map +1 -1
- package/lib/es6/Component.js +0 -11
- package/lib/es6/Component.js.map +1 -1
- package/lib/es6/enhancement/Children.js +17 -36
- package/lib/es6/enhancement/Children.js.map +1 -1
- package/lib/es6/enhancement/Root.js +19 -30
- package/lib/es6/enhancement/Root.js.map +1 -1
- package/lib/es6/enhancement/bindHandler.js +0 -10
- package/lib/es6/enhancement/bindHandler.js.map +1 -1
- package/lib/es6/enhancement/dataName.js +0 -2
- package/lib/es6/enhancement/dataName.js.map +1 -1
- package/lib/es6/enhancement/enhance.js +0 -1
- package/lib/es6/enhancement/enhance.js.map +1 -1
- package/lib/es6/enhancement/functionDefaultProps.js +0 -4
- package/lib/es6/enhancement/functionDefaultProps.js.map +1 -1
- package/lib/es6/enhancement/hoistProps.js +13 -23
- package/lib/es6/enhancement/hoistProps.js.map +1 -1
- package/lib/es6/enhancement/inheritedName.js +0 -2
- package/lib/es6/enhancement/inheritedName.js.map +1 -1
- package/lib/es6/enhancement/staticChildren.js +17 -41
- package/lib/es6/enhancement/staticChildren.js.map +1 -1
- package/lib/es6/enhancement/style.js +6 -12
- package/lib/es6/enhancement/style.js.map +1 -1
- package/lib/es6/enhancement/uncontrolledProps.js +16 -42
- package/lib/es6/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/es6/index.js +55 -110
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/register.js +0 -5
- package/lib/es6/register.js.map +1 -1
- package/lib/es6/styled/index.js.map +1 -1
- package/lib/es6/styled/sstyled.js +14 -49
- package/lib/es6/styled/sstyled.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,61 +2,52 @@ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["render"],
|
|
5
|
-
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
import assignProps from '@semcore/utils/lib/assignProps';
|
|
9
|
-
|
|
5
|
+
_excluded2 = ["Root", "styles", "children", "Children", "forwardRef"];
|
|
6
|
+
import React from 'react';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import assignProps from '@semcore/utils/lib/assignProps';
|
|
9
|
+
// @ts-ignore
|
|
10
10
|
import { useForkRef } from '@semcore/utils/lib/ref';
|
|
11
|
-
|
|
12
11
|
function createRootRender() {
|
|
13
12
|
// @ts-ignore
|
|
14
13
|
var Root = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
15
14
|
var Tag = _ref.render,
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
source = _objectWithoutProperties(_ref, _excluded);
|
|
18
16
|
var _Root$props = Root.props,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
_Root = _Root$props.Root,
|
|
18
|
+
styles = _Root$props.styles,
|
|
19
|
+
children = _Root$props.children,
|
|
20
|
+
Children = _Root$props.Children,
|
|
21
|
+
_Root$props$forwardRe = _Root$props.forwardRef,
|
|
22
|
+
forwardRef = _Root$props$forwardRe === void 0 ? null : _Root$props$forwardRe,
|
|
23
|
+
props = _objectWithoutProperties(_Root$props, _excluded2);
|
|
27
24
|
var clearProps = Object.entries(props).reduce(function (props, _ref2) {
|
|
28
25
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
name = _ref3[0],
|
|
27
|
+
value = _ref3[1];
|
|
32
28
|
if (value !== undefined) {
|
|
33
29
|
props[name] = value;
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
return props;
|
|
37
32
|
}, {});
|
|
38
|
-
var child = {};
|
|
39
|
-
|
|
33
|
+
var child = {};
|
|
34
|
+
// TODO: need to find better check solution (by lsroman)
|
|
40
35
|
if (typeof Children.origin !== 'undefined') {
|
|
41
36
|
// @ts-ignore
|
|
42
37
|
child.children = /*#__PURE__*/React.createElement(Children, null);
|
|
43
38
|
}
|
|
44
|
-
|
|
45
39
|
var other = assignProps(_objectSpread(_objectSpread({}, clearProps), {}, {
|
|
46
40
|
ref: useForkRef(forwardRef, ref)
|
|
47
41
|
}), _objectSpread(_objectSpread({}, child), source));
|
|
48
|
-
|
|
49
42
|
if (!Tag) {
|
|
50
43
|
throw new Error('`render` prop of Root is not provided');
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
return /*#__PURE__*/React.createElement(Tag, other);
|
|
54
|
-
});
|
|
55
|
-
|
|
46
|
+
});
|
|
47
|
+
// @ts-ignore
|
|
56
48
|
Root.props = {};
|
|
57
49
|
return Root;
|
|
58
50
|
}
|
|
59
|
-
|
|
60
51
|
function Enhancement() {
|
|
61
52
|
return {
|
|
62
53
|
init: function init() {
|
|
@@ -68,7 +59,6 @@ function Enhancement() {
|
|
|
68
59
|
Root: this.Root
|
|
69
60
|
});
|
|
70
61
|
}
|
|
71
|
-
|
|
72
62
|
return props;
|
|
73
63
|
},
|
|
74
64
|
render: function render(_render, props) {
|
|
@@ -77,6 +67,5 @@ function Enhancement() {
|
|
|
77
67
|
}
|
|
78
68
|
};
|
|
79
69
|
}
|
|
80
|
-
|
|
81
70
|
export default Enhancement;
|
|
82
71
|
//# sourceMappingURL=Root.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.js","names":["React","assignProps","useForkRef","createRootRender","Root","forwardRef","ref","Tag","render","source","props","_Root","styles","children","Children","clearProps","Object","entries","reduce","name","value","undefined","child","origin","other","Error","Enhancement","init","asProps","WrapperComponent","isFunction"],"sources":["../../../src/enhancement/Root.tsx"],"sourcesContent":["import React from 'react';\n// @ts-ignore\nimport assignProps from '@semcore/utils/lib/assignProps';\n// @ts-ignore\nimport { useForkRef } from '@semcore/utils/lib/ref';\n\nfunction createRootRender() {\n // @ts-ignore\n const Root = React.forwardRef(function ({ render: Tag, ...source }, ref) {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Root: _Root,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n styles,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n children,\n Children,\n forwardRef = null,\n ...props\n // @ts-ignore\n } = Root.props;\n\n const clearProps = Object.entries(props).reduce((props, [name, value]) => {\n if (value !== undefined) {\n props[name] = value;\n }\n return props;\n }, {});\n\n const child = {};\n // TODO: need to find better check solution (by lsroman)\n if (typeof Children.origin !== 'undefined') {\n // @ts-ignore\n child.children = <Children />;\n }\n\n const other = assignProps(\n {\n ...clearProps,\n ref: useForkRef(forwardRef, ref),\n },\n {\n ...child,\n ...source,\n },\n );\n if (!Tag) {\n throw new Error('`render` prop of Root is not provided');\n }\n return <Tag {...other} />;\n });\n // @ts-ignore\n Root.props = {};\n return Root;\n}\n\nfunction Enhancement() {\n return {\n init: function () {\n this.Root = createRootRender();\n },\n asProps: function (props, WrapperComponent, isFunction) {\n if (isFunction) {\n return {\n ...props,\n Root: this.Root,\n };\n }\n return props;\n },\n render: function (render, props) {\n this.Root.props = props;\n return render;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;AAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"Root.js","names":["React","assignProps","useForkRef","createRootRender","Root","forwardRef","_ref","ref","Tag","render","source","_objectWithoutProperties","_excluded","_Root$props","props","_Root","styles","children","Children","_Root$props$forwardRe","_excluded2","clearProps","Object","entries","reduce","_ref2","_ref3","_slicedToArray","name","value","undefined","child","origin","createElement","other","_objectSpread","Error","Enhancement","init","asProps","WrapperComponent","isFunction"],"sources":["../../../src/enhancement/Root.tsx"],"sourcesContent":["import React from 'react';\n// @ts-ignore\nimport assignProps from '@semcore/utils/lib/assignProps';\n// @ts-ignore\nimport { useForkRef } from '@semcore/utils/lib/ref';\n\nfunction createRootRender() {\n // @ts-ignore\n const Root = React.forwardRef(function ({ render: Tag, ...source }, ref) {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Root: _Root,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n styles,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n children,\n Children,\n forwardRef = null,\n ...props\n // @ts-ignore\n } = Root.props;\n\n const clearProps = Object.entries(props).reduce((props, [name, value]) => {\n if (value !== undefined) {\n props[name] = value;\n }\n return props;\n }, {});\n\n const child = {};\n // TODO: need to find better check solution (by lsroman)\n if (typeof Children.origin !== 'undefined') {\n // @ts-ignore\n child.children = <Children />;\n }\n\n const other = assignProps(\n {\n ...clearProps,\n ref: useForkRef(forwardRef, ref),\n },\n {\n ...child,\n ...source,\n },\n );\n if (!Tag) {\n throw new Error('`render` prop of Root is not provided');\n }\n return <Tag {...other} />;\n });\n // @ts-ignore\n Root.props = {};\n return Root;\n}\n\nfunction Enhancement() {\n return {\n init: function () {\n this.Root = createRootRender();\n },\n asProps: function (props, WrapperComponent, isFunction) {\n if (isFunction) {\n return {\n ...props,\n Root: this.Root,\n };\n }\n return props;\n },\n render: function (render, props) {\n this.Root.props = props;\n return render;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB;AACA,OAAOC,WAAW,MAAM,gCAAgC;AACxD;AACA,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,gBAAgBA,CAAA,EAAG;EAC1B;EACA,IAAMC,IAAI,gBAAGJ,KAAK,CAACK,UAAU,CAAC,UAAAC,IAAA,EAAsCC,GAAG,EAAE;IAAA,IAAvBC,GAAG,GAAAF,IAAA,CAAXG,MAAM;MAAUC,MAAM,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;IAC9D,IAAAC,WAAA,GAWIT,IAAI,CAACU,KAAK;MATNC,KAAK,GAAAF,WAAA,CAAXT,IAAI;MAEJY,MAAM,GAAAH,WAAA,CAANG,MAAM;MAENC,QAAQ,GAAAJ,WAAA,CAARI,QAAQ;MACRC,QAAQ,GAAAL,WAAA,CAARK,QAAQ;MAAAC,qBAAA,GAAAN,WAAA,CACRR,UAAU;MAAVA,UAAU,GAAAc,qBAAA,cAAG,IAAI,GAAAA,qBAA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gB,EAAEC,UAAU,EAAE;MACtD,IAAIA,UAAU,EAAE;QACd,OAAAN,aAAA,CAAAA,aAAA,KACKrB,KAAK;UACRV,IAAI,EAAE,IAAI,CAACA;QAAI;MAEnB;MACA,OAAOU,KAAK;IACd,CAAC;IACDL,MAAM,EAAE,SAAAA,OAAUA,OAAM,EAAEK,KAAK,EAAE;MAC/B,IAAI,CAACV,IAAI,CAACU,KAAK,GAAGA,KAAK;MACvB,OAAOL,OAAM;IACf;EACF,CAAC;AACH;AAEA,eAAe4B,WAAW"}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
function arraysEqual(a, b) {
|
|
2
2
|
if (a.length !== b.length) return false;
|
|
3
|
-
|
|
4
3
|
for (var i = 0; i < a.length; i++) {
|
|
5
4
|
if (a[i] !== b[i]) return false;
|
|
6
5
|
}
|
|
7
|
-
|
|
8
6
|
return true;
|
|
9
7
|
}
|
|
10
|
-
|
|
11
8
|
function handlerBinder(fn) {
|
|
12
9
|
return function () {
|
|
13
10
|
for (var _len = arguments.length, depsArgs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
11
|
depsArgs[_key] = arguments[_key];
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
var memoizeds = [];
|
|
18
|
-
|
|
19
14
|
if (handlerBinder.hasher.has(fn)) {
|
|
20
15
|
memoizeds = handlerBinder.hasher.get(fn);
|
|
21
16
|
var memoized = memoizeds.find(function (memoized) {
|
|
@@ -23,7 +18,6 @@ function handlerBinder(fn) {
|
|
|
23
18
|
});
|
|
24
19
|
if (memoized) return memoized.fn;
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
var bindFn = fn.apply(void 0, depsArgs).bind(fn);
|
|
28
22
|
memoizeds.push({
|
|
29
23
|
deps: depsArgs,
|
|
@@ -33,9 +27,7 @@ function handlerBinder(fn) {
|
|
|
33
27
|
return bindFn;
|
|
34
28
|
};
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
handlerBinder.hasher = new WeakMap();
|
|
38
|
-
|
|
39
31
|
function Enhancement() {
|
|
40
32
|
return {
|
|
41
33
|
condition: function condition(Component, isFunction) {
|
|
@@ -43,7 +35,6 @@ function Enhancement() {
|
|
|
43
35
|
},
|
|
44
36
|
init: function init() {
|
|
45
37
|
var _this = this;
|
|
46
|
-
|
|
47
38
|
Object.keys(this).filter(function (field) {
|
|
48
39
|
return field.startsWith('bindHandler');
|
|
49
40
|
}).forEach(function (name) {
|
|
@@ -52,6 +43,5 @@ function Enhancement() {
|
|
|
52
43
|
}
|
|
53
44
|
};
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
export default Enhancement;
|
|
57
47
|
//# sourceMappingURL=bindHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindHandler.js","names":["arraysEqual","a","b","length","i","handlerBinder","fn","depsArgs","memoizeds","hasher","has","get","memoized","find","deps","bindFn","bind","push","set","WeakMap","Enhancement","condition","Component","isFunction","init","Object","keys","filter","field","startsWith","forEach","name"],"sources":["../../../src/enhancement/bindHandler.tsx"],"sourcesContent":["function arraysEqual(a, b) {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction handlerBinder(fn) {\n return function (...depsArgs) {\n let memoizeds = [];\n if (handlerBinder.hasher.has(fn)) {\n memoizeds = handlerBinder.hasher.get(fn);\n const memoized = memoizeds.find((memoized) => arraysEqual(memoized.deps, depsArgs));\n if (memoized) return memoized.fn;\n }\n\n const bindFn = fn(...depsArgs).bind(fn);\n memoizeds.push({\n deps: depsArgs,\n fn: bindFn,\n });\n handlerBinder.hasher.set(fn, memoizeds);\n return bindFn;\n };\n}\n\nhandlerBinder.hasher = new WeakMap();\n\nfunction Enhancement() {\n return {\n condition: function (Component, isFunction) {\n return !isFunction;\n },\n init: function () {\n Object.keys(this)\n .filter((field) => field.startsWith('bindHandler'))\n .forEach((name) => {\n this[name] = handlerBinder(this[name].bind(this));\n });\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"bindHandler.js","names":["arraysEqual","a","b","length","i","handlerBinder","fn","_len","arguments","depsArgs","Array","_key","memoizeds","hasher","has","get","memoized","find","deps","bindFn","apply","bind","push","set","WeakMap","Enhancement","condition","Component","isFunction","init","_this","Object","keys","filter","field","startsWith","forEach","name"],"sources":["../../../src/enhancement/bindHandler.tsx"],"sourcesContent":["function arraysEqual(a, b) {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction handlerBinder(fn) {\n return function (...depsArgs) {\n let memoizeds = [];\n if (handlerBinder.hasher.has(fn)) {\n memoizeds = handlerBinder.hasher.get(fn);\n const memoized = memoizeds.find((memoized) => arraysEqual(memoized.deps, depsArgs));\n if (memoized) return memoized.fn;\n }\n\n const bindFn = fn(...depsArgs).bind(fn);\n memoizeds.push({\n deps: depsArgs,\n fn: bindFn,\n });\n handlerBinder.hasher.set(fn, memoizeds);\n return bindFn;\n };\n}\n\nhandlerBinder.hasher = new WeakMap();\n\nfunction Enhancement() {\n return {\n condition: function (Component, isFunction) {\n return !isFunction;\n },\n init: function () {\n Object.keys(this)\n .filter((field) => field.startsWith('bindHandler'))\n .forEach((name) => {\n this[name] = handlerBinder(this[name].bind(this));\n });\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":"AAAA,SAASA,WAAWA,CAACC,CAAC,EAAEC,CAAC,EAAE;EACzB,IAAID,CAAC,CAACE,MAAM,KAAKD,CAAC,CAACC,MAAM,EAAE,OAAO,KAAK;EACvC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,CAAC,CAACE,MAAM,EAAEC,CAAC,EAAE,EAAE;IACjC,IAAIH,CAAC,CAACG,CAAC,CAAC,KAAKF,CAAC,CAACE,CAAC,CAAC,EAAE,OAAO,KAAK;EACjC;EACA,OAAO,IAAI;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,CAAC,UAACC,KAAK;QAAA,OAAKA,KAAK,CAACC,UAAU,CAAC,aAAa,CAAC;MAAA,EAAC,CAClDC,OAAO,CAAC,UAACC,IAAI,EAAK;QACjBP,KAAI,CAACO,IAAI,CAAC,GAAGhC,aAAa,CAACyB,KAAI,CAACO,IAAI,CAAC,CAAChB,IAAI,CAACS,KAAI,CAAC,CAAC;MACnD,CAAC,CAAC;IACN;EACF,CAAC;AACH;AAEA,eAAeL,WAAW"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
|
|
3
2
|
function Enhancement() {
|
|
4
3
|
return {
|
|
5
4
|
wrapperProps: function wrapperProps(props, WrapperComponent) {
|
|
@@ -9,6 +8,5 @@ function Enhancement() {
|
|
|
9
8
|
}
|
|
10
9
|
};
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
export default Enhancement;
|
|
14
12
|
//# sourceMappingURL=dataName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataName.js","names":["Enhancement","wrapperProps","props","WrapperComponent","displayName"],"sources":["../../../src/enhancement/dataName.tsx"],"sourcesContent":["function Enhancement() {\n return {\n wrapperProps: function (props, WrapperComponent) {\n return {\n 'data-ui-name': WrapperComponent.displayName,\n ...props,\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dataName.js","names":["Enhancement","wrapperProps","props","WrapperComponent","_objectSpread","displayName"],"sources":["../../../src/enhancement/dataName.tsx"],"sourcesContent":["function Enhancement() {\n return {\n wrapperProps: function (props, WrapperComponent) {\n return {\n 'data-ui-name': WrapperComponent.displayName,\n ...props,\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";AAAA,SAASA,WAAWA,CAAA,EAAG;EACrB,OAAO;IACLC,YAAY,EAAE,SAAAA,aAAUC,KAAK,EAAEC,gBAAgB,EAAE;MAC/C,OAAAC,aAAA;QACE,cAAc,EAAED,gBAAgB,CAACE;MAAW,GACzCH,KAAK;IAEZ;EACF,CAAC;AACH;AAEA,eAAeF,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enhance.js","names":["Enhancement","condition","Component","Boolean","enhance","length","wrapperProps","props","WrapperComponent","reduce","acc"],"sources":["../../../src/enhancement/enhance.tsx"],"sourcesContent":["function Enhancement() {\n return {\n condition: function (Component) {\n return Boolean(Component.enhance && Component.enhance.length);\n },\n wrapperProps: function (props, WrapperComponent) {\n return WrapperComponent.enhance.reduce((acc, enhance) => enhance(acc), props);\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"enhance.js","names":["Enhancement","condition","Component","Boolean","enhance","length","wrapperProps","props","WrapperComponent","reduce","acc"],"sources":["../../../src/enhancement/enhance.tsx"],"sourcesContent":["function Enhancement() {\n return {\n condition: function (Component) {\n return Boolean(Component.enhance && Component.enhance.length);\n },\n wrapperProps: function (props, WrapperComponent) {\n return WrapperComponent.enhance.reduce((acc, enhance) => enhance(acc), props);\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":"AAAA,SAASA,WAAWA,CAAA,EAAG;EACrB,OAAO;IACLC,SAAS,EAAE,SAAAA,UAAUC,SAAS,EAAE;MAC9B,OAAOC,OAAO,CAACD,SAAS,CAACE,OAAO,IAAIF,SAAS,CAACE,OAAO,CAACC,MAAM,CAAC;IAC/D,CAAC;IACDC,YAAY,EAAE,SAAAA,aAAUC,KAAK,EAAEC,gBAAgB,EAAE;MAC/C,OAAOA,gBAAgB,CAACJ,OAAO,CAACK,MAAM,CAAC,UAACC,GAAG,EAAEN,OAAO;QAAA,OAAKA,OAAO,CAACM,GAAG,CAAC;MAAA,GAAEH,KAAK,CAAC;IAC/E;EACF,CAAC;AACH;AAEA,eAAeP,WAAW"}
|
|
@@ -5,11 +5,9 @@ function Enhancement() {
|
|
|
5
5
|
if (!Component.defaultProps) {
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
8
|
if (typeof Component.defaultProps === 'function') {
|
|
10
9
|
return true;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return Boolean(Object.keys(Component.defaultProps).length);
|
|
14
12
|
},
|
|
15
13
|
"static": function _static(WrapperComponent) {
|
|
@@ -23,11 +21,9 @@ function Enhancement() {
|
|
|
23
21
|
// TODO: optimization
|
|
24
22
|
return Object.assign({}, defaultProps(props), props);
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
return Object.assign({}, defaultProps, props);
|
|
28
25
|
}
|
|
29
26
|
};
|
|
30
27
|
}
|
|
31
|
-
|
|
32
28
|
export default Enhancement;
|
|
33
29
|
//# sourceMappingURL=functionDefaultProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functionDefaultProps.js","names":["Enhancement","defaultProps","condition","Component","Boolean","Object","keys","length","WrapperComponent","wrapperProps","props","assign"],"sources":["../../../src/enhancement/functionDefaultProps.tsx"],"sourcesContent":["function Enhancement() {\n let defaultProps = {};\n return {\n condition: function (Component) {\n if (!Component.defaultProps) {\n return false;\n }\n if (typeof Component.defaultProps === 'function') {\n return true;\n }\n return Boolean(Object.keys(Component.defaultProps).length);\n },\n static: function (WrapperComponent) {\n defaultProps = WrapperComponent.defaultProps;\n return {\n defaultProps: {},\n };\n },\n wrapperProps: function (props) {\n if (typeof defaultProps === 'function') {\n // TODO: optimization\n return Object.assign({}, defaultProps(props), props);\n }\n return Object.assign({}, defaultProps, props);\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"functionDefaultProps.js","names":["Enhancement","defaultProps","condition","Component","Boolean","Object","keys","length","_static","WrapperComponent","wrapperProps","props","assign"],"sources":["../../../src/enhancement/functionDefaultProps.tsx"],"sourcesContent":["function Enhancement() {\n let defaultProps = {};\n return {\n condition: function (Component) {\n if (!Component.defaultProps) {\n return false;\n }\n if (typeof Component.defaultProps === 'function') {\n return true;\n }\n return Boolean(Object.keys(Component.defaultProps).length);\n },\n static: function (WrapperComponent) {\n defaultProps = WrapperComponent.defaultProps;\n return {\n defaultProps: {},\n };\n },\n wrapperProps: function (props) {\n if (typeof defaultProps === 'function') {\n // TODO: optimization\n return Object.assign({}, defaultProps(props), props);\n }\n return Object.assign({}, defaultProps, props);\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":"AAAA,SAASA,WAAWA,CAAA,EAAG;EACrB,IAAIC,YAAY,GAAG,CAAC,CAAC;EACrB,OAAO;IACLC,SAAS,EAAE,SAAAA,UAAUC,SAAS,EAAE;MAC9B,IAAI,CAACA,SAAS,CAACF,YAAY,EAAE;QAC3B,OAAO,KAAK;MACd;MACA,IAAI,OAAOE,SAAS,CAACF,YAAY,KAAK,UAAU,EAAE;QAChD,OAAO,IAAI;MACb;MACA,OAAOG,OAAO,CAACC,MAAM,CAACC,IAAI,CAACH,SAAS,CAACF,YAAY,CAAC,CAACM,MAAM,CAAC;IAC5D,CAAC;IACD,UAAQ,SAAAC,QAAUC,gBAAgB,EAAE;MAClCR,YAAY,GAAGQ,gBAAgB,CAACR,YAAY;MAC5C,OAAO;QACLA,YAAY,EAAE,CAAC;MACjB,CAAC;IACH,CAAC;IACDS,YAAY,EAAE,SAAAA,aAAUC,KAAK,EAAE;MAC7B,IAAI,OAAOV,YAAY,KAAK,UAAU,EAAE;QACtC;QACA,OAAOI,MAAM,CAACO,MAAM,CAAC,CAAC,CAAC,EAAEX,YAAY,CAACU,KAAK,CAAC,EAAEA,KAAK,CAAC;MACtD;MACA,OAAON,MAAM,CAACO,MAAM,CAAC,CAAC,CAAC,EAAEX,YAAY,EAAEU,KAAK,CAAC;IAC/C;EACF,CAAC;AACH;AAEA,eAAeX,WAAW"}
|
|
@@ -2,17 +2,16 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
4
4
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
|
-
import { useContext, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import assignProps from '@semcore/utils/lib/assignProps';
|
|
8
|
-
|
|
9
|
-
import useEnhancedEffect from '@semcore/utils/lib/use/useEnhancedEffect';
|
|
10
|
-
|
|
5
|
+
import { useContext, useState } from 'react';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import assignProps from '@semcore/utils/lib/assignProps';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import useEnhancedEffect from '@semcore/utils/lib/use/useEnhancedEffect';
|
|
10
|
+
// @ts-ignore
|
|
11
11
|
import pick from '@semcore/utils/lib/pick';
|
|
12
12
|
export var HOIST_CONTEXT = Symbol('HOIST_CONTEXT');
|
|
13
13
|
var HOIST_SELF = Symbol('HOIST_SELF');
|
|
14
14
|
var HOIST_SET = Symbol('HOIST_SET');
|
|
15
|
-
|
|
16
15
|
function flatChildComponent(childComponents) {
|
|
17
16
|
return Object.values(childComponents).reduce(function (acc, Component) {
|
|
18
17
|
if (Array.isArray(Component)) {
|
|
@@ -20,11 +19,9 @@ function flatChildComponent(childComponents) {
|
|
|
20
19
|
} else {
|
|
21
20
|
acc.push(Component);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
return acc;
|
|
25
23
|
}, []);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
function Enhancement(childComponents, Context) {
|
|
29
26
|
return {
|
|
30
27
|
condition: function condition(Component) {
|
|
@@ -34,19 +31,16 @@ function Enhancement(childComponents, Context) {
|
|
|
34
31
|
},
|
|
35
32
|
init: function init(props, WrapperComponent, isFunction) {
|
|
36
33
|
var _this = this;
|
|
37
|
-
|
|
38
34
|
if (isFunction) {
|
|
39
35
|
// TODO: might breake rules of hooks (by lsroman)
|
|
40
36
|
this[HOIST_SELF] = useState({});
|
|
41
37
|
} else {
|
|
42
38
|
this[HOIST_SELF] = [{}, function (obj) {
|
|
43
39
|
_this[HOIST_SELF][0] = obj;
|
|
44
|
-
|
|
45
40
|
_this.forceUpdate();
|
|
46
41
|
}];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
}
|
|
43
|
+
// For optimization render
|
|
50
44
|
this[HOIST_SET] = function (obj) {
|
|
51
45
|
_this[HOIST_SELF][1](obj);
|
|
52
46
|
};
|
|
@@ -65,18 +59,16 @@ function Enhancement(childComponents, Context) {
|
|
|
65
59
|
var context = useContext(Context);
|
|
66
60
|
var renameProps = WrapperComponent.hoistProps.reduce(function (acc, propName) {
|
|
67
61
|
var _propName$split = propName.split(':'),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
_propName$split2 = _slicedToArray(_propName$split, 2),
|
|
63
|
+
name = _propName$split2[0],
|
|
64
|
+
rename = _propName$split2[1];
|
|
72
65
|
acc[name] = rename || name;
|
|
73
66
|
return acc;
|
|
74
67
|
}, {});
|
|
75
68
|
var hoistProps = Object.entries(pick(props, Object.keys(renameProps))).reduce(function (acc, _ref) {
|
|
76
69
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
name = _ref2[0],
|
|
71
|
+
value = _ref2[1];
|
|
80
72
|
acc[renameProps[name]] = value;
|
|
81
73
|
return acc;
|
|
82
74
|
}, {});
|
|
@@ -86,11 +78,9 @@ function Enhancement(childComponents, Context) {
|
|
|
86
78
|
}
|
|
87
79
|
}, Object.values(hoistProps));
|
|
88
80
|
}
|
|
89
|
-
|
|
90
81
|
return props;
|
|
91
82
|
}
|
|
92
83
|
};
|
|
93
84
|
}
|
|
94
|
-
|
|
95
85
|
export default Enhancement;
|
|
96
86
|
//# sourceMappingURL=hoistProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hoistProps.js","names":["useContext","useState","assignProps","useEnhancedEffect","pick","HOIST_CONTEXT","Symbol","HOIST_SELF","HOIST_SET","flatChildComponent","childComponents","Object","values","reduce","acc","Component","Array","isArray","push","Enhancement","Context","condition","some","Boolean","hoistProps","length","init","props","WrapperComponent","isFunction","obj","forceUpdate","context","asProps","wrapperProps","renameProps","propName","split","name","rename","entries","keys","value"],"sources":["../../../src/enhancement/hoistProps.tsx"],"sourcesContent":["import { useContext, useState } from 'react';\n// @ts-ignore\nimport assignProps from '@semcore/utils/lib/assignProps';\n// @ts-ignore\nimport useEnhancedEffect from '@semcore/utils/lib/use/useEnhancedEffect';\n// @ts-ignore\nimport pick from '@semcore/utils/lib/pick';\n\nexport const HOIST_CONTEXT = Symbol('HOIST_CONTEXT');\nconst HOIST_SELF = Symbol('HOIST_SELF');\nconst HOIST_SET = Symbol('HOIST_SET');\n\nfunction flatChildComponent(childComponents) {\n return Object.values(childComponents).reduce<unknown[]>((acc, Component) => {\n if (Array.isArray(Component)) {\n acc = [...acc, Component[0], ...flatChildComponent(Component[1])];\n } else {\n acc.push(Component);\n }\n return acc;\n }, []);\n}\n\nfunction Enhancement(childComponents, Context) {\n return {\n condition: function (Component) {\n return [Component, ...flatChildComponent(childComponents)].some((Component) =>\n Boolean(Component.hoistProps && Component.hoistProps.length),\n );\n },\n init: function (props, WrapperComponent, isFunction) {\n if (isFunction) {\n // TODO: might breake rules of hooks (by lsroman)\n this[HOIST_SELF] = useState({});\n } else {\n this[HOIST_SELF] = [\n {},\n (obj) => {\n this[HOIST_SELF][0] = obj;\n this.forceUpdate();\n },\n ];\n }\n // For optimization render\n this[HOIST_SET] = (obj) => {\n this[HOIST_SELF][1](obj);\n };\n },\n context: function (context) {\n // TODO: need to optimizte container initialization (by lsroman)\n // WrapperComponent.hoistProps\n return {\n ...context,\n [HOIST_CONTEXT]: this[HOIST_SET],\n };\n },\n asProps: function (props) {\n // TODO: need to check for no props overwriting (by lsroman)\n return assignProps(this[HOIST_SELF][0], props);\n },\n wrapperProps: function (props, WrapperComponent) {\n if (WrapperComponent.hoistProps && WrapperComponent.hoistProps.length) {\n const context = useContext(Context);\n const renameProps = WrapperComponent.hoistProps.reduce((acc, propName) => {\n const [name, rename] = propName.split(':');\n acc[name] = rename || name;\n return acc;\n }, {});\n const hoistProps = Object.entries(pick(props, Object.keys(renameProps))).reduce(\n (acc, [name, value]) => {\n acc[renameProps[name]] = value;\n return acc;\n },\n {},\n );\n\n useEnhancedEffect(() => {\n if (context[HOIST_CONTEXT]) {\n context[HOIST_CONTEXT](hoistProps);\n }\n }, Object.values(hoistProps));\n }\n return props;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"hoistProps.js","names":["useContext","useState","assignProps","useEnhancedEffect","pick","HOIST_CONTEXT","Symbol","HOIST_SELF","HOIST_SET","flatChildComponent","childComponents","Object","values","reduce","acc","Component","Array","isArray","concat","_toConsumableArray","push","Enhancement","Context","condition","some","Boolean","hoistProps","length","init","props","WrapperComponent","isFunction","_this","obj","forceUpdate","context","_objectSpread","_defineProperty","asProps","wrapperProps","renameProps","propName","_propName$split","split","_propName$split2","_slicedToArray","name","rename","entries","keys","_ref","_ref2","value"],"sources":["../../../src/enhancement/hoistProps.tsx"],"sourcesContent":["import { useContext, useState } from 'react';\n// @ts-ignore\nimport assignProps from '@semcore/utils/lib/assignProps';\n// @ts-ignore\nimport useEnhancedEffect from '@semcore/utils/lib/use/useEnhancedEffect';\n// @ts-ignore\nimport pick from '@semcore/utils/lib/pick';\n\nexport const HOIST_CONTEXT = Symbol('HOIST_CONTEXT');\nconst HOIST_SELF = Symbol('HOIST_SELF');\nconst HOIST_SET = Symbol('HOIST_SET');\n\nfunction flatChildComponent(childComponents) {\n return Object.values(childComponents).reduce<unknown[]>((acc, Component) => {\n if (Array.isArray(Component)) {\n acc = [...acc, Component[0], ...flatChildComponent(Component[1])];\n } else {\n acc.push(Component);\n }\n return acc;\n }, []);\n}\n\nfunction Enhancement(childComponents, Context) {\n return {\n condition: function (Component) {\n return [Component, ...flatChildComponent(childComponents)].some((Component) =>\n Boolean(Component.hoistProps && Component.hoistProps.length),\n );\n },\n init: function (props, WrapperComponent, isFunction) {\n if (isFunction) {\n // TODO: might breake rules of hooks (by lsroman)\n this[HOIST_SELF] = useState({});\n } else {\n this[HOIST_SELF] = [\n {},\n (obj) => {\n this[HOIST_SELF][0] = obj;\n this.forceUpdate();\n },\n ];\n }\n // For optimization render\n this[HOIST_SET] = (obj) => {\n this[HOIST_SELF][1](obj);\n };\n },\n context: function (context) {\n // TODO: need to optimizte container initialization (by lsroman)\n // WrapperComponent.hoistProps\n return {\n ...context,\n [HOIST_CONTEXT]: this[HOIST_SET],\n };\n },\n asProps: function (props) {\n // TODO: need to check for no props overwriting (by lsroman)\n return assignProps(this[HOIST_SELF][0], props);\n },\n wrapperProps: function (props, WrapperComponent) {\n if (WrapperComponent.hoistProps && WrapperComponent.hoistProps.length) {\n const context = useContext(Context);\n const renameProps = WrapperComponent.hoistProps.reduce((acc, propName) => {\n const [name, rename] = propName.split(':');\n acc[name] = rename || name;\n return acc;\n }, {});\n const hoistProps = Object.entries(pick(props, Object.keys(renameProps))).reduce(\n (acc, [name, value]) => {\n acc[renameProps[name]] = value;\n return acc;\n },\n {},\n );\n\n useEnhancedEffect(() => {\n if (context[HOIST_CONTEXT]) {\n context[HOIST_CONTEXT](hoistProps);\n }\n }, Object.values(hoistProps));\n }\n return props;\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;AAAA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,OAAO;AAC5C;AACA,OAAOC,WAAW,MAAM,gCAAgC;AACxD;AACA,OAAOC,iBAAiB,MAAM,0CAA0C;AACxE;AACA,OAAOC,IAAI,MAAM,yBAAyB;AAE1C,OAAO,IAAMC,aAAa,GAAGC,MAAM,CAAC,eAAe,CAAC;AACpD,IAAMC,UAAU,GAAGD,MAAM,CAAC,YAAY,CAAC;AACvC,IAAME,SAAS,GAAGF,MAAM,CA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B;UAAA,IAAAC,KAAA,GAAAN,cAAA,CAAAK,IAAA;YAAjBJ,IAAI,GAAAK,KAAA;YAAEC,KAAK,GAAAD,KAAA;UAChBrC,GAAG,CAAC0B,WAAW,CAACM,IAAI,CAAC,CAAC,GAAGM,KAAK;UAC9B,OAAOtC,GAAG;QACZ,CAAC,EACD,CAAC,CAAC,CACH;QAEDX,iBAAiB,CAAC,YAAM;UACtB,IAAIgC,OAAO,CAAC9B,aAAa,CAAC,EAAE;YAC1B8B,OAAO,CAAC9B,aAAa,CAAC,CAACqB,UAAU,CAAC;UACpC;QACF,CAAC,EAAEf,MAAM,CAACC,MAAM,CAACc,UAAU,CAAC,CAAC;MAC/B;MACA,OAAOG,KAAK;IACd;EACF,CAAC;AACH;AAEA,eAAeR,WAAW"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
export var INHERITED_NAME = Symbol('INHERITED_NAME');
|
|
4
|
-
|
|
5
4
|
function Enhancement() {
|
|
6
5
|
return {
|
|
7
6
|
condition: function condition(Component) {
|
|
@@ -12,6 +11,5 @@ function Enhancement() {
|
|
|
12
11
|
}
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
export default Enhancement;
|
|
17
15
|
//# sourceMappingURL=inheritedName.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inheritedName.js","names":["INHERITED_NAME","Symbol","Enhancement","condition","Component","Boolean","displayName","WrapperComponent","Set"],"sources":["../../../src/enhancement/inheritedName.tsx"],"sourcesContent":["export const INHERITED_NAME = Symbol('INHERITED_NAME');\n\nfunction Enhancement() {\n return {\n condition: function (Component) {\n return Boolean(Component.displayName);\n },\n static: function (WrapperComponent) {\n return {\n [INHERITED_NAME]: [\n ...new Set([...(WrapperComponent[INHERITED_NAME] || []), WrapperComponent.displayName]),\n ],\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;AAAA,OAAO,IAAMA,cAAc,GAAGC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"inheritedName.js","names":["INHERITED_NAME","Symbol","Enhancement","condition","Component","Boolean","displayName","_static","WrapperComponent","_defineProperty","_toConsumableArray","Set","concat"],"sources":["../../../src/enhancement/inheritedName.tsx"],"sourcesContent":["export const INHERITED_NAME = Symbol('INHERITED_NAME');\n\nfunction Enhancement() {\n return {\n condition: function (Component) {\n return Boolean(Component.displayName);\n },\n static: function (WrapperComponent) {\n return {\n [INHERITED_NAME]: [\n ...new Set([...(WrapperComponent[INHERITED_NAME] || []), WrapperComponent.displayName]),\n ],\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;AAAA,OAAO,IAAMA,cAAc,GAAGC,MAAM,CAAC,gBAAgB,CAAC;AAEtD,SAASC,WAAWA,CAAA,EAAG;EACrB,OAAO;IACLC,SAAS,EAAE,SAAAA,UAAUC,SAAS,EAAE;MAC9B,OAAOC,OAAO,CAACD,SAAS,CAACE,WAAW,CAAC;IACvC,CAAC;IACD,UAAQ,SAAAC,QAAUC,gBAAgB,EAAE;MAClC,OAAAC,eAAA,KACGT,cAAc,EAAAU,kBAAA,CACV,IAAIC,GAAG,IAAAC,MAAA,CAAAF,kBAAA,CAAMF,gBAAgB,CAACR,cAAc,CAAC,IAAI,EAAE,IAAGQ,gBAAgB,CAACF,WAAW,GAAE;IAG7F;EACF,CAAC;AACH;AAEA,eAAeJ,WAAW"}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
import { useContext } from 'react';
|
|
5
|
-
|
|
6
|
-
import assignProps from '@semcore/utils/lib/assignProps';
|
|
7
|
-
|
|
8
|
-
import pick from '@semcore/utils/lib/pick';
|
|
9
|
-
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import assignProps from '@semcore/utils/lib/assignProps';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import pick from '@semcore/utils/lib/pick';
|
|
9
|
+
// @ts-ignore
|
|
10
10
|
import logger from '@semcore/utils/lib/logger';
|
|
11
|
-
|
|
12
11
|
function assign(target, source) {
|
|
13
12
|
return Object.defineProperties(target, Object.keys(source).reduce(function (descriptors, key) {
|
|
14
13
|
descriptors[key] = Object.getOwnPropertyDescriptor(source, key);
|
|
15
14
|
return descriptors;
|
|
16
15
|
}, {}));
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
export function getterMethodName(name) {
|
|
20
18
|
return "get".concat(name, "Props");
|
|
21
19
|
}
|
|
@@ -25,27 +23,22 @@ export function getterMethodNameByDisplayName() {
|
|
|
25
23
|
var name = displayNames.slice(-(displayNames.length - 1)).join('');
|
|
26
24
|
return getterMethodName(name);
|
|
27
25
|
}
|
|
28
|
-
|
|
29
26
|
function flatGetterMethodNames(childComponents, parentName) {
|
|
30
27
|
return Object.entries(childComponents).reduce(function (acc, _ref) {
|
|
31
28
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
name = _ref2[0],
|
|
30
|
+
value = _ref2[1];
|
|
35
31
|
if (Array.isArray(value)) {
|
|
36
32
|
acc = [].concat(_toConsumableArray(acc), _toConsumableArray(flatGetterMethodNames(value[1], name)));
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
name = parentName ? "".concat(parentName).concat(name) : name;
|
|
40
35
|
acc.push(getterMethodName(name));
|
|
41
36
|
return acc;
|
|
42
37
|
}, []);
|
|
43
38
|
}
|
|
44
|
-
|
|
45
39
|
export var STATIC_COMPONENT = Symbol('STATIC_COMPONENT');
|
|
46
40
|
export var ROOT_COMPONENT = Symbol('ROOT_COMPONENT');
|
|
47
41
|
var SELF_GETTER_METHOD = Symbol('SELF_GETTER_METHOD');
|
|
48
|
-
|
|
49
42
|
function Enhancement(childComponents, createComponent, options) {
|
|
50
43
|
var getterMethodNames = flatGetterMethodNames(childComponents);
|
|
51
44
|
return {
|
|
@@ -54,24 +47,19 @@ function Enhancement(childComponents, createComponent, options) {
|
|
|
54
47
|
},
|
|
55
48
|
init: function init(props, WrapperComponent) {
|
|
56
49
|
var _this = this;
|
|
57
|
-
|
|
58
50
|
var getterMethods = pick(this, getterMethodNames);
|
|
59
|
-
|
|
60
51
|
this[SELF_GETTER_METHOD] = function () {
|
|
61
52
|
var selfGetterMethod = getterMethodNameByDisplayName(WrapperComponent.displayName);
|
|
62
53
|
logger.warn(true, "Getter `".concat(selfGetterMethod, "` can't be fired as it is a getter of static component"), props['data-ui-name'] || WrapperComponent.displayName);
|
|
63
54
|
};
|
|
64
|
-
|
|
65
55
|
assign(this, getterMethodNames.reduce(function (acc, name) {
|
|
66
56
|
var getterMethod = getterMethods[name];
|
|
67
57
|
if (!getterMethod) return acc;
|
|
68
|
-
|
|
69
58
|
acc[name] = function () {
|
|
70
59
|
var childrenProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
71
60
|
var getterProps = getterMethod.call(_this, childrenProps, acc[name].index);
|
|
72
61
|
return assignProps(childrenProps, getterProps);
|
|
73
62
|
};
|
|
74
|
-
|
|
75
63
|
acc[name].index = -1;
|
|
76
64
|
acc[name].cache = new Set();
|
|
77
65
|
return acc;
|
|
@@ -81,36 +69,30 @@ function Enhancement(childComponents, createComponent, options) {
|
|
|
81
69
|
if (Object.keys(childComponents).length && !WrapperComponent.displayName) {
|
|
82
70
|
throw new Error('"displayName" is not defined');
|
|
83
71
|
}
|
|
84
|
-
|
|
85
72
|
return Object.entries(childComponents).reduce(function (acc, _ref3) {
|
|
86
73
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
name = _ref4[0],
|
|
75
|
+
value = _ref4[1];
|
|
90
76
|
var childComponents = {};
|
|
91
|
-
|
|
92
77
|
if (Array.isArray(value)) {
|
|
93
78
|
childComponents = value[1];
|
|
94
79
|
value = value[0];
|
|
95
80
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
81
|
+
var prevStaticComponent = value[STATIC_COMPONENT];
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
var prevDisplayName = value.displayName;
|
|
84
|
+
// @ts-ignore
|
|
101
85
|
value.displayName = WrapperComponent.displayName + '.' + name;
|
|
102
86
|
value[STATIC_COMPONENT] = true;
|
|
103
87
|
value[ROOT_COMPONENT] = Component[ROOT_COMPONENT] || Component;
|
|
104
|
-
acc[name] = createComponent(value, childComponents, options);
|
|
105
|
-
|
|
88
|
+
acc[name] = createComponent(value, childComponents, options);
|
|
89
|
+
// @ts-ignore
|
|
106
90
|
value.displayName = prevDisplayName;
|
|
107
91
|
value[STATIC_COMPONENT] = prevStaticComponent;
|
|
108
92
|
return acc;
|
|
109
93
|
}, {});
|
|
110
94
|
},
|
|
111
|
-
context: function context(_context
|
|
112
|
-
/*, WrapperComponent*/
|
|
113
|
-
) {
|
|
95
|
+
context: function context(_context /*, WrapperComponent*/) {
|
|
114
96
|
// const getterMethod = getterMethodNameByDisplayName(WrapperComponent.displayName);
|
|
115
97
|
return _objectSpread(_objectSpread({}, _context), pick(this, getterMethodNames));
|
|
116
98
|
},
|
|
@@ -118,33 +100,27 @@ function Enhancement(childComponents, createComponent, options) {
|
|
|
118
100
|
if (!WrapperComponent[STATIC_COMPONENT]) return props;
|
|
119
101
|
var context = useContext(options.context);
|
|
120
102
|
var getterMethod = context[getterMethodNameByDisplayName(WrapperComponent.displayName)];
|
|
121
|
-
|
|
122
103
|
if (getterMethod) {
|
|
123
104
|
if (!getterMethod.cache.has(this)) {
|
|
124
105
|
getterMethod.cache.add(this);
|
|
125
106
|
getterMethod.index++;
|
|
126
107
|
if (this) this.index = getterMethod.index;
|
|
127
108
|
}
|
|
128
|
-
|
|
129
109
|
if (this) getterMethod.index = this.index;
|
|
130
110
|
return getterMethod(props);
|
|
131
111
|
}
|
|
132
|
-
|
|
133
112
|
return props;
|
|
134
113
|
},
|
|
135
114
|
render: function render(_render) {
|
|
136
115
|
var _this2 = this;
|
|
137
|
-
|
|
138
116
|
getterMethodNames.forEach(function (name) {
|
|
139
117
|
if (_this2[name] === undefined) return;
|
|
140
118
|
_this2[name].index = -1;
|
|
141
|
-
|
|
142
119
|
_this2[name].cache.clear();
|
|
143
120
|
});
|
|
144
121
|
return _render;
|
|
145
122
|
}
|
|
146
123
|
};
|
|
147
124
|
}
|
|
148
|
-
|
|
149
125
|
export default Enhancement;
|
|
150
126
|
//# sourceMappingURL=staticChildren.js.map
|