@semcore/utils
Advanced tools
Comparing version 3.16.2 to 3.18.0
@@ -5,10 +5,29 @@ # Changelog | ||
## [3.16.2] - 2020-06-10 | ||
## [3.18.0] - 2020-07-14 | ||
### Added | ||
- Добавился новый цвет `google-my-business` | ||
### Changed | ||
- Добавлена оптимизация для `assignProps`, теперь не создаются новые функции и ref | ||
ссылки если они не нужны. Это позволит избежать лишних перерендеров, когда свойства не меняются. | ||
## [3.17.2] - 2020-06-19 | ||
### Fixed | ||
- Убрана dev зависимость `core`. | ||
- Добавлена проверка на отсутствие локали в `i18nEnhance`. | ||
- Добавлена `TS` типы для `i18nEnhance`. | ||
- Исправлен не работающий autoFocus, когда нода быстро перерендривается. | ||
## [3.16.1] - 2020-06-08 | ||
## [3.17.0] - 2020-06-17 | ||
### Added | ||
- Добавлена возможность интерполяции в `i18nEnhance` | ||
## [3.16.3] - 2020-06-08 | ||
### Fixed | ||
@@ -23,3 +42,3 @@ | ||
- Добавлена проверка `children` свойств на одиночных тегах в `propsForElement` | ||
- функцию `i18nEnhance` для работы с переводами | ||
- Добавлена функция `i18nEnhance` для работы с переводами | ||
@@ -26,0 +45,0 @@ ## [3.15.4] - 2020-06-01 |
@@ -44,3 +44,3 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
return Object.keys(source).reduce(function (proxySource, propName) { | ||
if (typeof source[propName] === 'function' && propName.startsWith('on')) { | ||
if (typeof source[propName] === 'function' && typeof props[propName] === 'function' && propName.startsWith('on')) { | ||
proxySource[propName] = callAllEventHandlers(props[propName], source[propName]); | ||
@@ -59,8 +59,7 @@ } | ||
if (source.ref) { | ||
if (source.ref && props.ref) { | ||
newProps.ref = (0, _ref.forkRef)(source.ref, props.ref); | ||
} | ||
if (source.style) { | ||
// @ts-ignore | ||
if (source.style && props.style) { | ||
newProps.style = _objectSpread({}, source.style, {}, props.style); | ||
@@ -67,0 +66,0 @@ } |
@@ -33,2 +33,3 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
"pink": "#f160c3", | ||
"granitic": "#2f3439", | ||
"asphalt": "#45575c", | ||
@@ -40,3 +41,2 @@ "wall": "#64787e", | ||
"stone-light": "#bdc4c6", | ||
"granitic": "#2f3439", | ||
"gray10": "#222222", | ||
@@ -64,2 +64,3 @@ "gray20": "#333333", | ||
"google-green": "#006621", | ||
"google-my-business": "#1a73e8", | ||
"white": "#fff", | ||
@@ -66,0 +67,0 @@ "black": "#000" |
@@ -40,7 +40,6 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
if (autoFocus === false) return; | ||
if (!nodeRef.current || !nodeRef.current.focus) return; | ||
var inputNode = nodeRef.current; | ||
if (!inputNode || !inputNode.focus) return; | ||
var timer = setTimeout(function () { | ||
var _nodeRef$current; | ||
return (_nodeRef$current = nodeRef.current) === null || _nodeRef$current === void 0 ? void 0 : _nodeRef$current.focus(); | ||
return inputNode === null || inputNode === void 0 ? void 0 : inputNode.focus(); | ||
}, autoFocus || 0); | ||
@@ -47,0 +46,0 @@ return function () { |
@@ -0,5 +1,17 @@ | ||
type LocaleKeys = 'de' | 'en' | 'es' | 'fr' | 'it' | 'ja' | 'ru' | 'zh' | 'pt'; | ||
type DictionaryItem = { | ||
[key: string]: string; | ||
}; | ||
type Dictionary = { | ||
[K in LocaleKeys]: DictionaryItem; | ||
}; | ||
declare function interpolate(template: string, variables?: {}): string; | ||
interface IWithI18nEnhanceProps { | ||
getI18nText?: (key?: string) => any; | ||
getI18nText?: (key?: string, variables?: {}) => any; | ||
i18n?: { | ||
[key: string]: string; | ||
}; | ||
locale?: LocaleKeys; | ||
} | ||
declare const _default: () => (props: any) => any; | ||
export { _default as default, IWithI18nEnhanceProps }; | ||
export { _default as default, LocaleKeys, DictionaryItem, Dictionary, interpolate, IWithI18nEnhanceProps }; |
@@ -6,2 +6,3 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
}); | ||
exports.interpolate = interpolate; | ||
exports["default"] = void 0; | ||
@@ -19,8 +20,46 @@ | ||
var REGEX = { | ||
TEMPLATE_VAR: /{{(.*?)}}/g, | ||
HTML_BRACKETS: /[<>&"`]/g | ||
}; | ||
function mirror(a) { | ||
switch (a) { | ||
case '<': | ||
return '<'; | ||
case '>': | ||
return '>'; | ||
case '&': | ||
return '&'; | ||
case '"': | ||
return '"'; | ||
case '`': | ||
return '`'; | ||
} | ||
} | ||
function interpolate(template) { | ||
var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return template.replace(REGEX.TEMPLATE_VAR, function (_, key) { | ||
if (variables[key]) { | ||
return variables[key].replace(REGEX.HTML_BRACKETS, mirror); | ||
} | ||
return _; | ||
}); | ||
} | ||
var getText = function getText(dictionary, locale) { | ||
return function (key) { | ||
var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (key) { | ||
return dictionary ? dictionary[locale][key] : dictionary['en'][key]; | ||
} | ||
return dictionary[locale] && dictionary[locale][key] ? interpolate(dictionary[locale][key], variables) : interpolate(dictionary['en'][key], variables); | ||
} // TODO: убрать эту возможность | ||
return dictionary[locale] || dictionary['en']; | ||
@@ -35,5 +74,5 @@ }; | ||
locale = props.locale; | ||
return _objectSpread({}, props, { | ||
return _objectSpread({ | ||
getI18nText: getText(i18n, locale || contextLocale) | ||
}); | ||
}, props); | ||
}; | ||
@@ -40,0 +79,0 @@ }; |
@@ -38,3 +38,3 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
// @ts-ignore | ||
var version = "3.16.2"; | ||
var version = "3.18.0"; | ||
sh = document.createElement('style'); | ||
@@ -41,0 +41,0 @@ sh.setAttribute('data-ui-v', version); |
@@ -1,2 +0,2 @@ | ||
declare function isNode(node: any): boolean; | ||
declare function isNode(node?: any): boolean; | ||
export { isNode as default }; |
{ | ||
"name": "@semcore/utils", | ||
"description": "SEMRush Utils Component", | ||
"version": "3.16.2", | ||
"version": "3.18.0", | ||
"author": "Roman Lysov <r.lysov@semrush.com>", | ||
@@ -11,2 +11,5 @@ "license": "MIT", | ||
}, | ||
"devDependencies": { | ||
"@semcore/core": "^1" | ||
}, | ||
"dependencies": { | ||
@@ -13,0 +16,0 @@ "@babel/runtime": "^7.10", |
@@ -18,3 +18,7 @@ import cn from 'classnames'; | ||
return Object.keys(source).reduce((proxySource, propName) => { | ||
if (typeof source[propName] === 'function' && propName.startsWith('on')) { | ||
if ( | ||
typeof source[propName] === 'function' && | ||
typeof props[propName] === 'function' && | ||
propName.startsWith('on') | ||
) { | ||
proxySource[propName] = callAllEventHandlers(props[propName], source[propName]); | ||
@@ -44,8 +48,7 @@ } | ||
if (source.ref) { | ||
if (source.ref && props.ref) { | ||
newProps.ref = forkRef(source.ref, props.ref); | ||
} | ||
if (source.style) { | ||
// @ts-ignore | ||
if (source.style && props.style) { | ||
newProps.style = { | ||
@@ -52,0 +55,0 @@ ...source.style, |
/* eslint-disable */ | ||
import React from 'react'; | ||
export default function isNode(node) { | ||
export default function isNode(node?) { | ||
switch (typeof node) { | ||
@@ -6,0 +6,0 @@ case 'number': |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238981
3304
1