@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
|
@@ -4,80 +4,51 @@ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitial
|
|
|
4
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
I18nConsumer = Context.Consumer;
|
|
14
|
-
var messagesCache = createIntlCache();
|
|
7
|
+
import { createContext, Component } from "react";
|
|
8
|
+
import { createIntlCache } from "@formatjs/intl";
|
|
9
|
+
var Context = /* @__PURE__ */ createContext(void 0);
|
|
10
|
+
Context.Provider;
|
|
11
|
+
Context.Consumer;
|
|
12
|
+
createIntlCache();
|
|
15
13
|
function getText(dictionaries, locale) {
|
|
16
|
-
return function
|
|
14
|
+
return function(key) {
|
|
17
15
|
var dictionary = dictionaries[locale];
|
|
18
|
-
return dictionary ? dictionary[key] : dictionaries[
|
|
16
|
+
return dictionary ? dictionary[key] : dictionaries["en"][key];
|
|
19
17
|
};
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
var WithI18n = /*#__PURE__*/function (_Component) {
|
|
27
|
-
_inherits(WithI18n, _Component);
|
|
28
|
-
var _super = _createSuper(WithI18n);
|
|
29
|
-
function WithI18n() {
|
|
19
|
+
var WithI18n = /* @__PURE__ */ function(_Component) {
|
|
20
|
+
_inherits(WithI18n2, _Component);
|
|
21
|
+
var _super = _createSuper(WithI18n2);
|
|
22
|
+
function WithI18n2() {
|
|
30
23
|
var _this;
|
|
31
|
-
_classCallCheck(this,
|
|
24
|
+
_classCallCheck(this, WithI18n2);
|
|
32
25
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
26
|
args[_key] = arguments[_key];
|
|
34
27
|
}
|
|
35
28
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
-
/* @ts-ignore */
|
|
37
29
|
_defineProperty(_assertThisInitialized(_this), "context", void 0);
|
|
38
|
-
_defineProperty(_assertThisInitialized(_this), "getText", function
|
|
39
|
-
var _this$props = _this.props,
|
|
40
|
-
locale = _this$props.locale,
|
|
41
|
-
getText = _this$props.getText;
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "getText", function(dictionary, selfLocale) {
|
|
31
|
+
var _this$props = _this.props, locale = _this$props.locale, getText2 = _this$props.getText;
|
|
42
32
|
var contextLocale = _this.context;
|
|
43
|
-
return
|
|
33
|
+
return getText2(dictionary, selfLocale || locale || contextLocale);
|
|
44
34
|
});
|
|
45
35
|
return _this;
|
|
46
36
|
}
|
|
47
|
-
_createClass(
|
|
37
|
+
_createClass(WithI18n2, [{
|
|
48
38
|
key: "render",
|
|
49
39
|
value: function render() {
|
|
50
|
-
var _ref = this.props,
|
|
51
|
-
children = _ref.children;
|
|
40
|
+
var _ref = this.props, children = _ref.children;
|
|
52
41
|
return children({
|
|
53
42
|
getText: this.getText
|
|
54
43
|
});
|
|
55
44
|
}
|
|
56
45
|
}]);
|
|
57
|
-
return
|
|
46
|
+
return WithI18n2;
|
|
58
47
|
}(Component);
|
|
59
48
|
_defineProperty(WithI18n, "contextType", Context);
|
|
60
49
|
_defineProperty(WithI18n, "defaultProps", {
|
|
61
|
-
getText
|
|
50
|
+
getText
|
|
62
51
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en';
|
|
66
|
-
var fallbackDictionary = arguments.length > 2 ? arguments[2] : undefined;
|
|
67
|
-
var lang = (_React$useContext = React.useContext(Context)) !== null && _React$useContext !== void 0 ? _React$useContext : locale;
|
|
68
|
-
var resolvedDictionary = useAsyncI18nMessages(dictionary, lang, fallbackDictionary);
|
|
69
|
-
var intl = React.useMemo(function () {
|
|
70
|
-
return createIntl({
|
|
71
|
-
locale: lang,
|
|
72
|
-
messages: resolvedDictionary
|
|
73
|
-
}, messagesCache);
|
|
74
|
-
}, [resolvedDictionary, lang]);
|
|
75
|
-
return React.useCallback(function (messageId, variables) {
|
|
76
|
-
return intl.formatMessage({
|
|
77
|
-
id: messageId !== null && messageId !== void 0 ? messageId : ''
|
|
78
|
-
}, variables);
|
|
79
|
-
}, [intl]);
|
|
52
|
+
export {
|
|
53
|
+
Context
|
|
80
54
|
};
|
|
81
|
-
export default createHoc(WithI18n);
|
|
82
|
-
export { useI18n, I18nProvider, I18nConsumer };
|
|
83
|
-
//# sourceMappingURL=WithI18n.mjs.map
|
package/lib/utils/logger.mjs
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
-
var DEV = process.env.NODE_ENV !==
|
|
5
|
-
var Logger =
|
|
6
|
-
function
|
|
7
|
-
_classCallCheck(this,
|
|
4
|
+
var DEV = process.env.NODE_ENV !== "production";
|
|
5
|
+
var Logger = /* @__PURE__ */ function() {
|
|
6
|
+
function Logger2(logger2) {
|
|
7
|
+
_classCallCheck(this, Logger2);
|
|
8
8
|
_defineProperty(this, "logger", void 0);
|
|
9
|
-
this.logger =
|
|
10
|
-
warn: function warn() {
|
|
9
|
+
this.logger = logger2 || {
|
|
10
|
+
warn: function warn() {
|
|
11
|
+
}
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
_createClass(
|
|
14
|
+
_createClass(Logger2, [{
|
|
14
15
|
key: "console",
|
|
15
|
-
value: function
|
|
16
|
+
value: function console2(level, msg, component) {
|
|
16
17
|
this.logger[level](component ? "[".concat(component, "]: ").concat(msg) : msg);
|
|
17
18
|
}
|
|
18
19
|
}, {
|
|
@@ -20,13 +21,15 @@ var Logger = /*#__PURE__*/function () {
|
|
|
20
21
|
value: function warn(condition, msg, component) {
|
|
21
22
|
if (DEV) {
|
|
22
23
|
if (condition) {
|
|
23
|
-
this.console(
|
|
24
|
+
this.console("warn", msg, component);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
}]);
|
|
28
|
-
return
|
|
29
|
+
return Logger2;
|
|
29
30
|
}();
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
|
|
31
|
+
const logger = new Logger(console);
|
|
32
|
+
export {
|
|
33
|
+
Logger,
|
|
34
|
+
logger as default
|
|
35
|
+
};
|
package/lib/utils/pick.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function pick(obj, keys) {
|
|
2
2
|
var res = {};
|
|
3
3
|
var len = keys.length;
|
|
4
4
|
var idx = -1;
|
|
@@ -10,4 +10,6 @@ export default function pick(obj, keys) {
|
|
|
10
10
|
}
|
|
11
11
|
return res;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
export {
|
|
14
|
+
pick as default
|
|
15
|
+
};
|
package/lib/utils/ref.mjs
CHANGED
|
@@ -1,83 +1,43 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import
|
|
3
|
-
import React from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
if (typeof ref ===
|
|
2
|
+
import "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
function setRef(ref, value) {
|
|
6
|
+
if (typeof ref === "function") {
|
|
7
7
|
ref(value);
|
|
8
|
-
} else if (ref !== null && ref !== void 0 && ref.hasOwnProperty(
|
|
9
|
-
|
|
10
|
-
ref['current'] = value;
|
|
8
|
+
} else if (ref !== null && ref !== void 0 && ref.hasOwnProperty("current")) {
|
|
9
|
+
ref["current"] = value;
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
if (!ref) return null;
|
|
15
|
-
return 'current' in ref ? ref.current : ref;
|
|
16
|
-
}
|
|
17
|
-
export function useCallbackRef(initialValue, callback) {
|
|
18
|
-
var _React$useState = React.useState(function () {
|
|
19
|
-
return {
|
|
20
|
-
// value
|
|
21
|
-
value: initialValue,
|
|
22
|
-
// last callback
|
|
23
|
-
callback: callback,
|
|
24
|
-
// "memoized" public interface
|
|
25
|
-
facade: {
|
|
26
|
-
get current() {
|
|
27
|
-
return ref.value;
|
|
28
|
-
},
|
|
29
|
-
set current(value) {
|
|
30
|
-
var last = ref.value;
|
|
31
|
-
if (last !== value) {
|
|
32
|
-
ref.value = value;
|
|
33
|
-
ref.callback(value, last);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}),
|
|
39
|
-
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
40
|
-
ref = _React$useState2[0];
|
|
41
|
-
// update callback
|
|
42
|
-
ref.callback = callback;
|
|
43
|
-
return ref.facade;
|
|
44
|
-
}
|
|
45
|
-
export function useForkRef() {
|
|
12
|
+
function useForkRef() {
|
|
46
13
|
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
47
14
|
refs[_key] = arguments[_key];
|
|
48
15
|
}
|
|
49
|
-
return React.useCallback(function
|
|
16
|
+
return React.useCallback(function(refValue) {
|
|
50
17
|
var uniqueRefs = _toConsumableArray(new Set(refs));
|
|
51
|
-
uniqueRefs.forEach(function
|
|
18
|
+
uniqueRefs.forEach(function(ref) {
|
|
52
19
|
return setRef(ref, refValue);
|
|
53
20
|
});
|
|
54
21
|
}, refs);
|
|
55
22
|
}
|
|
56
|
-
|
|
23
|
+
function forkRef() {
|
|
57
24
|
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
58
25
|
refs[_key2] = arguments[_key2];
|
|
59
26
|
}
|
|
60
|
-
if (refs.every(function
|
|
27
|
+
if (refs.every(function(ref) {
|
|
61
28
|
return ref == null;
|
|
62
29
|
})) {
|
|
63
30
|
return null;
|
|
64
31
|
}
|
|
65
|
-
return function
|
|
32
|
+
return function(refValue) {
|
|
66
33
|
var uniqueRefs = _toConsumableArray(new Set(refs));
|
|
67
|
-
uniqueRefs.forEach(function
|
|
34
|
+
uniqueRefs.forEach(function(ref) {
|
|
68
35
|
return setRef(ref, refValue);
|
|
69
36
|
});
|
|
70
37
|
};
|
|
71
38
|
}
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var node = getRef(ref);
|
|
78
|
-
if (!node) return null;
|
|
79
|
-
if (node.nodeType === 1) return node;
|
|
80
|
-
if (Object.keys(node).length === 1 && 'getBoundingClientRect' in node) return null;
|
|
81
|
-
return findDOMNode(node);
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=ref.mjs.map
|
|
39
|
+
export {
|
|
40
|
+
forkRef,
|
|
41
|
+
setRef,
|
|
42
|
+
useForkRef
|
|
43
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
import canUseDOM from "../canUseDOM.mjs";
|
|
3
3
|
var useEnhancedEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export {
|
|
5
|
+
useEnhancedEffect as default
|
|
6
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/core",
|
|
3
3
|
"description": "Semrush Core Component",
|
|
4
|
-
"version": "16.0.0-prerelease.
|
|
4
|
+
"version": "16.0.0-prerelease.9",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -292,6 +292,6 @@
|
|
|
292
292
|
"@types/react-dom": "18.0.6"
|
|
293
293
|
},
|
|
294
294
|
"scripts": {
|
|
295
|
-
"build": "pnpm semcore-builder --coreUtils"
|
|
295
|
+
"build": "pnpm semcore-builder --coreUtils && pnpm vite build"
|
|
296
296
|
}
|
|
297
297
|
}
|
package/vite.config.ts
CHANGED