@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
package/lib/cjs/register.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = exports.Register = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
11
|
var Register = /*#__PURE__*/function () {
|
|
17
12
|
function Register() {
|
|
18
13
|
(0, _classCallCheck2["default"])(this, Register);
|
|
19
14
|
(0, _defineProperty2["default"])(this, "data", {});
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
(0, _createClass2["default"])(Register, [{
|
|
23
17
|
key: "get",
|
|
24
18
|
value: function get(name, defaultValue) {
|
|
@@ -36,10 +30,7 @@ var Register = /*#__PURE__*/function () {
|
|
|
36
30
|
}]);
|
|
37
31
|
return Register;
|
|
38
32
|
}();
|
|
39
|
-
|
|
40
33
|
exports.Register = Register;
|
|
41
|
-
|
|
42
34
|
var _default = new Register();
|
|
43
|
-
|
|
44
35
|
exports["default"] = _default;
|
|
45
36
|
//# sourceMappingURL=register.js.map
|
package/lib/cjs/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","names":["Register","name","defaultValue","data","set","
|
|
1
|
+
{"version":3,"file":"register.js","names":["Register","_classCallCheck2","_defineProperty2","_createClass2","key","value","get","name","defaultValue","data","set","exports","_default"],"sources":["../../src/register.tsx"],"sourcesContent":["class Register {\n data = {};\n\n get<D>(name, defaultValue?: D): D {\n if (name in this.data) {\n return this.data[name];\n } else {\n return this.set(name, defaultValue);\n }\n }\n\n set<D>(name, value: D): D {\n return (this.data[name] = value);\n }\n}\n\nexport { Register };\nexport default new Register();\n"],"mappings":";;;;;;;;;;IAAMA,QAAQ;EAAA,SAAAA,SAAA;IAAA,IAAAC,gBAAA,mBAAAD,QAAA;IAAA,IAAAE,gBAAA,2BACL,CAAC,CAAC;EAAA;EAAA,IAAAC,aAAA,aAAAH,QAAA;IAAAI,GAAA;IAAAC,KAAA,EAET,SAAAC,IAAOC,IAAI,EAAEC,YAAgB,EAAK;MAChC,IAAID,IAAI,IAAI,IAAI,CAACE,IAAI,EAAE;QACrB,OAAO,IAAI,CAACA,IAAI,CAACF,IAAI,CAAC;MACxB,CAAC,MAAM;QACL,OAAO,IAAI,CAACG,GAAG,CAACH,IAAI,EAAEC,YAAY,CAAC;MACrC;IACF;EAAC;IAAAJ,GAAA;IAAAC,KAAA,EAED,SAAAK,IAAOH,IAAI,EAAEF,KAAQ,EAAK;MACxB,OAAQ,IAAI,CAACI,IAAI,CAACF,IAAI,CAAC,GAAGF,KAAK;IACjC;EAAC;EAAA,OAAAL,QAAA;AAAA;AAAAW,OAAA,CAAAX,QAAA,GAAAA,QAAA;AAAA,IAAAY,QAAA,GAIY,IAAIZ,QAAQ,EAAE;AAAAW,OAAA,cAAAC,QAAA"}
|
package/lib/cjs/styled/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -28,9 +27,7 @@ Object.defineProperty(exports, "use", {
|
|
|
28
27
|
return _core.use;
|
|
29
28
|
}
|
|
30
29
|
});
|
|
31
|
-
|
|
32
30
|
var _core = _interopRequireWildcard(require("@reshadow/core"));
|
|
33
|
-
|
|
34
31
|
Object.keys(_core).forEach(function (key) {
|
|
35
32
|
if (key === "default" || key === "__esModule") return;
|
|
36
33
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -42,9 +39,7 @@ Object.keys(_core).forEach(function (key) {
|
|
|
42
39
|
}
|
|
43
40
|
});
|
|
44
41
|
});
|
|
45
|
-
|
|
46
42
|
var _sstyled = require("./sstyled");
|
|
47
|
-
|
|
48
43
|
Object.keys(_sstyled).forEach(function (key) {
|
|
49
44
|
if (key === "default" || key === "__esModule") return;
|
|
50
45
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/styled/index.tsx"],"sourcesContent":["export interface IStyledProps {\n /** @ignore */\n styles?: { [key: string]: string };\n}\nexport { default as styled } from '@reshadow/core';\nexport { use, css } from '@reshadow/core';\nexport * from '@reshadow/core';\n\nexport * from './sstyled';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_core","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_sstyled"],"sources":["../../../src/styled/index.tsx"],"sourcesContent":["export interface IStyledProps {\n /** @ignore */\n styles?: { [key: string]: string };\n}\nexport { default as styled } from '@reshadow/core';\nexport { use, css } from '@reshadow/core';\nexport * from '@reshadow/core';\n\nexport * from './sstyled';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEAC,MAAA,CAAAC,IAAA,CAAAJ,KAAA,EAAAK,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAN,KAAA,CAAAM,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAd,KAAA,CAAAM,GAAA;IAAA;EAAA;AAAA;AAEA,IAAAS,QAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,QAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,QAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,QAAA,CAAAT,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,58 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.sstyled = sstyled;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
11
|
var _react = require("react");
|
|
17
|
-
|
|
18
12
|
var _core = require("@reshadow/core");
|
|
19
|
-
|
|
20
13
|
/* eslint-disable */
|
|
14
|
+
|
|
21
15
|
var RESHADOW_ID = '__reshadow__';
|
|
22
16
|
var isSSR = !(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
23
17
|
var serverMap = (0, _core.getStyles)().map;
|
|
24
|
-
|
|
25
18
|
var getStyles = function getStyles() {
|
|
26
19
|
return {
|
|
27
20
|
map: serverMap,
|
|
28
|
-
|
|
29
21
|
get css() {
|
|
30
22
|
var serverStyles = '';
|
|
31
|
-
|
|
32
23
|
for (var id in serverMap) {
|
|
33
24
|
serverStyles += "<style type='text/css' id='".concat(id, "'>").concat(serverMap[id], "</style>");
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
return serverStyles;
|
|
37
27
|
}
|
|
38
|
-
|
|
39
28
|
};
|
|
40
29
|
};
|
|
41
|
-
|
|
42
30
|
function insert(code, hash) {
|
|
43
31
|
var id = 'reshadow-'.concat(hash);
|
|
44
|
-
|
|
45
32
|
if (isSSR) {
|
|
46
33
|
serverMap[id] = code;
|
|
47
34
|
return;
|
|
48
35
|
}
|
|
49
|
-
|
|
50
36
|
var container = document.getElementById(RESHADOW_ID);
|
|
51
|
-
|
|
52
37
|
if (!container) {
|
|
53
38
|
container = document.createElement('object');
|
|
54
39
|
container.id = RESHADOW_ID;
|
|
55
|
-
|
|
56
40
|
if (document.head) {
|
|
57
41
|
document.head.appendChild(container);
|
|
58
42
|
} else {
|
|
@@ -61,50 +45,40 @@ function insert(code, hash) {
|
|
|
61
45
|
});
|
|
62
46
|
}
|
|
63
47
|
}
|
|
64
|
-
|
|
65
48
|
var css = document.getElementById(id);
|
|
66
|
-
|
|
67
49
|
if (!css) {
|
|
68
50
|
css = document.createElement('style');
|
|
69
|
-
css.id = id;
|
|
70
|
-
|
|
51
|
+
css.id = id;
|
|
52
|
+
// @ts-ignore
|
|
71
53
|
css.type = 'text/css';
|
|
72
54
|
container.appendChild(css);
|
|
73
55
|
}
|
|
74
|
-
|
|
75
56
|
css.innerHTML = code;
|
|
76
57
|
}
|
|
77
|
-
|
|
78
58
|
function merge() {
|
|
79
59
|
var s1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
80
60
|
var s2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
81
61
|
return Object.entries(s2).reduce(function (acc, _ref) {
|
|
82
62
|
var _ref2 = (0, _slicedToArray2["default"])(_ref, 2),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
63
|
+
key = _ref2[0],
|
|
64
|
+
value = _ref2[1];
|
|
86
65
|
if (key.startsWith('@') || key.startsWith('--')) {
|
|
87
66
|
acc[key] = value;
|
|
88
67
|
} else {
|
|
89
68
|
acc[key] = (0, _classnames["default"])(acc[key], value);
|
|
90
69
|
}
|
|
91
|
-
|
|
92
70
|
return acc;
|
|
93
71
|
}, Object.assign({}, s1));
|
|
94
72
|
}
|
|
95
|
-
|
|
96
73
|
function getClassAndVars(styles, name, props) {
|
|
97
74
|
function getPropValue(key, props) {
|
|
98
75
|
var _props;
|
|
99
|
-
|
|
100
76
|
return (_props = props["use:".concat(key)]) !== null && _props !== void 0 ? _props : props[key];
|
|
101
77
|
}
|
|
102
|
-
|
|
103
78
|
return Object.entries(styles).reduce(function (acc, _ref3) {
|
|
104
79
|
var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
80
|
+
key = _ref4[0],
|
|
81
|
+
value = _ref4[1];
|
|
108
82
|
if (key.startsWith('--')) {
|
|
109
83
|
// @ts-ignore
|
|
110
84
|
acc[1][value] = getPropValue(key.substring(2), props);
|
|
@@ -113,12 +87,10 @@ function getClassAndVars(styles, name, props) {
|
|
|
113
87
|
acc[0][value] = true;
|
|
114
88
|
} else {
|
|
115
89
|
var _key$split = key.split('='),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
_key$split2 = (0, _slicedToArray2["default"])(_key$split, 2),
|
|
91
|
+
mod = _key$split2[0],
|
|
92
|
+
modValue = _key$split2[1];
|
|
120
93
|
var propValue = getPropValue(mod, props);
|
|
121
|
-
|
|
122
94
|
if (modValue === undefined) {
|
|
123
95
|
// @ts-ignore
|
|
124
96
|
acc[0][value] = Boolean(propValue !== null && propValue !== void 0 ? propValue : false);
|
|
@@ -127,64 +99,53 @@ function getClassAndVars(styles, name, props) {
|
|
|
127
99
|
acc[0][value] = propValue == modValue;
|
|
128
100
|
}
|
|
129
101
|
}
|
|
130
|
-
|
|
131
102
|
return acc;
|
|
132
103
|
}, [{}, {}]);
|
|
133
104
|
}
|
|
134
|
-
|
|
135
105
|
function reshadowToShadow(obj) {
|
|
136
106
|
return Object.entries(obj).reduce(function (style, _ref5) {
|
|
137
107
|
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
108
|
+
name = _ref6[0],
|
|
109
|
+
value = _ref6[1];
|
|
141
110
|
var n = name;
|
|
142
|
-
|
|
143
111
|
if (name.startsWith('__')) {
|
|
144
112
|
n = name.replace(/^__/, '');
|
|
145
113
|
} else if (name.startsWith('_')) {
|
|
146
114
|
n = name.replace(/^_/, '').replace('_', '=');
|
|
147
115
|
}
|
|
148
|
-
|
|
149
116
|
style[n] = value;
|
|
150
117
|
return style;
|
|
151
118
|
}, {});
|
|
152
119
|
}
|
|
153
|
-
|
|
154
120
|
function sstyled() {
|
|
155
121
|
var styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
156
122
|
// @ts-ignore
|
|
157
123
|
return {
|
|
158
124
|
cn: function cn(name, props) {
|
|
159
125
|
var _getClassAndVars = getClassAndVars(reshadowToShadow(styles), name, props),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
126
|
+
_getClassAndVars2 = (0, _slicedToArray2["default"])(_getClassAndVars, 2),
|
|
127
|
+
classes = _getClassAndVars2[0],
|
|
128
|
+
style = _getClassAndVars2[1];
|
|
164
129
|
var extraProps = {};
|
|
165
|
-
|
|
166
130
|
if (Object.keys(classes).length) {
|
|
167
131
|
// @ts-ignore
|
|
168
132
|
extraProps.className = (0, _classnames["default"])(props.className, classes);
|
|
169
133
|
}
|
|
170
|
-
|
|
171
134
|
if (Object.keys(style).length) {
|
|
172
135
|
// @ts-ignore
|
|
173
136
|
extraProps.style = Object.assign(style, props.style);
|
|
174
137
|
}
|
|
175
|
-
|
|
176
138
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), extraProps);
|
|
177
139
|
}
|
|
178
140
|
};
|
|
179
141
|
}
|
|
180
|
-
|
|
181
142
|
sstyled.css = function (css) {
|
|
182
143
|
throw new Error('Enable babel plugin');
|
|
183
144
|
};
|
|
184
|
-
|
|
185
145
|
sstyled.insert = insert;
|
|
186
146
|
sstyled.merge = merge;
|
|
187
147
|
sstyled.getStyles = getStyles;
|
|
188
148
|
sstyled.SHADOW_STYLES = Symbol('SHADOW_STYLES');
|
|
149
|
+
|
|
189
150
|
/* eslint-enable */
|
|
190
151
|
//# sourceMappingURL=sstyled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sstyled.js","names":["RESHADOW_ID","isSSR","window","document","createElement","serverMap","reshadowGetStyles","map","getStyles","css","serverStyles","id","insert","code","hash","
|
|
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":["/* eslint-disable */\nimport cn from 'classnames';\nimport { ReactNode } from 'react';\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, hash) {\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);\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, [key, value]) => {\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, name, props) {\n function getPropValue(key, props) {\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 acc[0][value] = propValue == modValue;\n }\n }\n return acc;\n },\n [{}, {}],\n );\n}\n\nfunction reshadowToShadow(obj) {\n return Object.entries(obj).reduce((style, [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(\n styles = {},\n): ((ReactNode) => 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): { [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/* eslint-enable */\n"],"mappings":";;;;;;;;;AACA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAHA;;AAKA,IAAMG,WAAW,GAAG,cAAc;AAElC,IAAMC,KAAK,GAAG,EAAE,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,QAAQ,IAAID,MAAM,CAACC,QAAQ,CAACC,aAAa,CAAC;AAElG,IAAMC,SAAS,GAAG,IAAAC,eAAiB,GAAE,CAACC,GAAG;AAEzC,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAA;EAAA,OAAU;IACvBD,GAAG,EAAEF,SAAS;IACd,IAAII,GAAGA,CAAA,EAAG;MACR,IAAIC,YAAY,GAAG,EAAE;MACrB,KAAK,IAAMC,EAAE,IAAIN,SAAS,EAAE;QAC1BK,YAAY,kCAAAE,MAAA,CAAkCD,EAAE,QAAAC,MAAA,CAAKP,SAAS,CAACM,EAAE,CAAC,aAAU;MAC9E;MACA,OAAOD,YAAY;IACrB;EACF,CAAC;AAAA,CAAC;AAEF,SAASG,MAAMA,CAACC,IAAI,EAAEC,IAAI,EAAE;EAC1B,IAAMJ,EAAE,GAAG,WAAW,CAACC,MAAM,CAACG,IAAI,CAAC;EAEnC,IAAId,KAAK,EAAE;IACTI,SAAS,CAACM,EAAE,CAAC,GAAGG,IAAI;IACpB;EACF;EAEA,IAAIE,SAAS,GAAGb,QAAQ,CAACc,cAAc,CAACjB,WAAW,CAA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MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAIX;EACA,OAAO;IACLc,EAAE,WAAAA,GAACI,IAAI,EAAEC,KAAK,EAAE;MACd,IAAAqB,gBAAA,GAAyBxB,eAAe,CAACgB,gBAAgB,CAACf,MAAM,CAAC,EAAEC,IAAI,EAAEC,KAAK,CAAC;QAAAsB,iBAAA,OAAA/B,eAAA,aAAA8B,gBAAA;QAAxEE,OAAO,GAAAD,iBAAA;QAAEP,KAAK,GAAAO,iBAAA;MACrB,IAAME,UAAU,GAAG,CAAC,CAAC;MAErB,IAAIvC,MAAM,CAACwC,IAAI,CAACF,OAAO,CAAC,CAACzC,MAAM,EAAE;QAC/B;QACA0C,UAAU,CAACE,SAAS,GAAG,IAAA/B,sBAAE,EAACK,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,GAAG,EAA6B;EACtD,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;;AAG/C"}
|
package/lib/es6/Component.js
CHANGED
|
@@ -5,28 +5,19 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
7
|
import { PureComponent } from 'react';
|
|
8
|
-
|
|
9
8
|
var RootComponent = /*#__PURE__*/function (_PureComponent) {
|
|
10
9
|
_inherits(RootComponent, _PureComponent);
|
|
11
|
-
|
|
12
10
|
var _super = _createSuper(RootComponent);
|
|
13
|
-
|
|
14
11
|
function RootComponent() {
|
|
15
12
|
var _this;
|
|
16
|
-
|
|
17
13
|
_classCallCheck(this, RootComponent);
|
|
18
|
-
|
|
19
14
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
15
|
args[_key] = arguments[_key];
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
|
-
|
|
25
18
|
_defineProperty(_assertThisInitialized(_this), "Root", void 0);
|
|
26
|
-
|
|
27
19
|
return _this;
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
_createClass(RootComponent, [{
|
|
31
22
|
key: "handlers",
|
|
32
23
|
get: function get() {
|
|
@@ -38,9 +29,7 @@ var RootComponent = /*#__PURE__*/function (_PureComponent) {
|
|
|
38
29
|
return {};
|
|
39
30
|
}
|
|
40
31
|
}]);
|
|
41
|
-
|
|
42
32
|
return RootComponent;
|
|
43
33
|
}(PureComponent);
|
|
44
|
-
|
|
45
34
|
export var Component = RootComponent;
|
|
46
35
|
//# sourceMappingURL=Component.js.map
|
package/lib/es6/Component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","names":["PureComponent","RootComponent","Component"],"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\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\nexport type HandlersType<UCProps> = { [K in keyof UCProps]?: <T = unknown>(arg: T) => void };\nexport type ChildrenType<Props = {}, Ctx = {}, UCProps = {}> =\n | ((props: Props & Ctx, handlers: HandlersType<UCProps>) => ReactNode)\n | ReactNode;\n\nexport type RootComponentHandler = (...args: any[]) => void | false;\n\nexport interface IRootComponentHandlers {\n [key: string]: RootComponentHandler;\n}\n\nexport interface IRootComponentProps<Props = {}, Ctx = {}> {\n forwardRef?: RefObject<any>;\n Children?: any;\n children?: ChildrenType<Props, Ctx>;\n styles?: IStyledProps['styles'];\n}\n\nexport type IComponentProps<Props = {}, Ctx = {}> = Props & IRootComponentProps<Props, Ctx>;\n\nexport type IFunctionProps<Props = {}, Ctx = {}> = IComponentProps<Props, Ctx> &\n Omit<AllHTMLAttributes<any>, keyof IComponentProps<Props, Ctx>> & { Root?: Root };\n\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\nexport type CProps<Props, Ctx = {}, UCProps = {}> = Props & {\n children?: ((props: Props & Ctx, handlers: UCProps) => React.ReactNode) | React.ReactNode;\n};\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 */\nexport type PropGetterReturn<T extends (...args: any) => any> = Partial<ReturnType<T>>;\nexport type PropGetterFn = <T extends {}>(props?: T) => T & { [key: string]: unknown };\nexport type Merge<Props, HTMLProps> = Props & Omit<HTMLProps, keyof Props>;\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\ndeclare const Root: Root;\n\nexport { Root };\n\nabstract class RootComponent<Props = {}, Context = {}, State = {}> extends PureComponent<\n Props & IRootComponentProps<Props, Context>,\n State\n> {\n get handlers(): Readonly<IRootComponentHandlers> {\n return {};\n }\n\n get asProps() {\n return {} as Readonly<\n Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>\n >;\n }\n\n Root: Root;\n}\n\nexport const Component = RootComponent;\nexport type Component<\n Props = {},\n Context = {},\n State = {},\n Handlers extends IRootComponentHandlers = IRootComponentHandlers,\n> = React.ComponentClass<Props, State> & {\n handlers: Readonly<Handlers>;\n\n asProps: Readonly<Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>>;\n\n Root: Root;\n};\n"],"mappings":";;;;;;AAAA,SAGEA,
|
|
1
|
+
{"version":3,"file":"Component.js","names":["PureComponent","RootComponent","_PureComponent","_inherits","_super","_createSuper","_this","_classCallCheck","_len","arguments","length","args","Array","_key","call","apply","concat","_defineProperty","_assertThisInitialized","_createClass","key","get","Component"],"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\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\nexport type HandlersType<UCProps> = { [K in keyof UCProps]?: <T = unknown>(arg: T) => void };\nexport type ChildrenType<Props = {}, Ctx = {}, UCProps = {}> =\n | ((props: Props & Ctx, handlers: HandlersType<UCProps>) => ReactNode)\n | ReactNode;\n\nexport type RootComponentHandler = (...args: any[]) => void | false;\n\nexport interface IRootComponentHandlers {\n [key: string]: RootComponentHandler;\n}\n\nexport interface IRootComponentProps<Props = {}, Ctx = {}> {\n forwardRef?: RefObject<any>;\n Children?: any;\n children?: ChildrenType<Props, Ctx>;\n styles?: IStyledProps['styles'];\n}\n\nexport type IComponentProps<Props = {}, Ctx = {}> = Props & IRootComponentProps<Props, Ctx>;\n\nexport type IFunctionProps<Props = {}, Ctx = {}> = IComponentProps<Props, Ctx> &\n Omit<AllHTMLAttributes<any>, keyof IComponentProps<Props, Ctx>> & { Root?: Root };\n\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\nexport type CProps<Props, Ctx = {}, UCProps = {}> = Props & {\n children?: ((props: Props & Ctx, handlers: UCProps) => React.ReactNode) | React.ReactNode;\n};\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 */\nexport type PropGetterReturn<T extends (...args: any) => any> = Partial<ReturnType<T>>;\nexport type PropGetterFn = <T extends {}>(props?: T) => T & { [key: string]: unknown };\nexport type Merge<Props, HTMLProps> = Props & Omit<HTMLProps, keyof Props>;\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\ndeclare const Root: Root;\n\nexport { Root };\n\nabstract class RootComponent<Props = {}, Context = {}, State = {}> extends PureComponent<\n Props & IRootComponentProps<Props, Context>,\n State\n> {\n get handlers(): Readonly<IRootComponentHandlers> {\n return {};\n }\n\n get asProps() {\n return {} as Readonly<\n Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>\n >;\n }\n\n Root: Root;\n}\n\nexport const Component = RootComponent;\nexport type Component<\n Props = {},\n Context = {},\n State = {},\n Handlers extends IRootComponentHandlers = IRootComponentHandlers,\n> = React.ComponentClass<Props, State> & {\n handlers: Readonly<Handlers>;\n\n asProps: Readonly<Merge<Props & IRootComponentProps<Props, Context>, AllHTMLAttributes<any>>>;\n\n Root: Root;\n};\n"],"mappings":";;;;;;AAAA,SAGEA,aAAa,QAGR,OAAO;AAAC,IAwEAC,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;IAAA,OAAAA,KAAA;EAAA;EAAAa,YAAA,CAAAlB,aAAA;IAAAmB,GAAA;IAAAC,GAAA,EAI1B,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,EAZwED,aAAa;AAiBxF,OAAO,IAAMsB,SAAS,GAAGrB,aAAa"}
|
|
@@ -3,46 +3,38 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
5
|
var _excluded = ["handlers", "getters"],
|
|
6
|
-
|
|
6
|
+
_excluded2 = ["handlers"];
|
|
7
7
|
import { useContext } from 'react';
|
|
8
8
|
import { CONTEXT_COMPONENT } from '../index';
|
|
9
9
|
export var CHILDREN_COMPONENT = Symbol('CHILDREN_COMPONENT');
|
|
10
10
|
var CHILDREN_SELF = Symbol('CHILDREN_SELF');
|
|
11
11
|
var GETTER_REG = /^get[\w]+Props$/;
|
|
12
|
-
|
|
13
12
|
function splitPropsAndGetters(props) {
|
|
14
13
|
return Object.entries(props).reduce(function (acc, _ref) {
|
|
15
14
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
key = _ref2[0],
|
|
16
|
+
value = _ref2[1];
|
|
19
17
|
if (GETTER_REG.exec(key) === null) {
|
|
20
18
|
acc.props[key] = value;
|
|
21
19
|
} else {
|
|
22
20
|
acc.getters[key] = value;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
return acc;
|
|
26
23
|
}, {
|
|
27
24
|
props: {},
|
|
28
25
|
getters: {}
|
|
29
26
|
});
|
|
30
27
|
}
|
|
31
|
-
|
|
32
28
|
function getterToArray(getter) {
|
|
33
29
|
if (!Array.isArray(getter)) {
|
|
34
30
|
return typeof getter === 'function' ? [getter] : [];
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
return getter;
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
function mergeObjects() {
|
|
41
35
|
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
42
36
|
var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
43
|
-
|
|
44
37
|
var core = _objectSpread(_objectSpread({}, a), b);
|
|
45
|
-
|
|
46
38
|
return Object.keys(core).reduce(function (acc, key) {
|
|
47
39
|
a[key] = getterToArray(a[key]);
|
|
48
40
|
b[key] = getterToArray(b[key]);
|
|
@@ -50,7 +42,6 @@ function mergeObjects() {
|
|
|
50
42
|
return acc;
|
|
51
43
|
}, {});
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
function assignGettersChain(getters) {
|
|
55
46
|
return function () {
|
|
56
47
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -59,37 +50,31 @@ function assignGettersChain(getters) {
|
|
|
59
50
|
}, props);
|
|
60
51
|
};
|
|
61
52
|
}
|
|
62
|
-
|
|
63
53
|
function createChildren(Context, contexts) {
|
|
64
54
|
var Children = function Children() {
|
|
65
55
|
var children = Children.origin;
|
|
66
|
-
|
|
67
56
|
if (typeof children === 'function') {
|
|
68
57
|
var _reduce = [].concat(_toConsumableArray(contexts), [Context]).reduce(function (acc, ctx) {
|
|
69
|
-
|
|
58
|
+
var _useContext = useContext(ctx),
|
|
70
59
|
handlers = _useContext.handlers,
|
|
71
60
|
propsAndGetters = _objectWithoutProperties(_useContext, _excluded2);
|
|
72
|
-
|
|
73
|
-
var _splitPropsAndGetters = splitPropsAndGetters(propsAndGetters),
|
|
61
|
+
var _splitPropsAndGetters = splitPropsAndGetters(propsAndGetters),
|
|
74
62
|
props = _splitPropsAndGetters.props,
|
|
75
63
|
getters = _splitPropsAndGetters.getters;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, props)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
props = _objectWithoutProperties(_reduce, _excluded);
|
|
87
|
-
|
|
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);
|
|
88
74
|
var mergedGetters = Object.entries(getters).reduce(function (acc, _ref3) {
|
|
89
75
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
key = _ref4[0],
|
|
77
|
+
value = _ref4[1];
|
|
93
78
|
acc[key] = assignGettersChain(value);
|
|
94
79
|
return acc;
|
|
95
80
|
}, {});
|
|
@@ -97,16 +82,13 @@ function createChildren(Context, contexts) {
|
|
|
97
82
|
} else if (children === undefined) {
|
|
98
83
|
return null;
|
|
99
84
|
}
|
|
100
|
-
|
|
101
85
|
return children;
|
|
102
86
|
};
|
|
103
|
-
|
|
104
87
|
Children.origin = null;
|
|
105
88
|
Children.props = {};
|
|
106
89
|
Children[CHILDREN_COMPONENT] = true;
|
|
107
90
|
return Children;
|
|
108
91
|
}
|
|
109
|
-
|
|
110
92
|
function Enhancement(Context, parent) {
|
|
111
93
|
return {
|
|
112
94
|
init: function init() {
|
|
@@ -126,6 +108,5 @@ function Enhancement(Context, parent) {
|
|
|
126
108
|
}
|
|
127
109
|
};
|
|
128
110
|
}
|
|
129
|
-
|
|
130
111
|
export default Enhancement;
|
|
131
112
|
//# sourceMappingURL=Children.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Children.js","names":["useContext","CONTEXT_COMPONENT","CHILDREN_COMPONENT","Symbol","CHILDREN_SELF","GETTER_REG","splitPropsAndGetters","props","Object","entries","reduce","acc","key","value","exec","getters","getterToArray","getter","Array","isArray","mergeObjects","a","b","core","keys","assignGettersChain","createChildren","Context","contexts","Children","children","origin","ctx","handlers","propsAndGetters","assign","mergedGetters","
|
|
1
|
+
{"version":3,"file":"Children.js","names":["useContext","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","_useContext","handlers","propsAndGetters","_objectWithoutProperties","_excluded2","_splitPropsAndGetters","assign","_reduce$handlers","_reduce$getters","_excluded","mergedGetters","_ref3","_ref4","Enhancement","parent","init","map","component","filter","Boolean","asProps"],"sources":["../../../src/enhancement/Children.tsx"],"sourcesContent":["import { useContext } 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) {\n return Object.entries(props).reduce(\n (acc, [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) {\n if (!Array.isArray(getter)) {\n return typeof getter === 'function' ? [getter] : [];\n }\n return getter;\n}\n\nfunction mergeObjects(a = {}, b = {}) {\n const core = { ...a, ...b };\n return Object.keys(core).reduce((acc, 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, contexts) {\n const Children = 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 } = useContext(ctx);\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, [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(Context, parent) {\n return {\n init: function () {\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 (props) {\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,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,iBAAiB,QAAQ,UAAU;AAE5C,OAAO,IAAMC,kBAAkB,GAAGC,MAAM,CAAC,oBAAoB,CAAC;AAC9D,IAAMC,aAAa,GAAGD,MAAM,CAAC,eAAe,CAAC;AAE7C,IAAME,UAAU,GAAG,iBAAiB;AAEpC,SAASC,oBAAoBA,CAACC,KAAK,EAAE;EACnC,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,MAAM,CACjC,UAACC,GAAG,EAAAC,IAAA,EAAmB;IAAA,IAAAC,KAAA,GAAAC,cAAA,CAAAF,IAAA;MAAhBG,GAAG,GAAAF,KAAA;MAAEG,KAAK,GAAAH,KAAA;IACf,IAAIR,UAAU,CAACY,IAAI,CAACF,GAAG,CAAC,KAAK,IAAI,EAAE;MACjCJ,GAAG,CAACJ,KAAK,CAACQ,GAAG,CAAC,GAAGC,KAAK;IACxB,CAAC,MAAM;MACLL,GAAG,CAACO,OAAO,CAACH,GAAG,CAAC,GAAGC,KAAK;IAC1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