@semcore/core 16.0.0-prerelease.6 → 16.0.0-prerelease.9
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/lib/LastInteractionType.mjs +16 -14
- package/lib/core-types/Component.mjs +22 -25
- package/lib/core-types/symbols.mjs +20 -10
- package/lib/coreFactory.mjs +154 -173
- package/lib/enhancement/Children.mjs +30 -45
- package/lib/enhancement/Root.mjs +22 -32
- package/lib/enhancement/bindHandler.mjs +10 -9
- package/lib/enhancement/dataName.mjs +4 -3
- package/lib/enhancement/enhance.mjs +4 -3
- package/lib/enhancement/functionDefaultProps.mjs +5 -5
- package/lib/enhancement/hoistProps.mjs +18 -28
- package/lib/enhancement/i18n.mjs +6 -6
- package/lib/enhancement/inheritedName.mjs +3 -2
- package/lib/enhancement/staticChildren.mjs +32 -35
- package/lib/enhancement/style.mjs +13 -14
- package/lib/enhancement/uncontrolledProps.mjs +21 -37
- package/lib/esm/LastInteractionType.mjs +51 -0
- package/lib/esm/core-types/Component.mjs +51 -0
- package/lib/esm/core-types/symbols.mjs +20 -0
- package/lib/esm/coreFactory.mjs +324 -0
- package/lib/esm/enhancement/Children.mjs +96 -0
- package/lib/esm/enhancement/Root.mjs +60 -0
- package/lib/esm/enhancement/bindHandler.mjs +48 -0
- package/lib/esm/enhancement/dataName.mjs +13 -0
- package/lib/esm/enhancement/enhance.mjs +16 -0
- package/lib/esm/enhancement/functionDefaultProps.mjs +29 -0
- package/lib/esm/enhancement/hoistProps.mjs +78 -0
- package/lib/esm/enhancement/i18n.mjs +20 -0
- package/lib/esm/enhancement/inheritedName.mjs +16 -0
- package/lib/esm/enhancement/staticChildren.mjs +120 -0
- package/lib/esm/enhancement/style.mjs +50 -0
- package/lib/esm/enhancement/uncontrolledProps.mjs +107 -0
- package/lib/esm/index.mjs +23 -0
- package/lib/esm/register.mjs +31 -0
- package/lib/esm/styled/reshadow-core.mjs +18 -0
- package/lib/esm/styled/sstyled.mjs +121 -0
- package/lib/esm/utils/assignProps.mjs +76 -0
- package/lib/esm/utils/canUseDOM.mjs +6 -0
- package/lib/esm/utils/capitalizeFirstLetter.mjs +6 -0
- package/lib/esm/utils/enhances/WithI18n.mjs +54 -0
- package/lib/esm/utils/logger.mjs +35 -0
- package/lib/esm/utils/pick.mjs +15 -0
- package/lib/esm/utils/ref.mjs +43 -0
- package/lib/esm/utils/use/useEnhancedEffect.mjs +6 -0
- package/lib/index.mjs +22 -8
- package/lib/register.mjs +10 -8
- package/lib/styled/reshadow-core.mjs +8 -233
- package/lib/styled/sstyled.mjs +38 -59
- package/lib/theme/light.json +1 -1
- package/lib/theme/themes/auto.css +1 -1
- package/lib/theme/themes/default.cjs +1 -1
- package/lib/theme/themes/default.cjs.map +1 -1
- package/lib/theme/themes/default.css +1 -1
- package/lib/theme/themes/default.mjs +1 -1
- package/lib/theme/themes/default.mjs.map +1 -1
- package/lib/theme/themes/light.cjs +1 -1
- package/lib/theme/themes/light.cjs.map +1 -1
- package/lib/theme/themes/light.css +1 -1
- package/lib/theme/themes/light.mjs +1 -1
- package/lib/theme/themes/light.mjs.map +1 -1
- package/lib/utils/assignProps.mjs +25 -33
- package/lib/utils/canUseDOM.mjs +5 -3
- package/lib/utils/capitalizeFirstLetter.mjs +4 -2
- package/lib/utils/enhances/WithI18n.mjs +22 -51
- package/lib/utils/logger.mjs +16 -13
- package/lib/utils/pick.mjs +4 -2
- package/lib/utils/ref.mjs +19 -59
- package/lib/utils/use/useEnhancedEffect.mjs +4 -3
- package/package.json +2 -2
- package/vite.config.ts +8 -0
package/lib/coreFactory.mjs
CHANGED
|
@@ -10,41 +10,38 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
11
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
12
12
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
_excluded3 = ["ref"];
|
|
16
|
-
import React from 'react';
|
|
17
|
-
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
13
|
+
import React from "react";
|
|
14
|
+
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
18
15
|
import { useForkRef } from "./utils/ref.mjs";
|
|
19
16
|
import useEnhancedEffect from "./utils/use/useEnhancedEffect.mjs";
|
|
20
|
-
import
|
|
17
|
+
import assignProps$1 from "./utils/assignProps.mjs";
|
|
21
18
|
import { Component } from "./core-types/Component.mjs";
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
19
|
+
import Enhancement$1 from "./enhancement/Children.mjs";
|
|
20
|
+
import Enhancement$2 from "./enhancement/Root.mjs";
|
|
21
|
+
import Enhancement$3 from "./enhancement/uncontrolledProps.mjs";
|
|
22
|
+
import Enhancement$5 from "./enhancement/functionDefaultProps.mjs";
|
|
23
|
+
import Enhancement$4, { ROOT_COMPONENT, getterMethodNameByDisplayName, STATIC_COMPONENT } from "./enhancement/staticChildren.mjs";
|
|
24
|
+
import Enhancement$6 from "./enhancement/inheritedName.mjs";
|
|
25
|
+
import Enhancement$a from "./enhancement/hoistProps.mjs";
|
|
26
|
+
import Enhancement$7 from "./enhancement/dataName.mjs";
|
|
27
|
+
import Enhancement$8 from "./enhancement/enhance.mjs";
|
|
28
|
+
import Enhancement$9 from "./enhancement/style.mjs";
|
|
29
|
+
import Enhancement from "./enhancement/bindHandler.mjs";
|
|
33
30
|
import i18nAppLocaleEnhance from "./enhancement/i18n.mjs";
|
|
34
|
-
import {
|
|
31
|
+
import { PARENT_COMPONENTS, CORE_COMPONENT, CONTEXT_COMPONENT, CREATE_COMPONENT, CORE_AS_PROPS, CORE_INSTANCE, CORE_INIT } from "./core-types/symbols.mjs";
|
|
32
|
+
var _excluded = ["forwardRef"], _excluded2 = ["forwardRef", "__WRAPPER_PROPS_BIND__"], _excluded3 = ["ref"];
|
|
35
33
|
function isEmptyObject(obj) {
|
|
36
|
-
return Object.getOwnPropertyNames(obj).length === 0 && Object.getOwnPropertySymbols &&
|
|
37
|
-
// For IE 11
|
|
34
|
+
return Object.getOwnPropertyNames(obj).length === 0 && Object.getOwnPropertySymbols && // For IE 11
|
|
38
35
|
Object.getOwnPropertySymbols(obj).length === 0 && Object.getPrototypeOf(obj) === Object.prototype;
|
|
39
36
|
}
|
|
40
|
-
function createGetField(enhancements,
|
|
37
|
+
function createGetField(enhancements, Component2, isFunction) {
|
|
41
38
|
return function getField(key) {
|
|
42
|
-
return enhancements.filter(function
|
|
39
|
+
return enhancements.filter(function(enhancement) {
|
|
43
40
|
if (!enhancement.condition) {
|
|
44
41
|
return true;
|
|
45
42
|
}
|
|
46
|
-
return enhancement.condition(
|
|
47
|
-
}).reduce(function
|
|
43
|
+
return enhancement.condition(Component2, isFunction);
|
|
44
|
+
}).reduce(function(acc, item) {
|
|
48
45
|
if (item[key]) {
|
|
49
46
|
acc.push(item[key]);
|
|
50
47
|
}
|
|
@@ -52,40 +49,32 @@ function createGetField(enhancements, Component, isFunction) {
|
|
|
52
49
|
}, []);
|
|
53
50
|
};
|
|
54
51
|
}
|
|
55
|
-
function createForwardWrapper(
|
|
56
|
-
var RootComponent =
|
|
57
|
-
var getterMethodName = getterMethodNameByDisplayName(
|
|
58
|
-
var getterMethod = RootComponent !== null && RootComponent !== void 0 && RootComponent.prototype ? RootComponent.prototype[getterMethodName] :
|
|
52
|
+
function createForwardWrapper(Component2, wrapperProps, statics, isFunction) {
|
|
53
|
+
var RootComponent = Component2[ROOT_COMPONENT];
|
|
54
|
+
var getterMethodName = getterMethodNameByDisplayName(Component2 === null || Component2 === void 0 ? void 0 : Component2.displayName);
|
|
55
|
+
var getterMethod = RootComponent !== null && RootComponent !== void 0 && RootComponent.prototype ? RootComponent.prototype[getterMethodName] : void 0;
|
|
59
56
|
var useGetterIndex = (getterMethod === null || getterMethod === void 0 ? void 0 : getterMethod.length) >= 2;
|
|
60
57
|
function WrapperForwardRefWithBind(_ref, ref) {
|
|
61
|
-
var _ref$forwardRef = _ref.forwardRef,
|
|
62
|
-
|
|
63
|
-
other = _objectWithoutProperties(_ref, _excluded);
|
|
64
|
-
return /*#__PURE__*/React.createElement(BindingWrapper, _extends({}, other, {
|
|
58
|
+
var _ref$forwardRef = _ref.forwardRef, forwardRef = _ref$forwardRef === void 0 ? null : _ref$forwardRef, other = _objectWithoutProperties(_ref, _excluded);
|
|
59
|
+
return /* @__PURE__ */ React.createElement(BindingWrapper, _extends({}, other, {
|
|
65
60
|
forwardRef: useForkRef(ref, forwardRef)
|
|
66
61
|
}));
|
|
67
62
|
}
|
|
68
63
|
function WrapperForwardRef(_ref2, ref) {
|
|
69
|
-
var _ref2$forwardRef = _ref2.forwardRef,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return enhancement(acc, WrapperComponent, isFunction);
|
|
75
|
-
}, other),
|
|
76
|
-
_reduce$ref = _reduce.ref,
|
|
77
|
-
enhancementRef = _reduce$ref === void 0 ? null : _reduce$ref,
|
|
78
|
-
props = _objectWithoutProperties(_reduce, _excluded3);
|
|
79
|
-
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
64
|
+
var _ref2$forwardRef = _ref2.forwardRef, forwardRef = _ref2$forwardRef === void 0 ? null : _ref2$forwardRef, __WRAPPER_PROPS_BIND__ = _ref2.__WRAPPER_PROPS_BIND__, other = _objectWithoutProperties(_ref2, _excluded2);
|
|
65
|
+
var _reduce = (__WRAPPER_PROPS_BIND__ || wrapperProps).reduce(function(acc, enhancement) {
|
|
66
|
+
return enhancement(acc, WrapperComponent, isFunction);
|
|
67
|
+
}, other), _reduce$ref = _reduce.ref, enhancementRef = _reduce$ref === void 0 ? null : _reduce$ref, props = _objectWithoutProperties(_reduce, _excluded3);
|
|
68
|
+
return /* @__PURE__ */ React.createElement(Component2, _extends({}, props, {
|
|
80
69
|
forwardRef: useForkRef(enhancementRef, ref, forwardRef)
|
|
81
70
|
}));
|
|
82
71
|
}
|
|
83
|
-
var BindingWrapper =
|
|
84
|
-
_inherits(
|
|
85
|
-
var _super = _createSuper(
|
|
86
|
-
function
|
|
72
|
+
var BindingWrapper = /* @__PURE__ */ function(_React$Component) {
|
|
73
|
+
_inherits(BindingWrapper2, _React$Component);
|
|
74
|
+
var _super = _createSuper(BindingWrapper2);
|
|
75
|
+
function BindingWrapper2() {
|
|
87
76
|
var _this;
|
|
88
|
-
_classCallCheck(this,
|
|
77
|
+
_classCallCheck(this, BindingWrapper2);
|
|
89
78
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
90
79
|
args[_key] = arguments[_key];
|
|
91
80
|
}
|
|
@@ -93,66 +82,61 @@ function createForwardWrapper(Component, wrapperProps, statics, isFunction) {
|
|
|
93
82
|
_defineProperty(_assertThisInitialized(_this), "index", -1);
|
|
94
83
|
return _this;
|
|
95
84
|
}
|
|
96
|
-
_createClass(
|
|
85
|
+
_createClass(BindingWrapper2, [{
|
|
97
86
|
key: "render",
|
|
98
87
|
value: function render() {
|
|
99
88
|
var _this2 = this;
|
|
100
|
-
return
|
|
101
|
-
__WRAPPER_PROPS_BIND__: wrapperProps.map(function
|
|
89
|
+
return /* @__PURE__ */ React.createElement(WrapperForwardRef, _extends({}, this.props, {
|
|
90
|
+
__WRAPPER_PROPS_BIND__: wrapperProps.map(function(fn) {
|
|
102
91
|
return fn.bind(_this2);
|
|
103
92
|
})
|
|
104
93
|
}));
|
|
105
94
|
}
|
|
106
95
|
}]);
|
|
107
|
-
return
|
|
96
|
+
return BindingWrapper2;
|
|
108
97
|
}(React.Component);
|
|
109
|
-
var WrapperComponent =
|
|
110
|
-
hoistNonReactStatics(WrapperComponent,
|
|
111
|
-
WrapperComponent.displayName =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
statics.forEach(function (enhancement) {
|
|
116
|
-
return Object.assign(WrapperComponent, enhancement(WrapperComponent, Component, isFunction));
|
|
98
|
+
var WrapperComponent = /* @__PURE__ */ React.forwardRef(useGetterIndex ? WrapperForwardRefWithBind : WrapperForwardRef);
|
|
99
|
+
hoistNonReactStatics(WrapperComponent, Component2);
|
|
100
|
+
WrapperComponent.displayName = Component2.displayName;
|
|
101
|
+
WrapperComponent.defaultProps = Component2.defaultProps;
|
|
102
|
+
statics.forEach(function(enhancement) {
|
|
103
|
+
return Object.assign(WrapperComponent, enhancement(WrapperComponent, Component2, isFunction));
|
|
117
104
|
});
|
|
118
105
|
return WrapperComponent;
|
|
119
106
|
}
|
|
120
107
|
function wrapClass(OriginComponent, enhancements, Context) {
|
|
121
108
|
var getField = createGetField(enhancements, OriginComponent, false);
|
|
122
|
-
var inits = getField(
|
|
123
|
-
var props = getField(
|
|
124
|
-
var renders = getField(
|
|
125
|
-
var statics = getField(
|
|
126
|
-
var wrapperProps = getField(
|
|
127
|
-
var contexts = getField(
|
|
128
|
-
var
|
|
129
|
-
_inherits(
|
|
130
|
-
var _super2 = _createSuper(
|
|
131
|
-
function
|
|
109
|
+
var inits = getField("init");
|
|
110
|
+
var props = getField("asProps");
|
|
111
|
+
var renders = getField("render");
|
|
112
|
+
var statics = getField("static");
|
|
113
|
+
var wrapperProps = getField("wrapperProps");
|
|
114
|
+
var contexts = getField("context");
|
|
115
|
+
var Component2 = /* @__PURE__ */ function(_OriginComponent2) {
|
|
116
|
+
_inherits(Component3, _OriginComponent2);
|
|
117
|
+
var _super2 = _createSuper(Component3);
|
|
118
|
+
function Component3(props2, context) {
|
|
132
119
|
var _this3;
|
|
133
|
-
_classCallCheck(this,
|
|
134
|
-
_this3 = _super2.call(this,
|
|
135
|
-
// INITS
|
|
120
|
+
_classCallCheck(this, Component3);
|
|
121
|
+
_this3 = _super2.call(this, props2, context);
|
|
136
122
|
_defineProperty(_assertThisInitialized(_this3), CORE_AS_PROPS, null);
|
|
137
123
|
_defineProperty(_assertThisInitialized(_this3), CORE_INSTANCE, WrapperComponent);
|
|
138
124
|
_defineProperty(_assertThisInitialized(_this3), CORE_INIT, false);
|
|
139
|
-
inits.forEach(function
|
|
140
|
-
return enhancement.call(_assertThisInitialized(_this3),
|
|
125
|
+
inits.forEach(function(enhancement) {
|
|
126
|
+
return enhancement.call(_assertThisInitialized(_this3), props2, WrapperComponent, false);
|
|
141
127
|
});
|
|
142
128
|
_this3[CORE_INIT] = true;
|
|
143
129
|
return _this3;
|
|
144
130
|
}
|
|
145
|
-
_createClass(
|
|
131
|
+
_createClass(Component3, [{
|
|
146
132
|
key: "asProps",
|
|
147
133
|
get: function get() {
|
|
148
134
|
var _this4 = this;
|
|
149
|
-
// TODO if not production
|
|
150
135
|
if (!this[CORE_INIT]) {
|
|
151
|
-
throw new Error(
|
|
136
|
+
throw new Error("Can not call asProps in constructor");
|
|
152
137
|
}
|
|
153
138
|
if (!this[CORE_AS_PROPS]) {
|
|
154
|
-
|
|
155
|
-
this[CORE_AS_PROPS] = props.reduce(function (acc, enhancement) {
|
|
139
|
+
this[CORE_AS_PROPS] = props.reduce(function(acc, enhancement) {
|
|
156
140
|
return enhancement.call(_this4, acc, WrapperComponent, false);
|
|
157
141
|
}, this.props);
|
|
158
142
|
}
|
|
@@ -162,9 +146,8 @@ function wrapClass(OriginComponent, enhancements, Context) {
|
|
|
162
146
|
key: "setContext",
|
|
163
147
|
value: function setContext() {
|
|
164
148
|
var _this5 = this;
|
|
165
|
-
var contextProps = _get(_getPrototypeOf(
|
|
166
|
-
|
|
167
|
-
return contexts.reduce(function (acc, enhancement) {
|
|
149
|
+
var contextProps = _get(_getPrototypeOf(Component3.prototype), "setContext", this) ? _get(_getPrototypeOf(Component3.prototype), "setContext", this).call(this) : {};
|
|
150
|
+
return contexts.reduce(function(acc, enhancement) {
|
|
168
151
|
return enhancement.call(_this5, acc, WrapperComponent, false);
|
|
169
152
|
}, contextProps);
|
|
170
153
|
}
|
|
@@ -173,119 +156,107 @@ function wrapClass(OriginComponent, enhancements, Context) {
|
|
|
173
156
|
value: function render() {
|
|
174
157
|
var _this6 = this;
|
|
175
158
|
this[CORE_AS_PROPS] = null;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
throw new Error('Component `render` method is not defined');
|
|
159
|
+
if (!_get(_getPrototypeOf(Component3.prototype), "render", this)) {
|
|
160
|
+
throw new Error("Component `render` method is not defined");
|
|
179
161
|
}
|
|
180
162
|
var asProps = this.asProps;
|
|
181
163
|
var ctx = this.setContext();
|
|
182
|
-
|
|
183
|
-
var render = renders.reduce(function (acc, enhancement) {
|
|
164
|
+
var render2 = renders.reduce(function(acc, enhancement) {
|
|
184
165
|
return enhancement.call(_this6, acc, asProps, WrapperComponent, false);
|
|
185
|
-
}, _get(_getPrototypeOf(
|
|
166
|
+
}, _get(_getPrototypeOf(Component3.prototype), "render", this).call(this));
|
|
186
167
|
if (!WrapperComponent[STATIC_COMPONENT] && !isEmptyObject(ctx)) {
|
|
187
|
-
return
|
|
168
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, {
|
|
188
169
|
value: _objectSpread(_objectSpread({}, asProps), ctx)
|
|
189
|
-
},
|
|
170
|
+
}, render2);
|
|
190
171
|
} else {
|
|
191
|
-
return
|
|
172
|
+
return render2;
|
|
192
173
|
}
|
|
193
174
|
}
|
|
194
175
|
}]);
|
|
195
|
-
return
|
|
176
|
+
return Component3;
|
|
196
177
|
}(OriginComponent);
|
|
197
|
-
var WrapperComponent = createForwardWrapper(
|
|
178
|
+
var WrapperComponent = createForwardWrapper(Component2, wrapperProps, statics, false);
|
|
198
179
|
return WrapperComponent;
|
|
199
180
|
}
|
|
200
181
|
function wrapFunction(OriginComponent, enhancements, Context) {
|
|
201
182
|
var getField = createGetField(enhancements, OriginComponent, true);
|
|
202
|
-
var inits = getField(
|
|
203
|
-
var props = getField(
|
|
204
|
-
var renders = getField(
|
|
205
|
-
var statics = getField(
|
|
206
|
-
var wrapperProps = getField(
|
|
207
|
-
var contexts = getField(
|
|
208
|
-
var
|
|
183
|
+
var inits = getField("init");
|
|
184
|
+
var props = getField("asProps");
|
|
185
|
+
var renders = getField("render");
|
|
186
|
+
var statics = getField("static");
|
|
187
|
+
var wrapperProps = getField("wrapperProps");
|
|
188
|
+
var contexts = getField("context");
|
|
189
|
+
var Component2 = /* @__PURE__ */ React.memo(function FunctionMemoComponent(other) {
|
|
209
190
|
var selfRef = React.useRef({});
|
|
210
191
|
var firstRender = React.useRef(true);
|
|
211
|
-
useEnhancedEffect(function
|
|
192
|
+
useEnhancedEffect(function() {
|
|
212
193
|
firstRender.current = false;
|
|
213
194
|
}, []);
|
|
214
195
|
if (firstRender.current) {
|
|
215
|
-
|
|
216
|
-
inits.forEach(function (enhancement) {
|
|
196
|
+
inits.forEach(function(enhancement) {
|
|
217
197
|
return enhancement.call(selfRef.current, other, WrapperComponent, true);
|
|
218
198
|
});
|
|
219
199
|
}
|
|
220
|
-
|
|
221
|
-
var asProps = props.reduce(function (acc, enhancement) {
|
|
200
|
+
var asProps = props.reduce(function(acc, enhancement) {
|
|
222
201
|
return enhancement.call(selfRef.current, acc, WrapperComponent, true);
|
|
223
202
|
}, other);
|
|
224
|
-
|
|
225
|
-
var ctx = contexts.reduce(function (acc, enhancement) {
|
|
203
|
+
var ctx = contexts.reduce(function(acc, enhancement) {
|
|
226
204
|
return enhancement.call(selfRef.current, acc, WrapperComponent, true);
|
|
227
205
|
}, {});
|
|
228
|
-
|
|
229
|
-
// RENDER
|
|
230
|
-
var render = renders.reduce(function (acc, enhancement) {
|
|
206
|
+
var render = renders.reduce(function(acc, enhancement) {
|
|
231
207
|
return enhancement.call(selfRef.current, acc, asProps, WrapperComponent, true);
|
|
232
|
-
},
|
|
208
|
+
}, /* @__PURE__ */ React.createElement(OriginComponent, asProps));
|
|
233
209
|
if (!WrapperComponent[STATIC_COMPONENT] && !isEmptyObject(ctx)) {
|
|
234
|
-
return
|
|
210
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, {
|
|
235
211
|
value: _objectSpread(_objectSpread({}, asProps), ctx)
|
|
236
212
|
}, render);
|
|
237
213
|
} else {
|
|
238
214
|
return render;
|
|
239
215
|
}
|
|
240
216
|
});
|
|
241
|
-
Object.assign(
|
|
242
|
-
var WrapperComponent = createForwardWrapper(
|
|
217
|
+
Object.assign(Component2, OriginComponent);
|
|
218
|
+
var WrapperComponent = createForwardWrapper(Component2, wrapperProps, statics, true);
|
|
243
219
|
return WrapperComponent;
|
|
244
220
|
}
|
|
245
221
|
function wrapCore(OriginComponent, enhancements, Context) {
|
|
246
|
-
var
|
|
222
|
+
var Component2 = function Component3(_ref3) {
|
|
247
223
|
var Root = _ref3.Root;
|
|
248
224
|
var defaultProps = OriginComponent.defaultProps || {};
|
|
249
|
-
return
|
|
225
|
+
return /* @__PURE__ */ React.createElement(Root, _extends({}, defaultProps, {
|
|
250
226
|
render: OriginComponent
|
|
251
227
|
}));
|
|
252
228
|
};
|
|
253
|
-
hoistNonReactStatics(
|
|
254
|
-
|
|
255
|
-
return wrapFunction(
|
|
229
|
+
hoistNonReactStatics(Component2, OriginComponent);
|
|
230
|
+
Component2.displayName = OriginComponent.displayName;
|
|
231
|
+
return wrapFunction(Component2, enhancements, Context);
|
|
256
232
|
}
|
|
257
233
|
function createComposeComponent(OriginComponent, Context, enhancements) {
|
|
258
234
|
if (React.PureComponent.isPrototypeOf(OriginComponent) || React.Component.isPrototypeOf(OriginComponent)) {
|
|
259
235
|
if (OriginComponent.prototype instanceof Component) {
|
|
260
236
|
return wrapClass(OriginComponent, enhancements, Context);
|
|
261
237
|
} else {
|
|
262
|
-
throw new Error(
|
|
238
|
+
throw new Error("Must inherit from our component");
|
|
263
239
|
}
|
|
264
|
-
} else if (typeof OriginComponent ===
|
|
240
|
+
} else if (typeof OriginComponent === "function") {
|
|
265
241
|
return wrapFunction(OriginComponent, enhancements, Context);
|
|
266
242
|
} else if (OriginComponent[CORE_COMPONENT]) {
|
|
267
243
|
return wrapCore(OriginComponent, enhancements, Context);
|
|
268
244
|
} else {
|
|
269
|
-
throw new Error(
|
|
245
|
+
throw new Error("Must be a React component");
|
|
270
246
|
}
|
|
271
247
|
}
|
|
272
|
-
|
|
273
|
-
return
|
|
248
|
+
function assignProps(p1, p2) {
|
|
249
|
+
return assignProps$1(p2, p1);
|
|
274
250
|
}
|
|
275
251
|
function createComponent(OriginComponent) {
|
|
276
|
-
var childComponents = arguments.length > 1 && arguments[1] !==
|
|
277
|
-
var options = arguments.length > 2 && arguments[2] !==
|
|
278
|
-
var _options$context = options.context,
|
|
279
|
-
context = _options$context === void 0 ? /*#__PURE__*/React.createContext({}) : _options$context,
|
|
280
|
-
_options$parent = options.parent,
|
|
281
|
-
parent = _options$parent === void 0 ? [] : _options$parent,
|
|
282
|
-
_options$enhancements = options.enhancements,
|
|
283
|
-
enhancements = _options$enhancements === void 0 ? [] : _options$enhancements;
|
|
252
|
+
var childComponents = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
253
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
254
|
+
var _options$context = options.context, context = _options$context === void 0 ? /* @__PURE__ */ React.createContext({}) : _options$context, _options$parent = options.parent, parent = _options$parent === void 0 ? [] : _options$parent, _options$enhancements = options.enhancements, enhancements = _options$enhancements === void 0 ? [] : _options$enhancements;
|
|
284
255
|
var parents = Array.isArray(parent) ? parent : [parent];
|
|
285
256
|
if (parents.length) {
|
|
286
|
-
var wholeFamily = parents.reduce(function
|
|
287
|
-
if (
|
|
288
|
-
acc = [].concat(_toConsumableArray(
|
|
257
|
+
var wholeFamily = parents.reduce(function(acc, parent2) {
|
|
258
|
+
if (parent2[PARENT_COMPONENTS]) {
|
|
259
|
+
acc = [].concat(_toConsumableArray(parent2[PARENT_COMPONENTS]), _toConsumableArray(acc));
|
|
289
260
|
}
|
|
290
261
|
return acc;
|
|
291
262
|
}, parents);
|
|
@@ -295,49 +266,59 @@ function createComponent(OriginComponent) {
|
|
|
295
266
|
if (OriginComponent[CORE_COMPONENT]) {
|
|
296
267
|
parents.push(OriginComponent);
|
|
297
268
|
}
|
|
298
|
-
var
|
|
269
|
+
var Component2 = createComposeComponent(OriginComponent, context, [].concat(_toConsumableArray(enhancements.map(function(f) {
|
|
299
270
|
return f(context, parents, createComponent, childComponents);
|
|
300
|
-
})), [
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
context
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
271
|
+
})), [
|
|
272
|
+
i18nAppLocaleEnhance(),
|
|
273
|
+
Enhancement(),
|
|
274
|
+
Enhancement$1(context, parents),
|
|
275
|
+
// root must be under the children
|
|
276
|
+
Enhancement$2(),
|
|
277
|
+
Enhancement$3(),
|
|
278
|
+
Enhancement$4(childComponents, createComponent, {
|
|
279
|
+
context,
|
|
280
|
+
parent,
|
|
281
|
+
enhancements
|
|
282
|
+
}),
|
|
283
|
+
// functionDefaultProps must be under the staticChild
|
|
284
|
+
Enhancement$5(),
|
|
285
|
+
// inheritedName must be under the staticChild
|
|
286
|
+
Enhancement$6(),
|
|
287
|
+
// dataName must be under the staticChild
|
|
288
|
+
Enhancement$7(),
|
|
289
|
+
// enhanceEnhancement must be under the functionDefaultPropsEnhancement
|
|
290
|
+
Enhancement$8(),
|
|
291
|
+
Enhancement$9(childComponents, context),
|
|
292
|
+
// must be the last one so any properties can be raised
|
|
293
|
+
Enhancement$a(childComponents, context)
|
|
294
|
+
]));
|
|
295
|
+
Component2[CONTEXT_COMPONENT] = context;
|
|
296
|
+
Component2._______childrenComponents = childComponents;
|
|
297
|
+
Component2[CREATE_COMPONENT] = function() {
|
|
298
|
+
var _OriginComponent = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : OriginComponent;
|
|
299
|
+
var _childComponents = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : childComponents;
|
|
300
|
+
var _options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : options;
|
|
323
301
|
return createComponent(_OriginComponent, _childComponents, _options);
|
|
324
302
|
};
|
|
325
|
-
|
|
326
|
-
return
|
|
303
|
+
Component2[CORE_COMPONENT] = true;
|
|
304
|
+
return Component2;
|
|
327
305
|
}
|
|
328
306
|
function createBaseComponent(OriginComponent) {
|
|
329
|
-
var
|
|
330
|
-
if (!React.PureComponent.isPrototypeOf(OriginComponent) && !React.Component.isPrototypeOf(OriginComponent) && typeof OriginComponent ===
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
307
|
+
var Component2 = null;
|
|
308
|
+
if (!React.PureComponent.isPrototypeOf(OriginComponent) && !React.Component.isPrototypeOf(OriginComponent) && typeof OriginComponent === "function") {
|
|
309
|
+
Component2 = /* @__PURE__ */ React.forwardRef(OriginComponent);
|
|
310
|
+
Component2.displayName = OriginComponent.displayName;
|
|
311
|
+
Component2.defaultProps = _objectSpread({
|
|
312
|
+
"data-ui-name": OriginComponent.displayName
|
|
335
313
|
}, OriginComponent.defaultProps);
|
|
336
|
-
|
|
314
|
+
Component2[CORE_COMPONENT] = true;
|
|
337
315
|
} else {
|
|
338
|
-
throw new Error(
|
|
316
|
+
throw new Error("createBaseComponent accepts only functional component");
|
|
339
317
|
}
|
|
340
|
-
return
|
|
318
|
+
return Component2;
|
|
341
319
|
}
|
|
342
|
-
export {
|
|
343
|
-
|
|
320
|
+
export {
|
|
321
|
+
assignProps,
|
|
322
|
+
createBaseComponent,
|
|
323
|
+
createComponent
|
|
324
|
+
};
|
|
@@ -2,17 +2,14 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
-
|
|
6
|
-
_excluded2 = ["handlers"];
|
|
7
|
-
import React from 'react';
|
|
5
|
+
import React from "react";
|
|
8
6
|
import { CONTEXT_COMPONENT, CHILDREN_COMPONENT } from "../core-types/symbols.mjs";
|
|
9
|
-
var
|
|
7
|
+
var _excluded = ["handlers", "getters"], _excluded2 = ["handlers"];
|
|
8
|
+
var CHILDREN_SELF = Symbol("CHILDREN_SELF");
|
|
10
9
|
var GETTER_REG = /^get[\w]+Props$/;
|
|
11
10
|
function splitPropsAndGetters(props) {
|
|
12
|
-
return Object.entries(props).reduce(function
|
|
13
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
14
|
-
key = _ref2[0],
|
|
15
|
-
value = _ref2[1];
|
|
11
|
+
return Object.entries(props).reduce(function(acc, _ref) {
|
|
12
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
16
13
|
if (GETTER_REG.exec(key) === null) {
|
|
17
14
|
acc.props[key] = value;
|
|
18
15
|
} else {
|
|
@@ -26,15 +23,15 @@ function splitPropsAndGetters(props) {
|
|
|
26
23
|
}
|
|
27
24
|
function getterToArray(getter) {
|
|
28
25
|
if (!Array.isArray(getter)) {
|
|
29
|
-
return typeof getter ===
|
|
26
|
+
return typeof getter === "function" ? [getter] : [];
|
|
30
27
|
}
|
|
31
28
|
return getter;
|
|
32
29
|
}
|
|
33
30
|
function mergeObjects() {
|
|
34
|
-
var a = arguments.length > 0 && arguments[0] !==
|
|
35
|
-
var b = arguments.length > 1 && arguments[1] !==
|
|
31
|
+
var a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
32
|
+
var b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
36
33
|
var core = _objectSpread(_objectSpread({}, a), b);
|
|
37
|
-
return Object.keys(core).reduce(function
|
|
34
|
+
return Object.keys(core).reduce(function(acc, key) {
|
|
38
35
|
a[key] = getterToArray(a[key]);
|
|
39
36
|
b[key] = getterToArray(b[key]);
|
|
40
37
|
acc[key] = [].concat(_toConsumableArray(a[key]), _toConsumableArray(b[key]));
|
|
@@ -42,43 +39,32 @@ function mergeObjects() {
|
|
|
42
39
|
}, {});
|
|
43
40
|
}
|
|
44
41
|
function assignGettersChain(getters) {
|
|
45
|
-
return function
|
|
46
|
-
var props = arguments.length > 0 && arguments[0] !==
|
|
47
|
-
return getters.reduce(function
|
|
42
|
+
return function() {
|
|
43
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
44
|
+
return getters.reduce(function(acc, getter) {
|
|
48
45
|
return getter(acc);
|
|
49
46
|
}, props);
|
|
50
47
|
};
|
|
51
48
|
}
|
|
52
49
|
function createChildren(Context, contexts) {
|
|
53
|
-
var Children = function
|
|
54
|
-
var children =
|
|
55
|
-
if (typeof children ===
|
|
56
|
-
var _reduce = [].concat(_toConsumableArray(contexts), [Context]).reduce(function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}, props));
|
|
67
|
-
}, Children.props),
|
|
68
|
-
_reduce$handlers = _reduce.handlers,
|
|
69
|
-
handlers = _reduce$handlers === void 0 ? {} : _reduce$handlers,
|
|
70
|
-
_reduce$getters = _reduce.getters,
|
|
71
|
-
getters = _reduce$getters === void 0 ? {} : _reduce$getters,
|
|
72
|
-
props = _objectWithoutProperties(_reduce, _excluded);
|
|
73
|
-
var mergedGetters = Object.entries(getters).reduce(function (acc, _ref4) {
|
|
74
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
75
|
-
key = _ref5[0],
|
|
76
|
-
value = _ref5[1];
|
|
50
|
+
var Children = function Children2() {
|
|
51
|
+
var children = Children2.origin;
|
|
52
|
+
if (typeof children === "function") {
|
|
53
|
+
var _reduce = [].concat(_toConsumableArray(contexts), [Context]).reduce(function(acc, ctx) {
|
|
54
|
+
var _ref3 = React.useContext(ctx), handlers2 = _ref3.handlers, propsAndGetters = _objectWithoutProperties(_ref3, _excluded2);
|
|
55
|
+
var _splitPropsAndGetters = splitPropsAndGetters(propsAndGetters), props2 = _splitPropsAndGetters.props, getters2 = _splitPropsAndGetters.getters;
|
|
56
|
+
return Object.assign({}, acc, _objectSpread({
|
|
57
|
+
handlers: Object.assign({}, acc.handlers, handlers2),
|
|
58
|
+
getters: mergeObjects(acc.getters, getters2)
|
|
59
|
+
}, props2));
|
|
60
|
+
}, Children2.props), _reduce$handlers = _reduce.handlers, handlers = _reduce$handlers === void 0 ? {} : _reduce$handlers, _reduce$getters = _reduce.getters, getters = _reduce$getters === void 0 ? {} : _reduce$getters, props = _objectWithoutProperties(_reduce, _excluded);
|
|
61
|
+
var mergedGetters = Object.entries(getters).reduce(function(acc, _ref4) {
|
|
62
|
+
var _ref5 = _slicedToArray(_ref4, 2), key = _ref5[0], value = _ref5[1];
|
|
77
63
|
acc[key] = assignGettersChain(value);
|
|
78
64
|
return acc;
|
|
79
65
|
}, {});
|
|
80
66
|
return children(_objectSpread(_objectSpread({}, props), mergedGetters), handlers);
|
|
81
|
-
} else if (children ===
|
|
67
|
+
} else if (children === void 0) {
|
|
82
68
|
return null;
|
|
83
69
|
}
|
|
84
70
|
return children;
|
|
@@ -91,14 +77,12 @@ function createChildren(Context, contexts) {
|
|
|
91
77
|
function Enhancement(Context, parent) {
|
|
92
78
|
return {
|
|
93
79
|
init: function init() {
|
|
94
|
-
var contexts = (Array.isArray(parent) ? parent : [parent]).map(function
|
|
80
|
+
var contexts = (Array.isArray(parent) ? parent : [parent]).map(function(component) {
|
|
95
81
|
return component[CONTEXT_COMPONENT];
|
|
96
82
|
}).filter(Boolean);
|
|
97
83
|
this[CHILDREN_SELF] = createChildren(Context, contexts);
|
|
98
84
|
},
|
|
99
85
|
asProps: function asProps(props) {
|
|
100
|
-
// TODO: learn the reason what it was used for (by lsroman)
|
|
101
|
-
// this[CHILDREN_SELF].origin = _Children ? _Children.origin : children;
|
|
102
86
|
this[CHILDREN_SELF].origin = props.children;
|
|
103
87
|
this[CHILDREN_SELF].props = props;
|
|
104
88
|
return _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -107,5 +91,6 @@ function Enhancement(Context, parent) {
|
|
|
107
91
|
}
|
|
108
92
|
};
|
|
109
93
|
}
|
|
110
|
-
export
|
|
111
|
-
|
|
94
|
+
export {
|
|
95
|
+
Enhancement as default
|
|
96
|
+
};
|