@salutejs/plasma-core 1.226.1-next-sbcom.0 → 1.227.0-dev.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/__helpers/IconPlaceholder.js +6 -9
- package/__helpers/index.js +1 -1
- package/collectPackageInfo.js +4 -4
- package/components/Badge/Badge.js +30 -103
- package/components/Badge/index.js +1 -1
- package/components/Basebox/Basebox.js +33 -42
- package/components/Basebox/index.js +1 -1
- package/components/Button/Button.js +28 -67
- package/components/Button/Button.mixins.js +22 -76
- package/components/Button/Button.props.js +5 -5
- package/components/Button/createButton.js +14 -145
- package/components/Button/index.js +4 -4
- package/components/Card/Card.js +34 -162
- package/components/Card/CardBody.js +4 -4
- package/components/Card/CardContent.js +14 -23
- package/components/Card/CardMedia.js +20 -91
- package/components/Card/CardPrice.js +18 -60
- package/components/Card/CardTypography.js +43 -52
- package/components/Card/index.js +5 -5
- package/components/Carousel/Carousel.js +46 -64
- package/components/Carousel/CarouselItem.js +21 -93
- package/components/Carousel/hooks.js +62 -121
- package/components/Carousel/index.js +3 -3
- package/components/Carousel/utils.js +59 -73
- package/components/Fade/Fade.js +6 -9
- package/components/Fade/index.js +1 -1
- package/components/Field/Field.js +48 -63
- package/components/Field/Field.statuses.js +3 -3
- package/components/Field/index.js +2 -2
- package/components/Image/Image.js +34 -115
- package/components/Image/index.js +1 -1
- package/components/Input/Input.js +7 -7
- package/components/Input/Input.mixins.js +9 -12
- package/components/Input/index.js +1 -1
- package/components/ModalBase/ModalBase.js +22 -100
- package/components/ModalBase/ModalBaseContext.js +6 -9
- package/components/ModalBase/ModalOverlay.js +28 -111
- package/components/ModalBase/hooks.js +15 -43
- package/components/ModalBase/index.js +2 -2
- package/components/PaginationDots/PaginationDot.js +11 -17
- package/components/PaginationDots/PaginationDots.js +4 -7
- package/components/PaginationDots/index.js +3 -3
- package/components/PaginationDots/usePaginationDots.js +10 -11
- package/components/Popup/Popup.js +52 -205
- package/components/Popup/index.js +1 -1
- package/components/PopupBase/PopupBase.js +35 -169
- package/components/PopupBase/PopupBaseContext.js +26 -86
- package/components/PopupBase/PopupBaseRoot.js +31 -169
- package/components/PopupBase/hooks.js +23 -97
- package/components/PopupBase/index.js +3 -3
- package/components/PopupBase/utils.js +32 -78
- package/components/Price/Price.js +15 -90
- package/components/Price/index.js +1 -1
- package/components/RadioGroup/RadioGroup.js +6 -127
- package/components/RadioGroup/index.js +1 -1
- package/components/SSRProvider/SSRProvider.js +4 -5
- package/components/SSRProvider/index.js +1 -1
- package/components/Skeleton/LineSkeleton.js +23 -95
- package/components/Skeleton/RectSkeleton.js +20 -93
- package/components/Skeleton/Skeleton.js +2 -2
- package/components/Skeleton/TextSkeleton.js +11 -55
- package/components/Skeleton/index.js +3 -3
- package/components/Slider/Double.js +52 -203
- package/components/Slider/Handle.js +28 -158
- package/components/Slider/Single.js +29 -177
- package/components/Slider/Slider.js +5 -7
- package/components/Slider/SliderBase.js +39 -48
- package/components/Slider/ThumbBase.js +19 -95
- package/components/Slider/index.js +3 -3
- package/components/Slider/utils.js +2 -2
- package/components/Spinner/Spinner.js +28 -100
- package/components/Spinner/SpinnerSvg.js +9 -78
- package/components/Spinner/index.js +1 -1
- package/components/Switch/Switch.js +49 -220
- package/components/Switch/index.js +1 -1
- package/components/Tabs/TabItem.js +33 -168
- package/components/Tabs/Tabs.js +32 -170
- package/components/Tabs/TabsContext.js +12 -42
- package/components/Tabs/createTabsController.js +33 -168
- package/components/Tabs/index.js +4 -4
- package/components/TextArea/TextArea.js +20 -30
- package/components/TextArea/index.js +1 -1
- package/components/TextField/index.js +3 -3
- package/components/Toast/Toast.js +15 -16
- package/components/Toast/ToastContext.js +4 -8
- package/components/Toast/ToastController.js +44 -101
- package/components/Toast/ToastProvider.js +37 -142
- package/components/Toast/index.js +3 -3
- package/components/Toast/useToast.js +6 -6
- package/components/Typography/Body.js +18 -18
- package/components/Typography/Button.js +13 -13
- package/components/Typography/Caption.js +8 -8
- package/components/Typography/Display.js +18 -18
- package/components/Typography/Footnote.js +13 -13
- package/components/Typography/Headline.js +43 -43
- package/components/Typography/Paragraph.js +24 -24
- package/components/Typography/Underline.js +8 -8
- package/es/__helpers/IconPlaceholder.js +5 -8
- package/es/collectPackageInfo.js +3 -3
- package/es/components/Badge/Badge.js +27 -100
- package/es/components/Basebox/Basebox.js +28 -37
- package/es/components/Button/Button.js +24 -63
- package/es/components/Button/Button.mixins.js +19 -73
- package/es/components/Button/Button.props.js +3 -3
- package/es/components/Button/createButton.js +12 -143
- package/es/components/Card/Card.js +29 -157
- package/es/components/Card/CardBody.js +2 -2
- package/es/components/Card/CardContent.js +12 -21
- package/es/components/Card/CardMedia.js +17 -88
- package/es/components/Card/CardPrice.js +13 -55
- package/es/components/Card/CardTypography.js +43 -52
- package/es/components/Carousel/Carousel.js +45 -63
- package/es/components/Carousel/CarouselItem.js +18 -90
- package/es/components/Carousel/hooks.js +58 -117
- package/es/components/Carousel/utils.js +58 -72
- package/es/components/Fade/Fade.js +5 -8
- package/es/components/Field/Field.js +44 -59
- package/es/components/Field/Field.statuses.js +4 -4
- package/es/components/Image/Image.js +31 -112
- package/es/components/Input/Input.js +4 -4
- package/es/components/Input/Input.mixins.js +6 -9
- package/es/components/ModalBase/ModalBase.js +16 -94
- package/es/components/ModalBase/ModalBaseContext.js +6 -9
- package/es/components/ModalBase/ModalOverlay.js +23 -106
- package/es/components/ModalBase/hooks.js +12 -40
- package/es/components/PaginationDots/PaginationDot.js +9 -15
- package/es/components/PaginationDots/PaginationDots.js +3 -6
- package/es/components/PaginationDots/usePaginationDots.js +9 -10
- package/es/components/Popup/Popup.js +48 -201
- package/es/components/PopupBase/PopupBase.js +27 -161
- package/es/components/PopupBase/PopupBaseContext.js +25 -85
- package/es/components/PopupBase/PopupBaseRoot.js +26 -164
- package/es/components/PopupBase/hooks.js +21 -95
- package/es/components/PopupBase/utils.js +31 -77
- package/es/components/Price/Price.js +12 -87
- package/es/components/RadioGroup/RadioGroup.js +5 -126
- package/es/components/SSRProvider/SSRProvider.js +3 -4
- package/es/components/Skeleton/LineSkeleton.js +18 -90
- package/es/components/Skeleton/RectSkeleton.js +16 -89
- package/es/components/Skeleton/Skeleton.js +2 -2
- package/es/components/Skeleton/TextSkeleton.js +7 -51
- package/es/components/Slider/Double.js +49 -200
- package/es/components/Slider/Handle.js +23 -153
- package/es/components/Slider/Single.js +26 -174
- package/es/components/Slider/Slider.js +2 -4
- package/es/components/Slider/SliderBase.js +36 -45
- package/es/components/Slider/ThumbBase.js +16 -92
- package/es/components/Slider/index.js +1 -1
- package/es/components/Slider/utils.js +2 -2
- package/es/components/Spinner/Spinner.js +23 -95
- package/es/components/Spinner/SpinnerSvg.js +8 -77
- package/es/components/Switch/Switch.js +45 -216
- package/es/components/Tabs/TabItem.js +28 -163
- package/es/components/Tabs/Tabs.js +28 -166
- package/es/components/Tabs/TabsContext.js +11 -41
- package/es/components/Tabs/createTabsController.js +28 -163
- package/es/components/TextArea/TextArea.js +18 -28
- package/es/components/Toast/Toast.js +10 -11
- package/es/components/Toast/ToastContext.js +3 -7
- package/es/components/Toast/ToastController.js +38 -95
- package/es/components/Toast/ToastProvider.js +34 -139
- package/es/components/Toast/useToast.js +4 -4
- package/es/components/Typography/Body.js +15 -15
- package/es/components/Typography/Button.js +10 -10
- package/es/components/Typography/Caption.js +5 -5
- package/es/components/Typography/Display.js +15 -15
- package/es/components/Typography/Footnote.js +10 -10
- package/es/components/Typography/Headline.js +40 -40
- package/es/components/Typography/Paragraph.js +21 -21
- package/es/components/Typography/Underline.js +5 -5
- package/es/hocs/withAutoFocus.js +8 -78
- package/es/hocs/withSkeleton.js +5 -10
- package/es/hooks/useDebouncedFunction.js +4 -36
- package/es/hooks/useFocusTrap.js +18 -21
- package/es/hooks/useForkRef.js +3 -3
- package/es/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/es/hooks/useResizeObserver.js +8 -8
- package/es/hooks/useUniqId.js +6 -52
- package/es/mixins/addFocus.js +17 -22
- package/es/mixins/applyDisabled.js +6 -9
- package/es/mixins/applyEllipsis.js +2 -4
- package/es/mixins/applyMaxLines.js +3 -6
- package/es/mixins/applyNoSelect.js +2 -4
- package/es/mixins/applyOutline.js +2 -4
- package/es/mixins/applyRoundness.js +4 -7
- package/es/mixins/applyScrollSnap.js +4 -7
- package/es/mixins/applySkeletonGradient.js +6 -9
- package/es/mixins/applyView.js +2 -5
- package/es/mixins/blur.js +2 -5
- package/es/mixins/shadows.js +1 -1
- package/es/tokens/colors.js +48 -48
- package/es/tokens/typography.js +18 -18
- package/es/utils/__tests__/formatters.test.js +2 -2
- package/es/utils/animatedScrollTo.js +24 -34
- package/es/utils/canUseDOM.js +1 -1
- package/es/utils/extractTextFrom.js +3 -7
- package/es/utils/focusManager.js +40 -47
- package/es/utils/formatCurrency.js +4 -4
- package/es/utils/formatters.js +6 -14
- package/es/utils/react.js +4 -4
- package/es/utils/roundness.js +2 -4
- package/es/utils/scopeTab.js +5 -5
- package/es/utils/setRef.js +1 -1
- package/es/utils/tabbable.js +16 -25
- package/es/utils/toCssSize.js +1 -3
- package/es/utils/transformStyles.js +5 -60
- package/hocs/index.js +2 -2
- package/hocs/withAutoFocus.js +9 -79
- package/hocs/withSkeleton.js +8 -13
- package/hooks/index.js +6 -6
- package/hooks/useDebouncedFunction.js +5 -37
- package/hooks/useFocusTrap.js +22 -25
- package/hooks/useForkRef.js +5 -5
- package/hooks/useIsomorphicLayoutEffect.js +3 -3
- package/hooks/useResizeObserver.js +9 -9
- package/hooks/useUniqId.js +8 -54
- package/mixins/addFocus.js +19 -24
- package/mixins/applyDisabled.js +7 -10
- package/mixins/applyEllipsis.js +3 -5
- package/mixins/applyMaxLines.js +4 -7
- package/mixins/applyNoSelect.js +3 -5
- package/mixins/applyOutline.js +3 -5
- package/mixins/applyRoundness.js +5 -8
- package/mixins/applyScrollSnap.js +5 -8
- package/mixins/applySkeletonGradient.js +8 -11
- package/mixins/applyView.js +3 -6
- package/mixins/blur.js +2 -5
- package/mixins/index.js +11 -11
- package/mixins/shadows.js +1 -1
- package/package.json +13 -18
- package/tokens/colors.js +48 -48
- package/tokens/typography.js +18 -18
- package/utils/__tests__/formatters.test.js +3 -3
- package/utils/animatedScrollTo.js +24 -34
- package/utils/canUseDOM.js +1 -1
- package/utils/extractTextFrom.js +4 -8
- package/utils/focusManager.js +41 -48
- package/utils/formatCurrency.js +4 -4
- package/utils/formatters.js +6 -14
- package/utils/index.js +10 -10
- package/utils/react.js +7 -7
- package/utils/roundness.js +2 -4
- package/utils/scopeTab.js +6 -6
- package/utils/setRef.js +1 -1
- package/utils/tabbable.js +16 -25
- package/utils/toCssSize.js +1 -3
- package/utils/transformStyles.js +5 -60
|
@@ -1,67 +1,3 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
function _object_spread(target) {
|
|
15
|
-
for(var i = 1; i < arguments.length; i++){
|
|
16
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
-
var ownKeys = Object.keys(source);
|
|
18
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
ownKeys.forEach(function(key) {
|
|
24
|
-
_define_property(target, key, source[key]);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
}
|
|
29
|
-
function _object_without_properties(source, excluded) {
|
|
30
|
-
if (source == null) return {};
|
|
31
|
-
var target = {}, sourceKeys, key, i;
|
|
32
|
-
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
33
|
-
sourceKeys = Reflect.ownKeys(source);
|
|
34
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
35
|
-
key = sourceKeys[i];
|
|
36
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
37
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
38
|
-
target[key] = source[key];
|
|
39
|
-
}
|
|
40
|
-
return target;
|
|
41
|
-
}
|
|
42
|
-
target = _object_without_properties_loose(source, excluded);
|
|
43
|
-
if (Object.getOwnPropertySymbols) {
|
|
44
|
-
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
45
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
46
|
-
key = sourceKeys[i];
|
|
47
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
48
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
49
|
-
target[key] = source[key];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return target;
|
|
53
|
-
}
|
|
54
|
-
function _object_without_properties_loose(source, excluded) {
|
|
55
|
-
if (source == null) return {};
|
|
56
|
-
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
57
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
58
|
-
key = sourceKeys[i];
|
|
59
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
60
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
61
|
-
target[key] = source[key];
|
|
62
|
-
}
|
|
63
|
-
return target;
|
|
64
|
-
}
|
|
65
1
|
import React, { useCallback, useMemo } from 'react';
|
|
66
2
|
import styled, { css } from 'styled-components';
|
|
67
3
|
import { DEFAULT_Z_INDEX } from '../PopupBase/PopupBaseRoot';
|
|
@@ -69,50 +5,32 @@ import { usePopupBaseContext } from '../PopupBase';
|
|
|
69
5
|
import { getIdLastModal } from './ModalBaseContext';
|
|
70
6
|
/*
|
|
71
7
|
* Класс компонента ModalBaseOverlay: `modal-base-overlay`
|
|
72
|
-
*/ export
|
|
8
|
+
*/ export const modalBaseOverlayClass = 'modal-base-overlay';
|
|
73
9
|
// TODO: новый отдельный оверлей #778
|
|
74
|
-
export
|
|
10
|
+
export const Overlay = styled.div.withConfig({
|
|
75
11
|
displayName: "ModalOverlay__Overlay",
|
|
76
12
|
componentId: "sc-e7f59b8c-0"
|
|
77
13
|
})([
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
],
|
|
84
|
-
|
|
14
|
+
`position:fixed;width:100%;height:100%;top:0;left:0;`,
|
|
15
|
+
` `,
|
|
16
|
+
`;background-color:`,
|
|
17
|
+
`;backdrop-filter:var(--backdrop-filter);cursor:`,
|
|
18
|
+
`;`
|
|
19
|
+
], ({ zIndex })=>css([
|
|
20
|
+
`z-index:`,
|
|
21
|
+
`;`
|
|
22
|
+
], zIndex || DEFAULT_Z_INDEX), ({ $withBlur })=>{
|
|
85
23
|
return css([
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, function(param) {
|
|
90
|
-
var $withBlur = param.$withBlur;
|
|
91
|
-
return css([
|
|
92
|
-
"--background-color:",
|
|
93
|
-
";--backdrop-filter:",
|
|
94
|
-
";"
|
|
24
|
+
`--background-color:`,
|
|
25
|
+
`;--backdrop-filter:`,
|
|
26
|
+
`;`
|
|
95
27
|
], $withBlur ? 'var(--plasma-modal-blur-overlay-color)' : 'var(--plasma-modal-overlay-color)', $withBlur ? 'blur(1rem)' : 'none');
|
|
96
|
-
},
|
|
97
|
-
var transparent = param.transparent;
|
|
98
|
-
return transparent ? 'transparent' : 'var(--background-color)';
|
|
99
|
-
}, function(param) {
|
|
100
|
-
var clickable = param.clickable;
|
|
101
|
-
return clickable ? 'pointer' : 'default';
|
|
102
|
-
});
|
|
28
|
+
}, ({ transparent })=>transparent ? 'transparent' : 'var(--background-color)', ({ clickable })=>clickable ? 'pointer' : 'default');
|
|
103
29
|
/**
|
|
104
30
|
* ModalOverlay - подложка для ModalBase.
|
|
105
|
-
*/ export
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"withBlur",
|
|
109
|
-
"onOverlayClick",
|
|
110
|
-
"onClose",
|
|
111
|
-
"zIndex",
|
|
112
|
-
"closeOnOverlayClick"
|
|
113
|
-
]);
|
|
114
|
-
var popupController = usePopupBaseContext();
|
|
115
|
-
var onModalOverlayKeyDown = useCallback(function(event) {
|
|
31
|
+
*/ export const ModalOverlay = ({ id, withBlur, onOverlayClick, onClose, zIndex, closeOnOverlayClick = true, ...rest })=>{
|
|
32
|
+
const popupController = usePopupBaseContext();
|
|
33
|
+
const onModalOverlayKeyDown = useCallback((event)=>{
|
|
116
34
|
if (!closeOnOverlayClick) {
|
|
117
35
|
return;
|
|
118
36
|
}
|
|
@@ -128,18 +46,17 @@ export var Overlay = styled.div.withConfig({
|
|
|
128
46
|
onOverlayClick,
|
|
129
47
|
onClose
|
|
130
48
|
]);
|
|
131
|
-
|
|
132
|
-
return getIdLastModal(popupController.items) !== id;
|
|
133
|
-
}, [
|
|
49
|
+
const transparent = useMemo(()=>getIdLastModal(popupController.items) !== id, [
|
|
134
50
|
id,
|
|
135
51
|
popupController.items
|
|
136
52
|
]);
|
|
137
|
-
return /*#__PURE__*/ React.createElement(Overlay,
|
|
53
|
+
return /*#__PURE__*/ React.createElement(Overlay, {
|
|
138
54
|
className: modalBaseOverlayClass,
|
|
139
55
|
transparent: transparent,
|
|
140
56
|
clickable: closeOnOverlayClick,
|
|
141
57
|
onClick: onModalOverlayKeyDown,
|
|
142
58
|
zIndex: zIndex,
|
|
143
|
-
$withBlur: withBlur
|
|
144
|
-
|
|
59
|
+
$withBlur: withBlur,
|
|
60
|
+
...rest
|
|
61
|
+
});
|
|
145
62
|
};
|
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
function _object_spread(target) {
|
|
15
|
-
for(var i = 1; i < arguments.length; i++){
|
|
16
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
-
var ownKeys = Object.keys(source);
|
|
18
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
ownKeys.forEach(function(key) {
|
|
24
|
-
_define_property(target, key, source[key]);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
}
|
|
29
1
|
import { useCallback, useEffect } from 'react';
|
|
30
2
|
import { usePopupBaseContext } from '../PopupBase';
|
|
31
3
|
import { getIdLastModal } from './ModalBaseContext';
|
|
32
|
-
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
var popupController = usePopupBaseContext();
|
|
4
|
+
const ESCAPE_KEYCODE = 27;
|
|
5
|
+
export const useModal = ({ id, popupInfo, onEscKeyDown, onClose, closeOnEsc = true })=>{
|
|
6
|
+
const popupController = usePopupBaseContext();
|
|
36
7
|
// При ESC закрывает текущее окно, если это возможно
|
|
37
|
-
|
|
8
|
+
const onKeyDown = useCallback((event)=>{
|
|
38
9
|
if (!closeOnEsc) {
|
|
39
10
|
return;
|
|
40
11
|
}
|
|
@@ -53,9 +24,9 @@ export var useModal = function useModal(param) {
|
|
|
53
24
|
popupController.items,
|
|
54
25
|
closeOnEsc
|
|
55
26
|
]);
|
|
56
|
-
useEffect(
|
|
27
|
+
useEffect(()=>{
|
|
57
28
|
window.addEventListener('keydown', onKeyDown);
|
|
58
|
-
return
|
|
29
|
+
return ()=>{
|
|
59
30
|
window.removeEventListener('keydown', onKeyDown);
|
|
60
31
|
};
|
|
61
32
|
}, [
|
|
@@ -64,13 +35,14 @@ export var useModal = function useModal(param) {
|
|
|
64
35
|
popupController.items,
|
|
65
36
|
closeOnEsc
|
|
66
37
|
]);
|
|
67
|
-
|
|
68
|
-
id
|
|
38
|
+
const modalInfo = {
|
|
39
|
+
id,
|
|
69
40
|
info: {
|
|
70
41
|
isModal: true
|
|
71
|
-
}
|
|
72
|
-
|
|
42
|
+
},
|
|
43
|
+
...popupInfo
|
|
44
|
+
};
|
|
73
45
|
return {
|
|
74
|
-
modalInfo
|
|
46
|
+
modalInfo
|
|
75
47
|
};
|
|
76
48
|
};
|
|
@@ -3,21 +3,15 @@ import { primary, surfaceLiquid03 } from '../../tokens';
|
|
|
3
3
|
/**
|
|
4
4
|
* Элемент пагинации точками.
|
|
5
5
|
* Стилизованный компонент, обладающий всеми свойствами ``div``.
|
|
6
|
-
*/ export
|
|
6
|
+
*/ export const PaginationDot = styled.li.withConfig({
|
|
7
7
|
displayName: "PaginationDot",
|
|
8
8
|
componentId: "sc-184538f4-0"
|
|
9
9
|
})([
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
], surfaceLiquid03,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var isActive = param.isActive;
|
|
19
|
-
return isActive && css([
|
|
20
|
-
"width:1.75rem;background:",
|
|
21
|
-
";"
|
|
22
|
-
], primary);
|
|
23
|
-
});
|
|
10
|
+
`width:0.375rem;height:0.375rem;border-radius:1rem;background:`,
|
|
11
|
+
`;transition:`,
|
|
12
|
+
`;font-size:0.5rem;& + &{margin-left:0.375rem;}&:focus{outline:0 none;}`,
|
|
13
|
+
``
|
|
14
|
+
], surfaceLiquid03, ({ theme })=>theme.lowPerformance ? 'unset' : 'width 0.1s ease-in-out, background 0.3s ease-in-out', ({ isActive })=>isActive && css([
|
|
15
|
+
`width:1.75rem;background:`,
|
|
16
|
+
`;`
|
|
17
|
+
], primary));
|
|
@@ -2,14 +2,11 @@ import styled from 'styled-components';
|
|
|
2
2
|
/**
|
|
3
3
|
* Оборачивающий компонент для пагинации точками.
|
|
4
4
|
* Стилизованный компонент, обладающий всеми свойствами ``div``.
|
|
5
|
-
*/ export
|
|
6
|
-
var tmp = param['aria-hidden'], ariaHidden = tmp === void 0 ? 'true' : tmp;
|
|
7
|
-
return {
|
|
5
|
+
*/ export const PaginationDots = styled.ul.attrs(({ 'aria-hidden': ariaHidden = 'true' })=>({
|
|
8
6
|
'aria-hidden': ariaHidden
|
|
9
|
-
}
|
|
10
|
-
}).withConfig({
|
|
7
|
+
})).withConfig({
|
|
11
8
|
displayName: "PaginationDots",
|
|
12
9
|
componentId: "sc-dd6e00ec-0"
|
|
13
10
|
})([
|
|
14
|
-
|
|
11
|
+
`display:flex;flex-wrap:wrap;align-self:center;align-items:center;margin:0;padding:0;list-style:none;`
|
|
15
12
|
]);
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var direction = 0;
|
|
2
|
+
export const usePaginationDots = ({ items, index, visibleItems = 7 })=>{
|
|
3
|
+
const activeId = items[index].id;
|
|
4
|
+
const prevIndex = useRef(null);
|
|
5
|
+
let direction = 0;
|
|
7
6
|
if (prevIndex.current !== null) {
|
|
8
7
|
direction = index > prevIndex.current ? 1 : -1;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
let start;
|
|
10
|
+
let end;
|
|
12
11
|
if (direction === 1) {
|
|
13
12
|
end = Math.min(Math.max(index + 2, visibleItems), items.length);
|
|
14
13
|
start = Math.max(end - visibleItems, 0);
|
|
@@ -20,10 +19,10 @@ export var usePaginationDots = function usePaginationDots(param) {
|
|
|
20
19
|
end = Math.min(start + visibleItems, items.length);
|
|
21
20
|
start = end - visibleItems;
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
const sliced = items.slice(start, end);
|
|
24
23
|
prevIndex.current = index;
|
|
25
24
|
return {
|
|
26
|
-
sliced
|
|
27
|
-
activeId
|
|
25
|
+
sliced,
|
|
26
|
+
activeId
|
|
28
27
|
};
|
|
29
28
|
};
|
|
@@ -1,191 +1,37 @@
|
|
|
1
|
-
function _array_like_to_array(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _array_with_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
|
-
function _define_property(obj, key, value) {
|
|
10
|
-
if (key in obj) {
|
|
11
|
-
Object.defineProperty(obj, key, {
|
|
12
|
-
value: value,
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true
|
|
16
|
-
});
|
|
17
|
-
} else {
|
|
18
|
-
obj[key] = value;
|
|
19
|
-
}
|
|
20
|
-
return obj;
|
|
21
|
-
}
|
|
22
|
-
function _iterable_to_array(iter) {
|
|
23
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
24
|
-
}
|
|
25
|
-
function _iterable_to_array_limit(arr, i) {
|
|
26
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
27
|
-
if (_i == null) return;
|
|
28
|
-
var _arr = [];
|
|
29
|
-
var _n = true;
|
|
30
|
-
var _d = false;
|
|
31
|
-
var _s, _e;
|
|
32
|
-
try {
|
|
33
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
34
|
-
_arr.push(_s.value);
|
|
35
|
-
if (i && _arr.length === i) break;
|
|
36
|
-
}
|
|
37
|
-
} catch (err) {
|
|
38
|
-
_d = true;
|
|
39
|
-
_e = err;
|
|
40
|
-
} finally{
|
|
41
|
-
try {
|
|
42
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
43
|
-
} finally{
|
|
44
|
-
if (_d) throw _e;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return _arr;
|
|
48
|
-
}
|
|
49
|
-
function _non_iterable_rest() {
|
|
50
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
51
|
-
}
|
|
52
|
-
function _object_spread(target) {
|
|
53
|
-
for(var i = 1; i < arguments.length; i++){
|
|
54
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
55
|
-
var ownKeys = Object.keys(source);
|
|
56
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
57
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
58
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
ownKeys.forEach(function(key) {
|
|
62
|
-
_define_property(target, key, source[key]);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return target;
|
|
66
|
-
}
|
|
67
|
-
function ownKeys(object, enumerableOnly) {
|
|
68
|
-
var keys = Object.keys(object);
|
|
69
|
-
if (Object.getOwnPropertySymbols) {
|
|
70
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
71
|
-
if (enumerableOnly) {
|
|
72
|
-
symbols = symbols.filter(function(sym) {
|
|
73
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
keys.push.apply(keys, symbols);
|
|
77
|
-
}
|
|
78
|
-
return keys;
|
|
79
|
-
}
|
|
80
|
-
function _object_spread_props(target, source) {
|
|
81
|
-
source = source != null ? source : {};
|
|
82
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
83
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
84
|
-
} else {
|
|
85
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
86
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return target;
|
|
90
|
-
}
|
|
91
|
-
function _object_without_properties(source, excluded) {
|
|
92
|
-
if (source == null) return {};
|
|
93
|
-
var target = {}, sourceKeys, key, i;
|
|
94
|
-
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
95
|
-
sourceKeys = Reflect.ownKeys(source);
|
|
96
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
97
|
-
key = sourceKeys[i];
|
|
98
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
99
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
100
|
-
target[key] = source[key];
|
|
101
|
-
}
|
|
102
|
-
return target;
|
|
103
|
-
}
|
|
104
|
-
target = _object_without_properties_loose(source, excluded);
|
|
105
|
-
if (Object.getOwnPropertySymbols) {
|
|
106
|
-
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
107
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
108
|
-
key = sourceKeys[i];
|
|
109
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
110
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
111
|
-
target[key] = source[key];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return target;
|
|
115
|
-
}
|
|
116
|
-
function _object_without_properties_loose(source, excluded) {
|
|
117
|
-
if (source == null) return {};
|
|
118
|
-
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
119
|
-
for(i = 0; i < sourceKeys.length; i++){
|
|
120
|
-
key = sourceKeys[i];
|
|
121
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
122
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
123
|
-
target[key] = source[key];
|
|
124
|
-
}
|
|
125
|
-
return target;
|
|
126
|
-
}
|
|
127
|
-
function _sliced_to_array(arr, i) {
|
|
128
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
129
|
-
}
|
|
130
|
-
function _to_array(arr) {
|
|
131
|
-
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
132
|
-
}
|
|
133
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
134
|
-
if (!o) return;
|
|
135
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
136
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
137
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
138
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
139
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
140
|
-
}
|
|
141
1
|
import React, { memo, useRef, useCallback, useEffect } from 'react';
|
|
142
2
|
import styled from 'styled-components';
|
|
143
3
|
import { usePopper } from 'react-popper';
|
|
144
4
|
import { useForkRef } from '../../hooks';
|
|
145
|
-
|
|
5
|
+
const StyledRoot = styled.div.withConfig({
|
|
146
6
|
displayName: "Popup__StyledRoot",
|
|
147
7
|
componentId: "sc-7a6b6e85-0"
|
|
148
8
|
})([
|
|
149
|
-
|
|
9
|
+
`position:relative;box-sizing:border-box;display:inline-flex;`
|
|
150
10
|
]);
|
|
151
|
-
|
|
11
|
+
const StyledPopup = styled.div.withConfig({
|
|
152
12
|
displayName: "Popup__StyledPopup",
|
|
153
13
|
componentId: "sc-7a6b6e85-1"
|
|
154
14
|
})([
|
|
155
|
-
|
|
15
|
+
`position:absolute;z-index:1;padding:var(--plasma-popup-padding);margin:var(--plasma-popup-margin);width:var(--plasma-popup-width);`
|
|
156
16
|
]);
|
|
157
|
-
export
|
|
158
|
-
return
|
|
17
|
+
export const getPlacement = (placement)=>{
|
|
18
|
+
return `${placement}-start`;
|
|
159
19
|
};
|
|
160
|
-
|
|
161
|
-
return (placements || []).map(
|
|
162
|
-
return getPlacement(placement);
|
|
163
|
-
});
|
|
20
|
+
const getAutoPlacements = (placements)=>{
|
|
21
|
+
return (placements || []).map((placement)=>getPlacement(placement));
|
|
164
22
|
};
|
|
165
23
|
/**
|
|
166
24
|
* Всплывающее окно с возможностью позиционирования
|
|
167
25
|
* и вызова по клику либо ховеру.
|
|
168
26
|
* @deprecated Используйте Popover
|
|
169
|
-
*/ export
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
"opened",
|
|
178
|
-
"trigger",
|
|
179
|
-
"placement",
|
|
180
|
-
"onToggle"
|
|
181
|
-
]), _rest1 = _sliced_to_array(_rest, 1), outerRootRef = _rest1[0];
|
|
182
|
-
var innerIsOpen = Boolean(isOpen || opened);
|
|
183
|
-
var rootRef = useRef(null);
|
|
184
|
-
var popupRef = useRef(null);
|
|
185
|
-
var handleRef = useForkRef(rootRef, outerRootRef);
|
|
186
|
-
var isAutoArray = Array.isArray(placement);
|
|
187
|
-
var isAuto = isAutoArray || placement === 'auto';
|
|
188
|
-
var _usePopper = usePopper(rootRef.current, popupRef.current, {
|
|
27
|
+
*/ export const Popup = /*#__PURE__*/ memo(/*#__PURE__*/ React.forwardRef(({ disclosure, children, isOpen, opened, trigger, placement = 'auto', onToggle, ...rest }, outerRootRef)=>{
|
|
28
|
+
const innerIsOpen = Boolean(isOpen || opened);
|
|
29
|
+
const rootRef = useRef(null);
|
|
30
|
+
const popupRef = useRef(null);
|
|
31
|
+
const handleRef = useForkRef(rootRef, outerRootRef);
|
|
32
|
+
const isAutoArray = Array.isArray(placement);
|
|
33
|
+
const isAuto = isAutoArray || placement === 'auto';
|
|
34
|
+
const { styles, attributes, forceUpdate } = usePopper(rootRef.current, popupRef.current, {
|
|
189
35
|
placement: getPlacement(isAutoArray ? 'auto' : placement),
|
|
190
36
|
modifiers: [
|
|
191
37
|
{
|
|
@@ -196,24 +42,22 @@ var getAutoPlacements = function getAutoPlacements(placements) {
|
|
|
196
42
|
}
|
|
197
43
|
}
|
|
198
44
|
]
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var rootHasTarget = (_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.contains(event.target);
|
|
45
|
+
});
|
|
46
|
+
const onDocumentClick = useCallback((event)=>{
|
|
47
|
+
const targetIsRoot = event.target === rootRef.current;
|
|
48
|
+
const rootHasTarget = rootRef.current?.contains(event.target);
|
|
204
49
|
if (!targetIsRoot && !rootHasTarget) {
|
|
205
|
-
onToggle
|
|
50
|
+
onToggle?.(false, event);
|
|
206
51
|
}
|
|
207
52
|
}, [
|
|
208
53
|
onToggle
|
|
209
54
|
]);
|
|
210
|
-
|
|
55
|
+
const onClick = useCallback((event)=>{
|
|
211
56
|
if (trigger === 'click') {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
var rootHasTarget = (_popupRef_current = popupRef.current) === null || _popupRef_current === void 0 ? void 0 : _popupRef_current.contains(event.target);
|
|
57
|
+
const targetIsPopup = event.target === popupRef.current;
|
|
58
|
+
const rootHasTarget = popupRef.current?.contains(event.target);
|
|
215
59
|
if (!targetIsPopup && !rootHasTarget) {
|
|
216
|
-
onToggle
|
|
60
|
+
onToggle?.(!innerIsOpen, event);
|
|
217
61
|
}
|
|
218
62
|
}
|
|
219
63
|
}, [
|
|
@@ -221,45 +65,43 @@ var getAutoPlacements = function getAutoPlacements(placements) {
|
|
|
221
65
|
innerIsOpen,
|
|
222
66
|
onToggle
|
|
223
67
|
]);
|
|
224
|
-
|
|
68
|
+
const onMouseEnter = useCallback((event)=>{
|
|
225
69
|
if (trigger === 'hover') {
|
|
226
|
-
onToggle
|
|
70
|
+
onToggle?.(true, event);
|
|
227
71
|
}
|
|
228
72
|
}, [
|
|
229
73
|
trigger,
|
|
230
74
|
onToggle
|
|
231
75
|
]);
|
|
232
|
-
|
|
76
|
+
const onMouseLeave = useCallback((event)=>{
|
|
233
77
|
if (trigger === 'hover') {
|
|
234
|
-
onToggle
|
|
78
|
+
onToggle?.(false, event);
|
|
235
79
|
}
|
|
236
80
|
}, [
|
|
237
81
|
trigger,
|
|
238
82
|
onToggle
|
|
239
83
|
]);
|
|
240
|
-
|
|
84
|
+
const onFocus = useCallback((event)=>{
|
|
241
85
|
if (trigger === 'hover') {
|
|
242
|
-
onToggle
|
|
86
|
+
onToggle?.(true, event);
|
|
243
87
|
}
|
|
244
88
|
}, [
|
|
245
89
|
trigger,
|
|
246
90
|
onToggle
|
|
247
91
|
]);
|
|
248
|
-
|
|
92
|
+
const onBlur = useCallback((event)=>{
|
|
249
93
|
if (trigger === 'hover') {
|
|
250
|
-
onToggle
|
|
94
|
+
onToggle?.(false, event);
|
|
251
95
|
}
|
|
252
96
|
}, [
|
|
253
97
|
trigger,
|
|
254
98
|
onToggle
|
|
255
99
|
]);
|
|
256
|
-
useEffect(
|
|
100
|
+
useEffect(()=>{
|
|
257
101
|
document.addEventListener('click', onDocumentClick);
|
|
258
|
-
return
|
|
259
|
-
return document.removeEventListener('click', onDocumentClick);
|
|
260
|
-
};
|
|
102
|
+
return ()=>document.removeEventListener('click', onDocumentClick);
|
|
261
103
|
}, []);
|
|
262
|
-
useEffect(
|
|
104
|
+
useEffect(()=>{
|
|
263
105
|
if (!innerIsOpen || !forceUpdate) {
|
|
264
106
|
return;
|
|
265
107
|
}
|
|
@@ -273,17 +115,22 @@ var getAutoPlacements = function getAutoPlacements(placements) {
|
|
|
273
115
|
innerIsOpen,
|
|
274
116
|
forceUpdate
|
|
275
117
|
]);
|
|
276
|
-
return /*#__PURE__*/ React.createElement(StyledRoot,
|
|
118
|
+
return /*#__PURE__*/ React.createElement(StyledRoot, {
|
|
277
119
|
ref: handleRef,
|
|
278
120
|
onClick: onClick,
|
|
279
121
|
onMouseEnter: onMouseEnter,
|
|
280
122
|
onMouseLeave: onMouseLeave,
|
|
281
123
|
onFocus: onFocus,
|
|
282
|
-
onBlur: onBlur
|
|
283
|
-
|
|
124
|
+
onBlur: onBlur,
|
|
125
|
+
...rest
|
|
126
|
+
}, disclosure, children && /*#__PURE__*/ React.createElement(StyledPopup, {
|
|
127
|
+
...attributes.popper,
|
|
284
128
|
ref: popupRef,
|
|
285
|
-
style:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
129
|
+
style: {
|
|
130
|
+
...styles.popper,
|
|
131
|
+
...{
|
|
132
|
+
display: innerIsOpen ? 'block' : 'none'
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}, children));
|
|
289
136
|
}));
|