@sima-land/ui-nucleons 40.2.1 → 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/identity.d.ts +1 -0
- package/hooks/identity.js +1 -0
- 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/package.json +5 -3
- 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/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/select/index.js +5 -7
- 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/styling/utils.js
CHANGED
|
@@ -14,8 +14,6 @@ const bind_1 = __importDefault(require("classnames/bind"));
|
|
|
14
14
|
*/
|
|
15
15
|
const ClassGetter = (classes, isValidKey, prefix = '') => {
|
|
16
16
|
const cx = bind_1.default.bind(classes);
|
|
17
|
-
return (value) => isValidKey(value)
|
|
18
|
-
? cx(`${prefix}${value}`)
|
|
19
|
-
: undefined;
|
|
17
|
+
return (value) => (isValidKey(value) ? cx(`${prefix}${value}`) : undefined);
|
|
20
18
|
};
|
|
21
19
|
exports.ClassGetter = ClassGetter;
|
package/text-field/index.js
CHANGED
|
@@ -45,7 +45,7 @@ const isVisible = (value) => !(0, lodash_1.isNil)(value) && `${value}` !== '';
|
|
|
45
45
|
* @param modifiers Данные визуальных модификаторов.
|
|
46
46
|
* @return Строка с css-классами.
|
|
47
47
|
*/
|
|
48
|
-
const modifiersToClasses = ({ disabled, failed, focused, variant }) => cx(disabled && 'disabled', failed && 'failed', focused && 'focused', variant && `variant-${variant}`);
|
|
48
|
+
const modifiersToClasses = ({ disabled, failed, focused, variant, }) => cx(disabled && 'disabled', failed && 'failed', focused && 'focused', variant && `variant-${variant}`);
|
|
49
49
|
/**
|
|
50
50
|
* Компонент текстового поля.
|
|
51
51
|
* @param props Свойства.
|
|
@@ -73,20 +73,13 @@ exports.TextField = (0, react_1.forwardRef)(function TextField({ autoFocus, capt
|
|
|
73
73
|
react_1.default.createElement("div", { "data-testid": 'text-field:block', className: cx('reset', 'input-block', commonModifyClasses, size && `size-${size}`, focused && classes.blockFocused, multiline && 'multiline', withLabel && 'with-label', variant === 'desktop' && rounds !== 'none' && shapes_1.SmallRounds[rounds]), onClick: event => {
|
|
74
74
|
const input = baseInputRef.current;
|
|
75
75
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
76
|
-
input
|
|
77
|
-
&& !disabled
|
|
78
|
-
&& input !== document.activeElement
|
|
79
|
-
&& input.focus();
|
|
76
|
+
input && !disabled && input !== document.activeElement && input.focus();
|
|
80
77
|
} },
|
|
81
78
|
!multiline && Boolean(startAdornment) && (react_1.default.createElement(box_1.Box, { display: 'flex', alignItems: 'center', marginRight: 4 }, startAdornment)),
|
|
82
79
|
react_1.default.createElement("div", { className: cx('main-column') },
|
|
83
80
|
withLabel && (react_1.default.createElement("label", { className: cx('label', commonModifyClasses, hasValue && 'filled', labelAsPlaceholder && 'as-placeholder'), children: label })),
|
|
84
81
|
react_1.default.createElement("div", { className: cx('input-wrapper') },
|
|
85
|
-
react_1.default.createElement(base_input_1.BaseInput, Object.assign({}, baseInputProps, { "data-testid": 'text-field:field', multiline: multiline, ref: baseInputRef, placeholder: withLabel && labelAsPlaceholder
|
|
86
|
-
? undefined
|
|
87
|
-
: placeholder, restPlaceholder: withLabel && labelAsPlaceholder
|
|
88
|
-
? undefined
|
|
89
|
-
: restPlaceholder, autoFocus: autoFocus, className: cx('base-input', commonModifyClasses, classes.baseInput, size && `size-${size}`), defaultValue: defaultValue, value: value, readOnly: readOnly, disabled: disabled, onFocus: (event) => {
|
|
82
|
+
react_1.default.createElement(base_input_1.BaseInput, Object.assign({}, baseInputProps, { "data-testid": 'text-field:field', multiline: multiline, ref: baseInputRef, placeholder: withLabel && labelAsPlaceholder ? undefined : placeholder, restPlaceholder: withLabel && labelAsPlaceholder ? undefined : restPlaceholder, autoFocus: autoFocus, className: cx('base-input', commonModifyClasses, classes.baseInput, size && `size-${size}`), defaultValue: defaultValue, value: value, readOnly: readOnly, disabled: disabled, onFocus: (event) => {
|
|
90
83
|
(0, lodash_1.isFunction)(onFocus) && onFocus(event);
|
|
91
84
|
toggleHasValue(Boolean(event.target.value));
|
|
92
85
|
toggleFocused(true);
|
package/timer/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export interface TimerProps {
|
|
|
9
9
|
timeout?: number;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param props
|
|
12
|
+
* Компонент для вывода оставшегося времени до целевой временной отметки.
|
|
13
|
+
* @param props Свойства.
|
|
14
14
|
* @return Элемент.
|
|
15
15
|
*/
|
|
16
|
-
export declare const Timer: ({ date, format, timeout
|
|
16
|
+
export declare const Timer: ({ date, format, timeout }: TimerProps) => JSX.Element;
|
package/timer/index.js
CHANGED
|
@@ -23,11 +23,11 @@ exports.Timer = void 0;
|
|
|
23
23
|
const react_1 = __importStar(require("react"));
|
|
24
24
|
const utils_1 = require("./utils");
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param props
|
|
26
|
+
* Компонент для вывода оставшегося времени до целевой временной отметки.
|
|
27
|
+
* @param props Свойства.
|
|
28
28
|
* @return Элемент.
|
|
29
29
|
*/
|
|
30
|
-
const Timer = ({ date, format = utils_1.formatDistance, timeout = 1000
|
|
30
|
+
const Timer = ({ date, format = utils_1.formatDistance, timeout = 1000 }) => {
|
|
31
31
|
const [distance, setDistance] = (0, react_1.useState)((0, utils_1.getDistanceToNow)(date));
|
|
32
32
|
(0, react_1.useEffect)(() => {
|
|
33
33
|
const timerId = setInterval(() => {
|
|
@@ -36,6 +36,6 @@ const Timer = ({ date, format = utils_1.formatDistance, timeout = 1000, }) => {
|
|
|
36
36
|
setDistance((0, utils_1.getDistanceToNow)(date));
|
|
37
37
|
return () => clearInterval(timerId);
|
|
38
38
|
}, [timeout]);
|
|
39
|
-
return
|
|
39
|
+
return react_1.default.createElement(react_1.default.Fragment, null, format(distance));
|
|
40
40
|
};
|
|
41
41
|
exports.Timer = Timer;
|
package/timer/utils.js
CHANGED
|
@@ -14,10 +14,7 @@ const UNITS = ['day', 'hour', 'minute', 'second'];
|
|
|
14
14
|
* @param distance Оставшееся время.
|
|
15
15
|
* @return Отформатированное время.
|
|
16
16
|
*/
|
|
17
|
-
const formatDistance = ({ days, hours, minutes, seconds }) => [
|
|
18
|
-
days,
|
|
19
|
-
...[hours % 24, minutes % 60, seconds % 60].map(s => `${s}`.padStart(2, '0')),
|
|
20
|
-
].join(':');
|
|
17
|
+
const formatDistance = ({ days, hours, minutes, seconds }) => [days, ...[hours % 24, minutes % 60, seconds % 60].map(s => `${s}`.padStart(2, '0'))].join(':');
|
|
21
18
|
exports.formatDistance = formatDistance;
|
|
22
19
|
/**
|
|
23
20
|
* Возвращает объект с данными об оставшемся времени от текущего момента.
|
package/top-bar/index.js
CHANGED
|
@@ -43,7 +43,7 @@ const TopBar = ({ divided, size = 'm', title, subtitle, buttonsProps: { start, s
|
|
|
43
43
|
hasStartSecondary ? react_1.default.createElement(exports.IconButton, Object.assign({}, startSecondary)) : secondaryStub,
|
|
44
44
|
react_1.default.createElement("div", { className: cx('main-section') },
|
|
45
45
|
react_1.default.createElement("div", { className: cx('title', 'ellipsis') }, title),
|
|
46
|
-
Boolean(subtitle) &&
|
|
46
|
+
Boolean(subtitle) && react_1.default.createElement("div", { className: cx('subtitle', 'ellipsis') }, subtitle)),
|
|
47
47
|
hasEndSecondary ? react_1.default.createElement(exports.IconButton, Object.assign({}, endSecondary)) : secondaryStub,
|
|
48
48
|
hasEnd ? react_1.default.createElement(exports.IconButton, Object.assign({}, end)) : stub));
|
|
49
49
|
};
|
package/upload/area.js
CHANGED
|
@@ -33,7 +33,9 @@ const cx = bind_1.default.bind(area_module_scss_1.default);
|
|
|
33
33
|
const UploadArea = (_a) => {
|
|
34
34
|
var { onSelect, className, fileRole = 'файл', formats, sizeLimit = '2 Mb', multiple, countLimit = multiple ? undefined : 1, failed, 'data-testid': testId = 'upload-area' } = _a, restProps = __rest(_a, ["onSelect", "className", "fileRole", "formats", "sizeLimit", "multiple", "countLimit", "failed", 'data-testid']);
|
|
35
35
|
const secondaryInfo = (0, lodash_1.upperFirst)([
|
|
36
|
-
countLimit &&
|
|
36
|
+
countLimit &&
|
|
37
|
+
countLimit > 0 &&
|
|
38
|
+
`${countLimit} ${(0, get_declination_1.default)(countLimit, ['файл', 'файла', 'файлов'])}`,
|
|
37
39
|
formats && `формат ${formats}`,
|
|
38
40
|
`до ${sizeLimit}`,
|
|
39
41
|
]
|
package/upload/utils.d.ts
CHANGED
|
@@ -16,13 +16,13 @@ declare type DnDResult<T> = {
|
|
|
16
16
|
* @param options Опции.
|
|
17
17
|
* @return Данные.
|
|
18
18
|
*/
|
|
19
|
-
export declare const useDragAndDrop: <T extends HTMLElement = HTMLElement>({ onDrop }: DnDProps<T>) => DnDResult<T>;
|
|
19
|
+
export declare const useDragAndDrop: <T extends HTMLElement = HTMLElement>({ onDrop, }: DnDProps<T>) => DnDResult<T>;
|
|
20
20
|
/**
|
|
21
21
|
* Возвращает функцию обработки FileList по заданным ограничениям.
|
|
22
22
|
* @param props Свойства.
|
|
23
23
|
* @return Функция.
|
|
24
24
|
*/
|
|
25
|
-
export declare const getFilesPreparer: ({ multiple, countLimit
|
|
25
|
+
export declare const getFilesPreparer: ({ multiple, countLimit }: {
|
|
26
26
|
multiple?: boolean | undefined;
|
|
27
27
|
countLimit?: number | undefined;
|
|
28
28
|
}) => (list: File[] | FileList) => File[];
|
package/upload/utils.js
CHANGED
|
@@ -11,7 +11,7 @@ const with_prevent_1 = __importDefault(require("../helpers/with-prevent"));
|
|
|
11
11
|
* @param options Опции.
|
|
12
12
|
* @return Данные.
|
|
13
13
|
*/
|
|
14
|
-
const useDragAndDrop = ({ onDrop }) => {
|
|
14
|
+
const useDragAndDrop = ({ onDrop, }) => {
|
|
15
15
|
const [active, setActive] = (0, react_1.useState)(false);
|
|
16
16
|
return {
|
|
17
17
|
active,
|
|
@@ -35,7 +35,7 @@ exports.useDragAndDrop = useDragAndDrop;
|
|
|
35
35
|
* @param props Свойства.
|
|
36
36
|
* @return Функция.
|
|
37
37
|
*/
|
|
38
|
-
const getFilesPreparer = ({ multiple, countLimit
|
|
38
|
+
const getFilesPreparer = ({ multiple, countLimit }) => (list) => {
|
|
39
39
|
const files = [...list];
|
|
40
40
|
multiple
|
|
41
41
|
? countLimit && Number.isFinite(countLimit) && files.splice(countLimit)
|
|
@@ -8,5 +8,5 @@ interface Props extends HintProps {
|
|
|
8
8
|
* @param props Свойства.
|
|
9
9
|
* @return Элемент.
|
|
10
10
|
*/
|
|
11
|
-
export declare const PositioningHint: ({ children, direction, openerRef
|
|
11
|
+
export declare const PositioningHint: ({ children, direction, openerRef }: Props) => JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -35,7 +35,7 @@ const cx = bind_1.default.bind(positioning_hint_module_scss_1.default);
|
|
|
35
35
|
* @param props Свойства.
|
|
36
36
|
* @return Элемент.
|
|
37
37
|
*/
|
|
38
|
-
const PositioningHint = ({ children, direction, openerRef
|
|
38
|
+
const PositioningHint = ({ children, direction, openerRef }) => {
|
|
39
39
|
const layer = (0, layer_1.useLayer)();
|
|
40
40
|
const ref = (0, react_1.useRef)(null);
|
|
41
41
|
(0, react_1.useEffect)(() => {
|
package/with-hint/utils.js
CHANGED
|
@@ -16,23 +16,23 @@ exports.PlaceAt = {
|
|
|
16
16
|
],
|
|
17
17
|
top: (hint, opener) => {
|
|
18
18
|
const [hintRect, openerRect, correct] = exports.PlaceAt.commons(hint, opener);
|
|
19
|
-
hint.style.left = `${correct.x + openerRect.left +
|
|
19
|
+
hint.style.left = `${correct.x + openerRect.left + openerRect.width / 2 - hintRect.width / 2}px`;
|
|
20
20
|
hint.style.top = `${correct.y - SPACE + openerRect.top - hintRect.height}px`;
|
|
21
21
|
},
|
|
22
22
|
right: (hint, opener) => {
|
|
23
23
|
const [hintRect, openerRect, correct] = exports.PlaceAt.commons(hint, opener);
|
|
24
24
|
hint.style.left = `${correct.x + SPACE + openerRect.right}px`;
|
|
25
|
-
hint.style.top = `${correct.y + openerRect.top +
|
|
25
|
+
hint.style.top = `${correct.y + openerRect.top + openerRect.height / 2 - hintRect.height / 2}px`;
|
|
26
26
|
},
|
|
27
27
|
bottom: (hint, opener) => {
|
|
28
28
|
const [hintRect, openerRect, correct] = exports.PlaceAt.commons(hint, opener);
|
|
29
|
-
hint.style.left = `${correct.x + openerRect.left +
|
|
29
|
+
hint.style.left = `${correct.x + openerRect.left + openerRect.width / 2 - hintRect.width / 2}px`;
|
|
30
30
|
hint.style.top = `${correct.y + SPACE + openerRect.bottom}px`;
|
|
31
31
|
},
|
|
32
32
|
left: (hint, opener) => {
|
|
33
33
|
const [hintRect, openerRect, correct] = exports.PlaceAt.commons(hint, opener);
|
|
34
34
|
hint.style.left = `${correct.x - SPACE + openerRect.left - hintRect.width}px`;
|
|
35
|
-
hint.style.top = `${correct.y + openerRect.top +
|
|
35
|
+
hint.style.top = `${correct.y + openerRect.top + openerRect.height / 2 - hintRect.height / 2}px`;
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
@@ -44,9 +44,7 @@ exports.PlaceAt = {
|
|
|
44
44
|
const onParentScroll = (element, callback) => {
|
|
45
45
|
let scrollParent = (0, get_scroll_parent_1.getScrollParent)(element);
|
|
46
46
|
// прокрутка на body не работает с addEventListener, https://stackoverflow.com/a/43632204/13166471
|
|
47
|
-
scrollParent = scrollParent === document.body
|
|
48
|
-
? document
|
|
49
|
-
: scrollParent;
|
|
47
|
+
scrollParent = scrollParent === document.body ? document : scrollParent;
|
|
50
48
|
return (0, on_1.default)(scrollParent, 'scroll', callback);
|
|
51
49
|
};
|
|
52
50
|
exports.onParentScroll = onParentScroll;
|
|
@@ -32,7 +32,7 @@ function makeInViewportObserverHOC(observersDataList) {
|
|
|
32
32
|
* @param props Свойства для оборачиваемого компонента.
|
|
33
33
|
* @return Компонент высшего порядка.
|
|
34
34
|
*/
|
|
35
|
-
const Wrapper = (props) => react_1.default.createElement(Component, Object.assign({}, { [propName]: addObserve }, props));
|
|
35
|
+
const Wrapper = (props) => (react_1.default.createElement(Component, Object.assign({}, { [propName]: addObserve }, props)));
|
|
36
36
|
Wrapper.displayName = `withInViewportObserver(${Component.displayName || Component.name})`;
|
|
37
37
|
return Wrapper;
|
|
38
38
|
};
|