@sima-land/ui-nucleons 43.0.2 → 44.0.0
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/alert/index.js +5 -1
- package/arrow-button/index.d.ts +4 -5
- package/autocomplete/autocomplete.module.scss +6 -0
- package/autocomplete/index.d.ts +1 -9
- package/autocomplete/index.js +35 -37
- package/avatar/index.js +5 -1
- package/avatar/user.js +5 -1
- package/base-input/base-input.module.scss +3 -8
- package/base-input/index.d.ts +2 -2
- package/base-input/index.js +7 -4
- package/bottom-bar/index.js +6 -1
- package/box/index.js +5 -1
- package/button/index.js +5 -1
- package/card/slots.js +5 -1
- package/carousel/draggable.js +5 -1
- package/carousel/index.js +5 -1
- package/checkbox/index.js +5 -1
- package/checkbox-field/index.js +5 -1
- package/chips/index.js +5 -1
- package/clean-buttons/clean-buttons.module.scss +26 -15
- package/clean-buttons/index.d.ts +7 -2
- package/clean-buttons/index.js +16 -10
- package/clean-buttons/types.d.ts +4 -0
- package/clean-buttons/types.js +2 -0
- package/clean-buttons/utils.d.ts +3 -0
- package/clean-buttons/utils.js +5 -0
- package/dot-nav/index.js +5 -1
- package/dropdown/index.js +5 -1
- package/field-grid/index.js +5 -1
- package/helpers/styles.d.ts +0 -1
- package/helpers/styles.js +0 -1
- package/hint/index.js +5 -1
- package/hooks/breakpoint/index.js +5 -1
- package/hooks/identity.d.ts +1 -1
- package/hooks/identity.js +1 -1
- package/hooks/index.js +2 -2
- package/hooks/intersection/index.d.ts +8 -0
- package/hooks/intersection/index.js +26 -0
- package/hooks/intersection/readme.md +55 -0
- package/hooks/intersection/test-utils.d.ts +64 -0
- package/hooks/intersection/test-utils.js +136 -0
- package/hooks/keydown.d.ts +1 -1
- package/hooks/keydown.js +7 -7
- package/layout/index.js +5 -1
- package/link/index.js +5 -1
- package/masked-field/index.js +5 -1
- package/modal/index.js +5 -1
- package/modal/slots.js +5 -1
- package/package.json +44 -45
- package/phone-input/index.js +5 -1
- package/plate/index.js +5 -1
- package/range/index.d.ts +1 -1
- package/range/index.js +6 -1
- package/screen/slots.js +5 -1
- package/select/index.js +5 -1
- package/side-page/index.d.ts +3 -1
- package/side-page/index.js +5 -1
- package/side-page/side-page.module.scss +3 -1
- package/side-page/slots.d.ts +3 -1
- package/side-page/slots.js +6 -1
- package/stepper/index.js +5 -1
- package/stroked-svg/index.js +5 -1
- package/tabs/index.js +5 -1
- package/text/index.js +5 -1
- package/text-field/index.js +5 -1
- package/timer/index.js +5 -1
- package/toggle/index.js +5 -1
- package/tooltip/index.js +5 -1
- package/touch-slider/index.d.ts +1 -0
- package/touch-slider/index.js +3 -4
- package/touch-slider/touch-slider.module.scss +11 -9
- package/unknown-content/index.js +5 -1
- package/utils.scss +9 -0
- package/with-hint/index.js +5 -1
- package/with-hint/positioning-hint.js +5 -1
- package/with-tooltip/index.js +5 -1
- package/with-tooltip/positioning-tooltip.js +5 -1
- package/helpers/intersection-observer.d.ts +0 -40
- package/helpers/intersection-observer.js +0 -60
- package/with-in-viewport-observer/index.d.ts +0 -9
- package/with-in-viewport-observer/index.js +0 -43
package/helpers/styles.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export declare const getTransitionStyle: (duration?: number, property?: string,
|
|
|
11
11
|
*
|
|
12
12
|
* Использовать только "translate3d" для смещения.
|
|
13
13
|
* @see https://stackoverflow.com/a/22312917
|
|
14
|
-
*
|
|
15
14
|
* @param x Смещение по оси x в пикселях.
|
|
16
15
|
* @param y Смещение по оси y в пикселях.
|
|
17
16
|
* @param z Смещение по оси z в пикселях.
|
package/helpers/styles.js
CHANGED
|
@@ -16,7 +16,6 @@ exports.getTransitionStyle = getTransitionStyle;
|
|
|
16
16
|
*
|
|
17
17
|
* Использовать только "translate3d" для смещения.
|
|
18
18
|
* @see https://stackoverflow.com/a/22312917
|
|
19
|
-
*
|
|
20
19
|
* @param x Смещение по оси x в пикселях.
|
|
21
20
|
* @param y Смещение по оси y в пикселях.
|
|
22
21
|
* @param z Смещение по оси z в пикселях.
|
package/hint/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/hooks/identity.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
/**
|
|
3
3
|
* Реф с актуальным переданным значением.
|
|
4
|
-
* Нужен, когда в ref
|
|
4
|
+
* Нужен, когда в ref нужно обновлять значение при каждом рендере.
|
|
5
5
|
* @param value Значение.
|
|
6
6
|
* @return Реф.
|
|
7
7
|
*/
|
package/hooks/identity.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.useIdentityRef = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
/**
|
|
6
6
|
* Реф с актуальным переданным значением.
|
|
7
|
-
* Нужен, когда в ref
|
|
7
|
+
* Нужен, когда в ref нужно обновлять значение при каждом рендере.
|
|
8
8
|
* @param value Значение.
|
|
9
9
|
* @return Реф.
|
|
10
10
|
*/
|
package/hooks/index.js
CHANGED
|
@@ -53,11 +53,11 @@ const useOutsideClick = (elementRef, callback) => {
|
|
|
53
53
|
const callbackRef = (0, identity_1.useIdentityRef)(callback);
|
|
54
54
|
(0, react_1.useEffect)(() => (0, on_1.default)(document.documentElement, 'click', event => {
|
|
55
55
|
const { current: element } = elementRef;
|
|
56
|
-
const { current:
|
|
56
|
+
const { current: handler } = callbackRef;
|
|
57
57
|
element &&
|
|
58
58
|
element !== event.target &&
|
|
59
59
|
!element.contains(event.target) &&
|
|
60
|
-
(
|
|
60
|
+
(handler === null || handler === void 0 ? void 0 : handler(event));
|
|
61
61
|
}), []);
|
|
62
62
|
};
|
|
63
63
|
exports.useOutsideClick = useOutsideClick;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Хук, вызывающий callback при пересечении целевого элемента с областью видимости.
|
|
4
|
+
* @param ref Ref с целевым элементом.
|
|
5
|
+
* @param callback Функция, которая будет вызвана при пересечении целевого элемента с областью видимости.
|
|
6
|
+
* @param options Опции создания IntersectionObserver.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useIntersection(ref: MutableRefObject<HTMLElement | null>, callback: (entry: IntersectionObserverEntry) => void, options?: IntersectionObserverInit): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIntersection = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const identity_1 = require("../identity");
|
|
6
|
+
/**
|
|
7
|
+
* Хук, вызывающий callback при пересечении целевого элемента с областью видимости.
|
|
8
|
+
* @param ref Ref с целевым элементом.
|
|
9
|
+
* @param callback Функция, которая будет вызвана при пересечении целевого элемента с областью видимости.
|
|
10
|
+
* @param options Опции создания IntersectionObserver.
|
|
11
|
+
*/
|
|
12
|
+
function useIntersection(ref, callback, options) {
|
|
13
|
+
const callbackRef = (0, identity_1.useIdentityRef)(callback);
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
const element = ref.current;
|
|
16
|
+
if (element) {
|
|
17
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, entry);
|
|
20
|
+
}, options);
|
|
21
|
+
observer.observe(element);
|
|
22
|
+
return () => observer.disconnect();
|
|
23
|
+
}
|
|
24
|
+
}, [ref, callbackRef, options]);
|
|
25
|
+
}
|
|
26
|
+
exports.useIntersection = useIntersection;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Утилиты для unit-тестирования
|
|
2
|
+
|
|
3
|
+
Утилиты для unit-тестирования (Jest) компонентов, использующих хук `useIntersection`
|
|
4
|
+
|
|
5
|
+
#### Пример компонента
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import { useIntersection } from '@sima-land/ui-nucleons/hooks/intersection';
|
|
9
|
+
|
|
10
|
+
const TestComponent = () => {
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
const [viewing, setViewing] = useState(false);
|
|
13
|
+
|
|
14
|
+
useIntersection(ref, entry => {
|
|
15
|
+
setViewing(entry.isIntersecting);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div ref={ref} data-testid='test-target'>
|
|
20
|
+
{viewing ? 'On screen' : 'Off screen'}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Пример тестов
|
|
27
|
+
|
|
28
|
+
```jsx
|
|
29
|
+
import { IntersectionMock } from '@sima-land/ui-nucleons/hooks/intersection/test-utils';
|
|
30
|
+
|
|
31
|
+
const intersectionMock = new IntersectionMock();
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
intersectionMock.apply();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterAll(() => {
|
|
38
|
+
intersectionMock.restore();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('test component', () => {
|
|
42
|
+
const { asFragment, getByTestId } = render(<TestComponent />);
|
|
43
|
+
const target = getByTestId('test-target');
|
|
44
|
+
|
|
45
|
+
expect(asFragment().textContent).toContain('Off screen');
|
|
46
|
+
|
|
47
|
+
intersectionMock.changeElementState({
|
|
48
|
+
target,
|
|
49
|
+
isIntersecting: true,
|
|
50
|
+
intersectionRatio: 0,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
expect(asFragment().textContent).toContain('On screen');
|
|
54
|
+
});
|
|
55
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare type IntersectionObserverEntryBase = Omit<IntersectionObserverEntry, 'time' | 'rootBounds' | 'boundingClientRect' | 'intersectionRect'>;
|
|
2
|
+
/**
|
|
3
|
+
* Возвращает новый объект, частично реализующий IntersectionObserverEntry.
|
|
4
|
+
* @param base Базовая информация.
|
|
5
|
+
* @return Объект.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createFakeEntry(base: IntersectionObserverEntryBase): IntersectionObserverEntry;
|
|
8
|
+
/**
|
|
9
|
+
* Реализует интерфейс для управления состоянием пересечения элемента с область видимости.
|
|
10
|
+
*/
|
|
11
|
+
export declare class IntersectionMock {
|
|
12
|
+
_original: typeof IntersectionObserver;
|
|
13
|
+
_observers: FakeIntersectionObserver[];
|
|
14
|
+
/** Конструктор. */
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Подменяет глобальный конструктор IntersectionObserver.
|
|
18
|
+
*/
|
|
19
|
+
apply(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Восстанавливает оригинальный глобальный конструктор IntersectionObserver.
|
|
22
|
+
*/
|
|
23
|
+
restore(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Имитирует изменение состояния пересечения элемента с областью видимости.
|
|
26
|
+
* @param entryArg Данные пересечения элемента.
|
|
27
|
+
*/
|
|
28
|
+
changeElementState(entryArg: IntersectionObserverEntryBase): void;
|
|
29
|
+
/**
|
|
30
|
+
* Записывает observer в список зарегистрированных.
|
|
31
|
+
* @param observer Observer.
|
|
32
|
+
*/
|
|
33
|
+
_registerObserver(observer: FakeIntersectionObserver): void;
|
|
34
|
+
/**
|
|
35
|
+
* Удаляет observer из списка зарегистрированных.
|
|
36
|
+
* @param observer Observer.
|
|
37
|
+
*/
|
|
38
|
+
_unregisterObserver(observer: FakeIntersectionObserver): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Имитация IntersectionObserver.
|
|
42
|
+
*/
|
|
43
|
+
export declare class FakeIntersectionObserver implements IntersectionObserver {
|
|
44
|
+
readonly root: Element | Document | null;
|
|
45
|
+
readonly rootMargin: string;
|
|
46
|
+
readonly thresholds: ReadonlyArray<number>;
|
|
47
|
+
_callback: IntersectionObserverCallback;
|
|
48
|
+
_elements: Element[];
|
|
49
|
+
/** @inheritdoc */
|
|
50
|
+
constructor(callback: IntersectionObserverCallback, options?: IntersectionObserverInit);
|
|
51
|
+
/** @inheritdoc */
|
|
52
|
+
observe(element: Element): void;
|
|
53
|
+
/** @inheritdoc */
|
|
54
|
+
unobserve(element: Element): void;
|
|
55
|
+
/** @inheritdoc */
|
|
56
|
+
disconnect(): void;
|
|
57
|
+
/** @inheritdoc */
|
|
58
|
+
takeRecords(): never[];
|
|
59
|
+
/**
|
|
60
|
+
* Запускает callback.
|
|
61
|
+
* @param entry Данные пересечения элемента.
|
|
62
|
+
*/
|
|
63
|
+
_runCallback(entry: IntersectionObserverEntry): void;
|
|
64
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FakeIntersectionObserver = exports.IntersectionMock = exports.createFakeEntry = void 0;
|
|
4
|
+
const test_utils_1 = require("react-dom/test-utils");
|
|
5
|
+
let intersectionMock;
|
|
6
|
+
/**
|
|
7
|
+
* Возвращает новый объект, частично реализующий IntersectionObserverEntry.
|
|
8
|
+
* @param base Базовая информация.
|
|
9
|
+
* @return Объект.
|
|
10
|
+
*/
|
|
11
|
+
function createFakeEntry(base) {
|
|
12
|
+
const entry = Object.assign(Object.assign({}, base), { time: Date.now(),
|
|
13
|
+
/** @inheritdoc */
|
|
14
|
+
get rootBounds() {
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.error('Not implemented in mock');
|
|
17
|
+
return null;
|
|
18
|
+
},
|
|
19
|
+
/** @inheritdoc */
|
|
20
|
+
get boundingClientRect() {
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.error('Not implemented in mock');
|
|
23
|
+
return null;
|
|
24
|
+
},
|
|
25
|
+
/** @inheritdoc */
|
|
26
|
+
get intersectionRect() {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.error('Not implemented in mock');
|
|
29
|
+
return null;
|
|
30
|
+
} });
|
|
31
|
+
return entry;
|
|
32
|
+
}
|
|
33
|
+
exports.createFakeEntry = createFakeEntry;
|
|
34
|
+
/**
|
|
35
|
+
* Реализует интерфейс для управления состоянием пересечения элемента с область видимости.
|
|
36
|
+
*/
|
|
37
|
+
class IntersectionMock {
|
|
38
|
+
/** Конструктор. */
|
|
39
|
+
constructor() {
|
|
40
|
+
this._observers = [];
|
|
41
|
+
this._original = window.IntersectionObserver;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Подменяет глобальный конструктор IntersectionObserver.
|
|
45
|
+
*/
|
|
46
|
+
apply() {
|
|
47
|
+
if (intersectionMock) {
|
|
48
|
+
throw Error('Already mocked');
|
|
49
|
+
}
|
|
50
|
+
intersectionMock = this;
|
|
51
|
+
window.IntersectionObserver = FakeIntersectionObserver;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Восстанавливает оригинальный глобальный конструктор IntersectionObserver.
|
|
55
|
+
*/
|
|
56
|
+
restore() {
|
|
57
|
+
if (window.IntersectionObserver !== FakeIntersectionObserver) {
|
|
58
|
+
throw Error('Not mocked');
|
|
59
|
+
}
|
|
60
|
+
window.IntersectionObserver = this._original;
|
|
61
|
+
intersectionMock = undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Имитирует изменение состояния пересечения элемента с областью видимости.
|
|
65
|
+
* @param entryArg Данные пересечения элемента.
|
|
66
|
+
*/
|
|
67
|
+
changeElementState(entryArg) {
|
|
68
|
+
(0, test_utils_1.act)(() => {
|
|
69
|
+
const entry = createFakeEntry(entryArg);
|
|
70
|
+
for (const observer of this._observers) {
|
|
71
|
+
if (observer._elements.some(e => e === entry.target) &&
|
|
72
|
+
observer.thresholds.includes(entry.intersectionRatio)) {
|
|
73
|
+
observer._runCallback(entry);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Записывает observer в список зарегистрированных.
|
|
80
|
+
* @param observer Observer.
|
|
81
|
+
*/
|
|
82
|
+
_registerObserver(observer) {
|
|
83
|
+
this._observers.push(observer);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Удаляет observer из списка зарегистрированных.
|
|
87
|
+
* @param observer Observer.
|
|
88
|
+
*/
|
|
89
|
+
_unregisterObserver(observer) {
|
|
90
|
+
this._observers.splice(this._observers.indexOf(observer));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.IntersectionMock = IntersectionMock;
|
|
94
|
+
/**
|
|
95
|
+
* Имитация IntersectionObserver.
|
|
96
|
+
*/
|
|
97
|
+
class FakeIntersectionObserver {
|
|
98
|
+
/** @inheritdoc */
|
|
99
|
+
constructor(callback, options = {}) {
|
|
100
|
+
this.root = (options === null || options === void 0 ? void 0 : options.root) || null;
|
|
101
|
+
this.rootMargin = (options === null || options === void 0 ? void 0 : options.rootMargin) || '0px 0px 0px 0px';
|
|
102
|
+
this.thresholds = Array.isArray(options.threshold)
|
|
103
|
+
? options.threshold
|
|
104
|
+
: [options.threshold || 0];
|
|
105
|
+
this._callback = callback;
|
|
106
|
+
this._elements = [];
|
|
107
|
+
intersectionMock === null || intersectionMock === void 0 ? void 0 : intersectionMock._registerObserver(this);
|
|
108
|
+
}
|
|
109
|
+
/** @inheritdoc */
|
|
110
|
+
observe(element) {
|
|
111
|
+
this._elements.push(element);
|
|
112
|
+
}
|
|
113
|
+
/** @inheritdoc */
|
|
114
|
+
unobserve(element) {
|
|
115
|
+
this._elements = this._elements.filter(e => e !== element);
|
|
116
|
+
}
|
|
117
|
+
/** @inheritdoc */
|
|
118
|
+
disconnect() {
|
|
119
|
+
this._elements = [];
|
|
120
|
+
intersectionMock === null || intersectionMock === void 0 ? void 0 : intersectionMock._unregisterObserver(this);
|
|
121
|
+
}
|
|
122
|
+
/** @inheritdoc */
|
|
123
|
+
takeRecords() {
|
|
124
|
+
// eslint-disable-next-line no-console
|
|
125
|
+
console.error('Not implemented in mock');
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Запускает callback.
|
|
130
|
+
* @param entry Данные пересечения элемента.
|
|
131
|
+
*/
|
|
132
|
+
_runCallback(entry) {
|
|
133
|
+
this._callback([entry], this);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.FakeIntersectionObserver = FakeIntersectionObserver;
|
package/hooks/keydown.d.ts
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @param targetKey Клавиша, для которой отслеживается нажатие.
|
|
4
4
|
* @param callback Обработчик нажатия.
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare function useKeydown(targetKey: string, callback: undefined | ((event: KeyboardEvent) => void)): void;
|
package/hooks/keydown.js
CHANGED
|
@@ -5,18 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useKeydown = void 0;
|
|
7
7
|
const react_1 = require("react");
|
|
8
|
+
const identity_1 = require("./identity");
|
|
8
9
|
const on_1 = __importDefault(require("../helpers/on"));
|
|
9
10
|
/**
|
|
10
11
|
* Хук, добавляющий обработчик нажатия на клавишу.
|
|
11
12
|
* @param targetKey Клавиша, для которой отслеживается нажатие.
|
|
12
13
|
* @param callback Обработчик нажатия.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
const ref = (0,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
key === targetKey && fn && fn();
|
|
15
|
+
function useKeydown(targetKey, callback) {
|
|
16
|
+
const ref = (0, identity_1.useIdentityRef)(callback);
|
|
17
|
+
(0, react_1.useEffect)(() => (0, on_1.default)(document, 'keydown', event => {
|
|
18
|
+
const handler = ref.current;
|
|
19
|
+
(event.key === targetKey || event.code === targetKey) && (handler === null || handler === void 0 ? void 0 : handler(event));
|
|
20
20
|
}), [targetKey]);
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
exports.useKeydown = useKeydown;
|
package/layout/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/link/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/masked-field/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/modal/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/modal/slots.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sima-land/ui-nucleons",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "44.0.0",
|
|
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",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@krutoo/input-mask": "^0.0.8",
|
|
13
|
-
"@sima-land/ui-quarks": "^
|
|
13
|
+
"@sima-land/ui-quarks": "^3.0.0",
|
|
14
14
|
"body-scroll-lock": "3.1.5",
|
|
15
15
|
"classnames": "^2.3.1",
|
|
16
|
-
"date-fns": "^2.
|
|
16
|
+
"date-fns": "^2.28.0",
|
|
17
17
|
"intersection-observer": "^0.12.0",
|
|
18
18
|
"lodash": "^4.17.21",
|
|
19
19
|
"overlayscrollbars": "^1.13.1",
|
|
@@ -21,62 +21,61 @@
|
|
|
21
21
|
"react-transition-group": "^4.4.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@babel/core": "^7.
|
|
25
|
-
"@babel/preset-env": "^7.16.
|
|
26
|
-
"@babel/preset-react": "^7.16.
|
|
27
|
-
"@babel/preset-typescript": "^7.16.
|
|
28
|
-
"@rushstack/eslint-patch": "^1.1.
|
|
29
|
-
"@sima-land/linters": "^2.1.
|
|
30
|
-
"@storybook/addon-actions": "^6.4.
|
|
31
|
-
"@storybook/addon-backgrounds": "^6.4.
|
|
32
|
-
"@storybook/addon-docs": "^6.4.
|
|
33
|
-
"@storybook/addon-storysource": "^6.4.
|
|
34
|
-
"@storybook/addons": "^6.4.
|
|
35
|
-
"@storybook/builder-webpack5": "^6.4.
|
|
36
|
-
"@storybook/manager-webpack5": "^6.4.
|
|
37
|
-
"@storybook/react": "^6.4.
|
|
38
|
-
"@storybook/theming": "^6.4.
|
|
39
|
-
"@svgr/core": "^
|
|
40
|
-
"@svgr/plugin-
|
|
41
|
-
"@svgr/
|
|
42
|
-
"@
|
|
24
|
+
"@babel/core": "^7.17.7",
|
|
25
|
+
"@babel/preset-env": "^7.16.11",
|
|
26
|
+
"@babel/preset-react": "^7.16.7",
|
|
27
|
+
"@babel/preset-typescript": "^7.16.7",
|
|
28
|
+
"@rushstack/eslint-patch": "^1.1.1",
|
|
29
|
+
"@sima-land/linters": "^2.1.2",
|
|
30
|
+
"@storybook/addon-actions": "^6.4.19",
|
|
31
|
+
"@storybook/addon-backgrounds": "^6.4.19",
|
|
32
|
+
"@storybook/addon-docs": "^6.4.19",
|
|
33
|
+
"@storybook/addon-storysource": "^6.4.19",
|
|
34
|
+
"@storybook/addons": "^6.4.19",
|
|
35
|
+
"@storybook/builder-webpack5": "^6.4.19",
|
|
36
|
+
"@storybook/manager-webpack5": "^6.4.19",
|
|
37
|
+
"@storybook/react": "^6.4.19",
|
|
38
|
+
"@storybook/theming": "^6.4.19",
|
|
39
|
+
"@svgr/core": "^6.2.1",
|
|
40
|
+
"@svgr/plugin-jsx": "^6.2.1",
|
|
41
|
+
"@svgr/plugin-svgo": "^6.2.0",
|
|
42
|
+
"@svgr/webpack": "^6.2.1",
|
|
43
|
+
"@testing-library/react": "^12.1.4",
|
|
43
44
|
"@types/body-scroll-lock": "^3.1.0",
|
|
44
|
-
"@types/enzyme": "^3.10.
|
|
45
|
-
"@types/jest": "^27.
|
|
46
|
-
"@types/lodash": "^4.14.
|
|
47
|
-
"@types/react": "^17.0.
|
|
48
|
-
"@types/react-dom": "^17.0.
|
|
45
|
+
"@types/enzyme": "^3.10.11",
|
|
46
|
+
"@types/jest": "^27.4.1",
|
|
47
|
+
"@types/lodash": "^4.14.180",
|
|
48
|
+
"@types/react": "^17.0.40",
|
|
49
|
+
"@types/react-dom": "^17.0.13",
|
|
49
50
|
"@types/react-transition-group": "^4.4.4",
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
|
|
53
|
-
"babel-jest": "^27.4.6",
|
|
51
|
+
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
|
|
52
|
+
"babel-jest": "^27.5.1",
|
|
54
53
|
"babel-loader": "^8.2.3",
|
|
55
|
-
"babel-preset-jest": "^27.
|
|
54
|
+
"babel-preset-jest": "^27.5.1",
|
|
56
55
|
"copyfiles": "^2.4.1",
|
|
57
|
-
"css-loader": "^
|
|
56
|
+
"css-loader": "^6.7.1",
|
|
58
57
|
"enzyme": "^3.9.0",
|
|
59
58
|
"enzyme-to-json": "^3.6.2",
|
|
60
|
-
"eslint": "^
|
|
59
|
+
"eslint": "^8.11.0",
|
|
61
60
|
"file-loader": "^6.2.0",
|
|
62
61
|
"handlebars": "^4.7.7",
|
|
63
62
|
"husky": "^7.0.4",
|
|
64
|
-
"jest": "^27.
|
|
63
|
+
"jest": "^27.5.1",
|
|
65
64
|
"jest-css-modules-transform": "^4.3.0",
|
|
66
|
-
"lint-staged": "^12.
|
|
67
|
-
"postcss": "^8.
|
|
68
|
-
"prettier": "^2.
|
|
65
|
+
"lint-staged": "^12.3.5",
|
|
66
|
+
"postcss": "^8.4.11",
|
|
67
|
+
"prettier": "^2.5.1",
|
|
69
68
|
"react": "^17.0.2",
|
|
70
|
-
"react-docgen-typescript": "^2.
|
|
69
|
+
"react-docgen-typescript": "^2.2.2",
|
|
71
70
|
"react-dom": "^17.0.2",
|
|
72
71
|
"rimraf": "^3.0.2",
|
|
73
|
-
"sass": "^1.
|
|
74
|
-
"sass-loader": "^
|
|
75
|
-
"style-loader": "^
|
|
76
|
-
"stylelint": "^14.
|
|
77
|
-
"typescript": "^4.
|
|
72
|
+
"sass": "^1.49.9",
|
|
73
|
+
"sass-loader": "^12.6.0",
|
|
74
|
+
"style-loader": "^3.3.1",
|
|
75
|
+
"stylelint": "^14.5.3",
|
|
76
|
+
"typescript": "^4.6.2",
|
|
78
77
|
"typescript-plugin-css-modules": "^3.4.0",
|
|
79
|
-
"webpack": "^5.
|
|
78
|
+
"webpack": "^5.70.0"
|
|
80
79
|
},
|
|
81
80
|
"peerDependencies": {
|
|
82
81
|
"react": ">=17",
|
package/phone-input/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/plate/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/range/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare class Range extends Component<RangeProps> {
|
|
|
35
35
|
start: Container<number>;
|
|
36
36
|
finish: Container<number>;
|
|
37
37
|
activeBounds: [number, number];
|
|
38
|
-
unsubscribeList
|
|
38
|
+
unsubscribeList: Array<() => void>;
|
|
39
39
|
activeThumbEl?: HTMLElement;
|
|
40
40
|
isGrabbed?: boolean;
|
|
41
41
|
/**
|