@sima-land/ui-nucleons 44.2.10 → 45.0.0-alpha.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/_internal/custom-scrollbar/index.d.ts +13 -7
- package/_internal/custom-scrollbar/index.js +29 -15
- package/_internal/dropdown-loading/index.d.ts +3 -3
- package/_internal/dropdown-loading/index.js +4 -2
- package/_internal/page-scroll-lock/adapters/body-scroll-lock.d.ts +39 -0
- package/_internal/page-scroll-lock/adapters/body-scroll-lock.js +62 -0
- package/_internal/page-scroll-lock/adapters/ui-nucleons.d.ts +25 -0
- package/_internal/page-scroll-lock/adapters/ui-nucleons.js +103 -0
- package/_internal/page-scroll-lock/context.d.ts +13 -0
- package/_internal/page-scroll-lock/context.js +54 -0
- package/_internal/page-scroll-lock/hook.d.ts +12 -0
- package/_internal/page-scroll-lock/hook.js +26 -0
- package/_internal/page-scroll-lock/index.d.ts +4 -0
- package/_internal/page-scroll-lock/index.js +9 -0
- package/_internal/page-scroll-lock/types.d.ts +22 -0
- package/_internal/{checkbox/index.js → page-scroll-lock/types.js} +0 -0
- package/_internal/readme.md +2 -0
- package/_internal/utils/dropdown.d.ts +1 -0
- package/_internal/utils/dropdown.js +1 -0
- package/alert/alert.module.scss +1 -24
- package/alert/index.d.ts +11 -17
- package/alert/index.js +33 -16
- package/arrow-button/arrow-button.module.scss +2 -0
- package/arrow-button/index.d.ts +2 -2
- package/autocomplete/autocomplete.d.ts +8 -0
- package/autocomplete/autocomplete.js +190 -0
- package/autocomplete/autocomplete.module.scss +2 -15
- package/autocomplete/index.d.ts +2 -27
- package/autocomplete/index.js +2 -126
- package/autocomplete/types.d.ts +19 -0
- package/autocomplete/types.js +2 -0
- package/autocomplete-deprecated/autocomplete.module.scss +20 -0
- package/autocomplete-deprecated/index.d.ts +28 -0
- package/autocomplete-deprecated/index.js +130 -0
- package/avatar/index.d.ts +2 -2
- package/avatar/user.d.ts +1 -1
- package/base-input/base-input.d.ts +11 -0
- package/base-input/base-input.js +96 -0
- package/base-input/base-input.module.scss +3 -3
- package/base-input/index.d.ts +2 -23
- package/base-input/index.js +2 -76
- package/base-input/types.d.ts +31 -0
- package/base-input/types.js +2 -0
- package/base-input/utils.d.ts +6 -0
- package/base-input/utils.js +14 -0
- package/base-input-deprecated/base-input.module.scss +66 -0
- package/base-input-deprecated/index.d.ts +24 -0
- package/base-input-deprecated/index.js +80 -0
- package/bordered-layout/index.d.ts +1 -0
- package/bordered-layout/index.js +1 -0
- package/bottom-bar/bottom-bar-util.scss +20 -0
- package/bottom-bar/bottom-bar.d.ts +12 -0
- package/bottom-bar/bottom-bar.js +47 -0
- package/bottom-bar/bottom-bar.module.scss +14 -0
- package/bottom-bar/index.d.ts +2 -21
- package/bottom-bar/index.js +5 -44
- package/bottom-bar/types.d.ts +10 -0
- package/bottom-bar/types.js +2 -0
- package/box/index.d.ts +1 -1
- package/breakpoints.scss +1 -1
- package/button/button.module.scss +70 -53
- package/button/index.d.ts +26 -41
- package/button/index.js +22 -46
- package/card/index.d.ts +2 -1
- package/card/index.js +23 -6
- package/card/slots.d.ts +17 -3
- package/card/slots.js +15 -13
- package/carousel/draggable.d.ts +7 -3
- package/carousel/draggable.js +10 -3
- package/carousel/helpers/draggable-event.d.ts +5 -2
- package/carousel/helpers/draggable-event.js +5 -0
- package/carousel/index.d.ts +1 -1
- package/carousel/index.js +24 -24
- package/checkbox/checkbox.module.scss +1 -0
- package/checkbox/index.d.ts +3 -3
- package/checkbox-field/index.d.ts +3 -0
- package/checkbox-field/index.js +3 -0
- package/clean-buttons/clean-buttons-util.scss +15 -0
- package/clean-buttons/clean-buttons.module.scss +5 -3
- package/clean-buttons/index.d.ts +16 -7
- package/clean-buttons/index.js +17 -14
- package/clean-buttons/types.d.ts +1 -1
- package/clean-buttons/utils.d.ts +5 -1
- package/clean-buttons/utils.js +4 -0
- package/{colors.d.ts → colors/index.d.ts} +1 -1
- package/{colors.js → colors/index.js} +0 -0
- package/dot-nav/index.d.ts +1 -1
- package/dropdown/index.d.ts +1 -0
- package/dropdown/utils.d.ts +19 -0
- package/dropdown/utils.js +45 -0
- package/dropdown-item/dropdown-item.module.scss +80 -15
- package/dropdown-item/index.d.ts +20 -9
- package/dropdown-item/index.js +12 -9
- package/dropdown-item/types.d.ts +3 -0
- package/dropdown-item/types.js +2 -0
- package/dropdown-item/utils.d.ts +45 -0
- package/dropdown-item/utils.js +89 -0
- package/expandable/utils.js +3 -3
- package/field-block/field-block.module.scss +155 -0
- package/field-block/index.d.ts +63 -0
- package/field-block/index.js +43 -0
- package/field-grid/index.d.ts +5 -4
- package/field-grid/index.js +1 -0
- package/helpers/bounds-of.d.ts +5 -1
- package/helpers/bounds-of.js +5 -0
- package/helpers/center-of.d.ts +4 -1
- package/helpers/center-of.js +8 -1
- package/helpers/create-container.d.ts +5 -2
- package/helpers/create-container.js +7 -2
- package/helpers/define-slots.d.ts +3 -3
- package/helpers/define-slots.js +5 -3
- package/helpers/events.d.ts +16 -8
- package/helpers/events.js +41 -15
- package/helpers/find-child-element.d.ts +12 -9
- package/helpers/find-child-element.js +9 -5
- package/helpers/find-offset-parent.d.ts +1 -2
- package/helpers/find-offset-parent.js +2 -2
- package/helpers/find-sibling-index.d.ts +11 -8
- package/helpers/find-sibling-index.js +8 -3
- package/helpers/fit-element-height.d.ts +5 -5
- package/helpers/fit-element-height.js +9 -7
- package/helpers/format-date.d.ts +11 -11
- package/helpers/format-date.js +15 -13
- package/helpers/format-number.d.ts +1 -1
- package/helpers/format-number.js +2 -2
- package/helpers/get-date-interval-data.d.ts +4 -1
- package/helpers/get-date-interval-data.js +7 -2
- package/helpers/get-declination.d.ts +5 -1
- package/helpers/get-declination.js +5 -0
- package/helpers/get-fraction-depth.d.ts +1 -1
- package/helpers/get-fraction-depth.js +2 -2
- package/helpers/get-no-index.d.ts +2 -2
- package/helpers/get-no-index.js +4 -3
- package/helpers/get-relative-pos.d.ts +4 -1
- package/helpers/get-relative-pos.js +7 -2
- package/helpers/get-scroll-parent.d.ts +1 -2
- package/helpers/get-scroll-parent.js +5 -5
- package/helpers/is-browser.d.ts +4 -1
- package/helpers/is-browser.js +8 -1
- package/helpers/is-fully-scrolled.d.ts +3 -3
- package/helpers/is-fully-scrolled.js +2 -2
- package/helpers/is-touch-device.d.ts +1 -1
- package/helpers/is-touch-device.js +4 -5
- package/helpers/layer.d.ts +1 -1
- package/helpers/layer.js +2 -2
- package/helpers/max-index-of.d.ts +4 -1
- package/helpers/max-index-of.js +7 -2
- package/helpers/media-query-list.d.ts +1 -1
- package/helpers/media-query-list.js +2 -2
- package/helpers/on.d.ts +4 -1
- package/helpers/on.js +7 -2
- package/helpers/point.d.ts +4 -1
- package/helpers/point.js +8 -1
- package/helpers/rename.d.ts +3 -1
- package/helpers/rename.js +1 -0
- package/helpers/scroll-to-child.d.ts +1 -1
- package/helpers/scroll-to-child.js +3 -2
- package/helpers/styles.d.ts +8 -2
- package/helpers/styles.js +18 -4
- package/helpers/with-prevent.d.ts +9 -6
- package/helpers/with-prevent.js +16 -9
- package/hint/hint-view.d.ts +26 -0
- package/hint/hint-view.js +43 -0
- package/hint/hint-view.module.scss +31 -0
- package/hint/hint.d.ts +14 -0
- package/hint/hint.js +41 -0
- package/hint/index.d.ts +5 -8
- package/hint/index.js +13 -48
- package/hint/utils.d.ts +61 -0
- package/hint/utils.js +161 -0
- package/{hint → hint-deprecated}/hint.module.scss +0 -0
- package/hint-deprecated/index.d.ts +11 -0
- package/hint-deprecated/index.js +53 -0
- package/hooks/breakpoint/index.d.ts +7 -4
- package/hooks/breakpoint/index.js +21 -13
- package/hooks/breakpoint/types.d.ts +3 -4
- package/hooks/breakpoint/utils.d.ts +2 -1
- package/hooks/breakpoint/utils.js +2 -1
- package/hooks/index.d.ts +8 -8
- package/hooks/index.js +27 -19
- package/hooks/intersection/test-utils.d.ts +1 -1
- package/hooks/intersection/test-utils.js +2 -1
- package/hooks/styles.d.ts +6 -0
- package/hooks/styles.js +26 -0
- package/info-text/index.d.ts +23 -0
- package/info-text/index.js +60 -0
- package/info-text/info-text.module.scss +28 -0
- package/input/index.d.ts +32 -0
- package/input/index.js +96 -0
- package/input/input.module.scss +20 -0
- package/input/utils.d.ts +36 -0
- package/input/utils.js +71 -0
- package/layout/index.d.ts +6 -11
- package/layout/index.js +6 -60
- package/layout/layout.d.ts +10 -0
- package/layout/layout.js +32 -0
- package/layout/layout.module.scss +33 -26
- package/layout/legacy.d.ts +15 -0
- package/layout/legacy.js +68 -0
- package/layout/legacy.module.scss +49 -0
- package/layout/types.d.ts +6 -0
- package/layout/types.js +2 -0
- package/link/index.d.ts +4 -1
- package/link/index.js +2 -2
- package/link/link.module.scss +10 -0
- package/loading-overlay/index.d.ts +1 -0
- package/loading-overlay/index.js +1 -0
- package/masked-field/index.d.ts +1 -0
- package/masked-field/index.js +1 -0
- package/masked-input/hook.d.ts +8 -0
- package/masked-input/hook.js +72 -0
- package/masked-input/index.d.ts +5 -0
- package/masked-input/index.js +7 -0
- package/masked-input/masked-input.d.ts +8 -0
- package/masked-input/masked-input.js +73 -0
- package/masked-input/types.d.ts +51 -0
- package/masked-input/types.js +2 -0
- package/masked-input/utils.d.ts +15 -0
- package/masked-input/utils.js +49 -0
- package/modal/index.d.ts +10 -12
- package/modal/index.js +27 -64
- package/modal/modal.module.scss +98 -55
- package/modal/slots.d.ts +13 -10
- package/modal/slots.js +30 -28
- package/modal/utils.d.ts +8 -10
- package/modal/utils.js +2 -26
- package/modal-overlay/index.d.ts +13 -0
- package/modal-overlay/index.js +60 -0
- package/modal-overlay/modal-overlay-util.scss +1 -0
- package/modal-overlay/modal-overlay.module.scss +14 -0
- package/modal-overlay/utils.d.ts +14 -0
- package/modal-overlay/utils.js +32 -0
- package/package.json +49 -41
- package/pagination/utils.d.ts +2 -2
- package/panel/index.d.ts +27 -13
- package/panel/index.js +43 -9
- package/panel/panel.module.scss +49 -8
- package/phone-input/index.d.ts +4 -28
- package/phone-input/index.js +2 -121
- package/phone-input/phone-input.d.ts +8 -0
- package/phone-input/phone-input.js +133 -0
- package/phone-input/phone-input.module.scss +8 -32
- package/phone-input/presets.d.ts +21 -22
- package/phone-input/presets.js +1 -2
- package/phone-input/types.d.ts +6 -0
- package/phone-input/types.js +2 -0
- package/phone-input/utils.d.ts +30 -1
- package/phone-input/utils.js +52 -3
- package/phone-input-deprecated/index.d.ts +29 -0
- package/phone-input-deprecated/index.js +124 -0
- package/phone-input-deprecated/phone-input.module.scss +41 -0
- package/plate/index.d.ts +3 -3
- package/plate/index.js +2 -2
- package/plate/plate.module.scss +3 -0
- package/popup/index.d.ts +5 -0
- package/popup/index.js +12 -0
- package/popup/popup-view.d.ts +14 -0
- package/popup/popup-view.js +35 -0
- package/popup/popup-view.module.scss +40 -0
- package/popup/popup.d.ts +17 -0
- package/popup/popup.js +73 -0
- package/popup/utils.d.ts +38 -0
- package/popup/utils.js +83 -0
- package/price/index.d.ts +1 -1
- package/price/index.js +3 -3
- package/price/utils.d.ts +5 -5
- package/price/utils.js +33 -23
- package/radio-button/index.d.ts +10 -0
- package/radio-button/index.js +33 -0
- package/radio-button/radio-button.module.scss +46 -0
- package/rating/index.d.ts +2 -1
- package/rating/types.d.ts +1 -1
- package/readme.md +34 -41
- package/screen/index.d.ts +4 -2
- package/screen/index.js +34 -3
- package/screen/screen.module.scss +0 -2
- package/screen/slots.d.ts +2 -8
- package/screen/slots.js +8 -9
- package/screen/utils.d.ts +2 -1
- package/select/index.d.ts +2 -33
- package/select/index.js +3 -109
- package/select/parts/block.d.ts +8 -0
- package/select/parts/block.js +70 -0
- package/select/parts/block.module.scss +3 -0
- package/select/parts/button.d.ts +8 -0
- package/select/parts/button.js +69 -0
- package/select/parts/menu.d.ts +8 -0
- package/select/parts/menu.js +105 -0
- package/select/parts/menu.module.scss +4 -0
- package/select/select.d.ts +14 -0
- package/select/select.js +145 -0
- package/select/types.d.ts +55 -0
- package/select/types.js +2 -0
- package/select/utils.d.ts +3 -0
- package/select/utils.js +13 -0
- package/select-deprecated/index.d.ts +34 -0
- package/select-deprecated/index.js +112 -0
- package/{select → select-deprecated}/select.module.scss +0 -0
- package/shadows.scss +18 -0
- package/side-page/index.d.ts +11 -26
- package/side-page/index.js +21 -26
- package/side-page/side-page.module.scss +35 -29
- package/side-page/slots.d.ts +12 -20
- package/side-page/slots.js +16 -28
- package/spinner/index.d.ts +18 -6
- package/spinner/index.js +25 -12
- package/spinner/spinner.module.scss +8 -0
- package/stepper/index.d.ts +18 -10
- package/stepper/index.js +17 -8
- package/stepper/stepper.module.scss +14 -15
- package/styling/fonts.d.ts +3 -3
- package/switcher-row/index.d.ts +42 -0
- package/switcher-row/index.js +59 -0
- package/switcher-row/switcher-row.module.scss +55 -0
- package/text/index.d.ts +1 -1
- package/text-button/index.d.ts +42 -0
- package/text-button/index.js +46 -0
- package/text-button/text-button.module.scss +99 -0
- package/text-field/index.d.ts +7 -6
- package/text-field/index.js +3 -2
- package/textarea/index.d.ts +21 -0
- package/textarea/index.js +85 -0
- package/textarea/textarea.module.scss +15 -0
- package/toggle/index.d.ts +3 -3
- package/toggle/toggle.module.scss +17 -8
- package/tooltip/index.d.ts +1 -0
- package/tooltip/index.js +1 -0
- package/top-bar/index.d.ts +3 -40
- package/top-bar/index.js +4 -60
- package/top-bar/top-bar-util.scss +29 -0
- package/top-bar/top-bar.d.ts +9 -0
- package/top-bar/top-bar.js +101 -0
- package/top-bar/top-bar.module.scss +129 -67
- package/top-bar/types.d.ts +31 -0
- package/top-bar/types.js +2 -0
- package/top-bar/utils.d.ts +14 -0
- package/top-bar/utils.js +56 -0
- package/touch-slider/index.d.ts +1 -0
- package/touch-slider/index.js +3 -2
- package/types.d.ts +18 -0
- package/types.js +2 -0
- package/unknown-content/index.d.ts +3 -3
- package/unknown-content/index.js +3 -3
- package/unknown-content/unknown-content.module.scss +16 -12
- package/upload-area/index.d.ts +2 -0
- package/upload-area/index.js +5 -0
- package/upload-area/types.d.ts +32 -0
- package/upload-area/types.js +2 -0
- package/upload-area/upload-area-util.scss +17 -0
- package/upload-area/upload-area.d.ts +8 -0
- package/upload-area/upload-area.js +105 -0
- package/upload-area/upload-area.module.scss +78 -0
- package/{upload → upload-area}/upload.svg +0 -0
- package/upload-area/utils.d.ts +17 -0
- package/upload-area/utils.js +48 -0
- package/utils.scss +74 -1
- package/with-hint/index.d.ts +3 -2
- package/with-hint/index.js +1 -0
- package/with-hint/positioning-hint.d.ts +1 -1
- package/with-hint/positioning-hint.js +2 -2
- package/with-tooltip/index.d.ts +2 -1
- package/with-tooltip/index.js +1 -0
- package/with-tooltip/utils.d.ts +2 -2
- package/_internal/body-scroll.d.ts +0 -23
- package/_internal/body-scroll.js +0 -41
- package/_internal/checkbox/index.d.ts +0 -5
- package/constants.d.ts +0 -6
- package/constants.js +0 -9
- package/nav-bar/index.d.ts +0 -46
- package/nav-bar/index.js +0 -76
- package/nav-bar/nav-bar.module.scss +0 -95
- package/upload/area.d.ts +0 -25
- package/upload/area.js +0 -65
- package/upload/area.module.scss +0 -44
- package/upload/utils.d.ts +0 -29
- package/upload/utils.js +0 -45
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInputMaskStore = exports.actions = void 0;
|
|
4
|
+
/* eslint-disable require-jsdoc, jsdoc/require-jsdoc */
|
|
5
|
+
const core_1 = require("@krutoo/input-mask/dist/core");
|
|
6
|
+
const utils_1 = require("@krutoo/input-mask/dist/dom/utils");
|
|
7
|
+
const redux_1 = require("redux");
|
|
8
|
+
exports.actions = {
|
|
9
|
+
manualChange: createAction('manual/change'),
|
|
10
|
+
inputChange: createAction('input/change'),
|
|
11
|
+
inputSelectionChange: createAction('input/selection-change'),
|
|
12
|
+
};
|
|
13
|
+
function createInputMaskStore(options, initialState) {
|
|
14
|
+
const reducer = createDomReducer(options);
|
|
15
|
+
return (0, redux_1.legacy_createStore)(reducer, initialState);
|
|
16
|
+
}
|
|
17
|
+
exports.createInputMaskStore = createInputMaskStore;
|
|
18
|
+
function createDomReducer(options) {
|
|
19
|
+
const innerReducer = (0, core_1.createReducer)(options);
|
|
20
|
+
function processState(a, b) {
|
|
21
|
+
return innerReducer(a, (0, core_1.defineChanges)(a, b));
|
|
22
|
+
}
|
|
23
|
+
const initialState = utils_1.State.init(options);
|
|
24
|
+
return function reducer(state = initialState, action) {
|
|
25
|
+
let result = state;
|
|
26
|
+
if (exports.actions.inputChange.is(action)) {
|
|
27
|
+
result = processState(state, utils_1.State.fromTarget(action.payload.input));
|
|
28
|
+
}
|
|
29
|
+
else if (exports.actions.inputSelectionChange.is(action)) {
|
|
30
|
+
result = utils_1.State.fromTarget(action.payload.input);
|
|
31
|
+
}
|
|
32
|
+
else if (exports.actions.manualChange.is(action)) {
|
|
33
|
+
// мы не знаем какое значение передано (clean или masked) поэтому берем из него только подходящие символы
|
|
34
|
+
const validCleanValue = action.payload.value
|
|
35
|
+
.split('')
|
|
36
|
+
.filter(c => c.match(options.pattern))
|
|
37
|
+
.join('');
|
|
38
|
+
const newMaskedValue = utils_1.Value.toMasked(options, validCleanValue);
|
|
39
|
+
const firstPlace = options.mask.indexOf(options.placeholder);
|
|
40
|
+
result = processState(utils_1.State.of(state.value, utils_1.Range.of(firstPlace, state.value.length)), utils_1.State.of(newMaskedValue, utils_1.Range.of(newMaskedValue.length)));
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function createAction(type) {
|
|
46
|
+
const creator = payload => ({ type, payload });
|
|
47
|
+
creator.is = (action) => action.type === type;
|
|
48
|
+
return creator;
|
|
49
|
+
}
|
package/modal/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ModalBody, ModalFooter, ModalHeader, ModalOverlap } from './slots';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export interface ModalProps extends
|
|
3
|
+
import { WithPageScrollLock } from '../_internal/page-scroll-lock';
|
|
4
|
+
export type ModalSize = 's' | 'm' | 'l' | 'xl' | 'fullscreen';
|
|
5
|
+
export interface ModalProps extends WithPageScrollLock {
|
|
6
6
|
/** Содержимое компонента. */
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
/** Высота в пикселях. */
|
|
@@ -16,17 +16,15 @@ export interface ModalProps extends WithBodyScrollLock {
|
|
|
16
16
|
/** Идентификатор для систем автоматизированного тестирования. */
|
|
17
17
|
'data-testid'?: string;
|
|
18
18
|
}
|
|
19
|
-
export interface ModalComponent {
|
|
20
|
-
(props: ModalProps): JSX.Element;
|
|
21
|
-
Header: typeof ModalHeader;
|
|
22
|
-
Body: typeof ModalBody;
|
|
23
|
-
Footer: typeof ModalFooter;
|
|
24
|
-
Overlap: typeof ModalOverlap;
|
|
25
|
-
}
|
|
26
19
|
/**
|
|
27
20
|
* Компонент модального окна.
|
|
28
21
|
* @param props Свойства.
|
|
29
22
|
* @return Элемент.
|
|
30
23
|
*/
|
|
31
|
-
export declare
|
|
32
|
-
export {
|
|
24
|
+
export declare function Modal({ children, height, onClose, scrollDisableOptions, size, withScrollDisable, 'data-testid': testId, }: ModalProps): JSX.Element;
|
|
25
|
+
export declare namespace Modal {
|
|
26
|
+
var Header: typeof ModalHeader;
|
|
27
|
+
var Body: typeof ModalBody;
|
|
28
|
+
var Footer: typeof ModalFooter;
|
|
29
|
+
var Overlap: typeof ModalOverlap;
|
|
30
|
+
}
|
package/modal/index.js
CHANGED
|
@@ -1,42 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.Modal = void 0;
|
|
30
|
-
const react_1 =
|
|
31
|
-
const top_bar_1 = require("../top-bar");
|
|
32
|
-
const bottom_bar_1 = require("../bottom-bar");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
33
8
|
const utils_1 = require("./utils");
|
|
34
|
-
const shadows_1 = require("../styling/shadows");
|
|
35
|
-
const lodash_1 = require("lodash");
|
|
36
9
|
const slots_1 = require("./slots");
|
|
37
|
-
const
|
|
10
|
+
const modal_overlay_1 = require("../modal-overlay");
|
|
11
|
+
const plate_1 = require("../plate");
|
|
38
12
|
const define_slots_1 = require("../helpers/define-slots");
|
|
39
|
-
const
|
|
13
|
+
const utils_2 = require("../modal-overlay/utils");
|
|
40
14
|
const bind_1 = __importDefault(require("classnames/bind"));
|
|
41
15
|
const modal_module_scss_1 = __importDefault(require("./modal.module.scss"));
|
|
42
16
|
const cx = bind_1.default.bind(modal_module_scss_1.default);
|
|
@@ -45,10 +19,8 @@ const cx = bind_1.default.bind(modal_module_scss_1.default);
|
|
|
45
19
|
* @param props Свойства.
|
|
46
20
|
* @return Элемент.
|
|
47
21
|
*/
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
const rootRef = (0, react_1.useRef)(null);
|
|
51
|
-
const bind = (0, utils_1.useCloseHandler)(onClose);
|
|
22
|
+
function Modal({ children, height, onClose, scrollDisableOptions, size = 'm', withScrollDisable = false, 'data-testid': testId = 'modal', }) {
|
|
23
|
+
const overlayClickBind = (0, utils_2.useExactClick)(onClose);
|
|
52
24
|
const fullscreen = size === 'fullscreen';
|
|
53
25
|
const { header, content, footer, overlap } = (0, define_slots_1.defineSlots)(children, {
|
|
54
26
|
header: slots_1.ModalHeader,
|
|
@@ -56,36 +28,27 @@ const Modal = ({ children, height, onClose, scrollDisableOptions, size = 'm', wi
|
|
|
56
28
|
footer: slots_1.ModalFooter,
|
|
57
29
|
overlap: slots_1.ModalOverlap,
|
|
58
30
|
});
|
|
59
|
-
const topBarSize = fullscreen ? 'm' : 's';
|
|
60
|
-
const headerHeight = header ? top_bar_1.TOP_BAR_HEIGHT[topBarSize] : 0;
|
|
61
|
-
const footerStubHeight = fullscreen ? 0 : 16;
|
|
62
|
-
const footerHeight = footer
|
|
63
|
-
? bottom_bar_1.BOTTOM_BAR_HEIGHT[footer.props.size || bottom_bar_1.BOTTOM_BAR_DEFAULTS.size]
|
|
64
|
-
: footerStubHeight;
|
|
65
31
|
const style = {
|
|
66
|
-
'--modal-height':
|
|
67
|
-
|
|
68
|
-
|
|
32
|
+
'--modal-height': typeof height === 'number' && Number.isFinite(height)
|
|
33
|
+
? `${Math.min(696, height)}px`
|
|
34
|
+
: undefined,
|
|
69
35
|
};
|
|
70
|
-
(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
!footer && !fullscreen && react_1.default.createElement("div", { className: cx('footer-stub') }),
|
|
85
|
-
!fullscreen && overlap && react_1.default.createElement("div", { className: cx('overlap') }, overlap))));
|
|
86
|
-
};
|
|
36
|
+
return (react_1.default.createElement(modal_overlay_1.ModalOverlay, Object.assign({ className: cx('overlay') }, overlayClickBind),
|
|
37
|
+
react_1.default.createElement(plate_1.Plate, { rounds: null, shadow: fullscreen ? null : 'z4', style: style, className: cx('modal', `size-${size}`, header && 'has-header', footer && 'has-footer'), "data-testid": testId },
|
|
38
|
+
react_1.default.createElement(utils_1.ModalContext.Provider, { value: {
|
|
39
|
+
withScrollDisable,
|
|
40
|
+
scrollDisableOptions,
|
|
41
|
+
topBarSize: 'unset',
|
|
42
|
+
bottomBarSize: 'unset',
|
|
43
|
+
} },
|
|
44
|
+
header,
|
|
45
|
+
content,
|
|
46
|
+
footer,
|
|
47
|
+
!footer && !fullscreen && react_1.default.createElement("div", { className: cx('footer-stub') }),
|
|
48
|
+
overlap && (react_1.default.createElement("div", { className: cx('overlap-content'), "data-testid": 'modal:overlap' }, overlap))))));
|
|
49
|
+
}
|
|
87
50
|
exports.Modal = Modal;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
51
|
+
Modal.Header = slots_1.ModalHeader;
|
|
52
|
+
Modal.Body = slots_1.ModalBody;
|
|
53
|
+
Modal.Footer = slots_1.ModalFooter;
|
|
54
|
+
Modal.Overlap = slots_1.ModalOverlap;
|
package/modal/modal.module.scss
CHANGED
|
@@ -1,62 +1,101 @@
|
|
|
1
1
|
@use '../colors';
|
|
2
|
+
@use '../breakpoints';
|
|
3
|
+
@use '../top-bar/top-bar-util';
|
|
4
|
+
@use '../bottom-bar/bottom-bar-util';
|
|
2
5
|
|
|
3
|
-
$max-height: 696px;
|
|
6
|
+
$modal-max-height: 696px;
|
|
7
|
+
|
|
8
|
+
@mixin regular-modal {
|
|
9
|
+
height: var(--modal-height, auto);
|
|
10
|
+
max-height: min(#{$modal-max-height}, calc(100vh - 32px));
|
|
11
|
+
min-height: 232px;
|
|
12
|
+
border-radius: 8px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@mixin fullscreen-modal {
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: calc(100 * var(--vh, 1vh));
|
|
18
|
+
max-height: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@mixin medium-header {
|
|
22
|
+
&.has-header {
|
|
23
|
+
--modal-header-height: #{top-bar-util.$size-m-height};
|
|
24
|
+
.header {
|
|
25
|
+
@include top-bar-util.size-m;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@mixin large-header {
|
|
31
|
+
&.has-header {
|
|
32
|
+
--modal-header-height: #{top-bar-util.$size-xl-height};
|
|
33
|
+
.header {
|
|
34
|
+
@include top-bar-util.size-xl;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@mixin medium-footer {
|
|
40
|
+
&.has-footer {
|
|
41
|
+
--modal-footer-height: #{bottom-bar-util.$size-m-height};
|
|
42
|
+
.footer {
|
|
43
|
+
@include bottom-bar-util.size-m;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@mixin large-footer {
|
|
49
|
+
&.has-footer {
|
|
50
|
+
--modal-footer-height: #{bottom-bar-util.$size-l-height};
|
|
51
|
+
.footer {
|
|
52
|
+
@include bottom-bar-util.size-l;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
4
56
|
|
|
5
57
|
.overlay {
|
|
6
|
-
background: rgba(0, 0, 0, 0.24);
|
|
7
|
-
overflow: auto;
|
|
8
|
-
position: fixed;
|
|
9
58
|
display: flex;
|
|
10
59
|
align-items: center;
|
|
11
|
-
|
|
12
|
-
width: 100%;
|
|
13
|
-
right: 0;
|
|
14
|
-
top: 0;
|
|
60
|
+
justify-content: center;
|
|
15
61
|
}
|
|
16
62
|
|
|
17
63
|
.modal {
|
|
18
|
-
|
|
64
|
+
flex-shrink: 0;
|
|
65
|
+
position: relative; // для overlap
|
|
66
|
+
margin: auto; // для корректной прокрутки во flex-контейнере
|
|
19
67
|
display: flex;
|
|
20
68
|
flex-direction: column;
|
|
21
|
-
border-radius: 8px;
|
|
22
|
-
background-color: #fff;
|
|
23
|
-
margin: auto;
|
|
24
|
-
flex-shrink: 0;
|
|
25
69
|
z-index: 1;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
&.size-m {
|
|
32
|
-
width: 640px;
|
|
33
|
-
}
|
|
34
|
-
&.size-l {
|
|
35
|
-
width: 768px;
|
|
36
|
-
}
|
|
37
|
-
&.size-xl {
|
|
38
|
-
width: 960px;
|
|
70
|
+
background-color: #fff;
|
|
71
|
+
@include breakpoints.down('xs') {
|
|
72
|
+
@include fullscreen-modal;
|
|
73
|
+
@include medium-header;
|
|
74
|
+
@include medium-footer;
|
|
39
75
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
76
|
+
@include breakpoints.up('xs') {
|
|
77
|
+
&:not(.size-fullscreen) {
|
|
78
|
+
@include regular-modal;
|
|
79
|
+
@include medium-header;
|
|
80
|
+
@include medium-footer;
|
|
81
|
+
&.size-s {
|
|
82
|
+
width: 480px;
|
|
83
|
+
}
|
|
84
|
+
&.size-m {
|
|
85
|
+
width: 640px;
|
|
86
|
+
}
|
|
87
|
+
&.size-l {
|
|
88
|
+
width: 768px;
|
|
89
|
+
}
|
|
90
|
+
&.size-xl {
|
|
91
|
+
width: 960px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
&.size-fullscreen {
|
|
95
|
+
@include fullscreen-modal;
|
|
96
|
+
@include large-header;
|
|
97
|
+
@include large-footer;
|
|
47
98
|
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.overlap {
|
|
52
|
-
position: absolute;
|
|
53
|
-
top: 0;
|
|
54
|
-
left: 0;
|
|
55
|
-
width: 100%;
|
|
56
|
-
height: 100%;
|
|
57
|
-
pointer-events: none;
|
|
58
|
-
* {
|
|
59
|
-
pointer-events: auto;
|
|
60
99
|
}
|
|
61
100
|
}
|
|
62
101
|
|
|
@@ -67,25 +106,29 @@ $max-height: 696px;
|
|
|
67
106
|
|
|
68
107
|
.body {
|
|
69
108
|
flex-grow: 1;
|
|
70
|
-
max-height: calc(
|
|
71
|
-
var(--modal-height, #{$max-height}) - var(--header-height) - var(--footer-height)
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.main {
|
|
76
|
-
display: flex;
|
|
77
|
-
flex-direction: column;
|
|
78
|
-
height: 100%;
|
|
79
|
-
flex-grow: 1;
|
|
80
109
|
}
|
|
81
110
|
|
|
82
111
|
.footer {
|
|
112
|
+
flex-shrink: 0;
|
|
83
113
|
border-radius: 0 0 8px 8px;
|
|
84
114
|
overflow: hidden;
|
|
85
115
|
}
|
|
86
116
|
|
|
87
117
|
.footer-stub {
|
|
118
|
+
flex-shrink: 0;
|
|
88
119
|
border-radius: 0 0 8px 8px;
|
|
89
120
|
height: 16px;
|
|
90
121
|
background: #fff;
|
|
91
122
|
}
|
|
123
|
+
|
|
124
|
+
.overlap-content {
|
|
125
|
+
position: absolute;
|
|
126
|
+
top: 0;
|
|
127
|
+
left: 0;
|
|
128
|
+
width: 100%;
|
|
129
|
+
height: 100%;
|
|
130
|
+
pointer-events: none;
|
|
131
|
+
* {
|
|
132
|
+
pointer-events: auto;
|
|
133
|
+
}
|
|
134
|
+
}
|
package/modal/slots.d.ts
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { TopBarProps } from '../top-bar';
|
|
3
3
|
import { BottomBarProps } from '../bottom-bar';
|
|
4
|
-
export interface ModalHeaderProps extends TopBarProps {
|
|
4
|
+
export interface ModalHeaderProps extends Omit<TopBarProps, 'size'> {
|
|
5
5
|
onBack?: () => void;
|
|
6
6
|
onClose?: () => void;
|
|
7
7
|
}
|
|
8
|
+
export type ModalFooterProps = Omit<BottomBarProps, 'size'>;
|
|
8
9
|
/**
|
|
9
10
|
* Шапка окна.
|
|
10
11
|
* @param props Свойства.
|
|
11
12
|
* @return Элемент.
|
|
12
13
|
*/
|
|
13
|
-
export declare
|
|
14
|
+
export declare function ModalHeader({ className, onBack, onClose, buttons, ...rest }: ModalHeaderProps): JSX.Element;
|
|
14
15
|
/**
|
|
15
16
|
* Основной контент окна.
|
|
16
17
|
* @param props Свойства.
|
|
17
18
|
* @return Элемент.
|
|
18
19
|
*/
|
|
19
|
-
export declare
|
|
20
|
-
children?:
|
|
21
|
-
fullScrollThreshold?: number
|
|
22
|
-
onFullScroll?: (
|
|
23
|
-
})
|
|
20
|
+
export declare function ModalBody({ children, onFullScroll, fullScrollThreshold, }: {
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
fullScrollThreshold?: number;
|
|
23
|
+
onFullScroll?: () => void;
|
|
24
|
+
}): JSX.Element;
|
|
24
25
|
/**
|
|
25
26
|
* Футер окна.
|
|
26
27
|
* @param props Свойства.
|
|
27
28
|
* @return Элемент.
|
|
28
29
|
*/
|
|
29
|
-
export declare
|
|
30
|
+
export declare function ModalFooter({ className, ...rest }: ModalFooterProps): JSX.Element;
|
|
30
31
|
/**
|
|
31
32
|
* Контент который будет выводится поверх окна с абсолютным позиционированием.
|
|
32
33
|
* @param props Свойства.
|
|
33
34
|
* @return Элемент.
|
|
34
35
|
*/
|
|
35
|
-
export declare
|
|
36
|
+
export declare function ModalOverlap({ children }: {
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
}): JSX.Element;
|
package/modal/slots.js
CHANGED
|
@@ -40,58 +40,60 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.ModalOverlap = exports.ModalFooter = exports.ModalBody = exports.ModalHeader = void 0;
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
42
|
const top_bar_1 = require("../top-bar");
|
|
43
|
-
const
|
|
44
|
-
const arrow_left_1 = __importDefault(require("@sima-land/ui-quarks/icons/24x24/Stroked/arrow-left"));
|
|
43
|
+
const utils_1 = require("../top-bar/utils");
|
|
45
44
|
const bottom_bar_1 = require("../bottom-bar");
|
|
46
45
|
const custom_scrollbar_1 = require("../_internal/custom-scrollbar");
|
|
47
|
-
const modal_module_scss_1 = __importDefault(require("./modal.module.scss"));
|
|
48
46
|
const viewport_1 = require("../context/viewport");
|
|
49
|
-
const
|
|
47
|
+
const utils_2 = require("./utils");
|
|
48
|
+
const page_scroll_lock_1 = require("../_internal/page-scroll-lock");
|
|
49
|
+
const bind_1 = __importDefault(require("classnames/bind"));
|
|
50
|
+
const modal_module_scss_1 = __importDefault(require("./modal.module.scss"));
|
|
51
|
+
const cx = bind_1.default.bind(modal_module_scss_1.default);
|
|
50
52
|
/**
|
|
51
53
|
* Шапка окна.
|
|
52
54
|
* @param props Свойства.
|
|
53
55
|
* @return Элемент.
|
|
54
56
|
*/
|
|
55
|
-
|
|
56
|
-
var { onBack, onClose } = _a,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
onClick: onBack,
|
|
61
|
-
icon: react_1.default.createElement(arrow_left_1.default, null),
|
|
62
|
-
},
|
|
63
|
-
})), (onClose && {
|
|
64
|
-
end: {
|
|
65
|
-
'data-testid': 'modal:close',
|
|
66
|
-
onClick: onClose,
|
|
67
|
-
icon: react_1.default.createElement(cross_1.default, null),
|
|
68
|
-
},
|
|
69
|
-
})), className: modal_module_scss_1.default.header })));
|
|
70
|
-
};
|
|
57
|
+
function ModalHeader(_a) {
|
|
58
|
+
var { className, onBack, onClose, buttons } = _a, rest = __rest(_a, ["className", "onBack", "onClose", "buttons"]);
|
|
59
|
+
const { topBarSize } = (0, react_1.useContext)(utils_2.ModalContext);
|
|
60
|
+
return (react_1.default.createElement(top_bar_1.TopBar, Object.assign({}, rest, { size: topBarSize, buttons: (0, utils_1.navigationButtons)({ buttons, onBack, onClose }), className: cx('header', className) })));
|
|
61
|
+
}
|
|
71
62
|
exports.ModalHeader = ModalHeader;
|
|
72
63
|
/**
|
|
73
64
|
* Основной контент окна.
|
|
74
65
|
* @param props Свойства.
|
|
75
66
|
* @return Элемент.
|
|
76
67
|
*/
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
function ModalBody({ children, onFullScroll, fullScrollThreshold, }) {
|
|
69
|
+
const viewportRef = (0, react_1.useRef)(null);
|
|
70
|
+
const scrollableRef = (0, react_1.useRef)(null);
|
|
71
|
+
const osComponentRef = (0, react_1.useRef)(null);
|
|
72
|
+
const { withScrollDisable, scrollDisableOptions } = (0, react_1.useContext)(utils_2.ModalContext);
|
|
73
|
+
(0, react_1.useImperativeHandle)(scrollableRef, () => (0, custom_scrollbar_1.getViewport)(osComponentRef.current));
|
|
74
|
+
(0, react_1.useImperativeHandle)(viewportRef, () => (0, custom_scrollbar_1.getViewport)(osComponentRef.current));
|
|
75
|
+
(0, page_scroll_lock_1.usePageScrollLock)(scrollableRef, Object.assign({ lockEnabled: withScrollDisable }, scrollDisableOptions));
|
|
76
|
+
return (react_1.default.createElement(viewport_1.ViewportContext.Provider, { value: viewportRef },
|
|
77
|
+
react_1.default.createElement(custom_scrollbar_1.CustomScrollbar, { inFlexBox: true, osComponentRef: osComponentRef, className: modal_module_scss_1.default.body, overflow: { x: 'hidden', y: 'scroll' }, onFullScroll: onFullScroll, fullScrollThreshold: fullScrollThreshold }, children)));
|
|
78
|
+
}
|
|
83
79
|
exports.ModalBody = ModalBody;
|
|
84
80
|
/**
|
|
85
81
|
* Футер окна.
|
|
86
82
|
* @param props Свойства.
|
|
87
83
|
* @return Элемент.
|
|
88
84
|
*/
|
|
89
|
-
|
|
85
|
+
function ModalFooter(_a) {
|
|
86
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
87
|
+
const { bottomBarSize } = (0, react_1.useContext)(utils_2.ModalContext);
|
|
88
|
+
return react_1.default.createElement(bottom_bar_1.BottomBar, Object.assign({}, rest, { size: bottomBarSize, className: cx('footer', className) }));
|
|
89
|
+
}
|
|
90
90
|
exports.ModalFooter = ModalFooter;
|
|
91
91
|
/**
|
|
92
92
|
* Контент который будет выводится поверх окна с абсолютным позиционированием.
|
|
93
93
|
* @param props Свойства.
|
|
94
94
|
* @return Элемент.
|
|
95
95
|
*/
|
|
96
|
-
|
|
96
|
+
function ModalOverlap({ children }) {
|
|
97
|
+
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
98
|
+
}
|
|
97
99
|
exports.ModalOverlap = ModalOverlap;
|
package/modal/utils.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
onMouseDown: ({ button, target }: React.MouseEvent) => void;
|
|
10
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BottomBarProps } from '../bottom-bar';
|
|
3
|
+
import { TopBarProps } from '../top-bar';
|
|
4
|
+
import { WithPageScrollLock } from '../_internal/page-scroll-lock';
|
|
5
|
+
export declare const ModalContext: import("react").Context<WithPageScrollLock & {
|
|
6
|
+
topBarSize?: TopBarProps['size'];
|
|
7
|
+
bottomBarSize?: BottomBarProps['size'];
|
|
8
|
+
}>;
|
package/modal/utils.js
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ModalContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Вызывает callback только если клик был начат и закончен по одному и тому же элементу.
|
|
8
|
-
* @param callback Сработает при клике.
|
|
9
|
-
* @return Свойства для целевого элемента.
|
|
10
|
-
*/
|
|
11
|
-
const useCloseHandler = (callback) => {
|
|
12
|
-
const callbackRef = (0, identity_1.useIdentityRef)(callback);
|
|
13
|
-
const mouseDownTarget = (0, react_1.useRef)();
|
|
14
|
-
const onMouseDown = (0, react_1.useCallback)(({ button, target }) => {
|
|
15
|
-
if (button === 0) {
|
|
16
|
-
mouseDownTarget.current = target;
|
|
17
|
-
}
|
|
18
|
-
}, []);
|
|
19
|
-
const onMouseUp = (0, react_1.useCallback)(({ target, currentTarget, button }) => {
|
|
20
|
-
const fn = callbackRef.current;
|
|
21
|
-
fn &&
|
|
22
|
-
button === 0 &&
|
|
23
|
-
target === currentTarget &&
|
|
24
|
-
currentTarget === mouseDownTarget.current &&
|
|
25
|
-
fn();
|
|
26
|
-
}, []);
|
|
27
|
-
return { onMouseUp, onMouseDown };
|
|
28
|
-
};
|
|
29
|
-
exports.useCloseHandler = useCloseHandler;
|
|
5
|
+
exports.ModalContext = (0, react_1.createContext)({});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes, Ref } from 'react';
|
|
2
|
+
export interface ModalOverlayProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Реф корневого элемента. */
|
|
4
|
+
rootRef?: Ref<HTMLDivElement>;
|
|
5
|
+
/** Идентификатор для систем автоматизированного тестирования. */
|
|
6
|
+
'data-testid'?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Полноэкранное затемнение для модальных компонентов (Alert, Modal, SidePage...).
|
|
10
|
+
* @param props Свойства.
|
|
11
|
+
* @return Элемент.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ModalOverlay({ rootRef, children, className, style, 'data-testid': testId, ...restProps }: ModalOverlayProps): JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.ModalOverlay = void 0;
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const styles_1 = require("../hooks/styles");
|
|
43
|
+
const layer_1 = require("../helpers/layer");
|
|
44
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
45
|
+
const modal_overlay_module_scss_1 = __importDefault(require("./modal-overlay.module.scss"));
|
|
46
|
+
/**
|
|
47
|
+
* Полноэкранное затемнение для модальных компонентов (Alert, Modal, SidePage...).
|
|
48
|
+
* @param props Свойства.
|
|
49
|
+
* @return Элемент.
|
|
50
|
+
*/
|
|
51
|
+
function ModalOverlay(_a) {
|
|
52
|
+
var { rootRef, children, className, style, 'data-testid': testId = 'modal-overlay' } = _a, restProps = __rest(_a, ["rootRef", "children", "className", "style", 'data-testid']);
|
|
53
|
+
const layer = (0, layer_1.useLayer)() + 100;
|
|
54
|
+
const ref = (0, react_1.useRef)(null);
|
|
55
|
+
(0, react_1.useImperativeHandle)(rootRef, () => ref.current);
|
|
56
|
+
(0, styles_1.useViewportHeightUnit)(ref);
|
|
57
|
+
return (react_1.default.createElement(layer_1.LayerProvider, { value: layer },
|
|
58
|
+
react_1.default.createElement("div", Object.assign({}, restProps, { ref: ref, className: (0, classnames_1.default)(modal_overlay_module_scss_1.default.root, className), "data-testid": testId, style: Object.assign(Object.assign({}, style), { zIndex: layer }) }), children)));
|
|
59
|
+
}
|
|
60
|
+
exports.ModalOverlay = ModalOverlay;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
$overlay-color: rgba(0, 0, 0, 0.24);
|