@semcore/core 2.21.0 → 2.22.0-prerelease.0
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 +6 -0
- package/lib/cjs/index.js +6 -426
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/index.js +2 -355
- package/lib/es6/index.js.map +1 -1
- package/lib/types/index.d.ts +2 -40
- package/package.json +2 -6
- package/lib/cjs/Component.js +0 -58
- package/lib/cjs/Component.js.map +0 -1
- package/lib/cjs/enhancement/Children.js +0 -121
- package/lib/cjs/enhancement/Children.js.map +0 -1
- package/lib/cjs/enhancement/Root.js +0 -78
- package/lib/cjs/enhancement/Root.js.map +0 -1
- package/lib/cjs/enhancement/bindHandler.js +0 -54
- package/lib/cjs/enhancement/bindHandler.js.map +0 -1
- package/lib/cjs/enhancement/dataName.js +0 -20
- package/lib/cjs/enhancement/dataName.js.map +0 -1
- package/lib/cjs/enhancement/enhance.js +0 -22
- package/lib/cjs/enhancement/enhance.js.map +0 -1
- package/lib/cjs/enhancement/functionDefaultProps.js +0 -36
- package/lib/cjs/enhancement/functionDefaultProps.js.map +0 -1
- package/lib/cjs/enhancement/hoistProps.js +0 -102
- package/lib/cjs/enhancement/hoistProps.js.map +0 -1
- package/lib/cjs/enhancement/i18n.js +0 -28
- package/lib/cjs/enhancement/i18n.js.map +0 -1
- package/lib/cjs/enhancement/inheritedName.js +0 -24
- package/lib/cjs/enhancement/inheritedName.js.map +0 -1
- package/lib/cjs/enhancement/staticChildren.js +0 -141
- package/lib/cjs/enhancement/staticChildren.js.map +0 -1
- package/lib/cjs/enhancement/style.js +0 -60
- package/lib/cjs/enhancement/style.js.map +0 -1
- package/lib/cjs/enhancement/uncontrolledProps.js +0 -135
- package/lib/cjs/enhancement/uncontrolledProps.js.map +0 -1
- package/lib/cjs/register.js +0 -37
- package/lib/cjs/register.js.map +0 -1
- package/lib/cjs/reshadow.d.js +0 -2
- package/lib/cjs/reshadow.d.js.map +0 -1
- package/lib/cjs/styled/index.js +0 -54
- package/lib/cjs/styled/index.js.map +0 -1
- package/lib/cjs/styled/sstyled.js +0 -150
- package/lib/cjs/styled/sstyled.js.map +0 -1
- package/lib/es6/Component.js +0 -50
- package/lib/es6/Component.js.map +0 -1
- package/lib/es6/enhancement/Children.js +0 -112
- package/lib/es6/enhancement/Children.js.map +0 -1
- package/lib/es6/enhancement/Root.js +0 -72
- package/lib/es6/enhancement/Root.js.map +0 -1
- package/lib/es6/enhancement/bindHandler.js +0 -47
- package/lib/es6/enhancement/bindHandler.js.map +0 -1
- package/lib/es6/enhancement/dataName.js +0 -12
- package/lib/es6/enhancement/dataName.js.map +0 -1
- package/lib/es6/enhancement/enhance.js +0 -15
- package/lib/es6/enhancement/enhance.js.map +0 -1
- package/lib/es6/enhancement/functionDefaultProps.js +0 -29
- package/lib/es6/enhancement/functionDefaultProps.js.map +0 -1
- package/lib/es6/enhancement/hoistProps.js +0 -90
- package/lib/es6/enhancement/hoistProps.js.map +0 -1
- package/lib/es6/enhancement/i18n.js +0 -21
- package/lib/es6/enhancement/i18n.js.map +0 -1
- package/lib/es6/enhancement/inheritedName.js +0 -15
- package/lib/es6/enhancement/inheritedName.js.map +0 -1
- package/lib/es6/enhancement/staticChildren.js +0 -126
- package/lib/es6/enhancement/staticChildren.js.map +0 -1
- package/lib/es6/enhancement/style.js +0 -52
- package/lib/es6/enhancement/style.js.map +0 -1
- package/lib/es6/enhancement/uncontrolledProps.js +0 -125
- package/lib/es6/enhancement/uncontrolledProps.js.map +0 -1
- package/lib/es6/register.js +0 -29
- package/lib/es6/register.js.map +0 -1
- package/lib/es6/reshadow.d.js +0 -2
- package/lib/es6/reshadow.d.js.map +0 -1
- package/lib/es6/styled/index.js +0 -10
- package/lib/es6/styled/index.js.map +0 -1
- package/lib/es6/styled/sstyled.js +0 -143
- package/lib/es6/styled/sstyled.js.map +0 -1
- package/lib/types/Component.d.ts +0 -152
- package/lib/types/enhancement/Children.d.ts +0 -6
- package/lib/types/enhancement/Root.d.ts +0 -6
- package/lib/types/enhancement/bindHandler.d.ts +0 -5
- package/lib/types/enhancement/dataName.d.ts +0 -4
- package/lib/types/enhancement/enhance.d.ts +0 -5
- package/lib/types/enhancement/functionDefaultProps.d.ts +0 -8
- package/lib/types/enhancement/hoistProps.d.ts +0 -10
- package/lib/types/enhancement/i18n.d.ts +0 -4
- package/lib/types/enhancement/inheritedName.d.ts +0 -8
- package/lib/types/enhancement/staticChildren.d.ts +0 -13
- package/lib/types/enhancement/style.d.ts +0 -9
- package/lib/types/enhancement/uncontrolledProps.d.ts +0 -7
- package/lib/types/register.d.ts +0 -8
- package/lib/types/styled/index.d.ts +0 -14
- package/lib/types/styled/sstyled.d.ts +0 -17
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.sstyled = sstyled;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _react = require("react");
|
|
12
|
-
var _core = require("@reshadow/core");
|
|
13
|
-
/** @ts-ignore */
|
|
14
|
-
|
|
15
|
-
var RESHADOW_ID = '__reshadow__';
|
|
16
|
-
var isSSR = !(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
17
|
-
var serverMap = (0, _core.getStyles)().map;
|
|
18
|
-
var getStyles = function getStyles() {
|
|
19
|
-
return {
|
|
20
|
-
map: serverMap,
|
|
21
|
-
get css() {
|
|
22
|
-
var serverStyles = '';
|
|
23
|
-
for (var id in serverMap) {
|
|
24
|
-
serverStyles += "<style type='text/css' id='".concat(id, "'>").concat(serverMap[id], "</style>");
|
|
25
|
-
}
|
|
26
|
-
return serverStyles;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
function insert(code, hash) {
|
|
31
|
-
var id = 'reshadow-'.concat(hash);
|
|
32
|
-
if (isSSR) {
|
|
33
|
-
serverMap[id] = code;
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
var container = document.getElementById(RESHADOW_ID);
|
|
37
|
-
if (!container) {
|
|
38
|
-
container = document.createElement('object');
|
|
39
|
-
container.id = RESHADOW_ID;
|
|
40
|
-
if (document.head) {
|
|
41
|
-
document.head.appendChild(container);
|
|
42
|
-
} else {
|
|
43
|
-
document.addEventListener('DOMContentLoaded', function () {
|
|
44
|
-
document.head.appendChild(container);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
var css = document.getElementById(id);
|
|
49
|
-
if (!css) {
|
|
50
|
-
css = document.createElement('style');
|
|
51
|
-
css.id = id;
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
css.type = 'text/css';
|
|
54
|
-
container.appendChild(css);
|
|
55
|
-
}
|
|
56
|
-
css.innerHTML = code;
|
|
57
|
-
}
|
|
58
|
-
function merge() {
|
|
59
|
-
var s1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
60
|
-
var s2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
61
|
-
return Object.entries(s2).reduce(function (acc, _ref) {
|
|
62
|
-
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2),
|
|
63
|
-
key = _ref2[0],
|
|
64
|
-
value = _ref2[1];
|
|
65
|
-
if (key.startsWith('@') || key.startsWith('--')) {
|
|
66
|
-
acc[key] = value;
|
|
67
|
-
} else {
|
|
68
|
-
acc[key] = (0, _classnames["default"])(acc[key], value);
|
|
69
|
-
}
|
|
70
|
-
return acc;
|
|
71
|
-
}, Object.assign({}, s1));
|
|
72
|
-
}
|
|
73
|
-
function getClassAndVars(styles, name, props) {
|
|
74
|
-
function getPropValue(key, props) {
|
|
75
|
-
var _props;
|
|
76
|
-
return (_props = props["use:".concat(key)]) !== null && _props !== void 0 ? _props : props[key];
|
|
77
|
-
}
|
|
78
|
-
return Object.entries(styles).reduce(function (acc, _ref3) {
|
|
79
|
-
var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2),
|
|
80
|
-
key = _ref4[0],
|
|
81
|
-
value = _ref4[1];
|
|
82
|
-
if (key.startsWith('--')) {
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
acc[1][value] = getPropValue(key.substring(2), props);
|
|
85
|
-
} else if (name === key) {
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
acc[0][value] = true;
|
|
88
|
-
} else {
|
|
89
|
-
var _key$split = key.split('='),
|
|
90
|
-
_key$split2 = (0, _slicedToArray2["default"])(_key$split, 2),
|
|
91
|
-
mod = _key$split2[0],
|
|
92
|
-
modValue = _key$split2[1];
|
|
93
|
-
var propValue = getPropValue(mod, props);
|
|
94
|
-
if (modValue === undefined) {
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
acc[0][value] = Boolean(propValue !== null && propValue !== void 0 ? propValue : false);
|
|
97
|
-
} else {
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
// biome-ignore lint/suspicious/noDoubleEquals:
|
|
100
|
-
acc[0][value] = propValue == modValue;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return acc;
|
|
104
|
-
}, [{}, {}]);
|
|
105
|
-
}
|
|
106
|
-
function reshadowToShadow(obj) {
|
|
107
|
-
return Object.entries(obj).reduce(function (style, _ref5) {
|
|
108
|
-
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
109
|
-
name = _ref6[0],
|
|
110
|
-
value = _ref6[1];
|
|
111
|
-
var n = name;
|
|
112
|
-
if (name.startsWith('__')) {
|
|
113
|
-
n = name.replace(/^__/, '');
|
|
114
|
-
} else if (name.startsWith('_')) {
|
|
115
|
-
n = name.replace(/^_/, '').replace('_', '=');
|
|
116
|
-
}
|
|
117
|
-
style[n] = value;
|
|
118
|
-
return style;
|
|
119
|
-
}, {});
|
|
120
|
-
}
|
|
121
|
-
function sstyled() {
|
|
122
|
-
var styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
return {
|
|
125
|
-
cn: function cn(name, props) {
|
|
126
|
-
var _getClassAndVars = getClassAndVars(reshadowToShadow(styles), name, props),
|
|
127
|
-
_getClassAndVars2 = (0, _slicedToArray2["default"])(_getClassAndVars, 2),
|
|
128
|
-
classes = _getClassAndVars2[0],
|
|
129
|
-
style = _getClassAndVars2[1];
|
|
130
|
-
var extraProps = {};
|
|
131
|
-
if (Object.keys(classes).length) {
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
extraProps.className = (0, _classnames["default"])(props.className, classes);
|
|
134
|
-
}
|
|
135
|
-
if (Object.keys(style).length) {
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
extraProps.style = Object.assign(style, props.style);
|
|
138
|
-
}
|
|
139
|
-
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), extraProps);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
sstyled.css = function (css) {
|
|
144
|
-
throw new Error('Enable babel plugin');
|
|
145
|
-
};
|
|
146
|
-
sstyled.insert = insert;
|
|
147
|
-
sstyled.merge = merge;
|
|
148
|
-
sstyled.getStyles = getStyles;
|
|
149
|
-
sstyled.SHADOW_STYLES = Symbol('SHADOW_STYLES');
|
|
150
|
-
//# sourceMappingURL=sstyled.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sstyled.js","names":["_classnames","_interopRequireDefault","require","_react","_core","RESHADOW_ID","isSSR","window","document","createElement","serverMap","reshadowGetStyles","map","getStyles","css","serverStyles","id","concat","insert","code","hash","container","getElementById","head","appendChild","addEventListener","type","innerHTML","merge","s1","arguments","length","undefined","s2","Object","entries","reduce","acc","_ref","_ref2","_slicedToArray2","key","value","startsWith","cn","assign","getClassAndVars","styles","name","props","getPropValue","_props","_ref3","_ref4","substring","_key$split","split","_key$split2","mod","modValue","propValue","Boolean","reshadowToShadow","obj","style","_ref5","_ref6","n","replace","sstyled","_getClassAndVars","_getClassAndVars2","classes","extraProps","keys","className","_objectSpread2","Error","SHADOW_STYLES","Symbol"],"sources":["../../../src/styled/sstyled.tsx"],"sourcesContent":["import cn from 'classnames';\nimport { ReactNode } from 'react';\n/** @ts-ignore */\nimport { getStyles as reshadowGetStyles } from '@reshadow/core';\n\nconst RESHADOW_ID = '__reshadow__';\n\nconst isSSR = !(typeof window !== 'undefined' && window.document && window.document.createElement);\n\nconst serverMap = reshadowGetStyles().map;\n\nconst getStyles = () => ({\n map: serverMap,\n get css() {\n let serverStyles = '';\n for (const id in serverMap) {\n serverStyles += `<style type='text/css' id='${id}'>${serverMap[id]}</style>`;\n }\n return serverStyles;\n },\n});\n\nfunction insert(code: any, hash: any) {\n const id = 'reshadow-'.concat(hash);\n\n if (isSSR) {\n serverMap[id] = code;\n return;\n }\n\n let container = document.getElementById(RESHADOW_ID);\n\n if (!container) {\n container = document.createElement('object');\n container.id = RESHADOW_ID;\n\n if (document.head) {\n document.head.appendChild(container);\n } else {\n document.addEventListener('DOMContentLoaded', function () {\n document.head.appendChild(container as any);\n });\n }\n }\n\n let css = document.getElementById(id);\n\n if (!css) {\n css = document.createElement('style');\n css.id = id;\n // @ts-ignore\n css.type = 'text/css';\n container.appendChild(css);\n }\n\n css.innerHTML = code;\n}\n\nfunction merge(s1 = {}, s2 = {}) {\n return Object.entries(s2).reduce((acc: any, [key, value]: any) => {\n if (key.startsWith('@') || key.startsWith('--')) {\n acc[key] = value;\n } else {\n acc[key] = cn(acc[key], value);\n }\n return acc;\n }, Object.assign({}, s1));\n}\n\nfunction getClassAndVars(styles: any, name: any, props: any) {\n function getPropValue(key: any, props: any) {\n return props[`use:${key}`] ?? props[key];\n }\n\n return Object.entries(styles).reduce(\n (acc, [key, value]) => {\n if (key.startsWith('--')) {\n // @ts-ignore\n acc[1][value] = getPropValue(key.substring(2), props);\n } else if (name === key) {\n // @ts-ignore\n acc[0][value] = true;\n } else {\n const [mod, modValue] = key.split('=');\n const propValue = getPropValue(mod, props);\n if (modValue === undefined) {\n // @ts-ignore\n acc[0][value] = Boolean(propValue ?? false);\n } else {\n // @ts-ignore\n // biome-ignore lint/suspicious/noDoubleEquals:\n acc[0][value] = propValue == modValue;\n }\n }\n return acc;\n },\n [{}, {}],\n );\n}\n\nfunction reshadowToShadow(obj: any) {\n return Object.entries(obj).reduce((style: any, [name, value]) => {\n let n = name;\n if (name.startsWith('__')) {\n n = name.replace(/^__/, '');\n } else if (name.startsWith('_')) {\n n = name.replace(/^_/, '').replace('_', '=');\n }\n style[n] = value;\n return style;\n }, {});\n}\n\nfunction sstyled(styles = {}): ((ReactNode: any) => ReactNode) & {\n cn(name: string, props: any): any;\n} {\n // @ts-ignore\n return {\n cn(name, props) {\n const [classes, style] = getClassAndVars(reshadowToShadow(styles), name, props);\n const extraProps = {};\n\n if (Object.keys(classes).length) {\n // @ts-ignore\n extraProps.className = cn(props.className, classes);\n }\n\n if (Object.keys(style).length) {\n // @ts-ignore\n extraProps.style = Object.assign(style, props.style);\n }\n return {\n ...props,\n ...extraProps,\n };\n },\n };\n}\n\nsstyled.css = function (css: any): { [key: string]: string } {\n throw new Error('Enable babel plugin');\n};\nsstyled.insert = insert;\nsstyled.merge = merge;\nsstyled.getStyles = getStyles;\nsstyled.SHADOW_STYLES = Symbol('SHADOW_STYLES');\n\nexport { sstyled };\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AADA;;AAGA,IAAMG,WAAW,GAAG,cAAc;AAElC,IAAMC,KAAK,GAAG,EAAE,OAAOC,MAAM,KAAK,WA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AACK,KAAK,CAAC0B,SAAS,EAAEH,OAAO,CAAC;MACrD;MAEA,IAAItC,MAAM,CAACwC,IAAI,CAACV,KAAK,CAAC,CAACjC,MAAM,EAAE;QAC7B;QACA0C,UAAU,CAACT,KAAK,GAAG9B,MAAM,CAACW,MAAM,CAACmB,KAAK,EAAEf,KAAK,CAACe,KAAK,CAAC;MACtD;MACA,WAAAY,cAAA,iBAAAA,cAAA,iBACK3B,KAAK,GACLwB,UAAU;IAEjB;EACF,CAAC;AACH;AAEAJ,OAAO,CAACvD,GAAG,GAAG,UAAUA,GAAQ,EAA6B;EAC3D,MAAM,IAAI+D,KAAK,CAAC,qBAAqB,CAAC;AACxC,CAAC;AACDR,OAAO,CAACnD,MAAM,GAAGA,MAAM;AACvBmD,OAAO,CAACzC,KAAK,GAAGA,KAAK;AACrByC,OAAO,CAACxD,SAAS,GAAGA,SAAS;AAC7BwD,OAAO,CAACS,aAAa,GAAGC,MAAM,CAAC,eAAe,CAAC"}
|
package/lib/es6/Component.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
import { PureComponent } from 'react';
|
|
8
|
-
var Root = undefined;
|
|
9
|
-
export { Root };
|
|
10
|
-
|
|
11
|
-
/** @deprecated */
|
|
12
|
-
var RootComponent = /*#__PURE__*/function (_PureComponent) {
|
|
13
|
-
_inherits(RootComponent, _PureComponent);
|
|
14
|
-
var _super = _createSuper(RootComponent);
|
|
15
|
-
function RootComponent() {
|
|
16
|
-
var _this;
|
|
17
|
-
_classCallCheck(this, RootComponent);
|
|
18
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
19
|
-
args[_key] = arguments[_key];
|
|
20
|
-
}
|
|
21
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
22
|
-
_defineProperty(_assertThisInitialized(_this), "Root", undefined);
|
|
23
|
-
_defineProperty(_assertThisInitialized(_this), "isControlled", false);
|
|
24
|
-
return _this;
|
|
25
|
-
}
|
|
26
|
-
_createClass(RootComponent, [{
|
|
27
|
-
key: "handlers",
|
|
28
|
-
get: function get() {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
key: "asProps",
|
|
33
|
-
get: function get() {
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
}]);
|
|
37
|
-
return RootComponent;
|
|
38
|
-
}(PureComponent);
|
|
39
|
-
export var Component = RootComponent;
|
|
40
|
-
/** @deprecated */
|
|
41
|
-
|
|
42
|
-
export var Intergalactic;
|
|
43
|
-
(function (_Intergalactic) {
|
|
44
|
-
var InternalTypings;
|
|
45
|
-
(function (_InternalTypings) {})(InternalTypings || (InternalTypings = _Intergalactic.InternalTypings || (_Intergalactic.InternalTypings = {})));
|
|
46
|
-
})(Intergalactic || (Intergalactic = {}));
|
|
47
|
-
export var wrapIntergalacticComponent = function wrapIntergalacticComponent(wrapper) {
|
|
48
|
-
return wrapper;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=Component.js.map
|
package/lib/es6/Component.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","names":["PureComponent","Root","undefined","RootComponent","_PureComponent","_inherits","_super","_createSuper","_this","_classCallCheck","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty","_assertThisInitialized","_createClass","key","get","Component","Intergalactic","_Intergalactic","InternalTypings","_InternalTypings","wrapIntergalacticComponent","wrapper"],"sources":["../../src/Component.tsx"],"sourcesContent":["import React, {\n AllHTMLAttributes,\n ForwardRefExoticComponent,\n PureComponent,\n ReactNode,\n RefObject,\n} from 'react';\nimport { IStyledProps } from './styled';\n\n/** @deprecated */\ntype KnownKeys<T> = {\n [K in keyof T]: string extends K ? never : number extends K ? never : K;\n} extends { [_ in keyof T]: infer U }\n ? U\n : never;\n\n/** @deprecated */\nexport type HandlersType<UCProps> = { [K in keyof UCProps]?: <T = unknown>(arg: T) => void };\n/** @deprecated */\nexport type ChildrenType<Props = {}, Ctx = {}, UCProps = {}> =\n | ((props: Props & Ctx, handlers: HandlersType<UCProps>) => ReactNode)\n | ReactNode;\n\n/** @deprecated */\nexport type RootComponentHandler = (...args: any[]) => void | false;\n\n/** @deprecated */\nexport interface IRootComponentHandlers {\n [key: string]: RootComponentHandler;\n}\n\n/** @deprecated */\nexport interface IRootComponentProps<Props = {}, Ctx = {}> {\n forwardRef?: RefObject<any>;\n Children?: any;\n children?: ChildrenType<Props, Ctx>;\n styles?: IStyledProps['styles'];\n 'data-ui-name'?: string;\n}\n\n/** @deprecated */\nexport type IComponentProps<Props = {}, Ctx = {}> = Props & IRootComponentProps<Props, Ctx>;\n\n/** @deprecated */\nexport type IFunctionProps<Props = {}, Ctx = {}> = IComponentProps<Props, Ctx> &\n Omit<AllHTMLAttributes<any>, keyof IComponentProps<Props, Ctx>> & { Root?: Root };\n\n/** @deprecated */\nexport type PropsWithRenderFnChildren<Props = {}, Ctx = {}, UCProps = {}> = Omit<\n Pick<Props, KnownKeys<Props>>,\n 'children'\n> & {\n children?: ChildrenType<Props, Ctx, UCProps>;\n [key: string]: unknown;\n};\n\n/** @deprecated */\nexport type CProps<Props, Ctx = {}, UCProps = {}> = Props & {\n children?: ((props: Props & Ctx, handlers: UCProps) => React.ReactNode) | React.ReactNode;\n};\n/** @deprecated */\nexport type ReturnEl = React.ReactElement | null;\n\nexport interface IRootNodeProps {\n render: React.ElementType | string;\n tag?: React.ElementType | string;\n\n [key: string]: any;\n}\n\ntype Root = ForwardRefExoticComponent<IRootNodeProps>;\n\n/**\n * @deprecated since version ^1.8.0\n */\nexport type PropGetter<T extends (...args: any) => any> = <P>(props?: P) => ReturnType<T> & P;\n/**\n * @deprecated since version ^1.8.0\n */\n/** @deprecated */\nexport type PropGetterReturn<T extends (...args: any) => any> = Partial<ReturnType<T>>;\n/** @deprecated */\nexport type PropGetterFn = <T extends {}>(props?: T) => T & { [key: string]: unknown };\n/** @deprecated */\nexport type Merge<Props, HTMLProps> = Props & Omit<HTMLProps, keyof Props>;\n/** @deprecated */\nexport type MergeGetters<G1 extends (...args: any) => any, G2 extends (...args: any) => any> = <P>(\n props?: P,\n) => Merge<ReturnType<G1>, ReturnType<G2>> & P;\n\nconst Root: Root = undefined as any;\n\nexport { Root };\n\n/** @deprecated */\nabstract class RootComponent<\n Props = {},\n Context = {},\n State = {},\n Enhance = {},\n> extends PureComponent<Props, State> {\n get handlers(): Readonly<IRootComponentHandlers> {\n return {};\n }\n\n get asProps() {\n return {} as Readonly<\n Merge<Props & IRootComponentProps<Props, Context> & Enhance, AllHTMLAttributes<any>>\n >;\n }\n\n Root: Root = undefined as any;\n\n isControlled = false;\n}\n\nexport const Component = RootComponent;\n/** @deprecated */\nexport type Component<\n Props = {},\n Context = {},\n State = {},\n Handlers extends IRootComponentHandlers = IRootComponentHandlers,\n> = React.ComponentClass<Props, State> & {\n isControlled: boolean;\n\n handlers: Readonly<Handlers>;\n\n asProps: Readonly<Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>>;\n\n Root: Root;\n};\n\nexport namespace Intergalactic {\n type ReactFCProps<C extends React.FC> = C extends React.FC<infer Props> ? Omit<Props, 'tag'> : {};\n type ReactComponentProps<C extends React.ComponentClass> = C extends React.ComponentClass<\n infer Props\n >\n ? Omit<Props, 'tag'>\n : never;\n type ReactFCLike = (props: any) => any;\n type ReactFCLikeProps<C extends ReactFCLike> = C extends (props: infer Props) => any ? Props : {};\n type ComponentChildren<\n Props,\n Context,\n RenderingResult = InternalTypings.ReturnResult,\n AdditionalContext extends any[] = never[],\n > =\n | ((props: MergeProps<Context, Props>, ...args: AdditionalContext) => RenderingResult)\n | InternalTypings.ReturnResult;\n type ComponentBasicProps<Tag extends InternalTypings.ComponentTag> = {\n ref?: React.Ref<InternalTypings.ComponentHtmlElement<Tag> | null>;\n /** @private DO NOT USE IT. Low-level api that prevents specified props from being applied as DOM attribute. */\n __excludeProps?: string[];\n };\n type MergeProps<HighPriorityProps, LowPriorityProps> = {\n [K in keyof LowPriorityProps]: K extends keyof HighPriorityProps\n ? HighPriorityProps[K]\n : LowPriorityProps[K];\n } & HighPriorityProps;\n /** @private */\n export namespace InternalTypings {\n export type EfficientOmit<Type, Keys> = {\n [Property in keyof Type as Exclude<Property, Keys>]: Type[Property];\n };\n export type ComponentPropsNesting<Tag extends InternalTypings.ComponentTag> = Omit<\n MergeProps<\n Tag extends React.FC\n ? ReactFCProps<Tag>\n : Tag extends React.ComponentClass\n ? ReactComponentProps<Tag>\n : Tag extends ReactFCLike\n ? ReactFCLikeProps<Tag>\n : Tag extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[Tag]\n : {},\n Tag extends { __nestedProps: infer NestedProps } ? NestedProps : {}\n >,\n 'children' | 'tag'\n >;\n export type ReturnResult =\n | React.ReactElement\n | React.ReactNode\n | React.ReactNode[]\n | string\n | null;\n export type ComponentTag =\n | keyof JSX.IntrinsicElements\n | React.ComponentClass\n | React.FC\n | ReactFCLike;\n export type ComponentProps<\n Tag extends ComponentTag,\n BaseTag extends ComponentTag | never,\n Props,\n Context = never,\n AdditionalContext extends any[] = never[],\n > = {\n tag?: Tag;\n children?: ComponentChildren<\n EfficientOmit<Props, 'children'> & { children: React.ReactNode },\n Context,\n ReturnResult,\n AdditionalContext\n >;\n } & ComponentBasicProps<Tag> &\n MergeProps<\n EfficientOmit<Props, 'tag' | 'children'>,\n MergeProps<ComponentPropsNesting<Tag>, ComponentPropsNesting<BaseTag>>\n >;\n export type PropsRenderingResultComponentProps<\n Tag extends ComponentTag,\n Props,\n Context = {},\n AdditionalContext extends any[] = never[],\n > = {\n tag?: Tag;\n children?: ComponentChildren<\n EfficientOmit<Props, 'children'> & { children: React.ReactNode },\n Context,\n Partial<\n EfficientOmit<\n MergeProps<Props, ComponentPropsNesting<Tag>>,\n 'children' | 'tag' | 'ref'\n > & {\n children?: React.ReactNode;\n }\n >,\n AdditionalContext\n >;\n } & ComponentBasicProps<Tag> &\n MergeProps<EfficientOmit<Props, 'tag' | 'children'>, ComponentPropsNesting<Tag>>;\n export type ComponentRenderingResults = React.ReactElement;\n export type ComponentAdditive<\n BaseTag extends ComponentTag,\n Tag extends ComponentTag,\n Props = {},\n Context = {},\n AdditionalContext = {},\n > = {\n __nestedProps: ComponentPropsNesting<BaseTag>;\n __tag: Tag;\n __props: Props;\n __context: Context;\n __additionalContext: AdditionalContext;\n };\n export type InferJsxIntrinsicElement<T extends React.DetailedHTMLProps<any, any>> =\n T extends React.DetailedHTMLProps<infer _, infer Element> ? Element : HTMLElement;\n type InferElementFromRef<T> = T extends React.Ref<infer Element> ? Element : never;\n type InferRefElementFromProps<T> = 'ref' extends keyof T\n ? InferElementFromRef<T['ref']>\n : HTMLElement;\n export type ComponentHtmlElement<Tag extends ComponentTag> =\n Tag extends keyof JSX.IntrinsicElements\n ? InferJsxIntrinsicElement<JSX.IntrinsicElements[Tag]>\n : Tag extends { __nestedProps: infer NestedProps }\n ? InferRefElementFromProps<NestedProps>\n : HTMLElement;\n export type UntypeRefAndTag<Props> = Intergalactic.InternalTypings.EfficientOmit<\n Props,\n 'ref' | 'tag'\n > & {\n ref: React.Ref<any>;\n tag: Intergalactic.InternalTypings.ComponentTag;\n };\n }\n export type Component<\n BaseTag extends InternalTypings.ComponentTag = never,\n BaseProps = {},\n Context = {},\n AdditionalContext extends any[] = never[],\n > = (<Tag extends InternalTypings.ComponentTag = BaseTag, Props extends BaseProps = BaseProps>(\n props: InternalTypings.ComponentProps<Tag, BaseTag, Props, Context, AdditionalContext>,\n ) => InternalTypings.ComponentRenderingResults) &\n InternalTypings.ComponentAdditive<BaseTag, Tag, BaseProps, Context, AdditionalContext>;\n export type Tag = InternalTypings.ComponentTag;\n export type DomProps<Tag extends keyof JSX.IntrinsicElements> =\n InternalTypings.InferJsxIntrinsicElement<JSX.IntrinsicElements[Tag]>;\n}\n\nexport const wrapIntergalacticComponent = <\n Component extends Intergalactic.Component<any, any, any, any>,\n PropsExtending = {},\n>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<Component>\n > &\n PropsExtending,\n ) => React.ReactNode,\n): Intergalactic.Component<\n Component['__tag'],\n Component['__props'] & Component['__nestedProps'] & PropsExtending,\n Component['__context'],\n Component['__additionalContext']\n> => wrapper as any;\n"],"mappings":";;;;;;AAAA,SAGEA,aAAa,QAGR,OAAO;AAoFd,IAAMC,IAAU,GAAGC,SAAgB;AAEnC,SAASD,IAAI;;AAEb;AAAA,IACeE,aAAa,0BAAAC,cAAA;EAAAC,SAAA,CAAAF,aAAA,EAAAC,cAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,aAAA;EAAA,SAAAA,cAAA;IAAA,IAAAK,KAAA;IAAAC,eAAA,OAAAN,aAAA;IAAA,SAAAO,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAAF,IAAA,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAAAP,KAAA,GAAAF,MAAA,CAAAU,IAAA,CAAAC,KAAA,CAAAX,MAAA,SAAAY,MAAA,CAAAL,IAAA;IAAAM,eAAA,CAAAC,sBAAA,CAAAZ,KAAA,WAgBbN,SAAS;IAAAiB,eAAA,CAAAC,sBAAA,CAAAZ,KAAA,mBAEP,KAAK;IAAA,OAAAA,KAAA;EAAA;EAAAa,YAAA,CAAAlB,aAAA;IAAAmB,GAAA;IAAAC,GAAA,EAZpB,SAAAA,IAAA,EAAiD;MAC/C,OAAO,CAAC,CAAC;IACX;EAAC;IAAAD,GAAA;IAAAC,GAAA,EAED,SAAAA,IAAA,EAAc;MACZ,OAAO,CAAC,CAAC;IAGX;EAAC;EAAA,OAAApB,aAAA;AAAA,EATOH,aAAa;AAgBvB,OAAO,IAAMwB,SAAS,GAAGrB,aAAa;AACtC;;AAgBA,WAAAsB,aAAA;AAiJC,WAAAC,cAAA;EAAA,IAAAC,eAAA;EAAA,WAAAC,gBAAA,MArHkBD,eAAe,KAAfA,eAAe,GAAAD,cAAA,CAAfC,eAAe,KAAAD,cAAA,CAAfC,eAAe;AAAA,GA5BjBF,aAAa,KAAbA,aAAa;AAmJ9B,OAAO,IAAMI,0BAA0B,GAAG,SAA7BA,0BAA0BA,CAIrCC,OAKoB;EAAA,OAMjBA,OAAO;AAAA,CAAO"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
4
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
-
var _excluded = ["handlers", "getters"],
|
|
6
|
-
_excluded2 = ["handlers"];
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { CONTEXT_COMPONENT } from '../index';
|
|
9
|
-
export var CHILDREN_COMPONENT = Symbol('CHILDREN_COMPONENT');
|
|
10
|
-
var CHILDREN_SELF = Symbol('CHILDREN_SELF');
|
|
11
|
-
var GETTER_REG = /^get[\w]+Props$/;
|
|
12
|
-
function splitPropsAndGetters(props) {
|
|
13
|
-
return Object.entries(props).reduce(function (acc, _ref) {
|
|
14
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
15
|
-
key = _ref2[0],
|
|
16
|
-
value = _ref2[1];
|
|
17
|
-
if (GETTER_REG.exec(key) === null) {
|
|
18
|
-
acc.props[key] = value;
|
|
19
|
-
} else {
|
|
20
|
-
acc.getters[key] = value;
|
|
21
|
-
}
|
|
22
|
-
return acc;
|
|
23
|
-
}, {
|
|
24
|
-
props: {},
|
|
25
|
-
getters: {}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function getterToArray(getter) {
|
|
29
|
-
if (!Array.isArray(getter)) {
|
|
30
|
-
return typeof getter === 'function' ? [getter] : [];
|
|
31
|
-
}
|
|
32
|
-
return getter;
|
|
33
|
-
}
|
|
34
|
-
function mergeObjects() {
|
|
35
|
-
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
36
|
-
var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
37
|
-
var core = _objectSpread(_objectSpread({}, a), b);
|
|
38
|
-
return Object.keys(core).reduce(function (acc, key) {
|
|
39
|
-
a[key] = getterToArray(a[key]);
|
|
40
|
-
b[key] = getterToArray(b[key]);
|
|
41
|
-
acc[key] = [].concat(_toConsumableArray(a[key]), _toConsumableArray(b[key]));
|
|
42
|
-
return acc;
|
|
43
|
-
}, {});
|
|
44
|
-
}
|
|
45
|
-
function assignGettersChain(getters) {
|
|
46
|
-
return function () {
|
|
47
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
48
|
-
return getters.reduce(function (acc, getter) {
|
|
49
|
-
return getter(acc);
|
|
50
|
-
}, props);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function createChildren(Context, contexts) {
|
|
54
|
-
var Children = function Children() {
|
|
55
|
-
var children = Children.origin;
|
|
56
|
-
if (typeof children === 'function') {
|
|
57
|
-
var _reduce = [].concat(_toConsumableArray(contexts), [Context]).reduce(function (acc, ctx) {
|
|
58
|
-
var _ref3 = React.useContext(ctx),
|
|
59
|
-
handlers = _ref3.handlers,
|
|
60
|
-
propsAndGetters = _objectWithoutProperties(_ref3, _excluded2);
|
|
61
|
-
var _splitPropsAndGetters = splitPropsAndGetters(propsAndGetters),
|
|
62
|
-
props = _splitPropsAndGetters.props,
|
|
63
|
-
getters = _splitPropsAndGetters.getters;
|
|
64
|
-
return Object.assign({}, acc, _objectSpread({
|
|
65
|
-
handlers: Object.assign({}, acc.handlers, handlers),
|
|
66
|
-
getters: mergeObjects(acc.getters, getters)
|
|
67
|
-
}, props));
|
|
68
|
-
}, Children.props),
|
|
69
|
-
_reduce$handlers = _reduce.handlers,
|
|
70
|
-
handlers = _reduce$handlers === void 0 ? {} : _reduce$handlers,
|
|
71
|
-
_reduce$getters = _reduce.getters,
|
|
72
|
-
getters = _reduce$getters === void 0 ? {} : _reduce$getters,
|
|
73
|
-
props = _objectWithoutProperties(_reduce, _excluded);
|
|
74
|
-
var mergedGetters = Object.entries(getters).reduce(function (acc, _ref4) {
|
|
75
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
76
|
-
key = _ref5[0],
|
|
77
|
-
value = _ref5[1];
|
|
78
|
-
acc[key] = assignGettersChain(value);
|
|
79
|
-
return acc;
|
|
80
|
-
}, {});
|
|
81
|
-
return children(_objectSpread(_objectSpread({}, props), mergedGetters), handlers);
|
|
82
|
-
} else if (children === undefined) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
return children;
|
|
86
|
-
};
|
|
87
|
-
Children.origin = null;
|
|
88
|
-
Children.props = {};
|
|
89
|
-
Children[CHILDREN_COMPONENT] = true;
|
|
90
|
-
return Children;
|
|
91
|
-
}
|
|
92
|
-
function Enhancement(Context, parent) {
|
|
93
|
-
return {
|
|
94
|
-
init: function init() {
|
|
95
|
-
var contexts = (Array.isArray(parent) ? parent : [parent]).map(function (component) {
|
|
96
|
-
return component[CONTEXT_COMPONENT];
|
|
97
|
-
}).filter(Boolean);
|
|
98
|
-
this[CHILDREN_SELF] = createChildren(Context, contexts);
|
|
99
|
-
},
|
|
100
|
-
asProps: function asProps(props) {
|
|
101
|
-
// TODO: learn the reason what it was used for (by lsroman)
|
|
102
|
-
// this[CHILDREN_SELF].origin = _Children ? _Children.origin : children;
|
|
103
|
-
this[CHILDREN_SELF].origin = props.children;
|
|
104
|
-
this[CHILDREN_SELF].props = props;
|
|
105
|
-
return _objectSpread(_objectSpread({}, props), {}, {
|
|
106
|
-
Children: this[CHILDREN_SELF]
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
export default Enhancement;
|
|
112
|
-
//# sourceMappingURL=Children.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Children.js","names":["React","CONTEXT_COMPONENT","CHILDREN_COMPONENT","Symbol","CHILDREN_SELF","GETTER_REG","splitPropsAndGetters","props","Object","entries","reduce","acc","_ref","_ref2","_slicedToArray","key","value","exec","getters","getterToArray","getter","Array","isArray","mergeObjects","a","arguments","length","undefined","b","core","_objectSpread","keys","concat","_toConsumableArray","assignGettersChain","createChildren","Context","contexts","Children","children","origin","_reduce","ctx","_ref3","useContext","handlers","propsAndGetters","_objectWithoutProperties","_excluded2","_splitPropsAndGetters","assign","_reduce$handlers","_reduce$getters","_excluded","mergedGetters","_ref4","_ref5","Enhancement","parent","init","map","component","filter","Boolean","asProps"],"sources":["../../../src/enhancement/Children.tsx"],"sourcesContent":["import React from 'react';\nimport { CONTEXT_COMPONENT } from '../index';\n\nexport const CHILDREN_COMPONENT = Symbol('CHILDREN_COMPONENT');\nconst CHILDREN_SELF = Symbol('CHILDREN_SELF');\n\nconst GETTER_REG = /^get[\\w]+Props$/;\n\nfunction splitPropsAndGetters(props: any) {\n return Object.entries(props).reduce(\n (acc: any, [key, value]) => {\n if (GETTER_REG.exec(key) === null) {\n acc.props[key] = value;\n } else {\n acc.getters[key] = value;\n }\n return acc;\n },\n { props: {}, getters: {} },\n );\n}\n\nfunction getterToArray(getter: any) {\n if (!Array.isArray(getter)) {\n return typeof getter === 'function' ? [getter] : [];\n }\n return getter;\n}\n\nfunction mergeObjects(a: any = {}, b: any = {}) {\n const core = { ...a, ...b };\n return Object.keys(core).reduce((acc: any, key) => {\n a[key] = getterToArray(a[key]);\n b[key] = getterToArray(b[key]);\n acc[key] = [...a[key], ...b[key]];\n return acc;\n }, {});\n}\n\nfunction assignGettersChain(getters: Array<Function>) {\n return function (props = {}) {\n return getters.reduce((acc, getter) => {\n return getter(acc);\n }, props);\n };\n}\n\nfunction createChildren(Context: any, contexts: any) {\n const Children: any = function () {\n const children = Children.origin;\n if (typeof children === 'function') {\n const {\n handlers = {},\n getters = {},\n ...props\n } = [...contexts, Context].reduce((acc, ctx) => {\n const { handlers, ...propsAndGetters } = React.useContext(ctx) as any;\n const { props, getters } = splitPropsAndGetters(propsAndGetters);\n return Object.assign({}, acc, {\n handlers: Object.assign({}, acc.handlers, handlers),\n getters: mergeObjects(acc.getters, getters),\n ...props,\n });\n }, Children.props);\n\n const mergedGetters = Object.entries(getters).reduce((acc: any, [key, value]) => {\n acc[key] = assignGettersChain(value as []);\n return acc;\n }, {});\n\n return children({ ...props, ...mergedGetters }, handlers);\n } else if (children === undefined) {\n return null;\n }\n return children;\n };\n Children.origin = null;\n Children.props = {};\n Children[CHILDREN_COMPONENT] = true;\n return Children;\n}\n\nfunction Enhancement(this: any, Context: any, parent: any) {\n return {\n init: function (this: any) {\n const contexts = (Array.isArray(parent) ? parent : [parent])\n .map((component) => component[CONTEXT_COMPONENT])\n .filter(Boolean);\n this[CHILDREN_SELF] = createChildren(Context, contexts);\n },\n asProps: function (this: any, props: any) {\n // TODO: learn the reason what it was used for (by lsroman)\n // this[CHILDREN_SELF].origin = _Children ? _Children.origin : children;\n this[CHILDREN_SELF].origin = props.children;\n this[CHILDREN_SELF].props = props;\n return {\n ...props,\n Children: this[CHILDREN_SELF],\n };\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,UAAU;AAE5C,OAAO,IAAMC,kBAAkB,GAAGC,MAAM,CAAC,oBAAoB,CA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AAE;MACjC,OAAO,IAAI;IACb;IACA,OAAOY,QAAQ;EACjB,CAAC;EACDD,QAAQ,CAACE,MAAM,GAAG,IAAI;EACtBF,QAAQ,CAAC/B,KAAK,GAAG,CAAC,CAAC;EACnB+B,QAAQ,CAACpC,kBAAkB,CAAC,GAAG,IAAI;EACnC,OAAOoC,QAAQ;AACjB;AAEA,SAASmB,WAAWA,CAAYrB,OAAY,EAAEsB,MAAW,EAAE;EACzD,OAAO;IACLC,IAAI,EAAE,SAAAA,KAAA,EAAqB;MACzB,IAAMtB,QAAQ,GAAG,CAAChB,KAAK,CAACC,OAAO,CAACoC,MAAM,CAAC,GAAGA,MAAM,GAAG,CAACA,MAAM,CAAC,EACxDE,GAAG,CAAC,UAACC,SAAS;QAAA,OAAKA,SAAS,CAAC5D,iBAAiB,CAAC;MAAA,EAAC,CAChD6D,MAAM,CAACC,OAAO,CAAC;MAClB,IAAI,CAAC3D,aAAa,CAAC,GAAG+B,cAAc,CAACC,OAAO,EAAEC,QAAQ,CAAC;IACzD,CAAC;IACD2B,OAAO,EAAE,SAAAA,QAAqBzD,KAAU,EAAE;MACxC;MACA;MACA,IAAI,CAACH,aAAa,CAAC,CAACoC,MAAM,GAAGjC,KAAK,CAACgC,QAAQ;MAC3C,IAAI,CAACnC,aAAa,CAAC,CAACG,KAAK,GAAGA,KAAK;MACjC,OAAAuB,aAAA,CAAAA,aAAA,KACKvB,KAAK;QACR+B,QAAQ,EAAE,IAAI,CAAClC,aAAa;MAAC;IAEjC;EACF,CAAC;AACH;AAEA,eAAeqD,WAAW"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["render"],
|
|
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
|
-
import { useForkRef } from '@semcore/utils/lib/ref';
|
|
11
|
-
function createRootRender() {
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
var Root = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
14
|
-
var Tag = _ref.render,
|
|
15
|
-
source = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
-
var _Root$props = Root.props,
|
|
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);
|
|
24
|
-
var clearProps = Object.entries(props).reduce(function (props, _ref2) {
|
|
25
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
26
|
-
name = _ref3[0],
|
|
27
|
-
value = _ref3[1];
|
|
28
|
-
if (value !== undefined) {
|
|
29
|
-
props[name] = value;
|
|
30
|
-
}
|
|
31
|
-
return props;
|
|
32
|
-
}, {});
|
|
33
|
-
var child = {};
|
|
34
|
-
// TODO: need to find better check solution (by lsroman)
|
|
35
|
-
if (typeof Children.origin !== 'undefined') {
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
child.children = /*#__PURE__*/React.createElement(Children, null);
|
|
38
|
-
}
|
|
39
|
-
var other = assignProps(_objectSpread(_objectSpread({}, clearProps), {}, {
|
|
40
|
-
ref: useForkRef(forwardRef, ref)
|
|
41
|
-
}), _objectSpread(_objectSpread({}, child), source));
|
|
42
|
-
if (!Tag) {
|
|
43
|
-
throw new Error('`render` prop of Root is not provided');
|
|
44
|
-
}
|
|
45
|
-
if (Tag === React.Fragment) return /*#__PURE__*/React.createElement(React.Fragment, null, other.children);
|
|
46
|
-
return /*#__PURE__*/React.createElement(Tag, other);
|
|
47
|
-
});
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
Root.props = {};
|
|
50
|
-
return Root;
|
|
51
|
-
}
|
|
52
|
-
function Enhancement() {
|
|
53
|
-
return {
|
|
54
|
-
init: function init() {
|
|
55
|
-
this.Root = createRootRender();
|
|
56
|
-
},
|
|
57
|
-
asProps: function asProps(props, WrapperComponent, isFunction) {
|
|
58
|
-
if (isFunction) {
|
|
59
|
-
return _objectSpread(_objectSpread({}, props), {}, {
|
|
60
|
-
Root: this.Root
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return props;
|
|
64
|
-
},
|
|
65
|
-
render: function render(_render, props) {
|
|
66
|
-
this.Root.props = props;
|
|
67
|
-
return _render;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
export default Enhancement;
|
|
72
|
-
//# sourceMappingURL=Root.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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","Fragment","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 Root: _Root,\n\n styles,\n\n children,\n Children,\n forwardRef = null,\n ...props\n // @ts-ignore\n } = Root.props;\n\n const clearProps = Object.entries(props).reduce((props: any, [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 if (Tag === React.Fragment) return <React.Fragment>{other.children}</React.Fragment>;\n\n return <Tag {...other} />;\n });\n // @ts-ignore\n Root.props = {};\n return Root;\n}\n\nfunction Enhancement() {\n return {\n init: function (this: any) {\n this.Root = createRootRender();\n },\n asProps: function (this: any, props: any, WrapperComponent: any, isFunction: boolean) {\n if (isFunction) {\n return {\n ...props,\n Root: this.Root,\n };\n }\n return props;\n },\n render: function (this: any, render: any, props: any) {\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,GAUIT,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,qBAAA;MACdL,KAAK,G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SAAAA,KAAA,EAAqB;MACzB,IAAI,CAACnC,IAAI,GAAGD,gBAAgB,EAAE;IAChC,CAAC;IACDqC,OAAO,EAAE,SAAAA,QAAqB1B,KAAU,EAAE2B,gBAAqB,EAAEC,UAAmB,EAAE;MACpF,IAAIA,UAAU,EAAE;QACd,OAAAP,aAAA,CAAAA,aAAA,KACKrB,KAAK;UACRV,IAAI,EAAE,IAAI,CAACA;QAAI;MAEnB;MACA,OAAOU,KAAK;IACd,CAAC;IACDL,MAAM,EAAE,SAAAA,OAAqBA,OAAW,EAAEK,KAAU,EAAE;MACpD,IAAI,CAACV,IAAI,CAACU,KAAK,GAAGA,KAAK;MACvB,OAAOL,OAAM;IACf;EACF,CAAC;AACH;AAEA,eAAe6B,WAAW"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
function arraysEqual(a, b) {
|
|
2
|
-
if (a.length !== b.length) return false;
|
|
3
|
-
for (var i = 0; i < a.length; i++) {
|
|
4
|
-
if (a[i] !== b[i]) return false;
|
|
5
|
-
}
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
function handlerBinder(fn) {
|
|
9
|
-
return function () {
|
|
10
|
-
for (var _len = arguments.length, depsArgs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11
|
-
depsArgs[_key] = arguments[_key];
|
|
12
|
-
}
|
|
13
|
-
var memoizeds = [];
|
|
14
|
-
if (handlerBinder.hasher.has(fn)) {
|
|
15
|
-
memoizeds = handlerBinder.hasher.get(fn);
|
|
16
|
-
var memoized = memoizeds.find(function (memoized) {
|
|
17
|
-
return arraysEqual(memoized.deps, depsArgs);
|
|
18
|
-
});
|
|
19
|
-
if (memoized) return memoized.fn;
|
|
20
|
-
}
|
|
21
|
-
var bindFn = fn.apply(void 0, depsArgs).bind(fn);
|
|
22
|
-
memoizeds.push({
|
|
23
|
-
deps: depsArgs,
|
|
24
|
-
fn: bindFn
|
|
25
|
-
});
|
|
26
|
-
handlerBinder.hasher.set(fn, memoizeds);
|
|
27
|
-
return bindFn;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
handlerBinder.hasher = new WeakMap();
|
|
31
|
-
function Enhancement() {
|
|
32
|
-
return {
|
|
33
|
-
condition: function condition(Component, isFunction) {
|
|
34
|
-
return !isFunction;
|
|
35
|
-
},
|
|
36
|
-
init: function init() {
|
|
37
|
-
var _this = this;
|
|
38
|
-
Object.keys(this).filter(function (field) {
|
|
39
|
-
return field.startsWith('bindHandler');
|
|
40
|
-
}).forEach(function (name) {
|
|
41
|
-
_this[name] = handlerBinder(_this[name].bind(_this));
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export default Enhancement;
|
|
47
|
-
//# sourceMappingURL=bindHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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: any, b: any) {\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: any) {\n return function (...depsArgs: any[]) {\n let memoizeds = [];\n if (handlerBinder.hasher.has(fn)) {\n memoizeds = handlerBinder.hasher.get(fn);\n const memoized = memoizeds.find((memoized: any) => 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: any, isFunction: boolean) {\n return !isFunction;\n },\n init: function (this: any) {\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,CAAM,EAAEC,CAAM,EAAE;EACnC,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;AACb;AAEA,SAASC,aAAaA,CAACC,EAAO,EAAE;EAC9B,OAAO,YAA8B;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAL,MAAA,EAAjBM,QAAQ,OAAAC,KAAA,CAAAH,IAAA,GAAAI,IAAA,MAAAA,IAAA,GAAAJ,IAAA,EAAAI,IAAA;MAARF,QAAQ,CAAAE,IAAA,IAAAH,SAAA,CAAAG,IAAA;IAAA;IAC1B,IAAIC,SAAS,GAAG,EAAE;IAClB,IAAIP,aAAa,CAACQ,MAAM,CAACC,GAAG,CAACR,EAAE,CAAC,EAAE;MAChCM,SAAS,GAAGP,aAAa,CAACQ,MAAM,CAACE,GAAG,CAACT,EAAE,CAAC;MACxC,IAAMU,QAAQ,GAAGJ,SAAS,CAACK,IAAI,CAAC,UAACD,QAAa;QAAA,OAAKhB,WAAW,CAACgB,QAAQ,CAACE,IAAI,EAAET,QAAQ,CAAC;MAAA,EAAC;MACxF,IAAIO,QAAQ,EAAE,OAAOA,QAAQ,CAACV,EAAE;IAClC;IAEA,IAAMa,MAAM,GAAGb,EAAE,CAAAc,KAAA,SAAIX,QAAQ,CAAC,CAACY,IAAI,CAACf,EAAE,CAAC;IACvCM,SAAS,CAACU,IAAI,CAAC;MACbJ,IAAI,EAAET,QAAQ;MACdH,EAAE,EAAEa;IACN,CAAC,CAAC;IACFd,aAAa,CAACQ,MAAM,CAACU,GAAG,CAACjB,EAAE,EAAEM,SAAS,CAAC;IACvC,OAAOO,MAAM;EACf,CAAC;AACH;AAEAd,aAAa,CAACQ,MAAM,GAAG,IAAIW,OAAO,EAAE;AAEpC,SAASC,WAAWA,CAAA,EAAG;EACrB,OAAO;IACLC,SAAS,EAAE,SAAAA,UAAUC,SAAc,EAAEC,UAAmB,EAAE;MACxD,OAAO,CAACA,UAAU;IACpB,CAAC;IACDC,IAAI,EAAE,SAAAA,KAAA,EAAqB;MAAA,IAAAC,KAAA;MACzBC,MAAM,CAACC,IAAI,CAAC,IAAI,CAAC,CACdC,MAAM,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,12 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
function Enhancement() {
|
|
3
|
-
return {
|
|
4
|
-
wrapperProps: function wrapperProps(props, WrapperComponent) {
|
|
5
|
-
return _objectSpread({
|
|
6
|
-
'data-ui-name': WrapperComponent.displayName
|
|
7
|
-
}, props);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export default Enhancement;
|
|
12
|
-
//# sourceMappingURL=dataName.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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: any, WrapperComponent: any) {\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,KAAU,EAAEC,gBAAqB,EAAE;MACzD,OAAAC,aAAA;QACE,cAAc,EAAED,gBAAgB,CAACE;MAAW,GACzCH,KAAK;IAEZ;EACF,CAAC;AACH;AAEA,eAAeF,WAAW"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function Enhancement() {
|
|
2
|
-
return {
|
|
3
|
-
condition: function condition(Component) {
|
|
4
|
-
var _Component$enhance;
|
|
5
|
-
return Boolean((_Component$enhance = Component.enhance) === null || _Component$enhance === void 0 ? void 0 : _Component$enhance.length);
|
|
6
|
-
},
|
|
7
|
-
wrapperProps: function wrapperProps(props, WrapperComponent) {
|
|
8
|
-
return WrapperComponent.enhance.reduce(function (acc, enhance) {
|
|
9
|
-
return enhance(acc);
|
|
10
|
-
}, props);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export default Enhancement;
|
|
15
|
-
//# sourceMappingURL=enhance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enhance.js","names":["Enhancement","condition","Component","_Component$enhance","Boolean","enhance","length","wrapperProps","props","WrapperComponent","reduce","acc"],"sources":["../../../src/enhancement/enhance.tsx"],"sourcesContent":["function Enhancement() {\n return {\n condition: function (Component: any) {\n return Boolean(Component.enhance?.length);\n },\n wrapperProps: function (props: any, WrapperComponent: any) {\n return WrapperComponent.enhance.reduce((acc: any, enhance: any) => enhance(acc), props);\n },\n };\n}\n\nexport default Enhancement;\n"],"mappings":"AAAA,SAASA,WAAWA,CAAA,EAAG;EACrB,OAAO;IACLC,SAAS,EAAE,SAAAA,UAAUC,SAAc,EAAE;MAAA,IAAAC,kBAAA;MACnC,OAAOC,OAAO,EAAAD,kBAAA,GAACD,SAAS,CAACG,OAAO,cAAAF,kBAAA,uBAAjBA,kBAAA,CAAmBG,MAAM,CAAC;IAC3C,CAAC;IACDC,YAAY,EAAE,SAAAA,aAAUC,KAAU,EAAEC,gBAAqB,EAAE;MACzD,OAAOA,gBAAgB,CAACJ,OAAO,CAACK,MAAM,CAAC,UAACC,GAAQ,EAAEN,OAAY;QAAA,OAAKA,OAAO,CAACM,GAAG,CAAC;MAAA,GAAEH,KAAK,CAAC;IACzF;EACF,CAAC;AACH;AAEA,eAAeR,WAAW"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
function Enhancement() {
|
|
2
|
-
var defaultProps = {};
|
|
3
|
-
return {
|
|
4
|
-
condition: function condition(Component) {
|
|
5
|
-
if (!Component.defaultProps) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (typeof Component.defaultProps === 'function') {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
return Boolean(Object.keys(Component.defaultProps).length);
|
|
12
|
-
},
|
|
13
|
-
"static": function _static(WrapperComponent) {
|
|
14
|
-
defaultProps = WrapperComponent.defaultProps;
|
|
15
|
-
return {
|
|
16
|
-
defaultProps: {}
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
|
-
wrapperProps: function wrapperProps(props) {
|
|
20
|
-
if (typeof defaultProps === 'function') {
|
|
21
|
-
// TODO: optimization
|
|
22
|
-
return Object.assign({}, defaultProps(props), props);
|
|
23
|
-
}
|
|
24
|
-
return Object.assign({}, defaultProps, props);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export default Enhancement;
|
|
29
|
-
//# sourceMappingURL=functionDefaultProps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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: any) {\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: any) {\n defaultProps = WrapperComponent.defaultProps;\n return {\n defaultProps: {},\n };\n },\n wrapperProps: function (props: any) {\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,SAAc,EAAE;MACnC,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,gBAAqB,EAAE;MACvCR,YAAY,GAAGQ,gBAAgB,CAACR,YAAY;MAC5C,OAAO;QACLA,YAAY,EAAE,CAAC;MACjB,CAAC;IACH,CAAC;IACDS,YAAY,EAAE,SAAAA,aAAUC,KAAU,EAAE;MAClC,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"}
|