@semcore/core 16.0.0-prerelease.10 → 16.0.0-prerelease.11

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.
Files changed (48) hide show
  1. package/lib/LastInteractionType.mjs +1 -1
  2. package/lib/coreFactory.mjs +5 -5
  3. package/lib/enhancement/Children.mjs +1 -1
  4. package/lib/enhancement/Root.mjs +3 -7
  5. package/lib/enhancement/hoistProps.mjs +3 -3
  6. package/lib/enhancement/i18n.mjs +1 -1
  7. package/lib/enhancement/staticChildren.mjs +3 -3
  8. package/lib/enhancement/style.mjs +2 -3
  9. package/lib/enhancement/uncontrolledProps.mjs +2 -2
  10. package/lib/esm/LastInteractionType.mjs +1 -1
  11. package/lib/esm/coreFactory.mjs +5 -5
  12. package/lib/esm/enhancement/Children.mjs +1 -1
  13. package/lib/esm/enhancement/Root.mjs +3 -7
  14. package/lib/esm/enhancement/hoistProps.mjs +3 -3
  15. package/lib/esm/enhancement/i18n.mjs +1 -1
  16. package/lib/esm/enhancement/staticChildren.mjs +3 -3
  17. package/lib/esm/enhancement/style.mjs +2 -3
  18. package/lib/esm/enhancement/uncontrolledProps.mjs +2 -2
  19. package/lib/esm/index.mjs +1 -0
  20. package/lib/esm/styled/index.mjs +8 -0
  21. package/lib/esm/styled/reshadow-core.mjs +219 -3
  22. package/lib/esm/utils/assignProps.mjs +86 -0
  23. package/lib/esm/utils/canUseDOM.mjs +6 -0
  24. package/lib/esm/utils/capitalizeFirstLetter.mjs +6 -0
  25. package/lib/esm/utils/createHoc.mjs +44 -0
  26. package/lib/esm/utils/enhances/WithI18n.mjs +78 -0
  27. package/lib/esm/utils/enhances/i18nEnhance.mjs +91 -0
  28. package/lib/esm/utils/getDisplayName.mjs +6 -0
  29. package/lib/esm/utils/logger.mjs +35 -0
  30. package/lib/esm/utils/pick.mjs +15 -0
  31. package/lib/esm/utils/ref.mjs +86 -0
  32. package/lib/esm/utils/use/useEnhancedEffect.mjs +6 -0
  33. package/lib/index.mjs +1 -0
  34. package/lib/styled/index.mjs +8 -6
  35. package/lib/styled/reshadow-core.mjs +219 -3
  36. package/lib/utils/assignProps.mjs +30 -28
  37. package/lib/utils/canUseDOM.mjs +5 -3
  38. package/lib/utils/capitalizeFirstLetter.mjs +4 -2
  39. package/lib/utils/createHoc.mjs +19 -21
  40. package/lib/utils/enhances/WithI18n.mjs +32 -37
  41. package/lib/utils/enhances/i18nEnhance.mjs +32 -33
  42. package/lib/utils/getDisplayName.mjs +5 -3
  43. package/lib/utils/logger.mjs +16 -13
  44. package/lib/utils/pick.mjs +4 -2
  45. package/lib/utils/ref.mjs +46 -43
  46. package/lib/utils/use/useEnhancedEffect.mjs +4 -3
  47. package/package.json +1 -1
  48. package/vite.config.ts +1 -2
@@ -1,68 +1,66 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import cn from 'classnames';
3
- import { sstyled } from "../styled/index.mjs";
2
+ import _cn from "classnames";
3
+ import "../styled/index.mjs";
4
4
  import { forkRef } from "./ref.mjs";
5
- export function callAllEventHandlers() {
5
+ import { sstyled } from "../styled/sstyled.mjs";
6
+ function callAllEventHandlers() {
6
7
  for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
7
8
  fns[_key] = arguments[_key];
8
9
  }
9
- return function () {
10
+ return function() {
10
11
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
11
12
  args[_key2] = arguments[_key2];
12
13
  }
13
- return !fns.some(function (fn) {
14
+ return !fns.some(function(fn) {
14
15
  var result;
15
16
  if (fn) {
16
17
  result = fn.apply(void 0, args);
17
18
  }
18
- return typeof result === 'boolean' && !result;
19
+ return typeof result === "boolean" && !result;
19
20
  });
20
21
  };
21
22
  }
22
- export function assignHandlers(props, source) {
23
- return Object.keys(source).reduce(function (proxySource, propName) {
24
- if (typeof source[propName] === 'function' && propName.startsWith('on')) {
23
+ function assignHandlers(props, source) {
24
+ return Object.keys(source).reduce(function(proxySource, propName) {
25
+ if (typeof source[propName] === "function" && propName.startsWith("on")) {
25
26
  proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);
26
27
  }
27
28
  return proxySource;
28
29
  }, {});
29
30
  }
30
31
  function assignHandlersInner(props, source) {
31
- return Object.keys(source).reduce(function (proxySource, propName) {
32
- if (propName !== 'ref' && propName.startsWith('on')) {
33
- if (typeof source[propName] === 'function' && typeof props[propName] === 'function') {
32
+ return Object.keys(source).reduce(function(proxySource, propName) {
33
+ if (propName !== "ref" && propName.startsWith("on")) {
34
+ if (typeof source[propName] === "function" && typeof props[propName] === "function") {
34
35
  proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);
35
- } else if (typeof source[propName] === 'function') {
36
+ } else if (typeof source[propName] === "function") {
36
37
  proxySource[propName] = source[propName];
37
- } else if (typeof props[propName] === 'function') {
38
+ } else if (typeof props[propName] === "function") {
38
39
  proxySource[propName] = props[propName];
39
40
  }
40
41
  }
41
42
  return proxySource;
42
43
  }, {});
43
44
  }
44
- export default function assignProps() {
45
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
46
- var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
47
- // @ts-ignore
45
+ function assignProps() {
46
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
47
+ var source = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
48
48
  if (props === source) return props;
49
49
  var newProps = _objectSpread(_objectSpread(_objectSpread({}, source), props), assignHandlersInner(props, source));
50
50
  for (var _key3 in source) {
51
- if (_key3.startsWith('use:')) {
52
- var originalKey = _key3.slice('use:'.length);
51
+ if (_key3.startsWith("use:")) {
52
+ var originalKey = _key3.slice("use:".length);
53
53
  newProps[originalKey] = source[_key3];
54
54
  }
55
55
  }
56
56
  for (var _key4 in props) {
57
- if (_key4.startsWith('use:')) {
58
- var _originalKey = _key4.slice('use:'.length);
57
+ if (_key4.startsWith("use:")) {
58
+ var _originalKey = _key4.slice("use:".length);
59
59
  newProps[_originalKey] = props[_key4];
60
60
  }
61
61
  }
62
-
63
- // because react set getter for ref
64
- var sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, 'ref');
65
- var propsDescriptorRef = Object.getOwnPropertyDescriptor(props, 'ref');
62
+ var sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, "ref");
63
+ var propsDescriptorRef = Object.getOwnPropertyDescriptor(props, "ref");
66
64
  if (sourceDescriptorRef !== null && sourceDescriptorRef !== void 0 && sourceDescriptorRef.configurable && propsDescriptorRef !== null && propsDescriptorRef !== void 0 && propsDescriptorRef.configurable) {
67
65
  newProps.ref = forkRef(source.ref, props.ref);
68
66
  }
@@ -74,11 +72,15 @@ export default function assignProps() {
74
72
  newProps.style = _objectSpread(_objectSpread({}, source.style), props.style);
75
73
  }
76
74
  if (source.className) {
77
- newProps.className = cn(props.className, source.className);
75
+ newProps.className = _cn(props.className, source.className);
78
76
  }
79
77
  if (source.styles && props.styles) {
80
78
  newProps.styles = sstyled.merge(source.styles, props.styles);
81
79
  }
82
80
  return newProps;
83
81
  }
84
- //# sourceMappingURL=assignProps.mjs.map
82
+ export {
83
+ assignHandlers,
84
+ callAllEventHandlers,
85
+ assignProps as default
86
+ };
@@ -1,4 +1,6 @@
1
- export default function () {
2
- return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
1
+ function canUseDOM() {
2
+ return !!(typeof window !== "undefined" && window.document && window.document.createElement);
3
3
  }
4
- //# sourceMappingURL=canUseDOM.mjs.map
4
+ export {
5
+ canUseDOM as default
6
+ };
@@ -1,4 +1,6 @@
1
- export default function capitalizeFirstLetter(input) {
1
+ function capitalizeFirstLetter(input) {
2
2
  return input.charAt(0).toUpperCase() + input.slice(1);
3
3
  }
4
- //# sourceMappingURL=capitalizeFirstLetter.mjs.map
4
+ export {
5
+ capitalizeFirstLetter as default
6
+ };
@@ -6,41 +6,39 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
7
7
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
8
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
- var _excluded = ["forwardedRef"];
10
- import React, { PureComponent } from 'react';
11
- import hoistNonReactStatics from 'hoist-non-react-statics';
9
+ import React, { PureComponent } from "react";
10
+ import hoistNonReactStatics from "hoist-non-react-statics";
12
11
  import getDisplayName from "./getDisplayName.mjs";
12
+ var _excluded = ["forwardedRef"];
13
13
  function createHoc(EnhancedComponent) {
14
14
  return function createWrapper() {
15
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
- return function (WrappedComponent) {
17
- var Component = /*#__PURE__*/function (_PureComponent) {
18
- _inherits(Component, _PureComponent);
19
- var _super = _createSuper(Component);
20
- function Component() {
21
- _classCallCheck(this, Component);
15
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
16
+ return function(WrappedComponent) {
17
+ var Component = /* @__PURE__ */ function(_PureComponent) {
18
+ _inherits(Component2, _PureComponent);
19
+ var _super = _createSuper(Component2);
20
+ function Component2() {
21
+ _classCallCheck(this, Component2);
22
22
  return _super.apply(this, arguments);
23
23
  }
24
- _createClass(Component, [{
24
+ _createClass(Component2, [{
25
25
  key: "render",
26
26
  value: function render() {
27
- // @ts-ignore
28
- var _WrappedComponent$def = _objectSpread(_objectSpread({}, WrappedComponent.defaultProps), this.props),
29
- forwardedRef = _WrappedComponent$def.forwardedRef,
30
- others = _objectWithoutProperties(_WrappedComponent$def, _excluded);
31
- return /*#__PURE__*/React.createElement(EnhancedComponent, _extends({}, options, this.props), function (enhancedComponentProps) {
32
- return /*#__PURE__*/React.createElement(WrappedComponent, _extends({
33
- forwardedRef: forwardedRef
27
+ var _WrappedComponent$def = _objectSpread(_objectSpread({}, WrappedComponent.defaultProps), this.props), forwardedRef = _WrappedComponent$def.forwardedRef, others = _objectWithoutProperties(_WrappedComponent$def, _excluded);
28
+ return /* @__PURE__ */ React.createElement(EnhancedComponent, _extends({}, options, this.props), function(enhancedComponentProps) {
29
+ return /* @__PURE__ */ React.createElement(WrappedComponent, _extends({
30
+ forwardedRef
34
31
  }, others, enhancedComponentProps));
35
32
  });
36
33
  }
37
34
  }]);
38
- return Component;
35
+ return Component2;
39
36
  }(PureComponent);
40
37
  _defineProperty(Component, "displayName", getDisplayName(WrappedComponent));
41
38
  return hoistNonReactStatics(Component, WrappedComponent);
42
39
  };
43
40
  };
44
41
  }
45
- export default createHoc;
46
- //# sourceMappingURL=createHoc.mjs.map
42
+ export {
43
+ createHoc as default
44
+ };
@@ -4,80 +4,75 @@ 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 React, { Component, createContext } from 'react';
7
+ import React, { createContext, Component } from "react";
8
8
  import createHoc from "../createHoc.mjs";
9
9
  import { useAsyncI18nMessages } from "./i18nEnhance.mjs";
10
- import { createIntl, createIntlCache } from '@formatjs/intl';
11
- export var Context = /*#__PURE__*/createContext(undefined);
12
- var I18nProvider = Context.Provider,
13
- I18nConsumer = Context.Consumer;
10
+ import { createIntlCache, createIntl } from "@formatjs/intl";
11
+ var Context = /* @__PURE__ */ createContext(void 0);
12
+ var I18nProvider = Context.Provider, I18nConsumer = Context.Consumer;
14
13
  var messagesCache = createIntlCache();
15
14
  function getText(dictionaries, locale) {
16
- return function (key) {
15
+ return function(key) {
17
16
  var dictionary = dictionaries[locale];
18
- return dictionary ? dictionary[key] : dictionaries['en'][key];
17
+ return dictionary ? dictionary[key] : dictionaries["en"][key];
19
18
  };
20
19
  }
21
-
22
- /** @deprecated */
23
- /**
24
- * @deprecated use `useI18n` instead
25
- */
26
- var WithI18n = /*#__PURE__*/function (_Component) {
27
- _inherits(WithI18n, _Component);
28
- var _super = _createSuper(WithI18n);
29
- function WithI18n() {
20
+ var WithI18n = /* @__PURE__ */ function(_Component) {
21
+ _inherits(WithI18n2, _Component);
22
+ var _super = _createSuper(WithI18n2);
23
+ function WithI18n2() {
30
24
  var _this;
31
- _classCallCheck(this, WithI18n);
25
+ _classCallCheck(this, WithI18n2);
32
26
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
27
  args[_key] = arguments[_key];
34
28
  }
35
29
  _this = _super.call.apply(_super, [this].concat(args));
36
- /* @ts-ignore */
37
30
  _defineProperty(_assertThisInitialized(_this), "context", void 0);
38
- _defineProperty(_assertThisInitialized(_this), "getText", function (dictionary, selfLocale) {
39
- var _this$props = _this.props,
40
- locale = _this$props.locale,
41
- getText = _this$props.getText;
31
+ _defineProperty(_assertThisInitialized(_this), "getText", function(dictionary, selfLocale) {
32
+ var _this$props = _this.props, locale = _this$props.locale, getText2 = _this$props.getText;
42
33
  var contextLocale = _this.context;
43
- return getText(dictionary, selfLocale || locale || contextLocale);
34
+ return getText2(dictionary, selfLocale || locale || contextLocale);
44
35
  });
45
36
  return _this;
46
37
  }
47
- _createClass(WithI18n, [{
38
+ _createClass(WithI18n2, [{
48
39
  key: "render",
49
40
  value: function render() {
50
- var _ref = this.props,
51
- children = _ref.children;
41
+ var _ref = this.props, children = _ref.children;
52
42
  return children({
53
43
  getText: this.getText
54
44
  });
55
45
  }
56
46
  }]);
57
- return WithI18n;
47
+ return WithI18n2;
58
48
  }(Component);
59
49
  _defineProperty(WithI18n, "contextType", Context);
60
50
  _defineProperty(WithI18n, "defaultProps", {
61
- getText: getText
51
+ getText
62
52
  });
63
- var useI18n = function useI18n(dictionary) {
53
+ var useI18n = function useI18n2(dictionary) {
64
54
  var _React$useContext;
65
- var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en';
66
- var fallbackDictionary = arguments.length > 2 ? arguments[2] : undefined;
55
+ var locale = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "en";
56
+ var fallbackDictionary = arguments.length > 2 ? arguments[2] : void 0;
67
57
  var lang = (_React$useContext = React.useContext(Context)) !== null && _React$useContext !== void 0 ? _React$useContext : locale;
68
58
  var resolvedDictionary = useAsyncI18nMessages(dictionary, lang, fallbackDictionary);
69
- var intl = React.useMemo(function () {
59
+ var intl = React.useMemo(function() {
70
60
  return createIntl({
71
61
  locale: lang,
72
62
  messages: resolvedDictionary
73
63
  }, messagesCache);
74
64
  }, [resolvedDictionary, lang]);
75
- return React.useCallback(function (messageId, variables) {
65
+ return React.useCallback(function(messageId, variables) {
76
66
  return intl.formatMessage({
77
- id: messageId !== null && messageId !== void 0 ? messageId : ''
67
+ id: messageId !== null && messageId !== void 0 ? messageId : ""
78
68
  }, variables);
79
69
  }, [intl]);
80
70
  };
81
- export default createHoc(WithI18n);
82
- export { useI18n, I18nProvider, I18nConsumer };
83
- //# sourceMappingURL=WithI18n.mjs.map
71
+ const WithI18n$1 = createHoc(WithI18n);
72
+ export {
73
+ Context,
74
+ I18nConsumer,
75
+ I18nProvider,
76
+ WithI18n$1 as default,
77
+ useI18n
78
+ };
@@ -4,24 +4,24 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
4
4
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
5
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
- import React from 'react';
7
+ import React from "react";
8
8
  import { useI18n } from "./WithI18n.mjs";
9
- export var useAsyncI18nMessages = function useAsyncI18nMessages(primaryContainer, locale, fallbackContainer) {
9
+ var useAsyncI18nMessages = function useAsyncI18nMessages2(primaryContainer, locale, fallbackContainer) {
10
10
  var _store$locale;
11
- var container = React.useMemo(function () {
11
+ var container = React.useMemo(function() {
12
12
  if (!fallbackContainer) return primaryContainer;
13
13
  if (!primaryContainer) return fallbackContainer;
14
14
  if (primaryContainer === fallbackContainer) return primaryContainer;
15
- var container = {};
16
- var _loop = function _loop(_locale) {
17
- if (typeof primaryContainer[_locale] === 'function' || typeof fallbackContainer[_locale] === 'function') {
18
- container[_locale] = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
15
+ var container2 = {};
16
+ var _loop = function _loop2(_locale2) {
17
+ if (typeof primaryContainer[_locale2] === "function" || typeof fallbackContainer[_locale2] === "function") {
18
+ container2[_locale2] = /* @__PURE__ */ _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
19
19
  var _yield$Promise$all, _yield$Promise$all2, primary, fallback;
20
20
  return _regeneratorRuntime().wrap(function _callee$(_context) {
21
21
  while (1) switch (_context.prev = _context.next) {
22
22
  case 0:
23
23
  _context.next = 2;
24
- return Promise.all([primaryContainer[_locale], fallbackContainer[_locale]]);
24
+ return Promise.all([primaryContainer[_locale2], fallbackContainer[_locale2]]);
25
25
  case 2:
26
26
  _yield$Promise$all = _context.sent;
27
27
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
@@ -36,57 +36,56 @@ export var useAsyncI18nMessages = function useAsyncI18nMessages(primaryContainer
36
36
  }));
37
37
  } else {
38
38
  var _primaryContainer$_lo, _fallbackContainer$_l;
39
- container[_locale] = _objectSpread(_objectSpread({}, (_primaryContainer$_lo = primaryContainer[_locale]) !== null && _primaryContainer$_lo !== void 0 ? _primaryContainer$_lo : {}), (_fallbackContainer$_l = fallbackContainer[_locale]) !== null && _fallbackContainer$_l !== void 0 ? _fallbackContainer$_l : {});
39
+ container2[_locale2] = _objectSpread(_objectSpread({}, (_primaryContainer$_lo = primaryContainer[_locale2]) !== null && _primaryContainer$_lo !== void 0 ? _primaryContainer$_lo : {}), (_fallbackContainer$_l = fallbackContainer[_locale2]) !== null && _fallbackContainer$_l !== void 0 ? _fallbackContainer$_l : {});
40
40
  }
41
41
  };
42
42
  for (var _locale in primaryContainer) {
43
43
  _loop(_locale);
44
44
  }
45
- return container;
45
+ return container2;
46
46
  }, [primaryContainer, fallbackContainer]);
47
- var initStore = React.useMemo(function () {
48
- var store = {};
47
+ var initStore = React.useMemo(function() {
48
+ var store2 = {};
49
49
  for (var _locale2 in container) {
50
- if (_typeof(container[_locale2]) === 'object') {
51
- store[_locale2] = container[_locale2];
50
+ if (_typeof(container[_locale2]) === "object") {
51
+ store2[_locale2] = container[_locale2];
52
52
  }
53
53
  }
54
- return store;
54
+ return store2;
55
55
  }, [container]);
56
- var _React$useState = React.useState(initStore),
57
- _React$useState2 = _slicedToArray(_React$useState, 2),
58
- store = _React$useState2[0],
59
- setStore = _React$useState2[1];
56
+ var _React$useState = React.useState(initStore), _React$useState2 = _slicedToArray(_React$useState, 2), store = _React$useState2[0], setStore = _React$useState2[1];
60
57
  var lastLoadedLocaleRef = React.useRef(null);
61
58
  if (store[locale]) lastLoadedLocaleRef.current = locale;
62
- var fallbackMessages = React.useMemo(function () {
59
+ var fallbackMessages = React.useMemo(function() {
63
60
  return Object.values(store)[0];
64
61
  }, [store]);
65
62
  var loadingLocaleRef = React.useRef(null);
66
- React.useEffect(function () {
63
+ React.useEffect(function() {
67
64
  loadingLocaleRef.current = locale;
68
65
  var asyncMessages = container[locale];
69
- if (typeof asyncMessages === 'function') {
70
- asyncMessages().then(function (module) {
66
+ if (typeof asyncMessages === "function") {
67
+ asyncMessages().then(function(module) {
71
68
  if (loadingLocaleRef.current !== locale) return;
72
69
  var messages = module;
73
- if ('default' in module && _typeof(module["default"]) === 'object') messages = module["default"];
74
- setStore(function (store) {
75
- return _objectSpread(_objectSpread({}, store), {}, _defineProperty({}, locale, messages));
70
+ if ("default" in module && _typeof(module["default"]) === "object") messages = module["default"];
71
+ setStore(function(store2) {
72
+ return _objectSpread(_objectSpread({}, store2), {}, _defineProperty({}, locale, messages));
76
73
  });
77
74
  })["catch"](console.error);
78
75
  }
79
76
  }, [container, locale]);
80
77
  return (_store$locale = store[locale]) !== null && _store$locale !== void 0 ? _store$locale : fallbackMessages;
81
78
  };
82
- export default (function (container) {
83
- return function (props) {
84
- var i18n = props.i18n,
85
- locale = props.locale;
79
+ const i18nEnhance = function(container) {
80
+ return function(props) {
81
+ var i18n = props.i18n, locale = props.locale;
86
82
  var getI18nText = useI18n(i18n, locale, container);
87
83
  return _objectSpread(_objectSpread({}, props), {}, {
88
- getI18nText: getI18nText
84
+ getI18nText
89
85
  });
90
86
  };
91
- });
92
- //# sourceMappingURL=i18nEnhance.mjs.map
87
+ };
88
+ export {
89
+ i18nEnhance as default,
90
+ useAsyncI18nMessages
91
+ };
@@ -1,4 +1,6 @@
1
- export default function getDisplayName(WrappedComponent) {
2
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
1
+ function getDisplayName(WrappedComponent) {
2
+ return WrappedComponent.displayName || WrappedComponent.name || "Component";
3
3
  }
4
- //# sourceMappingURL=getDisplayName.mjs.map
4
+ export {
5
+ getDisplayName as default
6
+ };
@@ -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 !== 'production';
5
- var Logger = /*#__PURE__*/function () {
6
- function Logger(logger) {
7
- _classCallCheck(this, Logger);
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 = logger || {
10
- warn: function warn() {}
9
+ this.logger = logger2 || {
10
+ warn: function warn() {
11
+ }
11
12
  };
12
13
  }
13
- _createClass(Logger, [{
14
+ _createClass(Logger2, [{
14
15
  key: "console",
15
- value: function console(level, msg, component) {
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('warn', msg, component);
24
+ this.console("warn", msg, component);
24
25
  }
25
26
  }
26
27
  }
27
28
  }]);
28
- return Logger;
29
+ return Logger2;
29
30
  }();
30
- export { Logger };
31
- export default new Logger(console);
32
- //# sourceMappingURL=logger.mjs.map
31
+ const logger = new Logger(console);
32
+ export {
33
+ Logger,
34
+ logger as default
35
+ };
@@ -1,4 +1,4 @@
1
- export default function pick(obj, keys) {
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
- //# sourceMappingURL=pick.mjs.map
13
+ export {
14
+ pick as default
15
+ };
package/lib/utils/ref.mjs CHANGED
@@ -1,83 +1,86 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import React from 'react';
4
- import { findDOMNode } from 'react-dom';
5
- export function setRef(ref, value) {
6
- if (typeof ref === 'function') {
3
+ import React from "react";
4
+ import { findDOMNode } from "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('current')) {
9
- // @ts-ignore
10
- ref['current'] = value;
8
+ } else if (ref !== null && ref !== void 0 && ref.hasOwnProperty("current")) {
9
+ ref["current"] = value;
11
10
  }
12
11
  }
13
- export function getRef(ref) {
12
+ function getRef(ref) {
14
13
  if (!ref) return null;
15
- return 'current' in ref ? ref.current : ref;
14
+ return "current" in ref ? ref.current : ref;
16
15
  }
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
- }
16
+ function useCallbackRef(initialValue, callback) {
17
+ var _React$useState = React.useState(function() {
18
+ return {
19
+ // value
20
+ value: initialValue,
21
+ // last callback
22
+ callback,
23
+ // "memoized" public interface
24
+ facade: {
25
+ get current() {
26
+ return ref.value;
27
+ },
28
+ set current(value) {
29
+ var last = ref.value;
30
+ if (last !== value) {
31
+ ref.value = value;
32
+ ref.callback(value, last);
35
33
  }
36
34
  }
37
- };
38
- }),
39
- _React$useState2 = _slicedToArray(_React$useState, 1),
40
- ref = _React$useState2[0];
41
- // update callback
35
+ }
36
+ };
37
+ }), _React$useState2 = _slicedToArray(_React$useState, 1), ref = _React$useState2[0];
42
38
  ref.callback = callback;
43
39
  return ref.facade;
44
40
  }
45
- export function useForkRef() {
41
+ function useForkRef() {
46
42
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
47
43
  refs[_key] = arguments[_key];
48
44
  }
49
- return React.useCallback(function (refValue) {
45
+ return React.useCallback(function(refValue) {
50
46
  var uniqueRefs = _toConsumableArray(new Set(refs));
51
- uniqueRefs.forEach(function (ref) {
47
+ uniqueRefs.forEach(function(ref) {
52
48
  return setRef(ref, refValue);
53
49
  });
54
50
  }, refs);
55
51
  }
56
- export function forkRef() {
52
+ function forkRef() {
57
53
  for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
58
54
  refs[_key2] = arguments[_key2];
59
55
  }
60
- if (refs.every(function (ref) {
56
+ if (refs.every(function(ref) {
61
57
  return ref == null;
62
58
  })) {
63
59
  return null;
64
60
  }
65
- return function (refValue) {
61
+ return function(refValue) {
66
62
  var uniqueRefs = _toConsumableArray(new Set(refs));
67
- uniqueRefs.forEach(function (ref) {
63
+ uniqueRefs.forEach(function(ref) {
68
64
  return setRef(ref, refValue);
69
65
  });
70
66
  };
71
67
  }
72
- export function getNodeByRef(ref) {
73
- if (typeof ref === 'function') {
68
+ function getNodeByRef(ref) {
69
+ if (typeof ref === "function") {
74
70
  ref = ref();
75
71
  }
76
72
  if (!ref) return null;
77
73
  var node = getRef(ref);
78
74
  if (!node) return null;
79
75
  if (node.nodeType === 1) return node;
80
- if (Object.keys(node).length === 1 && 'getBoundingClientRect' in node) return null;
76
+ if (Object.keys(node).length === 1 && "getBoundingClientRect" in node) return null;
81
77
  return findDOMNode(node);
82
78
  }
83
- //# sourceMappingURL=ref.mjs.map
79
+ export {
80
+ forkRef,
81
+ getNodeByRef,
82
+ getRef,
83
+ setRef,
84
+ useCallbackRef,
85
+ useForkRef
86
+ };
@@ -1,5 +1,6 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  import canUseDOM from "../canUseDOM.mjs";
3
3
  var useEnhancedEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;
4
- export default useEnhancedEffect;
5
- //# sourceMappingURL=useEnhancedEffect.mjs.map
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.10",
4
+ "version": "16.0.0-prerelease.11",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",