@sima-land/ui-nucleons 40.0.0 → 40.2.2
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/_internal/custom-scrollbar/index.js +3 -3
- package/alert/index.js +1 -1
- package/autocomplete/index.js +12 -17
- package/avatar/index.d.ts +1 -1
- package/avatar/index.js +2 -4
- package/avatar/user.d.ts +1 -1
- package/avatar/user.js +2 -2
- package/avatar/utils.js +7 -1
- package/base-input/index.d.ts +1 -1
- package/base-input/index.js +1 -1
- package/bordered-layout/index.d.ts +1 -1
- package/bordered-layout/index.js +1 -1
- package/box/index.js +17 -36
- package/button/index.d.ts +3 -3
- package/button/index.js +4 -4
- package/card/slots.js +1 -1
- package/carousel/draggable.js +14 -16
- package/carousel/index.d.ts +1 -1
- package/carousel/index.js +17 -37
- package/chips/index.js +1 -1
- package/clean-buttons/index.js +1 -3
- package/dot-nav/dot-nav.module.scss +2 -2
- package/dropdown/dropdown.module.scss +1 -3
- package/field-grid/index.d.ts +2 -2
- package/field-grid/index.js +3 -3
- package/file-icon/index.js +5 -6
- package/helpers/bounds-of.js +1 -3
- package/helpers/find-child-element.js +1 -3
- package/helpers/find-offset-parent.js +4 -3
- package/helpers/fit-element-height.js +1 -1
- package/helpers/format-date.js +3 -1
- package/helpers/get-fraction-depth.js +1 -3
- package/hooks/breakpoint/index.js +3 -2
- package/hooks/identity.d.ts +1 -0
- package/hooks/identity.js +1 -0
- package/hooks/index.d.ts +5 -0
- package/hooks/index.js +7 -2
- package/layout/index.js +1 -1
- package/link/index.js +1 -3
- package/loading-overlay/index.d.ts +1 -1
- package/loading-overlay/index.js +1 -1
- package/modal/index.js +2 -2
- package/modal/utils.d.ts +3 -2
- package/modal/utils.js +8 -7
- package/nav-bar/index.d.ts +1 -0
- package/nav-bar/index.js +1 -1
- package/package.json +14 -10
- package/pagination/base-pagination.js +18 -20
- package/pagination/index.js +1 -3
- package/pagination/utils.d.ts +2 -2
- package/pagination/utils.js +7 -6
- package/panel/index.js +1 -3
- package/phone-input/index.js +19 -20
- package/portal/index.js +3 -4
- package/price/utils.js +1 -3
- package/range/index.js +11 -14
- package/rating/index.js +2 -2
- package/readme.md +1 -1
- package/screen/index.js +14 -16
- package/screen/screen-layout.js +10 -4
- package/select/index.js +5 -7
- package/side-page/index.d.ts +39 -0
- package/side-page/index.js +91 -0
- package/side-page/side-page.module.scss +81 -0
- package/side-page/slots.d.ts +32 -0
- package/side-page/slots.js +59 -0
- package/spinner/index.d.ts +1 -1
- package/spinner/index.js +1 -1
- package/spinner/spinner.module.scss +1 -4
- package/styling/fonts.js +1 -3
- package/styling/utils.js +1 -3
- package/text-field/index.js +3 -10
- package/timer/index.d.ts +3 -3
- package/timer/index.js +4 -4
- package/timer/utils.js +1 -4
- package/top-bar/index.js +1 -1
- package/upload/area.js +3 -1
- package/upload/utils.d.ts +2 -2
- package/upload/utils.js +2 -2
- package/with-hint/positioning-hint.d.ts +1 -1
- package/with-hint/positioning-hint.js +1 -1
- package/with-hint/utils.js +5 -7
- package/with-in-viewport-observer/index.js +1 -1
package/field-grid/index.js
CHANGED
|
@@ -41,7 +41,7 @@ const TypeCheck = {
|
|
|
41
41
|
* @param props Свойства.
|
|
42
42
|
* @param props.children Содержимое, дочерними элементами могут быть только FieldGrid.Row.
|
|
43
43
|
* @param props.rootProps Свойства корневого элемента.
|
|
44
|
-
* @return
|
|
44
|
+
* @return Элемент.
|
|
45
45
|
*/
|
|
46
46
|
const FieldGrid = ({ children, rootProps }) => {
|
|
47
47
|
const rows = react_1.Children.toArray(children).filter(TypeCheck.isRow);
|
|
@@ -111,7 +111,7 @@ const Row = ({ isFirst: isFirstRow, isLast: isLastRow, children }) => {
|
|
|
111
111
|
* @param props.rounds Скругления для поля (будет задан автоматически).
|
|
112
112
|
* @param props.field Поле.
|
|
113
113
|
* @param props.renderField Должна вернуть поле получив свойства для него.
|
|
114
|
-
* @return
|
|
114
|
+
* @return Элемент.
|
|
115
115
|
*/
|
|
116
116
|
const Cell = ({ size, rounds, field, renderField }) => {
|
|
117
117
|
var _a;
|
|
@@ -127,7 +127,7 @@ const Cell = ({ size, rounds, field, renderField }) => {
|
|
|
127
127
|
className: cx(field.props.className, 'size-full'),
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
return
|
|
130
|
+
return react_1.default.createElement("div", { className: cx('cell', `size-${size}`) }, content);
|
|
131
131
|
};
|
|
132
132
|
exports.FieldGrid.Row = Row;
|
|
133
133
|
exports.FieldGrid.Cell = Cell;
|
package/file-icon/index.js
CHANGED
|
@@ -34,11 +34,10 @@ const VARIANTS = {
|
|
|
34
34
|
const FileIcon = (_a) => {
|
|
35
35
|
var { type } = _a, svgProps = __rest(_a, ["type"]);
|
|
36
36
|
const typeProps = VARIANTS[type];
|
|
37
|
-
return type && typeProps
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
react_1.default.createElement("text", { x: '16', y: '23', textAnchor: 'middle', fontSize: '6.5', fontWeight: '700', fill: '#fff' }, type.toUpperCase()))) : (react_1.default.createElement(unknown_svg_1.default, Object.assign({}, svgProps)));
|
|
37
|
+
return type && typeProps ? (react_1.default.createElement("svg", Object.assign({ width: '32', height: '32', viewBox: '0 0 32 32' }, svgProps),
|
|
38
|
+
react_1.default.createElement("path", { opacity: '0.88', d: 'M6 5C6 3.89543 6.89543 3 8 3H20L26 9V27C26 28.1046 25.1046 29 24 29H8C6.89543 29 6 28.1046 6 27V5Z', fill: typeProps.fill }),
|
|
39
|
+
react_1.default.createElement("path", { opacity: '0.32', d: 'M21 9L26 9L20 3L20 8C20 8.55229 20.4477 9 21 9Z', fill: 'white' }),
|
|
40
|
+
react_1.default.createElement("path", { opacity: '0.24', d: 'M25.1667 9L21 9L26 15L26 9C25.5833 9 25.6269 9 25.1667 9Z', fill: 'black' }),
|
|
41
|
+
react_1.default.createElement("text", { x: '16', y: '23', textAnchor: 'middle', fontSize: '6.5', fontWeight: '700', fill: '#fff' }, type.toUpperCase()))) : (react_1.default.createElement(unknown_svg_1.default, Object.assign({}, svgProps)));
|
|
43
42
|
};
|
|
44
43
|
exports.FileIcon = FileIcon;
|
package/helpers/bounds-of.js
CHANGED
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
* @return Ограничивающий прямоугольник.
|
|
7
7
|
*/
|
|
8
8
|
function boundsOf(element) {
|
|
9
|
-
return (element instanceof Element
|
|
10
|
-
? element.getBoundingClientRect()
|
|
11
|
-
: null);
|
|
9
|
+
return (element instanceof Element ? element.getBoundingClientRect() : null);
|
|
12
10
|
}
|
|
13
11
|
exports.default = boundsOf;
|
|
@@ -14,9 +14,7 @@ const lodash_1 = require("lodash");
|
|
|
14
14
|
*/
|
|
15
15
|
const findChildElement = ({ target, startIndex = 0, increment = 1, defaultResult = -1, isSuitable, needBreakLoop = lodash_1.identity, }) => {
|
|
16
16
|
let result = defaultResult;
|
|
17
|
-
if (target
|
|
18
|
-
&& target.children
|
|
19
|
-
&& isSuitable !== undefined) {
|
|
17
|
+
if (target && target.children && isSuitable !== undefined) {
|
|
20
18
|
const { children } = target;
|
|
21
19
|
for (let i = startIndex; i >= 0 && i < children.length; i += increment) {
|
|
22
20
|
const sibling = children[i];
|
|
@@ -9,9 +9,10 @@ exports.findOffsetParent = void 0;
|
|
|
9
9
|
const findOffsetParent = (element) => {
|
|
10
10
|
let parent = element.offsetParent || document.body;
|
|
11
11
|
if (getComputedStyle(parent).position === 'static') {
|
|
12
|
-
parent =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
parent =
|
|
13
|
+
getComputedStyle(document.documentElement).position === 'static'
|
|
14
|
+
? null
|
|
15
|
+
: document.documentElement;
|
|
15
16
|
}
|
|
16
17
|
return parent;
|
|
17
18
|
};
|
|
@@ -9,7 +9,7 @@ exports.fitElementHeight = void 0;
|
|
|
9
9
|
const fitElementHeight = ({ target }) => {
|
|
10
10
|
target.style.height = 'auto';
|
|
11
11
|
// актуальные значения после установки "auto" (в начало функции не переносить)
|
|
12
|
-
const { scrollHeight, offsetHeight, clientHeight
|
|
12
|
+
const { scrollHeight, offsetHeight, clientHeight } = target;
|
|
13
13
|
target.style.height = `${scrollHeight + offsetHeight - clientHeight}px`;
|
|
14
14
|
};
|
|
15
15
|
exports.fitElementHeight = fitElementHeight;
|
package/helpers/format-date.js
CHANGED
|
@@ -21,7 +21,9 @@ const createDateFormatter = ({ formatFrom = ['yyyy-MM-dd', 'dd.MM.yyyy'], format
|
|
|
21
21
|
const date = (0, exports.parseMultiple)(dateString, formatFrom, new Date());
|
|
22
22
|
let result = invalidPlaceholder;
|
|
23
23
|
if ((0, isValid_1.default)(date)) {
|
|
24
|
-
result = (0, format_1.default)(date, (0, lodash_1.isFunction)(formatTo) ? formatTo(new Date(date.getTime())) : formatTo, {
|
|
24
|
+
result = (0, format_1.default)(date, (0, lodash_1.isFunction)(formatTo) ? formatTo(new Date(date.getTime())) : formatTo, {
|
|
25
|
+
locale: ru_1.default,
|
|
26
|
+
});
|
|
25
27
|
}
|
|
26
28
|
return result;
|
|
27
29
|
};
|
|
@@ -8,8 +8,6 @@ exports.getFractionDepth = void 0;
|
|
|
8
8
|
*/
|
|
9
9
|
const getFractionDepth = (fraction = null) => {
|
|
10
10
|
const fractionString = Number(fraction).toString();
|
|
11
|
-
return fractionString.includes('.')
|
|
12
|
-
? fractionString.length - fractionString.indexOf('.') - 1
|
|
13
|
-
: 0;
|
|
11
|
+
return fractionString.includes('.') ? fractionString.length - fractionString.indexOf('.') - 1 : 0;
|
|
14
12
|
};
|
|
15
13
|
exports.getFractionDepth = getFractionDepth;
|
|
@@ -24,6 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.useBreakpoint = exports.BreakpointProvider = void 0;
|
|
26
26
|
const react_1 = __importStar(require("react"));
|
|
27
|
+
const __1 = require("..");
|
|
27
28
|
const is_browser_1 = __importDefault(require("../../helpers/is-browser"));
|
|
28
29
|
const utils_1 = require("./utils");
|
|
29
30
|
const Context = (0, react_1.createContext)(null);
|
|
@@ -34,7 +35,7 @@ const Context = (0, react_1.createContext)(null);
|
|
|
34
35
|
*/
|
|
35
36
|
const BreakpointProvider = ({ children }) => {
|
|
36
37
|
const [contextValue, setRegistry] = (0, react_1.useState)(null);
|
|
37
|
-
(0,
|
|
38
|
+
(0, __1.useIsomorphicLayoutEffect)(() => {
|
|
38
39
|
(0, is_browser_1.default)() && setRegistry((0, utils_1.createRegistry)());
|
|
39
40
|
}, []);
|
|
40
41
|
return react_1.default.createElement(Context.Provider, { value: contextValue }, children);
|
|
@@ -51,7 +52,7 @@ const useBreakpoint = (query) => {
|
|
|
51
52
|
}
|
|
52
53
|
const registry = (0, react_1.useContext)(Context);
|
|
53
54
|
const [matches, setMatches] = (0, react_1.useState)(false);
|
|
54
|
-
(0,
|
|
55
|
+
(0, __1.useIsomorphicLayoutEffect)(() => {
|
|
55
56
|
if (registry) {
|
|
56
57
|
const subscription = registry.subscribe(query, e => {
|
|
57
58
|
setMatches(e.matches);
|
package/hooks/identity.d.ts
CHANGED
package/hooks/identity.js
CHANGED
package/hooks/index.d.ts
CHANGED
|
@@ -21,3 +21,8 @@ export declare const useInfiniteScroll: (ref: React.MutableRefObject<HTMLElement
|
|
|
21
21
|
* @param callback Сработает при клике вне элемента.
|
|
22
22
|
*/
|
|
23
23
|
export declare const useOutsideClick: (elementRef: React.MutableRefObject<HTMLElement | undefined | null>, callback: (e: MouseEvent) => void) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Нужен для того чтобы не получать ошибку при использовании в SSR с NodeJS.
|
|
26
|
+
* @see {@link https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85#gistcomment-2911761}
|
|
27
|
+
*/
|
|
28
|
+
export declare const useIsomorphicLayoutEffect: typeof React.useEffect;
|
package/hooks/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useOutsideClick = exports.useInfiniteScroll = exports.useIsTouchDevice = void 0;
|
|
6
|
+
exports.useIsomorphicLayoutEffect = exports.useOutsideClick = exports.useInfiniteScroll = exports.useIsTouchDevice = void 0;
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const is_touch_device_1 = require("../helpers/is-touch-device");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
@@ -32,7 +32,7 @@ const useInfiniteScroll = (ref, { onFullScroll, threshold = 0, }) => {
|
|
|
32
32
|
const { current: element } = ref;
|
|
33
33
|
if (element) {
|
|
34
34
|
return (0, on_1.default)(element, 'scroll', (event) => {
|
|
35
|
-
const { scrollTop, clientHeight, scrollHeight
|
|
35
|
+
const { scrollTop, clientHeight, scrollHeight } = event.target;
|
|
36
36
|
const bottom = threshold + scrollTop + clientHeight;
|
|
37
37
|
const isFullyScrolled = bottom >= scrollHeight;
|
|
38
38
|
if (isFullyScrolled && onFullScroll) {
|
|
@@ -62,3 +62,8 @@ const useOutsideClick = (elementRef, callback) => {
|
|
|
62
62
|
}), []);
|
|
63
63
|
};
|
|
64
64
|
exports.useOutsideClick = useOutsideClick;
|
|
65
|
+
/**
|
|
66
|
+
* Нужен для того чтобы не получать ошибку при использовании в SSR с NodeJS.
|
|
67
|
+
* @see {@link https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85#gistcomment-2911761}
|
|
68
|
+
*/
|
|
69
|
+
exports.useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react_1.useLayoutEffect : react_1.useEffect;
|
package/layout/index.js
CHANGED
|
@@ -42,7 +42,7 @@ const cx = bind_1.default.bind(layout_module_scss_1.default);
|
|
|
42
42
|
* Возвращает созданный функциональный компонент, формирующий Layout.
|
|
43
43
|
* @param specificClass Специальный класс.
|
|
44
44
|
* @param displayName Отображаемое имя компонента.
|
|
45
|
-
* @return
|
|
45
|
+
* @return Элемент.
|
|
46
46
|
*/
|
|
47
47
|
const createLayout = (specificClass, displayName) => {
|
|
48
48
|
const Component = (0, react_1.forwardRef)((_a, ref) => {
|
package/link/index.js
CHANGED
|
@@ -45,9 +45,7 @@ const cx = bind_1.default.bind(link_module_scss_1.default);
|
|
|
45
45
|
* @param noIndex Флаг запрета индексации.
|
|
46
46
|
* @return Объект со свойствами, формирующими содержимое..
|
|
47
47
|
*/
|
|
48
|
-
const getContentProps = (children, noIndex) => noIndex
|
|
49
|
-
? { dangerouslySetInnerHTML: (0, get_no_index_1.getNoIndex)(children) }
|
|
50
|
-
: { children };
|
|
48
|
+
const getContentProps = (children, noIndex) => noIndex ? { dangerouslySetInnerHTML: (0, get_no_index_1.getNoIndex)(children) } : { children };
|
|
51
49
|
/**
|
|
52
50
|
* Компонент ссылки.
|
|
53
51
|
* @param props Свойства компонента. Поддерживаются свойства span/a.
|
|
@@ -15,4 +15,4 @@ export interface LoadingOverlayProps {
|
|
|
15
15
|
* @param props Свойства.
|
|
16
16
|
* @return Элемент.
|
|
17
17
|
*/
|
|
18
|
-
export declare const LoadingOverlay: ({ style, className, spinnerProps, fill }: LoadingOverlayProps) => JSX.Element;
|
|
18
|
+
export declare const LoadingOverlay: ({ style, className, spinnerProps, fill, }: LoadingOverlayProps) => JSX.Element;
|
package/loading-overlay/index.js
CHANGED
|
@@ -14,6 +14,6 @@ const cx = bind_1.default.bind(loading_overlay_module_scss_1.default);
|
|
|
14
14
|
* @param props Свойства.
|
|
15
15
|
* @return Элемент.
|
|
16
16
|
*/
|
|
17
|
-
const LoadingOverlay = ({ style, className, spinnerProps = {}, fill = true }) => (react_1.default.createElement("div", { className: cx('loading-overlay', fill && 'fill', className), style: style },
|
|
17
|
+
const LoadingOverlay = ({ style, className, spinnerProps = {}, fill = true, }) => (react_1.default.createElement("div", { className: cx('loading-overlay', fill && 'fill', className), style: style },
|
|
18
18
|
react_1.default.createElement(spinner_1.Spinner, Object.assign({}, spinnerProps))));
|
|
19
19
|
exports.LoadingOverlay = LoadingOverlay;
|
package/modal/index.js
CHANGED
|
@@ -68,7 +68,7 @@ exports.Modal = Modal;
|
|
|
68
68
|
const ModalInner = ({ children, height, onClose, scrollDisableOptions = { reserveScrollBarGap: true }, size = 'm', withScrollDisable = false, 'data-testid': testId = 'modal', }) => {
|
|
69
69
|
const layer = (0, layer_1.useLayer)() + 100;
|
|
70
70
|
const rootRef = (0, react_1.useRef)(null);
|
|
71
|
-
const
|
|
71
|
+
const bind = (0, utils_1.useCloseHandler)(onClose);
|
|
72
72
|
const fullscreen = size === 'fullscreen';
|
|
73
73
|
const { header, content, footer, overlap } = (0, define_slots_1.defineSlots)(children, {
|
|
74
74
|
header: slots_1.ModalHeader,
|
|
@@ -88,7 +88,7 @@ const ModalInner = ({ children, height, onClose, scrollDisableOptions = { reserv
|
|
|
88
88
|
'--footer-height': `${footerHeight}px`,
|
|
89
89
|
};
|
|
90
90
|
(0, body_scroll_1.useBodyScrollLock)(rootRef, withScrollDisable, scrollDisableOptions);
|
|
91
|
-
return (react_1.default.createElement("div", Object.assign({ ref: rootRef, className: cx('overlay'), "data-testid": 'modal:overlay', style: { zIndex: layer } },
|
|
91
|
+
return (react_1.default.createElement("div", Object.assign({ ref: rootRef, className: cx('overlay'), "data-testid": 'modal:overlay', style: { zIndex: layer } }, bind),
|
|
92
92
|
react_1.default.createElement("div", { className: cx('modal', `size-${size}`, !fullscreen && shadows_1.BoxShadow.z4), style: style, "data-testid": testId },
|
|
93
93
|
header &&
|
|
94
94
|
(0, react_1.cloneElement)(header, {
|
package/modal/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @
|
|
2
|
+
* Вызывает callback только если клик был начат и закончен по одному и тому же элементу.
|
|
3
|
+
* @param callback Сработает при клике.
|
|
4
|
+
* @return Свойства для целевого элемента.
|
|
4
5
|
*/
|
|
5
6
|
export declare const useCloseHandler: (callback?: (() => void) | undefined) => {
|
|
6
7
|
onMouseUp: ({ target, currentTarget, button }: any) => void;
|
package/modal/utils.js
CHANGED
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useCloseHandler = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
6
|
+
* Вызывает callback только если клик был начат и закончен по одному и тому же элементу.
|
|
7
|
+
* @param callback Сработает при клике.
|
|
8
|
+
* @return Свойства для целевого элемента.
|
|
8
9
|
*/
|
|
9
10
|
const useCloseHandler = (callback) => {
|
|
10
11
|
const mouseDownTarget = (0, react_1.useRef)();
|
|
@@ -14,11 +15,11 @@ const useCloseHandler = (callback) => {
|
|
|
14
15
|
}
|
|
15
16
|
}, []);
|
|
16
17
|
const onMouseUp = (0, react_1.useCallback)(({ target, currentTarget, button }) => {
|
|
17
|
-
callback
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
callback &&
|
|
19
|
+
button === 0 &&
|
|
20
|
+
target === currentTarget &&
|
|
21
|
+
currentTarget === mouseDownTarget.current &&
|
|
22
|
+
callback();
|
|
22
23
|
}, [callback]);
|
|
23
24
|
return { onMouseUp, onMouseDown };
|
|
24
25
|
};
|
package/nav-bar/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
4
4
|
icon?: React.ComponentType<React.SVGAttributes<SVGSVGElement>>;
|
|
5
5
|
stub?: boolean;
|
|
6
6
|
shift?: 'left' | 'right';
|
|
7
|
+
'data-testid'?: string;
|
|
7
8
|
}
|
|
8
9
|
export interface NavBarProps {
|
|
9
10
|
/** Заголовок. */
|
package/nav-bar/index.js
CHANGED
|
@@ -71,6 +71,6 @@ exports.NavBar = NavBar;
|
|
|
71
71
|
*/
|
|
72
72
|
const NavButton = (_a) => {
|
|
73
73
|
var { text, icon: Icon, stub = false, shift, className } = _a, buttonProps = __rest(_a, ["text", "icon", "stub", "shift", "className"]);
|
|
74
|
-
return (react_1.default.createElement("button", Object.assign({}, buttonProps, { type: 'button', className: cx('button', Icon && 'icon', shift === 'left' && 'shift-left', shift === 'right' && 'shift-right', stub && 'stub', className), "aria-hidden": stub }), Icon && !stub ? (react_1.default.createElement(Icon, { fill: colors_1.COLORS.get('gray87'), className: cx('svg'), "aria-hidden": 'true' })) : (text)));
|
|
74
|
+
return (react_1.default.createElement("button", Object.assign({}, (!stub && buttonProps), { type: 'button', className: cx('button', Icon && 'icon', shift === 'left' && 'shift-left', shift === 'right' && 'shift-right', stub && 'stub', className), "aria-hidden": stub }), Icon && !stub ? (react_1.default.createElement(Icon, { fill: colors_1.COLORS.get('gray87'), className: cx('svg'), "aria-hidden": 'true' })) : (text)));
|
|
75
75
|
};
|
|
76
76
|
exports.NavButton = NavButton;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sima-land/ui-nucleons",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.2.2",
|
|
4
4
|
"repository": "ssh://git@github.com:sima-land/ui-nucleons.git",
|
|
5
5
|
"author": "www.sima-land.ru team",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"lodash": "^4.17.21",
|
|
19
19
|
"overlayscrollbars": "^1.13.1",
|
|
20
20
|
"overlayscrollbars-react": "^0.2.2",
|
|
21
|
-
"react-transition-group": "^4.
|
|
21
|
+
"react-transition-group": "^4.4.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@babel/core": "^7.12.10",
|
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
"@babel/preset-react": "^7.12.10",
|
|
29
29
|
"@rushstack/eslint-patch": "^1.0.6",
|
|
30
30
|
"@sima-land/linters": "^2.1.0",
|
|
31
|
-
"@storybook/addon-actions": "^6.3.
|
|
32
|
-
"@storybook/addon-backgrounds": "^6.3.
|
|
33
|
-
"@storybook/addon-docs": "^6.3.
|
|
34
|
-
"@storybook/addon-storysource": "^6.3.
|
|
35
|
-
"@storybook/addons": "^6.3.
|
|
36
|
-
"@storybook/react": "^6.3.
|
|
31
|
+
"@storybook/addon-actions": "^6.3.12",
|
|
32
|
+
"@storybook/addon-backgrounds": "^6.3.12",
|
|
33
|
+
"@storybook/addon-docs": "^6.3.12",
|
|
34
|
+
"@storybook/addon-storysource": "^6.3.12",
|
|
35
|
+
"@storybook/addons": "^6.3.12",
|
|
36
|
+
"@storybook/react": "^6.3.12",
|
|
37
|
+
"@storybook/theming": "^6.3.12",
|
|
37
38
|
"@svgr/core": "^5.5.0",
|
|
38
39
|
"@svgr/plugin-svgo": "^5.5.0",
|
|
39
40
|
"@svgr/webpack": "^5.5.0",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"@types/lodash": "^4.14.168",
|
|
45
46
|
"@types/react": "^17.0.2",
|
|
46
47
|
"@types/react-dom": "^17.0.2",
|
|
48
|
+
"@types/react-transition-group": "^4.4.3",
|
|
47
49
|
"@typescript-eslint/eslint-plugin": "^4.15.2",
|
|
48
50
|
"@typescript-eslint/parser": "^4.15.2",
|
|
49
51
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
|
|
@@ -65,7 +67,7 @@
|
|
|
65
67
|
"lint-staged": "^10.5.4",
|
|
66
68
|
"prettier": "^2.3.2",
|
|
67
69
|
"react": "^17.0.2",
|
|
68
|
-
"react-docgen-typescript": "^1.
|
|
70
|
+
"react-docgen-typescript": "^2.1.1",
|
|
69
71
|
"react-dom": "^17.0.2",
|
|
70
72
|
"rimraf": "^3.0.2",
|
|
71
73
|
"sass": "^1.30.0",
|
|
@@ -93,6 +95,8 @@
|
|
|
93
95
|
"lint:scripts": "eslint --cache src/ --ext .js,.jsx,.ts,.tsx",
|
|
94
96
|
"lint:styles": "stylelint 'src/**/*.{css,scss}'",
|
|
95
97
|
"storybook": "start-storybook -p 9009 -c .storybook",
|
|
96
|
-
"storybook:build": "build-storybook --no-dll --quiet --loglevel error -o build-storybook"
|
|
98
|
+
"storybook:build": "build-storybook --no-dll --quiet --loglevel error -o build-storybook",
|
|
99
|
+
"prettier": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error",
|
|
100
|
+
"prettier:check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error"
|
|
97
101
|
}
|
|
98
102
|
}
|
|
@@ -62,34 +62,32 @@ const BasePagination = ({ total, current, onButtonClick, isButtonSelected = (0,
|
|
|
62
62
|
buttonKeys: exports.BUTTON_TYPES,
|
|
63
63
|
});
|
|
64
64
|
return (react_1.default.createElement("div", { className: (0, utils_1.cx)('base-pagination-wrapper') },
|
|
65
|
-
needPrevButton({ current, total }) &&
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
needPrevButton({ current, total }) &&
|
|
66
|
+
renderButton({
|
|
67
|
+
'aria-label': 'Назад',
|
|
68
|
+
type: exports.BUTTON_TYPES.prev,
|
|
69
|
+
children: exports.BUTTON_CONTENTS.prev,
|
|
70
|
+
onClick: () => onButtonClick && onButtonClick(current - 1),
|
|
71
|
+
page: current - 1,
|
|
72
|
+
}),
|
|
72
73
|
pageButtons.map(({ content, value }, index) => renderButton({
|
|
73
|
-
type: content === exports.BUTTON_TYPES.more
|
|
74
|
-
? exports.BUTTON_TYPES.more
|
|
75
|
-
: undefined,
|
|
74
|
+
type: content === exports.BUTTON_TYPES.more ? exports.BUTTON_TYPES.more : undefined,
|
|
76
75
|
isFirst: index === 0,
|
|
77
76
|
isLast: index === pageButtons.length - 1,
|
|
78
|
-
children: (0, lodash_1.has)(exports.BUTTON_CONTENTS, content)
|
|
79
|
-
? exports.BUTTON_CONTENTS[content]
|
|
80
|
-
: content,
|
|
77
|
+
children: (0, lodash_1.has)(exports.BUTTON_CONTENTS, content) ? exports.BUTTON_CONTENTS[content] : content,
|
|
81
78
|
selected: isButtonSelected(content),
|
|
82
79
|
'aria-label': `Перейти на страницу ${value}`,
|
|
83
80
|
onClick: () => onButtonClick && onButtonClick(value),
|
|
84
81
|
page: value,
|
|
85
82
|
}, index)),
|
|
86
|
-
needNextButton({ current, total }) &&
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
needNextButton({ current, total }) &&
|
|
84
|
+
renderButton({
|
|
85
|
+
'aria-label': 'Вперед',
|
|
86
|
+
type: exports.BUTTON_TYPES.next,
|
|
87
|
+
children: exports.BUTTON_CONTENTS.next,
|
|
88
|
+
onClick: () => onButtonClick && onButtonClick(current + 1),
|
|
89
|
+
page: current + 1,
|
|
90
|
+
})));
|
|
93
91
|
};
|
|
94
92
|
exports.BasePagination = BasePagination;
|
|
95
93
|
const resolveRounded = (0, fp_1.cond)([
|
package/pagination/index.js
CHANGED
|
@@ -12,8 +12,6 @@ const base_pagination_1 = require("./base-pagination");
|
|
|
12
12
|
* @return Элемент.
|
|
13
13
|
*/
|
|
14
14
|
const Pagination = ({ total, current, onChange, renderButton, }) => (react_1.default.createElement(base_pagination_1.BasePagination, { total: total, current: current, renderButton: renderButton, onButtonClick: content => {
|
|
15
|
-
Number.isFinite(content)
|
|
16
|
-
&& onChange
|
|
17
|
-
&& onChange({ value: content });
|
|
15
|
+
Number.isFinite(content) && onChange && onChange({ value: content });
|
|
18
16
|
} }));
|
|
19
17
|
exports.Pagination = Pagination;
|
package/pagination/utils.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare const getPageButtons: ({ current, total, buttonKeys, }: {
|
|
|
41
41
|
* @param props.total Максимальное значение.
|
|
42
42
|
* @return Список номеров.
|
|
43
43
|
*/
|
|
44
|
-
export declare const getCorrectRangeNumbers: ({ current, range: rangeSize, total
|
|
44
|
+
export declare const getCorrectRangeNumbers: ({ current, range: rangeSize, total }: State) => number[];
|
|
45
45
|
/**
|
|
46
46
|
* Возвращает список чисел вокруг заданного.
|
|
47
47
|
* @param props Свойства.
|
|
@@ -50,5 +50,5 @@ export declare const getCorrectRangeNumbers: ({ current, range: rangeSize, total
|
|
|
50
50
|
* @param props.total Максимальное значение.
|
|
51
51
|
* @return Список номеров.
|
|
52
52
|
*/
|
|
53
|
-
export declare const getRangeNumbers: ({ current, range: rangeSize, total
|
|
53
|
+
export declare const getRangeNumbers: ({ current, range: rangeSize, total }: State) => number[];
|
|
54
54
|
export {};
|
package/pagination/utils.js
CHANGED
|
@@ -14,7 +14,10 @@ exports.cx = bind_1.default.bind(pagination_module_scss_1.default);
|
|
|
14
14
|
* @param content Содержимое кнопки.
|
|
15
15
|
* @return Список кнопок.
|
|
16
16
|
*/
|
|
17
|
-
const PageButton = (value, content = value) => ({
|
|
17
|
+
const PageButton = (value, content = value) => ({
|
|
18
|
+
value,
|
|
19
|
+
content,
|
|
20
|
+
});
|
|
18
21
|
exports.PageButton = PageButton;
|
|
19
22
|
/**
|
|
20
23
|
* Возвращает список кнопок навигации.
|
|
@@ -40,9 +43,7 @@ const getPageButtons = ({ current, total, buttonKeys = { more: '...' }, }) => {
|
|
|
40
43
|
else {
|
|
41
44
|
list.unshift((0, exports.PageButton)(1),
|
|
42
45
|
// не выводим многоточие когда вместо него можно поставить одно число
|
|
43
|
-
list[0].value === 3
|
|
44
|
-
? (0, exports.PageButton)(2)
|
|
45
|
-
: (0, exports.PageButton)(list[0].value - 1, buttonKeys.more));
|
|
46
|
+
list[0].value === 3 ? (0, exports.PageButton)(2) : (0, exports.PageButton)(list[0].value - 1, buttonKeys.more));
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
if (list[list.length - 1].value < total) {
|
|
@@ -72,7 +73,7 @@ exports.getPageButtons = getPageButtons;
|
|
|
72
73
|
* @param props.total Максимальное значение.
|
|
73
74
|
* @return Список номеров.
|
|
74
75
|
*/
|
|
75
|
-
const getCorrectRangeNumbers = ({ current, range: rangeSize, total
|
|
76
|
+
const getCorrectRangeNumbers = ({ current, range: rangeSize, total }) => {
|
|
76
77
|
let result = [
|
|
77
78
|
...(0, exports.getRangeNumbers)({
|
|
78
79
|
current,
|
|
@@ -99,7 +100,7 @@ exports.getCorrectRangeNumbers = getCorrectRangeNumbers;
|
|
|
99
100
|
* @param props.total Максимальное значение.
|
|
100
101
|
* @return Список номеров.
|
|
101
102
|
*/
|
|
102
|
-
const getRangeNumbers = ({ current, range: rangeSize, total
|
|
103
|
+
const getRangeNumbers = ({ current, range: rangeSize, total }) => {
|
|
103
104
|
const pageNumbers = [];
|
|
104
105
|
const readyRange = Math.min(rangeSize, total) || 0;
|
|
105
106
|
const halfRange = Math.floor(readyRange / 2);
|
package/panel/index.js
CHANGED
|
@@ -16,9 +16,7 @@ const cx = bind_1.default.bind(panel_module_scss_1.default);
|
|
|
16
16
|
* @return Элемент.
|
|
17
17
|
*/
|
|
18
18
|
const Panel = ({ color: panelColor = 'gray4', contentColor = 'gray87', inline = false, icon: Icon, className, children, html, 'data-testid': testId = 'panel', }) => {
|
|
19
|
-
const contentProps = html
|
|
20
|
-
? { dangerouslySetInnerHTML: { __html: html } }
|
|
21
|
-
: { children };
|
|
19
|
+
const contentProps = html ? { dangerouslySetInnerHTML: { __html: html } } : { children };
|
|
22
20
|
return (react_1.default.createElement("div", { className: cx('panel', inline && 'inline', (0, colors_1.bgColor)(panelColor), className), "data-testid": testId },
|
|
23
21
|
Icon && (react_1.default.createElement(Icon, { fill: colors_2.COLORS.get(contentColor), width: 16, height: 20, className: cx('icon'), "aria-hidden": 'true' })),
|
|
24
22
|
react_1.default.createElement("div", Object.assign({}, contentProps, { className: cx('content', (0, colors_1.color)(contentColor)) }))));
|
package/phone-input/index.js
CHANGED
|
@@ -83,32 +83,31 @@ const PhoneInput = (_a) => {
|
|
|
83
83
|
react_1.default.createElement("img", { alt: '', width: 24, height: 24, src: country.imageSrc }),
|
|
84
84
|
react_1.default.createElement(AdornmentSVG, { fill: colors_1.COLORS.get('gray38'), className: (0, sizes_1.marginLeft)(1) }))) });
|
|
85
85
|
return (react_1.default.createElement("div", { "data-testid": testId, style: style, className: cx('root', className) },
|
|
86
|
-
country.id === presets_1.IDS.other
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
onBlur
|
|
86
|
+
country.id === presets_1.IDS.other ? (react_1.default.createElement(text_field_1.TextField, Object.assign({}, commonFieldProps, { onChange: (e) => {
|
|
87
|
+
e.target.value = e.target.value.replace(/\D/g, '').slice(0, 20);
|
|
88
|
+
onChange && onChange(e);
|
|
89
|
+
}, onBlur: e => {
|
|
90
|
+
onBlur &&
|
|
91
|
+
onBlur(e, {
|
|
92
92
|
value: e.target.value,
|
|
93
93
|
cleanValue: e.target.value,
|
|
94
94
|
ready: e.target.value.length > 0,
|
|
95
95
|
});
|
|
96
|
-
|
|
96
|
+
} }))) : (react_1.default.createElement(masked_field_1.MaskedField, Object.assign({}, commonFieldProps, {
|
|
97
97
|
// убираем код страны, так как он уже зашит в маску
|
|
98
98
|
value: cleanValue, mask: country.mask, onBlur: (event, state) => {
|
|
99
|
-
onBlur &&
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
onBlur &&
|
|
100
|
+
onBlur(event, Object.assign(Object.assign({}, state), {
|
|
101
|
+
// вставляем код страны обратно в чистое значение
|
|
102
|
+
cleanValue: `${country.codeChars}${state.cleanValue}` }));
|
|
102
103
|
} }))),
|
|
103
|
-
isPopupOpen && (react_1.default.createElement(dropdown_1.Dropdown, { ref: dropdownRef, role: 'menu', className: cx('popup'), "data-testid": 'phone-input:dropdown' }, presets_1.countriesList.map((item, index) => item.id === country.id
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
react_1.default.createElement("span", { className: cx('item-name') }, item.name),
|
|
112
|
-
react_1.default.createElement("span", { className: cx('item-code') }, item.code))))))));
|
|
104
|
+
isPopupOpen && (react_1.default.createElement(dropdown_1.Dropdown, { ref: dropdownRef, role: 'menu', className: cx('popup'), "data-testid": 'phone-input:dropdown' }, presets_1.countriesList.map((item, index) => item.id === country.id ? null : (react_1.default.createElement(dropdown_item_1.DropdownItem, { key: index, size: 'l', role: 'menuitem', className: cx('popup-item'), onClick: () => {
|
|
105
|
+
togglePopup(false);
|
|
106
|
+
setCountry(item);
|
|
107
|
+
onCountrySelect && onCountrySelect(item);
|
|
108
|
+
} },
|
|
109
|
+
react_1.default.createElement("img", { alt: '', width: 24, height: 24, src: item.imageSrc }),
|
|
110
|
+
react_1.default.createElement("span", { className: cx('item-name') }, item.name),
|
|
111
|
+
react_1.default.createElement("span", { className: cx('item-code') }, item.code))))))));
|
|
113
112
|
};
|
|
114
113
|
exports.PhoneInput = PhoneInput;
|
package/portal/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Portal = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const react_dom_1 = require("react-dom");
|
|
6
|
+
const hooks_1 = require("../hooks");
|
|
6
7
|
/**
|
|
7
8
|
* Компонент слоя. Выводит содержимое в портале.
|
|
8
9
|
* @param props Свойства.
|
|
@@ -11,7 +12,7 @@ const react_dom_1 = require("react-dom");
|
|
|
11
12
|
const Portal = ({ children, defineRoot = () => document.body }) => {
|
|
12
13
|
const [mounted, setMounted] = (0, react_1.useState)(false);
|
|
13
14
|
const ref = (0, react_1.useRef)();
|
|
14
|
-
(0,
|
|
15
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
15
16
|
const root = defineRoot();
|
|
16
17
|
ref.current = document.createElement('div');
|
|
17
18
|
root.appendChild(ref.current);
|
|
@@ -20,8 +21,6 @@ const Portal = ({ children, defineRoot = () => document.body }) => {
|
|
|
20
21
|
ref.current && ref.current.remove();
|
|
21
22
|
};
|
|
22
23
|
}, []);
|
|
23
|
-
return mounted && ref.current
|
|
24
|
-
? (0, react_dom_1.createPortal)(children, ref.current)
|
|
25
|
-
: null;
|
|
24
|
+
return mounted && ref.current ? (0, react_dom_1.createPortal)(children, ref.current) : null;
|
|
26
25
|
};
|
|
27
26
|
exports.Portal = Portal;
|
package/price/utils.js
CHANGED
|
@@ -16,9 +16,7 @@ const formatPrice = (value, grapheme, { graphemeBefore } = {}) => {
|
|
|
16
16
|
// целая часть
|
|
17
17
|
(0, exports.formatInteger)(number),
|
|
18
18
|
// дробная часть
|
|
19
|
-
Number.isFinite(number) &&
|
|
20
|
-
!Number.isInteger(number) &&
|
|
21
|
-
`,${(0, exports.formatFractional)(number)}`,
|
|
19
|
+
Number.isFinite(number) && !Number.isInteger(number) && `,${(0, exports.formatFractional)(number)}`,
|
|
22
20
|
// графема после
|
|
23
21
|
grapheme && !graphemeBefore && ` ${grapheme}`,
|
|
24
22
|
]
|