@salutejs/plasma-core 1.136.0-dev.0 → 1.137.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/CHANGELOG.md +31 -0
- package/api/plasma-core.api.md +14 -46
- package/components/ModalBase/ModalBase.js +3 -4
- package/components/ModalBase/ModalOverlay.d.ts +0 -1
- package/components/ModalBase/ModalOverlay.js +1 -6
- package/components/ModalBase/hooks.js +0 -3
- package/components/ModalBase/index.d.ts +1 -2
- package/components/ModalBase/index.js +0 -8
- package/components/ModalBase/types.d.ts +2 -3
- package/components/PopupBase/PopupBase.d.ts +2 -1
- package/components/PopupBase/PopupBase.js +32 -10
- package/components/PopupBase/PopupBaseContext.d.ts +2 -4
- package/components/PopupBase/PopupBaseContext.js +7 -11
- package/components/PopupBase/PopupBaseRoot.d.ts +0 -1
- package/components/PopupBase/PopupBaseRoot.js +3 -12
- package/components/PopupBase/hooks.d.ts +2 -1
- package/components/PopupBase/hooks.js +13 -13
- package/components/PopupBase/index.d.ts +2 -3
- package/components/PopupBase/index.js +7 -15
- package/components/PopupBase/types.d.ts +10 -6
- package/components/PopupBase/utils.d.ts +3 -0
- package/components/PopupBase/utils.js +15 -1
- package/es/components/ModalBase/ModalBase.js +3 -4
- package/es/components/ModalBase/ModalOverlay.js +2 -7
- package/es/components/ModalBase/hooks.js +0 -2
- package/es/components/ModalBase/index.js +0 -1
- package/es/components/PopupBase/PopupBase.js +29 -9
- package/es/components/PopupBase/PopupBaseContext.js +8 -11
- package/es/components/PopupBase/PopupBaseRoot.js +2 -9
- package/es/components/PopupBase/hooks.js +13 -11
- package/es/components/PopupBase/index.js +1 -2
- package/es/components/PopupBase/utils.js +9 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
# v1.135.0 (Thu Oct 19 2023)
|
|
2
|
+
|
|
3
|
+
#### 🚀 Enhancement
|
|
4
|
+
|
|
5
|
+
- Release 19.10.2023 [#815](https://github.com/salute-developers/plasma/pull/815) ([@Yeti-or](https://github.com/Yeti-or) [@kayman233](https://github.com/kayman233) [@TitanKuzmich](https://github.com/TitanKuzmich) [@Yakutoc](https://github.com/Yakutoc) nikita.belyanskiy@south.rt.ru [@neretin-trike](https://github.com/neretin-trike))
|
|
6
|
+
- feat(plasma-core): animation with other API ([@kayman233](https://github.com/kayman233))
|
|
7
|
+
- feat(plasma-ui): add placement for Confirm ([@kayman233](https://github.com/kayman233))
|
|
8
|
+
- feat(plasma-new-hope/b2c/web/core): Add Popover to new hope ([@TitanKuzmich](https://github.com/TitanKuzmich))
|
|
9
|
+
|
|
10
|
+
#### 🐛 Bug Fix
|
|
11
|
+
|
|
12
|
+
- fix(plasma-core, plasma-ui): remove withAnimation from PopupBase ([@kayman233](https://github.com/kayman233))
|
|
13
|
+
- fix(plasma-core, plasma-ui): minor refactoring and types fix ([@kayman233](https://github.com/kayman233))
|
|
14
|
+
- feat(plasma-core, plasma-ui): add animation for PopupBase etc ([@kayman233](https://github.com/kayman233))
|
|
15
|
+
- docs(plasma-core/hope/web/b2c): generate new api ([@TitanKuzmich](https://github.com/TitanKuzmich))
|
|
16
|
+
- docs: generate new api for plasma-core ([@TitanKuzmich](https://github.com/TitanKuzmich))
|
|
17
|
+
- fix(plasma-web-docs): Make button blur prop deprecated ([@TitanKuzmich](https://github.com/TitanKuzmich))
|
|
18
|
+
- fix(plasma-core): refactor in PopupBase/ModalBase ([@kayman233](https://github.com/kayman233))
|
|
19
|
+
- feat(plasma-core, plasma-web, plasma-b2c): ModalBase component ([@kayman233](https://github.com/kayman233))
|
|
20
|
+
|
|
21
|
+
#### Authors: 6
|
|
22
|
+
|
|
23
|
+
- [@kayman233](https://github.com/kayman233)
|
|
24
|
+
- Alex Czech ([@Yakutoc](https://github.com/Yakutoc))
|
|
25
|
+
- Krivonos Aleksandr ([@TitanKuzmich](https://github.com/TitanKuzmich))
|
|
26
|
+
- neretinaa ([@neretin-trike](https://github.com/neretin-trike))
|
|
27
|
+
- Nikita Belyanskiy (nikita.belyanskiy@south.rt.ru)
|
|
28
|
+
- Vasiliy ([@Yeti-or](https://github.com/Yeti-or))
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
1
32
|
# v1.134.0 (Fri Sep 29 2023)
|
|
2
33
|
|
|
3
34
|
#### 🚀 Enhancement
|
package/api/plasma-core.api.md
CHANGED
|
@@ -14,7 +14,6 @@ import { Context } from 'react';
|
|
|
14
14
|
import { CSSObject } from 'styled-components';
|
|
15
15
|
import { CSSProperties } from 'react';
|
|
16
16
|
import { DefaultTheme } from 'styled-components';
|
|
17
|
-
import { Dispatch } from 'react';
|
|
18
17
|
import { DraggableData } from 'react-draggable';
|
|
19
18
|
import { FC } from 'react';
|
|
20
19
|
import { FlattenInterpolation } from 'styled-components';
|
|
@@ -23,10 +22,10 @@ import { FunctionComponent } from 'react';
|
|
|
23
22
|
import { HTMLAttributes } from 'react';
|
|
24
23
|
import { InterpolationFunction } from 'styled-components';
|
|
25
24
|
import { MutableRefObject } from 'react';
|
|
25
|
+
import { PropsWithChildren } from 'react';
|
|
26
26
|
import { default as React_2 } from 'react';
|
|
27
27
|
import { ReactNode } from 'react';
|
|
28
28
|
import { RefObject } from 'react';
|
|
29
|
-
import { SetStateAction } from 'react';
|
|
30
29
|
import { spacing } from '@salutejs/plasma-typo';
|
|
31
30
|
import { SpacingProps } from '@salutejs/plasma-typo';
|
|
32
31
|
import { SpacingProps as SpacingProps_2 } from '@salutejs/plasma-typo/lib/cjs/mixins/applySpacing';
|
|
@@ -566,6 +565,12 @@ export interface DoubleSliderProps extends SliderBaseProps {
|
|
|
566
565
|
value: number[];
|
|
567
566
|
}
|
|
568
567
|
|
|
568
|
+
// @public (undocumented)
|
|
569
|
+
export const endAnimationClass = "popup-base-end-animation";
|
|
570
|
+
|
|
571
|
+
// @public (undocumented)
|
|
572
|
+
export const endTransitionClass = "popup-base-end-transition";
|
|
573
|
+
|
|
569
574
|
// @public (undocumented)
|
|
570
575
|
export const extractTextFrom: (textSource?: string | number | null | ReactNode) => string;
|
|
571
576
|
|
|
@@ -756,9 +761,6 @@ export interface MaxLinesProps {
|
|
|
756
761
|
maxLines?: number;
|
|
757
762
|
}
|
|
758
763
|
|
|
759
|
-
// @public (undocumented)
|
|
760
|
-
export type ModalAnimationInfo = PopupAnimationInfo;
|
|
761
|
-
|
|
762
764
|
// @public
|
|
763
765
|
export const ModalBase: FC<ModalBaseProps>;
|
|
764
766
|
|
|
@@ -784,7 +786,7 @@ export type ModalBaseRootProps = PopupRootProps & Pick<ModalBaseProps, 'initialF
|
|
|
784
786
|
export const ModalOverlay: FC<ModalOverlayProps>;
|
|
785
787
|
|
|
786
788
|
// @public (undocumented)
|
|
787
|
-
export type ModalOverlayProps = Pick<PopupRootProps, 'id' | '
|
|
789
|
+
export type ModalOverlayProps = Pick<PopupRootProps, 'id' | 'zIndex'> & Pick<ModalBaseProps, 'withBlur' | 'closeOnOverlayClick' | 'onOverlayClick' | 'onClose'>;
|
|
788
790
|
|
|
789
791
|
// @public (undocumented)
|
|
790
792
|
export const monthLongName: (val: number) => string;
|
|
@@ -852,18 +854,6 @@ export interface PinProps {
|
|
|
852
854
|
// @public @deprecated
|
|
853
855
|
export const Popup: React_2.NamedExoticComponent<PopupProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
854
856
|
|
|
855
|
-
// @public (undocumented)
|
|
856
|
-
export interface PopupAnimationInfo {
|
|
857
|
-
// (undocumented)
|
|
858
|
-
endAnimation: boolean;
|
|
859
|
-
// (undocumented)
|
|
860
|
-
endTransition: boolean;
|
|
861
|
-
// (undocumented)
|
|
862
|
-
setEndAnimation: React.Dispatch<React.SetStateAction<boolean>>;
|
|
863
|
-
// (undocumented)
|
|
864
|
-
setEndTransition: React.Dispatch<React.SetStateAction<boolean>>;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
857
|
// @public
|
|
868
858
|
export const PopupBase: React_2.ForwardRefExoticComponent<PopupBaseProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
869
859
|
|
|
@@ -875,9 +865,8 @@ export type PopupBasePlacement = BasicPopupBasePlacement | MixedPopupBasePlaceme
|
|
|
875
865
|
|
|
876
866
|
// @public (undocumented)
|
|
877
867
|
export interface PopupBaseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
878
|
-
animationInfo?: PopupAnimationInfo;
|
|
879
868
|
children?: React.ReactNode;
|
|
880
|
-
frame?: 'document' | React.RefObject<HTMLElement>;
|
|
869
|
+
frame?: 'document' | string | React.RefObject<HTMLElement>;
|
|
881
870
|
isOpen: boolean;
|
|
882
871
|
// (undocumented)
|
|
883
872
|
offset?: [number, number] | [string, string];
|
|
@@ -885,16 +874,12 @@ export interface PopupBaseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
885
874
|
// (undocumented)
|
|
886
875
|
placement?: PopupBasePlacement;
|
|
887
876
|
popupInfo?: PopupInfo;
|
|
877
|
+
withAnimation?: boolean;
|
|
888
878
|
zIndex?: string;
|
|
889
879
|
}
|
|
890
880
|
|
|
891
881
|
// @public (undocumented)
|
|
892
|
-
export const PopupBaseProvider:
|
|
893
|
-
children: ReactNode;
|
|
894
|
-
}>;
|
|
895
|
-
|
|
896
|
-
// @public
|
|
897
|
-
export const PopupBaseRoot: React_2.ForwardRefExoticComponent<PopupRootProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
882
|
+
export const PopupBaseProvider: FC<PropsWithChildren>;
|
|
898
883
|
|
|
899
884
|
// @public (undocumented)
|
|
900
885
|
export const popupBaseRootClass = "popup-base-root";
|
|
@@ -914,7 +899,7 @@ export interface PopupInfo {
|
|
|
914
899
|
// (undocumented)
|
|
915
900
|
id: string;
|
|
916
901
|
// (undocumented)
|
|
917
|
-
info?:
|
|
902
|
+
info?: Record<string, any>;
|
|
918
903
|
}
|
|
919
904
|
|
|
920
905
|
// @public (undocumented)
|
|
@@ -931,6 +916,8 @@ export interface PopupProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
931
916
|
|
|
932
917
|
// @public (undocumented)
|
|
933
918
|
export interface PopupRootProps extends Omit<PopupBaseProps, 'isOpen' | 'overlay'> {
|
|
919
|
+
// Warning: (ae-forgotten-export) The symbol "PopupAnimationInfo" needs to be exported by the entry point index.d.ts
|
|
920
|
+
animationInfo: PopupAnimationInfo;
|
|
934
921
|
// (undocumented)
|
|
935
922
|
id: string;
|
|
936
923
|
// (undocumented)
|
|
@@ -1362,13 +1349,6 @@ export const useForkRef: UseForkRefHook;
|
|
|
1362
1349
|
// @public
|
|
1363
1350
|
export const useIsomorphicLayoutEffect: typeof useEffect;
|
|
1364
1351
|
|
|
1365
|
-
// Warning: (ae-forgotten-export) The symbol "ModalHookArgs" needs to be exported by the entry point index.d.ts
|
|
1366
|
-
//
|
|
1367
|
-
// @public (undocumented)
|
|
1368
|
-
export const useModal: ({ id, popupInfo, onEscKeyDown, onClose, closeOnEsc }: ModalHookArgs) => {
|
|
1369
|
-
modalInfo: ModalInfo;
|
|
1370
|
-
};
|
|
1371
|
-
|
|
1372
1352
|
// @public (undocumented)
|
|
1373
1353
|
export const usePaginationDots: ({ items, index, visibleItems }: SmartPaginationDotsProps) => {
|
|
1374
1354
|
sliced: {
|
|
@@ -1377,17 +1357,6 @@ export const usePaginationDots: ({ items, index, visibleItems }: SmartPagination
|
|
|
1377
1357
|
activeId: string | number;
|
|
1378
1358
|
};
|
|
1379
1359
|
|
|
1380
|
-
// Warning: (ae-forgotten-export) The symbol "PopupHookArgs" needs to be exported by the entry point index.d.ts
|
|
1381
|
-
//
|
|
1382
|
-
// @public (undocumented)
|
|
1383
|
-
export const usePopup: ({ isOpen, id, popupInfo, animationInfo }: PopupHookArgs) => {
|
|
1384
|
-
isVisible: boolean;
|
|
1385
|
-
setVisible: Dispatch<SetStateAction<boolean>>;
|
|
1386
|
-
};
|
|
1387
|
-
|
|
1388
|
-
// @public (undocumented)
|
|
1389
|
-
export const usePopupAnimation: () => PopupAnimationInfo;
|
|
1390
|
-
|
|
1391
1360
|
// @public (undocumented)
|
|
1392
1361
|
export const usePopupBaseContext: () => PopupContextType;
|
|
1393
1362
|
|
|
@@ -1492,7 +1461,6 @@ export interface WithSkeletonProps {
|
|
|
1492
1461
|
|
|
1493
1462
|
// Warnings were encountered during analysis:
|
|
1494
1463
|
//
|
|
1495
|
-
// components/ModalBase/hooks.d.ts:4:5 - (ae-forgotten-export) The symbol "ModalInfo" needs to be exported by the entry point index.d.ts
|
|
1496
1464
|
// components/Toast/Toast.d.ts:4:5 - (ae-forgotten-export) The symbol "ToastRole" needs to be exported by the entry point index.d.ts
|
|
1497
1465
|
// components/Toast/useToast.d.ts:2:5 - (ae-forgotten-export) The symbol "ShowToast" needs to be exported by the entry point index.d.ts
|
|
1498
1466
|
|
|
@@ -21,7 +21,7 @@ var _collectPackageInfo = /*#__PURE__*/require("../../collectPackageInfo");
|
|
|
21
21
|
|
|
22
22
|
var _NoScroll;
|
|
23
23
|
|
|
24
|
-
var _excluded = ["id", "
|
|
24
|
+
var _excluded = ["id", "withAnimation", "onClose", "onOverlayClick", "onEscKeyDown", "closeOnEsc", "closeOnOverlayClick", "withBlur", "initialFocusRef", "focusAfterRef", "zIndex", "popupInfo", "children"];
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
27
|
|
|
@@ -40,7 +40,7 @@ var NoScroll = /*#__PURE__*/(0, _styledComponents.createGlobalStyle)(["body{over
|
|
|
40
40
|
|
|
41
41
|
var ModalBase = function ModalBase(_ref) {
|
|
42
42
|
var id = _ref.id,
|
|
43
|
-
|
|
43
|
+
withAnimation = _ref.withAnimation,
|
|
44
44
|
onClose = _ref.onClose,
|
|
45
45
|
onOverlayClick = _ref.onOverlayClick,
|
|
46
46
|
onEscKeyDown = _ref.onEscKeyDown,
|
|
@@ -73,14 +73,13 @@ var ModalBase = function ModalBase(_ref) {
|
|
|
73
73
|
id: id,
|
|
74
74
|
ref: trapRef,
|
|
75
75
|
popupInfo: modalInfo,
|
|
76
|
-
|
|
76
|
+
withAnimation: withAnimation,
|
|
77
77
|
zIndex: zIndex,
|
|
78
78
|
overlay: /*#__PURE__*/_react["default"].createElement(_ModalOverlay.ModalOverlay, {
|
|
79
79
|
id: innerId,
|
|
80
80
|
withBlur: withBlur,
|
|
81
81
|
onOverlayClick: onOverlayClick,
|
|
82
82
|
onClose: onClose,
|
|
83
|
-
animationInfo: animationInfo,
|
|
84
83
|
zIndex: zIndex,
|
|
85
84
|
closeOnOverlayClick: closeOnOverlayClick
|
|
86
85
|
})
|
|
@@ -3,7 +3,6 @@ import { ModalOverlayProps } from './types';
|
|
|
3
3
|
export declare const modalBaseOverlayClass = "modal-base-overlay";
|
|
4
4
|
export declare const Overlay: import("styled-components").StyledComponent<"div", any, {
|
|
5
5
|
transparent?: boolean | undefined;
|
|
6
|
-
endAnimation?: boolean | undefined;
|
|
7
6
|
$withBlur?: boolean | undefined;
|
|
8
7
|
clickable?: boolean | undefined;
|
|
9
8
|
zIndex?: string | undefined;
|
|
@@ -19,7 +19,7 @@ var _ModalBaseContext = /*#__PURE__*/require("./ModalBaseContext");
|
|
|
19
19
|
|
|
20
20
|
var _collectPackageInfo = /*#__PURE__*/require("../../collectPackageInfo");
|
|
21
21
|
|
|
22
|
-
var _excluded = ["id", "withBlur", "onOverlayClick", "onClose", "
|
|
22
|
+
var _excluded = ["id", "withBlur", "onOverlayClick", "onClose", "zIndex", "closeOnOverlayClick"];
|
|
23
23
|
|
|
24
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
25
|
|
|
@@ -67,7 +67,6 @@ var ModalOverlay = function ModalOverlay(_ref5) {
|
|
|
67
67
|
withBlur = _ref5.withBlur,
|
|
68
68
|
onOverlayClick = _ref5.onOverlayClick,
|
|
69
69
|
onClose = _ref5.onClose,
|
|
70
|
-
animationInfo = _ref5.animationInfo,
|
|
71
70
|
zIndex = _ref5.zIndex,
|
|
72
71
|
_ref5$closeOnOverlayC = _ref5.closeOnOverlayClick,
|
|
73
72
|
closeOnOverlayClick = _ref5$closeOnOverlayC === void 0 ? true : _ref5$closeOnOverlayC,
|
|
@@ -91,14 +90,10 @@ var ModalOverlay = function ModalOverlay(_ref5) {
|
|
|
91
90
|
var transparent = (0, _react.useMemo)(function () {
|
|
92
91
|
return (0, _ModalBaseContext.getIdLastModal)(popupController.items) !== id;
|
|
93
92
|
}, [id, popupController.items]);
|
|
94
|
-
var endAnimation = (0, _react.useMemo)(function () {
|
|
95
|
-
return (0, _ModalBaseContext.getIdFirstModal)(popupController.items) === id && (animationInfo === null || animationInfo === void 0 ? void 0 : animationInfo.endAnimation);
|
|
96
|
-
}, [id, popupController.items]);
|
|
97
93
|
return /*#__PURE__*/_react["default"].createElement(Overlay, _extends({
|
|
98
94
|
className: modalBaseOverlayClass,
|
|
99
95
|
transparent: transparent,
|
|
100
96
|
clickable: closeOnOverlayClick,
|
|
101
|
-
endAnimation: endAnimation,
|
|
102
97
|
onClick: onModalOverlayKeyDown,
|
|
103
98
|
zIndex: zIndex,
|
|
104
99
|
$withBlur: withBlur
|
|
@@ -11,15 +11,12 @@ var _PopupBase = /*#__PURE__*/require("../PopupBase");
|
|
|
11
11
|
|
|
12
12
|
var _ModalBaseContext = /*#__PURE__*/require("./ModalBaseContext");
|
|
13
13
|
|
|
14
|
-
var _collectPackageInfo = /*#__PURE__*/require("../../collectPackageInfo");
|
|
15
|
-
|
|
16
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
15
|
|
|
18
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
17
|
|
|
20
18
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
19
|
|
|
22
|
-
(0, _collectPackageInfo.collectPackageInfo)('ModalBase/hooks');
|
|
23
20
|
var ESCAPE_KEYCODE = 27;
|
|
24
21
|
|
|
25
22
|
var useModal = function useModal(_ref) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { ModalBase } from './ModalBase';
|
|
2
|
-
export { useModal } from './hooks';
|
|
3
2
|
export { ModalOverlay, modalBaseOverlayClass } from './ModalOverlay';
|
|
4
|
-
export type { ModalBaseProps,
|
|
3
|
+
export type { ModalBaseProps, ModalBaseRootProps, ModalOverlayProps } from './types';
|
|
@@ -9,12 +9,6 @@ Object.defineProperty(exports, "ModalBase", {
|
|
|
9
9
|
return _ModalBase.ModalBase;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "useModal", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _hooks.useModal;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
12
|
Object.defineProperty(exports, "ModalOverlay", {
|
|
19
13
|
enumerable: true,
|
|
20
14
|
get: function get() {
|
|
@@ -30,6 +24,4 @@ Object.defineProperty(exports, "modalBaseOverlayClass", {
|
|
|
30
24
|
|
|
31
25
|
var _ModalBase = /*#__PURE__*/require("./ModalBase");
|
|
32
26
|
|
|
33
|
-
var _hooks = /*#__PURE__*/require("./hooks");
|
|
34
|
-
|
|
35
27
|
var _ModalOverlay = /*#__PURE__*/require("./ModalOverlay");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PopupBaseProps, PopupRootProps } from '../PopupBase';
|
|
3
|
-
import {
|
|
3
|
+
import { PopupHookArgs } from '../PopupBase/types';
|
|
4
4
|
export interface ModalBaseProps extends PopupBaseProps {
|
|
5
5
|
/**
|
|
6
6
|
* Нужно ли применять blur для подложки.
|
|
@@ -36,7 +36,6 @@ export interface ModalBaseProps extends PopupBaseProps {
|
|
|
36
36
|
*/
|
|
37
37
|
onClose?: () => void;
|
|
38
38
|
}
|
|
39
|
-
export declare type ModalAnimationInfo = PopupAnimationInfo;
|
|
40
39
|
export declare type ModalBaseRootProps = PopupRootProps & Pick<ModalBaseProps, 'initialFocusRef' | 'focusAfterRef' | 'onClose'>;
|
|
41
|
-
export declare type ModalOverlayProps = Pick<PopupRootProps, 'id' | '
|
|
40
|
+
export declare type ModalOverlayProps = Pick<PopupRootProps, 'id' | 'zIndex'> & Pick<ModalBaseProps, 'withBlur' | 'closeOnOverlayClick' | 'onOverlayClick' | 'onClose'>;
|
|
42
41
|
export declare type ModalHookArgs = Pick<PopupHookArgs, 'id' | 'popupInfo'> & Pick<ModalBaseProps, 'closeOnEsc' | 'onEscKeyDown' | 'onClose'>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PopupBaseProps } from './types';
|
|
2
|
+
import { PopupAnimationInfo, PopupBaseProps } from './types';
|
|
3
|
+
export declare const getClassName: (animationInfo: PopupAnimationInfo, className?: string | undefined) => string;
|
|
3
4
|
/**
|
|
4
5
|
* Базовый копмонент PopupBase.
|
|
5
6
|
*/
|
|
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.PopupBase = void 0;
|
|
8
|
+
exports.PopupBase = exports.getClassName = void 0;
|
|
9
9
|
|
|
10
10
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
|
11
11
|
|
|
@@ -21,9 +21,11 @@ var _PopupBaseRoot = /*#__PURE__*/require("./PopupBaseRoot");
|
|
|
21
21
|
|
|
22
22
|
var _hooks2 = /*#__PURE__*/require("./hooks");
|
|
23
23
|
|
|
24
|
+
var _utils = /*#__PURE__*/require("./utils");
|
|
25
|
+
|
|
24
26
|
var _collectPackageInfo = /*#__PURE__*/require("../../collectPackageInfo");
|
|
25
27
|
|
|
26
|
-
var _excluded = ["id", "isOpen", "placement", "offset", "frame", "children", "overlay", "role", "zIndex", "popupInfo", "
|
|
28
|
+
var _excluded = ["id", "isOpen", "placement", "offset", "frame", "children", "overlay", "role", "zIndex", "popupInfo", "withAnimation", "className"];
|
|
27
29
|
|
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
31
|
|
|
@@ -31,6 +33,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
31
33
|
|
|
32
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
35
|
|
|
36
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
37
|
+
|
|
34
38
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
35
39
|
|
|
36
40
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -52,12 +56,19 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
52
56
|
var StyledPortal = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
53
57
|
componentId: "plasma__sc-1md4coi-0"
|
|
54
58
|
})([""]);
|
|
59
|
+
|
|
60
|
+
var getClassName = function getClassName(animationInfo, className) {
|
|
61
|
+
var endAnimation = animationInfo !== null && animationInfo !== void 0 && animationInfo.endAnimation ? _utils.endAnimationClass : '';
|
|
62
|
+
var endTransition = animationInfo !== null && animationInfo !== void 0 && animationInfo.endTransition ? _utils.endTransitionClass : '';
|
|
63
|
+
return [className, endAnimation, endTransition].filter(Boolean).join(' ');
|
|
64
|
+
};
|
|
55
65
|
/**
|
|
56
66
|
* Базовый копмонент PopupBase.
|
|
57
67
|
*/
|
|
58
68
|
|
|
59
69
|
|
|
60
|
-
|
|
70
|
+
exports.getClassName = getClassName;
|
|
71
|
+
var PopupBase = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
61
72
|
var id = _ref.id,
|
|
62
73
|
isOpen = _ref.isOpen,
|
|
63
74
|
_ref$placement = _ref.placement,
|
|
@@ -71,7 +82,9 @@ var PopupBase = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
71
82
|
role = _ref.role,
|
|
72
83
|
zIndex = _ref.zIndex,
|
|
73
84
|
popupInfo = _ref.popupInfo,
|
|
74
|
-
|
|
85
|
+
_ref$withAnimation = _ref.withAnimation,
|
|
86
|
+
withAnimation = _ref$withAnimation === void 0 ? false : _ref$withAnimation,
|
|
87
|
+
className = _ref.className,
|
|
75
88
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
76
89
|
|
|
77
90
|
var uniqId = (0, _hooks.useUniqId)();
|
|
@@ -81,9 +94,10 @@ var PopupBase = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
81
94
|
isOpen: isOpen,
|
|
82
95
|
id: innerId,
|
|
83
96
|
popupInfo: popupInfo,
|
|
84
|
-
|
|
97
|
+
withAnimation: withAnimation
|
|
85
98
|
}),
|
|
86
99
|
isVisible = _usePopup.isVisible,
|
|
100
|
+
animationInfo = _usePopup.animationInfo,
|
|
87
101
|
setVisible = _usePopup.setVisible;
|
|
88
102
|
|
|
89
103
|
var portalRef = (0, _react.useRef)(null);
|
|
@@ -97,19 +111,26 @@ var PopupBase = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
97
111
|
(0, _react.useEffect)(function () {
|
|
98
112
|
var portal = document.getElementById(_PopupBaseContext.POPOVER_PORTAL_ID);
|
|
99
113
|
|
|
100
|
-
if (frame !== '
|
|
114
|
+
if (typeof frame !== 'string' && frame && frame.current) {
|
|
101
115
|
portal = frame.current;
|
|
102
116
|
}
|
|
103
117
|
|
|
104
118
|
if (!portal) {
|
|
105
119
|
portal = document.createElement('div');
|
|
106
120
|
portal.setAttribute('id', _PopupBaseContext.POPOVER_PORTAL_ID);
|
|
107
|
-
|
|
121
|
+
|
|
122
|
+
if (typeof frame === 'string' && frame !== 'document') {
|
|
123
|
+
var _document$getElementB;
|
|
124
|
+
|
|
125
|
+
(_document$getElementB = document.getElementById(frame)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.appendChild(portal);
|
|
126
|
+
} else {
|
|
127
|
+
document.body.appendChild(portal);
|
|
128
|
+
}
|
|
108
129
|
}
|
|
109
130
|
|
|
110
131
|
portalRef.current = portal;
|
|
111
132
|
/**
|
|
112
|
-
* Изменение стейта нужно для того, чтобы
|
|
133
|
+
* Изменение стейта нужно для того, чтобы Popup
|
|
113
134
|
* отобразился после записи DOM элемента в portalRef.current
|
|
114
135
|
*/
|
|
115
136
|
|
|
@@ -120,7 +141,9 @@ var PopupBase = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
120
141
|
return null;
|
|
121
142
|
}
|
|
122
143
|
|
|
123
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, portalRef.current && /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement(StyledPortal,
|
|
144
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, portalRef.current && /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement(StyledPortal, _extends({
|
|
145
|
+
className: getClassName(animationInfo, className)
|
|
146
|
+
}, rest), overlay, /*#__PURE__*/_react["default"].createElement(_PopupBaseRoot.PopupBaseRoot, {
|
|
124
147
|
id: innerId,
|
|
125
148
|
ref: innerRef,
|
|
126
149
|
placement: placement,
|
|
@@ -131,5 +154,4 @@ var PopupBase = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
131
154
|
setVisible: setVisible
|
|
132
155
|
}, children)), portalRef.current));
|
|
133
156
|
});
|
|
134
|
-
|
|
135
157
|
exports.PopupBase = PopupBase;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { PopupContextType } from './types';
|
|
3
3
|
export declare const POPOVER_PORTAL_ID = "plasma-popup-root";
|
|
4
4
|
export declare const usePopupBaseContext: () => PopupContextType;
|
|
5
|
-
export declare const PopupBaseProvider:
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
}>;
|
|
5
|
+
export declare const PopupBaseProvider: FC<PropsWithChildren>;
|
|
@@ -39,8 +39,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
39
39
|
var POPOVER_PORTAL_ID = 'plasma-popup-root';
|
|
40
40
|
exports.POPOVER_PORTAL_ID = POPOVER_PORTAL_ID;
|
|
41
41
|
var items = [];
|
|
42
|
-
|
|
43
|
-
var PopupBaseContext = /*#__PURE__*/_react["default"].createContext({
|
|
42
|
+
var PopupBaseContext = /*#__PURE__*/(0, _react.createContext)({
|
|
44
43
|
items: items,
|
|
45
44
|
register: function register(_info) {
|
|
46
45
|
throw new Error('Function not implemented. Add PopupBaseProvider');
|
|
@@ -51,7 +50,7 @@ var PopupBaseContext = /*#__PURE__*/_react["default"].createContext({
|
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
var usePopupBaseContext = function usePopupBaseContext() {
|
|
54
|
-
return _react
|
|
53
|
+
return (0, _react.useContext)(PopupBaseContext);
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
exports.usePopupBaseContext = usePopupBaseContext;
|
|
@@ -59,16 +58,13 @@ exports.usePopupBaseContext = usePopupBaseContext;
|
|
|
59
58
|
var PopupBaseProvider = function PopupBaseProvider(_ref) {
|
|
60
59
|
var children = _ref.children;
|
|
61
60
|
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
items =
|
|
65
|
-
setItems =
|
|
61
|
+
var _useState = (0, _react.useState)([]),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
items = _useState2[0],
|
|
64
|
+
setItems = _useState2[1];
|
|
66
65
|
|
|
67
66
|
var register = function register(info) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
updatedItems.push(info);
|
|
71
|
-
setItems(updatedItems);
|
|
67
|
+
setItems([].concat(_toConsumableArray(items), [info]));
|
|
72
68
|
};
|
|
73
69
|
|
|
74
70
|
var unregister = function unregister(id) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PopupRootProps } from './types';
|
|
3
3
|
export declare const DEFAULT_Z_INDEX = 9000;
|
|
4
|
-
export declare const popupBaseRootClass = "popup-base-root";
|
|
5
4
|
/**
|
|
6
5
|
* Корень PopupBase.
|
|
7
6
|
* Управляет показом/скрытием и анимацией всплывающего окна.
|
|
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.PopupBaseRoot = exports.
|
|
8
|
+
exports.PopupBaseRoot = exports.DEFAULT_Z_INDEX = void 0;
|
|
9
9
|
|
|
10
10
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
|
11
11
|
|
|
@@ -17,8 +17,6 @@ var _PopupBaseContext = /*#__PURE__*/require("./PopupBaseContext");
|
|
|
17
17
|
|
|
18
18
|
var _utils = /*#__PURE__*/require("./utils");
|
|
19
19
|
|
|
20
|
-
var _collectPackageInfo = /*#__PURE__*/require("../../collectPackageInfo");
|
|
21
|
-
|
|
22
20
|
var _excluded = ["id", "placement", "offset", "frame", "setVisible", "children", "role", "zIndex", "animationInfo"];
|
|
23
21
|
|
|
24
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -31,15 +29,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
31
29
|
|
|
32
30
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
33
31
|
|
|
34
|
-
(0, _collectPackageInfo.collectPackageInfo)('PopupBase/PopupBaseRoot');
|
|
35
32
|
var DEFAULT_Z_INDEX = 9000;
|
|
36
|
-
/*
|
|
37
|
-
* Класс корневого компонента PopupBaseRoot: `popup-base-root`
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
33
|
exports.DEFAULT_Z_INDEX = DEFAULT_Z_INDEX;
|
|
41
|
-
var popupBaseRootClass = 'popup-base-root';
|
|
42
|
-
exports.popupBaseRootClass = popupBaseRootClass;
|
|
43
34
|
|
|
44
35
|
var PopupBaseView = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
45
36
|
componentId: "plasma__sc-14025jn-0"
|
|
@@ -91,9 +82,9 @@ var PopupBaseRoot = /*#__PURE__*/_react["default"].forwardRef(function (_ref4, r
|
|
|
91
82
|
setVisible(false);
|
|
92
83
|
animationInfo.setEndAnimation(false);
|
|
93
84
|
}
|
|
94
|
-
}, [popupController.unregister, animationInfo, setVisible]);
|
|
85
|
+
}, [popupController.unregister, animationInfo === null || animationInfo === void 0 ? void 0 : animationInfo.endAnimation, setVisible]);
|
|
95
86
|
return /*#__PURE__*/_react["default"].createElement(PopupRootContainer, _extends({
|
|
96
|
-
className: popupBaseRootClass,
|
|
87
|
+
className: _utils.popupBaseRootClass,
|
|
97
88
|
ref: innerRef,
|
|
98
89
|
placement: placement,
|
|
99
90
|
frame: frame,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PopupAnimationInfo, PopupHookArgs } from './types';
|
|
3
3
|
export declare const usePopupAnimation: () => PopupAnimationInfo;
|
|
4
|
-
export declare const usePopup: ({ isOpen, id, popupInfo,
|
|
4
|
+
export declare const usePopup: ({ isOpen, id, popupInfo, withAnimation }: PopupHookArgs) => {
|
|
5
5
|
isVisible: boolean;
|
|
6
6
|
setVisible: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
7
|
+
animationInfo: PopupAnimationInfo;
|
|
7
8
|
};
|
|
@@ -9,8 +9,6 @@ var _react = /*#__PURE__*/require("react");
|
|
|
9
9
|
|
|
10
10
|
var _PopupBaseContext = /*#__PURE__*/require("./PopupBaseContext");
|
|
11
11
|
|
|
12
|
-
var _collectPackageInfo = /*#__PURE__*/require("../../collectPackageInfo");
|
|
13
|
-
|
|
14
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
13
|
|
|
16
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -29,8 +27,6 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
29
27
|
|
|
30
28
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
29
|
|
|
32
|
-
(0, _collectPackageInfo.collectPackageInfo)('PopupBase/hooks');
|
|
33
|
-
|
|
34
30
|
// Хук для поключения анимации
|
|
35
31
|
var usePopupAnimation = function usePopupAnimation() {
|
|
36
32
|
var _useState = (0, _react.useState)(false),
|
|
@@ -58,18 +54,21 @@ var usePopup = function usePopup(_ref) {
|
|
|
58
54
|
var isOpen = _ref.isOpen,
|
|
59
55
|
id = _ref.id,
|
|
60
56
|
popupInfo = _ref.popupInfo,
|
|
61
|
-
|
|
57
|
+
withAnimation = _ref.withAnimation;
|
|
62
58
|
|
|
63
59
|
var _useState5 = (0, _react.useState)(false),
|
|
64
60
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
65
61
|
isVisible = _useState6[0],
|
|
66
62
|
setVisible = _useState6[1];
|
|
67
63
|
|
|
68
|
-
var popupController = (0, _PopupBaseContext.usePopupBaseContext)();
|
|
64
|
+
var popupController = (0, _PopupBaseContext.usePopupBaseContext)();
|
|
65
|
+
var animationInfo = usePopupAnimation(); // для использования transition в качестве анимации
|
|
69
66
|
|
|
70
67
|
(0, _react.useEffect)(function () {
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
if (withAnimation && animationInfo) {
|
|
69
|
+
animationInfo.setEndTransition(!isVisible || (animationInfo === null || animationInfo === void 0 ? void 0 : animationInfo.endAnimation));
|
|
70
|
+
}
|
|
71
|
+
}, [animationInfo, withAnimation, isVisible]); // сначала добавление/удаление из контекста, и только после этого отображение/скрытие
|
|
73
72
|
|
|
74
73
|
(0, _react.useEffect)(function () {
|
|
75
74
|
// при первом открытии
|
|
@@ -78,7 +77,7 @@ var usePopup = function usePopup(_ref) {
|
|
|
78
77
|
id: id
|
|
79
78
|
}, popupInfo));
|
|
80
79
|
setVisible(true);
|
|
81
|
-
animationInfo
|
|
80
|
+
animationInfo.setEndAnimation(false);
|
|
82
81
|
return;
|
|
83
82
|
}
|
|
84
83
|
|
|
@@ -87,18 +86,19 @@ var usePopup = function usePopup(_ref) {
|
|
|
87
86
|
} // если есть анимация - закрытие по окончании анимации
|
|
88
87
|
|
|
89
88
|
|
|
90
|
-
if (
|
|
91
|
-
animationInfo
|
|
89
|
+
if (withAnimation) {
|
|
90
|
+
animationInfo.setEndAnimation(true);
|
|
92
91
|
return;
|
|
93
92
|
} // иначе обычное закрытие
|
|
94
93
|
|
|
95
94
|
|
|
96
95
|
popupController.unregister(id);
|
|
97
96
|
setVisible(false);
|
|
98
|
-
}, [isOpen, isVisible, animationInfo]);
|
|
97
|
+
}, [isOpen, isVisible, animationInfo, withAnimation]);
|
|
99
98
|
return {
|
|
100
99
|
isVisible: isVisible,
|
|
101
|
-
setVisible: setVisible
|
|
100
|
+
setVisible: setVisible,
|
|
101
|
+
animationInfo: animationInfo
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
104
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { PopupBaseProvider, usePopupBaseContext } from './PopupBaseContext';
|
|
2
2
|
export { PopupBase } from './PopupBase';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export type { PopupBasePlacement, PopupInfo, PopupContextType, PopupBaseProps, PopupAnimationInfo, PopupRootProps, } from './types';
|
|
3
|
+
export { popupBaseRootClass, endAnimationClass, endTransitionClass } from './utils';
|
|
4
|
+
export type { PopupBasePlacement, PopupInfo, PopupContextType, PopupBaseProps, PopupRootProps } from './types';
|
|
@@ -21,28 +21,22 @@ Object.defineProperty(exports, "PopupBase", {
|
|
|
21
21
|
return _PopupBase.PopupBase;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _hooks.usePopupAnimation;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "usePopup", {
|
|
24
|
+
Object.defineProperty(exports, "popupBaseRootClass", {
|
|
31
25
|
enumerable: true,
|
|
32
26
|
get: function get() {
|
|
33
|
-
return
|
|
27
|
+
return _utils.popupBaseRootClass;
|
|
34
28
|
}
|
|
35
29
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "endAnimationClass", {
|
|
37
31
|
enumerable: true,
|
|
38
32
|
get: function get() {
|
|
39
|
-
return
|
|
33
|
+
return _utils.endAnimationClass;
|
|
40
34
|
}
|
|
41
35
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "endTransitionClass", {
|
|
43
37
|
enumerable: true,
|
|
44
38
|
get: function get() {
|
|
45
|
-
return
|
|
39
|
+
return _utils.endTransitionClass;
|
|
46
40
|
}
|
|
47
41
|
});
|
|
48
42
|
|
|
@@ -50,6 +44,4 @@ var _PopupBaseContext = /*#__PURE__*/require("./PopupBaseContext");
|
|
|
50
44
|
|
|
51
45
|
var _PopupBase = /*#__PURE__*/require("./PopupBase");
|
|
52
46
|
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
var _PopupBaseRoot = /*#__PURE__*/require("./PopupBaseRoot");
|
|
47
|
+
var _utils = /*#__PURE__*/require("./utils");
|
|
@@ -4,7 +4,7 @@ export declare type MixedPopupBasePlacement = 'top-right' | 'top-left' | 'bottom
|
|
|
4
4
|
export declare type PopupBasePlacement = BasicPopupBasePlacement | MixedPopupBasePlacement;
|
|
5
5
|
export interface PopupInfo {
|
|
6
6
|
id: string;
|
|
7
|
-
info?:
|
|
7
|
+
info?: Record<string, any>;
|
|
8
8
|
}
|
|
9
9
|
export interface PopupContextType {
|
|
10
10
|
items: PopupInfo[];
|
|
@@ -19,9 +19,9 @@ export interface PopupBaseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
19
19
|
placement?: PopupBasePlacement;
|
|
20
20
|
offset?: [number, number] | [string, string];
|
|
21
21
|
/**
|
|
22
|
-
* В каком контейнере позиционируется(по умолчанию document)
|
|
22
|
+
* В каком контейнере позиционируется(по умолчанию document), можно также указать id элемента или ref для него.
|
|
23
23
|
*/
|
|
24
|
-
frame?: 'document' | React.RefObject<HTMLElement>;
|
|
24
|
+
frame?: 'document' | string | React.RefObject<HTMLElement>;
|
|
25
25
|
/**
|
|
26
26
|
* Содержимое PopupBase.
|
|
27
27
|
*/
|
|
@@ -39,9 +39,9 @@ export interface PopupBaseProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
39
39
|
*/
|
|
40
40
|
popupInfo?: PopupInfo;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Использовать ли анимацию.
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
withAnimation?: boolean;
|
|
45
45
|
}
|
|
46
46
|
export interface PopupAnimationInfo {
|
|
47
47
|
endAnimation: boolean;
|
|
@@ -52,8 +52,12 @@ export interface PopupAnimationInfo {
|
|
|
52
52
|
export interface PopupRootProps extends Omit<PopupBaseProps, 'isOpen' | 'overlay'> {
|
|
53
53
|
id: string;
|
|
54
54
|
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
55
|
+
/**
|
|
56
|
+
* Данные из хука usePopupAnimation.
|
|
57
|
+
*/
|
|
58
|
+
animationInfo: PopupAnimationInfo;
|
|
55
59
|
}
|
|
56
|
-
export interface PopupHookArgs extends Pick<PopupBaseProps, 'isOpen' | 'popupInfo' | '
|
|
60
|
+
export interface PopupHookArgs extends Pick<PopupBaseProps, 'isOpen' | 'popupInfo' | 'withAnimation'> {
|
|
57
61
|
id: string;
|
|
58
62
|
}
|
|
59
63
|
export interface PopupRootContainerProps extends Omit<PopupBaseProps, 'isOpen' | 'overlay'> {
|
|
@@ -1 +1,4 @@
|
|
|
1
|
+
export declare const popupBaseRootClass = "popup-base-root";
|
|
2
|
+
export declare const endAnimationClass = "popup-base-end-animation";
|
|
3
|
+
export declare const endTransitionClass = "popup-base-end-transition";
|
|
1
4
|
export declare const handlePosition: (placement?: "center" | "left" | "right" | "top" | "bottom" | "top-right" | "top-left" | "bottom-right" | "bottom-left" | undefined, offset?: [number, number] | [string, string] | undefined) => import("styled-components").FlattenSimpleInterpolation;
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.handlePosition = void 0;
|
|
6
|
+
exports.handlePosition = exports.endTransitionClass = exports.endAnimationClass = exports.popupBaseRootClass = void 0;
|
|
7
7
|
|
|
8
8
|
var _styledComponents = /*#__PURE__*/require("styled-components");
|
|
9
9
|
|
|
10
|
+
var _collectPackageInfo = /*#__PURE__*/require("../../collectPackageInfo");
|
|
11
|
+
|
|
10
12
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
13
|
|
|
12
14
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -19,6 +21,18 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
19
21
|
|
|
20
22
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
23
|
|
|
24
|
+
(0, _collectPackageInfo.collectPackageInfo)('PopupBase/utils');
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* Класс корневого компонента PopupBaseRoot: `popup-base-root`
|
|
28
|
+
*/
|
|
29
|
+
var popupBaseRootClass = 'popup-base-root';
|
|
30
|
+
exports.popupBaseRootClass = popupBaseRootClass;
|
|
31
|
+
var endAnimationClass = 'popup-base-end-animation';
|
|
32
|
+
exports.endAnimationClass = endAnimationClass;
|
|
33
|
+
var endTransitionClass = 'popup-base-end-transition';
|
|
34
|
+
exports.endTransitionClass = endTransitionClass;
|
|
35
|
+
|
|
22
36
|
var handlePosition = function handlePosition(placement, offset) {
|
|
23
37
|
var x = '0rem';
|
|
24
38
|
var y = '0rem';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _NoScroll;
|
|
2
2
|
|
|
3
|
-
var _excluded = ["id", "
|
|
3
|
+
var _excluded = ["id", "withAnimation", "onClose", "onOverlayClick", "onEscKeyDown", "closeOnEsc", "closeOnOverlayClick", "withBlur", "initialFocusRef", "focusAfterRef", "zIndex", "popupInfo", "children"];
|
|
4
4
|
|
|
5
5
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6
6
|
|
|
@@ -24,7 +24,7 @@ var NoScroll = /*#__PURE__*/createGlobalStyle(["body{overflow-y:hidden;}"]);
|
|
|
24
24
|
|
|
25
25
|
export var ModalBase = function ModalBase(_ref) {
|
|
26
26
|
var id = _ref.id,
|
|
27
|
-
|
|
27
|
+
withAnimation = _ref.withAnimation,
|
|
28
28
|
onClose = _ref.onClose,
|
|
29
29
|
onOverlayClick = _ref.onOverlayClick,
|
|
30
30
|
onEscKeyDown = _ref.onEscKeyDown,
|
|
@@ -57,14 +57,13 @@ export var ModalBase = function ModalBase(_ref) {
|
|
|
57
57
|
id: id,
|
|
58
58
|
ref: trapRef,
|
|
59
59
|
popupInfo: modalInfo,
|
|
60
|
-
|
|
60
|
+
withAnimation: withAnimation,
|
|
61
61
|
zIndex: zIndex,
|
|
62
62
|
overlay: /*#__PURE__*/React.createElement(ModalOverlay, {
|
|
63
63
|
id: innerId,
|
|
64
64
|
withBlur: withBlur,
|
|
65
65
|
onOverlayClick: onOverlayClick,
|
|
66
66
|
onClose: onClose,
|
|
67
|
-
animationInfo: animationInfo,
|
|
68
67
|
zIndex: zIndex,
|
|
69
68
|
closeOnOverlayClick: closeOnOverlayClick
|
|
70
69
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["id", "withBlur", "onOverlayClick", "onClose", "
|
|
1
|
+
var _excluded = ["id", "withBlur", "onOverlayClick", "onClose", "zIndex", "closeOnOverlayClick"];
|
|
2
2
|
|
|
3
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
10
10
|
import styled, { css } from 'styled-components';
|
|
11
11
|
import { DEFAULT_Z_INDEX } from '../PopupBase/PopupBaseRoot';
|
|
12
12
|
import { usePopupBaseContext } from '../PopupBase';
|
|
13
|
-
import {
|
|
13
|
+
import { getIdLastModal } from './ModalBaseContext';
|
|
14
14
|
import { collectPackageInfo } from '../../collectPackageInfo';
|
|
15
15
|
collectPackageInfo('ModalBase/ModalOverlay');
|
|
16
16
|
|
|
@@ -43,7 +43,6 @@ export var ModalOverlay = function ModalOverlay(_ref5) {
|
|
|
43
43
|
withBlur = _ref5.withBlur,
|
|
44
44
|
onOverlayClick = _ref5.onOverlayClick,
|
|
45
45
|
onClose = _ref5.onClose,
|
|
46
|
-
animationInfo = _ref5.animationInfo,
|
|
47
46
|
zIndex = _ref5.zIndex,
|
|
48
47
|
_ref5$closeOnOverlayC = _ref5.closeOnOverlayClick,
|
|
49
48
|
closeOnOverlayClick = _ref5$closeOnOverlayC === void 0 ? true : _ref5$closeOnOverlayC,
|
|
@@ -67,14 +66,10 @@ export var ModalOverlay = function ModalOverlay(_ref5) {
|
|
|
67
66
|
var transparent = useMemo(function () {
|
|
68
67
|
return getIdLastModal(popupController.items) !== id;
|
|
69
68
|
}, [id, popupController.items]);
|
|
70
|
-
var endAnimation = useMemo(function () {
|
|
71
|
-
return getIdFirstModal(popupController.items) === id && (animationInfo === null || animationInfo === void 0 ? void 0 : animationInfo.endAnimation);
|
|
72
|
-
}, [id, popupController.items]);
|
|
73
69
|
return /*#__PURE__*/React.createElement(Overlay, _extends({
|
|
74
70
|
className: modalBaseOverlayClass,
|
|
75
71
|
transparent: transparent,
|
|
76
72
|
clickable: closeOnOverlayClick,
|
|
77
|
-
endAnimation: endAnimation,
|
|
78
73
|
onClick: onModalOverlayKeyDown,
|
|
79
74
|
zIndex: zIndex,
|
|
80
75
|
$withBlur: withBlur
|
|
@@ -7,8 +7,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
import { useCallback, useEffect } from 'react';
|
|
8
8
|
import { usePopupBaseContext } from '../PopupBase';
|
|
9
9
|
import { getIdLastModal } from './ModalBaseContext';
|
|
10
|
-
import { collectPackageInfo } from '../../collectPackageInfo';
|
|
11
|
-
collectPackageInfo('ModalBase/hooks');
|
|
12
10
|
var ESCAPE_KEYCODE = 27;
|
|
13
11
|
export var useModal = function useModal(_ref) {
|
|
14
12
|
var id = _ref.id,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
var _excluded = ["id", "isOpen", "placement", "offset", "frame", "children", "overlay", "role", "zIndex", "popupInfo", "
|
|
1
|
+
var _excluded = ["id", "isOpen", "placement", "offset", "frame", "children", "overlay", "role", "zIndex", "popupInfo", "withAnimation", "className"];
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
4
|
|
|
3
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
6
|
|
|
@@ -16,23 +18,29 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
16
18
|
|
|
17
19
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
20
|
|
|
19
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
21
|
+
import React, { useEffect, useRef, useState, forwardRef } from 'react';
|
|
20
22
|
import ReactDOM from 'react-dom';
|
|
21
23
|
import styled from 'styled-components';
|
|
22
24
|
import { useForkRef, useUniqId } from '../../hooks';
|
|
23
25
|
import { POPOVER_PORTAL_ID } from './PopupBaseContext';
|
|
24
26
|
import { PopupBaseRoot } from './PopupBaseRoot';
|
|
25
27
|
import { usePopup } from './hooks';
|
|
28
|
+
import { endAnimationClass, endTransitionClass } from './utils';
|
|
26
29
|
import { collectPackageInfo } from '../../collectPackageInfo';
|
|
27
30
|
collectPackageInfo('PopupBase/PopupBase');
|
|
28
31
|
var StyledPortal = /*#__PURE__*/styled.div.withConfig({
|
|
29
32
|
componentId: "plasma__sc-1md4coi-0"
|
|
30
33
|
})([""]);
|
|
34
|
+
export var getClassName = function getClassName(animationInfo, className) {
|
|
35
|
+
var endAnimation = animationInfo !== null && animationInfo !== void 0 && animationInfo.endAnimation ? endAnimationClass : '';
|
|
36
|
+
var endTransition = animationInfo !== null && animationInfo !== void 0 && animationInfo.endTransition ? endTransitionClass : '';
|
|
37
|
+
return [className, endAnimation, endTransition].filter(Boolean).join(' ');
|
|
38
|
+
};
|
|
31
39
|
/**
|
|
32
40
|
* Базовый копмонент PopupBase.
|
|
33
41
|
*/
|
|
34
42
|
|
|
35
|
-
export var PopupBase = /*#__PURE__*/
|
|
43
|
+
export var PopupBase = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
36
44
|
var id = _ref.id,
|
|
37
45
|
isOpen = _ref.isOpen,
|
|
38
46
|
_ref$placement = _ref.placement,
|
|
@@ -46,7 +54,9 @@ export var PopupBase = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
46
54
|
role = _ref.role,
|
|
47
55
|
zIndex = _ref.zIndex,
|
|
48
56
|
popupInfo = _ref.popupInfo,
|
|
49
|
-
|
|
57
|
+
_ref$withAnimation = _ref.withAnimation,
|
|
58
|
+
withAnimation = _ref$withAnimation === void 0 ? false : _ref$withAnimation,
|
|
59
|
+
className = _ref.className,
|
|
50
60
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
51
61
|
|
|
52
62
|
var uniqId = useUniqId();
|
|
@@ -56,9 +66,10 @@ export var PopupBase = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
56
66
|
isOpen: isOpen,
|
|
57
67
|
id: innerId,
|
|
58
68
|
popupInfo: popupInfo,
|
|
59
|
-
|
|
69
|
+
withAnimation: withAnimation
|
|
60
70
|
}),
|
|
61
71
|
isVisible = _usePopup.isVisible,
|
|
72
|
+
animationInfo = _usePopup.animationInfo,
|
|
62
73
|
setVisible = _usePopup.setVisible;
|
|
63
74
|
|
|
64
75
|
var portalRef = useRef(null);
|
|
@@ -72,19 +83,26 @@ export var PopupBase = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
72
83
|
useEffect(function () {
|
|
73
84
|
var portal = document.getElementById(POPOVER_PORTAL_ID);
|
|
74
85
|
|
|
75
|
-
if (frame !== '
|
|
86
|
+
if (typeof frame !== 'string' && frame && frame.current) {
|
|
76
87
|
portal = frame.current;
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
if (!portal) {
|
|
80
91
|
portal = document.createElement('div');
|
|
81
92
|
portal.setAttribute('id', POPOVER_PORTAL_ID);
|
|
82
|
-
|
|
93
|
+
|
|
94
|
+
if (typeof frame === 'string' && frame !== 'document') {
|
|
95
|
+
var _document$getElementB;
|
|
96
|
+
|
|
97
|
+
(_document$getElementB = document.getElementById(frame)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.appendChild(portal);
|
|
98
|
+
} else {
|
|
99
|
+
document.body.appendChild(portal);
|
|
100
|
+
}
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
portalRef.current = portal;
|
|
86
104
|
/**
|
|
87
|
-
* Изменение стейта нужно для того, чтобы
|
|
105
|
+
* Изменение стейта нужно для того, чтобы Popup
|
|
88
106
|
* отобразился после записи DOM элемента в portalRef.current
|
|
89
107
|
*/
|
|
90
108
|
|
|
@@ -95,7 +113,9 @@ export var PopupBase = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
95
113
|
return null;
|
|
96
114
|
}
|
|
97
115
|
|
|
98
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, portalRef.current && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(StyledPortal,
|
|
116
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, portalRef.current && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(StyledPortal, _extends({
|
|
117
|
+
className: getClassName(animationInfo, className)
|
|
118
|
+
}, rest), overlay, /*#__PURE__*/React.createElement(PopupBaseRoot, {
|
|
99
119
|
id: innerId,
|
|
100
120
|
ref: innerRef,
|
|
101
121
|
placement: placement,
|
|
@@ -18,12 +18,12 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
18
18
|
|
|
19
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
20
|
|
|
21
|
-
import React, { useEffect } from 'react';
|
|
21
|
+
import React, { useEffect, useState, createContext, useContext } from 'react';
|
|
22
22
|
import { collectPackageInfo } from '../../collectPackageInfo';
|
|
23
23
|
collectPackageInfo('PopupBase/PopupBaseContext');
|
|
24
24
|
export var POPOVER_PORTAL_ID = 'plasma-popup-root';
|
|
25
25
|
var items = [];
|
|
26
|
-
var PopupBaseContext = /*#__PURE__*/
|
|
26
|
+
var PopupBaseContext = /*#__PURE__*/createContext({
|
|
27
27
|
items: items,
|
|
28
28
|
register: function register(_info) {
|
|
29
29
|
throw new Error('Function not implemented. Add PopupBaseProvider');
|
|
@@ -33,21 +33,18 @@ var PopupBaseContext = /*#__PURE__*/React.createContext({
|
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
export var usePopupBaseContext = function usePopupBaseContext() {
|
|
36
|
-
return
|
|
36
|
+
return useContext(PopupBaseContext);
|
|
37
37
|
};
|
|
38
38
|
export var PopupBaseProvider = function PopupBaseProvider(_ref) {
|
|
39
39
|
var children = _ref.children;
|
|
40
40
|
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
items =
|
|
44
|
-
setItems =
|
|
41
|
+
var _useState = useState([]),
|
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
+
items = _useState2[0],
|
|
44
|
+
setItems = _useState2[1];
|
|
45
45
|
|
|
46
46
|
var register = function register(info) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
updatedItems.push(info);
|
|
50
|
-
setItems(updatedItems);
|
|
47
|
+
setItems([].concat(_toConsumableArray(items), [info]));
|
|
51
48
|
};
|
|
52
49
|
|
|
53
50
|
var unregister = function unregister(id) {
|
|
@@ -10,15 +10,8 @@ import React, { useCallback, useRef } from 'react';
|
|
|
10
10
|
import styled, { css } from 'styled-components';
|
|
11
11
|
import { useForkRef } from '../../hooks';
|
|
12
12
|
import { usePopupBaseContext } from './PopupBaseContext';
|
|
13
|
-
import { handlePosition } from './utils';
|
|
14
|
-
import { collectPackageInfo } from '../../collectPackageInfo';
|
|
15
|
-
collectPackageInfo('PopupBase/PopupBaseRoot');
|
|
13
|
+
import { handlePosition, popupBaseRootClass } from './utils';
|
|
16
14
|
export var DEFAULT_Z_INDEX = 9000;
|
|
17
|
-
/*
|
|
18
|
-
* Класс корневого компонента PopupBaseRoot: `popup-base-root`
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
export var popupBaseRootClass = 'popup-base-root';
|
|
22
15
|
var PopupBaseView = /*#__PURE__*/styled.div.withConfig({
|
|
23
16
|
componentId: "plasma__sc-14025jn-0"
|
|
24
17
|
})(["position:relative;max-width:100%;pointer-events:all;"]);
|
|
@@ -67,7 +60,7 @@ export var PopupBaseRoot = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
|
67
60
|
setVisible(false);
|
|
68
61
|
animationInfo.setEndAnimation(false);
|
|
69
62
|
}
|
|
70
|
-
}, [popupController.unregister, animationInfo, setVisible]);
|
|
63
|
+
}, [popupController.unregister, animationInfo === null || animationInfo === void 0 ? void 0 : animationInfo.endAnimation, setVisible]);
|
|
71
64
|
return /*#__PURE__*/React.createElement(PopupRootContainer, _extends({
|
|
72
65
|
className: popupBaseRootClass,
|
|
73
66
|
ref: innerRef,
|
|
@@ -19,8 +19,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
19
19
|
import { useEffect, useState } from 'react';
|
|
20
20
|
import { usePopupBaseContext } from './PopupBaseContext'; // Хук для поключения анимации
|
|
21
21
|
|
|
22
|
-
import { collectPackageInfo } from '../../collectPackageInfo';
|
|
23
|
-
collectPackageInfo('PopupBase/hooks');
|
|
24
22
|
export var usePopupAnimation = function usePopupAnimation() {
|
|
25
23
|
var _useState = useState(false),
|
|
26
24
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -44,18 +42,21 @@ export var usePopup = function usePopup(_ref) {
|
|
|
44
42
|
var isOpen = _ref.isOpen,
|
|
45
43
|
id = _ref.id,
|
|
46
44
|
popupInfo = _ref.popupInfo,
|
|
47
|
-
|
|
45
|
+
withAnimation = _ref.withAnimation;
|
|
48
46
|
|
|
49
47
|
var _useState5 = useState(false),
|
|
50
48
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
51
49
|
isVisible = _useState6[0],
|
|
52
50
|
setVisible = _useState6[1];
|
|
53
51
|
|
|
54
|
-
var popupController = usePopupBaseContext();
|
|
52
|
+
var popupController = usePopupBaseContext();
|
|
53
|
+
var animationInfo = usePopupAnimation(); // для использования transition в качестве анимации
|
|
55
54
|
|
|
56
55
|
useEffect(function () {
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
if (withAnimation && animationInfo) {
|
|
57
|
+
animationInfo.setEndTransition(!isVisible || (animationInfo === null || animationInfo === void 0 ? void 0 : animationInfo.endAnimation));
|
|
58
|
+
}
|
|
59
|
+
}, [animationInfo, withAnimation, isVisible]); // сначала добавление/удаление из контекста, и только после этого отображение/скрытие
|
|
59
60
|
|
|
60
61
|
useEffect(function () {
|
|
61
62
|
// при первом открытии
|
|
@@ -64,7 +65,7 @@ export var usePopup = function usePopup(_ref) {
|
|
|
64
65
|
id: id
|
|
65
66
|
}, popupInfo));
|
|
66
67
|
setVisible(true);
|
|
67
|
-
animationInfo
|
|
68
|
+
animationInfo.setEndAnimation(false);
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -73,17 +74,18 @@ export var usePopup = function usePopup(_ref) {
|
|
|
73
74
|
} // если есть анимация - закрытие по окончании анимации
|
|
74
75
|
|
|
75
76
|
|
|
76
|
-
if (
|
|
77
|
-
animationInfo
|
|
77
|
+
if (withAnimation) {
|
|
78
|
+
animationInfo.setEndAnimation(true);
|
|
78
79
|
return;
|
|
79
80
|
} // иначе обычное закрытие
|
|
80
81
|
|
|
81
82
|
|
|
82
83
|
popupController.unregister(id);
|
|
83
84
|
setVisible(false);
|
|
84
|
-
}, [isOpen, isVisible, animationInfo]);
|
|
85
|
+
}, [isOpen, isVisible, animationInfo, withAnimation]);
|
|
85
86
|
return {
|
|
86
87
|
isVisible: isVisible,
|
|
87
|
-
setVisible: setVisible
|
|
88
|
+
setVisible: setVisible,
|
|
89
|
+
animationInfo: animationInfo
|
|
88
90
|
};
|
|
89
91
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { PopupBaseProvider, usePopupBaseContext } from './PopupBaseContext';
|
|
2
2
|
export { PopupBase } from './PopupBase';
|
|
3
|
-
export {
|
|
4
|
-
export { PopupBaseRoot, popupBaseRootClass } from './PopupBaseRoot';
|
|
3
|
+
export { popupBaseRootClass, endAnimationClass, endTransitionClass } from './utils';
|
|
@@ -11,6 +11,15 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
13
|
import { css } from 'styled-components';
|
|
14
|
+
import { collectPackageInfo } from '../../collectPackageInfo';
|
|
15
|
+
collectPackageInfo('PopupBase/utils');
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Класс корневого компонента PopupBaseRoot: `popup-base-root`
|
|
19
|
+
*/
|
|
20
|
+
export var popupBaseRootClass = 'popup-base-root';
|
|
21
|
+
export var endAnimationClass = 'popup-base-end-animation';
|
|
22
|
+
export var endTransitionClass = 'popup-base-end-transition';
|
|
14
23
|
export var handlePosition = function handlePosition(placement, offset) {
|
|
15
24
|
var x = '0rem';
|
|
16
25
|
var y = '0rem';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salutejs/plasma-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.137.0-dev.0",
|
|
4
4
|
"description": "Core library for Plasma: Salute Design System",
|
|
5
5
|
"author": "Salute Frontend Team <salute.developers@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"react-draggable": "4.4.3",
|
|
82
82
|
"react-popper": "2.3.0"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "18613ec93b0f813fb1cc97f0af0adc5310d25523"
|
|
85
85
|
}
|